blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 3
264
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
85
| license_type
stringclasses 2
values | repo_name
stringlengths 5
140
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 986
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 3.89k
681M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 23
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 145
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
10.4M
| extension
stringclasses 122
values | content
stringlengths 3
10.4M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
158
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
98118f0fb48ff3e1f504eea13c9f2f18a200fb36 | 7b9e626cfc3aa45ff44f79b0fb31b782a17d6c98 | /src/functors/lattice/blockReduction2D1D.cpp | bf6cfe10c3b84cc0667c66f85d67b9c081ac428e | [] | no_license | lex16000/LBv1.2 | e95b1b42925aaa892e6099be83496a0a56271dff | cee82cc6fe75d2f9b25a9f62ce8d50d3480c47ac | refs/heads/master | 2021-04-06T01:41:48.099885 | 2018-04-04T12:01:09 | 2018-04-04T12:01:09 | 125,254,173 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,086 | cpp | /* This file is part of the OpenLB library
*
* Copyright (C) 2018 Adrian Kummerländer
* E-mail contact: [email protected]
* The most recent release of OpenLB can be downloaded at
* <http://www.openlb.net/>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "blockReduction2D1D.h"
#include "blockReduction2D1D.hh"
namespace olb {
template class BlockReduction2D1D<double>;
}
| [
"[email protected]"
] | |
eaca35ffd8d1751217ad74cce26acc950fc48cdf | 71734273f0efd015e771aeb8026e2cdb045870cc | /cef/libcef_dll/cpptoc/post_data_element_cpptoc.cc | 4f21d7a8751c39d7615e764505f01b0536e54858 | [
"Apache-2.0"
] | permissive | killvxk/miniblink49 | 6efc4ff4a65eaface992d6bf02e537caa9131ed2 | ff3d0e133d18de1748c688b0c0e173965db17033 | refs/heads/master | 2020-03-18T01:43:40.001114 | 2019-04-27T12:11:45 | 2019-04-27T12:11:45 | 134,156,673 | 1 | 0 | MIT | 2019-04-27T12:11:46 | 2018-05-20T14:17:42 | C++ | UTF-8 | C++ | false | false | 5,266 | cc | // Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#if (defined ENABLE_CEF) && (ENABLE_CEF == 1)
#include "libcef_dll/cpptoc/post_data_element_cpptoc.h"
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_post_data_element_t* cef_post_data_element_create() {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
CefRefPtr<CefPostDataElement> _retval = CefPostDataElement::Create();
// Return type: refptr_same
return CefPostDataElementCppToC::Wrap(_retval);
}
namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK post_data_element_is_read_only(
struct _cef_post_data_element_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefPostDataElementCppToC::Get(self)->IsReadOnly();
// Return type: bool
return _retval;
}
void CEF_CALLBACK post_data_element_set_to_empty(
struct _cef_post_data_element_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Execute
CefPostDataElementCppToC::Get(self)->SetToEmpty();
}
void CEF_CALLBACK post_data_element_set_to_file(
struct _cef_post_data_element_t* self, const cef_string_t* fileName) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: fileName; type: string_byref_const
DCHECK(fileName);
if (!fileName)
return;
// Execute
CefPostDataElementCppToC::Get(self)->SetToFile(
CefString(fileName));
}
void CEF_CALLBACK post_data_element_set_to_bytes(
struct _cef_post_data_element_t* self, size_t size, const void* bytes) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: bytes; type: simple_byaddr
DCHECK(bytes);
if (!bytes)
return;
// Execute
CefPostDataElementCppToC::Get(self)->SetToBytes(
size,
bytes);
}
cef_postdataelement_type_t CEF_CALLBACK post_data_element_get_type(
struct _cef_post_data_element_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return PDE_TYPE_EMPTY;
// Execute
cef_postdataelement_type_t _retval = CefPostDataElementCppToC::Get(
self)->GetType();
// Return type: simple
return _retval;
}
cef_string_userfree_t CEF_CALLBACK post_data_element_get_file(
struct _cef_post_data_element_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefPostDataElementCppToC::Get(self)->GetFile();
// Return type: string
return _retval.DetachToUserFree();
}
size_t CEF_CALLBACK post_data_element_get_bytes_count(
struct _cef_post_data_element_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
size_t _retval = CefPostDataElementCppToC::Get(self)->GetBytesCount();
// Return type: simple
return _retval;
}
size_t CEF_CALLBACK post_data_element_get_bytes(
struct _cef_post_data_element_t* self, size_t size, void* bytes) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: bytes; type: simple_byaddr
DCHECK(bytes);
if (!bytes)
return 0;
// Execute
size_t _retval = CefPostDataElementCppToC::Get(self)->GetBytes(
size,
bytes);
// Return type: simple
return _retval;
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
CefPostDataElementCppToC::CefPostDataElementCppToC() {
GetStruct()->is_read_only = post_data_element_is_read_only;
GetStruct()->set_to_empty = post_data_element_set_to_empty;
GetStruct()->set_to_file = post_data_element_set_to_file;
GetStruct()->set_to_bytes = post_data_element_set_to_bytes;
GetStruct()->get_type = post_data_element_get_type;
GetStruct()->get_file = post_data_element_get_file;
GetStruct()->get_bytes_count = post_data_element_get_bytes_count;
GetStruct()->get_bytes = post_data_element_get_bytes;
}
template<> CefRefPtr<CefPostDataElement> CefCppToC<CefPostDataElementCppToC,
CefPostDataElement, cef_post_data_element_t>::UnwrapDerived(
CefWrapperType type, cef_post_data_element_t* s) {
NOTREACHED() << "Unexpected class type: " << type;
return NULL;
}
#ifndef NDEBUG
template<> base::AtomicRefCount CefCppToC<CefPostDataElementCppToC,
CefPostDataElement, cef_post_data_element_t>::DebugObjCt = 0;
#endif
template<> CefWrapperType CefCppToC<CefPostDataElementCppToC,
CefPostDataElement, cef_post_data_element_t>::kWrapperType =
WT_POST_DATA_ELEMENT;
#endif
| [
"[email protected]"
] | |
3b7c051a9c94b036a3cb39ae8f89b37531d95f20 | 2572a2dc50392495be992c1f5b9225feac707dce | /CodeChef/STRSUB.cpp | ebc8491383eb20db7200a8606e5ca0869b481d9f | [] | no_license | agentmishra/DSA | f60aabb0c77f07a665944f224935103b29cedcf5 | 63cd024bafec0b25e150b51b88e4563e31a62ef9 | refs/heads/master | 2023-03-25T23:44:44.199513 | 2021-01-02T16:00:08 | 2021-01-02T16:00:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,732 | cpp | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define ll long long
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define nl "\n";
#define loop(from,to) for(int i=from;i<to;i++)
#define OJ \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
#define fastio \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
signed main()
{
OJ;
fastio;
int t;
cin >> t;
while (t--)
{
// maps biggest L->R
map<int,int> seq;
int n, limit, q;
cin >> n >> limit >> q;
// indexing from 1
vector<int> a(n + 1, 0);
string s;
cin >> s;
loop(1 ,n + 1)
a[i] = s[i - 1] - '0';
int start, end;
vector<pair<int, int>> queries;
loop(0, q)
{
cin >> start >> end;
queries.push_back({start, end});
}
// min substring length
int maxlength = 2*limit;
int index;
// Precompute far[i]
// far[i] is the first value for the ith character such that the substring becomes invalid
vector<int> far(n + 1,0);
// sumfar because for each i we need sum from i=L to a valid K. so precompute
vector<int> sumfar(n + 1,0);
int j = 1;
int count1 = 0, count0 = 0;
if(a[j])
count1++;
else
count0++;
loop(1, n+1)
{
while(j<=n and count1<=limit and count0<=limit)
{
j++;
if(j>n)
break;
if(a[j])
count1++;
else
count0++;
}
// first invalid j
far[i] = j;
// subtract for next i
if(a[i])
count1--;
else
count0--;
}
sumfar[0] = 0;
loop(1, n +1)
sumfar[i] = sumfar[i - 1] + far[i];
loop(0 ,q)
{
/*
Substring generation
a b c d
a->ab->abc->abcd
b->bc->bcd
c->cd
Now what we can do is:
2 3 4 5 6
For substrings starting with i(2),
if there is some j_(5) which satisfies then defenitly
then i+1(3) to j_ will defently satisfy so instead of evaluating
from from j=1 for i+1, we can start from j_ + 1,
and for computing the sum what we can do is subtract accordingly according
to the value at i(2) since now we are starting from i+1
Next optimization
We know that substrings starting with the ith character has a j_ + 1, such that it is invalid here onwards
Now lets denote this invalid number for the ith character as j, this number is either > end or not greater than end
Lets denote the true invalid which is out of range of R as far[i] which we will compute beforehand
i.e. j = min(far[i], R + 1)
either of them is the invalid one and thats what we need when we compute for each ith char
i.e here ans += j - i
Now our algo becomes:
def answer_query(L, R):
answer = 0
for i in L...R
j = min(far[i], R+1) # R+1 is the first j such that j > R
answer += j - i
return answer
Since far is a montonous function, We can simplify the equation and binary search on the first k for far[k] such that
far[k] <= R
because at the first when far[i] will be less than R
*/
ll ans = 0;
start = queries[i].first, end = queries[i].second;
int low = start - 1;
int high = end + 1;
// We need to find such k fo far[k] such that it is the last k for which far[k] <= R and far[k + 1] > R
while(high - low > 1)
{
int mid = (low + high)/2;
if(far[mid] <= end)
low = mid;
else
high = mid;
}
int val = low;
ans = sumfar[val] - sumfar[start - 1] + (end - val) * (end + 1) - (end*(end + 1)/2 - start*(start - 1)/2);
cout<<ans<<nl
}
}
return 0;
}
| [
"[email protected]"
] | |
fb537fb4ec0010a33d7c719a432ea04e0976ec6e | 3d01c099673783c2f84146dc9dbd05e0bd60d5b8 | /include/sancus_fd.h | 0757ac737e73b756b85a1a976bdad5a7fac84ebb | [] | no_license | sancus-project/sancus-core-old | 58aa3544c8f34c289efa5b6a4e28c60783b41fbd | 712c8f38caca2aeca205dca01bfbc820e8135efd | refs/heads/master | 2016-09-10T04:32:00.321564 | 2011-12-06T19:20:14 | 2011-12-06T19:20:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,482 | h | /*
* This file is part of sancus-core <http://github.com/amery/sancus-core>
*
* Copyright (c) 2010-2011, Alejandro Mery <[email protected]>
* 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 the author 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 <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _SANCUS_FD_H
#define _SANCUS_FD_H
#ifdef _FCNTL_H
static inline int sancus_open(const char *pathname, int flags, int cloexec, mode_t mode)
{
int fd;
#ifdef O_CLOEXEC
if (cloexec)
flags |= O_CLOEXEC;
else
flags &= ~O_CLOEXEC;
#endif
try_open:
if ((fd = open(pathname, flags, mode)) < 0) {
if (errno == EINTR)
goto try_open;
else
goto open_done;
}
if (cloexec) {
int fl = fcntl(fd, F_GETFL);
if (fl < 0)
goto open_failed;
#ifdef O_CLOEXEC
if ((fl & FD_CLOEXEC) == 0)
#endif
if (fcntl(fd, F_SETFL, fl|FD_CLOEXEC) < 0) {
goto open_failed;
}
}
goto open_done;
open_failed:
close(fd);
fd = -1;
open_done:
return fd;
}
#endif /* _FCNTL_H */
static inline int sancus_close(int *fd)
{
int ret = 0;
if (fd != NULL && *fd >= 0) {
try_close:
ret = close(*fd);
if (ret == -1 && errno == EINTR)
goto try_close;
*fd = -1;
}
return ret;
}
static inline ssize_t sancus_write(int fd, const char *data, size_t size)
{
int wc, wt = 0;
while (size) {
try_write:
wc = write(fd, data, size);
if (unlikely(wc < 0)) {
if (errno == EINTR)
goto try_write;
return wc;
}
wt += wc;
size -= wc;
data += wc;
}
return wt;
}
#ifdef _SYS_UIO_H
static inline ssize_t sancus_writev(int fd, struct iovec *iov, int iovcnt)
{
int wt = 0;
while (iovcnt) {
register int wc;
try_write:
wc = writev(fd, iov, iovcnt);
if (unlikely(wc < 0)) {
if (errno == EINTR)
goto try_write;
return wc;
}
wt += wc;
while (wc) {
if ((unsigned)wc >= iov->iov_len) {
wc -= iov->iov_len;
iovcnt--;
iov++;
} else {
iov->iov_len -= wc;
/* GCC: warning: pointer of type ‘void *’ used in arithmetic */
iov->iov_base = (char*)iov->iov_base+wc;
wc = 0;
}
}
}
return wt;
}
#endif /* _SYS_UIO_H */
#endif /* !_SANCUS_FD_H */
| [
"[email protected]"
] | |
788e178cfde1695fe886c153ed6503fa21e4cb3a | 7d1cc7ee88219f5ffeff36fd81da8058c7f04d03 | /BFGS/Cpp/examples/bealeFunction.cpp | fbe0ff0ac5467a99a4962f44236b2161798c160e | [] | no_license | dnhsieh/Optimization | 243737a59d4bc34c8d5d2e242e7034aabd5e2977 | 980b62efde37072f7e266755b58ffa0fe76ad772 | refs/heads/main | 2023-04-29T22:47:20.439819 | 2021-05-12T02:42:37 | 2021-05-12T02:42:37 | 366,477,552 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 756 | cpp | #include "struct.h"
// global minimum : 0
// global minimizer: (3, 0.5)
void objgrd(double *fcnVal, double *grdVec, double *posVec, fcndata &fcnObj)
{
double xVal = posVec[0];
double yVal = posVec[1];
double f1Val = 1.5 + xVal * (-1.0 + yVal );
double f2Val = 2.25 + xVal * (-1.0 + yVal * yVal );
double f3Val = 2.625 + xVal * (-1.0 + yVal * yVal * yVal);
*fcnVal = f1Val * f1Val + f2Val * f2Val + f3Val * f3Val;
grdVec[0] = 2 * f1Val * (-1.0 + yVal )
+ 2 * f2Val * (-1.0 + yVal * yVal )
+ 2 * f3Val * (-1.0 + yVal * yVal * yVal);
grdVec[1] = 2 * f1Val * xVal
+ 2 * f2Val * 2.0 * xVal * yVal
+ 2 * f3Val * 3.0 * xVal * yVal * yVal;
return;
}
| [
"[email protected]"
] | |
c1de9cc3e192c9440e768c76db0d6ee2e4194ec5 | 12e83a2eb7997a69865a1b0736a1f6034da76dd5 | /OOP5/at_home/Robot.cpp | cdec2d346674a7d161646c74ca5ef02a4e2d127d | [] | no_license | kimphuongtu135/OOP244 | 1157d86e7dfc1dfc5d8dbcb5821fc85dab46ed2e | 41abe9cdab170b1bc7138578a56208053deac272 | refs/heads/master | 2022-07-31T09:12:49.078877 | 2020-05-20T20:54:25 | 2020-05-20T20:54:25 | 265,682,503 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,988 | cpp | // Robot.cpp
// Robot.cpp
/*-------------------------
Name: Kim Phuong Tu
Student Number: 148886179
Date: OCT 12th, 2019
---------------------------*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include "Parts.h"
#include "Robot.h"
using namespace std;
namespace sdds {
//Set the empty state
Robot::Robot() {
nickname[0] = '\0';
durability = 0;
legs = 0;
}
Robot::Robot(const char* nick, int num, int sped,int dura) {
//Set value for nickname
if (nick == nullptr || nick[0] == '\0') {
nickname[0] = '\0';
durability = 0;
legs = 0;
}
else {
//Set the value for nickname
if (strlen(nick) > NICK_MAX_LEN)
strncpy(nickname, nick, NICK_MAX_LEN);
else
strcpy(nickname, nick);
//Set the value for durability
if (dura < 1)
durability = 100;
else
durability = dura;
//Set the value for arms's force
arms = Arms(num);
legs = Legs(sped);
}
}
ostream& Robot::display()const {
if (nickname[0] == '\0' && durability == 0) {
cout << "This Robot isn't operational" << endl;
}
else {
cout << "***Robot Summary***" << endl;
cout << "Nickname: " << nickname << endl;
cout << "Arm Power: " << arms.getForce() << endl;
cout << "Durability: " << durability << endl;
cout << "Legs: " << legs.getSpeed() << endl;
}
return cout;
}
// Return the value of arms class
Arms Robot::getArms()const {
return arms;
}
Legs Robot::getLegs()const {
return legs;
}
Robot::operator bool()const {
if (nickname[0] == '\0' || durability == 0)
return true;
else
return false;
}
Robot& Robot::operator-=(int num) {
durability -= num;
if (durability < 1)
durability = 0;
return *this;
}
void box(Robot& robot1, Robot& robot2) {
cout << "Attempting to begin a Robot boxing match" << endl;
if (robot1.operator bool() != true && robot2.operator bool() != true)
{
cout << "Both participants are operational... beginning the bout" << endl;
while (robot1.operator bool() != true && robot2.operator bool() != true)
{
if (robot1.getLegs() > robot2.getLegs()) //Compare which robot is faster than another one
{
robot2.operator-= (robot1.getArms().getForce());
if (robot2.operator bool() != true)
robot1.operator-= (robot2.getArms().getForce());
}
else {
robot1.operator-= (robot2.getArms().getForce());
if (robot1.operator bool() != true)
robot2.operator-= (robot1.getArms().getForce());
}
}
//Comparing which robot is KO first
if (robot1.operator bool() != true || robot2.operator bool() != true)
cout << "The bout has concluded... the winner is: " << endl;
//Finding the winner and display the information of winner
if (robot1.operator bool() != true)
robot1.display();
else
robot2.display();
}
else
cout << "At least one of the Robots isn't operational. No bout will be had." << endl;
}
}
| [
"[email protected]"
] | |
6dd247a725ae400d4db1fc388a7081f0413cbc86 | 4a4c1dcd29abe87745bb30adfbdf5205eb39f3b5 | /havok/Source/Physics/Collide/Shape/Compound/Collection/ExtendedMeshShape/hkpExtendedMeshShape.h | c45dd7806e234a212d644fe2fcfcea3165bad681 | [] | no_license | Hengle/ThirdParty | e7c4d794088712ec88bcea28a27f3acb71b6208c | a7ebed87d43e9cc58ec50836a2cc747bc539fd93 | refs/heads/master | 2023-03-16T04:24:59.905476 | 2014-01-20T16:54:54 | 2014-01-20T16:54:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,635 | h | /*
*
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Product and Trade Secret source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2012 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
#ifndef HKP_EXTENDED_MESH_SHAPE_H
#define HKP_EXTENDED_MESH_SHAPE_H
#include <Physics/Collide/Shape/Compound/Collection/hkpShapeCollection.h>
#include <Physics/Collide/Shape/Convex/Triangle/hkpTriangleShape.h>
extern const class hkClass hkpExtendedMeshShapeShapesSubpartClass;
extern const class hkClass hkpExtendedMeshShapeTrianglesSubpartClass;
extern const class hkClass hkpExtendedMeshShapeSubpartClass;
extern hkReal hkConvexShapeDefaultRadius;
extern const hkClass hkpExtendedMeshShapeClass;
class hkpMeshMaterial;
class hkpSimpleMeshShape;
class hkpMoppBvTreeShape;
/// A class for wrapping geometric collision detection information. It can directly reference
/// sets of triangle strips with vertex striding, and either 8, 16 or 32 bit indices to vertices.
/// It can also directly reference triangle soups, using three indices per triangle rather than one.
/// It also handles degenerate triangles internally, so no extra checking is required by the user.
/// The mesh shape creates hkTriangleShapes in the hkpShapeBuffer passed in to the getChildShape function.
/// It gives these shapes a radius (see hkpConvexShape::getRadius()) as specified by the hkpExtendedMeshShape::getRadius() function.
/// This class can also store lists of convex shapes.
class hkpExtendedMeshShape: public hkpShapeCollection
{
//+hk.ReflectedFile("hkpExtendedMeshShape")
//+version(4)
public:
HK_DECLARE_CLASS_ALLOCATOR(HK_MEMORY_CLASS_SHAPE);
HK_DECLARE_REFLECTION();
HKCD_DECLARE_SHAPE_TYPE(hkcdShapeType::EXTENDED_MESH);
/// The striding of mesh indices
enum IndexStridingType
{
INDICES_INVALID, ///< default, will raise assert.
INDICES_INT8, ///< 8 bit "single byte" striding.
INDICES_INT16, ///< 16 bit "short" striding.
INDICES_INT32, ///< 32 bit "int" striding.
INDICES_MAX_ID
};
enum MaterialIndexStridingType
{
MATERIAL_INDICES_INVALID = 0,
MATERIAL_INDICES_INT8 = 1,
MATERIAL_INDICES_INT16 = 2,
MATERIAL_INDICES_MAX_ID = 3,
};
enum SubpartType
{
SUBPART_TRIANGLES = 0,
SUBPART_SHAPE = 1,
SUBPART_TYPE_MAX = 2,
};
enum SubpartTypesAndFlags
{
SUBPART_TYPE_MASK = 0x0001, // Subpart type stored in the first bit
SUBPART_MATERIAL_INDICES_MASK = 0x0006, // Bits 2 and 3 used for material indices
SUBPART_MATERIAL_INDICES_SHIFT = 1,
SUBPART_NUM_MATERIALS_MASK = 0xFFF8, // Most significant 13 bits used for storing the number of materials
SUBPART_NUM_MATERIALS_SHIFT = 3,
};
/// A subpart.
struct Subpart
{
//+version(3)
public:
HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_COLLIDE, hkpExtendedMeshShape::Subpart );
HK_DECLARE_REFLECTION();
HK_DECLARE_POD_TYPE();
inline Subpart(SubpartType type);
Subpart(hkFinishLoadedObjectFlag flag) {}
/// Gets the subpart type
HK_FORCE_INLINE SubpartType getType() const;
/// Sets the subpart type
HK_FORCE_INLINE void setType(SubpartType newValue);
/// Gets the material index striding type
HK_FORCE_INLINE MaterialIndexStridingType getMaterialIndexStridingType() const;
/// Sets the material index striding type
HK_FORCE_INLINE void setMaterialIndexStridingType(MaterialIndexStridingType newValue);
/// Sets the number of materials
HK_FORCE_INLINE hkUint16 getNumMaterials() const;
/// Gets the number of materials
HK_FORCE_INLINE void setNumMaterials(hkUint16 newValue);
protected:
/// Stores the number of materials, material index striding type and subpart type
hkUint16 m_typeAndFlags;
public:
/// Stores a 16 bit shape info
hkUint16 m_shapeInfo;
/// The byte offset between two hkMeshMaterials
hkInt16 m_materialStriding; //+nosave
/// The byte offset between two material indices (Usually sizeof(hkUint8) or...)
hkUint16 m_materialIndexStriding;
/// A pointer, pointing to a strided array of material index (hkUint8), one index for each triangle.
/// - You are limited to a maximum of 256 materials per subpart.
/// - You are not forced to store those indices in a hkUint8 array, with the striding m_materialIndexStriding
/// parameter you can extract this
/// - If you do not want to use materials, simply set this element to HK_NULL
const void* m_materialIndexBase; //+nosave
/// The base for the material table, the byte offset between two hkMeshMaterials is defined by
/// m_materialStriding.
/// Note: On PlayStation(R)3 this must be aligned to a m_materialStriding boundary if you wish to access materials in your own code on SPU.
const hkpMeshMaterial* m_materialBase; //+nosave
/// User data associated with each subpart
hkUlong m_userData; //+default(0)
};
/// A subpart defining a triangle, a triangle list or a triangle strip.
struct TrianglesSubpart : public Subpart
{
//+version(3)
public:
HK_DECLARE_REFLECTION();
HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_COLLIDE, hkpExtendedMeshShape::TrianglesSubpart );
HK_DECLARE_POD_TYPE();
/// A partial initializing constructor. It will only set values in Debug
/// apart from a default material that gets set in Release too.
inline TrianglesSubpart();
/// Serialization constructor.
TrianglesSubpart(hkFinishLoadedObjectFlag flag) : Subpart(flag) {}
/// Set transform components
HK_FORCE_INLINE void setTranslation( hkVector4Parameter translation );
HK_FORCE_INLINE void setRotation( hkQuaternionParameter rotation );
HK_FORCE_INLINE void setScaling( hkVector4Parameter scaling );
/// Get transform components
HK_FORCE_INLINE const hkVector4& getTranslation() const;
HK_FORCE_INLINE const hkQuaternion& getRotation() const;
HK_FORCE_INLINE const hkVector4& getScaling() const;
public:
/// the number of triangles
int m_numTriangleShapes;
//
// Vertex information
//
/// A pointer to the first vertex, defined by three floats.
/// Must be aligned on a 16 byte boundary
const hkReal* m_vertexBase; //+nosave
/// The number of vertices.
int m_numVertices;
//
// Triangle Index Information
//
/// A pointer to triples of vertex indices.
/// Used to be a union type, but to make
/// auto serialization possible, we leave it as
/// a void* here.
const void* m_indexBase; //+nosave
/// The byte offset between two consecutive vertices (usually 12, 16 or more).
hkUint16 m_vertexStriding;
/// This information is set automatically when a subpart is added to a mesh and should be left at -1.
/// It is the offset in a global array for all triangles in the mesh of the first triangle of this sub piece.
/// This info is used for "welding" collisions between triangles.
int m_triangleOffset; //+default(-1)
/// The byte offset between two indices triples.
/// - E.g. (Usually sizeof(hkUint16) if you use triangle strips
/// - or 3 * sizeof(hkUint16) if you use independent triangles
hkUint16 m_indexStriding;
/// A type defining whether 8, 16, or 32 bits are used to index vertices.
hkEnum<IndexStridingType,hkInt8> m_stridingType;
/// A flag used to specify whether triangles should be returned wound the same way
/// or alternate ways. It must be set to 0 or 1, and defaults to 0.
/// If Triangle strips are used, each subsequent triangle in a list
/// will be wound the alternate way. However for one sided welding, we require that
/// all triangles have a consistent winding. This flag should be set to 1 in this case. This
/// means the first triangle will be returned with vertices set to (0, 1, 2) and the second
/// triangle will be returned with vertices set to (1, 3, 2). If this flag is set to 0 the
/// second triangle will be returned with vertices set to (1, 2, 3). If independent triangles
/// are used this flag should be set to 0 to maintain winding.
hkInt8 m_flipAlternateTriangles;
/// Triangle extrusion. This setting can help the bullet through paper issue in certain situations,
/// without using continuous simulation, however it does not guarantee robust results. All triangles
/// in this subpart are extruded in the direction specified (which defaults to 0, i.e is disabled). If you have a ground
/// made of triangles, with nothing beneath it, you can extrude the triangles a few meters in the downwards direction.
/// When high speed non-continuous debris hits the landscape it will be more likely to bounce off rather than
/// tunnel through. The effects of this extrusion is improved when also using one sided welding, as contact
/// points will be correctly rotated to point up, even when objects are deeply penetrating.
hkVector4 m_extrusion;
/// The transform to be applied on the vertices (translation, rotation, scaling). Usually used for instancing.
hkQsTransform m_transform;
};
/// A shapes subpart defining a list of one or more convex shapes of type hkpConvexShape.
struct ShapesSubpart : public Subpart
{
//+version(1)
public:
enum
{
FLAG_NONE,
FLAG_TRANSLATE_SET,
FLAG_ROTATE_SET
};
public:
HK_DECLARE_REFLECTION();
HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_COLLIDE, hkpExtendedMeshShape::ShapesSubpart );
ShapesSubpart() : Subpart(SUBPART_SHAPE) {}
ShapesSubpart( const hkpConvexShape*const* childShapes, int numChildShapes, const hkVector4& offset = hkVector4::getZero() );
ShapesSubpart( const hkpConvexShape*const* childShapes, int numChildShapes, const hkTransform& transform );
ShapesSubpart(const ShapesSubpart& part) : Subpart(part), m_rotation(part.m_rotation), m_translation(part.m_translation) { m_childShapes = part.m_childShapes; }
ShapesSubpart(hkFinishLoadedObjectFlag flag);
~ShapesSubpart();
inline void setFlags( int f ) { m_translation.setInt24W(f); }
inline int getFlags() const { return m_translation.getInt24W(); }
const hkVector4& getTranslation() const { return m_translation; }
const hkQuaternion& getRotation() const { return m_rotation; }
public:
/// The child shapes forming this subpart.
hkArray< hkRefPtr<hkpConvexShape> > m_childShapes;
protected:
hkQuaternion m_rotation; ///< The rotation of this subpart.
hkVector4 m_translation; ///< The translation of this subpart.
};
public:
/// Constructs a new hkpExtendedMeshShape.
/// This mesh supports triangle soups as well as shape soups.
/// - The triangles are grouped in subparts and can be transformed (translation, rotation, scaling) and get a radius applied
/// - The shapes can be grouped in subparts and can be translated and rotated on a per subpart basis.
/// "numBitsForSubpart" is the number of bits used (in the 32 bit shape key) for the subpart index.
/// Note that the highest bit is used as the type identifier, discerning whether this subpart consists
/// of triangles or convex shapes.
/// The remaining bits from the 32 bit shape key are used for the terminal index. By
/// default numBitsForSubpartIndex is 12, which means the mesh shape can have 2^11 - 1
/// subparts (0xffffffff is the "invalid" shape key) = 2047, and each subpart can have 2^20 triangles = 1048576.
/// The subpart is stored in the high bits, so you can extract subpart/terminal indices like this:
/// - int subpartIndex = key >> ( 32 - mymesh->getNumBitsForSubpartIndex() );
/// - int terminalIndex = key & ( ~0U >> mymesh->getNumBitsForSubpartIndex() );
hkpExtendedMeshShape( hkReal radius = hkConvexShapeDefaultRadius, int numBitsForSubpartIndex = 12 );
/// A utility constructor that creates and extended mesh shape from a mesh shape.
hkpExtendedMeshShape( const class hkpMeshShape* meshShape );
/// Serialization constructor.
hkpExtendedMeshShape( hkFinishLoadedObjectFlag flag );
/// Destructor. Simply removes the references to all childShapes
~hkpExtendedMeshShape();
public:
//
// Subpart access
//
/// Adds a triangle subpart. To modify member xxxx of this triangle subpart later on, call getTrianglesSubpartAt(int ).xxxx = yyyy.
virtual void addTrianglesSubpart( const TrianglesSubpart& part );
/// Adds a shape subpart. To modify member xxxx of this shape subpart later on, call getShapesSubpartAt(int ).xxxx = yyyy.
/// returns the subpart index
virtual int addShapesSubpart( const ShapesSubpart& part );
/// Returns the number of all triangle subparts.
inline int getNumTrianglesSubparts() const;
/// Returns the number of all shape subparts.
inline int getNumShapesSubparts() const;
/// Gets read/write access to a triangle subpart.
inline TrianglesSubpart& getTrianglesSubpartAt( int i );
/// Gets const access to a triangle subpart.
inline const TrianglesSubpart& getTrianglesSubpartAt( int i ) const;
/// Gets read/write access to a shape subpart.
inline ShapesSubpart& getShapesSubpartAt( int i );
/// Gets const access to a shape subpart.
inline const ShapesSubpart& getShapesSubpartAt( int i ) const;
/// Gets the subpart that a shape key belongs to.
inline const Subpart& getSubPart( hkpShapeKey shapeKey ) const;
/// Gets the index of a subpart that a shape key belongs to.
/// Note that this will only return the index within the subpart's specific type list, i.e., either the index in the triangles list or in the shapes list.
/// You can get the subpart's type by calling getSubpartType().
HK_FORCE_INLINE hkInt32 getSubPartIndex( hkpShapeKey shapeKey ) const;
/// Get the terminal shape's index within the subpart.
HK_FORCE_INLINE hkInt32 getTerminalIndexInSubPart( hkpShapeKey key ) const;
/// Gets the number of bits of a shape key used to encode the subpart.
HK_FORCE_INLINE hkInt32 getNumBitsForSubpartIndex() const;
/// Returns the first shape key of a subpart
HK_FORCE_INLINE hkInt32 getSubpartShapeKeyBase( int subpartIndex) const;
/// Get the type of the shape referenced by the supplied shape key.
HK_FORCE_INLINE SubpartType getSubpartType( hkpShapeKey key ) const;
/// Gets the shape info for the given shape key. The shape infos are stored per sub-part in the case of extended mesh shapes.
HK_FORCE_INLINE hkUint16 getShapeInfo(hkpShapeKey shapeKey) const;
/// Sets the shape info for the given shape key. The shape infos are stored per sub-part in the case of extended mesh shapes.
HK_FORCE_INLINE void setShapeInfo(hkpShapeKey shapeKey, hkUint16 shapeInfo);
/// Returns the triangle subparts
HK_FORCE_INLINE const hkArray<TrianglesSubpart>& getTriangleSubparts() const { return m_trianglesSubparts; }
/// REturns the shape subparts
HK_FORCE_INLINE const hkArray<ShapesSubpart>& getShapesSubparts() const { return m_shapesSubparts; }
/// Gets the mesh material by shape key, or returns HK_NULL if m_materialIndexBase isn't defined.
const hkpMeshMaterial* getMeshMaterial( hkpShapeKey key ) const;
//
// Scaling and radius access
//
/// Gets the extra radius for every triangle.
inline hkReal getRadius() const;
/// Sets the extra radius for every triangle.
inline void setRadius(hkReal r );
//
// hkpShapeContainer interface
//
/// The number of child shapes. The default implementation just iterates over all keys and is really slow
virtual int getNumChildShapes() const;
/// Get the first child shape key.
virtual hkpShapeKey getFirstKey() const;
/// This function implements hkpShapeContainer::getNextKey.
/// NOTE: This function calls hkpTriangleUtil::isDegenerate to make sure no keys for degenerate triangles are returned.
/// If you are implementing your own mesh shape, your getNextKey function must make sure that it similarly does
/// not return keys for degenerate triangles. You can use the hkpTriangleUtil::isDegenerate utility function to check whether
/// triangles are valid.
virtual hkpShapeKey getNextKey( hkpShapeKey oldKey ) const;
// hkpShapeCollection interface implementation.
virtual void setWeldingInfo( hkpShapeKey key, hkInt16 weldingInfo );
// hkpShapeCollection interface implementation.
virtual void initWeldingInfo( hkpWeldingUtility::WeldingType weldingType );
// hkpShapeContainer::getChildShape() interface implementation.
virtual const hkpShape* getChildShape( hkpShapeKey key, hkpShapeBuffer& buffer ) const;
// hkpShapeContainer::getCollisionFilterInfo() interface implementation.
virtual hkUint32 getCollisionFilterInfo( hkpShapeKey key ) const;
//
// hkpShape interface
//
// hkpShape interface implementation.
virtual void getAabb(const hkTransform& localToWorld, hkReal tolerance, hkAabb& out) const;
virtual int calcSizeForSpu(const CalcSizeForSpuInput& input, int spuBufferSizeLeft) const;
protected:
// Internal method to calculate the AABB extents for a single TrianglesSubpart.
static void calcAabbExtents( TrianglesSubpart& part, hkAabb& out );
// Internal method to calculate the AABB extents for a single ShapesSubpart.
static void calcAabbExtents( const ShapesSubpart& part, hkAabb& out );
public:
void recalcAabbExtents();
protected:
/// Internal methods to help simplify the memory management involved when the subparts are embedded
struct TrianglesSubpart* expandOneTriangleSubparts();
struct ShapesSubpart* expandOneShapesSubparts();
void freeTriangleSubparts();
void freeShapesSubparts();
int _getNumChildShapesInTrianglesSubpart(const TrianglesSubpart& subpart, int subpartIndex) const;
int _getNumChildShapesInShapesSubpart(const ShapesSubpart& subpart) const;
void assertTrianglesSubpartValidity( const TrianglesSubpart& part );
void assertShapesSubpartValidity ( const ShapesSubpart& part );
protected:
/// If this shape only contains a single triangle subpart and/or single shapes subpart then these
/// can be embedded directly into the shape. This saves significantly on DMA transfers.
TrianglesSubpart m_embeddedTrianglesSubpart;
public:
// Cached AABB
hkVector4 m_aabbHalfExtents;
hkVector4 m_aabbCenter;
/// Material class
const hkClass* m_materialClass; //+nosave +default(0)
hkInt32 m_numBitsForSubpartIndex;
protected:
// On PlayStation(R)3 these must be aligned according to their size.
hkArray<struct TrianglesSubpart> m_trianglesSubparts;
hkArray<struct ShapesSubpart> m_shapesSubparts;
public:
hkArray<hkUint16> m_weldingInfo;
hkEnum<hkpWeldingUtility::WeldingType, hkUint8> m_weldingType; // +default(hkpWeldingUtility::WELDING_TYPE_NONE)
/// Collision filter info used if there is no material set.
/// Note if you set this value to hkpGroupFilter::USE_COLLIDABLE_FILTER_INFO, and no material info
/// is set, than the hkpGroupFilter collision filter info will be taken from the rootCollidable
hkUint32 m_defaultCollisionFilterInfo;
/// This is cached number of child shapes. It's set to -1 when it's not updated.
mutable hkInt32 m_cachedNumChildShapes; //+default(-1)
protected:
/// Extra padding which makes easier to deal with penetration. Can be updated at run-time.
hkReal m_triangleRadius;
hkInt32 m_padding; // +nosave
};
#include <Physics/Collide/Shape/Compound/Collection/ExtendedMeshShape/hkpExtendedMeshShape.inl>
#endif // HKP_EXTENDED_MESH_SHAPE_H
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20120831)
*
* Confidential Information of Havok. (C) Copyright 1999-2012
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available at www.havok.com/tryhavok.
*
*/
| [
"[email protected]"
] | |
3ecc6400d5b4a1647749f43da3d7329950f5c867 | 4986b051e2d7502c1e76369c8cb9314a15c58247 | /Lighting.h | 6039aa3a5250810cdd0f26402b620e20623cb0d3 | [] | no_license | mostafa-kamal-99/SnakeAndLadder-Monopoly | 4d492620887bf46f3117c6e7e9599db889d61bc2 | 4af46ad125728fc1e6659e7855a90faf7fa83e0a | refs/heads/master | 2020-11-27T04:05:58.448974 | 2019-12-20T17:17:02 | 2019-12-20T17:17:02 | 229,298,184 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 256 | h | #pragma once
#include "Attack.h"
class Attack;
class Lighting : public Attack
{
public:
Lighting( Grid*g,Player *p=NULL); // A Constructor for Attack that takes the Player to act on of it
Lighting();
void Apply ();
~Lighting(void);
};
| [
"[email protected]"
] | |
4c5a6699aed75152acca5c5ef95f52c0913a1ab3 | 8de4f46db32c7ccfd77d25b7697f9a013ab13187 | /MakeTes_02/good_morning.hpp | c843edc9ce3cd3fb38b241dc6e3f5c2cec6eb9df | [] | no_license | yoshi-jun/Make_practice | dbd1ab9389b633ee5a6f21d99610d58bbc7a4b36 | 7c4073fe7b4f483d87a85958c308b2f6eb7cbbd6 | refs/heads/master | 2023-04-12T01:00:38.321163 | 2021-05-17T06:10:52 | 2021-05-17T06:10:52 | 365,935,182 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 76 | hpp | #ifndef GOOF_MORNING_H
#define GOOD_MORNINF_H
void good_morning();
#endif
| [
"[email protected]"
] | |
c685e76c72b62c93c805ba2852627b25655b58ae | a78390c58814a59998f330adab061c7f7678725e | /sources/sedris_cpp_sdk_4.1.4/src/lib/taccess/interface/include/seIterator.h | 0b77a31d1d0b0b3a6fd479184c7318d2a3e6bb83 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | Geo4Win/sedris-dynamic | d632c3c496bdd111b8cb27d69de359cd7cc7c420 | cfb3b2f1605221bb1cfd86c8315ff0ca740767b8 | refs/heads/master | 2021-07-06T16:47:05.668696 | 2017-10-02T04:55:03 | 2017-10-02T04:55:03 | 105,417,233 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 15,485 | h | /*
* Copyright (c) 2006 Accent Geographic. All rights reserved.
* See the license file for licensing information.
* Created 2003/05/30
*/
// SEDRIS C++ SDK Release 4.1.4 - July 1, 2011
/*
* NOTICE
*
* This software is provided openly and freely for use in representing and
* interchanging environmental data & databases.
*
* This software was developed for use by the United States Government with
* unlimited rights. The software was developed under contract
* DASG60-02-D-0006 TO-193 by Science Applications International Corporation.
* The software is unclassified and is deemed as Distribution A, approved
* for Public Release.
*
* Use by others is permitted only upon the ACCEPTANCE OF THE TERMS AND
* CONDITIONS, AS STIPULATED UNDER THE FOLLOWING PROVISIONS:
*
* 1. Recipient may make unlimited copies of this software and give
* copies to other persons or entities as long as the copies contain
* this NOTICE, and as long as the same copyright notices that
* appear on, or in, this software remain.
*
* 2. Trademarks. All trademarks belong to their respective trademark
* holders. Third-Party applications/software/information are
* copyrighted by their respective owners.
*
* 3. Recipient agrees to forfeit all intellectual property and
* ownership rights for any version created from the modification
* or adaptation of this software, including versions created from
* the translation and/or reverse engineering of the software design.
*
* 4. Transfer. Recipient may not sell, rent, lease, or sublicense
* this software. Recipient may, however enable another person
* or entity the rights to use this software, provided that this
* AGREEMENT and NOTICE is furnished along with the software and
* /or software system utilizing this software.
*
* All revisions, modifications, created by the Recipient, to this
* software and/or related technical data shall be forwarded by the
* Recipient to the Government at the following address:
*
* SMDC
* Attention SEDRIS (TO193) TPOC
* P.O. Box 1500
* Huntsville, AL 35807-3801
*
* or via electronic mail to: [email protected]
*
* 5. No Warranty. This software is being delivered to you AS IS
* and there is no warranty, EXPRESS or IMPLIED, as to its use
* or performance.
*
* The RECIPIENT ASSUMES ALL RISKS, KNOWN AND UNKNOWN, OF USING
* THIS SOFTWARE. The DEVELOPER EXPRESSLY DISCLAIMS, and the
* RECIPIENT WAIVES, ANY and ALL PERFORMANCE OR RESULTS YOU MAY
* OBTAIN BY USING THIS SOFTWARE OR DOCUMENTATION. THERE IS
* NO WARRANTY, EXPRESS OR, IMPLIED, AS TO NON-INFRINGEMENT OF
* THIRD PARTY RIGHTS, MERCHANTABILITY, OR FITNESS FOR ANY
* PARTICULAR PURPOSE. IN NO EVENT WILL THE DEVELOPER, THE
* UNITED STATES GOVERNMENT OR ANYONE ELSE ASSOCIATED WITH THE
* DEVELOPMENT OF THIS SOFTWARE BE HELD LIABLE FOR ANY CONSEQUENTIAL,
* INCIDENTAL OR SPECIAL DAMAGES, INCLUDING ANY LOST PROFITS
* OR LOST SAVINGS WHATSOEVER.
*/
// $Id: seIterator.h,v 1.5 2006-05-03 15:21:33-04 shend Exp $
#ifndef _seIterator_h
#define _seIterator_h
/** @file seIterator.h
@author Warren Macchi (Accent Geographic)
@brief Declaration of seIterator.
*/
#include "seObject.h"
namespace sedris {
class IInterface;
class IIterator;
/** seIterator is the generalized iterator for seObject's.
This class is used to iterate through a list of objects.
The following sample shows how you can use an iterator to
retrieve DRM objects of a specific type, using their
specific DRM object classes:
@code
seDRMPolygon poly;
... poly is retrieved from the transmittal
seIterator iter;
seDRMVertex vtx;
poly.getComponentIterator(iter, SE_CLS_DRM_VERTEX)
while (iter.getNext(vtx))
{
... process vertex object
}
@endcode
The following sample shows how you can use an iterator to retrieve and
process all the components of a DRM object in a generic way:
@code
... aggr_obj is retrieved from the transmittal
seIterator iter;
seObject comp_obj, link_obj;
aggr_obj.getComponentIterator(iter)
while (iter.getNext(comp_obj, link_obj))
{
if (comp_obj.isA(SE_CLS_DRM_UNION_OF_PRIMITIVE_GEOMETRY))
{
seDRMUnionOfPrimitiveGeometry uofp(comp_obj);
... process uofp
}
else if (comp_obj.isA(...))
{
... process another type
}
...
}
@endcode
@note The ITR behaviour of an seIterator is determined by the ITR behaviour
of the seWorkspace at the moment the iterator is created. See
seWorkspace::setITRBehaviour() and getNext() for more information.
@author Warren Macchi (Accent Geographic)
@see seObject::getComponentIterator, seObject::getAssociateIterator,
seObject::getAggregateIterator, seObject, seTransmittal, getNext(),
seWorkspace::setITRBehaviour()
*/
class EXPORT_DLL seIterator
{
public:
/// Default constructor
seIterator() : _impl(NULL), _ownr(NULL)
{
}
/// Copies another iterator's state into this one.
seIterator( const seIterator &other );
/// Destructor
virtual ~seIterator()
{
if (isValid())
release();
}
/** Copies another iterator's state into this one.
You can use this operator to store, for example, a temporary
iterator if you need to look ahead somewhat, and then return to
where you left off.
@note After the iterators are copied, they will both return the
same objects after a similar call to getNext() on them.
*/
seIterator &operator =( const seIterator &other );
/** Returns true if the iterators have the same owners, are of the same
type, and they will return the same elements on getNext().
*/
virtual bool operator ==( const seIterator &other ) const;
/** Returns true if this iterator handle is valid, don't confuse with
isCompleted().
*/
virtual bool isValid() const
{
return (_impl != NULL);
}
/** Returns true if the iterator will NOT return any more objects (i.e.
getNext() will return false).
Sample usage:
@code
while (!iter.isCompleted())
{
... get next object and process
}
@endcode
*/
virtual bool isCompleted();
/** Returns the number of objects remaining in the iterator.
An optional DRM class can be used to filter the returned count.
For performance reasons do not use this method as a replacement for
isCompleted() or use this method as part of a loop test. For example,
rather than seeing if an iterator is empty by doing:
@code
while (iter.getCount() > 0) // NOT VERY EFFICIENT
{
... retrieve and process objects
}
@endcode
use the following instead:
@code
while (!iter.isCompleted()) // BETTER
{
... retrieve and process objects
}
@endcode
If you do need to loop based on the number of objects in the
iterator, use as follows:
@code
unsigned int i;
unsigned int count = iter.getCount();
for (i=0, i < count; i++)
{
... retrieve and process ith object
}
@endcode
An example of using the filter type to get a count ahead of
processing is:
@code
seIterator iter;
seObject comp_obj, link_obj;
poly_obj.getComponentIterator(iter);
unsigned int vertex_count = iter.getCount(SE_CLS_DRM_VERTEX);
// here you may allocate an array based on vertex_count
while (iter.getNext(comp_obj, link_obj))
{
// process component, which may or may not be a vertex!
}
@endcode
@warning If the iterator was created with a DRM filter type (i.e.
the filter type was not SE_CLS_DRM_NULL) and you pass in a
different DRM class type to this method, the result is
undefined unless the type passed-in is a subclass of the
type used to initialize the iterator.
@throws seException if the count could not be retrieved (due to a
file failure, a failed ITR resolution, etc.)
@param filter in: DRM class to filter the current iterator set
@return number of elements left
*/
virtual unsigned int getCount( SE_DRM_Class filter = SE_CLS_DRM_NULL );
/** Retrieves the next element and link object from the iterator.
As a convenience, this method returns false when the iterator is
empty. Hence, you can use code like
@code
seIterator iter;
seObject comp_obj, link_obj;
some_obj.getComponentIterator(iter);
while (iter.getNext(comp_obj, link_obj))
{
... use comp_obj and link_obj as needed
}
@endcode
However, note that the above will not let you continue the loop
in the case of an exception occurring in the getNext() call. If
you do want to continue the loop, then you should use isCompleted()
for the loop test and call getNext() inside the loop in a try/catch
statement:
@code
seIterator iter;
seObject comp_obj, link_obj;
some_obj.getComponentIterator(iter);
while (!iter.isCompleted())
{
try {
iter.getNext(comp_obj, link_obj);
... use comp_obj and link_obj as needed
} catch ( seException& e ) {
... process exception
}
}
@endcode
The ITR behaviour of an iterator is dependent on the ITR behaviour
set at the workspace level (see seWorkspace::setITRBehaviour()) when
the iterator is created. Iterators are typically created by calling
one of the "get" iterator methods of an seObject (for example
seObject::getComponentIterator()). After the iterator is created,
changing the workspace ITR behaviour has no effect on the iterator.
The ITR behaviour value is interpreted as follows:
<ul>
<li>If ITR behaviour is SE_ITRBEH_RESOLVE, then all objects
returned by the API will be resolved objects. If an object cannot
be resolved (for example the referenced transmittal is missing)
then an exception will occur (the exception type will be dependent
on the failed step, for example it could be UNRESOLVED_TRANSMITTAL,
UNPUBLISHED_OBJECT, or some other exception type).</li>
<li>If ITR behaviour is SE_ITRBEH_REPORT, then when the iterator
encounters an ITR reference it will return an unresolved object,
no matter what its DRM type may be. You can call seObject::resolve()
to attempt to resolve the object if you need to. Note that the
current filter DRM class for the iterator is ignored for ITR
references when using SE_ITRBEH_REPORT. Hence, for this case,
you should not use seDRMBase-derived classes as parameters to
getNext().</li>
<li>If ITR behaviour is SE_ITRBEH_IGNORE, then ITR references are
skipped by the iterator and are never returned.</li>
</ul>
@note If there is no link object associated with the next object,
the link object parameter is set to an invalid object handle
(i.e. you can use seObject::isValid() to see if a link object
was available).
@note This method respects the DRM ordering of ordered classes.
@warning If you use one of the seDRMBase-derived classes as parameters
to this method, you must ensure that the derived type will be
able to hold a reference to whatever object will be returned, or
an exception will occur. If you don't know what type will be
returned, you can pass in a base class (such as seObject) and
then get the type of the object by using seObject::getDRMClass().
@see seWorkspace::setITRBehaviour(), seObject::isResolved()
@throws seException if an error occurs.
@param obj in/out: a handle to store the next object
@param link_obj in/out: a handle to store the next link object (if
part of the relation)
*/
virtual bool getNext( seObject &obj, seObject &link_obj );
/** Retrieves the next element from the iterator, ignoring the link
object.
@see getNext(seObject, seObject)
@throws seException if an error occurs.
@param obj in/out: a handle to store the next object
*/
virtual bool getNext( seObject &obj );
/** Retrieves the Nth next element from the iterator.
This is a convenience method that skips over the iterator list
and returns the next Nth element in the list. When "nth" equals
1, this method is equivalent to calling getNext().
@warning Since an iterator is a sequential list, once you request
an nth object, calling getNthNext() with the same nth value will
NOT return the same object. That is, an iterator always moves
forward in its list of objects, never backward.
@see getNext(seObject, seObject)
@throws seException if an error occurs.
@param nth in: a number greater than or equal to 1
@param obj in/out: a handle to store the next object
@param link_obj in/out: a handle to store the next link object (if
available)
*/
virtual bool getNthNext( unsigned int nth, seObject &obj,
seObject &link_obj );
/** Retrieves the Nth next element from the iterator, ignoring the link
object.
This is a convenience method that skips over the iterator list
and returns the next Nth element in the list. When "nth" equals
1, this method is equivalent to calling getNext().
@warning Since an iterator is a sequential list, once you request
an nth object, calling getNthNext() with the same nth value will
NOT return the same object. That is, an iterator always moves
forward in its list of objects, never backward.
@note This method respects the DRM ordering of ordered classes.
@note If there is no @p nth element (i.e. this method returns false),
no changes are made to the iterator so that you can continue
iterating through its elements as if no method was called.
@see getNthNext(unsigned int, seObject, seObject)
*/
virtual bool getNthNext( unsigned int nth, seObject &obj );
/** Releases the handle to the iterator.
Generally there is no need to call this method, since release()
is called by any change of handle or when the object goes out
of scope.
*/
virtual void release();
private:
SE_HANDLE_DECL(Iterator, Interface)
};
} // namespace sedris
#endif // _seIterator_h
| [
"[email protected]"
] | |
12ab4c301b5725b3c1549c7e59ec17a1da48e063 | 8476eb45fe9dfd43818245e17a1c661b88e69400 | /CustomCodes/utils/funcs/KinDyn200511_221619/kin/mex/Inertia_LeftPelvisRotation_mex.hh | b1c17b38ac6ef44a58d2941a79ee1a0f72cc3195 | [] | no_license | prem-chand/Cassie_Controller_AngularMomentum | f8c7521bc990b42d8ff098759e04637afaca2cc1 | c784242f1a949525accb8f9e9fe4a53feb0fba87 | refs/heads/main | 2023-08-15T02:09:23.748744 | 2021-09-21T21:43:24 | 2021-09-21T21:43:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 901 | hh | /*
* Automatically Generated from Mathematica.
* Mon 11 May 2020 22:23:50 GMT-04:00
*/
#ifndef INERTIA_LEFTPELVISROTATION_MEX_HH
#define INERTIA_LEFTPELVISROTATION_MEX_HH
#ifdef MATLAB_MEX_FILE
// No need for external definitions
#else // MATLAB_MEX_FILE
#include "math2mat.hpp"
#include "mdefs.hpp"
namespace SymExpression
{
void Inertia_LeftPelvisRotation_mex_raw(double *p_output1, const double *var1);
inline void Inertia_LeftPelvisRotation_mex(Eigen::MatrixXd &p_output1, const Eigen::VectorXd &var1)
{
// Check
// - Inputs
assert_size_matrix(var1, 20, 1);
// - Outputs
assert_size_matrix(p_output1, 3, 3);
// set zero the matrix
p_output1.setZero();
// Call Subroutine with raw data
Inertia_LeftPelvisRotation_mex_raw(p_output1.data(), var1.data());
}
}
#endif // MATLAB_MEX_FILE
#endif // INERTIA_LEFTPELVISROTATION_MEX_HH
| [
"[email protected]"
] | |
f7b6c49b275368197e138ba0c5665ca4d00d881e | ad62d5a6236c35d71a647802cf4d6d2ead2558a8 | /src/WalletLegacy/WalletTransactionSender.h | 64c67e3e90112b3124f3cc5331016c92a824d9d8 | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | cycere/quid | 7af570e6d2fd6a8e4cbd5c5253060c76c488bd72 | 889b5bd36339d4e632c07a037db9ba38bf89ea30 | refs/heads/master | 2023-01-21T22:13:08.580206 | 2020-12-01T00:00:40 | 2020-12-01T00:00:40 | 316,043,120 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,163 | h | // Copyright (c) 2011-2016 The Cryptonote developers
// Copyright (c) 2017-2021 The Cycere developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#pragma once
#include "QuidCore/Account.h"
#include "QuidCore/Currency.h"
#include "INode.h"
#include "WalletLegacy/WalletSendTransactionContext.h"
#include "WalletLegacy/WalletUserTransactionsCache.h"
#include "WalletLegacy/WalletUnconfirmedTransactions.h"
#include "WalletLegacy/WalletRequest.h"
#include "ITransfersContainer.h"
namespace Quid {
class WalletTransactionSender
{
public:
WalletTransactionSender(const Currency& currency, WalletUserTransactionsCache& transactionsCache, AccountKeys keys, ITransfersContainer& transfersContainer);
void stop();
std::shared_ptr<WalletRequest> makeSendRequest(TransactionId& transactionId, std::deque<std::shared_ptr<WalletLegacyEvent>>& events,
const std::vector<WalletLegacyTransfer>& transfers, uint64_t fee, const std::string& extra = "", uint64_t mixIn = 0, uint64_t unlockTimestamp = 0);
private:
std::shared_ptr<WalletRequest> makeGetRandomOutsRequest(std::shared_ptr<SendTransactionContext> context);
std::shared_ptr<WalletRequest> doSendTransaction(std::shared_ptr<SendTransactionContext> context, std::deque<std::shared_ptr<WalletLegacyEvent>>& events);
void prepareInputs(const std::list<TransactionOutputInformation>& selectedTransfers, std::vector<COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::outs_for_amount>& outs,
std::vector<TransactionSourceEntry>& sources, uint64_t mixIn);
void splitDestinations(TransferId firstTransferId, size_t transfersCount, const TransactionDestinationEntry& changeDts,
const TxDustPolicy& dustPolicy, std::vector<TransactionDestinationEntry>& splittedDests);
void digitSplitStrategy(TransferId firstTransferId, size_t transfersCount, const TransactionDestinationEntry& change_dst, uint64_t dust_threshold,
std::vector<TransactionDestinationEntry>& splitted_dsts, uint64_t& dust);
void sendTransactionRandomOutsByAmount(std::shared_ptr<SendTransactionContext> context, std::deque<std::shared_ptr<WalletLegacyEvent>>& events,
boost::optional<std::shared_ptr<WalletRequest> >& nextRequest, std::error_code ec);
void relayTransactionCallback(std::shared_ptr<SendTransactionContext> context, std::deque<std::shared_ptr<WalletLegacyEvent>>& events,
boost::optional<std::shared_ptr<WalletRequest> >& nextRequest, std::error_code ec);
void notifyBalanceChanged(std::deque<std::shared_ptr<WalletLegacyEvent>>& events);
void validateTransfersAddresses(const std::vector<WalletLegacyTransfer>& transfers);
bool validateDestinationAddress(const std::string& address);
uint64_t selectTransfersToSend(uint64_t neededMoney, bool addDust, uint64_t dust, std::list<TransactionOutputInformation>& selectedTransfers);
const Currency& m_currency;
AccountKeys m_keys;
WalletUserTransactionsCache& m_transactionsCache;
uint64_t m_upperTransactionSizeLimit;
bool m_isStoping;
ITransfersContainer& m_transferDetails;
};
} /* namespace Quid */
| [
"[email protected]"
] | |
64131c5a4e0f175298626558390e583c3d7c24fe | 26ad4cc35496d364b31396e43a863aee08ef2636 | /SDK/SoT_BP_BountyRewardSkull_Proxy_Common_DVR_functions.cpp | d0cafb96bcf9bdf590af9d1e3ca5eb01f8d4c06d | [] | no_license | cw100/SoT-SDK | ddb9b19ce6ae623299b2b02dee51c29581537ba1 | 3e6f12384c8e21ed83ef56f00030ca0506d297fb | refs/heads/master | 2020-05-05T12:09:55.938323 | 2019-03-20T14:11:57 | 2019-03-20T14:11:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 374 | cpp | // Sea of Thieves (1.4) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "SoT_BP_BountyRewardSkull_Proxy_Common_DVR_classes.hpp"
namespace SDK
{
//---------------------------------------------------------------------------
//Functions
//---------------------------------------------------------------------------
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"[email protected]"
] | |
0012a71e0e45802949458127cb2d9b67cc12a108 | 84875d668911475f4bbf6aa5e44a70f19e941e42 | /src/utils/S64String.cc | ebb9805746d45fb525712cfce468bc6bd1fc07ea | [
"MIT"
] | permissive | sroycode/zapdos | 26592d95f51828f53dd104fe04fe98eb127706b0 | 8818ef109e072dcbe990914d9a2a6d70ef190d3e | refs/heads/master | 2021-06-24T06:18:54.712462 | 2020-12-07T08:06:25 | 2020-12-07T08:06:25 | 156,883,254 | 5 | 0 | MIT | 2020-08-02T09:12:57 | 2018-11-09T15:47:05 | C++ | UTF-8 | C++ | false | false | 1,965 | cc | /**
* @project zapdos
* @file src/utils/S64String.cc
* @author S Roychowdhury < sroycode at gmail dot com >
* @version 1.0.0
*
* @section LICENSE
*
* Copyright (c) 2018-2020 S Roychowdhury
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @section DESCRIPTION
*
* S64String.cc : Snappy Compression Headers
*
*/
#include <snappy.h>
#include "utils/S64String.hpp"
#include "utils/B64String.hpp"
/**
* Encode : compress from string
*
*/
std::string zpds::utils::S64String::Encode(const std::string& input)
{
std::string output;
::snappy::Compress(input.data(), input.size(), &output);
return ::zpds::utils::B64String::Encode(output);
}
/**
* Decode : snappy uncompress from string
*
*/
std::string zpds::utils::S64String::Decode(std::string input)
{
std::string output;
std::string buffer = ::zpds::utils::B64String::Decode(input);
::snappy::Uncompress(buffer.data(), buffer.size(), &output);
return output;
}
| [
"[email protected]"
] | |
80989780b4cdc378496cf853505faa689e297c65 | 629f7423b91988b6c735a417b72f6fd886198d16 | /AOJ/ITP1/2-d.cpp | f2dc9b588c48177efc98f6b0b3b024952e907365 | [
"MIT"
] | permissive | yu1k/competitive-programming | 6af576f51255ee6edc77f0e6d5b24bac0f65596f | 0c47db99ce7fb9bcf6e3b0dbfb8c84d9cfa165fd | refs/heads/master | 2021-12-11T15:14:19.201721 | 2021-12-01T14:49:29 | 2021-12-01T14:49:29 | 192,532,915 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 290 | cpp | #include <iostream>
using namespace std;
int main(){
int w;
int h;
int x;
int y;
int r;
cin >> w >> h >> x >> y >> r;
if((x >= r) && (x <= w - r) && (y >= r) && (y <= h - r)){
cout << "Yes" << endl;
}
else{
cout << "No" << endl;
}
} | [
"[email protected]"
] | |
de94617abbacb7bba63cd0587bb7eb7c74556a32 | 4d556635b5649fb711acd215276687573c5d427c | /P03/bonus/test.cpp | 157b68b4ee7cc9f52cbd77d17b1cc61d16e68c87 | [] | no_license | sworup-bhattarai/cse1325 | fe7099c75270ddd8b5486ccf3335e33017347914 | 6bc9096f179b0927507371ef85c5fbb197edfb5b | refs/heads/main | 2023-04-08T13:41:27.875255 | 2021-04-27T04:01:41 | 2021-04-27T04:01:41 | 330,570,220 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,293 | cpp | #include "fraction.h"
#include <iostream>
#include <sstream>
int main() {
// Vector is the bit representing the test being performed
// Result accumulates all failures, and is the return code
int vector = 1;
int result = 0;
// Four fractions to handle the test cases
Fraction f1{1, 2};
Fraction f2{3, -4};
Fraction f3{-1, 3};
Fraction f4{2, 4};
//
// Begin testing
//
// I/O Testing
// Test output
std::ostringstream oss;
oss << f1 << ' ' << f3;
if (oss.str() != "1/2 -1/3") {
std::cerr << "FAIL: Stream out\n";
result |= vector;
}
// Test input
std::string sfi{"-13/255"};
std::istringstream iss{sfi};
Fraction fi;
iss >> fi;
if (fi != Fraction{-13, 255}) {
std::cerr << "FAIL: Stream in\n";
result |= vector;
}
vector <<= 1;
// Reduce testing
// Test reduce() handling of a negative denominator
if (f2 != Fraction{-3, 4}) {
std::cerr << "FAIL: Reduce sign\n";
result |= vector;
}
if (f1 != f4) {
std::cerr << "FAIL: Reduce numerator and denominator\n";
result |= vector;
}
vector <<= 1;
// Negation testing
// Test negation of a positive fraction
if (-f1 != Fraction{-1, 2}) {
std::cerr << "FAIL: Unary negative of positive\n";
result |= vector;
}
// Test negation of a negative fraction
if (-f2 != Fraction{3, 4}) {
std::cerr << "FAIL: Unary negative of negative\n";
result |= vector;
}
vector <<= 1;
// Mathematical operator testing
// Test addition
if (f1+f2 != Fraction{-1, 4}) {
std::cerr << "FAIL: Addition\n";
result |= vector;
}
// Test subtraction
if (f1-f3 != Fraction{5, 6}) {
std::cerr << "FAIL: Subtraction\n";
result |= vector;
}
// Test multiplication
if (f2*f3 != Fraction{3, 12}) {
std::cerr << "FAIL: Multiplication\n";
result |= vector;
}
// Test division
if (f3/f1 != Fraction{-2, 3}) {
std::cerr << "FAIL: Division\n";
result |= vector;
}
vector <<= 1;
// Comparison operator testing
// Test equality
if (f1 == f2 || f1 == f3 || f2 == f3) {
std::cerr << "FAIL: Equality\n";
result |= vector;
}
// Test inequality
if (f1 != f4) {
std::cerr << "FAIL: Inquality\n";
result |= vector;
}
// Test less than
if (f1 < f2 || f1 < f4) {
std::cerr << "FAIL: Less than\n";
result |= vector;
}
// Test less than or equal
if (f1 <= f2 || !(f1 <= f4)) {
std::cerr << "FAIL: Less than or equal\n";
result |= vector;
}
// Test greater than
if (f2 > f1 || f4 > f1) {
std::cerr << "FAIL: Greater than\n";
result |= vector;
}
// Test greater than or equal
if (f2 >= f1 || !(f4 >= f1)) {
std::cerr << "FAIL: Greater than or equal\n";
result |= vector;
}
vector <<= 1;
//
// End Testing
//
// Report the test results to the user and OS
if(result) std::cerr << "\nFAILED - result is " << std::hex << std::showbase << result << std::endl;
return result;
}
| [
"[email protected]"
] | |
f4ca8c1611d7c7d5f4510f61277a3dc451054f7a | f58365bcef42779533bcc3b93d7449b26139dfba | /av/avAnimation/AnimationPrototype.cpp | 7d5c74bf64f56dd59ebe122d820ef79be6890c27 | [] | no_license | hl0071/test_osg | 763b83895f30e1761b6b3e86171fca5c0508a08e | 2ea41efe216e15f7a4452c6b105397a923f3b04f | refs/heads/master | 2023-03-19T09:02:48.435332 | 2017-03-16T18:32:40 | 2017-03-16T18:32:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 24,348 | cpp | //#include <avDebug.h>
#include "av/avCore/Database.h"
#include "Animation.h"
#include "AnimationPrototype.h"
namespace avAnimation
{
bool readXFile ( std::istream * is, AnimationLoader* Loader );
bool IsEqual ( float delta, const osg::Matrixf& A, const osg::Matrixf& B )
{
const float *pA = A.ptr ();
const float *pB = B.ptr ();
for ( int i = 0; i < 16; i++ )
{
if ( fabs ( *pA++ - *pB++ ) > delta )
{
return false;
}
}
return true;
}
class NamedDrawableCullCallback : public osg::Drawable::CullCallback
{
bool cull(osg::NodeVisitor* nv, osg::Drawable* drawable, osg::RenderInfo* renderInfo) const
{
const osg::NodePath& np = nv->getNodePath();
for ( osg::NodePath::const_reverse_iterator It = np.rbegin(); It != np.rend(); It++ )
{
const AnimationObject* AO = dynamic_cast <const AnimationObject*> ( *It );
if ( AO )
{
return AO -> IsNameCulled( drawable->getName().c_str() );
}
}
return false;
}
};
class AnimatedDrawableComputeBoundingBoxCallback : public osg::Drawable::ComputeBoundingBoxCallback
{
osg::BoundingBox computeBound(const osg::Drawable &drawable) const
{
osg::BoundingBox BB;
#if OSG_MIN_VERSION_REQUIRED(3,3,2)
BB = drawable.computeBoundingBox();
#else
BB = drawable.computeBound();
#endif
// Let's estimate possible BB change due to animation matrices application
// supposed that all the animated model drawables are created relative to the model zero
// and could be arbitrary rotated around it.
osg::Vec3f diff = -BB.center();
diff.x() = diff.x() > 0 ? diff.x() : -diff.x();
diff.y() = diff.y() > 0 ? diff.y() : -diff.y();
diff.z() = diff.z() > 0 ? diff.z() : -diff.z();
diff += ( BB._max - BB._min ) * 0.5f; // substitute half size so diff now is vector to the most distant vertex
float MaxRadius = diff.length ();
// At the moment take the upper hemisphere only (assume the rest is under the deck)
BB.set ( -MaxRadius, -MaxRadius, 0.0f, MaxRadius, MaxRadius, MaxRadius );
return BB;
}
};
std::map<std::string, AnimationPrototype*> AnimationPrototype::m_Cache;
AnimationPrototype::AnimationPrototype ( ResourceLoaderPtr ResourceLoader ) :
m_bTextureDefined ( false ),
m_nMatrixIndex ( 0 ),
m_bNeedToOptimize (true),
m_bThisMatrixIsNotUsed (false),
m_bAllEqualToInitial (true),
m_pLastBoneAdded (NULL),
m_ResourceLoader ( ResourceLoader )
{
m_CurAnimationSetForLoad = m_Animations.end();
// Make a root identity bone as place for the collection of unattached bones
m_RootBone = CreateBone( "Unattached root" );
m_BonesLoadingStack.push_back(m_RootBone.get());
osg::StateSet* stateset = getOrCreateStateSet();
stateset->setMode(GL_VERTEX_PROGRAM_POINT_SIZE,osg::StateAttribute::ON);
stateset->setMode(GL_CULL_FACE,osg::StateAttribute::ON);
osg::Program* program = new osg::Program;
stateset->setAttribute(program);
// get shaders from source
program->addShader( m_ResourceLoader->getShader ( "Animation.vs", osg::Shader::VERTEX ));
program->addShader( m_ResourceLoader->getShader ( "Animation.fs", osg::Shader::FRAGMENT ));
}
AnimationPrototype::~AnimationPrototype ( )
{
m_Cache.erase ( m_Name );
}
void AnimationPrototype::Update ( float TimeFromAnimationStart, const AnimationElement *MainAE, osg::Uniform *Table, ExternalBonesMap & extMatrixMap,
const AnimationElement *NextAE, float ToNextAnimationBlendFactor )
{
//_uniformBoneMatrices->setElement( unsigned int index, const osg::Matrixf& m4 );
if ( !m_RootBone.valid ( ) )
return;
ResetBones ( m_RootBone.get() );
// Precalculate some timings for main and additional animations
UpdateBones ( TimeFromAnimationStart, *MainAE, 1.0f );
if ( NextAE ) // Blending to the next AnimationElement is active
UpdateBones ( 0.0f, *NextAE, ToNextAnimationBlendFactor );
// Recalculate Matrices
osg::Matrixf M;
RecalcBones ( m_RootBone.get(), M, Table, extMatrixMap );
}
void AnimationPrototype::OptimizeBonesTree ( )
{
// Remove unused (existing only for useful control) matrices here
// 1. Remove root bone if there were no bones added manually
if ( m_RootBone -> GetChildren().size ( ) == 1 )
{
//avLog(MT_INFO, "Remove bone: %s\n", m_RootBone -> GetName().c_str() );
m_BoneMap.erase ( m_RootBone -> GetName() );
m_RootBone = m_RootBone -> GetChildren() [ 0 ]; // everything removed automatically
}
// 2. Remove the bone if there is no vertices dependent on it (_ResultIndex==-1) or on deeper bones
RemoveRedundantBones ( m_RootBone.get(), 0 );
// The following lines are for debugging only
osg::Matrixf M;
RecalcMTBM ( m_RootBone.get(), M );
}
const AnimationSet* AnimationPrototype::GetAnimationSet ( const std::string &AnimationName ) const
{
AnimationCollection::const_iterator ACI = m_Animations.find ( AnimationName );
if ( ACI == m_Animations.end ( ) )
return 0;
return &ACI -> second;
}
void AnimationPrototype::ResetBones ( Bone *bone )
{
bone -> Reset();
for ( unsigned int i = 0; i < bone -> GetChildren().size(); i++ )
ResetBones ( bone -> GetChildren()[ i ].get() );
}
void AnimationPrototype::UpdateBones ( float TimeFromAnimationStart, const AnimationElement &AE, float CurNextInfluenceBlendFactor )
{
// Main animation
float CurPosInFrames = fmod ( TimeFromAnimationStart, AE.m_fDuration ) / AE.m_fDuration * AE.m_pAnimationSet->m_LengthInFrames;
for ( std::vector<AnimationKey>::const_iterator It = AE.m_pAnimationSet->begin(); It != AE.m_pAnimationSet->end(); ++It )
It -> m_pBone -> Animate ( CurPosInFrames, CurNextInfluenceBlendFactor, *It );
// Additional animations
#if 1
for ( std::vector<AnimationSubElement>::const_iterator ASE_It = AE.m_SubElements.begin(); ASE_It != AE.m_SubElements.end(); ++ASE_It )
{
// Precalculate some timings
float TimeFromAdditionalAnimationStart = fmod ( TimeFromAnimationStart, ASE_It->m_fPauseLength + ASE_It->m_fDuration ) - ASE_It->m_fPauseLength;
if ( TimeFromAdditionalAnimationStart < 0.0f )
continue;
float MainAdditionalInfluenceBlendFactor = 1.0f;
if ( TimeFromAdditionalAnimationStart < ASE_It->m_fBlendBorderLength )
MainAdditionalInfluenceBlendFactor = TimeFromAdditionalAnimationStart / ASE_It->m_fBlendBorderLength;
else if ( ASE_It->m_fDuration - TimeFromAdditionalAnimationStart < ASE_It->m_fBlendBorderLength )
MainAdditionalInfluenceBlendFactor = ( ASE_It->m_fDuration - TimeFromAdditionalAnimationStart ) / ASE_It->m_fBlendBorderLength;
float CurPosInFrames = fmod ( TimeFromAdditionalAnimationStart, ASE_It->m_fDuration ) / ASE_It->m_fDuration *
ASE_It ->m_pAnimationSet->m_LengthInFrames;
for ( std::vector<AnimationKey>::const_iterator It = ASE_It -> m_pAnimationSet->begin(); It != ASE_It -> m_pAnimationSet->end(); ++It )
It -> m_pBone -> Animate ( CurPosInFrames, MainAdditionalInfluenceBlendFactor * CurNextInfluenceBlendFactor, *It );
}
#endif
}
void AnimationPrototype::RecalcBones ( Bone *bone, const osg::Matrixf &Accumulated, osg::Uniform *Table, ExternalBonesMap & m_extMatrixMap )
{
// update amtrix
osg::Matrixf ThisNodeAccumulated(bone->GetCurrentMatrix());
ThisNodeAccumulated.postMult(Accumulated);
// update uniform if needed
if (bone->GetMatrixIndex() >= 0)
Table->setElement(bone->GetMatrixIndex(), bone->GetModelToBoneMatrix() * ThisNodeAccumulated);
// update external trackable matrices
ExternalBonesMap::iterator itExtBone = m_extMatrixMap.find(bone->GetName());
if (itExtBone != m_extMatrixMap.end())
itExtBone->second->setMatrix(ThisNodeAccumulated);
// go down
for (unsigned i = 0; i < bone->GetChildren().size(); ++i)
RecalcBones(bone->GetChildren()[i].get(), ThisNodeAccumulated, Table, m_extMatrixMap);
}
bool AnimationPrototype::RemoveRedundantBones ( Bone *bone, Bone *FatherBone )
{
// Have to begin from the children
for ( unsigned int i = 0; i < bone -> GetChildren().size(); )
{
if ( !RemoveRedundantBones ( bone -> GetChildren()[ i ].get(), bone ) )
{
i++;
}
}
if ( FatherBone && bone -> GetMatrixIndex() == -1 && bone -> GetChildren().empty ( ) )
{
//avLog(MT_INFO, "Remove bone: %s\n", bone -> GetName().c_str() );
m_BoneMap.erase ( bone -> GetName() );
for ( std::vector<osg::ref_ptr<Bone>>::const_iterator It = FatherBone -> GetChildren().begin (); It != FatherBone -> GetChildren().end(); ++It )
{
if ( (*It) -> GetName() == bone -> GetName() )
{
FatherBone -> GetChildren().erase ( It );
break;
}
}
return true;
}
return false;
}
void AnimationPrototype::RecalcMTBM ( Bone *bone, const osg::Matrixf &Accumulated )
{
osg::Matrixf ThisNodeAccumulated ( bone -> GetInitialMatrix() * Accumulated );
if ( bone -> GetMatrixIndex() >= 0 )
{
if ( !IsEqual ( 0.01, osg::Matrixf::inverse ( ThisNodeAccumulated ), bone -> GetModelToBoneMatrix() ) )
{
//avLog(MT_INFO, "Recalculation of ModelToBoneMatrix gives different results.\n" );
}
}
for ( unsigned int i = 0; i < bone -> GetChildren().size(); i++ )
{
RecalcMTBM ( bone -> GetChildren()[ i ].get(), ThisNodeAccumulated );
}
}
AnimationPrototype *AnimationPrototype::CreateAnimationPrototype ( const char *Model, ResourceLoaderPtr ResourceLoader )
{
std::map<std::string, AnimationPrototype *>::const_iterator It = m_Cache.find ( Model );
if ( It == m_Cache.end () )
{
// Store even zero results for not to try to load them again
AnimationPrototype *Result = new AnimationPrototype ( ResourceLoader );
Result -> m_Name = Model;
// Here we could choose the loader according to the Model extension. Now only readXFile from XFileParser is available
if ( !avAnimation::readXFile ( ResourceLoader->getStream ( Model )->get (), Result ))
{
delete Result;
Result = NULL;
}
m_Cache [ Model ] = Result;
return Result;
}
return It -> second;
}
Bone* AnimationPrototype::CreateBone( const std::string& Name )
{
Bone *bone = new Bone ( Name );
m_BoneMap [ Name ] = bone;
m_pLastBoneAdded = bone;
return bone;
}
Bone* AnimationPrototype::GetBone( const std::string& Name )
{
PrototypeBoneMap::iterator boneIt = m_BoneMap.find(Name);
if (boneIt != m_BoneMap.end())
return boneIt->second;
return NULL;
}
void AnimationPrototype::AddBone ( const std::string& Name )
{
m_BonesLoadingStack.back() -> GetChildren().push_back( CreateBone( Name ) );
}
void AnimationPrototype::SetBoneInitialMatrix ( const osg::Matrixf& M )
{
if ( m_pLastBoneAdded )
{
m_pLastBoneAdded -> SetInitialMatrix( M );
}
}
void AnimationPrototype::MoveLevelDown ( )
{
m_BonesLoadingStack.push_back(m_pLastBoneAdded);
}
void AnimationPrototype::MoveLevelUp ( )
{
m_pLastBoneAdded = m_BonesLoadingStack.back();
m_BonesLoadingStack.pop_back();
}
void AnimationPrototype::SetIndexAndModelToBoneMatrix ( const std::string& Name, const osg::Matrixf& Mat )
{
// Look for such a bone in the bone tree
std::map<std::string, Bone *>::iterator It = m_BoneMap.find ( Name );
Bone *bone = NULL;
if ( It == m_BoneMap.end ( ) )
{
// No such a bone in the bone tree. Try to add it to the root bone
bone = CreateBone( Name );
bone -> SetInitialMatrix ( osg::Matrixf::inverse ( Mat ) );
m_RootBone -> GetChildren().push_back( bone );
}
else
{
bone = It->second;
}
bone->SetIndexAndModelToBoneMatrix ( m_nMatrixIndex, Mat );
if ( m_nMatrixIndex > MaxBlendingMatricesPerModel )
{
//avLog( MT_INFO, "Number of blending matrices per model exceeds the maximum.\n" );
}
}
void AnimationPrototype::AddDrawable( const std::string& Name, std::vector<osg::Vec3f>& Vertices, std::vector<osg::Vec3f>& Normals, std::vector<osg::Vec2f>& TxtCoord, std::vector<int>& Indices, std::map<std::string, std::vector<std::pair<int,float>>>& BonesMapOfVerticesWeghtsTables, const std::string& TextureName )
{
int MaxWeightUsed = 0;
// Optimization
#if 1
// Remove duplicated vertices here
// Just calculate unique vertices number
std::vector<int> IndicesRemap;
int UniqueVerticesNum ( 0 );
{
struct VertexCompare
{
VertexCompare ( const std::vector<osg::Vec3f> &Vertices, const std::vector<osg::Vec3f> &Normals, const std::vector<osg::Vec2f> &TxtCoord ) :
_Vertices ( Vertices ),
_Normals ( Normals ),
_TxtCoord ( TxtCoord )
{
}
bool operator()(const int &_Left, const int &_Right) const
{
if ( _Vertices [ _Left ] < _Vertices [ _Right ] )
return true;
if ( _Vertices [ _Right ] < _Vertices [ _Left ] )
return false;
if ( _TxtCoord [ _Left ] < _TxtCoord [ _Right ] )
return true;
if ( _TxtCoord [ _Right ] < _TxtCoord [ _Left ] )
return false;
if ( _Normals [ _Left ] < _Normals [ _Right ] )
return true;
return false;
}
const std::vector<osg::Vec3f> &_Vertices;
const std::vector<osg::Vec3f> &_Normals;
const std::vector<osg::Vec2f> &_TxtCoord;
};
std::map<int,int,VertexCompare> MM ( VertexCompare ( Vertices, Normals, TxtCoord ) );
// check the i-th vertex to be unique if yes then assign it next unique index and store it in MM
// if not then takes the unique index that is already in MM and in any case fill the IndicesRemap
for ( unsigned int i = 0; i < Vertices.size(); i++ )
{
IndicesRemap.push_back ( MM.insert ( std::pair <int,int>( i, (unsigned)MM.size() ) ).first -> second );
}
UniqueVerticesNum = MM.size();
}
// use IndicesRemap for proper remapping of all the data
for ( unsigned int i = 0; i < Indices.size(); i++ )
{
Indices [ i ] = IndicesRemap [ Indices [ i ] ];
}
int AlreadyFilledIndex = -1;
for ( unsigned int i = 0; i < Vertices.size() && AlreadyFilledIndex < UniqueVerticesNum; i++ )
{
int Index = IndicesRemap [ i ];
if ( Index > AlreadyFilledIndex ) // new index
{
Vertices [ Index ] = Vertices [ i ];
Normals [ Index ] = Normals [ i ];
TxtCoord [ Index ] = TxtCoord [ i ];
AlreadyFilledIndex = Index;
}
}
_ASSERT ( AlreadyFilledIndex + 1 == UniqueVerticesNum );
Vertices.resize ( UniqueVerticesNum );
Normals.resize ( UniqueVerticesNum );
TxtCoord.resize ( UniqueVerticesNum );
std::vector<osg::Vec4ub> Matrix_Weights ( UniqueVerticesNum ); // filled by osg::Vec4ub ( )
std::vector<osg::Vec4ub> Matrix_Indices ( UniqueVerticesNum );
// Recalculate per bone weights
for ( std::map<std::string, std::vector<std::pair<int,float>>>::iterator It = BonesMapOfVerticesWeghtsTables.begin ();
It != BonesMapOfVerticesWeghtsTables.end (); ++It )
{
std::vector<bool> HasBeenWritten ( UniqueVerticesNum ); //filled by false
std::vector<std::pair<int,float>> NewTable;
const std::vector<std::pair<int,float>> &OldTable = It -> second;
for ( std::vector<std::pair<int,float>>::const_iterator ItOT = OldTable.begin(); ItOT != OldTable.end(); ++ItOT )
{
int NewIndex = IndicesRemap [ ItOT -> first ];
if ( !HasBeenWritten [ NewIndex ] )
{
HasBeenWritten [ NewIndex ] = true;
NewTable.push_back ( std::pair<int,float> ( NewIndex, ItOT -> second ) );
}
}
It -> second = NewTable;
}
#endif
// Recalculate from vertex weights per matrix to matrix weight per vertex
for ( std::map<std::string, Bone *>::const_iterator BonesIt = m_BoneMap.begin(); BonesIt != m_BoneMap.end(); ++BonesIt )
{
if ( BonesIt -> second -> GetMatrixIndex() == -1 )
{
continue;
}
const std::vector<std::pair<int,float>> &Table = BonesMapOfVerticesWeghtsTables [ BonesIt -> second -> GetName() ];
for ( std::vector<std::pair<int,float>>::const_iterator VertIt = Table.begin(); VertIt != Table.end(); ++VertIt )
{
unsigned char VertexWeight = VertIt -> second * 255.0f;
osg::Vec4ub &Dest_Weights = Matrix_Weights [ VertIt->first ];
osg::Vec4ub &Dest_Indices = Matrix_Indices [ VertIt->first ];
int MinWeightIndex = 0;
int i = 0;
for ( ; i < 4; i++ )
{
if ( Dest_Weights._v [ i ] == 0 )
{
Dest_Weights._v [ i ] = VertexWeight;
Dest_Indices._v [ i ] = BonesIt -> second -> GetMatrixIndex();
break;
}
else if ( Dest_Weights._v [ i ] < Dest_Weights._v [ MinWeightIndex ] )
{
MinWeightIndex = i;
}
}
if ( i == 4 ) // We have more than 4 matrices for this vertex so replace the one with smallest weight
{
//avLog( MT_INFO, "Vertex needs more than 4 matrices for blending. We do not support that now.\n" );
if ( Dest_Weights._v [ MinWeightIndex ] < VertexWeight )
{
Dest_Weights._v [ MinWeightIndex ] = VertexWeight;
Dest_Indices._v [ MinWeightIndex ] = BonesIt -> second -> GetMatrixIndex();
}
}
if ( i + 1 > MaxWeightUsed )
{
MaxWeightUsed = i + 1;
}
}
}
osg::Vec3Array *coords = new osg::Vec3Array;
coords->reserve(Vertices.size());
osg::Vec3Array *normals = new osg::Vec3Array;
normals->reserve(Vertices.size());
osg::Vec2Array *txt_coords = new osg::Vec2Array;
txt_coords->reserve(Vertices.size());
osg::Vec4ubArray *matrix_weights = new osg::Vec4ubArray;
matrix_weights->reserve(Vertices.size());
osg::Vec4ubArray *matrix_indices = new osg::Vec4ubArray;
matrix_indices->reserve(Vertices.size());
for ( unsigned int i = 0; i < Vertices.size(); i++ )
{
coords->push_back ( Vertices [ i ] );
if ( Normals.size () == Vertices.size() )
{
normals->push_back ( Normals [ i ] );
}
if ( TxtCoord.size () == Vertices.size() )
{
txt_coords->push_back ( TxtCoord [ i ] );
}
matrix_weights->push_back ( Matrix_Weights [ i ] );
matrix_indices->push_back ( Matrix_Indices [ i ] );
}
osg::Geometry *geom = new osg::Geometry;
geom->setVertexArray(coords);
if ( Normals.size () == Vertices.size() )
{
geom->setNormalArray(normals);
geom->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
}
if ( TxtCoord.size () == Vertices.size() )
{
geom->setTexCoordArray(0, txt_coords);
}
geom->setVertexAttribArray(1,matrix_weights);
geom->setVertexAttribBinding(1,osg::Geometry::BIND_PER_VERTEX);
geom->setVertexAttribNormalize(1, GL_TRUE );
geom->setVertexAttribArray(5,matrix_indices);
geom->setVertexAttribBinding(5,osg::Geometry::BIND_PER_VERTEX);
geom->setVertexAttribNormalize(5, GL_FALSE );
geom->addPrimitiveSet ( new osg::DrawElementsUInt ( osg::PrimitiveSet::TRIANGLES, Indices.size(), (GLuint*)&Indices [ 0 ] ) );
geom->setCullCallback ( new NamedDrawableCullCallback );
geom->setComputeBoundingBoxCallback ( new AnimatedDrawableComputeBoundingBoxCallback );
geom->setName ( Name );
addDrawable ( geom );
if ( TextureName != "" && !m_bTextureDefined )
{
m_bTextureDefined = true;
osg::StateSet* stateset = getOrCreateStateSet();
stateset->setTextureAttributeAndModes( 0, new osg::Texture2D( m_ResourceLoader->getImage ( TextureName )));
stateset->addUniform( new osg::Uniform("PersonTexture", 0 ) );
}
}
void AnimationPrototype::BeginAnimationSet( const std::string& AnimationSetName )
{
if ( m_bNeedToOptimize )
{
// After all the vertices weights are defined we could optimize the bones tree
// Use the first BeginAnimationSet as the place for the bones tree optimization
OptimizeBonesTree ( );
m_bNeedToOptimize = false;
}
m_CurAnimationSetForLoad = m_Animations.insert ( std::pair <std::string,AnimationSet>( AnimationSetName, AnimationSet() ) ).first;
m_CurAnimationSetForLoad -> second.m_LengthInFrames = 0;
}
void AnimationPrototype::BeginAnimation( const std::string& BoneName, int FramesNum )
{
if ( m_CurAnimationSetForLoad == m_Animations.end() ) // BeginAnimation is called not inside BeginAnimationSet EndAnimationSet pair
{
return;
}
m_CurAnimationSetForLoad -> second.push_back ( AnimationKey ( ) );
AnimationKey& ak = m_CurAnimationSetForLoad -> second.back();
ak.m_pBone = 0;
ak.reserve( FramesNum );
m_InitialMatrix.makeIdentity();
m_bThisMatrixIsNotUsed = false;
m_bAllEqualToInitial = true;
std::map<std::string, Bone *>::iterator It = m_BoneMap.find ( BoneName );
if ( It != m_BoneMap.end ( ) )
{
m_InitialMatrix = It -> second -> GetInitialMatrix();
ak.m_pBone = It -> second;
}
else
{
m_bThisMatrixIsNotUsed = true; // No such a matrix at all or it was removed due to optimization
}
}
void AnimationPrototype::AddFrame( int Frame, const osg::Matrixf& osgM )
{
if ( m_CurAnimationSetForLoad -> second.empty() ) // AddFrame is called not inside BeginAnimation EndAnimation pair
{
return;
}
if ( m_CurAnimationSetForLoad -> second.m_LengthInFrames < Frame )
{
m_CurAnimationSetForLoad -> second.m_LengthInFrames = Frame;
}
if ( !IsEqual ( 0.01f, m_InitialMatrix, osgM ) )
{
m_bAllEqualToInitial = false;
}
AnimationKey& ak = m_CurAnimationSetForLoad -> second.back();
ak.push_back ( FrameBonePosition ( Frame, osgM.getRotate(), osgM.getTrans () ) );
}
void AnimationPrototype::EndAnimation()
{
if ( m_CurAnimationSetForLoad -> second.empty() ) // EndAnimation is called without any BeginAnimation before it
{
return;
}
if ( m_bAllEqualToInitial || m_bThisMatrixIsNotUsed || m_CurAnimationSetForLoad -> second.back().empty() )
{
m_CurAnimationSetForLoad -> second.pop_back();
}
}
void AnimationPrototype::EndAnimationSet()
{
if ( m_CurAnimationSetForLoad -> second.empty() )
{
m_Animations.erase( m_CurAnimationSetForLoad );
}
m_CurAnimationSetForLoad = m_Animations.end();
}
//
} // namespace avAnimation | [
"[email protected]"
] | |
269c089b72e18b7131bdc98ee382456382beb9ad | 16c2aa1096e8d0efed3f3219b22f1b0a86a78c52 | / cf-B - Hills And Valleys - code.cpp | 6da2e4540c8975dceed56642d3a7ef6d93e790f5 | [] | no_license | ash1526/CodeLibrary | e1c36045c979031f98f99fbfbd446d3e29c050b7 | 7ee6fa852e1cc4b38c9160c927fdb0cf580eb5ab | refs/heads/master | 2023-08-17T12:50:16.964705 | 2021-10-19T16:51:43 | 2021-10-19T16:51:43 | 361,191,580 | 0 | 2 | null | 2021-10-04T17:43:18 | 2021-04-24T15:02:46 | C++ | UTF-8 | C++ | false | false | 3,727 | cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define inf LLONG_MAX
#define ninf LLONG_MIN
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(s) s.begin(),s.end()
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define rr(v) for(auto &val:v)
#define _max(v) *max_valment(v.begin(), v.end())
#define _min(v) *min_valment(v.begin(), v.end())
#define ms(s, n) memset(s, n, sizeof(s))
ll power(ll x, ll y){ll res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
ll powermod(ll x, ll y, ll p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
ll gcd(ll a, ll b) { if (b == 0)return a; return gcd(b, a % b);}
ll fact(ll n){ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res; }
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r));}
#define print(v) rep(i, 0, v.size()) cout<< v[i]<< " "; cout<< endl;
#define mod 1e9+7
int main()
{
io;
ll t; cin >> t;
//t=1;
while(t--)
{
vector<ll> v;
ll n, x; cin >> n;
rep(i, 0, n)
{
cin >> x; v.pb(x);
}
vector<ll> v1;
ll ans=0;
rep(i, 1, n)
{
if((i+1)<n and ((v[i-1]>v[i] and v[i+1]>v[i]) or (v[i-1]<v[i] and v[i+1]<v[i])))
{
//cout<< i+1 <<" "<< n << endl;
v1.pb(i);
ans++;
}
}
//print(v1);
ll minans=LLONG_MAX;
rep(i, 0, v1.size())
{
ll left, right, left1, right1, cur, tempans, temp;
temp=v[v1[i]];
left=v[v1[i]-1];
right=v[v1[i]+1];
cur=v[v1[i]];
cur=left;
tempans=ans;
tempans--;
if(v1[i]-2>=0 and ((left>temp and left>v[v1[i]-2]) or (left<temp and left<v[v1[i]-2])))
{
tempans--;
}
if(v1[i]+2<n and ((right>temp and right>v[v1[i]+2]) or (right<temp and right<v[v1[i]+2])))
{
if((right>cur and (right>v[v1[i]+2]) or (right<cur and right<v[v1[i]+2])))
{
}
else {tempans--;}//cout<< "yes\n"<< left;
}
else
{
if(v1[i]+2<n and ((right>cur and right>v[v1[i]+2]) or (right<cur and right<v[v1[i]+2]))) tempans++;
}
if(tempans<minans) minans=tempans;
cur=right;
tempans=ans;
tempans--;
if(v1[i]+2<n and ((right>temp and right>v[v1[i]+2]) or (right<temp and right<v[v1[i]+2])))
{
tempans--;
}
if(v1[i]-2>=0 and ((left>temp and left>v[v1[i]-2]) or (left<temp and left<v[v1[i]-2])))
{
if((left<cur and left<v[v1[i]-2]) or(left>cur and left>v[v1[i]-2]))
{
}
else tempans--;
}
else
{
if(v1[i]-2>=0 and((left<cur and left<v[v1[i]-2]) or(left>cur and left>v[v1[i]-2]))) tempans++;
}
if(tempans<minans) minans=tempans;
v[v1[i]]=temp;
//cout << left << " "<< v[v1[i]] << " "<< right << " " << minans << endl;
}
if(minans==LLONG_MAX) cout << 0 << endl;
else
cout<< minans << endl;
}
return 0;
}
| [
"[email protected]"
] | |
e993629f4ad66a7c3abdd15a97e26bb09896c78a | 717a6d38827731fc75f7966eb86ea9f2e1e00235 | /src/GenSimSteppingVerbose.cc | bc2f5f63b07b193966ee72f9516218e8f1a9dc02 | [] | no_license | hansoullee20/GenSim | e1b0088ef198d1cf07421389275d173002236e30 | dddfe5ee20fcbebb1ac59ec6dc6623213d863451 | refs/heads/master | 2020-04-06T11:49:59.000776 | 2018-11-13T19:19:44 | 2018-11-13T19:19:44 | 157,432,329 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,203 | cc |
#include "GenSimSteppingVerbose.hh"
GenSimSteppingVerbose::GenSimSteppingVerbose()
{;}
GenSimSteppingVerbose::~GenSimSteppingVerbose()
{}
void GenSimSteppingVerbose::StepInfo()
{
// G4cout << "In GenSimSteppingVerbose::StepInfo()" << G4endl;
CopyState();// ??? , from G4VSteppingVerbose
G4int prec = G4cout.precision(3);
// verboseLevel = 3;
if( verboseLevel >= 1 ){
if( verboseLevel >= 4 ) VerboseTrack();
if( verboseLevel >= 3 ){
// G4cout << G4endl;
// G4cout << std::setw( 5) << "#Step#" << " "
// << std::setw( 6) << "X" << " "
// << std::setw( 6) << "Y" << " "
// << std::setw( 6) << "Z" << " "
// << std::setw( 9) << "KineE" << " "
// << std::setw( 9) << "dEStep" << " "
// << std::setw(10) << "StepLeng"
// << std::setw(10) << "TrakLeng"
// << std::setw(10) << "Volume" << " "
// << std::setw(10) << "Process" << G4endl;
}
// G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " "
// << std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
// << std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
// << std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
// << std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
// << std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
// << std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
// << std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
// << " ";
// if( fStepStatus != fWorldBoundary){
if( fTrack->GetNextVolume() != 0 ) {
// G4cout << std::setw(10) << fTrack->GetVolume()->GetName();
} else {
// G4cout << std::setw(10) << "OutOfWorld";
}
if(fStep->GetPostStepPoint()->GetProcessDefinedStep() != NULL){
// G4cout << " "
// << std::setw(10) << fStep->GetPostStepPoint()->GetProcessDefinedStep()
// ->GetProcessName();
} else {
// G4cout << " UserLimit";
}
// G4cout << G4endl;
if( verboseLevel == 2 ){
G4int tN2ndariesTot = fN2ndariesAtRestDoIt +
fN2ndariesAlongStepDoIt +
fN2ndariesPostStepDoIt;
if(tN2ndariesTot>0){
// G4cout << " :----- List of 2ndaries - "
// << "#SpawnInStep=" << std::setw(3) << tN2ndariesTot
// << "(Rest=" << std::setw(2) << fN2ndariesAtRestDoIt
// << ",Along=" << std::setw(2) << fN2ndariesAlongStepDoIt
// << ",Post=" << std::setw(2) << fN2ndariesPostStepDoIt
// << "), "
// << "#SpawnTotal=" << std::setw(3) << (*fSecondary).size()
// << " ---------------"
// << G4endl;
for(size_t lp1=(*fSecondary).size()-tN2ndariesTot;
lp1<(*fSecondary).size(); lp1++){
// G4cout << " : "
// << std::setw(6)
// << G4BestUnit((*fSecondary)[lp1]->GetPosition().x(),"Length")
// << std::setw(6)
// << G4BestUnit((*fSecondary)[lp1]->GetPosition().y(),"Length")
// << std::setw(6)
// << G4BestUnit((*fSecondary)[lp1]->GetPosition().z(),"Length")
// << std::setw(6)
// << G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(),"Energy")
// << std::setw(10)
// << (*fSecondary)[lp1]->GetDefinition()->GetParticleName();
// G4cout << G4endl;
}
// G4cout << " :-----------------------------"
// << "----------------------------------"
// << "-- EndOf2ndaries Info ---------------"
// << G4endl;
}
}
}
G4cout.precision(prec);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void GenSimSteppingVerbose::TrackingStarted()
{
CopyState();
G4int prec = G4cout.precision(3);
if( verboseLevel > 0 ){
// G4cout << std::setw( 5) << "Step#" << " "
// << std::setw( 6) << "X" << " "
// << std::setw( 6) << "Y" << " "
// << std::setw( 6) << "Z" << " "
// << std::setw( 9) << "KineE" << " "
// << std::setw( 9) << "dEStep" << " "
// << std::setw(10) << "StepLeng"
// << std::setw(10) << "TrakLeng"
// << std::setw(10) << "Volume" << " "
// << std::setw(10) << "Process" << G4endl;
// G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " "
// << std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
// << std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
// << std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
// << std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
// << std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
// << std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
// << std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
// << " ";
if(fTrack->GetNextVolume()){
// G4cout << std::setw(10) << fTrack->GetVolume()->GetName();
} else {
// G4cout << std::setw(10) << "OutOfWorld";
}
// G4cout << " initStep" << G4endl;
} // end if ( verboseLevel > 0 )
G4cout.precision(prec);
}
| [
"[email protected]"
] | |
2b1f2d640789b9d59376b7f96fbc956a8c80fdb4 | 7d7ad5c623eef9ca6e73a632a6383ba72bad68f8 | /macro.cpp | 41472f637a5eb996ce28f5fc16ce10225feee32a | [] | no_license | avk2/mathfc | 577b7ce70a47c491dd5390c0ba3c3da6c9367947 | 22efafd0048bd272976fd81fa65205b59d6a030f | refs/heads/master | 2023-01-04T23:12:25.583327 | 2020-10-31T19:29:58 | 2020-10-31T19:29:58 | 308,948,438 | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 4,563 | cpp | /*
Math function compiler version 4.0
File macro.cpp
Platrorms supported : x86 / Win32 and Win64
Author: Kavinov A.V.
*/
#include <algorithm>
#include <cstring>
#ifdef _DEBUG
#include <iostream> // for debugging
#endif
#include "expr.h"
// Some functions are immediately translated to other functions
using namespace std;
TExpression* CreateMacro(const string& FunctionName,
const vector<string>& args)
{
size_t argnum= args.size();
if(argnum==1 && (FunctionName=="cot" || FunctionName=="ctg"))
{
TFunctionCall* innerfunc =
new TFunctionCall("tan",args[0]);
return new TFunctionCall("$inv",innerfunc);
}
if(argnum==1 && (FunctionName=="sinh" || FunctionName=="sh"))
{
TFunctionCall* innerfunc =
new TFunctionCall("exp",args[0]);
return new TFunctionCall("$she",innerfunc);
}
if(argnum==1 && (FunctionName=="cosh" || FunctionName=="ch"))
{
TFunctionCall* innerfunc =
new TFunctionCall("exp",args[0]);
return new TFunctionCall("$che",innerfunc);
}
if(argnum==1 && (FunctionName=="tanh" || FunctionName=="th"))
{
TFunctionCall* innerfunc =
new TFunctionCall("exp",args[0]);
return new TFunctionCall("$the",innerfunc);
}
if(argnum==1 && (FunctionName=="arsinh"
|| FunctionName=="arsh" || FunctionName=="asinh"))
{
TExpression* x1= CreateExpression(args[0]);
TSum* innersum= new TSum(),*outersum= new TSum();
outersum->AddItem(x1,false);
TExpression* x2= x1->CreateCopy();
TFunctionCall* sq= new TFunctionCall("sqr",x2);
innersum->AddItem(sq,false);
innersum->AddItem(new TConstant(1.),false);
TFunctionCall* sqroot= new TFunctionCall("sqrt",innersum);
outersum->AddItem(sqroot,false);
return new TFunctionCall("ln",outersum);
}
if(argnum==1 && (FunctionName=="arcosh"
|| FunctionName=="arch" || FunctionName=="acosh"))
{
TExpression* x1= CreateExpression(args[0]);
TSum* innersum= new TSum(),*outersum= new TSum();
outersum->AddItem(x1,false);
TExpression* x2= x1->CreateCopy();
TFunctionCall* sq= new TFunctionCall("sqr",x2);
innersum->AddItem(sq,false);
innersum->AddItem(new TConstant(1.),true); // отличие от asinh
TFunctionCall* sqroot= new TFunctionCall("sqrt",innersum);
outersum->AddItem(sqroot,false);
return new TFunctionCall("ln",outersum);
}
if(argnum==1 && (FunctionName=="artanh"
|| FunctionName=="arth" || FunctionName=="atanh"))
{
TExpression* x1= CreateExpression(args[0]);
TExpression* x2= x1->CreateCopy();
TProduct* d= new TProduct();
TSum* s1= new TSum(), *s2= new TSum();
s1->AddItem(new TConstant(1.0),false);
s1->AddItem(x1,false);
s2->AddItem(new TConstant(1.0),false);
s2->AddItem(x2,true);
d->AddItem(s1,false);
d->AddItem(s2,true);
TFunctionCall* flog= new TFunctionCall("ln",d);
TProduct* p= new TProduct();
p->AddItem(new TConstant(0.5),false);
p->AddItem(flog,false);
return p;
}
if(FunctionName=="norm1")
{
TSum* sum= new TSum();
for (const string& i : args)
{
if (i.length() == 0) throw EFEmptySubexpression();
TExpression* e=
CreateExpression(i[0] == ',' ? string(i, 1, string::npos) : i);
sum->AddItem(new TFunctionCall("abs",e),false);
}
return sum;
}
if(FunctionName=="norm2")
{
TSum* sum= new TSum();
for (const string& i : args)
{
if (i.length() == 0) throw EFEmptySubexpression();
TExpression* e=
CreateExpression(i[0] == ',' ? string(i, 1, string::npos) : i);
sum->AddItem(new TFunctionCall("sqr",e),false);
}
return new TFunctionCall("sqrt",sum);
}
if(FunctionName=="norminf")
{
vector<TExpression*> max_args;
for (const string& i : args)
{
if (i.length() == 0) throw EFEmptySubexpression();
TExpression* e=
CreateExpression(i[0] == ',' ? string(i, 1, string::npos) : i);
TFunctionCall* a= new TFunctionCall("abs",e);
max_args.push_back(a);
}
return new TFunctionCall("max",std::move(max_args));
}
return nullptr;
}
| [
"[email protected]"
] | |
57ac081f26d392c1cc68746da5bb6375c94a6714 | fa7d492fe04ce4119dad28a24121487f596cd1ef | /cppcolormap.hpp | 03dc1c36319bd0b2fbb7581003d5fb560c45b9ea | [] | no_license | randomplum/wxteq1 | c6eacff828b9992c27222e28ac4088fd970e0773 | 88c397c9d1a214c9d5430c7e5e3aa8f92c681f48 | refs/heads/main | 2023-06-08T15:10:42.033649 | 2021-06-21T22:39:39 | 2021-06-21T22:39:39 | 379,080,197 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 143,295 | hpp | /**
\file cppcolormap.h Colormaps in C++
(c - GPLv3) T.W.J. de Geus (Tom) | [email protected] | www.geus.me | github.com/tdegeus/cppcolormap
*/
#ifndef CPPCOLORMAP_H
#define CPPCOLORMAP_H
#define CPPCOLORMAP_VERSION_MAJOR 1
#define CPPCOLORMAP_VERSION_MINOR 3
#define CPPCOLORMAP_VERSION_PATCH 0
#define CPPCOLORMAP_VERSION_AT_LEAST(x,y,z) \
(CPPCOLORMAP_VERSION_MAJOR > x || (CPPCOLORMAP_VERSION_MAJOR >= x && \
(CPPCOLORMAP_VERSION_MINOR > y || (CPPCOLORMAP_VERSION_MINOR >= y && \
CPPCOLORMAP_VERSION_PATCH >= z))))
#define CPPCOLORMAP_VERSION(x,y,z) \
(CPPCOLORMAP_VERSION_MAJOR == x && \
CPPCOLORMAP_VERSION_MINOR == y && \
CPPCOLORMAP_VERSION_PATCH == z)
// use "M_PI" from "math.h"
#define _USE_MATH_DEFINES
#include <vector>
#include <string>
#include <cfloat>
#include <iostream>
#include <sstream>
#include <math.h>
#include <xtensor/xtensor.hpp>
#include <xtensor/xarray.hpp>
#include <xtensor/xview.hpp>
#include <xtensor/xsort.hpp>
#include <xtensor/xmath.hpp>
#include <xtensor/xmanipulation.hpp>
namespace cppcolormap
{
namespace detail
{
/**
See: https://www.codespeedy.com/convert-rgb-to-hex-color-code-in-cpp
\param r Red [0..255].
\param g Green [0..255].
\param b Blue [0..255].
\return Hex string.
*/
std::string rgb2hex(size_t r, size_t g, size_t b)
{
std::stringstream ss;
ss << "#" << std::hex << (r << 16 | g << 8 | b);
return ss.str();
}
/**
See: https://stackoverflow.com/questions/28104559/arduino-strange-behavior-converting-hex-to-rgb
\param hex Hex string.
\return RGB data.
*/
xt::xtensor<size_t, 1> hex2rgb(std::string hex)
{
if (hex.at(0) == '#') {
hex.erase(0, 1);
}
while (hex.length() != 6) {
hex += "0";
}
xt::xtensor<size_t, 1> rgb = xt::empty<size_t>({size_t(3)});
size_t h = (size_t)std::stol(&hex[0], nullptr, 16);
rgb(0) = h >> 16;
rgb(1) = h >> 8 & 0xFF;
rgb(2) = h & 0xFF;
return rgb;
}
} // namespace detail
/**
Convert RGB -> HEX.
\param data RGB data.
\returns Vector of strings.
*/
std::vector<std::string> rgb2hex(const xt::xtensor<double, 2>& data)
{
std::vector<std::string> out;
for (size_t i = 0; i < data.shape(0); ++i) {
out.push_back(detail::rgb2hex(
static_cast<size_t>(data(i, 0) * 255.0),
static_cast<size_t>(data(i, 1) * 255.0),
static_cast<size_t>(data(i, 2) * 255.0)));
}
return out;
}
/**
Convert RGB -> HEX.
\param data RGB data.
\returns String.
*/
std::string rgb2hex(const xt::xtensor<double, 1>& data)
{
return detail::rgb2hex(
static_cast<size_t>(data(0) * 255.0),
static_cast<size_t>(data(1) * 255.0),
static_cast<size_t>(data(2) * 255.0));
}
/**
Convert HEX -> RGB.
\param hex HEX data.
\returns RGB data.
*/
xt::xtensor<double, 2> hex2rgb(const std::vector<std::string>& hex)
{
xt::xtensor<double, 2> out = xt::empty<double>({hex.size(), size_t(3)});
for (size_t i = 0; i < hex.size(); ++i) {
xt::view(out, i, xt::all()) = detail::hex2rgb(hex[i]);
}
return out / 255.0;
}
/**
Convert HEX -> RGB.
\param hex HEX data.
\returns RGB data.
*/
xt::xtensor<double, 1> hex2rgb(const std::string& hex)
{
return detail::hex2rgb(hex) / 255.0;
}
/**
Interpolate the individual colours.
\param data RGB data.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> interp(const xt::xtensor<double, 2>& data, size_t N)
{
if (N == data.shape(0)) {
return data;
}
xt::xtensor<double, 2> out = xt::empty<double>({N, data.shape(1)});
xt::xtensor<double, 1> x = xt::linspace(0.0, 1.0, data.shape(0));
xt::xtensor<double, 1> xi = xt::linspace(0.0, 1.0, N);
for (size_t j = 0; j < data.shape(1); j++) {
auto c = xt::view(data, xt::all(), j);
auto ci = xt::view(out, xt::all(), j);
ci = xt::interp(xi, x, c);
}
return out;
}
namespace detail {
template <class D, class C, typename V, class R>
inline void as_colors_func(const D& data, const C& colors, V vmin, V vmax, R& ret)
{
assert(vmax > vmin);
assert(colors.shape(0) > 0);
auto d = xt::eval((data - vmin) / (vmax - vmin));
d = xt::where(data < vmin, 0, d);
d = xt::where(data > vmax, 1, d);
auto index = xt::eval(xt::cast<size_t>(d * (colors.shape(0) - 1)));
size_t stride = colors.shape(1);
for (size_t i = 0; i < data.size(); ++i) {
size_t j = index.data()[i];
std::copy(
&colors.data()[j * stride],
&colors.data()[(j + 1) * stride],
&ret.data()[i * stride]);
}
}
template <class E, typename = void>
struct as_colors_impl
{
template <typename T, typename S>
static xt::xarray<T> run(const E& data, const xt::xtensor<T, 2> colors, S vmin, S vmax)
{
size_t N = data.dimension();
std::vector<size_t> shape(N + 1);
std::copy(data.shape().cbegin(), data.shape().cend(), shape.begin());
shape[N] = colors.shape(1);
xt::xarray<T> ret = xt::empty<T>(shape);
as_colors_func(data, colors, vmin, vmax, ret);
return ret;
}
};
}
/**
Convert data to colors using a colormap.
\param data The data.
\param colors The colormap, e.g. ``cppcolormap::jet()``.
\param vmin The lower limit of the color-axis.
\param vmax The upper limit of the color-axis.
*/
template <class E, typename T, typename S>
inline auto as_colors(const E& data, const xt::xtensor<T, 2> colors, S vmin, S vmax)
{
return detail::as_colors_impl<E>::run(data, colors, vmin, vmax);
}
/**
Convert data to colors using a colormap.
\param data The data.
\param colors The colormap, e.g. ``cppcolormap::jet()``.
*/
template <class E, typename T>
inline auto as_colors(const E& data, const xt::xtensor<T, 2> colors)
{
return detail::as_colors_impl<E>::run(data, colors, xt::amin(data)(), xt::amax(data)());
}
/**
Qualitative colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Accent(size_t N = 8)
{
xt::xtensor<double, 2> data = {
{127, 201, 127},
{190, 174, 212},
{253, 192, 134},
{255, 255, 153},
{ 56, 108, 176},
{240, 2, 127},
{191, 91, 23},
{102, 102, 102},
};
return interp(data / 255.0, N);
}
/**
Qualitative colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Dark2(size_t N = 8)
{
xt::xtensor<double, 2> data = {
{ 27, 158, 119},
{217, 95, 2},
{117, 112, 179},
{231, 41, 138},
{102, 166, 30},
{230, 171, 2},
{166, 118, 29},
{102, 102, 102},
};
return interp(data / 255.0, N);
}
/**
Qualitative colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Paired(size_t N = 12)
{
xt::xtensor<double, 2> data = {
{166, 206, 227},
{ 31, 120, 180},
{178, 223, 138},
{ 51, 160, 44},
{251, 154, 153},
{227, 26, 28},
{253, 191, 111},
{255, 127, 0},
{202, 178, 214},
{106, 61, 154},
{255, 255, 153},
{177, 89, 40},
};
return interp(data / 255.0, N);
}
/**
Qualitative colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Spectral(size_t N = 11)
{
xt::xtensor<double, 2> data = {
{158, 1, 66},
{213, 62, 79},
{244, 109, 67},
{253, 174, 97},
{254, 224, 139},
{255, 255, 191},
{230, 245, 152},
{171, 221, 164},
{102, 194, 165},
{ 50, 136, 189},
{ 94, 79, 162},
};
return interp(data / 255.0, N);
}
/**
Qualitative colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Pastel1(size_t N = 9)
{
xt::xtensor<double, 2> data = {
{251, 180, 174},
{179, 205, 227},
{204, 235, 197},
{222, 203, 228},
{254, 217, 166},
{255, 255, 204},
{229, 216, 189},
{253, 218, 236},
{242, 242, 242},
};
return interp(data / 255.0, N);
}
/**
Qualitative colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Pastel2(size_t N = 8)
{
xt::xtensor<double, 2> data = {
{179, 226, 205},
{253, 205, 172},
{203, 213, 232},
{244, 202, 228},
{230, 245, 201},
{255, 242, 174},
{241, 226, 204},
{204, 204, 204},
};
return interp(data / 255.0, N);
}
/**
Qualitative colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Set1(size_t N = 9)
{
xt::xtensor<double, 2> data = {
{228, 26, 28},
{ 55, 126, 184},
{ 77, 175, 74},
{152, 78, 163},
{255, 127, 0},
{255, 255, 51},
{166, 86, 40},
{247, 129, 191},
{153, 153, 153},
};
return interp(data / 255.0, N);
}
/**
Qualitative colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Set2(size_t N = 8)
{
xt::xtensor<double, 2> data = {
{102, 194, 165},
{252, 141, 98},
{141, 160, 203},
{231, 138, 195},
{166, 216, 84},
{255, 217, 47},
{229, 196, 148},
{179, 179, 179},
};
return interp(data / 255.0, N);
}
/**
Qualitative colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Set3(size_t N = 12)
{
xt::xtensor<double, 2> data = {
{141, 211, 199},
{255, 255, 179},
{190, 186, 218},
{251, 128, 114},
{128, 177, 211},
{253, 180, 98},
{179, 222, 105},
{252, 205, 229},
{217, 217, 217},
{188, 128, 189},
{204, 235, 197},
{255, 237, 111},
};
return interp(data / 255.0, N);
}
/**
Sequential colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Blues(size_t N = 9)
{
xt::xtensor<double, 2> data = {
{247, 251, 255},
{222, 235, 247},
{198, 219, 239},
{158, 202, 225},
{107, 174, 214},
{ 66, 146, 198},
{ 33, 113, 181},
{ 8, 81, 156},
{ 8, 48, 107},
};
return interp(data / 255.0, N);
}
/**
Sequential colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Greens(size_t N = 9)
{
xt::xtensor<double, 2> data = {
{247, 252, 245},
{229, 245, 224},
{199, 233, 192},
{161, 217, 155},
{116, 196, 118},
{ 65, 171, 93},
{ 35, 139, 69},
{ 0, 109, 44},
{ 0, 68, 27},
};
return interp(data / 255.0, N);
}
/**
Sequential colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Greys(size_t N = 2)
{
xt::xtensor<double, 2> data = {
{255, 255, 255},
{ 0, 0, 0},
};
return interp(data / 255.0, N);
}
/**
Sequential colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Oranges(size_t N = 9)
{
xt::xtensor<double, 2> data = {
{255, 245, 235},
{254, 230, 206},
{253, 208, 162},
{253, 174, 107},
{253, 141, 60},
{241, 105, 19},
{217, 72, 1},
{166, 54, 3},
{127, 39, 4},
};
return interp(data / 255.0, N);
}
/**
Sequential colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Purples(size_t N = 9)
{
xt::xtensor<double, 2> data = {
{252, 251, 253},
{239, 237, 245},
{218, 218, 235},
{188, 189, 220},
{158, 154, 200},
{128, 125, 186},
{106, 81, 163},
{ 84, 39, 143},
{ 63, 0, 125},
};
return interp(data / 255.0, N);
}
/**
Sequential colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Reds(size_t N = 9)
{
xt::xtensor<double, 2> data = {
{255, 245, 240},
{254, 224, 210},
{252, 187, 161},
{252, 146, 114},
{251, 106, 74},
{239, 59, 44},
{203, 24, 29},
{165, 15, 21},
{103, 0, 13},
};
return interp(data / 255.0, N);
}
/**
Sequential colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> BuPu(size_t N = 9)
{
xt::xtensor<double, 2> data = {
{247, 252, 253},
{224, 236, 244},
{191, 211, 230},
{158, 188, 218},
{140, 150, 198},
{140, 107, 177},
{136, 65, 157},
{129, 15, 124},
{ 77, 0, 75},
};
return interp(data / 255.0, N);
}
/**
Sequential colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> GnBu(size_t N = 9)
{
xt::xtensor<double, 2> data = {
{247, 252, 240},
{224, 243, 219},
{204, 235, 197},
{168, 221, 181},
{123, 204, 196},
{ 78, 179, 211},
{ 43, 140, 190},
{ 8, 104, 172},
{ 8, 64, 129},
};
return interp(data / 255.0, N);
}
/**
Sequential colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> PuBu(size_t N = 9)
{
xt::xtensor<double, 2> data = {
{255, 247, 251},
{236, 231, 242},
{208, 209, 230},
{166, 189, 219},
{116, 169, 207},
{ 54, 144, 192},
{ 5, 112, 176},
{ 4, 90, 141},
{ 2, 56, 88},
};
return interp(data / 255.0, N);
}
/**
Sequential colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> PuBuGn(size_t N = 9)
{
xt::xtensor<double, 2> data = {
{255, 247, 251},
{236, 226, 240},
{208, 209, 230},
{166, 189, 219},
{103, 169, 207},
{ 54, 144, 192},
{ 2, 129, 138},
{ 1, 108, 89},
{ 1, 70, 54},
};
return interp(data / 255.0, N);
}
/**
Sequential colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> PuRd(size_t N = 9)
{
xt::xtensor<double, 2> data = {
{247, 244, 249},
{231, 225, 239},
{212, 185, 218},
{201, 148, 199},
{223, 101, 176},
{231, 41, 138},
{206, 18, 86},
{152, 0, 67},
{103, 0, 31},
};
return interp(data / 255.0, N);
}
/**
Sequential colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> RdPu(size_t N = 9)
{
xt::xtensor<double, 2> data = {
{255, 247, 243},
{253, 224, 221},
{252, 197, 192},
{250, 159, 181},
{247, 104, 161},
{221, 52, 151},
{174, 1, 126},
{122, 1, 119},
{ 73, 0, 106},
};
return interp(data / 255.0, N);
}
/**
Sequential colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> OrRd(size_t N = 9)
{
xt::xtensor<double, 2> data = {
{255, 247, 236},
{254, 232, 200},
{253, 212, 158},
{253, 187, 132},
{252, 141, 89},
{239, 101, 72},
{215, 48, 31},
{179, 0, 0},
{127, 0, 0},
};
return interp(data / 255.0, N);
}
/**
Sequential colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> RdOrYl(size_t N = 9)
{
xt::xtensor<double, 2> data = {
{128, 0 , 38 },
{189, 0 , 38 },
{227, 26 , 28 },
{252, 78 , 42 },
{253, 141, 60 },
{254, 178, 76 },
{254, 217, 118},
{255, 237, 160},
{255, 255, 204},
};
return interp(data / 255.0, N);
}
/**
Sequential colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> YlGn(size_t N = 9)
{
xt::xtensor<double, 2> data = {
{255, 255, 229},
{247, 252, 185},
{217, 240, 163},
{173, 221, 142},
{120, 198, 121},
{ 65, 171, 93},
{ 35, 132, 67},
{ 0, 104, 55},
{ 0, 69, 41},
};
return interp(data / 255.0, N);
}
/**
Sequential colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> YlGnBu(size_t N = 9)
{
xt::xtensor<double, 2> data = {
{255, 255, 217},
{237, 248, 177},
{199, 233, 180},
{127, 205, 187},
{ 65, 182, 196},
{ 29, 145, 192},
{ 34, 94, 168},
{ 37, 52, 148},
{ 8, 29, 88},
};
return interp(data / 255.0, N);
}
/**
Sequential colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> YlOrRd(size_t N = 9)
{
xt::xtensor<double, 2> data = {
{255, 255, 204},
{255, 237, 160},
{254, 217, 118},
{254, 178, 76},
{253, 141, 60},
{252, 78, 42},
{227, 26, 28},
{189, 0, 38},
{128, 0, 38},
};
return interp(data / 255.0, N);
}
/**
Diverging colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> BrBG(size_t N = 11)
{
xt::xtensor<double, 2> data = {
{ 84, 48, 5},
{140, 81, 10},
{191, 129, 45},
{223, 194, 125},
{246, 232, 195},
{245, 245, 245},
{199, 234, 229},
{128, 205, 193},
{ 53, 151, 143},
{ 1, 102, 94},
{ 0, 60, 48},
};
return interp(data / 255.0, N);
}
/**
Diverging colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> PuOr(size_t N = 11)
{
xt::xtensor<double, 2> data = {
{127, 59, 8},
{179, 88, 6},
{224, 130, 20},
{253, 184, 99},
{254, 224, 182},
{247, 247, 247},
{216, 218, 235},
{178, 171, 210},
{128, 115, 172},
{ 84, 39, 136},
{ 45, 0, 75},
};
return interp(data / 255.0, N);
}
/**
Diverging colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> RdBu(size_t N = 11)
{
xt::xtensor<double, 2> data = {
{103, 0, 31},
{178, 24, 43},
{214, 96, 77},
{244, 165, 130},
{253, 219, 199},
{247, 247, 247},
{209, 229, 240},
{146, 197, 222},
{ 67, 147, 195},
{ 33, 102, 172},
{ 5, 48, 97},
};
return interp(data / 255.0, N);
}
/**
Diverging colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> RdGy(size_t N = 11)
{
xt::xtensor<double, 2> data = {
{103, 0, 31},
{178, 24, 43},
{214, 96, 77},
{244, 165, 130},
{253, 219, 199},
{255, 255, 255},
{224, 224, 224},
{186, 186, 186},
{135, 135, 135},
{ 77, 77, 77},
{ 26, 26, 26},
};
return interp(data / 255.0, N);
}
/**
Diverging colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> RdYlBu(size_t N = 11)
{
xt::xtensor<double, 2> data = {
{165, 0, 38},
{215, 48, 39},
{244, 109, 67},
{253, 174, 97},
{254, 224, 144},
{255, 255, 191},
{224, 243, 248},
{171, 217, 233},
{116, 173, 209},
{ 69, 117, 180},
{ 49, 54, 149},
};
return interp(data / 255.0, N);
}
/**
Diverging colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> RdYlGn(size_t N = 11)
{
xt::xtensor<double, 2> data = {
{165, 0, 38},
{215, 48, 39},
{244, 109, 67},
{253, 174, 97},
{254, 224, 139},
{255, 255, 191},
{217, 239, 139},
{166, 217, 106},
{102, 189, 99},
{ 26, 152, 80},
{ 0, 104, 55},
};
return interp(data / 255.0, N);
}
/**
Diverging colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> PiYG(size_t N = 11)
{
xt::xtensor<double, 2> data = {
{142, 1, 82},
{197, 27, 125},
{222, 119, 174},
{241, 182, 218},
{253, 224, 239},
{247, 247, 247},
{230, 245, 208},
{184, 225, 134},
{127, 188, 65},
{ 77, 146, 33},
{ 39, 100, 25},
};
return interp(data / 255.0, N);
}
/**
Diverging colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> PRGn(size_t N = 11)
{
xt::xtensor<double, 2> data = {
{ 64, 0, 75},
{118, 42, 131},
{153, 112, 171},
{194, 165, 207},
{231, 212, 232},
{247, 247, 247},
{217, 240, 211},
{166, 219, 160},
{ 90, 174, 97},
{ 27, 120, 55},
{ 0, 68, 27},
};
return interp(data / 255.0, N);
}
namespace detail
{
inline xt::xtensor<double, 1> from_anchor_color(size_t N, const xt::xtensor<double, 2>& x)
{
size_t n = x.shape(0);
xt::xtensor<size_t, 1> idx = xt::view(x, xt::all(), 0) * (double)N;
idx(0) = 0;
idx(n - 1) = N;
xt::xtensor<double, 1> ret = xt::empty<double>({N});
for (size_t i = 0; i < n - 1; ++i) {
xt::view(ret, xt::range(idx(i), idx(i + 1))) =
x(i, 2) + (x(i + 1, 1) - x(i, 2)) * xt::linspace<double>(0.0, 1.0, idx(i + 1) - idx(i));
}
return ret;
}
inline xt::xtensor<double, 2> from_anchor(
size_t N,
const xt::xtensor<double, 2>& r,
const xt::xtensor<double, 2>& g,
const xt::xtensor<double, 2>& b)
{
std::array<size_t, 2> shape = {N, 3};
xt::xtensor<double, 2> ret(shape);
xt::view(ret, xt::all(), 0) = from_anchor_color(N, r);
xt::view(ret, xt::all(), 1) = from_anchor_color(N, g);
xt::view(ret, xt::all(), 2) = from_anchor_color(N, b);
return ret;
}
} // namespace detail
/**
matplotlib colormap, from anchor.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> spring(size_t N = 256)
{
xt::xtensor<double, 2> r = {
{0.0, 1.0, 1.0},
{1.0, 1.0, 1.0}};
xt::xtensor<double, 2> g = {
{0.0, 0.0, 0.0},
{1.0, 1.0, 1.0}};
xt::xtensor<double, 2> b = {
{0.0, 1.0, 1.0},
{1.0, 0.0, 0.0}};
return detail::from_anchor(N, r, g, b);
}
/**
matplotlib colormap, from anchor.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> summer(size_t N = 256)
{
xt::xtensor<double, 2> r = {
{0.0, 0.0, 0.0},
{1.0, 1.0, 1.0}};
xt::xtensor<double, 2> g = {
{0.0, 0.5, 0.5},
{1.0, 1.0, 1.0}};
xt::xtensor<double, 2> b = {
{0.0, 0.4, 0.4},
{1.0, 0.4, 0.4}};
return detail::from_anchor(N, r, g, b);
}
/**
matplotlib colormap, from anchor.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> autumn(size_t N = 256)
{
xt::xtensor<double, 2> r = {
{0.0, 1.0, 1.0},
{1.0, 1.0, 1.0}};
xt::xtensor<double, 2> g = {
{0.0, 0.0, 0.0},
{1.0, 1.0, 1.0}};
xt::xtensor<double, 2> b = {
{0.0, 0.0, 0.0},
{1.0, 0.0, 0.0}};
return detail::from_anchor(N, r, g, b);
}
/**
matplotlib colormap, from anchor.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> winter(size_t N = 256)
{
xt::xtensor<double, 2> r = {
{0.0, 0.0, 0.0},
{1.0, 0.0, 0.0}};
xt::xtensor<double, 2> g = {
{0.0, 0.0, 0.0},
{1.0, 1.0, 1.0}};
xt::xtensor<double, 2> b = {
{0.0, 1.0, 1.0},
{1.0, 0.5, 0.5}};
return detail::from_anchor(N, r, g, b);
}
/**
matplotlib colormap, from anchor.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> bone(size_t N = 256)
{
xt::xtensor<double, 2> r = {
{0.0, 0.0, 0.0},
{0.746032, 0.652778, 0.652778},
{1.0, 1.0, 1.0}};
xt::xtensor<double, 2> g = {
{0.0, 0.0, 0.0},
{0.365079, 0.319444, 0.319444},
{0.746032, 0.777778, 0.777778},
{1.0, 1.0, 1.0}};
xt::xtensor<double, 2> b = {
{0.0, 0.0, 0.0},
{0.365079, 0.444444, 0.444444},
{1.0, 1.0, 1.0}};
return detail::from_anchor(N, r, g, b);
}
/**
matplotlib colormap, from anchor.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> cool(size_t N = 256)
{
xt::xtensor<double, 2> r = {
{0.0, 0.0, 0.0},
{1.0, 1.0, 1.0}};
xt::xtensor<double, 2> g = {
{0.0, 1.0, 1.0},
{1.0, 0.0, 0.0}};
xt::xtensor<double, 2> b = {
{0.0, 1.0, 1.0},
{1.0, 1.0, 1.0}};
return detail::from_anchor(N, r, g, b);
}
/**
matplotlib colormap, from anchor.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> hot(size_t N = 256)
{
xt::xtensor<double, 2> r = {
{0.0, 0.0416, 0.0416},
{0.365079, 1.000000, 1.000000},
{1.0, 1.0, 1.0}};
xt::xtensor<double, 2> g = {
{0.0, 0.0, 0.0},
{0.365079, 0.000000, 0.000000},
{0.746032, 1.000000, 1.000000},
{1.0, 1.0, 1.0}};
xt::xtensor<double, 2> b = {
{0.0, 0.0, 0.0},
{0.746032, 0.000000, 0.000000},
{1.0, 1.0, 1.0}};
return detail::from_anchor(N, r, g, b);
}
/**
matplotlib colormap, from anchor.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> copper(size_t N = 256)
{
xt::xtensor<double, 2> r = {
{0.0, 0.0, 0.0},
{0.809524, 1.000000, 1.000000},
{1.0, 1.0, 1.0}};
xt::xtensor<double, 2> g = {
{0.0, 0.0, 0.0},
{1.0, 0.7812, 0.7812}};
xt::xtensor<double, 2> b = {
{0.0, 0.0, 0.0},
{1.0, 0.4975, 0.4975}};
return detail::from_anchor(N, r, g, b);
}
/**
matplotlib colormap, from anchor.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> hsv(size_t N = 256)
{
xt::xtensor<double, 2> r = {
{0.0, 1.0, 1.0},
{0.158730, 1.000000, 1.000000},
{0.174603, 0.968750, 0.968750},
{0.333333, 0.031250, 0.031250},
{0.349206, 0.000000, 0.000000},
{0.666667, 0.000000, 0.000000},
{0.682540, 0.031250, 0.031250},
{0.841270, 0.968750, 0.968750},
{0.857143, 1.000000, 1.000000},
{1.0, 1.0, 1.0}};
xt::xtensor<double, 2> g = {
{0.0, 0.0, 0.0},
{0.158730, 0.937500, 0.937500},
{0.174603, 1.000000, 1.000000},
{0.507937, 1.000000, 1.000000},
{0.666667, 0.062500, 0.062500},
{0.682540, 0.000000, 0.000000},
{1.0, 0.0, 0.0}};
xt::xtensor<double, 2> b = {
{0.0, 0.0, 0.0},
{0.333333, 0.000000, 0.000000},
{0.349206, 0.062500, 0.062500},
{0.507937, 1.000000, 1.000000},
{0.841270, 1.000000, 1.000000},
{0.857143, 0.937500, 0.937500},
{1.0, 0.09375, 0.09375}};
return detail::from_anchor(N, r, g, b);
}
/**
matplotlib colormap, from anchor.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> nipy_spectral(size_t N = 256)
{
xt::xtensor<double, 2> r = {
{0.0, 0.0, 0.0},
{0.05, 0.4667, 0.4667},
{0.10, 0.5333, 0.5333},
{0.15, 0.0, 0.0},
{0.20, 0.0, 0.0},
{0.25, 0.0, 0.0},
{0.30, 0.0, 0.0},
{0.35, 0.0, 0.0},
{0.40, 0.0, 0.0},
{0.45, 0.0, 0.0},
{0.50, 0.0, 0.0},
{0.55, 0.0, 0.0},
{0.60, 0.0, 0.0},
{0.65, 0.7333, 0.7333},
{0.70, 0.9333, 0.9333},
{0.75, 1.0, 1.0},
{0.80, 1.0, 1.0},
{0.85, 1.0, 1.0},
{0.90, 0.8667, 0.8667},
{0.95, 0.80, 0.80},
{1.0, 0.80, 0.80}};
xt::xtensor<double, 2> g = {
{0.0, 0.0, 0.0},
{0.05, 0.0, 0.0},
{0.10, 0.0, 0.0},
{0.15, 0.0, 0.0},
{0.20, 0.0, 0.0},
{0.25, 0.4667, 0.4667},
{0.30, 0.6000, 0.6000},
{0.35, 0.6667, 0.6667},
{0.40, 0.6667, 0.6667},
{0.45, 0.6000, 0.6000},
{0.50, 0.7333, 0.7333},
{0.55, 0.8667, 0.8667},
{0.60, 1.0, 1.0},
{0.65, 1.0, 1.0},
{0.70, 0.9333, 0.9333},
{0.75, 0.8000, 0.8000},
{0.80, 0.6000, 0.6000},
{0.85, 0.0, 0.0},
{0.90, 0.0, 0.0},
{0.95, 0.0, 0.0},
{1.0, 0.80, 0.80}};
xt::xtensor<double, 2> b = {
{0.0, 0.0, 0.0},
{0.05, 0.5333, 0.5333},
{0.10, 0.6000, 0.6000},
{0.15, 0.6667, 0.6667},
{0.20, 0.8667, 0.8667},
{0.25, 0.8667, 0.8667},
{0.30, 0.8667, 0.8667},
{0.35, 0.6667, 0.6667},
{0.40, 0.5333, 0.5333},
{0.45, 0.0, 0.0},
{0.5, 0.0, 0.0},
{0.55, 0.0, 0.0},
{0.60, 0.0, 0.0},
{0.65, 0.0, 0.0},
{0.70, 0.0, 0.0},
{0.75, 0.0, 0.0},
{0.80, 0.0, 0.0},
{0.85, 0.0, 0.0},
{0.90, 0.0, 0.0},
{0.95, 0.0, 0.0},
{1.0, 0.80, 0.80}};
return detail::from_anchor(N, r, g, b);
}
/**
matplotlib colormap, from anchor.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> jet(size_t N = 256)
{
xt::xtensor<double, 2> r = {
{0.00, 0.0, 0.0},
{0.35, 0.0, 0.0},
{0.66, 1.0, 1.0},
{0.89, 1.0, 1.0},
{1.00, 0.5, 0.5}};
xt::xtensor<double, 2> g = {
{0.000, 0.0, 0.0},
{0.125, 0.0, 0.0},
{0.375, 1.0, 1.0},
{0.640, 1.0, 1.0},
{0.910, 0.0, 0.0},
{1.000, 0.0, 0.0}};
xt::xtensor<double, 2> b = {
{0.00, 0.5, 0.5},
{0.11, 1.0, 1.0},
{0.34, 1.0, 1.0},
{0.65, 0.0, 0.0},
{1.00, 0.0, 0.0}};
return detail::from_anchor(N, r, g, b);
}
namespace detail
{
inline xt::xtensor<double, 2> from_fraction(size_t N, const xt::xtensor<double, 2>& x)
{
size_t n = x.shape(0);
xt::xtensor<size_t, 1> idx = xt::view(x, xt::all(), 0) * (double)N;
idx(0) = 0;
idx(n - 1) = N;
std::array<size_t, 2> shape = {N, 3};
xt::xtensor<double, 2> ret(shape);
for (size_t i = 0; i < n - 1; ++i) {
for (size_t j = 0; j < 3; ++j) {
xt::view(ret, xt::range(idx(i), idx(i + 1)), j)
= x(i, j + 1)
+ (x(i + 1, j + 1) - x(i, j + 1))
* xt::linspace<double>(0.0, 1.0, idx(i + 1) - idx(i));
}
}
return ret;
}
} // namespace detail
/**
matplotlib colormap, from fraction.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> terrain(size_t N = 6)
{
xt::xtensor<double, 2> data = {
{0.00, 0.2, 0.2, 0.6},
{0.15, 0.0, 0.6, 1.0},
{0.25, 0.0, 0.8, 0.4},
{0.50, 1.0, 1.0, 0.6},
{0.75, 0.5, 0.36, 0.33},
{1.00, 1.0, 1.0, 1.0}};
return detail::from_fraction(N, data);
}
namespace detail
{
// Gnuplot palette functions
inline xt::xtensor<double, 1> _g0(const xt::xtensor<double, 1>& x)
{
return xt::zeros_like(x);
}
inline xt::xtensor<double, 1> _g1(const xt::xtensor<double, 1>& x)
{
return 0.5 * xt::ones_like(x);
}
inline xt::xtensor<double, 1> _g2(const xt::xtensor<double, 1>& x)
{
return xt::ones_like(x);
}
inline xt::xtensor<double, 1> _g3(const xt::xtensor<double, 1>& x)
{
return x;
}
inline xt::xtensor<double, 1> _g4(const xt::xtensor<double, 1>& x)
{
return xt::pow(x, 2.0);
}
inline xt::xtensor<double, 1> _g5(const xt::xtensor<double, 1>& x)
{
return xt::pow(x, 3.0);
}
inline xt::xtensor<double, 1> _g6(const xt::xtensor<double, 1>& x)
{
return xt::pow(x, 4.0);
}
inline xt::xtensor<double, 1> _g7(const xt::xtensor<double, 1>& x)
{
return xt::sqrt(x);
}
inline xt::xtensor<double, 1> _g8(const xt::xtensor<double, 1>& x)
{
return xt::sqrt(xt::sqrt(x));
}
inline xt::xtensor<double, 1> _g9(const xt::xtensor<double, 1>& x)
{
return xt::sin(x * M_PI * 0.5);
}
inline xt::xtensor<double, 1> _g10(const xt::xtensor<double, 1>& x)
{
return xt::cos(x * M_PI * 0.5);
}
inline xt::xtensor<double, 1> _g11(const xt::xtensor<double, 1>& x)
{
return xt::abs(x - 0.5);
}
inline xt::xtensor<double, 1> _g12(const xt::xtensor<double, 1>& x)
{
return xt::pow(2.0 * x - 1.0, 2.0);
}
inline xt::xtensor<double, 1> _g13(const xt::xtensor<double, 1>& x)
{
return xt::sin(x * M_PI);
}
inline xt::xtensor<double, 1> _g14(const xt::xtensor<double, 1>& x)
{
return xt::abs(xt::cos(x * M_PI));
}
inline xt::xtensor<double, 1> _g15(const xt::xtensor<double, 1>& x)
{
return xt::sin(x * 2.0 * M_PI);
}
inline xt::xtensor<double, 1> _g16(const xt::xtensor<double, 1>& x)
{
return xt::cos(x * 2.0 * M_PI);
}
inline xt::xtensor<double, 1> _g17(const xt::xtensor<double, 1>& x)
{
return xt::abs(xt::sin(x * 2.0 * M_PI));
}
inline xt::xtensor<double, 1> _g18(const xt::xtensor<double, 1>& x)
{
return xt::abs(xt::cos(x * 2.0 * M_PI));
}
inline xt::xtensor<double, 1> _g19(const xt::xtensor<double, 1>& x)
{
return xt::abs(xt::sin(x * 4.0 * M_PI));
}
inline xt::xtensor<double, 1> _g20(const xt::xtensor<double, 1>& x)
{
return xt::abs(xt::cos(x * 4.0 * M_PI));
}
inline xt::xtensor<double, 1> _g21(const xt::xtensor<double, 1>& x)
{
return 3.0 * x;
}
inline xt::xtensor<double, 1> _g22(const xt::xtensor<double, 1>& x)
{
return 3.0 * x - 1.0;
}
inline xt::xtensor<double, 1> _g23(const xt::xtensor<double, 1>& x)
{
return 3.0 * x - 2.0;
}
inline xt::xtensor<double, 1> _g24(const xt::xtensor<double, 1>& x)
{
return xt::abs(3.0 * x - 1.0);
}
inline xt::xtensor<double, 1> _g25(const xt::xtensor<double, 1>& x)
{
return xt::abs(3.0 * x - 2.0);
}
inline xt::xtensor<double, 1> _g26(const xt::xtensor<double, 1>& x)
{
return (3.0 * x - 1.0) * 0.5;
}
inline xt::xtensor<double, 1> _g27(const xt::xtensor<double, 1>& x)
{
return (3.0 * x - 2.0) * 0.5;
}
inline xt::xtensor<double, 1> _g28(const xt::xtensor<double, 1>& x)
{
return xt::abs((3.0 * x - 1.0) * 0.5);
}
inline xt::xtensor<double, 1> _g29(const xt::xtensor<double, 1>& x)
{
return xt::abs((3.0 * x - 2.0) * 0.5);
}
inline xt::xtensor<double, 1> _g30(const xt::xtensor<double, 1>& x)
{
return x / 0.32 - 0.78125;
}
inline xt::xtensor<double, 1> _g31(const xt::xtensor<double, 1>& x)
{
return 2.0 * x - 0.84;
}
inline xt::xtensor<double, 1> _g32(const xt::xtensor<double, 1>& x)
{
auto ret = xt::zeros_like(x);
ret = xt::where(xt::less(x, 0.25), 4.0 * x, ret);
ret = xt::where(xt::greater_equal(x, 0.25) && xt::less(x, 0.92), -2.0 * x + 1.84, ret);
ret = xt::where(xt::greater_equal(x, 0.92), x / 0.08 - 11.5, ret);
return ret;
}
inline xt::xtensor<double, 1> _g33(const xt::xtensor<double, 1>& x)
{
return xt::abs(2.0 * x - 0.5);
}
inline xt::xtensor<double, 1> _g34(const xt::xtensor<double, 1>& x)
{
return 2.0 * x;
}
inline xt::xtensor<double, 1> _g35(const xt::xtensor<double, 1>& x)
{
return 2.0 * x - 0.5;
}
inline xt::xtensor<double, 1> _g36(const xt::xtensor<double, 1>& x)
{
return 2.0 * x - 1.0;
}
inline xt::xtensor<double, 1> gnu_palette(size_t i, const xt::xtensor<double, 1>& x)
{
xt::xtensor<double, 1> ret;
if (i == 0) { ret = _g0(x); }
else if (i == 1) { ret = _g1(x); }
else if (i == 2) { ret = _g2(x); }
else if (i == 3) { ret = _g3(x); }
else if (i == 4) { ret = _g4(x); }
else if (i == 5) { ret = _g5(x); }
else if (i == 6) { ret = _g6(x); }
else if (i == 7) { ret = _g7(x); }
else if (i == 8) { ret = _g8(x); }
else if (i == 9) { ret = _g9(x); }
else if (i == 10) { ret = _g10(x); }
else if (i == 11) { ret = _g11(x); }
else if (i == 12) { ret = _g12(x); }
else if (i == 13) { ret = _g13(x); }
else if (i == 14) { ret = _g14(x); }
else if (i == 15) { ret = _g15(x); }
else if (i == 16) { ret = _g16(x); }
else if (i == 17) { ret = _g17(x); }
else if (i == 18) { ret = _g18(x); }
else if (i == 19) { ret = _g19(x); }
else if (i == 20) { ret = _g20(x); }
else if (i == 21) { ret = _g21(x); }
else if (i == 22) { ret = _g22(x); }
else if (i == 23) { ret = _g23(x); }
else if (i == 24) { ret = _g24(x); }
else if (i == 25) { ret = _g25(x); }
else if (i == 26) { ret = _g26(x); }
else if (i == 27) { ret = _g27(x); }
else if (i == 28) { ret = _g28(x); }
else if (i == 29) { ret = _g29(x); }
else if (i == 30) { ret = _g30(x); }
else if (i == 31) { ret = _g31(x); }
else if (i == 32) { ret = _g32(x); }
else if (i == 33) { ret = _g33(x); }
else if (i == 34) { ret = _g34(x); }
else if (i == 35) { ret = _g35(x); }
else if (i == 36) { ret = _g36(x); }
else { throw std::runtime_error("gnu_palette out-of-bounds"); }
ret = xt::where(xt::greater(ret, 1.0), 1.0, ret);
ret = xt::where(xt::less(ret, 0.0), 0.0, ret);
return ret;
}
} // namespace detail
/**
GNU plot colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> afmhot(size_t N = 256)
{
std::array<size_t, 2> shape = {N, 3};
xt::xtensor<double, 2> data(shape);
xt::xtensor<double, 1> x = xt::linspace<double>(0.0, 1.0, N);
xt::view(data, xt::all(), 0) = detail::gnu_palette(34, x);
xt::view(data, xt::all(), 1) = detail::gnu_palette(35, x);
xt::view(data, xt::all(), 2) = detail::gnu_palette(36, x);
return data;
}
/**
matplotlib colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> magma(size_t N = 256)
{
xt::xtensor<double, 2> data = {
{0.001462, 0.000466, 0.013866},
{0.002258, 0.001295, 0.018331},
{0.003279, 0.002305, 0.023708},
{0.004512, 0.003490, 0.029965},
{0.005950, 0.004843, 0.037130},
{0.007588, 0.006356, 0.044973},
{0.009426, 0.008022, 0.052844},
{0.011465, 0.009828, 0.060750},
{0.013708, 0.011771, 0.068667},
{0.016156, 0.013840, 0.076603},
{0.018815, 0.016026, 0.084584},
{0.021692, 0.018320, 0.092610},
{0.024792, 0.020715, 0.100676},
{0.028123, 0.023201, 0.108787},
{0.031696, 0.025765, 0.116965},
{0.035520, 0.028397, 0.125209},
{0.039608, 0.031090, 0.133515},
{0.043830, 0.033830, 0.141886},
{0.048062, 0.036607, 0.150327},
{0.052320, 0.039407, 0.158841},
{0.056615, 0.042160, 0.167446},
{0.060949, 0.044794, 0.176129},
{0.065330, 0.047318, 0.184892},
{0.069764, 0.049726, 0.193735},
{0.074257, 0.052017, 0.202660},
{0.078815, 0.054184, 0.211667},
{0.083446, 0.056225, 0.220755},
{0.088155, 0.058133, 0.229922},
{0.092949, 0.059904, 0.239164},
{0.097833, 0.061531, 0.248477},
{0.102815, 0.063010, 0.257854},
{0.107899, 0.064335, 0.267289},
{0.113094, 0.065492, 0.276784},
{0.118405, 0.066479, 0.286321},
{0.123833, 0.067295, 0.295879},
{0.129380, 0.067935, 0.305443},
{0.135053, 0.068391, 0.315000},
{0.140858, 0.068654, 0.324538},
{0.146785, 0.068738, 0.334011},
{0.152839, 0.068637, 0.343404},
{0.159018, 0.068354, 0.352688},
{0.165308, 0.067911, 0.361816},
{0.171713, 0.067305, 0.370771},
{0.178212, 0.066576, 0.379497},
{0.184801, 0.065732, 0.387973},
{0.191460, 0.064818, 0.396152},
{0.198177, 0.063862, 0.404009},
{0.204935, 0.062907, 0.411514},
{0.211718, 0.061992, 0.418647},
{0.218512, 0.061158, 0.425392},
{0.225302, 0.060445, 0.431742},
{0.232077, 0.059889, 0.437695},
{0.238826, 0.059517, 0.443256},
{0.245543, 0.059352, 0.448436},
{0.252220, 0.059415, 0.453248},
{0.258857, 0.059706, 0.457710},
{0.265447, 0.060237, 0.461840},
{0.271994, 0.060994, 0.465660},
{0.278493, 0.061978, 0.469190},
{0.284951, 0.063168, 0.472451},
{0.291366, 0.064553, 0.475462},
{0.297740, 0.066117, 0.478243},
{0.304081, 0.067835, 0.480812},
{0.310382, 0.069702, 0.483186},
{0.316654, 0.071690, 0.485380},
{0.322899, 0.073782, 0.487408},
{0.329114, 0.075972, 0.489287},
{0.335308, 0.078236, 0.491024},
{0.341482, 0.080564, 0.492631},
{0.347636, 0.082946, 0.494121},
{0.353773, 0.085373, 0.495501},
{0.359898, 0.087831, 0.496778},
{0.366012, 0.090314, 0.497960},
{0.372116, 0.092816, 0.499053},
{0.378211, 0.095332, 0.500067},
{0.384299, 0.097855, 0.501002},
{0.390384, 0.100379, 0.501864},
{0.396467, 0.102902, 0.502658},
{0.402548, 0.105420, 0.503386},
{0.408629, 0.107930, 0.504052},
{0.414709, 0.110431, 0.504662},
{0.420791, 0.112920, 0.505215},
{0.426877, 0.115395, 0.505714},
{0.432967, 0.117855, 0.506160},
{0.439062, 0.120298, 0.506555},
{0.445163, 0.122724, 0.506901},
{0.451271, 0.125132, 0.507198},
{0.457386, 0.127522, 0.507448},
{0.463508, 0.129893, 0.507652},
{0.469640, 0.132245, 0.507809},
{0.475780, 0.134577, 0.507921},
{0.481929, 0.136891, 0.507989},
{0.488088, 0.139186, 0.508011},
{0.494258, 0.141462, 0.507988},
{0.500438, 0.143719, 0.507920},
{0.506629, 0.145958, 0.507806},
{0.512831, 0.148179, 0.507648},
{0.519045, 0.150383, 0.507443},
{0.525270, 0.152569, 0.507192},
{0.531507, 0.154739, 0.506895},
{0.537755, 0.156894, 0.506551},
{0.544015, 0.159033, 0.506159},
{0.550287, 0.161158, 0.505719},
{0.556571, 0.163269, 0.505230},
{0.562866, 0.165368, 0.504692},
{0.569172, 0.167454, 0.504105},
{0.575490, 0.169530, 0.503466},
{0.581819, 0.171596, 0.502777},
{0.588158, 0.173652, 0.502035},
{0.594508, 0.175701, 0.501241},
{0.600868, 0.177743, 0.500394},
{0.607238, 0.179779, 0.499492},
{0.613617, 0.181811, 0.498536},
{0.620005, 0.183840, 0.497524},
{0.626401, 0.185867, 0.496456},
{0.632805, 0.187893, 0.495332},
{0.639216, 0.189921, 0.494150},
{0.645633, 0.191952, 0.492910},
{0.652056, 0.193986, 0.491611},
{0.658483, 0.196027, 0.490253},
{0.664915, 0.198075, 0.488836},
{0.671349, 0.200133, 0.487358},
{0.677786, 0.202203, 0.485819},
{0.684224, 0.204286, 0.484219},
{0.690661, 0.206384, 0.482558},
{0.697098, 0.208501, 0.480835},
{0.703532, 0.210638, 0.479049},
{0.709962, 0.212797, 0.477201},
{0.716387, 0.214982, 0.475290},
{0.722805, 0.217194, 0.473316},
{0.729216, 0.219437, 0.471279},
{0.735616, 0.221713, 0.469180},
{0.742004, 0.224025, 0.467018},
{0.748378, 0.226377, 0.464794},
{0.754737, 0.228772, 0.462509},
{0.761077, 0.231214, 0.460162},
{0.767398, 0.233705, 0.457755},
{0.773695, 0.236249, 0.455289},
{0.779968, 0.238851, 0.452765},
{0.786212, 0.241514, 0.450184},
{0.792427, 0.244242, 0.447543},
{0.798608, 0.247040, 0.444848},
{0.804752, 0.249911, 0.442102},
{0.810855, 0.252861, 0.439305},
{0.816914, 0.255895, 0.436461},
{0.822926, 0.259016, 0.433573},
{0.828886, 0.262229, 0.430644},
{0.834791, 0.265540, 0.427671},
{0.840636, 0.268953, 0.424666},
{0.846416, 0.272473, 0.421631},
{0.852126, 0.276106, 0.418573},
{0.857763, 0.279857, 0.415496},
{0.863320, 0.283729, 0.412403},
{0.868793, 0.287728, 0.409303},
{0.874176, 0.291859, 0.406205},
{0.879464, 0.296125, 0.403118},
{0.884651, 0.300530, 0.400047},
{0.889731, 0.305079, 0.397002},
{0.894700, 0.309773, 0.393995},
{0.899552, 0.314616, 0.391037},
{0.904281, 0.319610, 0.388137},
{0.908884, 0.324755, 0.385308},
{0.913354, 0.330052, 0.382563},
{0.917689, 0.335500, 0.379915},
{0.921884, 0.341098, 0.377376},
{0.925937, 0.346844, 0.374959},
{0.929845, 0.352734, 0.372677},
{0.933606, 0.358764, 0.370541},
{0.937221, 0.364929, 0.368567},
{0.940687, 0.371224, 0.366762},
{0.944006, 0.377643, 0.365136},
{0.947180, 0.384178, 0.363701},
{0.950210, 0.390820, 0.362468},
{0.953099, 0.397563, 0.361438},
{0.955849, 0.404400, 0.360619},
{0.958464, 0.411324, 0.360014},
{0.960949, 0.418323, 0.359630},
{0.963310, 0.425390, 0.359469},
{0.965549, 0.432519, 0.359529},
{0.967671, 0.439703, 0.359810},
{0.969680, 0.446936, 0.360311},
{0.971582, 0.454210, 0.361030},
{0.973381, 0.461520, 0.361965},
{0.975082, 0.468861, 0.363111},
{0.976690, 0.476226, 0.364466},
{0.978210, 0.483612, 0.366025},
{0.979645, 0.491014, 0.367783},
{0.981000, 0.498428, 0.369734},
{0.982279, 0.505851, 0.371874},
{0.983485, 0.513280, 0.374198},
{0.984622, 0.520713, 0.376698},
{0.985693, 0.528148, 0.379371},
{0.986700, 0.535582, 0.382210},
{0.987646, 0.543015, 0.385210},
{0.988533, 0.550446, 0.388365},
{0.989363, 0.557873, 0.391671},
{0.990138, 0.565296, 0.395122},
{0.990871, 0.572706, 0.398714},
{0.991558, 0.580107, 0.402441},
{0.992196, 0.587502, 0.406299},
{0.992785, 0.594891, 0.410283},
{0.993326, 0.602275, 0.414390},
{0.993834, 0.609644, 0.418613},
{0.994309, 0.616999, 0.422950},
{0.994738, 0.624350, 0.427397},
{0.995122, 0.631696, 0.431951},
{0.995480, 0.639027, 0.436607},
{0.995810, 0.646344, 0.441361},
{0.996096, 0.653659, 0.446213},
{0.996341, 0.660969, 0.451160},
{0.996580, 0.668256, 0.456192},
{0.996775, 0.675541, 0.461314},
{0.996925, 0.682828, 0.466526},
{0.997077, 0.690088, 0.471811},
{0.997186, 0.697349, 0.477182},
{0.997254, 0.704611, 0.482635},
{0.997325, 0.711848, 0.488154},
{0.997351, 0.719089, 0.493755},
{0.997351, 0.726324, 0.499428},
{0.997341, 0.733545, 0.505167},
{0.997285, 0.740772, 0.510983},
{0.997228, 0.747981, 0.516859},
{0.997138, 0.755190, 0.522806},
{0.997019, 0.762398, 0.528821},
{0.996898, 0.769591, 0.534892},
{0.996727, 0.776795, 0.541039},
{0.996571, 0.783977, 0.547233},
{0.996369, 0.791167, 0.553499},
{0.996162, 0.798348, 0.559820},
{0.995932, 0.805527, 0.566202},
{0.995680, 0.812706, 0.572645},
{0.995424, 0.819875, 0.579140},
{0.995131, 0.827052, 0.585701},
{0.994851, 0.834213, 0.592307},
{0.994524, 0.841387, 0.598983},
{0.994222, 0.848540, 0.605696},
{0.993866, 0.855711, 0.612482},
{0.993545, 0.862859, 0.619299},
{0.993170, 0.870024, 0.626189},
{0.992831, 0.877168, 0.633109},
{0.992440, 0.884330, 0.640099},
{0.992089, 0.891470, 0.647116},
{0.991688, 0.898627, 0.654202},
{0.991332, 0.905763, 0.661309},
{0.990930, 0.912915, 0.668481},
{0.990570, 0.920049, 0.675675},
{0.990175, 0.927196, 0.682926},
{0.989815, 0.934329, 0.690198},
{0.989434, 0.941470, 0.697519},
{0.989077, 0.948604, 0.704863},
{0.988717, 0.955742, 0.712242},
{0.988367, 0.962878, 0.719649},
{0.988033, 0.970012, 0.727077},
{0.987691, 0.977154, 0.734536},
{0.987387, 0.984288, 0.742002},
{0.987053, 0.991438, 0.749504},
};
return interp(data, N);
}
/**
matplotlib colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> inferno(size_t N = 256)
{
xt::xtensor<double, 2> data = {
{0.001462, 0.000466, 0.013866},
{0.002267, 0.001270, 0.018570},
{0.003299, 0.002249, 0.024239},
{0.004547, 0.003392, 0.030909},
{0.006006, 0.004692, 0.038558},
{0.007676, 0.006136, 0.046836},
{0.009561, 0.007713, 0.055143},
{0.011663, 0.009417, 0.063460},
{0.013995, 0.011225, 0.071862},
{0.016561, 0.013136, 0.080282},
{0.019373, 0.015133, 0.088767},
{0.022447, 0.017199, 0.097327},
{0.025793, 0.019331, 0.105930},
{0.029432, 0.021503, 0.114621},
{0.033385, 0.023702, 0.123397},
{0.037668, 0.025921, 0.132232},
{0.042253, 0.028139, 0.141141},
{0.046915, 0.030324, 0.150164},
{0.051644, 0.032474, 0.159254},
{0.056449, 0.034569, 0.168414},
{0.061340, 0.036590, 0.177642},
{0.066331, 0.038504, 0.186962},
{0.071429, 0.040294, 0.196354},
{0.076637, 0.041905, 0.205799},
{0.081962, 0.043328, 0.215289},
{0.087411, 0.044556, 0.224813},
{0.092990, 0.045583, 0.234358},
{0.098702, 0.046402, 0.243904},
{0.104551, 0.047008, 0.253430},
{0.110536, 0.047399, 0.262912},
{0.116656, 0.047574, 0.272321},
{0.122908, 0.047536, 0.281624},
{0.129285, 0.047293, 0.290788},
{0.135778, 0.046856, 0.299776},
{0.142378, 0.046242, 0.308553},
{0.149073, 0.045468, 0.317085},
{0.155850, 0.044559, 0.325338},
{0.162689, 0.043554, 0.333277},
{0.169575, 0.042489, 0.340874},
{0.176493, 0.041402, 0.348111},
{0.183429, 0.040329, 0.354971},
{0.190367, 0.039309, 0.361447},
{0.197297, 0.038400, 0.367535},
{0.204209, 0.037632, 0.373238},
{0.211095, 0.037030, 0.378563},
{0.217949, 0.036615, 0.383522},
{0.224763, 0.036405, 0.388129},
{0.231538, 0.036405, 0.392400},
{0.238273, 0.036621, 0.396353},
{0.244967, 0.037055, 0.400007},
{0.251620, 0.037705, 0.403378},
{0.258234, 0.038571, 0.406485},
{0.264810, 0.039647, 0.409345},
{0.271347, 0.040922, 0.411976},
{0.277850, 0.042353, 0.414392},
{0.284321, 0.043933, 0.416608},
{0.290763, 0.045644, 0.418637},
{0.297178, 0.047470, 0.420491},
{0.303568, 0.049396, 0.422182},
{0.309935, 0.051407, 0.423721},
{0.316282, 0.053490, 0.425116},
{0.322610, 0.055634, 0.426377},
{0.328921, 0.057827, 0.427511},
{0.335217, 0.060060, 0.428524},
{0.341500, 0.062325, 0.429425},
{0.347771, 0.064616, 0.430217},
{0.354032, 0.066925, 0.430906},
{0.360284, 0.069247, 0.431497},
{0.366529, 0.071579, 0.431994},
{0.372768, 0.073915, 0.432400},
{0.379001, 0.076253, 0.432719},
{0.385228, 0.078591, 0.432955},
{0.391453, 0.080927, 0.433109},
{0.397674, 0.083257, 0.433183},
{0.403894, 0.085580, 0.433179},
{0.410113, 0.087896, 0.433098},
{0.416331, 0.090203, 0.432943},
{0.422549, 0.092501, 0.432714},
{0.428768, 0.094790, 0.432412},
{0.434987, 0.097069, 0.432039},
{0.441207, 0.099338, 0.431594},
{0.447428, 0.101597, 0.431080},
{0.453651, 0.103848, 0.430498},
{0.459875, 0.106089, 0.429846},
{0.466100, 0.108322, 0.429125},
{0.472328, 0.110547, 0.428334},
{0.478558, 0.112764, 0.427475},
{0.484789, 0.114974, 0.426548},
{0.491022, 0.117179, 0.425552},
{0.497257, 0.119379, 0.424488},
{0.503493, 0.121575, 0.423356},
{0.509730, 0.123769, 0.422156},
{0.515967, 0.125960, 0.420887},
{0.522206, 0.128150, 0.419549},
{0.528444, 0.130341, 0.418142},
{0.534683, 0.132534, 0.416667},
{0.540920, 0.134729, 0.415123},
{0.547157, 0.136929, 0.413511},
{0.553392, 0.139134, 0.411829},
{0.559624, 0.141346, 0.410078},
{0.565854, 0.143567, 0.408258},
{0.572081, 0.145797, 0.406369},
{0.578304, 0.148039, 0.404411},
{0.584521, 0.150294, 0.402385},
{0.590734, 0.152563, 0.400290},
{0.596940, 0.154848, 0.398125},
{0.603139, 0.157151, 0.395891},
{0.609330, 0.159474, 0.393589},
{0.615513, 0.161817, 0.391219},
{0.621685, 0.164184, 0.388781},
{0.627847, 0.166575, 0.386276},
{0.633998, 0.168992, 0.383704},
{0.640135, 0.171438, 0.381065},
{0.646260, 0.173914, 0.378359},
{0.652369, 0.176421, 0.375586},
{0.658463, 0.178962, 0.372748},
{0.664540, 0.181539, 0.369846},
{0.670599, 0.184153, 0.366879},
{0.676638, 0.186807, 0.363849},
{0.682656, 0.189501, 0.360757},
{0.688653, 0.192239, 0.357603},
{0.694627, 0.195021, 0.354388},
{0.700576, 0.197851, 0.351113},
{0.706500, 0.200728, 0.347777},
{0.712396, 0.203656, 0.344383},
{0.718264, 0.206636, 0.340931},
{0.724103, 0.209670, 0.337424},
{0.729909, 0.212759, 0.333861},
{0.735683, 0.215906, 0.330245},
{0.741423, 0.219112, 0.326576},
{0.747127, 0.222378, 0.322856},
{0.752794, 0.225706, 0.319085},
{0.758422, 0.229097, 0.315266},
{0.764010, 0.232554, 0.311399},
{0.769556, 0.236077, 0.307485},
{0.775059, 0.239667, 0.303526},
{0.780517, 0.243327, 0.299523},
{0.785929, 0.247056, 0.295477},
{0.791293, 0.250856, 0.291390},
{0.796607, 0.254728, 0.287264},
{0.801871, 0.258674, 0.283099},
{0.807082, 0.262692, 0.278898},
{0.812239, 0.266786, 0.274661},
{0.817341, 0.270954, 0.270390},
{0.822386, 0.275197, 0.266085},
{0.827372, 0.279517, 0.261750},
{0.832299, 0.283913, 0.257383},
{0.837165, 0.288385, 0.252988},
{0.841969, 0.292933, 0.248564},
{0.846709, 0.297559, 0.244113},
{0.851384, 0.302260, 0.239636},
{0.855992, 0.307038, 0.235133},
{0.860533, 0.311892, 0.230606},
{0.865006, 0.316822, 0.226055},
{0.869409, 0.321827, 0.221482},
{0.873741, 0.326906, 0.216886},
{0.878001, 0.332060, 0.212268},
{0.882188, 0.337287, 0.207628},
{0.886302, 0.342586, 0.202968},
{0.890341, 0.347957, 0.198286},
{0.894305, 0.353399, 0.193584},
{0.898192, 0.358911, 0.188860},
{0.902003, 0.364492, 0.184116},
{0.905735, 0.370140, 0.179350},
{0.909390, 0.375856, 0.174563},
{0.912966, 0.381636, 0.169755},
{0.916462, 0.387481, 0.164924},
{0.919879, 0.393389, 0.160070},
{0.923215, 0.399359, 0.155193},
{0.926470, 0.405389, 0.150292},
{0.929644, 0.411479, 0.145367},
{0.932737, 0.417627, 0.140417},
{0.935747, 0.423831, 0.135440},
{0.938675, 0.430091, 0.130438},
{0.941521, 0.436405, 0.125409},
{0.944285, 0.442772, 0.120354},
{0.946965, 0.449191, 0.115272},
{0.949562, 0.455660, 0.110164},
{0.952075, 0.462178, 0.105031},
{0.954506, 0.468744, 0.099874},
{0.956852, 0.475356, 0.094695},
{0.959114, 0.482014, 0.089499},
{0.961293, 0.488716, 0.084289},
{0.963387, 0.495462, 0.079073},
{0.965397, 0.502249, 0.073859},
{0.967322, 0.509078, 0.068659},
{0.969163, 0.515946, 0.063488},
{0.970919, 0.522853, 0.058367},
{0.972590, 0.529798, 0.053324},
{0.974176, 0.536780, 0.048392},
{0.975677, 0.543798, 0.043618},
{0.977092, 0.550850, 0.039050},
{0.978422, 0.557937, 0.034931},
{0.979666, 0.565057, 0.031409},
{0.980824, 0.572209, 0.028508},
{0.981895, 0.579392, 0.026250},
{0.982881, 0.586606, 0.024661},
{0.983779, 0.593849, 0.023770},
{0.984591, 0.601122, 0.023606},
{0.985315, 0.608422, 0.024202},
{0.985952, 0.615750, 0.025592},
{0.986502, 0.623105, 0.027814},
{0.986964, 0.630485, 0.030908},
{0.987337, 0.637890, 0.034916},
{0.987622, 0.645320, 0.039886},
{0.987819, 0.652773, 0.045581},
{0.987926, 0.660250, 0.051750},
{0.987945, 0.667748, 0.058329},
{0.987874, 0.675267, 0.065257},
{0.987714, 0.682807, 0.072489},
{0.987464, 0.690366, 0.079990},
{0.987124, 0.697944, 0.087731},
{0.986694, 0.705540, 0.095694},
{0.986175, 0.713153, 0.103863},
{0.985566, 0.720782, 0.112229},
{0.984865, 0.728427, 0.120785},
{0.984075, 0.736087, 0.129527},
{0.983196, 0.743758, 0.138453},
{0.982228, 0.751442, 0.147565},
{0.981173, 0.759135, 0.156863},
{0.980032, 0.766837, 0.166353},
{0.978806, 0.774545, 0.176037},
{0.977497, 0.782258, 0.185923},
{0.976108, 0.789974, 0.196018},
{0.974638, 0.797692, 0.206332},
{0.973088, 0.805409, 0.216877},
{0.971468, 0.813122, 0.227658},
{0.969783, 0.820825, 0.238686},
{0.968041, 0.828515, 0.249972},
{0.966243, 0.836191, 0.261534},
{0.964394, 0.843848, 0.273391},
{0.962517, 0.851476, 0.285546},
{0.960626, 0.859069, 0.298010},
{0.958720, 0.866624, 0.310820},
{0.956834, 0.874129, 0.323974},
{0.954997, 0.881569, 0.337475},
{0.953215, 0.888942, 0.351369},
{0.951546, 0.896226, 0.365627},
{0.950018, 0.903409, 0.380271},
{0.948683, 0.910473, 0.395289},
{0.947594, 0.917399, 0.410665},
{0.946809, 0.924168, 0.426373},
{0.946392, 0.930761, 0.442367},
{0.946403, 0.937159, 0.458592},
{0.946903, 0.943348, 0.474970},
{0.947937, 0.949318, 0.491426},
{0.949545, 0.955063, 0.507860},
{0.951740, 0.960587, 0.524203},
{0.954529, 0.965896, 0.540361},
{0.957896, 0.971003, 0.556275},
{0.961812, 0.975924, 0.571925},
{0.966249, 0.980678, 0.587206},
{0.971162, 0.985282, 0.602154},
{0.976511, 0.989753, 0.616760},
{0.982257, 0.994109, 0.631017},
{0.988362, 0.998364, 0.644924},
};
return interp(data, N);
}
/**
matplotlib colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> plasma(size_t N = 256)
{
xt::xtensor<double, 2> data = {
{0.050383, 0.029803, 0.527975},
{0.063536, 0.028426, 0.533124},
{0.075353, 0.027206, 0.538007},
{0.086222, 0.026125, 0.542658},
{0.096379, 0.025165, 0.547103},
{0.105980, 0.024309, 0.551368},
{0.115124, 0.023556, 0.555468},
{0.123903, 0.022878, 0.559423},
{0.132381, 0.022258, 0.563250},
{0.140603, 0.021687, 0.566959},
{0.148607, 0.021154, 0.570562},
{0.156421, 0.020651, 0.574065},
{0.164070, 0.020171, 0.577478},
{0.171574, 0.019706, 0.580806},
{0.178950, 0.019252, 0.584054},
{0.186213, 0.018803, 0.587228},
{0.193374, 0.018354, 0.590330},
{0.200445, 0.017902, 0.593364},
{0.207435, 0.017442, 0.596333},
{0.214350, 0.016973, 0.599239},
{0.221197, 0.016497, 0.602083},
{0.227983, 0.016007, 0.604867},
{0.234715, 0.015502, 0.607592},
{0.241396, 0.014979, 0.610259},
{0.248032, 0.014439, 0.612868},
{0.254627, 0.013882, 0.615419},
{0.261183, 0.013308, 0.617911},
{0.267703, 0.012716, 0.620346},
{0.274191, 0.012109, 0.622722},
{0.280648, 0.011488, 0.625038},
{0.287076, 0.010855, 0.627295},
{0.293478, 0.010213, 0.629490},
{0.299855, 0.009561, 0.631624},
{0.306210, 0.008902, 0.633694},
{0.312543, 0.008239, 0.635700},
{0.318856, 0.007576, 0.637640},
{0.325150, 0.006915, 0.639512},
{0.331426, 0.006261, 0.641316},
{0.337683, 0.005618, 0.643049},
{0.343925, 0.004991, 0.644710},
{0.350150, 0.004382, 0.646298},
{0.356359, 0.003798, 0.647810},
{0.362553, 0.003243, 0.649245},
{0.368733, 0.002724, 0.650601},
{0.374897, 0.002245, 0.651876},
{0.381047, 0.001814, 0.653068},
{0.387183, 0.001434, 0.654177},
{0.393304, 0.001114, 0.655199},
{0.399411, 0.000859, 0.656133},
{0.405503, 0.000678, 0.656977},
{0.411580, 0.000577, 0.657730},
{0.417642, 0.000564, 0.658390},
{0.423689, 0.000646, 0.658956},
{0.429719, 0.000831, 0.659425},
{0.435734, 0.001127, 0.659797},
{0.441732, 0.001540, 0.660069},
{0.447714, 0.002080, 0.660240},
{0.453677, 0.002755, 0.660310},
{0.459623, 0.003574, 0.660277},
{0.465550, 0.004545, 0.660139},
{0.471457, 0.005678, 0.659897},
{0.477344, 0.006980, 0.659549},
{0.483210, 0.008460, 0.659095},
{0.489055, 0.010127, 0.658534},
{0.494877, 0.011990, 0.657865},
{0.500678, 0.014055, 0.657088},
{0.506454, 0.016333, 0.656202},
{0.512206, 0.018833, 0.655209},
{0.517933, 0.021563, 0.654109},
{0.523633, 0.024532, 0.652901},
{0.529306, 0.027747, 0.651586},
{0.534952, 0.031217, 0.650165},
{0.540570, 0.034950, 0.648640},
{0.546157, 0.038954, 0.647010},
{0.551715, 0.043136, 0.645277},
{0.557243, 0.047331, 0.643443},
{0.562738, 0.051545, 0.641509},
{0.568201, 0.055778, 0.639477},
{0.573632, 0.060028, 0.637349},
{0.579029, 0.064296, 0.635126},
{0.584391, 0.068579, 0.632812},
{0.589719, 0.072878, 0.630408},
{0.595011, 0.077190, 0.627917},
{0.600266, 0.081516, 0.625342},
{0.605485, 0.085854, 0.622686},
{0.610667, 0.090204, 0.619951},
{0.615812, 0.094564, 0.617140},
{0.620919, 0.098934, 0.614257},
{0.625987, 0.103312, 0.611305},
{0.631017, 0.107699, 0.608287},
{0.636008, 0.112092, 0.605205},
{0.640959, 0.116492, 0.602065},
{0.645872, 0.120898, 0.598867},
{0.650746, 0.125309, 0.595617},
{0.655580, 0.129725, 0.592317},
{0.660374, 0.134144, 0.588971},
{0.665129, 0.138566, 0.585582},
{0.669845, 0.142992, 0.582154},
{0.674522, 0.147419, 0.578688},
{0.679160, 0.151848, 0.575189},
{0.683758, 0.156278, 0.571660},
{0.688318, 0.160709, 0.568103},
{0.692840, 0.165141, 0.564522},
{0.697324, 0.169573, 0.560919},
{0.701769, 0.174005, 0.557296},
{0.706178, 0.178437, 0.553657},
{0.710549, 0.182868, 0.550004},
{0.714883, 0.187299, 0.546338},
{0.719181, 0.191729, 0.542663},
{0.723444, 0.196158, 0.538981},
{0.727670, 0.200586, 0.535293},
{0.731862, 0.205013, 0.531601},
{0.736019, 0.209439, 0.527908},
{0.740143, 0.213864, 0.524216},
{0.744232, 0.218288, 0.520524},
{0.748289, 0.222711, 0.516834},
{0.752312, 0.227133, 0.513149},
{0.756304, 0.231555, 0.509468},
{0.760264, 0.235976, 0.505794},
{0.764193, 0.240396, 0.502126},
{0.768090, 0.244817, 0.498465},
{0.771958, 0.249237, 0.494813},
{0.775796, 0.253658, 0.491171},
{0.779604, 0.258078, 0.487539},
{0.783383, 0.262500, 0.483918},
{0.787133, 0.266922, 0.480307},
{0.790855, 0.271345, 0.476706},
{0.794549, 0.275770, 0.473117},
{0.798216, 0.280197, 0.469538},
{0.801855, 0.284626, 0.465971},
{0.805467, 0.289057, 0.462415},
{0.809052, 0.293491, 0.458870},
{0.812612, 0.297928, 0.455338},
{0.816144, 0.302368, 0.451816},
{0.819651, 0.306812, 0.448306},
{0.823132, 0.311261, 0.444806},
{0.826588, 0.315714, 0.441316},
{0.830018, 0.320172, 0.437836},
{0.833422, 0.324635, 0.434366},
{0.836801, 0.329105, 0.430905},
{0.840155, 0.333580, 0.427455},
{0.843484, 0.338062, 0.424013},
{0.846788, 0.342551, 0.420579},
{0.850066, 0.347048, 0.417153},
{0.853319, 0.351553, 0.413734},
{0.856547, 0.356066, 0.410322},
{0.859750, 0.360588, 0.406917},
{0.862927, 0.365119, 0.403519},
{0.866078, 0.369660, 0.400126},
{0.869203, 0.374212, 0.396738},
{0.872303, 0.378774, 0.393355},
{0.875376, 0.383347, 0.389976},
{0.878423, 0.387932, 0.386600},
{0.881443, 0.392529, 0.383229},
{0.884436, 0.397139, 0.379860},
{0.887402, 0.401762, 0.376494},
{0.890340, 0.406398, 0.373130},
{0.893250, 0.411048, 0.369768},
{0.896131, 0.415712, 0.366407},
{0.898984, 0.420392, 0.363047},
{0.901807, 0.425087, 0.359688},
{0.904601, 0.429797, 0.356329},
{0.907365, 0.434524, 0.352970},
{0.910098, 0.439268, 0.349610},
{0.912800, 0.444029, 0.346251},
{0.915471, 0.448807, 0.342890},
{0.918109, 0.453603, 0.339529},
{0.920714, 0.458417, 0.336166},
{0.923287, 0.463251, 0.332801},
{0.925825, 0.468103, 0.329435},
{0.928329, 0.472975, 0.326067},
{0.930798, 0.477867, 0.322697},
{0.933232, 0.482780, 0.319325},
{0.935630, 0.487712, 0.315952},
{0.937990, 0.492667, 0.312575},
{0.940313, 0.497642, 0.309197},
{0.942598, 0.502639, 0.305816},
{0.944844, 0.507658, 0.302433},
{0.947051, 0.512699, 0.299049},
{0.949217, 0.517763, 0.295662},
{0.951344, 0.522850, 0.292275},
{0.953428, 0.527960, 0.288883},
{0.955470, 0.533093, 0.285490},
{0.957469, 0.538250, 0.282096},
{0.959424, 0.543431, 0.278701},
{0.961336, 0.548636, 0.275305},
{0.963203, 0.553865, 0.271909},
{0.965024, 0.559118, 0.268513},
{0.966798, 0.564396, 0.265118},
{0.968526, 0.569700, 0.261721},
{0.970205, 0.575028, 0.258325},
{0.971835, 0.580382, 0.254931},
{0.973416, 0.585761, 0.251540},
{0.974947, 0.591165, 0.248151},
{0.976428, 0.596595, 0.244767},
{0.977856, 0.602051, 0.241387},
{0.979233, 0.607532, 0.238013},
{0.980556, 0.613039, 0.234646},
{0.981826, 0.618572, 0.231287},
{0.983041, 0.624131, 0.227937},
{0.984199, 0.629718, 0.224595},
{0.985301, 0.635330, 0.221265},
{0.986345, 0.640969, 0.217948},
{0.987332, 0.646633, 0.214648},
{0.988260, 0.652325, 0.211364},
{0.989128, 0.658043, 0.208100},
{0.989935, 0.663787, 0.204859},
{0.990681, 0.669558, 0.201642},
{0.991365, 0.675355, 0.198453},
{0.991985, 0.681179, 0.195295},
{0.992541, 0.687030, 0.192170},
{0.993032, 0.692907, 0.189084},
{0.993456, 0.698810, 0.186041},
{0.993814, 0.704741, 0.183043},
{0.994103, 0.710698, 0.180097},
{0.994324, 0.716681, 0.177208},
{0.994474, 0.722691, 0.174381},
{0.994553, 0.728728, 0.171622},
{0.994561, 0.734791, 0.168938},
{0.994495, 0.740880, 0.166335},
{0.994355, 0.746995, 0.163821},
{0.994141, 0.753137, 0.161404},
{0.993851, 0.759304, 0.159092},
{0.993482, 0.765499, 0.156891},
{0.993033, 0.771720, 0.154808},
{0.992505, 0.777967, 0.152855},
{0.991897, 0.784239, 0.151042},
{0.991209, 0.790537, 0.149377},
{0.990439, 0.796859, 0.147870},
{0.989587, 0.803205, 0.146529},
{0.988648, 0.809579, 0.145357},
{0.987621, 0.815978, 0.144363},
{0.986509, 0.822401, 0.143557},
{0.985314, 0.828846, 0.142945},
{0.984031, 0.835315, 0.142528},
{0.982653, 0.841812, 0.142303},
{0.981190, 0.848329, 0.142279},
{0.979644, 0.854866, 0.142453},
{0.977995, 0.861432, 0.142808},
{0.976265, 0.868016, 0.143351},
{0.974443, 0.874622, 0.144061},
{0.972530, 0.881250, 0.144923},
{0.970533, 0.887896, 0.145919},
{0.968443, 0.894564, 0.147014},
{0.966271, 0.901249, 0.148180},
{0.964021, 0.907950, 0.149370},
{0.961681, 0.914672, 0.150520},
{0.959276, 0.921407, 0.151566},
{0.956808, 0.928152, 0.152409},
{0.954287, 0.934908, 0.152921},
{0.951726, 0.941671, 0.152925},
{0.949151, 0.948435, 0.152178},
{0.946602, 0.955190, 0.150328},
{0.944152, 0.961916, 0.146861},
{0.941896, 0.968590, 0.140956},
{0.940015, 0.975158, 0.131326},
};
return interp(data, N);
}
/**
matplotlib colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> viridis(size_t N = 256)
{
xt::xtensor<double, 2> data = {
{0.267004, 0.004874, 0.329415},
{0.268510, 0.009605, 0.335427},
{0.269944, 0.014625, 0.341379},
{0.271305, 0.019942, 0.347269},
{0.272594, 0.025563, 0.353093},
{0.273809, 0.031497, 0.358853},
{0.274952, 0.037752, 0.364543},
{0.276022, 0.044167, 0.370164},
{0.277018, 0.050344, 0.375715},
{0.277941, 0.056324, 0.381191},
{0.278791, 0.062145, 0.386592},
{0.279566, 0.067836, 0.391917},
{0.280267, 0.073417, 0.397163},
{0.280894, 0.078907, 0.402329},
{0.281446, 0.084320, 0.407414},
{0.281924, 0.089666, 0.412415},
{0.282327, 0.094955, 0.417331},
{0.282656, 0.100196, 0.422160},
{0.282910, 0.105393, 0.426902},
{0.283091, 0.110553, 0.431554},
{0.283197, 0.115680, 0.436115},
{0.283229, 0.120777, 0.440584},
{0.283187, 0.125848, 0.444960},
{0.283072, 0.130895, 0.449241},
{0.282884, 0.135920, 0.453427},
{0.282623, 0.140926, 0.457517},
{0.282290, 0.145912, 0.461510},
{0.281887, 0.150881, 0.465405},
{0.281412, 0.155834, 0.469201},
{0.280868, 0.160771, 0.472899},
{0.280255, 0.165693, 0.476498},
{0.279574, 0.170599, 0.479997},
{0.278826, 0.175490, 0.483397},
{0.278012, 0.180367, 0.486697},
{0.277134, 0.185228, 0.489898},
{0.276194, 0.190074, 0.493001},
{0.275191, 0.194905, 0.496005},
{0.274128, 0.199721, 0.498911},
{0.273006, 0.204520, 0.501721},
{0.271828, 0.209303, 0.504434},
{0.270595, 0.214069, 0.507052},
{0.269308, 0.218818, 0.509577},
{0.267968, 0.223549, 0.512008},
{0.266580, 0.228262, 0.514349},
{0.265145, 0.232956, 0.516599},
{0.263663, 0.237631, 0.518762},
{0.262138, 0.242286, 0.520837},
{0.260571, 0.246922, 0.522828},
{0.258965, 0.251537, 0.524736},
{0.257322, 0.256130, 0.526563},
{0.255645, 0.260703, 0.528312},
{0.253935, 0.265254, 0.529983},
{0.252194, 0.269783, 0.531579},
{0.250425, 0.274290, 0.533103},
{0.248629, 0.278775, 0.534556},
{0.246811, 0.283237, 0.535941},
{0.244972, 0.287675, 0.537260},
{0.243113, 0.292092, 0.538516},
{0.241237, 0.296485, 0.539709},
{0.239346, 0.300855, 0.540844},
{0.237441, 0.305202, 0.541921},
{0.235526, 0.309527, 0.542944},
{0.233603, 0.313828, 0.543914},
{0.231674, 0.318106, 0.544834},
{0.229739, 0.322361, 0.545706},
{0.227802, 0.326594, 0.546532},
{0.225863, 0.330805, 0.547314},
{0.223925, 0.334994, 0.548053},
{0.221989, 0.339161, 0.548752},
{0.220057, 0.343307, 0.549413},
{0.218130, 0.347432, 0.550038},
{0.216210, 0.351535, 0.550627},
{0.214298, 0.355619, 0.551184},
{0.212395, 0.359683, 0.551710},
{0.210503, 0.363727, 0.552206},
{0.208623, 0.367752, 0.552675},
{0.206756, 0.371758, 0.553117},
{0.204903, 0.375746, 0.553533},
{0.203063, 0.379716, 0.553925},
{0.201239, 0.383670, 0.554294},
{0.199430, 0.387607, 0.554642},
{0.197636, 0.391528, 0.554969},
{0.195860, 0.395433, 0.555276},
{0.194100, 0.399323, 0.555565},
{0.192357, 0.403199, 0.555836},
{0.190631, 0.407061, 0.556089},
{0.188923, 0.410910, 0.556326},
{0.187231, 0.414746, 0.556547},
{0.185556, 0.418570, 0.556753},
{0.183898, 0.422383, 0.556944},
{0.182256, 0.426184, 0.557120},
{0.180629, 0.429975, 0.557282},
{0.179019, 0.433756, 0.557430},
{0.177423, 0.437527, 0.557565},
{0.175841, 0.441290, 0.557685},
{0.174274, 0.445044, 0.557792},
{0.172719, 0.448791, 0.557885},
{0.171176, 0.452530, 0.557965},
{0.169646, 0.456262, 0.558030},
{0.168126, 0.459988, 0.558082},
{0.166617, 0.463708, 0.558119},
{0.165117, 0.467423, 0.558141},
{0.163625, 0.471133, 0.558148},
{0.162142, 0.474838, 0.558140},
{0.160665, 0.478540, 0.558115},
{0.159194, 0.482237, 0.558073},
{0.157729, 0.485932, 0.558013},
{0.156270, 0.489624, 0.557936},
{0.154815, 0.493313, 0.557840},
{0.153364, 0.497000, 0.557724},
{0.151918, 0.500685, 0.557587},
{0.150476, 0.504369, 0.557430},
{0.149039, 0.508051, 0.557250},
{0.147607, 0.511733, 0.557049},
{0.146180, 0.515413, 0.556823},
{0.144759, 0.519093, 0.556572},
{0.143343, 0.522773, 0.556295},
{0.141935, 0.526453, 0.555991},
{0.140536, 0.530132, 0.555659},
{0.139147, 0.533812, 0.555298},
{0.137770, 0.537492, 0.554906},
{0.136408, 0.541173, 0.554483},
{0.135066, 0.544853, 0.554029},
{0.133743, 0.548535, 0.553541},
{0.132444, 0.552216, 0.553018},
{0.131172, 0.555899, 0.552459},
{0.129933, 0.559582, 0.551864},
{0.128729, 0.563265, 0.551229},
{0.127568, 0.566949, 0.550556},
{0.126453, 0.570633, 0.549841},
{0.125394, 0.574318, 0.549086},
{0.124395, 0.578002, 0.548287},
{0.123463, 0.581687, 0.547445},
{0.122606, 0.585371, 0.546557},
{0.121831, 0.589055, 0.545623},
{0.121148, 0.592739, 0.544641},
{0.120565, 0.596422, 0.543611},
{0.120092, 0.600104, 0.542530},
{0.119738, 0.603785, 0.541400},
{0.119512, 0.607464, 0.540218},
{0.119423, 0.611141, 0.538982},
{0.119483, 0.614817, 0.537692},
{0.119699, 0.618490, 0.536347},
{0.120081, 0.622161, 0.534946},
{0.120638, 0.625828, 0.533488},
{0.121380, 0.629492, 0.531973},
{0.122312, 0.633153, 0.530398},
{0.123444, 0.636809, 0.528763},
{0.124780, 0.640461, 0.527068},
{0.126326, 0.644107, 0.525311},
{0.128087, 0.647749, 0.523491},
{0.130067, 0.651384, 0.521608},
{0.132268, 0.655014, 0.519661},
{0.134692, 0.658636, 0.517649},
{0.137339, 0.662252, 0.515571},
{0.140210, 0.665859, 0.513427},
{0.143303, 0.669459, 0.511215},
{0.146616, 0.673050, 0.508936},
{0.150148, 0.676631, 0.506589},
{0.153894, 0.680203, 0.504172},
{0.157851, 0.683765, 0.501686},
{0.162016, 0.687316, 0.499129},
{0.166383, 0.690856, 0.496502},
{0.170948, 0.694384, 0.493803},
{0.175707, 0.697900, 0.491033},
{0.180653, 0.701402, 0.488189},
{0.185783, 0.704891, 0.485273},
{0.191090, 0.708366, 0.482284},
{0.196571, 0.711827, 0.479221},
{0.202219, 0.715272, 0.476084},
{0.208030, 0.718701, 0.472873},
{0.214000, 0.722114, 0.469588},
{0.220124, 0.725509, 0.466226},
{0.226397, 0.728888, 0.462789},
{0.232815, 0.732247, 0.459277},
{0.239374, 0.735588, 0.455688},
{0.246070, 0.738910, 0.452024},
{0.252899, 0.742211, 0.448284},
{0.259857, 0.745492, 0.444467},
{0.266941, 0.748751, 0.440573},
{0.274149, 0.751988, 0.436601},
{0.281477, 0.755203, 0.432552},
{0.288921, 0.758394, 0.428426},
{0.296479, 0.761561, 0.424223},
{0.304148, 0.764704, 0.419943},
{0.311925, 0.767822, 0.415586},
{0.319809, 0.770914, 0.411152},
{0.327796, 0.773980, 0.406640},
{0.335885, 0.777018, 0.402049},
{0.344074, 0.780029, 0.397381},
{0.352360, 0.783011, 0.392636},
{0.360741, 0.785964, 0.387814},
{0.369214, 0.788888, 0.382914},
{0.377779, 0.791781, 0.377939},
{0.386433, 0.794644, 0.372886},
{0.395174, 0.797475, 0.367757},
{0.404001, 0.800275, 0.362552},
{0.412913, 0.803041, 0.357269},
{0.421908, 0.805774, 0.351910},
{0.430983, 0.808473, 0.346476},
{0.440137, 0.811138, 0.340967},
{0.449368, 0.813768, 0.335384},
{0.458674, 0.816363, 0.329727},
{0.468053, 0.818921, 0.323998},
{0.477504, 0.821444, 0.318195},
{0.487026, 0.823929, 0.312321},
{0.496615, 0.826376, 0.306377},
{0.506271, 0.828786, 0.300362},
{0.515992, 0.831158, 0.294279},
{0.525776, 0.833491, 0.288127},
{0.535621, 0.835785, 0.281908},
{0.545524, 0.838039, 0.275626},
{0.555484, 0.840254, 0.269281},
{0.565498, 0.842430, 0.262877},
{0.575563, 0.844566, 0.256415},
{0.585678, 0.846661, 0.249897},
{0.595839, 0.848717, 0.243329},
{0.606045, 0.850733, 0.236712},
{0.616293, 0.852709, 0.230052},
{0.626579, 0.854645, 0.223353},
{0.636902, 0.856542, 0.216620},
{0.647257, 0.858400, 0.209861},
{0.657642, 0.860219, 0.203082},
{0.668054, 0.861999, 0.196293},
{0.678489, 0.863742, 0.189503},
{0.688944, 0.865448, 0.182725},
{0.699415, 0.867117, 0.175971},
{0.709898, 0.868751, 0.169257},
{0.720391, 0.870350, 0.162603},
{0.730889, 0.871916, 0.156029},
{0.741388, 0.873449, 0.149561},
{0.751884, 0.874951, 0.143228},
{0.762373, 0.876424, 0.137064},
{0.772852, 0.877868, 0.131109},
{0.783315, 0.879285, 0.125405},
{0.793760, 0.880678, 0.120005},
{0.804182, 0.882046, 0.114965},
{0.814576, 0.883393, 0.110347},
{0.824940, 0.884720, 0.106217},
{0.835270, 0.886029, 0.102646},
{0.845561, 0.887322, 0.099702},
{0.855810, 0.888601, 0.097452},
{0.866013, 0.889868, 0.095953},
{0.876168, 0.891125, 0.095250},
{0.886271, 0.892374, 0.095374},
{0.896320, 0.893616, 0.096335},
{0.906311, 0.894855, 0.098125},
{0.916242, 0.896091, 0.100717},
{0.926106, 0.897330, 0.104071},
{0.935904, 0.898570, 0.108131},
{0.945636, 0.899815, 0.112838},
{0.955300, 0.901065, 0.118128},
{0.964894, 0.902323, 0.123941},
{0.974417, 0.903590, 0.130215},
{0.983868, 0.904867, 0.136897},
{0.993248, 0.906157, 0.143936},
};
return interp(data, N);
}
/**
matplotlib colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> seismic(size_t N = 5)
{
xt::xtensor<double, 2> data = {
{0.0, 0.0, 0.3},
{0.0, 0.0, 1.0},
{1.0, 1.0, 1.0},
{1.0, 0.0, 0.0},
{0.5, 0.0, 0.0}};
return interp(data, N);
}
/**
Monotone colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> White(size_t N = 1)
{
xt::xtensor<double, 2> data = {{255, 255, 255}};
return interp(data / 255.0, N);
}
/**
Monotone colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Grey(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0.5, 0.5, 0.5}};
return interp(data, N);
}
/**
Monotone colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Black(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 0, 0}};
return interp(data / 255.0, N);
}
/**
Monotone colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Red(size_t N = 1)
{
xt::xtensor<double, 2> data = {{255, 0, 0}};
return interp(data / 255.0, N);
}
/**
Monotone colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Blue(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 0, 255}};
return interp(data / 255.0, N);
}
/**
Eindhoven University of Technology.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> tuewarmred(size_t N = 1)
{
xt::xtensor<double, 2> data = {{247, 49, 49}};
return interp(data / 255.0, N);
}
/**
Eindhoven University of Technology.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> tuedarkblue(size_t N = 1)
{
xt::xtensor<double, 2> data = {{16, 16, 115}};
return interp(data / 255.0, N);
}
/**
Eindhoven University of Technology.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> tueblue(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 102, 204}};
return interp(data / 255.0, N);
}
/**
Eindhoven University of Technology.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> tuelightblue(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 162, 222}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Apricot(size_t N = 1)
{
xt::xtensor<double, 2> data = {{251, 185, 130}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Aquamarine(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 181, 190}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Bittersweet(size_t N = 1)
{
xt::xtensor<double, 2> data = {{192, 79, 23}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> BlueGreen(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 179, 184}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> BlueViolet(size_t N = 1)
{
xt::xtensor<double, 2> data = {{71, 57, 146}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> BrickRed(size_t N = 1)
{
xt::xtensor<double, 2> data = {{182, 50, 28}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Brown(size_t N = 1)
{
xt::xtensor<double, 2> data = {{121, 37, 0}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> BurntOrange(size_t N = 1)
{
xt::xtensor<double, 2> data = {{247, 146, 29}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> CadetBlue(size_t N = 1)
{
xt::xtensor<double, 2> data = {{116, 114, 154}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> CarnationPink(size_t N = 1)
{
xt::xtensor<double, 2> data = {{242, 130, 180}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Cerulean(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 162, 227}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> CornflowerBlue(size_t N = 1)
{
xt::xtensor<double, 2> data = {{65, 176, 228}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Cyan(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 174, 239}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Dandelion(size_t N = 1)
{
xt::xtensor<double, 2> data = {{253, 188, 66}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> DarkOrchid(size_t N = 1)
{
xt::xtensor<double, 2> data = {{164, 83, 138}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Emerald(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 169, 157}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> ForestGreen(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 155, 85}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Fuchsia(size_t N = 1)
{
xt::xtensor<double, 2> data = {{140, 54, 140}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Goldenrod(size_t N = 1)
{
xt::xtensor<double, 2> data = {{255, 223, 66}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Gray(size_t N = 1)
{
xt::xtensor<double, 2> data = {{148, 150, 152}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Green(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 166, 79}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> GreenYellow(size_t N = 1)
{
xt::xtensor<double, 2> data = {{223, 230, 116}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> JungleGreen(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 169, 154}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Lavender(size_t N = 1)
{
xt::xtensor<double, 2> data = {{244, 158, 196}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> LimeGreen(size_t N = 1)
{
xt::xtensor<double, 2> data = {{141, 199, 62}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Magenta(size_t N = 1)
{
xt::xtensor<double, 2> data = {{236, 0, 140}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Mahogany(size_t N = 1)
{
xt::xtensor<double, 2> data = {{169, 52, 31}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Maroon(size_t N = 1)
{
xt::xtensor<double, 2> data = {{175, 50, 53}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Melon(size_t N = 1)
{
xt::xtensor<double, 2> data = {{248, 158, 123}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> MidnightBlue(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 103, 149}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Mulberry(size_t N = 1)
{
xt::xtensor<double, 2> data = {{169, 60, 147}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> NavyBlue(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 110, 184}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> OliveGreen(size_t N = 1)
{
xt::xtensor<double, 2> data = {{60, 128, 49}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Orange(size_t N = 1)
{
xt::xtensor<double, 2> data = {{245, 129, 55}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> OrangeRed(size_t N = 1)
{
xt::xtensor<double, 2> data = {{237, 19, 90}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Orchid(size_t N = 1)
{
xt::xtensor<double, 2> data = {{175, 114, 176}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Peach(size_t N = 1)
{
xt::xtensor<double, 2> data = {{247, 150, 90}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Periwinkle(size_t N = 1)
{
xt::xtensor<double, 2> data = {{121, 119, 184}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> PineGreen(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 139, 114}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Plum(size_t N = 1)
{
xt::xtensor<double, 2> data = {{146, 38, 143}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> ProcessBlue(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 176, 240}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Purple(size_t N = 1)
{
xt::xtensor<double, 2> data = {{153, 71, 155}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> RawSienna(size_t N = 1)
{
xt::xtensor<double, 2> data = {{151, 64, 6}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> RedOrange(size_t N = 1)
{
xt::xtensor<double, 2> data = {{242, 96, 53}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> RedViolet(size_t N = 1)
{
xt::xtensor<double, 2> data = {{161, 36, 107}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Rhodamine(size_t N = 1)
{
xt::xtensor<double, 2> data = {{239, 85, 159}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> RoyalBlue(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 113, 188}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> RoyalPurple(size_t N = 1)
{
xt::xtensor<double, 2> data = {{97, 63, 153}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> RubineRed(size_t N = 1)
{
xt::xtensor<double, 2> data = {{237, 1, 125}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Salmon(size_t N = 1)
{
xt::xtensor<double, 2> data = {{246, 146, 137}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> SeaGreen(size_t N = 1)
{
xt::xtensor<double, 2> data = {{63, 188, 157}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Sepia(size_t N = 1)
{
xt::xtensor<double, 2> data = {{103, 24, 0}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> SkyBlue(size_t N = 1)
{
xt::xtensor<double, 2> data = {{70, 197, 221}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> SpringGreen(size_t N = 1)
{
xt::xtensor<double, 2> data = {{198, 220, 103}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Tan(size_t N = 1)
{
xt::xtensor<double, 2> data = {{218, 157, 118}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> TealBlue(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 174, 179}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Thistle(size_t N = 1)
{
xt::xtensor<double, 2> data = {{216, 131, 183}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Turquoise(size_t N = 1)
{
xt::xtensor<double, 2> data = {{0, 180, 206}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Violet(size_t N = 1)
{
xt::xtensor<double, 2> data = {{88, 66, 155}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> VioletRed(size_t N = 1)
{
xt::xtensor<double, 2> data = {{239, 88, 160}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> WildStrawberry(size_t N = 1)
{
xt::xtensor<double, 2> data = {{238, 41, 103}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Yellow(size_t N = 1)
{
xt::xtensor<double, 2> data = {{255, 242, 0}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> YellowGreen(size_t N = 1)
{
xt::xtensor<double, 2> data = {{152, 204, 112}};
return interp(data / 255.0, N);
}
/**
dvips color. See: https://en.wikibooks.org/wiki/LaTeX/Colors
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> YellowOrange(size_t N = 1)
{
xt::xtensor<double, 2> data = {{250, 162, 26}};
return interp(data / 255.0, N);
}
/**
Inverse of cppcolormap::Accent.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Accent_r(size_t N = 8)
{
return xt::flip(Accent(N), 0);
}
/**
Inverse of cppcolormap::Dark2.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Dark2_r(size_t N = 8)
{
return xt::flip(Dark2(N), 0);
}
/**
Inverse of cppcolormap::Paired.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Paired_r(size_t N = 12)
{
return xt::flip(Paired(N), 0);
}
/**
Inverse of cppcolormap::Spectral.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Spectral_r(size_t N = 11)
{
return xt::flip(Spectral(N), 0);
}
/**
Inverse of cppcolormap::Pastel1.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Pastel1_r(size_t N = 9)
{
return xt::flip(Pastel1(N), 0);
}
/**
Inverse of cppcolormap::Pastel2.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Pastel2_r(size_t N = 8)
{
return xt::flip(Pastel2(N), 0);
}
/**
Inverse of cppcolormap::Set1.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Set1_r(size_t N = 9)
{
return xt::flip(Set1(N), 0);
}
/**
Inverse of cppcolormap::Set2.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Set2_r(size_t N = 8)
{
return xt::flip(Set2(N), 0);
}
/**
Inverse of cppcolormap::Set3.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Set3_r(size_t N = 12)
{
return xt::flip(Set3(N), 0);
}
/**
Inverse of cppcolormap::Blues.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Blues_r(size_t N = 9)
{
return xt::flip(Blues(N), 0);
}
/**
Inverse of cppcolormap::Greens.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Greens_r(size_t N = 9)
{
return xt::flip(Greens(N), 0);
}
/**
Inverse of cppcolormap::Greys.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Greys_r(size_t N = 2)
{
return xt::flip(Greys(N), 0);
}
/**
Inverse of cppcolormap::Oranges.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Oranges_r(size_t N = 9)
{
return xt::flip(Oranges(N), 0);
}
/**
Inverse of cppcolormap::Purples.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Purples_r(size_t N = 9)
{
return xt::flip(Purples(N), 0);
}
/**
Inverse of cppcolormap::Reds.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> Reds_r(size_t N = 9)
{
return xt::flip(Reds(N), 0);
}
/**
Inverse of cppcolormap::BuPu.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> BuPu_r(size_t N = 9)
{
return xt::flip(BuPu(N), 0);
}
/**
Inverse of cppcolormap::GnBu.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> GnBu_r(size_t N = 9)
{
return xt::flip(GnBu(N), 0);
}
/**
Inverse of cppcolormap::PuBu.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> PuBu_r(size_t N = 9)
{
return xt::flip(PuBu(N), 0);
}
/**
Inverse of cppcolormap::PuBuGn.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> PuBuGn_r(size_t N = 9)
{
return xt::flip(PuBuGn(N), 0);
}
/**
Inverse of cppcolormap::PuRd.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> PuRd_r(size_t N = 9)
{
return xt::flip(PuRd(N), 0);
}
/**
Inverse of cppcolormap::RdPu.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> RdPu_r(size_t N = 9)
{
return xt::flip(RdPu(N), 0);
}
/**
Inverse of cppcolormap::OrRd.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> OrRd_r(size_t N = 9)
{
return xt::flip(OrRd(N), 0);
}
/**
Inverse of cppcolormap::RdOrYl.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> RdOrYl_r(size_t N = 9)
{
return xt::flip(RdOrYl(N), 0);
}
/**
Inverse of cppcolormap::YlGn.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> YlGn_r(size_t N = 9)
{
return xt::flip(YlGn(N), 0);
}
/**
Inverse of cppcolormap::YlGnBu.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> YlGnBu_r(size_t N = 9)
{
return xt::flip(YlGnBu(N), 0);
}
/**
Inverse of cppcolormap::YlOrRd.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> YlOrRd_r(size_t N = 9)
{
return xt::flip(YlOrRd(N), 0);
}
/**
Inverse of cppcolormap::BrBG.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> BrBG_r(size_t N = 11)
{
return xt::flip(BrBG(N), 0);
}
/**
Inverse of cppcolormap::PuOr.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> PuOr_r(size_t N = 11)
{
return xt::flip(PuOr(N), 0);
}
/**
Inverse of cppcolormap::RdBu.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> RdBu_r(size_t N = 11)
{
return xt::flip(RdBu(N), 0);
}
/**
Inverse of cppcolormap::RdGy.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> RdGy_r(size_t N = 11)
{
return xt::flip(RdGy(N), 0);
}
/**
Inverse of cppcolormap::RdYlBu.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> RdYlBu_r(size_t N = 11)
{
return xt::flip(RdYlBu(N), 0);
}
/**
Inverse of cppcolormap::RdYlGn.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> RdYlGn_r(size_t N = 11)
{
return xt::flip(RdYlGn(N), 0);
}
/**
Inverse of cppcolormap::PiYG.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> PiYG_r(size_t N = 11)
{
return xt::flip(PiYG(N), 0);
}
/**
Inverse of cppcolormap::PRGn.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> PRGn_r(size_t N = 11)
{
return xt::flip(PRGn(N), 0);
}
/**
Inverse of cppcolormap::spring.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> spring_r(size_t N = 256)
{
return xt::flip(spring(N), 0);
}
/**
Inverse of cppcolormap::summer.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> summer_r(size_t N = 256)
{
return xt::flip(summer(N), 0);
}
/**
Inverse of cppcolormap::autumn.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> autumn_r(size_t N = 256)
{
return xt::flip(autumn(N), 0);
}
/**
Inverse of cppcolormap::winter.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> winter_r(size_t N = 256)
{
return xt::flip(winter(N), 0);
}
/**
Inverse of cppcolormap::bone.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> bone_r(size_t N = 256)
{
return xt::flip(bone(N), 0);
}
/**
Inverse of cppcolormap::cool.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> cool_r(size_t N = 256)
{
return xt::flip(cool(N), 0);
}
/**
Inverse of cppcolormap::hot.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> hot_r(size_t N = 256)
{
return xt::flip(hot(N), 0);
}
/**
Inverse of cppcolormap::copper.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> copper_r(size_t N = 256)
{
return xt::flip(copper(N), 0);
}
/**
Inverse of cppcolormap::hsv.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> hsv_r(size_t N = 256)
{
return xt::flip(hsv(N), 0);
}
/**
Inverse of cppcolormap::nipy_spectral.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> nipy_spectral_r(size_t N = 256)
{
return xt::flip(nipy_spectral(N), 0);
}
/**
Inverse of cppcolormap::jet.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> jet_r(size_t N = 256)
{
return xt::flip(jet(N), 0);
}
/**
Inverse of cppcolormap::terrain.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> terrain_r(size_t N = 5)
{
return xt::flip(terrain(N), 0);
}
/**
Inverse of cppcolormap::seismic.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> seismic_r(size_t N = 6)
{
return xt::flip(seismic(N), 0);
}
/**
Inverse of cppcolormap::afmhot.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> afmhot_r(size_t N = 256)
{
return xt::flip(afmhot(N), 0);
}
/**
Inverse of cppcolormap::magma.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> magma_r(size_t N = 256)
{
return xt::flip(magma(N), 0);
}
/**
Inverse of cppcolormap::inferno.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> inferno_r(size_t N = 256)
{
return xt::flip(inferno(N), 0);
}
/**
Inverse of cppcolormap::plasma.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> plasma_r(size_t N = 256)
{
return xt::flip(plasma(N), 0);
}
/**
Inverse of cppcolormap::viridis.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> viridis_r(size_t N = 256)
{
return xt::flip(viridis(N), 0);
}
/**
Get colormap specified as string.
\param cmap Name of the colormap.
\param N Number of colors to output.
\returns RGB data.
*/
inline xt::xtensor<double, 2> colormap(const std::string& cmap, size_t N = 256)
{
if (cmap == "Accent") { return Accent(N); }
if (cmap == "Dark2") { return Dark2(N); }
if (cmap == "Paired") { return Paired(N); }
if (cmap == "Spectral") { return Spectral(N); }
if (cmap == "Pastel1") { return Pastel1(N); }
if (cmap == "Pastel2") { return Pastel2(N); }
if (cmap == "Set1") { return Set1(N); }
if (cmap == "Set2") { return Set2(N); }
if (cmap == "Set3") { return Set3(N); }
if (cmap == "Blues") { return Blues(N); }
if (cmap == "Greens") { return Greens(N); }
if (cmap == "Greys") { return Greys(N); }
if (cmap == "Oranges") { return Oranges(N); }
if (cmap == "Purples") { return Purples(N); }
if (cmap == "Reds") { return Reds(N); }
if (cmap == "BuPu") { return BuPu(N); }
if (cmap == "GnBu") { return GnBu(N); }
if (cmap == "PuBu") { return PuBu(N); }
if (cmap == "PuBuGn") { return PuBuGn(N); }
if (cmap == "PuRd") { return PuRd(N); }
if (cmap == "RdPu") { return RdPu(N); }
if (cmap == "OrRd") { return OrRd(N); }
if (cmap == "RdOrYl") { return RdOrYl(N); }
if (cmap == "YlGn") { return YlGn(N); }
if (cmap == "YlGnBu") { return YlGnBu(N); }
if (cmap == "YlOrRd") { return YlOrRd(N); }
if (cmap == "BrBG") { return BrBG(N); }
if (cmap == "PuOr") { return PuOr(N); }
if (cmap == "RdBu") { return RdBu(N); }
if (cmap == "RdGy") { return RdGy(N); }
if (cmap == "RdYlBu") { return RdYlBu(N); }
if (cmap == "RdYlGn") { return RdYlGn(N); }
if (cmap == "PiYG") { return PiYG(N); }
if (cmap == "PRGn") { return PRGn(N); }
if (cmap == "spring") { return spring(N); }
if (cmap == "summer") { return summer(N); }
if (cmap == "autumn") { return autumn(N); }
if (cmap == "winter") { return winter(N); }
if (cmap == "bone") { return bone(N); }
if (cmap == "cool") { return cool(N); }
if (cmap == "hot") { return hot(N); }
if (cmap == "copper") { return copper(N); }
if (cmap == "hsv") { return hsv(N); }
if (cmap == "nipy_spectral") { return nipy_spectral(N); }
if (cmap == "jet") { return jet(N); }
if (cmap == "terrain") { return terrain(N); }
if (cmap == "seismic") { return seismic(N); }
if (cmap == "afmhot") { return afmhot(N); }
if (cmap == "magma") { return magma(N); }
if (cmap == "inferno") { return inferno(N); }
if (cmap == "plasma") { return plasma(N); }
if (cmap == "viridis") { return viridis(N); }
if (cmap == "Accent_r") { return Accent_r(N); }
if (cmap == "Dark2_r") { return Dark2_r(N); }
if (cmap == "Paired_r") { return Paired_r(N); }
if (cmap == "Spectral_r") { return Spectral_r(N); }
if (cmap == "Pastel1_r") { return Pastel1_r(N); }
if (cmap == "Pastel2_r") { return Pastel2_r(N); }
if (cmap == "Set1_r") { return Set1_r(N); }
if (cmap == "Set2_r") { return Set2_r(N); }
if (cmap == "Set3_r") { return Set3_r(N); }
if (cmap == "Blues_r") { return Blues_r(N); }
if (cmap == "Greens_r") { return Greens_r(N); }
if (cmap == "Greys_r") { return Greys_r(N); }
if (cmap == "Oranges_r") { return Oranges_r(N); }
if (cmap == "Purples_r") { return Purples_r(N); }
if (cmap == "Reds_r") { return Reds_r(N); }
if (cmap == "BuPu_r") { return BuPu_r(N); }
if (cmap == "GnBu_r") { return GnBu_r(N); }
if (cmap == "PuBu_r") { return PuBu_r(N); }
if (cmap == "PuBuGn_r") { return PuBuGn_r(N); }
if (cmap == "PuRd_r") { return PuRd_r(N); }
if (cmap == "RdPu_r") { return RdPu_r(N); }
if (cmap == "OrRd_r") { return OrRd_r(N); }
if (cmap == "RdOrYl_r") { return RdOrYl_r(N); }
if (cmap == "YlGn_r") { return YlGn_r(N); }
if (cmap == "YlGnBu_r") { return YlGnBu_r(N); }
if (cmap == "YlOrRd_r") { return YlOrRd_r(N); }
if (cmap == "BrBG_r") { return BrBG_r(N); }
if (cmap == "PuOr_r") { return PuOr_r(N); }
if (cmap == "RdBu_r") { return RdBu_r(N); }
if (cmap == "RdGy_r") { return RdGy_r(N); }
if (cmap == "RdYlBu_r") { return RdYlBu_r(N); }
if (cmap == "RdYlGn_r") { return RdYlGn_r(N); }
if (cmap == "PiYG_r") { return PiYG_r(N); }
if (cmap == "PRGn_r") { return PRGn_r(N); }
if (cmap == "spring_r") { return spring_r(N); }
if (cmap == "summer_r") { return summer_r(N); }
if (cmap == "autumn_r") { return autumn_r(N); }
if (cmap == "winter_r") { return winter_r(N); }
if (cmap == "bone_r") { return bone_r(N); }
if (cmap == "cool_r") { return cool_r(N); }
if (cmap == "hot_r") { return hot_r(N); }
if (cmap == "copper_r") { return copper_r(N); }
if (cmap == "hsv_r") { return hsv_r(N); }
if (cmap == "nipy_spectral_r") { return nipy_spectral_r(N); }
if (cmap == "jet_r") { return jet_r(N); }
if (cmap == "terrain_r") { return terrain_r(N); }
if (cmap == "seismic_r") { return seismic_r(N); }
if (cmap == "afmhot_r") { return afmhot_r(N); }
if (cmap == "magma_r") { return magma_r(N); }
if (cmap == "inferno_r") { return inferno_r(N); }
if (cmap == "plasma_r") { return plasma_r(N); }
if (cmap == "viridis_r") { return viridis_r(N); }
if (cmap == "White") { return White(N); }
if (cmap == "Grey") { return Grey(N); }
if (cmap == "Black") { return Black(N); }
if (cmap == "Red") { return Red(N); }
if (cmap == "Blue") { return Blue(N); }
if (cmap == "tuewarmred") { return tuewarmred(N); }
if (cmap == "tuedarkblue") { return tuedarkblue(N); }
if (cmap == "tueblue") { return tueblue(N); }
if (cmap == "tuelightblue") { return tuelightblue(N); }
if (cmap == "Apricot") { return Apricot(N); }
if (cmap == "Aquamarine") { return Aquamarine(N); }
if (cmap == "Bittersweet") { return Bittersweet(N); }
if (cmap == "BlueGreen") { return BlueGreen(N); }
if (cmap == "BlueViolet") { return BlueViolet(N); }
if (cmap == "BrickRed") { return BrickRed(N); }
if (cmap == "Brown") { return Brown(N); }
if (cmap == "BurntOrange") { return BurntOrange(N); }
if (cmap == "CadetBlue") { return CadetBlue(N); }
if (cmap == "CarnationPink") { return CarnationPink(N); }
if (cmap == "Cerulean") { return Cerulean(N); }
if (cmap == "CornflowerBlue") { return CornflowerBlue(N); }
if (cmap == "Cyan") { return Cyan(N); }
if (cmap == "Dandelion") { return Dandelion(N); }
if (cmap == "DarkOrchid") { return DarkOrchid(N); }
if (cmap == "Emerald") { return Emerald(N); }
if (cmap == "ForestGreen") { return ForestGreen(N); }
if (cmap == "Fuchsia") { return Fuchsia(N); }
if (cmap == "Goldenrod") { return Goldenrod(N); }
if (cmap == "Gray") { return Gray(N); }
if (cmap == "Green") { return Green(N); }
if (cmap == "GreenYellow") { return GreenYellow(N); }
if (cmap == "JungleGreen") { return JungleGreen(N); }
if (cmap == "Lavender") { return Lavender(N); }
if (cmap == "LimeGreen") { return LimeGreen(N); }
if (cmap == "Magenta") { return Magenta(N); }
if (cmap == "Mahogany") { return Mahogany(N); }
if (cmap == "Maroon") { return Maroon(N); }
if (cmap == "Melon") { return Melon(N); }
if (cmap == "MidnightBlue") { return MidnightBlue(N); }
if (cmap == "Mulberry") { return Mulberry(N); }
if (cmap == "NavyBlue") { return NavyBlue(N); }
if (cmap == "OliveGreen") { return OliveGreen(N); }
if (cmap == "Orange") { return Orange(N); }
if (cmap == "OrangeRed") { return OrangeRed(N); }
if (cmap == "Orchid") { return Orchid(N); }
if (cmap == "Peach") { return Peach(N); }
if (cmap == "Periwinkle") { return Periwinkle(N); }
if (cmap == "PineGreen") { return PineGreen(N); }
if (cmap == "Plum") { return Plum(N); }
if (cmap == "ProcessBlue") { return ProcessBlue(N); }
if (cmap == "Purple") { return Purple(N); }
if (cmap == "RawSienna") { return RawSienna(N); }
if (cmap == "RedOrange") { return RedOrange(N); }
if (cmap == "RedViolet") { return RedViolet(N); }
if (cmap == "Rhodamine") { return Rhodamine(N); }
if (cmap == "RoyalBlue") { return RoyalBlue(N); }
if (cmap == "RoyalPurple") { return RoyalPurple(N); }
if (cmap == "RubineRed") { return RubineRed(N); }
if (cmap == "Salmon") { return Salmon(N); }
if (cmap == "SeaGreen") { return SeaGreen(N); }
if (cmap == "Sepia") { return Sepia(N); }
if (cmap == "SkyBlue") { return SkyBlue(N); }
if (cmap == "SpringGreen") { return SpringGreen(N); }
if (cmap == "Tan") { return Tan(N); }
if (cmap == "TealBlue") { return TealBlue(N); }
if (cmap == "Thistle") { return Thistle(N); }
if (cmap == "Turquoise") { return Turquoise(N); }
if (cmap == "Violet") { return Violet(N); }
if (cmap == "VioletRed") { return VioletRed(N); }
if (cmap == "WildStrawberry") { return WildStrawberry(N); }
if (cmap == "Yellow") { return Yellow(N); }
if (cmap == "YellowGreen") { return YellowGreen(N); }
if (cmap == "YellowOrange") { return YellowOrange(N); }
throw std::runtime_error("Colormap not recognized");
}
/**
xterm color-cyle.
\returns RGB data.
*/
inline xt::xtensor<double, 2> xterm()
{
xt::xtensor<double, 2> data = {
{ 0, 0, 0}, // 0 , Black (SYSTEM) , #000000, hsl(0,0%,0%)
{128, 0, 0}, // 1 , Maroon (SYSTEM), #800000, hsl(0,100%,25%)
{ 0, 128, 0}, // 2 , Green (SYSTEM) , #008000, hsl(120,100%,25%)
{128, 128, 0}, // 3 , Olive (SYSTEM) , #808000, hsl(60,100%,25%)
{ 0, 0, 128}, // 4 , Navy (SYSTEM) , #000080, hsl(240,100%,25%)
{128, 0, 128}, // 5 , Purple (SYSTEM), #800080, hsl(300,100%,25%)
{ 0, 128, 128}, // 6 , Teal (SYSTEM) , #008080, hsl(180,100%,25%)
{192, 192, 192}, // 7 , Silver (SYSTEM), #c0c0c0, hsl(0,0%,75%)
{128, 128, 128}, // 8 , Grey (SYSTEM) , #808080, hsl(0,0%,50%)
{255, 0, 0}, // 9 , Red (SYSTEM) , #ff0000, hsl(0,100%,50%)
{ 0, 255, 0}, // 10 , Lime (SYSTEM) , #00ff00, hsl(120,100%,50%)
{255, 255, 0}, // 11 , Yellow (SYSTEM), #ffff00, hsl(60,100%,50%)
{ 0, 0, 255}, // 12 , Blue (SYSTEM) , #0000ff, hsl(240,100%,50%)
{255, 0, 255}, // 13 , Fuchsia (SYSTEM,) #ff00ff, hsl(300,100%,50%)
{ 0, 255, 255}, // 14 , Aqua (SYSTEM) , #00ffff, hsl(180,100%,50%)
{255, 255, 255}, // 15 , White (SYSTEM) , #ffffff, hsl(0,0%,100%)
{ 0, 0, 0}, // 16 , Grey0 , #000000, hsl(0,0%,0%)
{ 0, 0, 95}, // 17 , NavyBlue , #00005f, hsl(240,100%,18%)
{ 0, 0, 135}, // 18 , DarkBlue , #000087, hsl(240,100%,26%)
{ 0, 0, 175}, // 19 , Blue3 , #0000af, hsl(240,100%,34%)
{ 0, 0, 215}, // 20 , Blue3 , #0000d7, hsl(240,100%,42%)
{ 0, 0, 255}, // 21 , Blue1 , #0000ff, hsl(240,100%,50%)
{ 0, 95, 0}, // 22 , DarkGreen , #005f00, hsl(120,100%,18%)
{ 0, 95, 95}, // 23 , DeepSkyBlue4 , #005f5f, hsl(180,100%,18%)
{ 0, 95, 135}, // 24 , DeepSkyBlue4 , #005f87, hsl(97,100%,26%)
{ 0, 95, 175}, // 25 , DeepSkyBlue4 , #005faf, hsl(07,100%,34%)
{ 0, 95, 215}, // 26 , DodgerBlue3 , #005fd7, hsl(13,100%,42%)
{ 0, 95, 255}, // 27 , DodgerBlue2 , #005fff, hsl(17,100%,50%)
{ 0, 135, 0}, // 28 , Green4 , #008700, hsl(120,100%,26%)
{ 0, 135, 95}, // 29 , SpringGreen4 , #00875f, hsl(62,100%,26%)
{ 0, 135, 135}, // 30 , Turquoise4 , #008787, hsl(180,100%,26%)
{ 0, 135, 175}, // 31 , DeepSkyBlue3 , #0087af, hsl(93,100%,34%)
{ 0, 135, 215}, // 32 , DeepSkyBlue3 , #0087d7, hsl(02,100%,42%)
{ 0, 135, 255}, // 33 , DodgerBlue1 , #0087ff, hsl(08,100%,50%)
{ 0, 175, 0}, // 34 , Green3 , #00af00, hsl(120,100%,34%)
{ 0, 175, 95}, // 35 , SpringGreen3 , #00af5f, hsl(52,100%,34%)
{ 0, 175, 135}, // 36 , DarkCyan , #00af87, hsl(66,100%,34%)
{ 0, 175, 175}, // 37 , LightSeaGreen , #00afaf, hsl(180,100%,34%)
{ 0, 175, 215}, // 38 , DeepSkyBlue2 , #00afd7, hsl(91,100%,42%)
{ 0, 175, 255}, // 39 , DeepSkyBlue1 , #00afff, hsl(98,100%,50%)
{ 0, 215, 0}, // 40 , Green3 , #00d700, hsl(120,100%,42%)
{ 0, 215, 95}, // 41 , SpringGreen3 , #00d75f, hsl(46,100%,42%)
{ 0, 215, 135}, // 42 , SpringGreen2 , #00d787, hsl(57,100%,42%)
{ 0, 215, 175}, // 43 , Cyan3 , #00d7af, hsl(68,100%,42%)
{ 0, 215, 215}, // 44 , DarkTurquoise , #00d7d7, hsl(180,100%,42%)
{ 0, 215, 255}, // 45 , Turquoise2 , #00d7ff, hsl(89,100%,50%)
{ 0, 255, 0}, // 46 , Green1 , #00ff00, hsl(120,100%,50%)
{ 0, 255, 95}, // 47 , SpringGreen2 , #00ff5f, hsl(42,100%,50%)
{ 0, 255, 135}, // 48 , SpringGreen1 , #00ff87, hsl(51,100%,50%)
{ 0, 255, 175}, // 49 , MediumSpringGre,en#00ffaf, hsl(61,100%,50%)
{ 0, 255, 215}, // 50 , Cyan2 , #00ffd7, hsl(70,100%,50%)
{ 0, 255, 255}, // 51 , Cyan1 , #00ffff, hsl(180,100%,50%)
{ 95, 0, 0}, // 52 , DarkRed , #5f0000, hsl(0,100%,18%)
{ 95, 0, 95}, // 53 , DeepPink4 , #5f005f, hsl(300,100%,18%)
{ 95, 0, 135}, // 54 , Purple4 , #5f0087, hsl(82,100%,26%)
{ 95, 0, 175}, // 55 , Purple4 , #5f00af, hsl(72,100%,34%)
{ 95, 0, 215}, // 56 , Purple3 , #5f00d7, hsl(66,100%,42%)
{ 95, 0, 255}, // 57 , BlueViolet , #5f00ff, hsl(62,100%,50%)
{ 95, 95, 0}, // 58 , Orange4 , #5f5f00, hsl(60,100%,18%)
{ 95, 95, 95}, // 59 , Grey37 , #5f5f5f, hsl(0,0%,37%)
{ 95, 95, 135}, // 60 , MediumPurple4 , #5f5f87, hsl(240,17%,45%)
{ 95, 95, 175}, // 61 , SlateBlue3 , #5f5faf, hsl(240,33%,52%)
{ 95, 95, 215}, // 62 , SlateBlue3 , #5f5fd7, hsl(240,60%,60%)
{ 95, 95, 255}, // 63 , RoyalBlue1 , #5f5fff, hsl(240,100%,68%)
{ 95, 135, 0}, // 64 , Chartreuse4 , #5f8700, hsl(7,100%,26%)
{ 95, 135, 95}, // 65 , DarkSeaGreen4 , #5f875f, hsl(120,17%,45%)
{ 95, 135, 135}, // 66 , PaleTurquoise4 , #5f8787, hsl(180,17%,45%)
{ 95, 135, 175}, // 67 , SteelBlue , #5f87af, hsl(210,33%,52%)
{ 95, 135, 215}, // 68 , SteelBlue3 , #5f87d7, hsl(220,60%,60%)
{ 95, 135, 255}, // 69 , CornflowerBlue , #5f87ff, hsl(225,100%,68%)
{ 95, 175, 0}, // 70 , Chartreuse3 , #5faf00, hsl(7,100%,34%)
{ 95, 175, 95}, // 71 , DarkSeaGreen4 , #5faf5f, hsl(120,33%,52%)
{ 95, 175, 135}, // 72 , CadetBlue , #5faf87, hsl(150,33%,52%)
{ 95, 175, 175}, // 73 , CadetBlue , #5fafaf, hsl(180,33%,52%)
{ 95, 175, 215}, // 74 , SkyBlue3 , #5fafd7, hsl(200,60%,60%)
{ 95, 175, 255}, // 75 , SteelBlue1 , #5fafff, hsl(210,100%,68%)
{ 95, 215, 0}, // 76 , Chartreuse3 , #5fd700, hsl(3,100%,42%)
{ 95, 215, 95}, // 77 , PaleGreen3 , #5fd75f, hsl(120,60%,60%)
{ 95, 215, 135}, // 78 , SeaGreen3 , #5fd787, hsl(140,60%,60%)
{ 95, 215, 175}, // 79 , Aquamarine3 , #5fd7af, hsl(160,60%,60%)
{ 95, 215, 215}, // 80 , MediumTurquoise, #5fd7d7, hsl(180,60%,60%)
{ 95, 215, 255}, // 81 , SteelBlue1 , #5fd7ff, hsl(195,100%,68%)
{ 95, 255, 0}, // 82 , Chartreuse2 , #5fff00, hsl(7,100%,50%)
{ 95, 255, 95}, // 83 , SeaGreen2 , #5fff5f, hsl(120,100%,68%)
{ 95, 255, 135}, // 84 , SeaGreen1 , #5fff87, hsl(135,100%,68%)
{ 95, 255, 175}, // 85 , SeaGreen1 , #5fffaf, hsl(150,100%,68%)
{ 95, 255, 215}, // 86 , Aquamarine1 , #5fffd7, hsl(165,100%,68%)
{ 95, 255, 255}, // 87 , DarkSlateGray2 , #5fffff, hsl(180,100%,68%)
{135, 0, 0}, // 88 , DarkRed , #870000, hsl(0,100%,26%)
{135, 0, 95}, // 89 , DeepPink4 , #87005f, hsl(17,100%,26%)
{135, 0, 135}, // 90 , DarkMagenta , #870087, hsl(300,100%,26%)
{135, 0, 175}, // 91 , DarkMagenta , #8700af, hsl(86,100%,34%)
{135, 0, 215}, // 92 , DarkViolet , #8700d7, hsl(77,100%,42%)
{135, 0, 255}, // 93 , Purple , #8700ff, hsl(71,100%,50%)
{135, 95, 0}, // 94 , Orange4 , #875f00, hsl(2,100%,26%)
{135, 95, 95}, // 95 , LightPink4 , #875f5f, hsl(0,17%,45%)
{135, 95, 135}, // 96 , Plum4 , #875f87, hsl(300,17%,45%)
{135, 95, 175}, // 97 , MediumPurple3 , #875faf, hsl(270,33%,52%)
{135, 95, 215}, // 98 , MediumPurple3 , #875fd7, hsl(260,60%,60%)
{135, 95, 255}, // 99 , SlateBlue1 , #875fff, hsl(255,100%,68%)
{135, 135, 0}, // 100, Yellow4 , #878700, hsl(60,100%,26%)
{135, 135, 95}, // 101, Wheat4 , #87875f, hsl(60,17%,45%)
{135, 135, 135}, // 102, Grey53 , #878787, hsl(0,0%,52%)
{135, 135, 175}, // 103, LightSlateGrey , #8787af, hsl(240,20%,60%)
{135, 135, 215}, // 104, MediumPurple , #8787d7, hsl(240,50%,68%)
{135, 135, 255}, // 105, LightSlateBlue , #8787ff, hsl(240,100%,76%)
{135, 175, 0}, // 106, Yellow4 , #87af00, hsl(3,100%,34%)
{135, 175, 95}, // 107, DarkOliveGreen3, #87af5f, hsl(90,33%,52%)
{135, 175, 135}, // 108, DarkSeaGreen , #87af87, hsl(120,20%,60%)
{135, 175, 175}, // 109, LightSkyBlue3 , #87afaf, hsl(180,20%,60%)
{135, 175, 215}, // 110, LightSkyBlue3 , #87afd7, hsl(210,50%,68%)
{135, 175, 255}, // 111, SkyBlue2 , #87afff, hsl(220,100%,76%)
{135, 215, 0}, // 112, Chartreuse2 , #87d700, hsl(2,100%,42%)
{135, 215, 95}, // 113, DarkOliveGreen3, #87d75f, hsl(100,60%,60%)
{135, 215, 135}, // 114, PaleGreen3 , #87d787, hsl(120,50%,68%)
{135, 215, 175}, // 115, DarkSeaGreen3 , #87d7af, hsl(150,50%,68%)
{135, 215, 215}, // 116, DarkSlateGray3 , #87d7d7, hsl(180,50%,68%)
{135, 215, 255}, // 117, SkyBlue1 , #87d7ff, hsl(200,100%,76%)
{135, 255, 0}, // 118, Chartreuse1 , #87ff00, hsl(8,100%,50%)
{135, 255, 95}, // 119, LightGreen , #87ff5f, hsl(105,100%,68%)
{135, 255, 135}, // 120, LightGreen , #87ff87, hsl(120,100%,76%)
{135, 255, 175}, // 121, PaleGreen1 , #87ffaf, hsl(140,100%,76%)
{135, 255, 215}, // 122, Aquamarine1 , #87ffd7, hsl(160,100%,76%)
{135, 255, 255}, // 123, DarkSlateGray1 , #87ffff, hsl(180,100%,76%)
{175, 0, 0}, // 124, Red3 , #af0000, hsl(0,100%,34%)
{175, 0, 95}, // 125, DeepPink4 , #af005f, hsl(27,100%,34%)
{175, 0, 135}, // 126, MediumVioletRed, #af0087, hsl(13,100%,34%)
{175, 0, 175}, // 127, Magenta3 , #af00af, hsl(300,100%,34%)
{175, 0, 215}, // 128, DarkViolet , #af00d7, hsl(88,100%,42%)
{175, 0, 255}, // 129, Purple , #af00ff, hsl(81,100%,50%)
{175, 95, 0}, // 130, DarkOrange3 , #af5f00, hsl(2,100%,34%)
{175, 95, 95}, // 131, IndianRed , #af5f5f, hsl(0,33%,52%)
{175, 95, 135}, // 132, HotPink3 , #af5f87, hsl(330,33%,52%)
{175, 95, 175}, // 133, MediumOrchid3 , #af5faf, hsl(300,33%,52%)
{175, 95, 215}, // 134, MediumOrchid , #af5fd7, hsl(280,60%,60%)
{175, 95, 255}, // 135, MediumPurple2 , #af5fff, hsl(270,100%,68%)
{175, 135, 0}, // 136, DarkGoldenrod , #af8700, hsl(6,100%,34%)
{175, 135, 95}, // 137, LightSalmon3 , #af875f, hsl(30,33%,52%)
{175, 135, 135}, // 138, RosyBrown , #af8787, hsl(0,20%,60%)
{175, 135, 175}, // 139, Grey63 , #af87af, hsl(300,20%,60%)
{175, 135, 215}, // 140, MediumPurple2 , #af87d7, hsl(270,50%,68%)
{175, 135, 255}, // 141, MediumPurple1 , #af87ff, hsl(260,100%,76%)
{175, 175, 0}, // 142, Gold3 , #afaf00, hsl(60,100%,34%)
{175, 175, 95}, // 143, DarkKhaki , #afaf5f, hsl(60,33%,52%)
{175, 175, 135}, // 144, NavajoWhite3 , #afaf87, hsl(60,20%,60%)
{175, 175, 175}, // 145, Grey69 , #afafaf, hsl(0,0%,68%)
{175, 175, 215}, // 146, LightSteelBlue3, #afafd7, hsl(240,33%,76%)
{175, 175, 255}, // 147, LightSteelBlue , #afafff, hsl(240,100%,84%)
{175, 215, 0}, // 148, Yellow3 , #afd700, hsl(1,100%,42%)
{175, 215, 95}, // 149, DarkOliveGreen3, #afd75f, hsl(80,60%,60%)
{175, 215, 135}, // 150, DarkSeaGreen3 , #afd787, hsl(90,50%,68%)
{175, 215, 175}, // 151, DarkSeaGreen2 , #afd7af, hsl(120,33%,76%)
{175, 215, 215}, // 152, LightCyan3 , #afd7d7, hsl(180,33%,76%)
{175, 215, 255}, // 153, LightSkyBlue1 , #afd7ff, hsl(210,100%,84%)
{175, 255, 0}, // 154, GreenYellow , #afff00, hsl(8,100%,50%)
{175, 255, 95}, // 155, DarkOliveGreen2, #afff5f, hsl(90,100%,68%)
{175, 255, 135}, // 156, PaleGreen1 , #afff87, hsl(100,100%,76%)
{175, 255, 175}, // 157, DarkSeaGreen2 , #afffaf, hsl(120,100%,84%)
{175, 255, 215}, // 158, DarkSeaGreen1 , #afffd7, hsl(150,100%,84%)
{175, 255, 255}, // 159, PaleTurquoise1 , #afffff, hsl(180,100%,84%)
{215, 0, 0}, // 160, Red3 , #d70000, hsl(0,100%,42%)
{215, 0, 95}, // 161, DeepPink3 , #d7005f, hsl(33,100%,42%)
{215, 0, 135}, // 162, DeepPink3 , #d70087, hsl(22,100%,42%)
{215, 0, 175}, // 163, Magenta3 , #d700af, hsl(11,100%,42%)
{215, 0, 215}, // 164, Magenta3 , #d700d7, hsl(300,100%,42%)
{215, 0, 255}, // 165, Magenta2 , #d700ff, hsl(90,100%,50%)
{215, 95, 0}, // 166, DarkOrange3 , #d75f00, hsl(6,100%,42%)
{215, 95, 95}, // 167, IndianRed , #d75f5f, hsl(0,60%,60%)
{215, 95, 135}, // 168, HotPink3 , #d75f87, hsl(340,60%,60%)
{215, 95, 175}, // 169, HotPink2 , #d75faf, hsl(320,60%,60%)
{215, 95, 215}, // 170, Orchid , #d75fd7, hsl(300,60%,60%)
{215, 95, 255}, // 171, MediumOrchid1 , #d75fff, hsl(285,100%,68%)
{215, 135, 0}, // 172, Orange3 , #d78700, hsl(7,100%,42%)
{215, 135, 95}, // 173, LightSalmon3 , #d7875f, hsl(20,60%,60%)
{215, 135, 135}, // 174, LightPink3 , #d78787, hsl(0,50%,68%)
{215, 135, 175}, // 175, Pink3 , #d787af, hsl(330,50%,68%)
{215, 135, 215}, // 176, Plum3 , #d787d7, hsl(300,50%,68%)
{215, 135, 255}, // 177, Violet , #d787ff, hsl(280,100%,76%)
{215, 175, 0}, // 178, Gold3 , #d7af00, hsl(8,100%,42%)
{215, 175, 95}, // 179, LightGoldenrod3, #d7af5f, hsl(40,60%,60%)
{215, 175, 135}, // 180, Tan , #d7af87, hsl(30,50%,68%)
{215, 175, 175}, // 181, MistyRose3 , #d7afaf, hsl(0,33%,76%)
{215, 175, 215}, // 182, Thistle3 , #d7afd7, hsl(300,33%,76%)
{215, 175, 255}, // 183, Plum2 , #d7afff, hsl(270,100%,84%)
{215, 215, 0}, // 184, Yellow3 , #d7d700, hsl(60,100%,42%)
{215, 215, 95}, // 185, Khaki3 , #d7d75f, hsl(60,60%,60%)
{215, 215, 135}, // 186, LightGoldenrod2, #d7d787, hsl(60,50%,68%)
{215, 215, 175}, // 187, LightYellow3 , #d7d7af, hsl(60,33%,76%)
{215, 215, 215}, // 188, Grey84 , #d7d7d7, hsl(0,0%,84%)
{215, 215, 255}, // 189, LightSteelBlue1, #d7d7ff, hsl(240,100%,92%)
{215, 255, 0}, // 190, Yellow2 , #d7ff00, hsl(9,100%,50%)
{215, 255, 95}, // 191, DarkOliveGreen1, #d7ff5f, hsl(75,100%,68%)
{215, 255, 135}, // 192, DarkOliveGreen1, #d7ff87, hsl(80,100%,76%)
{215, 255, 175}, // 193, DarkSeaGreen1 , #d7ffaf, hsl(90,100%,84%)
{215, 255, 215}, // 194, Honeydew2 , #d7ffd7, hsl(120,100%,92%)
{215, 255, 255}, // 195, LightCyan1 , #d7ffff, hsl(180,100%,92%)
{255, 0, 0}, // 196, Red1 , #ff0000, hsl(0,100%,50%)
{255, 0, 95}, // 197, DeepPink2 , #ff005f, hsl(37,100%,50%)
{255, 0, 135}, // 198, DeepPink1 , #ff0087, hsl(28,100%,50%)
{255, 0, 175}, // 199, DeepPink1 , #ff00af, hsl(18,100%,50%)
{255, 0, 215}, // 200, Magenta2 , #ff00d7, hsl(09,100%,50%)
{255, 0, 255}, // 201, Magenta1 , #ff00ff, hsl(300,100%,50%)
{255, 95, 0}, // 202, OrangeRed1 , #ff5f00, hsl(2,100%,50%)
{255, 95, 95}, // 203, IndianRed1 , #ff5f5f, hsl(0,100%,68%)
{255, 95, 135}, // 204, IndianRed1 , #ff5f87, hsl(345,100%,68%)
{255, 95, 175}, // 205, HotPink , #ff5faf, hsl(330,100%,68%)
{255, 95, 215}, // 206, HotPink , #ff5fd7, hsl(315,100%,68%)
{255, 95, 255}, // 207, MediumOrchid1 , #ff5fff, hsl(300,100%,68%)
{255, 135, 0}, // 208, DarkOrange , #ff8700, hsl(1,100%,50%)
{255, 135, 95}, // 209, Salmon1 , #ff875f, hsl(15,100%,68%)
{255, 135, 135}, // 210, LightCoral , #ff8787, hsl(0,100%,76%)
{255, 135, 175}, // 211, PaleVioletRed1 , #ff87af, hsl(340,100%,76%)
{255, 135, 215}, // 212, Orchid2 , #ff87d7, hsl(320,100%,76%)
{255, 135, 255}, // 213, Orchid1 , #ff87ff, hsl(300,100%,76%)
{255, 175, 0}, // 214, Orange1 , #ffaf00, hsl(1,100%,50%)
{255, 175, 95}, // 215, SandyBrown , #ffaf5f, hsl(30,100%,68%)
{255, 175, 135}, // 216, LightSalmon1 , #ffaf87, hsl(20,100%,76%)
{255, 175, 175}, // 217, LightPink1 , #ffafaf, hsl(0,100%,84%)
{255, 175, 215}, // 218, Pink1 , #ffafd7, hsl(330,100%,84%)
{255, 175, 255}, // 219, Plum1 , #ffafff, hsl(300,100%,84%)
{255, 215, 0}, // 220, Gold1 , #ffd700, hsl(0,100%,50%)
{255, 215, 95}, // 221, LightGoldenrod2, #ffd75f, hsl(45,100%,68%)
{255, 215, 135}, // 222, LightGoldenrod2, #ffd787, hsl(40,100%,76%)
{255, 215, 175}, // 223, NavajoWhite1 , #ffd7af, hsl(30,100%,84%)
{255, 215, 215}, // 224, MistyRose1 , #ffd7d7, hsl(0,100%,92%)
{255, 215, 255}, // 225, Thistle1 , #ffd7ff, hsl(300,100%,92%)
{255, 255, 0}, // 226, Yellow1 , #ffff00, hsl(60,100%,50%)
{255, 255, 95}, // 227, LightGoldenrod1, #ffff5f, hsl(60,100%,68%)
{255, 255, 135}, // 228, Khaki1 , #ffff87, hsl(60,100%,76%)
{255, 255, 175}, // 229, Wheat1 , #ffffaf, hsl(60,100%,84%)
{255, 255, 215}, // 230, Cornsilk1 , #ffffd7, hsl(60,100%,92%)
{255, 255, 255}, // 231, Grey100 , #ffffff, hsl(0,0%,100%)
{ 8, 8, 8}, // 232, Grey3 , #080808, hsl(0,0%,3%)
{ 18, 18, 18}, // 233, Grey7 , #121212, hsl(0,0%,7%)
{ 28, 28, 28}, // 234, Grey11 , #1c1c1c, hsl(0,0%,10%)
{ 38, 38, 38}, // 235, Grey15 , #262626, hsl(0,0%,14%)
{ 48, 48, 48}, // 236, Grey19 , #303030, hsl(0,0%,18%)
{ 58, 58, 58}, // 237, Grey23 , #3a3a3a, hsl(0,0%,22%)
{ 68, 68, 68}, // 238, Grey27 , #444444, hsl(0,0%,26%)
{ 78, 78, 78}, // 239, Grey30 , #4e4e4e, hsl(0,0%,30%)
{ 88, 88, 88}, // 240, Grey35 , #585858, hsl(0,0%,34%)
{ 98, 98, 98}, // 241, Grey39 , #626262, hsl(0,0%,37%)
{108, 108, 108}, // 242, Grey42 , #6c6c6c, hsl(0,0%,40%)
{118, 118, 118}, // 243, Grey46 , #767676, hsl(0,0%,46%)
{128, 128, 128}, // 244, Grey50 , #808080, hsl(0,0%,50%)
{138, 138, 138}, // 245, Grey54 , #8a8a8a, hsl(0,0%,54%)
{148, 148, 148}, // 246, Grey58 , #949494, hsl(0,0%,58%)
{158, 158, 158}, // 247, Grey62 , #9e9e9e, hsl(0,0%,61%)
{168, 168, 168}, // 248, Grey66 , #a8a8a8, hsl(0,0%,65%)
{178, 178, 178}, // 249, Grey70 , #b2b2b2, hsl(0,0%,69%)
{188, 188, 188}, // 250, Grey74 , #bcbcbc, hsl(0,0%,73%)
{198, 198, 198}, // 251, Grey78 , #c6c6c6, hsl(0,0%,77%)
{208, 208, 208}, // 252, Grey82 , #d0d0d0, hsl(0,0%,81%)
{218, 218, 218}, // 253, Grey85 , #dadada, hsl(0,0%,85%)
{228, 228, 228}, // 254, Grey89 , #e4e4e4, hsl(0,0%,89%)
{238, 238, 238}, // 255, Grey93 , #eeeeee, hsl(0,0%,93%)
};
return data / 255.0;
}
/**
Eindhoven University of Technology color-cyle.
\returns RGB data.
*/
inline xt::xtensor<double, 2> tue()
{
xt::xtensor<double, 2> data = {
{247, 49, 49}, // 0: warm red
{214, 0, 74}, // 1: red
{214, 0, 123}, // 2: pink
{173, 32, 173}, // 3: dark pink
{ 16, 16, 115}, // 4: dark blue
{ 0, 102, 204}, // 5: blue
{ 0, 162, 222}, // 6: light blue
{255, 154, 0}, // 7: orange
{255, 221, 0}, // 8: yellow
{206, 223, 0}, // 9: lemon
{132, 210, 0}, // 10: lime
{ 0, 172, 130}, // 11: green
{ 0, 146, 181}, // 12: cornflower blue
};
return data / 255.0;
}
/**
Inverse of cppcolormap::xterm.
\returns RGB data.
*/
inline xt::xtensor<double, 2> xterm_r()
{
return xt::flip(xterm(), 0);
}
/**
Inverse of cppcolormap::tue.
\returns RGB data.
*/
inline xt::xtensor<double, 2> tue_r()
{
return xt::flip(tue(), 0);
}
/**
Get color-cycle specified as string.
\param cmap Name of the colormap.
\returns RGB data.
*/
inline xt::xtensor<double, 2> colorcycle(const std::string& cmap)
{
if (cmap == "xterm") {
return xterm();
}
if (cmap == "tue") {
return tue();
}
if (cmap == "xterm_r") {
return xterm_r();
}
if (cmap == "tue_r") {
return tue_r();
}
throw std::runtime_error("Color-cycle not recognized");
}
/**
Algorithm to use for color matching.
*/
enum metric
{
euclidean, ///< Euclidean norm
fast_perceptual, ///< Fast best perception algorithm. See: https://stackoverflow.com/a/1847112/2646505
perceptual ///< Best perception algorithm. See: https://en.wikipedia.org/wiki/Color_difference
};
namespace detail
{
double euclidean_metric(double R1, double G1, double B1, double R2, double G2, double B2)
{
return std::pow(R1 - R2, 2.0) +
std::pow(G1 - G2, 2.0) +
std::pow(B1 - B2, 2.0);
}
// https://stackoverflow.com/a/1847112/2646505
double fast_perceptual_metric(double R1, double G1, double B1, double R2, double G2, double B2)
{
return 0.3 * std::pow(R1 - R2, 2.0) +
0.59 * std::pow(G1 - G2, 2.0) +
0.11 * std::pow(B1 - B2, 2.0);
}
// https://en.wikipedia.org/wiki/Color_difference
double perceptual_metric(double R1, double G1, double B1, double R2, double G2, double B2)
{
double r_ = (R1 + R2) / 2.0;
double DR = (R1 - R2);
double DG = (G1 - G2);
double DB = (B1 - B2);
return 2 * DR * DR + 4 * DG * DG + 3 * DB * DB + ((r_ * (DR * DR - DB * DB)));
}
}
/**
Match colors.
\param A List of colors.
\param B List of colors.
\param distance_metric Metric to use in color matching.
\return For each item in ``A``, the index of the closets corresponding color in ``B``.
*/
inline xt::xtensor<size_t, 1> match(
const xt::xtensor<double, 2>& A,
const xt::xtensor<double, 2>& B,
metric distance_metric = euclidean)
{
xt::xtensor<size_t, 1> idx = xt::empty<size_t>({A.shape(0)});
xt::xtensor<double, 1> d = xt::empty<double>({B.shape(0)});
auto fmetric = detail::euclidean_metric;
if (distance_metric == metric::fast_perceptual) {
fmetric = detail::fast_perceptual_metric;
}
if (distance_metric == metric::perceptual) {
fmetric = detail::perceptual_metric;
}
for (size_t i = 0; i < A.shape(0); ++i) {
for (size_t j = 0; j < B.shape(0); ++j) {
d(j) = fmetric(A(i, 0), A(i, 1), A(i, 2), B(j, 0), B(j, 1), B(j, 2));
}
idx(i) = xt::argmin(d)(0);
}
return idx;
}
} // namespace cppcolormap
#endif
| [
"[email protected]"
] | |
222882eba238a12cd9b2a5a96cac1b019093a1a0 | c5c2633980fa4629bda09b26f12e2321c6837d12 | /Discrete Math/2 course/Labs/02_semestr/01_subword_search/GSearch4/main.cpp | c81f6276e968289b990a22a964fcfdf3c12f0232 | [] | no_license | DimaPhil/ITMO | bb5dbcc12730cb932ffc6c94bed7e69b71c583e1 | 356a781ae599129f318a469786d34fa088e9dd45 | refs/heads/master | 2021-03-24T14:05:13.915854 | 2017-02-26T12:02:47 | 2017-02-26T12:02:47 | 20,375,933 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,958 | cpp | #include <bits/stdc++.h>
const int alphabet = 30;
struct node {
node *parent, *link, *up;
node *children[alphabet];
node *next[alphabet];
char toParent;
bool isLeaf;
std::vector <int> id;
void cleanNode() {
parent = 0;
link = 0;
up = 0;
for (int i = 0; i < alphabet; i++) {
children[i] = 0;
next[i] = 0;
}
id.clear();
}
};
node *root = new node();
node *getLink(node *vertex);
node *get(node *vertex, char symbol);
node *getLink(node *vertex) {
if (vertex->link == 0) {
if (vertex == root || vertex->parent == root) {
vertex->link = root;
} else {
vertex->link = get(getLink(vertex->parent), vertex->toParent);
}
}
return vertex->link;
}
node *get(node *vertex, char symbol) {
int c = (int)symbol;
if (vertex->next[c] == 0) {
if (vertex->children[c] != 0) {
vertex->next[c] = vertex->children[c];
} else {
vertex->next[c] = (vertex == root) ? root : get(getLink(vertex), c);
}
}
return vertex->next[c];
}
node *getUp(node *vertex) {
if (vertex->up == 0) {
if (getLink(vertex)->isLeaf) {
vertex->up = getLink(vertex);
} else if (getLink(vertex) == root) {
vertex->up = root;
} else {
vertex->up = getUp(getLink(vertex));
}
}
return vertex->up;
}
void add(char *s, int id) {
node *now = root;
int length = strlen(s);
for (int i = 0; i < length; i++) {
int c = s[i] - 'a';
if (now->children[c] == 0) {
now->children[c] = new node();
now->children[c]->cleanNode();
now->children[c]->parent = now;
now->children[c]->toParent = c;
now->children[c]->isLeaf = false;
}
now = now->children[c];
}
now->isLeaf = true;
now->id.push_back(id);
}
const int maxn = 1e6 + 10;
char s[maxn], t[maxn];
int main() {
freopen("search4.in", "r", stdin);
freopen("search4.out", "w", stdout);
root->cleanNode();
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%s", s);
add(s, i);
}
scanf("%s", t);
int length = strlen(t);
std::vector <bool> ok(n, false);
node *now = root;
for (int i = 0; i < length; i++) {
int c = t[i] - 'a';
now = get(now, c);
node *tmp = now;
for (size_t j = 0; j < now->id.size(); j++) {
ok[now->id[j]] = true;
}
now->id.clear();
while (tmp != root) {
node *tmp2 = getUp(tmp);
tmp->up = root;
tmp = tmp2;
for (size_t j = 0; j < tmp->id.size(); j++) {
ok[tmp->id[j]] = true;
}
}
}
for (int i = 0; i < n; i++) {
printf("%s\n", ok[i] ? "YES" : "NO");
}
} | [
"[email protected]"
] | |
b5f8272ffb5fc67470c713950fa0b2adb382e956 | 932f17cb8f225dce669f73d8ce15c46a2fce9f7a | /ScaryMaze/Source/ScaryMaze/Ground.cpp | dbb275a9b9169a0150ff533c9b0c830fbcd30683 | [] | no_license | cop4331-group-14/COP4331-Project | 634960552c30b045d961a1ed86c1999e84f49806 | c3ddd3258703f56cfe39a1aa8dd52031611a5838 | refs/heads/master | 2021-10-26T10:02:16.489285 | 2019-04-11T18:21:08 | 2019-04-11T18:21:08 | 170,191,528 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 492 | cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "Ground.h"
// Constructor. Ground has no properties other than it's mesh.
AGround::AGround()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
// Applies the mesh to Ground.
GroundMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("GroundMeshComponent"));
RootComponent = GroundMesh;
} | [
"[email protected]"
] | |
4ee859788d3a61e42df7bffb4b4185e340cc8bd5 | c4fea8d1653fe862daac5dda6bb7fc67749c4ec4 | /chapter13/ex13_22.h | b2d8843f1de99b8424150d147a00cfa0e907b868 | [] | no_license | zhuanggengzhen/cpp-primer | c2beec0c5f477e016fa9c2024b14811cdf165676 | 5d2f6f9ca83eb239196486c682724addb6750e89 | refs/heads/master | 2021-01-10T01:47:25.242357 | 2015-11-15T10:58:32 | 2015-11-15T10:58:32 | 43,162,407 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 430 | h | #include <string>
class HasPtr
{
public:
HasPtr(const std::string &s = std::string()) : ps(new std::string(s)), i(0) {}
HasPtr(const HasPtr &hp) : ps(new std::string(*(hp.ps))), i(hp.i) { }
HasPtr &operator=(const HasPtr &rhs)
{
std::string *new_ps = new std::string(*rhs.ps);
delete ps;//To avoid memory leaks
ps = new_ps;
i = rhs.i;
return *this;
}
~HasPtr(){ delete ps; }
private:
std::string *ps;
int i;
};
| [
"[email protected]"
] | |
263c2d48eca69bf9078ec2c82bd56276972f97f0 | 28a65d7e2e0c1ff8ba5b008f027f736763f299fc | /engine/modules/scene/terrain/editor/terrain_editor.cpp | dcf4dc6f7cd2086d862623caf54b24bb21ee5a30 | [
"MIT"
] | permissive | jaccen2007/echo | b1837ac97d53a201f6ba926982c8c8a5ba7000fb | f32e94ed22f842f4a0a67f4417f9ca617b970147 | refs/heads/master | 2021-05-21T10:14:41.952721 | 2020-03-30T15:30:16 | 2020-03-30T15:30:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 443 | cpp | #include "terrain_editor.h"
#include "engine/core/editor/editor.h"
namespace Echo
{
#ifdef ECHO_EDITOR_MODE
TerrainEditor::TerrainEditor(Object* object)
: ObjectEditor(object)
{
}
TerrainEditor::~TerrainEditor()
{
}
// get camera2d icon, used for editor
const char* TerrainEditor::getEditorIcon() const
{
return "engine/modules/scene/terrain/editor/icon/terrain.png";
}
#endif
}
| [
"[email protected]"
] | |
ffc7c4c5602167f23f51b64624df43e672457b9a | c71c0c5d693bccd4cb64b2282cbedbac25b6e114 | /src/Magnum/SceneGraph/FeatureGroup.h | 9bc76c9b1bb95b0464ce8d45e69bdd00ba600b21 | [
"MIT"
] | permissive | janbajana/magnum | 69287c6d4fc0be577e7b19078406131484f4c53f | 9870cd72c96a3e09d5d79cbcd838bb365f84abc6 | refs/heads/master | 2023-08-23T07:20:47.202851 | 2021-10-24T17:52:08 | 2021-10-24T18:17:34 | 269,671,008 | 1 | 0 | NOASSERTION | 2020-06-05T14:47:21 | 2020-06-05T14:47:20 | null | UTF-8 | C++ | false | false | 7,630 | h | #ifndef Magnum_SceneGraph_FeatureGroup_h
#define Magnum_SceneGraph_FeatureGroup_h
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
2020, 2021 Vladimír Vondruš <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
/** @file
* @brief Class @ref Magnum::SceneGraph::AbstractFeatureGroup, @ref Magnum::SceneGraph::FeatureGroup, alias @ref Magnum::SceneGraph::BasicFeatureGroup2D, @ref Magnum::SceneGraph::BasicFeatureGroup3D, @ref Magnum::SceneGraph::FeatureGroup2D, @ref Magnum::SceneGraph::FeatureGroup3D
*/
#include <vector>
#include <Corrade/Utility/Assert.h>
#include "Magnum/SceneGraph/SceneGraph.h"
#include "Magnum/SceneGraph/visibility.h"
namespace Magnum { namespace SceneGraph {
/**
@brief Base for group of features
See @ref FeatureGroup.
*/
template<UnsignedInt dimensions, class T> class AbstractFeatureGroup {
public:
/**
* @brief Object transformation underlying type
* @m_since{2019,10}
*/
typedef T Type;
enum: UnsignedInt {
/**
* Dimension count
* @m_since{2019,10}
*/
Dimensions = dimensions
};
private:
template<UnsignedInt, class, class> friend class FeatureGroup;
explicit AbstractFeatureGroup();
virtual ~AbstractFeatureGroup();
void add(AbstractFeature<dimensions, T>& feature);
void remove(AbstractFeature<dimensions, T>& feature);
std::vector<std::reference_wrapper<AbstractFeature<dimensions, T>>> _features;
};
/**
@brief Group of features
See @ref AbstractGroupedFeature for more information.
@see @ref scenegraph, @ref BasicFeatureGroup2D, @ref BasicFeatureGroup3D,
@ref FeatureGroup2D, @ref FeatureGroup3D
*/
template<UnsignedInt dimensions, class Feature, class T> class FeatureGroup: public AbstractFeatureGroup<dimensions, T> {
friend AbstractGroupedFeature<dimensions, Feature, T>;
public:
explicit FeatureGroup() = default;
/**
* @brief Destructor
*
* Removes all features belonging to this group, but not deletes them.
*/
~FeatureGroup();
/** @brief Whether the group is empty */
bool isEmpty() const {
return AbstractFeatureGroup<dimensions, T>::_features.empty();
}
/** @brief Count of features in the group */
std::size_t size() const {
return AbstractFeatureGroup<dimensions, T>::_features.size();
}
/** @brief Feature at given index */
Feature& operator[](std::size_t index) {
return static_cast<Feature&>(AbstractFeatureGroup<dimensions, T>::_features[index].get());
}
/** @overload */
const Feature& operator[](std::size_t index) const {
return static_cast<Feature&>(AbstractFeatureGroup<dimensions, T>::_features[index].get());
}
/**
* @brief Add a feature to the group
* @return Reference to self (for method chaining)
*
* If the features is part of another group, it is removed from it.
* @see @ref remove(), @ref AbstractGroupedFeature::AbstractGroupedFeature()
*/
FeatureGroup<dimensions, Feature, T>& add(Feature& feature);
/**
* @brief Remove a feature from the group
* @return Reference to self (for method chaining)
*
* The feature must be part of the group.
* @see @ref add()
*/
FeatureGroup<dimensions, Feature, T>& remove(Feature& feature);
};
/**
@brief Base feature group for two-dimensional scenes
Convenience alternative to @cpp FeatureGroup<2, Feature, T> @ce. See
@ref AbstractGroupedFeature for more information.
@see @ref FeatureGroup2D, @ref BasicFeatureGroup3D
*/
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Multiple definitions still broken */
template<class Feature, class T> using BasicFeatureGroup2D = FeatureGroup<2, Feature, T>;
#endif
/**
@brief Base feature group for two-dimensional float scenes
Convenience alternative to @cpp BasicFeatureGroup2D<Feature, Float> @ce. See
@ref AbstractGroupedFeature for more information.
@see @ref FeatureGroup3D
*/
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Multiple definitions still broken */
template<class Feature> using FeatureGroup2D = BasicFeatureGroup2D<Feature, Float>;
#endif
/**
@brief Base feature group for three-dimensional scenes
Convenience alternative to @cpp FeatureGroup<3, Feature, T> @ce. See
@ref AbstractGroupedFeature for more information.
@see @ref FeatureGroup3D, @ref BasicFeatureGroup2D
*/
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Multiple definitions still broken */
template<class Feature, class T> using BasicFeatureGroup3D = FeatureGroup<3, Feature, T>;
#endif
/**
@brief Base feature group for three-dimensional float scenes
Convenience alternative to @cpp BasicFeatureGroup3D<Feature, Float> @ce. See
@ref AbstractGroupedFeature for more information.
@see @ref FeatureGroup2D
*/
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Multiple definitions still broken */
template<class Feature> using FeatureGroup3D = BasicFeatureGroup3D<Feature, Float>;
#endif
template<UnsignedInt dimensions, class Feature, class T> FeatureGroup<dimensions, Feature, T>::~FeatureGroup() {
for(auto i: AbstractFeatureGroup<dimensions, T>::_features) static_cast<Feature&>(i.get())._group = nullptr;
}
template<UnsignedInt dimensions, class Feature, class T> FeatureGroup<dimensions, Feature, T>& FeatureGroup<dimensions, Feature, T>::add(Feature& feature) {
/* Remove from previous group */
if(feature._group)
feature._group->remove(feature);
/* Crossreference the feature and group together */
AbstractFeatureGroup<dimensions, T>::add(feature);
feature._group = this;
return *this;
}
template<UnsignedInt dimensions, class Feature, class T> FeatureGroup<dimensions, Feature, T>& FeatureGroup<dimensions, Feature, T>::remove(Feature& feature) {
CORRADE_ASSERT(feature._group == this,
"SceneGraph::AbstractFeatureGroup::remove(): feature is not part of this group", *this);
AbstractFeatureGroup<dimensions, T>::remove(feature);
feature._group = nullptr;
return *this;
}
#if defined(CORRADE_TARGET_WINDOWS) && !(defined(CORRADE_TARGET_MINGW) && !defined(CORRADE_TARGET_CLANG))
extern template class MAGNUM_SCENEGRAPH_EXPORT AbstractFeatureGroup<2, Float>;
extern template class MAGNUM_SCENEGRAPH_EXPORT AbstractFeatureGroup<3, Float>;
#endif
}}
#endif
| [
"[email protected]"
] | |
ac6fe2623b94911e18a1ce91419063b3aaa22dfd | 1b49df9a4361c57a9e291d13fc85dce8dc349455 | /WH7/作業2/送一收多/server.cpp | cf8616585b4d6ed5428251bab51733fbffb78b4a | [] | no_license | davidchen0970/computer-network | 10cc786afd05ec10b133daa7e3165ba3baeb4c55 | 7ea722dbaa8f4abce56c4cd7eb52289cb2cd1c6b | refs/heads/main | 2023-04-18T17:03:24.815127 | 2021-05-03T02:40:14 | 2021-05-03T02:40:14 | 360,529,326 | 0 | 0 | null | null | null | null | BIG5 | C++ | false | false | 1,457 | cpp | #include<iostream>
#include<winsock.h>
using namespace std;
int main()
{
//------------------------------------------------
//初始化記憶體空間
SOCKET server_socket, client_socket;
WSAData wsadata;
struct sockaddr_in server, client;
char recieve[1024] = {};
char sending[1024] = "I love Algorithm?";
char Ip_Address[1024] = "127.0.0.1";
int port = 1234, binding = 0, send_recv = 0, listening = 0;
server.sin_family = AF_INET;
server.sin_addr.s_addr = inet_addr(Ip_Address);
server.sin_port = htons(port);
int client_length = sizeof(client);
int server_length = sizeof(server);
//------------------------------------------------
//初始化程式
WSAStartup(0x101, (LPWSADATA)&wsadata);
server_socket = socket(AF_INET, SOCK_STREAM, 0);
cout << "socket:\t\t" << server_socket << endl;
binding = bind(server_socket, (struct sockaddr*)&server, server_length);
cout << "bind():\t\t" << binding << endl;
listening = listen(server_socket, 5);
cout << "listen():\t" << listening << endl;
client_length = sizeof(client);
client_socket = accept(server_socket, (struct sockaddr*)&client, &client_length);
//------------------------------------------------
//先送後收
while (true)
{
send_recv = recv(client_socket, recieve, 6, 0);
if (send_recv)
cout << "Server recieve : " << recieve << ", "<< send_recv<<" bytes" << endl;
else
break;
}
system("pause");
closesocket(server_socket);
WSACleanup();
}
| [
"[email protected]"
] | |
f2e0459c2dd8a6ee22f549c4015dbc89d68fea15 | fec81bfe0453c5646e00c5d69874a71c579a103d | /blazetest/src/utiltest/memory/OperationTest.cpp | fadd76f7a56ab632303f5b7dc0496d71c42e56b4 | [
"BSD-3-Clause"
] | permissive | parsa/blaze | 801b0f619a53f8c07454b80d0a665ac0a3cf561d | 6ce2d5d8951e9b367aad87cc55ac835b054b5964 | refs/heads/master | 2022-09-19T15:46:44.108364 | 2022-07-30T04:47:03 | 2022-07-30T04:47:03 | 105,918,096 | 52 | 7 | null | null | null | null | UTF-8 | C++ | false | false | 11,335 | cpp | //=================================================================================================
/*!
// \file src/utiltest/memory/OperationTest.cpp
// \brief Source file for the memory operation test
//
// Copyright (C) 2012-2020 Klaus Iglberger - All Rights Reserved
//
// This file is part of the Blaze library. You can redistribute it and/or modify it under
// the terms of the New (Revised) BSD License. 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.
// 3. Neither the names of the Blaze development group nor the names of its contributors
// may be used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
// SHALL THE COPYRIGHT HOLDER 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.
*/
//=================================================================================================
//*************************************************************************************************
// Includes
//*************************************************************************************************
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <blaze/math/StaticVector.h>
#include <blaze/util/Memory.h>
#include <blaze/util/typetraits/AlignmentOf.h>
#include <blazetest/utiltest/memory/OperationTest.h>
#include <blazetest/utiltest/AlignedResource.h>
#include <blazetest/utiltest/ThrowingResource.h>
namespace blazetest {
namespace utiltest {
namespace memory {
//=================================================================================================
//
// CONSTRUCTORS
//
//=================================================================================================
//*************************************************************************************************
/*!\brief Constructor for the OperationTest class test.
//
// \exception std::runtime_error Operation error detected.
*/
OperationTest::OperationTest()
{
testBuiltinTypes();
testClassTypes();
testNullPointer();
}
//*************************************************************************************************
//=================================================================================================
//
// TEST TYPE TRAITS
//
//=================================================================================================
//*************************************************************************************************
/*!\brief Test of aligned allocation and deallocation of built-in data types.
//
// \return void
// \exception std::runtime_error Error detected.
//
// This function performs a test of the aligned allocation and deallocation functionality in
// combination with built-in data types. In case an error is detected, a \a std::runtime_error
// exception is thrown.
*/
void OperationTest::testBuiltinTypes()
{
// Built-in data type 'char'
{
test_ = "Built-in data types (char)";
char* array = blaze::allocate<char>( number );
const size_t alignment( blaze::AlignmentOf<char>::value );
const size_t deviation( reinterpret_cast<size_t>( array ) % alignment );
if( deviation != 0UL ) {
std::ostringstream oss;
oss << " Test: " << test_ << "\n"
<< " Error: Invalid alignment detected\n"
<< " Details:\n"
<< " Expected alignment: " << alignment << "\n"
<< " Deviation : " << deviation << "\n";
throw std::runtime_error( oss.str() );
}
blaze::deallocate( array );
}
// Built-in data type 'int'
{
test_ = "Built-in data types (int)";
int* array = blaze::allocate<int>( number );
const size_t alignment( blaze::AlignmentOf<int>::value );
const size_t deviation( reinterpret_cast<size_t>( array ) % alignment );
if( deviation != 0UL ) {
std::ostringstream oss;
oss << " Test: " << test_ << "\n"
<< " Error: Invalid alignment detected\n"
<< " Details:\n"
<< " Expected alignment: " << alignment << "\n"
<< " Deviation : " << deviation << "\n";
throw std::runtime_error( oss.str() );
}
blaze::deallocate( array );
}
// Built-in data type 'float'
{
test_ = "Built-in data types (float)";
float* array = blaze::allocate<float>( number );
const size_t alignment( blaze::AlignmentOf<float>::value );
const size_t deviation( reinterpret_cast<size_t>( array ) % alignment );
if( deviation != 0UL ) {
std::ostringstream oss;
oss << " Test: " << test_ << "\n"
<< " Error: Invalid alignment detected\n"
<< " Details:\n"
<< " Expected alignment: " << alignment << "\n"
<< " Deviation : " << deviation << "\n";
throw std::runtime_error( oss.str() );
}
blaze::deallocate( array );
}
// Built-in data type 'double'
{
test_ = "Built-in data types (double)";
double* array = blaze::allocate<double>( number );
const size_t alignment( blaze::AlignmentOf<double>::value );
const size_t deviation( reinterpret_cast<size_t>( array ) % alignment );
if( deviation != 0UL ) {
std::ostringstream oss;
oss << " Test: " << test_ << "\n"
<< " Error: Invalid alignment detected\n"
<< " Details:\n"
<< " Expected alignment: " << alignment << "\n"
<< " Deviation : " << deviation << "\n";
throw std::runtime_error( oss.str() );
}
blaze::deallocate( array );
}
}
//*************************************************************************************************
//*************************************************************************************************
/*!\brief Test of aligned allocation and deallocation of class types.
//
// \return void
// \exception std::runtime_error Error detected.
//
// This function performs a test of the aligned allocation and deallocation functionality in
// combination with class types. In case an error is detected, a \a std::runtime_error exception
// is thrown.
*/
void OperationTest::testClassTypes()
{
// User-specific class type 'AlignedResource'
{
test_ = "User-specific class types (AlignedResource)";
AlignedResource* array = blaze::allocate<AlignedResource>( number );
const size_t alignment( blaze::AlignmentOf<AlignedResource>::value );
for( size_t i=0UL; i<number; ++i )
{
const size_t deviation( reinterpret_cast<size_t>( &array[i] ) % alignment );
if( deviation != 0UL ) {
std::ostringstream oss;
oss << " Test: " << test_ << "\n"
<< " Error: Invalid alignment at index " << i << " detected\n"
<< " Details:\n"
<< " Expected alignment: " << alignment << "\n"
<< " Deviation : " << deviation << "\n";
throw std::runtime_error( oss.str() );
}
if( array[i].getValue() != 7U ) {
std::ostringstream oss;
oss << " Test: " << test_ << "\n"
<< " Error: Invalid value at index " << i << " detected\n"
<< " Details:\n"
<< " Current value : " << array[i].getValue() << "\n"
<< " Expected value: 7\n";
throw std::runtime_error( oss.str() );
}
}
blaze::deallocate( array );
if( AlignedResource::getCount() != 0U ) {
std::ostringstream oss;
oss << " Test: " << test_ << "\n"
<< " Error: Invalid number of instances detected\n"
<< " Details:\n"
<< " Current count : " << AlignedResource::getCount() << "\n"
<< " Expected count: 0\n";
throw std::runtime_error( oss.str() );
}
}
// User-specific class type 'ThrowingResource'
{
test_ = "User-specific class types (ThrowingResource)";
try {
blaze::allocate<ThrowingResource>( number );
}
catch( ... )
{
if( ThrowingResource::getCount() != 0U ) {
std::ostringstream oss;
oss << " Test: " << test_ << "\n"
<< " Error: Invalid number of instances detected\n"
<< " Details:\n"
<< " Current count : " << ThrowingResource::getCount() << "\n"
<< " Expected count: 0\n";
throw std::runtime_error( oss.str() );
}
return;
}
}
}
//*************************************************************************************************
//*************************************************************************************************
/*!\brief Test of a deallocation of a \c nullptr.
//
// \return void
// \exception std::runtime_error Error detected.
//
// This function performs a test of the deallocation using a \c nullptr. In case an error is
// detected, a \a std::runtime_error exception is thrown.
*/
void OperationTest::testNullPointer()
{
const int* const array( nullptr );
blaze::deallocate( array );
}
//*************************************************************************************************
} // namespace memory
} // namespace utiltest
} // namespace blazetest
//=================================================================================================
//
// MAIN FUNCTION
//
//=================================================================================================
//*************************************************************************************************
int main()
{
std::cout << " Running memory operation test..." << std::endl;
try
{
RUN_MEMORY_OPERATION_TEST;
}
catch( std::exception& ex ) {
std::cerr << "\n\n ERROR DETECTED during memory operation test:\n"
<< ex.what() << "\n";
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
//*************************************************************************************************
| [
"[email protected]"
] | |
cab696804c2ef282ac39b8dddf772ecf5d8ece68 | 33035c05aad9bca0b0cefd67529bdd70399a9e04 | /src/boost_mpi_collectives_scan.hpp | 14509c184fc6ec91fa5eac107bceaea6c4d5b364 | [
"LicenseRef-scancode-unknown-license-reference",
"BSL-1.0"
] | permissive | elvisbugs/BoostForArduino | 7e2427ded5fd030231918524f6a91554085a8e64 | b8c912bf671868e2182aa703ed34076c59acf474 | refs/heads/master | 2023-03-25T13:11:58.527671 | 2021-03-27T02:37:29 | 2021-03-27T02:37:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 42 | hpp | #include <boost/mpi/collectives/scan.hpp>
| [
"[email protected]"
] | |
6dbd06ab141026ca54aae043c847f084181cb21a | f81124e4a52878ceeb3e4b85afca44431ce68af2 | /re20_2/processor22/constant/polyMesh/boundary | 1ccba1fd10e1cd6ebb917fe5538613b2342b793f | [] | no_license | chaseguy15/coe-of2 | 7f47a72987638e60fd7491ee1310ee6a153a5c10 | dc09e8d5f172489eaa32610e08e1ee7fc665068c | refs/heads/master | 2023-03-29T16:59:14.421456 | 2021-04-06T23:26:52 | 2021-04-06T23:26:52 | 355,040,336 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,187 | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class polyBoundaryMesh;
location "constant/polyMesh";
object boundary;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
8
(
inlet
{
type patch;
nFaces 0;
startFace 612;
}
outlet
{
type patch;
nFaces 0;
startFace 612;
}
cylinder
{
type wall;
inGroups List<word> 1(wall);
nFaces 0;
startFace 612;
}
top
{
type symmetryPlane;
inGroups List<word> 1(symmetryPlane);
nFaces 2;
startFace 612;
}
bottom
{
type symmetryPlane;
inGroups List<word> 1(symmetryPlane);
nFaces 3;
startFace 614;
}
defaultFaces
{
type empty;
inGroups List<word> 1(empty);
nFaces 784;
startFace 617;
}
procBoundary22to21
{
type processor;
inGroups List<word> 1(processor);
nFaces 175;
startFace 1401;
matchTolerance 0.0001;
transform unknown;
myProcNo 22;
neighbProcNo 21;
}
procBoundary22to23
{
type processor;
inGroups List<word> 1(processor);
nFaces 164;
startFace 1576;
matchTolerance 0.0001;
transform unknown;
myProcNo 22;
neighbProcNo 23;
}
)
// ************************************************************************* //
| [
"[email protected]"
] | ||
815a9489ca93ccd7df83bc1e973bdfc287a23663 | f1074252cf5d16c2b166d467cecda5041d3634ff | /PAPER/TESTMBAHRA/main.cpp | 08039ca6fc3562760016fef2e6e4f3f72d39a20e | [] | no_license | asyllh/RESEARCH | a9bcfad391ec3b350a04761cec9c0fe50cc8206e | 5eca9f163b27bf4c027ac39e306b7e0590aacac1 | refs/heads/master | 2021-01-01T15:27:15.615702 | 2018-10-01T14:21:21 | 2018-10-01T14:21:21 | 97,621,687 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 47,692 | cpp | /*--------------
ALH
Fixing bug in mbahra from SCSPP
16/02/2018
---------------*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <ctime>
#include <random>
#include <cmath>
using namespace std;
int main(int argc, char **argv) {
//int randseed = atoi(argv[1]);
int instance;
int i, j, k;
int feasible = 0;
int threshold = 70;
int vacant = 999;
//vector<int> scores = {1, 69, 8, 3, 70, 13, 68, 10, 68, 6, 70, 30, 62, 45, 57, 5, 19, 43, 70, 70};
vector<int> scores;
int minWidth = 1;
int maxWidth = atoi(argv[1]);
int nScores = atoi(argv[2]);
int nBox = nScores / 2;
int nComp = (nBox + (nBox%2)) /2;
vector<int> randOrder;
vector<int> order;
vector<int> final;
//vector<int> original = {4, 974, 118, 32, 989, 182, 951, 133, 968, 80, 991, 439, 876, 633, 794, 69, 279, 611};
//int nScores = scores.size();
//int nBox = nScores / 2;
//int nComp = (nBox + (nBox % 2)) / 2;
vector<int> invOrder(nScores);
vector<vector<int> > adjMat(nScores, vector<int>(nScores, 0));
vector<int> mates(nScores, vacant);
vector<int> fullCycle;
vector<int> completePath;
//srand(randseed);
for(instance = 10; instance < 100; ++instance){
//srand(1);
scores.clear();
randOrder.clear();
for(i = 0; i < adjMat.size(); ++i){
for(j = 0; j < adjMat[i].size(); ++j){
adjMat[i][j] = 0;
}
}
for(i = 0; i < mates.size(); ++i){
mates[i] = vacant;
}
completePath.clear();
fullCycle.clear();
final.clear();
feasible = 0;
if (feasible == 0) {
/*for (i = 0; i < nScores; ++i) {
order.push_back(i);
}
for (i = 1; i < nScores; ++i) {
for (j = i - 1; j >= 0; --j) {
if (scores[i] < scores[order[j]]) {
order[j + 1] = order[j];
order[j] = i;
}
}
}*/
/*cout << "Order:\n";
for (int v : order) {
cout << v << " ";
}
cout << endl;
for (i = 0; i < nScores; ++i) {
invOrder[order[i]] = i;
}
cout << "invOrder:\n";
for (int v : invOrder) {
cout << v << " ";
}
cout << endl;*/
/*for (i = 0; i < nScores; i += 2) {
adjMat[invOrder[i]][invOrder[i + 1]] = 2;
adjMat[invOrder[i + 1]][invOrder[i]] = 2;
}*/
//sort(scores.begin(), scores.end());
/*for (i = 0; i < scores.size() - 1; ++i) {
for (j = i + 1; j < scores.size(); ++j) {
if (scores[i] + scores[j] >= threshold && adjMat[i][j] != 2) {
adjMat[i][j] = 1;
adjMat[j][i] = 1;
}
}
}*/
/*for (i = 0; i < nScores; ++i) {
if (mates[i] == vacant) {
for (j = 0; j < nScores; ++j) {
if (adjMat[i][j] == 2) {
mates[i] = j;
mates[j] = i;
break;
}
}
}
}*/
for(i = 0; i < nScores - 2; ++i){
scores.push_back(rand() % (maxWidth - minWidth + 1) + minWidth);
}
scores.push_back(70);
scores.push_back(70);
if(instance == 22){
cout << "scores:\n";
for(int v : scores){
cout << v << " ";
}
cout << endl;
}
sort(scores.begin(), scores.end());
for(i = 0; i < scores.size() - 1; ++i){
for(j = i+1; j < scores.size(); ++j){
if(scores[i] + scores[j] >= threshold){
adjMat[i][j] = 1;
adjMat[j][i] = 1;
}
}
}
for(i = 0; i < nScores - 2; ++i){
randOrder.push_back(i);
}
random_shuffle(randOrder.begin(), randOrder.end());
/*cout << "randorder:\n";
for(int v : randOrder){
cout << v << " ";
}
cout << endl;*/
for(i = 0; i < (nScores - 2) / 2; ++i){
//cout << "hi\n";
adjMat[randOrder[2*i]][randOrder[2*i+1]] = 2;
adjMat[randOrder[2*i+1]][randOrder[2*i]] = 2;
}
//cout << "hi\n";
adjMat[nScores-1][nScores-2] = 2;
adjMat[nScores - 2][nScores - 1] = 2;
/*cout << "adjMat:\n";
for(i = 0; i < adjMat.size(); ++i){
for(j = 0; j < adjMat[i].size(); ++j){
cout << adjMat[i][j] << " ";
}
cout << endl;
}
cout << endl;*/
for(i = 0; i < nScores; ++i){
for(j = 0; j < nScores; ++j){
if(adjMat[i][j] == 2){
mates[i] = j;
break;
}
}
}
if(instance == 90){
cout << "Mates:\n";
for (int v : mates) {
cout << v << " ";
}
cout << endl;
}
//MTGMA
int vacantFlag = 0;
int matchSize = 0;
int lastMatch = vacant;
int mateMatch = vacant;
vector<int> cycleVertex(nScores, 1);
vector<int> matchList(nScores, vacant);
for (i = 0; i < nScores; ++i) {
vacantFlag = 0;
if (matchList[i] == vacant) {
for (j = nScores - 1; j > i; --j) {
if (adjMat[i][j] == 1 && matchList[j] == vacant) {
matchList[i] = j;
matchList[j] = i;
lastMatch = i;
++matchSize;
if (vacantFlag == 1) {
cycleVertex[i] = vacant;
cycleVertex[j] = vacant;
}
break;
}
else if (adjMat[i][j] == 2 && matchList[j] == vacant) {
vacantFlag = 1;
}
}
if (matchList[i] == vacant) {
mateMatch = mates[i]; //check if matches line 588 in SCSPP.
if ((scores[i] + scores[mateMatch] >= threshold) && (matchList[mateMatch] == vacant) &&
(lastMatch != vacant)
&& (mateMatch > i) && (scores[lastMatch] + scores[mateMatch] >= threshold)) {
matchList[i] = matchList[lastMatch];
matchList[lastMatch] = mateMatch;
matchList[mateMatch] = lastMatch;
matchList[matchList[i]] = i;
cycleVertex[lastMatch] = vacant;
cycleVertex[mateMatch] = vacant;
lastMatch = i;
++matchSize;
}
}
}
//cout << "hi2\n";
}
//cout << matchSize << endl;
if(instance == 90){
cout << "matchlist:\n";
for(int c: matchList){
cout << c << " ";
}
cout << endl;
}
if (matchSize < nBox) {
feasible = 0;
goto End;
}
/**MIS**/
int numCycles = 0;
int smallestVertex;
int currentVertex;
vector<int> lengthMateInduced;
vector<int> tempMIS;
vector<int> checked(nScores, 0);
vector<vector<int> > mateInduced;
for (i = 0; i < nScores; ++i) {
if (checked[i] == 0) {
smallestVertex = i;
break;
}
}
do {
currentVertex = smallestVertex;
do {
tempMIS.push_back(currentVertex);
checked[currentVertex] = 1;
tempMIS.push_back(mates[currentVertex]);
checked[mates[currentVertex]] = 1;
currentVertex = matchList[mates[currentVertex]];
} while (currentVertex != smallestVertex);
mateInduced.push_back(tempMIS);
tempMIS.clear();
for (i = 0; i < nScores; ++i) {
if (checked[i] == 0) {
smallestVertex = i;
break;
}
}
} while (smallestVertex != currentVertex);
tempMIS.clear();
numCycles = mateInduced.size();
for (i = 0; i < mateInduced.size(); ++i) {
lengthMateInduced.push_back(mateInduced[i].size());
}
if(mateInduced.size() > 4){
cout << "MPS - instance = " << instance << ": \n";
for(i = 0; i < mateInduced.size(); ++i){
for(j = 0; j < mateInduced[i].size(); ++j){
cout << mateInduced[i][j] << " ";
}
cout << endl;
}
cout << endl << endl;
}
else{
continue;
}
//cout << "hi\n";
if (lengthMateInduced[0] == nScores) {
for (j = 0; j < mateInduced[0].size(); ++j) {
fullCycle.push_back(mateInduced[0][j]);
}
/**MakePath**/
for (i = 0; i < fullCycle.size() - 1; ++i) {
if ((fullCycle[i] == nScores - 1 && fullCycle[i + 1] == nScores - 2) ||
(fullCycle[i] == nScores - 2 && fullCycle[i + 1] == nScores - 1)) {
if (i == 0) {
for (j = 2; j < fullCycle.size(); ++j) {
completePath.push_back(fullCycle[j]);
}
break;
}
else if (i == fullCycle.size() - 2) {
for (j = 0; j < fullCycle.size() - 2; ++j) {
completePath.push_back(fullCycle[j]);
}
break;
}
else {
for (j = i + 2; j < fullCycle.size(); ++j) {
completePath.push_back(fullCycle[j]);
}
for (j = 0; j < i; ++j) {
completePath.push_back(fullCycle[j]);
}
break;
}
}
}
/*for (i = 0; i < completePath.size(); ++i) {
final.push_back(original[order[completePath[i]]]);
}*/
feasible = 1;
goto End;
}
/**FCA**/
int qstar, numEdges;
vector<int> edge;
vector<int> t;
vector<vector<int> > T;
vector<vector<int> > S(nComp, vector<int>(nComp, 0));
for (i = 0; i < mateInduced.size(); ++i) {
for (j = 0; j < mateInduced[i].size(); ++j) {
if (cycleVertex[mateInduced[i][j]] != vacant) {
cycleVertex[mateInduced[i][j]] = i;
}
}
}
for (i = 0; i < matchSize; ++i) {
while (cycleVertex[i] == vacant) {
++i;
}
edge.push_back(i);
}
numEdges = edge.size();
qstar = -1;
k = 0;
do {
while (k < numEdges - 2 &&
(adjMat[edge[k]][matchList[edge[k + 1]]] != 1 || cycleVertex[edge[k]] == cycleVertex[edge[k + 1]])) {
++k;
}
if (adjMat[edge[k]][matchList[edge[k + 1]]] == 1 && cycleVertex[edge[k]] != cycleVertex[edge[k + 1]]) {
++qstar;
t.push_back(edge[k]);
S[qstar][cycleVertex[edge[k]]] = 1;
while (k < numEdges - 1 && adjMat[edge[k]][matchList[edge[k + 1]]] == 1 &&
S[qstar][cycleVertex[edge[k + 1]]] == 0) {
++k;
t.push_back(edge[k]);
S[qstar][cycleVertex[edge[k]]] = 1;
}
T.push_back(t);
t.clear();
}
++k;
} while (k < numEdges - 1);
t.clear();
if(instance == 90){
cout << "T - instance = " << instance << ": \n";
for(i = 0; i < T.size(); ++i){
for(j = 0; j < T[i].size(); ++j){
cout << T[i][j] << " ";
}
cout << endl;
}
cout << endl << endl;
}
if(instance == 90){
cout << "S - instance = " << instance << ": \n";
for(i = 0; i < T.size(); ++i){
for(j = 0; j < numCycles; ++j){
cout << S[i][j] << " ";
}
cout << endl;
}
cout << endl << endl;
}
if (qstar == -1) {
feasible = 0;
goto End;
}
/**PatchGraph**/
int q, u, v, save, SSum, SqIntS;
int a;
bool found = false;
int v1 = 0;
int v2 = 0;
int full = vacant;
vector<int> SSet;
vector<int> tempPG;
vector<int> QSet(nComp, 0);
vector<int> patchCycle(nComp, vacant);
vector<int> patchVertex(nScores, vacant);
vector<vector<int> > Tpatch;
for (i = 0; i < T.size(); ++i) {
if (T.size() == numCycles) {
full = i;
break;
}
}
if (full != vacant) {
save = 0;
//cout << "Full: " << full << endl;
for (v = 0; v < T[full].size(); ++v) {
for (j = 0; j < mateInduced[cycleVertex[T[full][v]]].size(); ++j) {
if (mateInduced[cycleVertex[T[full][v]]][j] == matchList[T[full][v]]) {
save = j;
break;
}
}
//region oneTCyclePatch
/****************************oneTCyclePatch algorithm: ***********************************/
//CASE ONE: if element matchList[T[full][v]] is before element T[full][v] in the mateInduced cycle
//i.e. if the element at position 'save' in the cycle is matchList[T[full][v]] and the element at position "save + 1" is T[full][v]
if (mateInduced[cycleVertex[T[full][v]]][save + 1] == T[full][v]) {
for (i = save + 1; i-- > 0;) { //from element at position 'save' to the first element in the cycle
fullCycle.push_back(mateInduced[cycleVertex[T[full][v]]][i]);
}
for (i = mateInduced[cycleVertex[T[full][v]]].size();
i-- > save + 1;) { //from end of cycle to element at position save+1
fullCycle.push_back(mateInduced[cycleVertex[T[full][v]]][i]);
}
}
//CASE TWO: if element matchList[T[full][v]] is after element T[full][v] in the mateInduced cycle
//i.e. if the element at position 'save' in the cycle is matchList[T[full][v]] and the element at position "save - 1" is T[full][v]
else if (mateInduced[cycleVertex[T[full][v]]][save - 1] == T[full][v]) {
for (i = save; i < mateInduced[cycleVertex[T[full][v]]].size(); ++i) {
fullCycle.push_back(mateInduced[cycleVertex[T[full][v]]][i]);
}
for (i = 0; i < save; ++i) {
fullCycle.push_back(mateInduced[cycleVertex[T[full][v]]][i]);
}
}
//CASE THREE: if element matchList[T[full][v]] is the first element in the cycle, and T[full][v] is the last element in the cycle
//i.e. if save = 0 and T[full][v] is at position mateInduced[cycleVertex[T[full][v]]].size()-1
else if (save == 0 &&
mateInduced[cycleVertex[T[full][v]]][mateInduced[cycleVertex[T[full][v]]].size() -
1] == T[full][v]) {
for (i = 0; i < mateInduced[cycleVertex[T[full][v]]].size(); ++i) {
fullCycle.push_back(mateInduced[cycleVertex[T[full][v]]][i]);
}
}
//CASE FOUR: if element matchList[T[full][v]] is the last element in the cycle, and T[full][v] is the first element in the cycle
//i.e. if save = mateInduced[cycleVertex[T[full][v]]].size()-1 and T[full][v] is at position 0
else if (save == mateInduced[cycleVertex[T[full][v]]].size() - 1 &&
mateInduced[cycleVertex[T[full][v]]][0] == T[full][v]) {
for (i = mateInduced[cycleVertex[T[full][v]]].size(); i-- > 0;) {
fullCycle.push_back(mateInduced[cycleVertex[T[full][v]]][i]);
}
}
//END ONETCYCLEPATCH FUNCTION
//endregion
}
//region MakePath
/**MakePath**/
for (i = 0; i < fullCycle.size() - 1; ++i) {
if ((fullCycle[i] == nScores - 1 && fullCycle[i + 1] == nScores - 2) ||
(fullCycle[i] == nScores - 2 && fullCycle[i + 1] == nScores - 1)) {
if (i == 0) {
for (j = 2; j < fullCycle.size(); ++j) {
completePath.push_back(fullCycle[j]);
}
break;
}
else if (i == fullCycle.size() - 2) {
for (j = 0; j < fullCycle.size() - 2; ++j) {
completePath.push_back(fullCycle[j]);
}
break;
}
else {
for (j = i + 2; j < fullCycle.size(); ++j) {
completePath.push_back(fullCycle[j]);
}
for (j = 0; j < i; ++j) {
completePath.push_back(fullCycle[j]);
}
break;
}
}
}
/*for (i = 0; i < completePath.size(); ++i) {
final.push_back(original[order[completePath[i]]]);
}*/
feasible = 1;
goto End;
//endregion
}
else {
for(a = 0; a < T.size() - 1; ++a){
for(q = a+1; q < T.size(); ++q){
SqIntS = 0;
for(i = 0; i < numCycles; ++i){
if(S[a][i] + S[q][i] == 0){
SqIntS = 0;
break;
}
if(S[a][i] + S[q][i] == 2){
++SqIntS;
}
}
if(SqIntS == 1){
v1 = a;
v2 = q;
SSum = numCycles;
found = true;
break;
}
}
if(found){
break;
}
}
/*q = 0;
QSet[0] = 1;
SSum = 0;
for (i = 0; i < numCycles; ++i) {
SSet.push_back(S[q][i]);
}
for (i = 0; i < numCycles; ++i) {
SSum = SSum + SSet[i];
}
if (SSum >= 1) {
patchCycle[q] = 1;
}
while (q <= qstar && SSum < numCycles) {
do {
++q;
SqIntS = vacant;
if (q <= qstar) {
for (j = 0; j < numCycles; ++j) {
if (S[q][j] == 1 && SSet[j] == 1) {
SqIntS = 1;
}
}
}
} while (q < qstar + 1 && (QSet[q] == 1 || SqIntS == vacant));
if (q <= qstar) {
for (i = 0; i < numCycles; ++i) {
if (SSet[i] == 0 && S[q][i] == 1) {
SSet[i] = 1;
++SSum;
patchCycle[q] = 1;
}
}
QSet[q] = 1;
q = 0;
}
}//endwhile*/
//If patching graph is connected, then instance is feasible, else infeasible
if (SSum == numCycles) {
/*for (i = 0; i < patchCycle.size(); ++i) {
if (patchCycle[i] == 1) {
for (j = 0; j < T[i].size(); ++j) {
tempPG.push_back(T[i][j]);
}
Tpatch.push_back(tempPG);
tempPG.clear();
}
}
tempPG.clear();*/
for(j = 0; j < T[v1].size(); ++j){
tempPG.push_back(T[v1][j]);
}
Tpatch.push_back(tempPG);
tempPG.clear();
for(j = 0; j < T[v2].size(); ++j){
tempPG.push_back(T[v2][j]);
}
Tpatch.push_back(tempPG);
tempPG.clear();
if(instance == 90){
cout << "Tpatch:\n";
for(i =0; i < Tpatch.size(); ++i){
for(j = 0; j < Tpatch[i].size(); ++j){
cout << Tpatch[i][j] << " ";
}
cout << endl;
}
cout << endl;
}
vector<int> patchML;
vector<int> inCycle(nScores, 0);
copy(matchList.begin(), matchList.end(), back_inserter(patchML));
/*cout << "Patch MatchList:\n";
for(int w : patchML){
cout << w << " ";
}
cout << endl;*/
for(u = 0; u < Tpatch.size(); ++u){
for(v = 0; v < Tpatch[u].size() - 1; ++v){
patchML[Tpatch[u][v]] = matchList[Tpatch[u][v+1]];
patchML[matchList[Tpatch[u][v+1]]] = Tpatch[u][v];
}
patchML[Tpatch[u][Tpatch[u].size()-1]] = matchList[Tpatch[u][0]];
patchML[matchList[Tpatch[u][0]]] = Tpatch[u][Tpatch[u].size()-1];
}
/*cout << "Patch MatchList:\n";
for(int w : patchML){
cout << w << " ";
}
cout << endl;*/
int current = nScores - 2;
do{
fullCycle.push_back(current);
inCycle[current] = 1;
fullCycle.push_back(mates[current]);
inCycle[mates[current]] = 1;
if(inCycle[patchML[mates[current]]] == 0){
current = patchML[mates[current]];
}
else{
current = matchList[mates[current]];
}
} while(fullCycle.size() < nScores);
//region MAKEPATH
/**MAKEPATH FUNCTION**/
for (i = 0; i < fullCycle.size() - 1; ++i) {
if ((fullCycle[i] == nScores - 1 && fullCycle[i + 1] == nScores - 2) ||
(fullCycle[i] == nScores - 2 && fullCycle[i + 1] == nScores - 1)) {
if (i == 0) { //if the dominating vertices are at the beginning of the fullCycle vector
for (j = 2; j < fullCycle.size(); ++j) {
completePath.push_back(fullCycle[j]);
}
break;
}
else if (i == fullCycle.size() -
2) { //if the dominating vertices are at the end of the fullCycle vector
for (j = 0; j < fullCycle.size() - 2; ++j) {
completePath.push_back(fullCycle[j]);
}
break;
}
else { //if the dominating vertices are in the middle of the fullCycle vector
for (j = i + 2; j < fullCycle.size(); ++j) {
completePath.push_back(fullCycle[j]);
}
for (j = 0; j < i; ++j) {
completePath.push_back(fullCycle[j]);
}
break;
}
}
}
/*for (i = 0; i < completePath.size(); ++i) {
final.push_back(original[order[completePath[i]]]);
}*/
feasible = 1;
goto End;
//END MAKE PATH FUNCTION
//endregion
}
else if (SSum < numCycles) {
feasible = 0;
goto End;
}
else {
feasible = 0;
goto End;
}
}
}
End:
//cout << "end:\n";
if (feasible == 1) {
//cout << "Final:\n";
/*for (int v : final) {
cout << v << " ";
}*/
cout << endl;
}
}
cout << "COMPLETE.\n";
}
/*
for (i = 0; i < Tpatch.size(); ++i) {
for (j = 0; j < Tpatch[i].size(); ++j) {
patchVertex[Tpatch[i][j]] = i;
patchVertex[matchList[Tpatch[i][j]]] = i;
}
}
u = 0;
v = 0;
save = 0;
for (j = 0; j < mateInduced[cycleVertex[Tpatch[u][v]]].size(); ++j) {
if (mateInduced[cycleVertex[Tpatch[u][v]]][j] == matchList[Tpatch[u][v]]) {
save = j;
break;
}
}
//region multipleTCyclePatch
//MULTIPLE T CYCLE PATCH FUNCTION ***********************
int x = 0;
//CASE ONE: if the current value is matchList[Tpatch[u][v]] and the previous value is Tpatch[u][v]
if (mateInduced[cycleVertex[Tpatch[u][v]]][save - 1] == Tpatch[u][v]) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][save]);
for (i = save + 1; i < mateInduced[cycleVertex[Tpatch[u][v]]].size(); ++i) {
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
x = 1;
break;
}
}
if (x == 0) {
for (i = 0; i < save; ++i) {
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
break;
}
}
}
}
//CASE TWO: if the current value is Tpatch[u][v] and the previous value is matchList[Tpatch[u][v]]
else if (mateInduced[cycleVertex[Tpatch[u][v]]][save - 1] == matchList[Tpatch[u][v]]) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][save]);
for (i = save + 1; i < mateInduced[cycleVertex[Tpatch[u][v]]].size(); ++i) {
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
x = 1;
break;
}
}
if (x == 0) {
for (i = 0; i < save; ++i) {
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
break;
}
}
}
}
//CASE THREE: if the current vertex is Tpatch[u][v] and the next element is matchList[Tpatch[u][v]]
else if (mateInduced[cycleVertex[Tpatch[u][v]]][save + 1] == matchList[Tpatch[u][v]]) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][save]);
for (i = save; i-- > 0;) { //from element at position 'save' to the first element in the cycle
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
x = 1;
break;
}
}
if (x == 0) {
for (i = mateInduced[cycleVertex[Tpatch[u][v]]].size();
i-- > save + 1;) { //from end of cycle to element at position save+1
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
break;
}
}
}
}
//CASE FOUR: if the current vertex is matchList[Tpatch[u][v]] and the next element is Tpatch[u][v]
else if (mateInduced[cycleVertex[Tpatch[u][v]]][save + 1] == Tpatch[u][v]) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][save]);
for (i = save; i-- > 0;) { //from element at position 'save' to the first element in the cycle
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
x = 1;
break;
}
}
if (x == 0) {
for (i = mateInduced[cycleVertex[Tpatch[u][v]]].size();
i-- > save + 1;) { //from end of cycle to element at position save+1
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
break;
}
}
}
}
//CASE FIVE: if the current vertex is matchList[Tpatch[u][v]] and is the first element in the cycle, and
//the last element in the cycle is Tpatch[u][v]
else if (save == 0 &&
mateInduced[cycleVertex[Tpatch[u][v]]][mateInduced[cycleVertex[Tpatch[u][v]]].size() - 1] ==
Tpatch[u][v]) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][save]);
for (i = 1; i < mateInduced[cycleVertex[Tpatch[u][v]]].size(); ++i) {
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
break;
}
}
}
//CASE SIX: if the current vertex is matchList[Tpatch[u][v]] and is last element in the cycle, and
//the first element in the cycle is Tpatch[u][v]
else if (save == mateInduced[cycleVertex[Tpatch[u][v]]].size() - 1 &&
mateInduced[cycleVertex[Tpatch[u][v]]][0] == Tpatch[u][v]) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][save]);
for (i = mateInduced[cycleVertex[Tpatch[u][v]]].size() - 1; i-- > 0;) {
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
break;
}
}
}
//CASE SEVEN: if the current vertex is Tpatch[u][v] and is the first element in the cycle, and
//and the last element in the cycle is matchList[Tpatch[u][v]]
else if (save == 0 &&
mateInduced[cycleVertex[Tpatch[u][v]]][mateInduced[cycleVertex[Tpatch[u][v]]].size() - 1] ==
matchList[Tpatch[u][v]]) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][save]);
for (i = 1; i < mateInduced[cycleVertex[Tpatch[u][v]]].size(); ++i) {
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
break;
}
}
}
//CASE EIGHT: if the current vertex is Tpatch[u][v] and is last element in the cycle, and
//the first element in the cycle is matchList[Tpatch[u][v]]
else if (save == mateInduced[cycleVertex[Tpatch[u][v]]].size() - 1 &&
mateInduced[cycleVertex[Tpatch[u][v]]][0] == matchList[Tpatch[u][v]]) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][save]);
for (i = mateInduced[cycleVertex[Tpatch[u][v]]].size() - 1; i-- > 0;) {
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
break;
}
}
}
//END MULTIPLE T CYCLE PATCH FUNCTION
//endregion
*/
/* while (fullCycle.size() < nScores) {
save = 0;
for (i = 0; i < Tpatch[u].size(); ++i) {
if (Tpatch[u][i] == fullCycle.back()) {
if (i == Tpatch[u].size() - 1) {
v = 0;
}
else {
v = ++i;
}
for (j = 0; j < mateInduced[cycleVertex[Tpatch[u][v]]].size(); ++j) {
if (mateInduced[cycleVertex[Tpatch[u][v]]][j] == matchList[Tpatch[u][v]]) {
save = j;
break;
}
}
break;
}
else if (matchList[Tpatch[u][i]] == fullCycle.back()) {
if (i == 0) {
v = Tpatch[u].size() - 1;
}
else {
v = --i;
}
for (j = 0; j < mateInduced[cycleVertex[Tpatch[u][v]]].size(); ++j) {
if (mateInduced[cycleVertex[Tpatch[u][v]]][j] == Tpatch[u][v]) {
save = j;
break;
}
}
break;
}
}
//region multipleTCyclePatch
//MULTIPLE T CYCLE PATCH FUNCTION
int x = 0;
//CASE ONE: if the current value is matchList[Tpatch[u][v]] and the previous value is Tpatch[u][v]
if (mateInduced[cycleVertex[Tpatch[u][v]]][save - 1] == Tpatch[u][v]) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][save]);
for (i = save + 1; i < mateInduced[cycleVertex[Tpatch[u][v]]].size(); ++i) {
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
x = 1;
break;
}
}
if (x == 0) {
for (i = 0; i < save; ++i) {
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
break;
}
}
}
}
//CASE TWO: if the current value is Tpatch[u][v] and the previous value is matchList[Tpatch[u][v]]
else if (mateInduced[cycleVertex[Tpatch[u][v]]][save - 1] == matchList[Tpatch[u][v]]) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][save]);
for (i = save + 1; i < mateInduced[cycleVertex[Tpatch[u][v]]].size(); ++i) {
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
x = 1;
break;
}
}
if (x == 0) {
for (i = 0; i < save; ++i) {
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
break;
}
}
}
}
//CASE THREE: if the current vertex is Tpatch[u][v] and the next element is matchList[Tpatch[u][v]]
else if (mateInduced[cycleVertex[Tpatch[u][v]]][save + 1] == matchList[Tpatch[u][v]]) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][save]);
for (i = save; i-- > 0;) { //from element at position 'save' to the first element in the cycle
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
x = 1;
break;
}
}
if (x == 0) {
for (i = mateInduced[cycleVertex[Tpatch[u][v]]].size();
i-- > save + 1;) { //from end of cycle to element at position save+1
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
break;
}
}
}
}
//CASE FOUR: if the current vertex is matchList[Tpatch[u][v]] and the next element is Tpatch[u][v]
else if (mateInduced[cycleVertex[Tpatch[u][v]]][save + 1] == Tpatch[u][v]) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][save]);
for (i = save; i-- > 0;) { //from element at position 'save' to the first element in the cycle
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
x = 1;
break;
}
}
if (x == 0) {
for (i = mateInduced[cycleVertex[Tpatch[u][v]]].size();
i-- > save + 1;) { //from end of cycle to element at position save+1
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
break;
}
}
}
}
//CASE FIVE: if the current vertex is matchList[Tpatch[u][v]] and is the first element in the cycle, and
//the last element in the cycle is Tpatch[u][v]
else if (save == 0 && mateInduced[cycleVertex[Tpatch[u][v]]][mateInduced[cycleVertex[Tpatch[u][v]]].size() - 1] == Tpatch[u][v]) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][save]);
for (i = 1; i < mateInduced[cycleVertex[Tpatch[u][v]]].size(); ++i) {
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
break;
}
}
}
//CASE SIX: if the current vertex is matchList[Tpatch[u][v]] and is last element in the cycle, and
//the first element in the cycle is Tpatch[u][v]
else if (save == mateInduced[cycleVertex[Tpatch[u][v]]].size() - 1 &&
mateInduced[cycleVertex[Tpatch[u][v]]][0] == Tpatch[u][v]) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][save]);
for (i = mateInduced[cycleVertex[Tpatch[u][v]]].size() - 1; i-- > 0;) {
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
break;
}
}
}
//CASE SEVEN: if the current vertex is Tpatch[u][v] and is the first element in the cycle, and
//and the last element in the cycle is matchList[Tpatch[u][v]]
else if (save == 0 && mateInduced[cycleVertex[Tpatch[u][v]]][mateInduced[cycleVertex[Tpatch[u][v]]].size() - 1] == matchList[Tpatch[u][v]]) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][save]);
for (i = 1; i < mateInduced[cycleVertex[Tpatch[u][v]]].size(); ++i) {
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
break;
}
}
}
//CASE EIGHT: if the current vertex is Tpatch[u][v] and is last element in the cycle, and
//the first element in the cycle is matchList[Tpatch[u][v]]
else if (save == mateInduced[cycleVertex[Tpatch[u][v]]].size() - 1 &&
mateInduced[cycleVertex[Tpatch[u][v]]][0] == matchList[Tpatch[u][v]]) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][save]);
for (i = mateInduced[cycleVertex[Tpatch[u][v]]].size() - 1; i-- > 0;) {
if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] == vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
}
else if (patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]] != vacant) {
fullCycle.push_back(mateInduced[cycleVertex[Tpatch[u][v]]][i]);
u = patchVertex[mateInduced[cycleVertex[Tpatch[u][v]]][i]];
break;
}
}
}
//END MULTIPLE T CYCLE PATCH FUNCTION
//endregion
}*/
| [
"[email protected]"
] | |
507d4c6f90f0fc04fee3748536d2e277b4df95bb | f53267d2223a023e1c643a648dd9bed4f1e58c53 | /FT68000/trunk/software/cc64/source/Analyze.cpp | e783fafecb0b6f715a7e87a8953026630c2db4c2 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | robfinch/Cores | 9eec2c88ba7c2495ed5c1bdde9ff1fd82436a6cd | 0015669674bafdc4eff56e816cf714c975536fc3 | refs/heads/master | 2023-07-06T21:07:31.639981 | 2023-06-28T23:05:20 | 2023-06-28T23:05:20 | 13,174,959 | 58 | 27 | null | 2017-08-12T12:03:51 | 2013-09-28T15:03:00 | C++ | UTF-8 | C++ | false | false | 22,341 | cpp | // ============================================================================
// __
// \\__/ o\ (C) 2012-2017 Robert Finch, Waterloo
// \ __ / All rights reserved.
// \/_// robfinch<remove>@finitron.ca
// ||
//
// C64 - 'C' derived language compiler
// - 64 bit CPU
//
// This source file is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This source file is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ============================================================================
//
#include "stdafx.h"
/*
* 68000 C compiler
*
* Copyright 1984, 1985, 1986 Matthew Brandt.
* all commercial rights reserved.
*
* This compiler is intended as an instructive tool for personal use. Any
* use for profit without the written consent of the author is prohibited.
*
* This compiler may be distributed freely for non-commercial use as long
* as this notice stays intact. Please forward any enhancements or questions
* to:
*
* Matthew Brandt
* Box 920337
* Norcross, Ga 30092
*/
int bsave_mask;
extern int popcnt(int m);
extern int AllocateRegisterVars();
static void scan_compound(Statement *stmt);
static void repcse_compound(Statement *stmt);
extern int OptimizationDesireability(CSE *csp);
CSE CSETable[500];
short int csendx;
short int loop_active;
/*
* this module will step through the parse tree and find all
* optimizable expressions. at present these expressions are
* limited to expressions that are valid throughout the scope
* of the function. the list of optimizable expressions is:
*
* constants
* global and static addresses
* auto addresses
* contents of auto addresses.
*
* contents of auto addresses are valid only if the address is
* never referred to without dereferencing.
*
* scan will build a list of optimizable expressions which
* opt1 will replace during the second optimization pass.
*/
CSE *olist; /* list of optimizable expressions */
//
// equalnode will return 1 if the expressions pointed to by
// node1 and node2 are equivalent.
//
int equalnode(ENODE *node1, ENODE *node2)
{
if (node1 == NULL || node2 == NULL) {
return FALSE;
}
if (node1->nodetype != node2->nodetype) {
return FALSE;
}
switch (node1->nodetype) {
case en_fcon:
return (Float128::IsEqual(&node1->f128,&node2->f128));
// return (node1->f == node2->f);
case en_regvar:
case en_fpregvar:
case en_icon:
case en_labcon:
case en_classcon: // Check type ?
case en_autocon:
case en_autovcon:
case en_autofcon:
{
return (node1->i == node2->i);
}
case en_nacon:{
return (node1->sp->compare(*node2->sp)==0);
}
case en_cnacon:
return (node1->sp->compare(*node2->sp)==0);
default:
if( IsLValue(node1) && equalnode(node1->p[0], node2->p[0]) ) {
// if( equalnode(node1->p[0], node2->p[0]) )
return TRUE;
}
return FALSE;
}
}
//
// SearchCSEList will search the common expression table for an entry
// that matches the node passed and return a pointer to it.
//
static CSE *SearchCSEList(ENODE *node)
{
int cnt;
for (cnt = 0; cnt < csendx; cnt++) {
if( equalnode(node,CSETable[cnt].exp) )
return &CSETable[cnt];
}
return (CSE *)NULL;
}
/*
* copy the node passed into a new enode so it wont get
* corrupted during substitution.
*/
static ENODE *DuplicateEnode(ENODE *node)
{
ENODE *temp;
if( node == NULL )
return (ENODE *)NULL;
temp = allocEnode();
memcpy(temp,node,sizeof(ENODE)); // copy all the fields
return temp;
}
// InsertNodeIntoCSEList will enter a reference to an expression node into the
// common expression table. duse is a flag indicating whether or not
// this reference will be dereferenced.
CSE *InsertNodeIntoCSEList(ENODE *node, int duse)
{
CSE *csp;
if( (csp = SearchCSEList(node)) == NULL ) { /* add to tree */
if (csendx > 499)
throw new C64PException(ERR_CSETABLE,0x01);
csp = &CSETable[csendx];
csendx++;
csp->uses = loop_active;
csp->duses = (duse != 0) * loop_active;
csp->exp = DuplicateEnode(node);
csp->voidf = 0;
csp->reg = 0;
return csp;
}
(csp->uses) += loop_active;
if( duse )
(csp->duses) += loop_active;
return csp;
}
// Immediate constants have low priority.
// Even though their use might be high, they are given a low priority.
void DumpCSETable()
{
int nn;
CSE *csp;
dfs.printf("<CSETable>\n");
dfs.printf("N OD Uses DUses Void Reg Sym\n");
for (nn = 0; nn < csendx; nn++) {
csp = &CSETable[nn];
dfs.printf("%d: ", nn);
dfs.printf("%d ",OptimizationDesireability(csp));
dfs.printf("%d ",csp->uses);
dfs.printf("%d ",csp->duses);
dfs.printf("%d ",csp->voidf);
dfs.printf("%d ",csp->reg);
if (csp->exp && csp->exp->sym && csp->exp->sym->name)
dfs.printf("%s ",(char *)csp->exp->sym->name->c_str());
dfs.printf("\n");
}
dfs.printf("</CSETable>\n");
}
// voidauto2 searches the entire CSE list for auto dereferenced node which
// point to the passed node. There might be more than one LValue that matches.
// voidauto will void an auto dereference node which points to
// the same auto constant as node.
//
int voidauto2(ENODE *node)
{
int uses;
bool voided;
int cnt;
uses = 0;
voided = false;
for (cnt = 0; cnt < csendx; cnt++) {
if( IsLValue(CSETable[cnt].exp) && equalnode(node,CSETable[cnt].exp->p[0]) ) {
CSETable[cnt].voidf = 1;
voided = true;
uses += CSETable[cnt].uses;
}
}
return voided ? uses : -1;
}
/*
* scanexpr will scan the expression pointed to by node for optimizable
* subexpressions. when an optimizable expression is found it is entered
* into the tree. if a reference to an autocon node is scanned the
* corresponding auto dereferenced node will be voided. duse should be
* set if the expression will be dereferenced.
*/
static void scanexpr(ENODE *node, int duse)
{
CSE *csp, *csp1;
int first;
int nn;
if( node == NULL )
return;
switch( node->nodetype ) {
case en_fpregvar:
case en_regvar:
break;
case en_cnacon:
case en_clabcon:
case en_fcon:
case en_icon:
case en_labcon:
case en_nacon:
InsertNodeIntoCSEList(node,duse);
break;
case en_autofcon:
case en_autovcon:
case en_autocon:
case en_classcon:
case en_tempfpref:
case en_tempref:
csp1 = InsertNodeIntoCSEList(node,duse);
if ((nn = voidauto2(node)) > 0) {
csp1->duses += loop_active;
csp1->uses = csp1->duses + nn - loop_active;
}
break;
case en_ref32: case en_ref32u:
case en_b_ref:
case en_c_ref:
case en_h_ref:
case en_w_ref:
case en_ub_ref:
case en_uc_ref:
case en_uh_ref:
case en_uw_ref:
case en_flt_ref:
case en_dbl_ref:
case en_quad_ref:
case en_bfieldref:
case en_ubfieldref:
case en_cfieldref:
case en_ucfieldref:
case en_hfieldref:
case en_uhfieldref:
case en_wfieldref:
case en_uwfieldref:
case en_struct_ref:
case en_vector_ref:
// There is something wrong with the following code that causes
// it to remove zero extension conversion from a byte to a word.
if( node->p[0]->nodetype == en_autocon || node->p[0]->nodetype==en_autofcon
|| node->p[0]->nodetype == en_classcon || node->p[0]->nodetype==en_autovcon) {
first = (SearchCSEList(node)==NULL); // Detect if this is the first insert
csp = InsertNodeIntoCSEList(node,duse);
if (csp->voidf)
scanexpr(node->p[0], 1);
// take care: the non-derereferenced use of the autocon node may
// already be in the list. In this case, set voidf to 1
if (SearchCSEList(node->p[0]) != NULL) {
csp->voidf = 1;
scanexpr(node->p[0], 1);
}
else {
// if( csp->voidf )
// scanexpr(node->p[0],1);
if (first) {
///* look for register nodes */
//int i = 0;
//long j = node->p[0]->i;
//if ((node->p[0]->nodetype== en_regvar || node->p[0]->nodetype==en_bregvar) &&
// (j >= 11 && j < 18))
//{
// csp->voidf--; /* this is not in auto_lst */
// //csp->uses += 90 * (100 - i);
// //csp->duses += 30 * (100 - i);
// break;
//}
///* set voidf if the node is not in autolst */
//csp->voidf++;
//i = 0;
//while (i < autoptr) {
// if (autolst[i] == j) {
// csp->voidf--;
// break;
// }
// ++i;
//}
/*
* even if that item must not be put in a register,
* it is legal to put its address therein
*/
//if (csp->voidf)
// scanexpr(node->p[0], 1);
//}
//if( csp->voidf )
// scanexpr(node->p[0],1);
}
}
}
else
scanexpr(node->p[0],1);
break;
case en_cbc: case en_cubw:
case en_cbh: case en_cucw:
case en_cbw: case en_cuhw:
case en_cbu: case en_ccu: case en_chu:
case en_cubu: case en_cucu: case en_cuhu:
case en_cch:
case en_ccw:
case en_chw:
case en_uminus:
case en_abs:
case en_compl: case en_ainc:
case en_adec: case en_not:
case en_chk:
case en_i2d:
case en_i2q:
case en_d2i:
case en_q2i:
case en_s2q:
scanexpr(node->p[0],duse);
break;
case en_asadd: case en_assub:
case en_add: case en_sub:
scanexpr(node->p[0],duse);
scanexpr(node->p[1],duse);
break;
case en_mul: case en_mulu: case en_div: case en_udiv:
case en_shl: case en_shlu: case en_shr: case en_shru: case en_asr:
case en_mod: case en_umod: case en_and:
case en_or: case en_xor:
case en_lor: case en_land:
case en_eq: case en_ne:
case en_gt: case en_ge:
case en_lt: case en_le:
case en_ugt: case en_uge:
case en_ult: case en_ule:
case en_feq: case en_fne:
case en_flt: case en_fle:
case en_fgt: case en_fge:
case en_fdmul: case en_fddiv:
case en_fdadd: case en_fdsub:
case en_fadd: case en_fsub:
case en_fmul: case en_fdiv:
case en_veq: case en_vne:
case en_vlt: case en_vle:
case en_vgt: case en_vge:
case en_vadd: case en_vsub:
case en_vmul: case en_vdiv:
case en_vadds: case en_vsubs:
case en_vmuls: case en_vdivs:
case en_asmul: case en_asmulu:
case en_asdiv: case en_asdivu:
case en_asmod: case en_aslsh:
case en_asrsh:
case en_asand: case en_asxor: case en_asor:
case en_cond:
case en_void:
case en_list:
case en_aggregate:
scanexpr(node->p[0],0);
scanexpr(node->p[1],0);
break;
case en_assign:
scanexpr(node->p[0],0);
scanexpr(node->p[1],0);
break;
case en_fcall:
scanexpr(node->p[0],1);
scanexpr(node->p[1],0);
break;
default: dfs.printf("Uncoded node in scanexpr():%d\r\n", node->nodetype);
}
}
/*
* scan will gather all optimizable expressions into the expression
* list for a block of statements.
*/
void scan(Statement *block)
{
loop_active = 1;
while( block != NULL ) {
switch( block->stype ) {
case st_compound:
scan(block->prolog);
scan_compound(block);
scan(block->epilog);
break;
case st_check:
case st_return:
case st_throw:
case st_expr:
opt_const(&block->exp);
scanexpr(block->exp,0);
break;
case st_while:
case st_until:
case st_do:
case st_dountil:
loop_active++;
opt_const(&block->exp);
scanexpr(block->exp,0);
scan(block->s1);
loop_active--;
break;
case st_doloop:
case st_forever:
loop_active++;
scan(block->s1);
loop_active--;
break;
case st_for:
loop_active++;
opt_const(&block->initExpr);
scanexpr(block->initExpr,0);
opt_const(&block->exp);
scanexpr(block->exp,0);
scan(block->s1);
opt_const(&block->incrExpr);
scanexpr(block->incrExpr,0);
loop_active--;
break;
case st_if:
opt_const(&block->exp);
scanexpr(block->exp,0);
scan(block->s1);
scan(block->s2);
break;
case st_switch:
opt_const(&block->exp);
scanexpr(block->exp,0);
scan(block->s1);
break;
case st_firstcall:
case st_case:
case st_default:
scan(block->s1);
break;
//case st_spinlock:
// scan(block->s1);
// scan(block->s2);
// break;
// nothing to process for these statement
case st_break:
case st_continue:
case st_goto:
break;
default: ;// printf("Uncoded statement in scan():%d\r\n", block->stype);
}
block = block->next;
}
}
static void scan_compound(Statement *stmt)
{
SYM *sp;
sp = sp->GetPtr(stmt->ssyms.GetHead());
while (sp) {
if (sp->initexp) {
opt_const(&sp->initexp);
scanexpr(sp->initexp,0);
}
sp = sp->GetNextPtr();
}
scan(stmt->s1);
}
//
// Returns the desirability of optimization for a subexpression.
//
// Immediate constants have low priority because small constants
// can be directly encoded in the instruction. There's no value to
// placing them in registers.
/*
int OptimizationDesireability(CSE *csp)
{
if (csp->exp==nullptr)
return(0);
if( csp->voidf || (csp->exp->nodetype == en_icon &&
csp->exp->i < 32768 && csp->exp->i >= -32768))
return 0;
// added this line to disable register optimization of global variables.
// The compiler would assign a register to a global variable ignoring
// the fact that the value might change due to a subroutine call.
//
if (csp->exp->nodetype == en_nacon)
return 0;
if (csp->exp->isVolatile)
return 0;
if( IsLValue(csp->exp) )
return 2 * csp->uses;
return csp->uses;
}
*/
/*
* repexpr will replace all allocated references within an expression
* with tempref nodes.
*/
void repexpr(ENODE *node)
{
CSE *csp;
if( node == NULL )
return;
switch( node->nodetype ) {
case en_fcon:
case en_autofcon:
case en_tempfpref:
/*
if( (csp = SearchCSEList(node)) != NULL ) {
if( csp->reg > 0 ) {
node->nodetype = en_fpregvar;
node->i = csp->reg;
}
}
break;
*/
case en_icon:
case en_nacon:
case en_labcon:
case en_autovcon:
case en_autocon:
case en_classcon:
case en_cnacon:
case en_clabcon:
case en_tempref:
if( (csp = SearchCSEList(node)) != NULL ) {
if( csp->reg > 0 ) {
node->nodetype = en_regvar;
node->i = csp->reg;
}
}
break;
case en_ref32: case en_ref32u:
case en_b_ref:
case en_c_ref:
case en_h_ref:
case en_w_ref:
case en_ub_ref:
case en_uc_ref:
case en_uh_ref:
case en_uw_ref:
case en_bfieldref:
case en_ubfieldref:
case en_cfieldref:
case en_ucfieldref:
case en_hfieldref:
case en_uhfieldref:
case en_wfieldref:
case en_uwfieldref:
case en_struct_ref:
case en_vector_ref:
if( (csp = SearchCSEList(node)) != NULL ) {
if( csp->reg > 0 ) {
node->nodetype = en_regvar;
node->i = csp->reg;
}
else
repexpr(node->p[0]);
}
else
repexpr(node->p[0]);
break;
case en_dbl_ref:
case en_flt_ref:
case en_quad_ref:
if( (csp = SearchCSEList(node)) != NULL ) {
if( csp->reg > 0 ) {
node->nodetype = en_regvar;
node->i = csp->reg;
}
else
repexpr(node->p[0]);
}
else
repexpr(node->p[0]);
break;
case en_cbc: case en_cubw:
case en_cbh: case en_cucw:
case en_cbw: case en_cuhw:
case en_cbu: case en_ccu: case en_chu:
case en_cubu: case en_cucu: case en_cuhu:
case en_cch:
case en_ccw:
case en_chw:
case en_uminus:
case en_abs:
case en_not: case en_compl:
case en_ainc: case en_adec:
case en_chk:
case en_i2d:
case en_i2q:
case en_d2i:
case en_q2i:
case en_s2q:
repexpr(node->p[0]);
break;
case en_add: case en_sub:
case en_mul: case en_mulu: case en_div: case en_udiv:
case en_mod: case en_umod:
case en_shl: case en_shlu: case en_shru: case en_asr:
case en_shr:
case en_and:
case en_or: case en_xor:
case en_land: case en_lor:
case en_eq: case en_ne:
case en_lt: case en_le:
case en_gt: case en_ge:
case en_ult: case en_ule:
case en_ugt: case en_uge:
case en_feq: case en_fne:
case en_flt: case en_fle:
case en_fgt: case en_fge:
case en_fdmul: case en_fddiv:
case en_fdadd: case en_fdsub:
case en_fadd: case en_fsub:
case en_fmul: case en_fdiv:
case en_veq: case en_vne:
case en_vlt: case en_vle:
case en_vgt: case en_vge:
case en_vadd: case en_vsub:
case en_vmul: case en_vdiv:
case en_vadds: case en_vsubs:
case en_vmuls: case en_vdivs:
case en_cond: case en_void:
case en_asadd: case en_assub:
case en_asmul: case en_asmulu:
case en_asdiv: case en_asdivu:
case en_asor: case en_asand: case en_asxor:
case en_asmod: case en_aslsh:
case en_asrsh: case en_fcall:
case en_list: case en_aggregate:
case en_assign:
repexpr(node->p[0]);
repexpr(node->p[1]);
break;
case en_regvar:
case en_fpregvar:
break;
default:
dfs.printf("Uncoded node in repexr():%d\r\n",node->nodetype);
}
}
/*
* repcse will scan through a block of statements replacing the
* optimized expressions with their temporary references.
*/
void repcse(Statement *block)
{
while( block != NULL ) {
switch( block->stype ) {
case st_compound:
repcse(block->prolog);
repcse_compound(block);
repcse(block->epilog);
break;
case st_return:
case st_throw:
repexpr(block->exp);
break;
case st_check:
repexpr(block->exp);
break;
case st_expr:
repexpr(block->exp);
break;
case st_while:
case st_until:
case st_do:
case st_dountil:
repexpr(block->exp);
case st_doloop:
case st_forever:
repcse(block->s1);
repcse(block->s2);
break;
case st_for:
repexpr(block->initExpr);
repexpr(block->exp);
repcse(block->s1);
repexpr(block->incrExpr);
break;
case st_if:
repexpr(block->exp);
repcse(block->s1);
repcse(block->s2);
break;
case st_switch:
repexpr(block->exp);
repcse(block->s1);
break;
case st_try:
case st_catch:
case st_case:
case st_default:
case st_firstcall:
repcse(block->s1);
break;
}
block = block->next;
}
}
static void repcse_compound(Statement *stmt)
{
SYM *sp;
sp = sp->GetPtr(stmt->ssyms.GetHead());
while (sp) {
if (sp->initexp) {
repexpr(sp->initexp);
}
sp = sp->GetNextPtr();
}
repcse(stmt->s1);
}
/*
* opt1 is the externally callable optimization routine. it will
* collect and allocate common subexpressions and substitute the
* tempref for all occurrances of the expression within the block.
*
* optimizer is currently turned off...
*/
int opt1(Statement *block)
{
int nn;
csendx = 0;
nn = 0;
olist = (CSE *)NULL;
if (opt_noregs==FALSE) {
scan(block); /* collect expressions */
nn = AllocateRegisterVars();
repcse(block); /* replace allocated expressions */
}
return nn;
}
| [
"[email protected]"
] | |
91f0ebed8c6306550882f5e3fdb34855fed06d41 | dcc54530b7c7b380803029295ffe71585af525b3 | /Handy2D/src/SDLManager.cpp | 087903c2d255c767d45221271dc60775fb9cb5c3 | [
"MIT"
] | permissive | HadaHector/Handy2D | 17683faf0fc62cb9b4bafd3f0fc9b5f65e0e328e | 265b427e02879fef01d1e29338e5049b7dfe5cbe | refs/heads/master | 2020-04-13T08:50:01.931888 | 2020-01-04T12:22:19 | 2020-01-04T12:22:19 | 147,951,469 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,577 | cpp | #include "SDLManager.h"
#include <chrono>
#include <array>
#include <iostream>
#include "RenderLayer.h"
#include "Input.h"
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf.h"
#include "PaintedImage.h"
#include "Texture.h"
#include "Time.h"
#include "CollisionManager.h"
#include "SDL_mixer.h"
//#include "vld.h"
class SDLEventHandler
{
public:
static void Handle(const SDL_Event& Event)
{
switch (Event.type)
{
case SDL_KEYDOWN:
{
if (!Event.key.repeat)
{
int key = Event.key.keysym.scancode;
SToggleState& State = Input::GetButton(key);
State.active = true;
State.downtime = 0.0f;
State.pressed = true;
Input::m_aJustPressed.insert(key);
//std::cout << key << "\n";
}
}
break;
case SDL_KEYUP:
{
int key = Event.key.keysym.scancode;
SToggleState& State = Input::GetButton(key);
State.active = false;
State.released = true;
Input::m_aJustReleased.insert(key);
}
break;
case SDL_MOUSEMOTION:
Input::m_vMousePos.x = Event.motion.x;
Input::m_vMousePos.y = Event.motion.y;
break;
case SDL_MOUSEBUTTONDOWN:
{
int key = -1 * Event.button.button;
SToggleState& State = Input::GetButton(key);
State.active = true;
State.downtime = 0.0f;
State.pressed = true;
Input::m_aJustPressed.insert(key);
}
break;
case SDL_MOUSEBUTTONUP:
{
int key = -1 * Event.button.button;
SToggleState& State = Input::GetButton(key);
State.active = false;
State.released = true;
Input::m_aJustReleased.insert(key);
}
break;
case SDL_MOUSEWHEEL:
break;
case SDL_WINDOWEVENT:
if (Event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
{
SDLManager::GetGameLogic()->OnResize();
}
break;
default:
break;
}
}
};
SDLManager SDLManager::Instance;
int SDLManager::drawnum = 0;
int SDLManager::spritenum = 0;
unsigned char SDLManager::clearcolor[4] = { 0,0,0,0 };
SDL_Renderer* SDLManager::GetRenderer() { return m_pRenderer; }
void SDLManager::Start(SWindowParams params, CGameLogic* pGameLogic)
{
Instance.m_WindowParams = params;
Instance.m_pGameLogic = pGameLogic;
if (Instance.Init())
{
Instance.MainLoop();
}
}
void SDLManager::SetWindowSize(IntVec size)
{
SDL_SetWindowSize(Instance.m_pWindow, size.x, size.y);
}
void SDLManager::SetWindowMinSize(IntVec size)
{
SDL_SetWindowMinimumSize(Instance.m_pWindow, size.x, size.y);
}
void SDLManager::SetWindowMaxSize(IntVec size)
{
SDL_SetWindowMaximumSize(Instance.m_pWindow, size.x, size.y);
}
void SDLManager::SetClearColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
{
SDL_SetRenderDrawColor(Instance.m_pRenderer, r, g, b, a);
}
CGameLogic* SDLManager::GetGameLogic()
{
return Instance.m_pGameLogic;
}
bool SDLManager::Init()
{
try
{
if (SDL_Init(SDL_INIT_VIDEO) < 0) throw std::runtime_error("SDL could not initialize!");
Uint32 flags = SDL_WINDOW_SHOWN;
if (m_WindowParams.bFullscreen) flags = flags | SDL_WINDOW_FULLSCREEN;
if (m_WindowParams.bBorderless) flags = flags | SDL_WINDOW_BORDERLESS;
if (m_WindowParams.bMaximized) flags = flags | SDL_WINDOW_MAXIMIZED;
if (m_WindowParams.bMinimized) flags = flags | SDL_WINDOW_MINIMIZED;
if (m_WindowParams.bResizeAble) flags = flags | SDL_WINDOW_RESIZABLE;
m_pWindow = SDL_CreateWindow(m_WindowParams.sTitle.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, m_WindowParams.nWidth, m_WindowParams.nHeight, flags);
if (m_pWindow == NULL)
{
std::string error = "Window could not be created! error:";
error += SDL_GetError();
throw std::runtime_error(error);
}
m_pRenderer = SDL_CreateRenderer(m_pWindow, -1, SDL_RENDERER_ACCELERATED);
if (m_pRenderer == NULL)
{
std::string error = "Renderer could not be created! error:";
error += SDL_GetError();
throw std::runtime_error(error);
}
SDL_SetRenderDrawColor(m_pRenderer, 0xFF, 0xFF, 0xFF, 0xFF);
int imgFlags = IMG_INIT_PNG;
if (!(IMG_Init(imgFlags) & imgFlags))
{
std::string error = "SDL_image could not initialize! error:";
error += IMG_GetError();
throw std::runtime_error(error);
}
if (TTF_Init() == -1)
{
std::string error = "TTF init error! error:";
error += TTF_GetError();
throw std::runtime_error(error);
}
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096) == -1)
{
return false;
}
if (!LoadMedia()) throw std::runtime_error("Failed to load media!");
}
catch (std::runtime_error e)
{
std::cout << e.what() << "\n";
return false;
}
/*
std::array<int, 800> aHeights;
for (int x = 0; x < 800; ++x)
{
aHeights[x] = (int)( 250 + sin(x / (double)50) * 120);
}
m_pGenerated = new PaintedImage(800, 600);
m_pGenerated->Fill([aHeights](int x, int y) -> int {
return y < aHeights[x] ? 0x22ff44ff : 0x77bbffff;
});
*/
return true;
}
bool SDLManager::LoadMedia()
{ //Loading success flag
bool success = true;
/* default font is deprecated
m_pDefaultFont = TTF_OpenFont("arial.ttf", 18);
if (m_pDefaultFont == nullptr)
{
printf("Failed to load lazy font! SDL_ttf Error: %s\n", TTF_GetError());
success = false;
}
*/
success &= m_pGameLogic->Load();
return success;
}
void SDLManager::Close()
{
//delete layers
for (auto& Layer : m_aRenderLayers)
{
delete(Layer);
}
m_aRenderLayers.clear();
//unload all image
CTexture::UnloadTextures();
SDL_DestroyRenderer(m_pRenderer);
m_pRenderer = nullptr;
SDL_DestroyWindow(m_pWindow);
m_pWindow = nullptr;
delete(m_pGameLogic);
m_pGameLogic = nullptr;
//Quit SDL subsystems
TTF_Quit();
IMG_Quit();
Mix_Quit();
SDL_Quit();
}
void SDLManager::MainLoop()
{
Time::Init();
while (m_bRunning)
{
Time::FrameBegin();
SDL_Event e;
//Handle events on queue
while (SDL_PollEvent(&e) != 0)
{
//User requests quit
if (e.type == SDL_QUIT)
{
m_bRunning = false;
}
SDLEventHandler::Handle(e);
}
m_bRunning &= m_pGameLogic->m_bRunning;
RunFrame();
Time::FrameEnd();
Input::Update();
}
Time::Close();
Close();
}
void SDLManager::RunFrame()
{
m_pGameLogic->Update();
CCollisionManager::Collide();
drawnum = 0;
SDL_SetRenderDrawColor(m_pRenderer, clearcolor[0], clearcolor[1], clearcolor[2], clearcolor[3]);
SDL_RenderClear(m_pRenderer);
for (auto&& Layer : m_aRenderLayers)
{
Layer->Render();
Layer->HandleEvents();
}
SDL_RenderPresent(m_pRenderer);
}
IntVec SDLManager::GetSize()
{
IntVec size;
SDL_GetWindowSize(Instance.m_pWindow, &size.x, &size.y);
return size;
}
void SDLManager::AddLayer(CRenderLayer * pLayer)
{
m_aRenderLayers.push_back(pLayer);
}
| [
"[email protected]"
] | |
0388175da9943f03c03df50c21e9a996bb1120c7 | 4a28104787a4ce3bf362fda9182e4f1fe6276c30 | /codeforces Ladders/Level 3/151A.cpp | e82a4a480ab304bed4be7afea47b28a35a23aa74 | [] | no_license | Ason4901/geeksforgeeks | d0538a22db00c86e97ec8b9f6c548ebd1ecef8ce | 777aa4c0752bb0a9b942922e1ad99095a161cc6b | refs/heads/master | 2023-02-24T07:51:15.469015 | 2021-01-30T15:36:20 | 2021-01-30T15:36:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 780 | cpp | //A. Soft Drinking
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
using namespace std;
int main()
{
std::ios::sync_with_stdio(false);
int n, k, l , c, d, p, nl, np;
cin>>n>>k>>l>>c>>d>>p>>nl>>np;
int mm = (k * l) / nl;
int ll = c * d;
int pp = p / np;
cout<<min(mm, min(ll,pp))/n<<endl;
return 0;
}
| [
"[email protected]"
] | |
149cbd4744e8c3c78866b7b920829ddd19a65d63 | 44289ecb892b6f3df043bab40142cf8530ac2ba4 | /Sources/Elastos/Packages/Apps/Dialer/inc/elastos/droid/dialer/list/CRemoveView.h | a0919b21fafa63e08cd1d8c9156f4df8934a788e | [
"Apache-2.0"
] | permissive | warrenween/Elastos | a6ef68d8fb699fd67234f376b171c1b57235ed02 | 5618eede26d464bdf739f9244344e3e87118d7fe | refs/heads/master | 2021-01-01T04:07:12.833674 | 2017-06-17T15:34:33 | 2017-06-17T15:34:33 | 97,120,576 | 2 | 1 | null | 2017-07-13T12:33:20 | 2017-07-13T12:33:20 | null | UTF-8 | C++ | false | false | 1,232 | h | //=========================================================================
// Copyright (C) 2012 The Elastos Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//=========================================================================
#ifndef __ELASTOS_DROID_DIALER_LIST_CREMOVEVIEW_H__
#define __ELASTOS_DROID_DIALER_LIST_CREMOVEVIEW_H__
#include "_Elastos_Droid_Dialer_List_CRemoveView.h"
#include "elastos/droid/dialer/list/RemoveView.h"
namespace Elastos {
namespace Droid {
namespace Dialer {
namespace List {
CarClass(CRemoveView)
, public RemoveView
{
public:
CAR_OBJECT_DECL();
};
} // List
} // Dialer
} // Droid
} // Elastos
#endif //__ELASTOS_DROID_DIALER_LIST_CREMOVEVIEW_H__
| [
"[email protected]"
] | |
59db8cdb778dd88c082b57bdb8b1b33e6002b1a8 | 82c4f8be9dd4e38ec7b50d14fbdfd93f5bd878f0 | /champ_config/include/quadruped_description.h | b22fc86b7c8d1fe9c61de7029937017a2c62db5d | [] | permissive | chvmp/champ | 8489c9882f551c3e139201c1ae5932248e866b77 | cf71f39a550798c003376e54c9ab1cc7f8068bd6 | refs/heads/master | 2023-05-12T23:52:46.689934 | 2022-08-15T08:17:43 | 2022-08-15T08:17:43 | 186,157,988 | 1,274 | 308 | BSD-3-Clause | 2023-05-02T14:59:08 | 2019-05-11T16:44:17 | C++ | UTF-8 | C++ | false | false | 1,235 | h | #ifndef QUADRUPED_DESCRIPTION_H
#define QUADRUPED_DESCRIPTION_H
#include <quadruped_base/quadruped_base.h>
namespace champ
{
namespace URDF
{
void loadFromHeader(champ::QuadrupedBase &base)
{
base.lf.hip.setOrigin(0.175, 0.105, 0, 0, 0, 0);
base.lf.upper_leg.setOrigin(0, 0.06, 0, 0, 0, 0);
base.lf.lower_leg.setOrigin(0, 0, -0.141, 0, 0, 0);
base.lf.foot.setOrigin(0, 0, -0.141, 0, 0, 0);
base.rf.hip.setOrigin(0.175, -0.105, 0, 0, 0, 0);
base.rf.upper_leg.setOrigin(0, -0.06, 0, 0, 0, 0);
base.rf.lower_leg.setOrigin(0, 0, -0.141, 0, 0, 0);
base.rf.foot.setOrigin(0, 0, -0.141, 0, 0, 0);
base.lh.hip.setOrigin(-0.175, 0.105, 0, 0, 0, 0);
base.lh.upper_leg.setOrigin(0, 0.06, 0, 0, 0, 0);
base.lh.lower_leg.setOrigin(0, 0, -0.141, 0, 0, 0);
base.lh.foot.setOrigin(0, 0, -0.141, 0, 0, 0);
base.rh.hip.setOrigin(-0.175, -0.105, 0, 0, 0, 0);
base.rh.upper_leg.setOrigin(0, -0.06, 0, 0, 0, 0);
base.rh.lower_leg.setOrigin(0, 0, -0.141, 0, 0, 0);
base.rh.foot.setOrigin(0, 0, -0.141, 0, 0, 0);
}
}
}
#endif | [
"[email protected]"
] | |
b8f6817b969f60a6c4a60f72c51f800094c00398 | 43aa6c8707e4307dd4d41a70cc79c1560bc77fca | /oldskool/fridge_level/kriek.hpp | 57b586eb6247d4e433526ba2fec7d43560b06189 | [] | no_license | IMULMUL/stuffz | 5640ac70f0069042bf58737fd85f051ed42db172 | f5941bac060a8fb4cb66e605000d3bd706875458 | refs/heads/master | 2022-12-22T16:26:48.636866 | 2022-12-18T00:44:39 | 2022-12-18T00:44:39 | 202,901,822 | 0 | 0 | null | 2022-12-18T08:40:00 | 2019-08-17T15:55:00 | C | UTF-8 | C++ | false | false | 313 | hpp | #ifndef KRIEK_HPP
#define KRIEK_HPP
#include "beer.hpp"
class Kriek : public Beer
{
public:
explicit Kriek();
explicit Kriek(char* name);
~Kriek();
std::string get_type();
private:
unsigned int alcohol_percentage;
unsigned int bla;
};
#endif
| [
"[email protected]"
] | |
18956c1cf380b7ab64a3b37b20d8657867c24848 | 6fac50aa19020566f2e01595a6a0632a42ba3da3 | /UVA/350.cpp | 7e4e7737d0a29e5046df08ce16547321d1393275 | [] | no_license | sayemimtiaz/competitive-programming | c36905ee99b1cfeb578c2b47367eff901a5e444f | 58ff86e0d3804bd072d733e5fa491d6c192e4345 | refs/heads/master | 2023-01-27T14:47:06.767566 | 2023-01-08T21:50:49 | 2023-01-08T21:50:49 | 36,745,247 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 394 | cpp | #include<stdio.h>
#include<math.h>
int main()
{
long double z,i,m,l,count,p,c,k;
c=1;
while(1)
{
scanf("%Lf %Lf %Lf %Lf",&z,&i,&m,&l);
if(z==0&&i==0&&l==0&&m==0)
break;
count=0;
while(1)
{
p=(z*l)+i;
p=fmodl(p,m);
if(count==0)
k=p;
else if(p==k)
break;
count++;
l=p;
}
printf("Case %0.Lf: %0.Lf\n",c,count);
c++;
}
return 0;
} | [
"[email protected]"
] | |
e9d21255f30e45b032aeb2e24a0dfa5b591de7c9 | 00b7e7e932c5b714e6288f13ef0b1e56a471dd93 | /arduino uwu/wave.ino | 90e95bc2bd0e213c41c1d2f9dbbb7d3a1235ed76 | [] | no_license | th3arsene/code | ab26d41a99dcca0cbf27b08fe991893db912fb51 | 6fd6be238d79e879a6ae82e6fdb1b8deb630cfc0 | refs/heads/master | 2020-04-08T19:52:52.250312 | 2018-11-30T14:35:15 | 2018-11-30T14:35:15 | 159,674,703 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 689 | ino | const int rLed1 = 2;
const int rLed2 = 6;
const int rLed3 = 5;
const int rLed4 = 4;
const int rLed5 = 3;
void setup()
{
pinMode(rLed1, OUTPUT);
pinMode(rLed2, OUTPUT);
pinMode(rLed3, OUTPUT);
pinMode(rLed4, OUTPUT);
pinMode(rLed5, OUTPUT);
}
void loop()
{
digitalWrite(rLed1, HIGH); 0
digitalWrite(rLed2, HIGH);
delay(100);
digitalWrite(rLed1, LOW);
digitalWrite(rLed3, HIGH);
delay(100);
digitalWrite(rLed2, LOW);
digitalWrite(rLed4, HIGH);
delay(100);
digitalWrite(rLed3, LOW);
digitalWrite(rLed5, HIGH);
delay(100);
digitalWrite(rLed4, LOW);
digitalWrite(rLed5, LOW);
}
| [
"[email protected]"
] | |
fc6b39cd24a70d6ae70b3d020f9f89f24f85bcc9 | 062715f71bd2fa347d0591ebc2b6c178cb227a95 | /src/bitcoin-tx.cpp | 32ab8cc28bb4a7b72c02c0902e8e374eabfab352 | [
"MIT"
] | permissive | minblock/vickcoin | 5fad9bb523419689d4dc81f16e7ed597e9509d68 | 21c95da576d321ca9ef6b771255528e10a1d8db6 | refs/heads/master | 2021-05-22T14:35:12.960456 | 2020-04-04T10:12:11 | 2020-04-04T10:12:11 | 252,964,490 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 28,922 | cpp | // Copyright (c) 2009-2016 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#if defined(HAVE_CONFIG_H)
#include "config/bitcoin-config.h"
#endif
#include "base58.h"
#include "clientversion.h"
#include "coins.h"
#include "consensus/consensus.h"
#include "core_io.h"
#include "keystore.h"
#include "policy/policy.h"
#include "primitives/transaction.h"
#include "script/script.h"
#include "script/sign.h"
#include <univalue.h>
#include "util.h"
#include "utilmoneystr.h"
#include "utilstrencodings.h"
#include <stdio.h>
#include <boost/algorithm/string.hpp>
#include <boost/assign/list_of.hpp>
static bool fCreateBlank;
static std::map<std::string,UniValue> registers;
static const int CONTINUE_EXECUTION=-1;
//
// This function returns either one of EXIT_ codes when it's expected to stop the process or
// CONTINUE_EXECUTION when it's expected to continue further.
//
static int AppInitRawTx(int argc, char* argv[])
{
//
// Parameters
//
ParseParameters(argc, argv);
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
try {
SelectParams(ChainNameFromCommandLine());
} catch (const std::exception& e) {
fprintf(stderr, "Error: %s\n", e.what());
return EXIT_FAILURE;
}
fCreateBlank = GetBoolArg("-create", false);
if (argc<2 || IsArgSet("-?") || IsArgSet("-h") || IsArgSet("-help"))
{
// First part of help message is specific to this utility
std::string strUsage = strprintf(_("%s vickcoin-tx utility version"), _(PACKAGE_NAME)) + " " + FormatFullVersion() + "\n\n" +
_("Usage:") + "\n" +
" vickcoin-tx [options] <hex-tx> [commands] " + _("Update hex-encoded vickcoin transaction") + "\n" +
" vickcoin-tx [options] -create [commands] " + _("Create hex-encoded vickcoin transaction") + "\n" +
"\n";
fprintf(stdout, "%s", strUsage.c_str());
strUsage = HelpMessageGroup(_("Options:"));
strUsage += HelpMessageOpt("-?", _("This help message"));
strUsage += HelpMessageOpt("-create", _("Create new, empty TX."));
strUsage += HelpMessageOpt("-json", _("Select JSON output"));
strUsage += HelpMessageOpt("-txid", _("Output only the hex-encoded transaction id of the resultant transaction."));
AppendParamsHelpMessages(strUsage);
fprintf(stdout, "%s", strUsage.c_str());
strUsage = HelpMessageGroup(_("Commands:"));
strUsage += HelpMessageOpt("delin=N", _("Delete input N from TX"));
strUsage += HelpMessageOpt("delout=N", _("Delete output N from TX"));
strUsage += HelpMessageOpt("in=TXID:VOUT(:SEQUENCE_NUMBER)", _("Add input to TX"));
strUsage += HelpMessageOpt("locktime=N", _("Set TX lock time to N"));
strUsage += HelpMessageOpt("nversion=N", _("Set TX version to N"));
strUsage += HelpMessageOpt("outaddr=VALUE:ADDRESS", _("Add address-based output to TX"));
strUsage += HelpMessageOpt("outpubkey=VALUE:PUBKEY[:FLAGS]", _("Add pay-to-pubkey output to TX") + ". " +
_("Optionally add the \"W\" flag to produce a pay-to-witness-pubkey-hash output") + ". " +
_("Optionally add the \"S\" flag to wrap the output in a pay-to-script-hash."));
strUsage += HelpMessageOpt("outdata=[VALUE:]DATA", _("Add data-based output to TX"));
strUsage += HelpMessageOpt("outscript=VALUE:SCRIPT[:FLAGS]", _("Add raw script output to TX") + ". " +
_("Optionally add the \"W\" flag to produce a pay-to-witness-script-hash output") + ". " +
_("Optionally add the \"S\" flag to wrap the output in a pay-to-script-hash."));
strUsage += HelpMessageOpt("outmultisig=VALUE:REQUIRED:PUBKEYS:PUBKEY1:PUBKEY2:....[:FLAGS]", _("Add Pay To n-of-m Multi-sig output to TX. n = REQUIRED, m = PUBKEYS") + ". " +
_("Optionally add the \"W\" flag to produce a pay-to-witness-script-hash output") + ". " +
_("Optionally add the \"S\" flag to wrap the output in a pay-to-script-hash."));
strUsage += HelpMessageOpt("sign=SIGHASH-FLAGS", _("Add zero or more signatures to transaction") + ". " +
_("This command requires JSON registers:") +
_("prevtxs=JSON object") + ", " +
_("privatekeys=JSON object") + ". " +
_("See signrawtransaction docs for format of sighash flags, JSON objects."));
fprintf(stdout, "%s", strUsage.c_str());
strUsage = HelpMessageGroup(_("Register Commands:"));
strUsage += HelpMessageOpt("load=NAME:FILENAME", _("Load JSON file FILENAME into register NAME"));
strUsage += HelpMessageOpt("set=NAME:JSON-STRING", _("Set register NAME to given JSON-STRING"));
fprintf(stdout, "%s", strUsage.c_str());
if (argc < 2) {
fprintf(stderr, "Error: too few parameters\n");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
return CONTINUE_EXECUTION;
}
static void RegisterSetJson(const std::string& key, const std::string& rawJson)
{
UniValue val;
if (!val.read(rawJson)) {
std::string strErr = "Cannot parse JSON for key " + key;
throw std::runtime_error(strErr);
}
registers[key] = val;
}
static void RegisterSet(const std::string& strInput)
{
// separate NAME:VALUE in string
size_t pos = strInput.find(':');
if ((pos == std::string::npos) ||
(pos == 0) ||
(pos == (strInput.size() - 1)))
throw std::runtime_error("Register input requires NAME:VALUE");
std::string key = strInput.substr(0, pos);
std::string valStr = strInput.substr(pos + 1, std::string::npos);
RegisterSetJson(key, valStr);
}
static void RegisterLoad(const std::string& strInput)
{
// separate NAME:FILENAME in string
size_t pos = strInput.find(':');
if ((pos == std::string::npos) ||
(pos == 0) ||
(pos == (strInput.size() - 1)))
throw std::runtime_error("Register load requires NAME:FILENAME");
std::string key = strInput.substr(0, pos);
std::string filename = strInput.substr(pos + 1, std::string::npos);
FILE *f = fopen(filename.c_str(), "r");
if (!f) {
std::string strErr = "Cannot open file " + filename;
throw std::runtime_error(strErr);
}
// load file chunks into one big buffer
std::string valStr;
while ((!feof(f)) && (!ferror(f))) {
char buf[4096];
int bread = fread(buf, 1, sizeof(buf), f);
if (bread <= 0)
break;
valStr.insert(valStr.size(), buf, bread);
}
int error = ferror(f);
fclose(f);
if (error) {
std::string strErr = "Error reading file " + filename;
throw std::runtime_error(strErr);
}
// evaluate as JSON buffer register
RegisterSetJson(key, valStr);
}
static CAmount ExtractAndValidateValue(const std::string& strValue)
{
CAmount value;
if (!ParseMoney(strValue, value))
throw std::runtime_error("invalid TX output value");
return value;
}
static void MutateTxVersion(CMutableTransaction& tx, const std::string& cmdVal)
{
int64_t newVersion = atoi64(cmdVal);
if (newVersion < 1 || newVersion > CTransaction::MAX_STANDARD_VERSION)
throw std::runtime_error("Invalid TX version requested");
tx.nVersion = (int) newVersion;
}
static void MutateTxLocktime(CMutableTransaction& tx, const std::string& cmdVal)
{
int64_t newLocktime = atoi64(cmdVal);
if (newLocktime < 0LL || newLocktime > 0xffffffffLL)
throw std::runtime_error("Invalid TX locktime requested");
tx.nLockTime = (unsigned int) newLocktime;
}
static void MutateTxAddInput(CMutableTransaction& tx, const std::string& strInput)
{
std::vector<std::string> vStrInputParts;
boost::split(vStrInputParts, strInput, boost::is_any_of(":"));
// separate TXID:VOUT in string
if (vStrInputParts.size()<2)
throw std::runtime_error("TX input missing separator");
// extract and validate TXID
std::string strTxid = vStrInputParts[0];
if ((strTxid.size() != 64) || !IsHex(strTxid))
throw std::runtime_error("invalid TX input txid");
uint256 txid(uint256S(strTxid));
static const unsigned int minTxOutSz = 9;
static const unsigned int maxVout = MAX_BLOCK_BASE_SIZE / minTxOutSz;
// extract and validate vout
std::string strVout = vStrInputParts[1];
int vout = atoi(strVout);
if ((vout < 0) || (vout > (int)maxVout))
throw std::runtime_error("invalid TX input vout");
// extract the optional sequence number
uint32_t nSequenceIn=std::numeric_limits<unsigned int>::max();
if (vStrInputParts.size() > 2)
nSequenceIn = std::stoul(vStrInputParts[2]);
// append to transaction input list
CTxIn txin(txid, vout, CScript(), nSequenceIn);
tx.vin.push_back(txin);
}
static void MutateTxAddOutAddr(CMutableTransaction& tx, const std::string& strInput)
{
// Separate into VALUE:ADDRESS
std::vector<std::string> vStrInputParts;
boost::split(vStrInputParts, strInput, boost::is_any_of(":"));
if (vStrInputParts.size() != 2)
throw std::runtime_error("TX output missing or too many separators");
// Extract and validate VALUE
CAmount value = ExtractAndValidateValue(vStrInputParts[0]);
// extract and validate ADDRESS
std::string strAddr = vStrInputParts[1];
CBitcoinAddress addr(strAddr);
if (!addr.IsValid())
throw std::runtime_error("invalid TX output address");
// build standard output script via GetScriptForDestination()
CScript scriptPubKey = GetScriptForDestination(addr.Get());
// construct TxOut, append to transaction output list
CTxOut txout(value, scriptPubKey);
tx.vout.push_back(txout);
}
static void MutateTxAddOutPubKey(CMutableTransaction& tx, const std::string& strInput)
{
// Separate into VALUE:PUBKEY[:FLAGS]
std::vector<std::string> vStrInputParts;
boost::split(vStrInputParts, strInput, boost::is_any_of(":"));
if (vStrInputParts.size() < 2 || vStrInputParts.size() > 3)
throw std::runtime_error("TX output missing or too many separators");
// Extract and validate VALUE
CAmount value = ExtractAndValidateValue(vStrInputParts[0]);
// Extract and validate PUBKEY
CPubKey pubkey(ParseHex(vStrInputParts[1]));
if (!pubkey.IsFullyValid())
throw std::runtime_error("invalid TX output pubkey");
CScript scriptPubKey = GetScriptForRawPubKey(pubkey);
CBitcoinAddress addr(scriptPubKey);
// Extract and validate FLAGS
bool bSegWit = false;
bool bScriptHash = false;
if (vStrInputParts.size() == 3) {
std::string flags = vStrInputParts[2];
bSegWit = (flags.find("W") != std::string::npos);
bScriptHash = (flags.find("S") != std::string::npos);
}
if (bSegWit) {
// Call GetScriptForWitness() to build a P2WSH scriptPubKey
scriptPubKey = GetScriptForWitness(scriptPubKey);
}
if (bScriptHash) {
// Get the address for the redeem script, then call
// GetScriptForDestination() to construct a P2SH scriptPubKey.
CBitcoinAddress redeemScriptAddr(scriptPubKey);
scriptPubKey = GetScriptForDestination(redeemScriptAddr.Get());
}
// construct TxOut, append to transaction output list
CTxOut txout(value, scriptPubKey);
tx.vout.push_back(txout);
}
static void MutateTxAddOutMultiSig(CMutableTransaction& tx, const std::string& strInput)
{
// Separate into VALUE:REQUIRED:NUMKEYS:PUBKEY1:PUBKEY2:....[:FLAGS]
std::vector<std::string> vStrInputParts;
boost::split(vStrInputParts, strInput, boost::is_any_of(":"));
// Check that there are enough parameters
if (vStrInputParts.size()<3)
throw std::runtime_error("Not enough multisig parameters");
// Extract and validate VALUE
CAmount value = ExtractAndValidateValue(vStrInputParts[0]);
// Extract REQUIRED
uint32_t required = stoul(vStrInputParts[1]);
// Extract NUMKEYS
uint32_t numkeys = stoul(vStrInputParts[2]);
// Validate there are the correct number of pubkeys
if (vStrInputParts.size() < numkeys + 3)
throw std::runtime_error("incorrect number of multisig pubkeys");
if (required < 1 || required > 20 || numkeys < 1 || numkeys > 20 || numkeys < required)
throw std::runtime_error("multisig parameter mismatch. Required " \
+ std::to_string(required) + " of " + std::to_string(numkeys) + "signatures.");
// extract and validate PUBKEYs
std::vector<CPubKey> pubkeys;
for(int pos = 1; pos <= int(numkeys); pos++) {
CPubKey pubkey(ParseHex(vStrInputParts[pos + 2]));
if (!pubkey.IsFullyValid())
throw std::runtime_error("invalid TX output pubkey");
pubkeys.push_back(pubkey);
}
// Extract FLAGS
bool bSegWit = false;
bool bScriptHash = false;
if (vStrInputParts.size() == numkeys + 4) {
std::string flags = vStrInputParts.back();
bSegWit = (flags.find("W") != std::string::npos);
bScriptHash = (flags.find("S") != std::string::npos);
}
else if (vStrInputParts.size() > numkeys + 4) {
// Validate that there were no more parameters passed
throw std::runtime_error("Too many parameters");
}
CScript scriptPubKey = GetScriptForMultisig(required, pubkeys);
if (bSegWit) {
// Call GetScriptForWitness() to build a P2WSH scriptPubKey
scriptPubKey = GetScriptForWitness(scriptPubKey);
}
if (bScriptHash) {
// Get the address for the redeem script, then call
// GetScriptForDestination() to construct a P2SH scriptPubKey.
CBitcoinAddress addr(scriptPubKey);
scriptPubKey = GetScriptForDestination(addr.Get());
}
// construct TxOut, append to transaction output list
CTxOut txout(value, scriptPubKey);
tx.vout.push_back(txout);
}
static void MutateTxAddOutData(CMutableTransaction& tx, const std::string& strInput)
{
CAmount value = 0;
// separate [VALUE:]DATA in string
size_t pos = strInput.find(':');
if (pos==0)
throw std::runtime_error("TX output value not specified");
if (pos != std::string::npos) {
// Extract and validate VALUE
value = ExtractAndValidateValue(strInput.substr(0, pos));
}
// extract and validate DATA
std::string strData = strInput.substr(pos + 1, std::string::npos);
if (!IsHex(strData))
throw std::runtime_error("invalid TX output data");
std::vector<unsigned char> data = ParseHex(strData);
CTxOut txout(value, CScript() << OP_RETURN << data);
tx.vout.push_back(txout);
}
static void MutateTxAddOutScript(CMutableTransaction& tx, const std::string& strInput)
{
// separate VALUE:SCRIPT[:FLAGS]
std::vector<std::string> vStrInputParts;
boost::split(vStrInputParts, strInput, boost::is_any_of(":"));
if (vStrInputParts.size() < 2)
throw std::runtime_error("TX output missing separator");
// Extract and validate VALUE
CAmount value = ExtractAndValidateValue(vStrInputParts[0]);
// extract and validate script
std::string strScript = vStrInputParts[1];
CScript scriptPubKey = ParseScript(strScript);
// Extract FLAGS
bool bSegWit = false;
bool bScriptHash = false;
if (vStrInputParts.size() == 3) {
std::string flags = vStrInputParts.back();
bSegWit = (flags.find("W") != std::string::npos);
bScriptHash = (flags.find("S") != std::string::npos);
}
if (bSegWit) {
scriptPubKey = GetScriptForWitness(scriptPubKey);
}
if (bScriptHash) {
CBitcoinAddress addr(scriptPubKey);
scriptPubKey = GetScriptForDestination(addr.Get());
}
// construct TxOut, append to transaction output list
CTxOut txout(value, scriptPubKey);
tx.vout.push_back(txout);
}
static void MutateTxDelInput(CMutableTransaction& tx, const std::string& strInIdx)
{
// parse requested deletion index
int inIdx = atoi(strInIdx);
if (inIdx < 0 || inIdx >= (int)tx.vin.size()) {
std::string strErr = "Invalid TX input index '" + strInIdx + "'";
throw std::runtime_error(strErr.c_str());
}
// delete input from transaction
tx.vin.erase(tx.vin.begin() + inIdx);
}
static void MutateTxDelOutput(CMutableTransaction& tx, const std::string& strOutIdx)
{
// parse requested deletion index
int outIdx = atoi(strOutIdx);
if (outIdx < 0 || outIdx >= (int)tx.vout.size()) {
std::string strErr = "Invalid TX output index '" + strOutIdx + "'";
throw std::runtime_error(strErr.c_str());
}
// delete output from transaction
tx.vout.erase(tx.vout.begin() + outIdx);
}
static const unsigned int N_SIGHASH_OPTS = 6;
static const struct {
const char *flagStr;
int flags;
} sighashOptions[N_SIGHASH_OPTS] = {
{"ALL", SIGHASH_ALL},
{"NONE", SIGHASH_NONE},
{"SINGLE", SIGHASH_SINGLE},
{"ALL|ANYONECANPAY", SIGHASH_ALL|SIGHASH_ANYONECANPAY},
{"NONE|ANYONECANPAY", SIGHASH_NONE|SIGHASH_ANYONECANPAY},
{"SINGLE|ANYONECANPAY", SIGHASH_SINGLE|SIGHASH_ANYONECANPAY},
};
static bool findSighashFlags(int& flags, const std::string& flagStr)
{
flags = 0;
for (unsigned int i = 0; i < N_SIGHASH_OPTS; i++) {
if (flagStr == sighashOptions[i].flagStr) {
flags = sighashOptions[i].flags;
return true;
}
}
return false;
}
uint256 ParseHashUO(std::map<std::string,UniValue>& o, std::string strKey)
{
if (!o.count(strKey))
return uint256();
return ParseHashUV(o[strKey], strKey);
}
std::vector<unsigned char> ParseHexUO(std::map<std::string,UniValue>& o, std::string strKey)
{
if (!o.count(strKey)) {
std::vector<unsigned char> emptyVec;
return emptyVec;
}
return ParseHexUV(o[strKey], strKey);
}
static CAmount AmountFromValue(const UniValue& value)
{
if (!value.isNum() && !value.isStr())
throw std::runtime_error("Amount is not a number or string");
CAmount amount;
if (!ParseFixedPoint(value.getValStr(), 8, &amount))
throw std::runtime_error("Invalid amount");
if (!MoneyRange(amount))
throw std::runtime_error("Amount out of range");
return amount;
}
static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
{
int nHashType = SIGHASH_ALL;
if (flagStr.size() > 0)
if (!findSighashFlags(nHashType, flagStr))
throw std::runtime_error("unknown sighash flag/sign option");
std::vector<CTransaction> txVariants;
txVariants.push_back(tx);
// mergedTx will end up with all the signatures; it
// starts as a clone of the raw tx:
CMutableTransaction mergedTx(txVariants[0]);
bool fComplete = true;
CCoinsView viewDummy;
CCoinsViewCache view(&viewDummy);
if (!registers.count("privatekeys"))
throw std::runtime_error("privatekeys register variable must be set.");
CBasicKeyStore tempKeystore;
UniValue keysObj = registers["privatekeys"];
for (unsigned int kidx = 0; kidx < keysObj.size(); kidx++) {
if (!keysObj[kidx].isStr())
throw std::runtime_error("privatekey not a std::string");
CBitcoinSecret vchSecret;
bool fGood = vchSecret.SetString(keysObj[kidx].getValStr());
if (!fGood)
throw std::runtime_error("privatekey not valid");
CKey key = vchSecret.GetKey();
tempKeystore.AddKey(key);
}
// Add previous txouts given in the RPC call:
if (!registers.count("prevtxs"))
throw std::runtime_error("prevtxs register variable must be set.");
UniValue prevtxsObj = registers["prevtxs"];
{
for (unsigned int previdx = 0; previdx < prevtxsObj.size(); previdx++) {
UniValue prevOut = prevtxsObj[previdx];
if (!prevOut.isObject())
throw std::runtime_error("expected prevtxs internal object");
std::map<std::string,UniValue::VType> types = boost::assign::map_list_of("txid", UniValue::VSTR)("vout",UniValue::VNUM)("scriptPubKey",UniValue::VSTR);
if (!prevOut.checkObject(types))
throw std::runtime_error("prevtxs internal object typecheck fail");
uint256 txid = ParseHashUV(prevOut["txid"], "txid");
int nOut = atoi(prevOut["vout"].getValStr());
if (nOut < 0)
throw std::runtime_error("vout must be positive");
std::vector<unsigned char> pkData(ParseHexUV(prevOut["scriptPubKey"], "scriptPubKey"));
CScript scriptPubKey(pkData.begin(), pkData.end());
{
CCoinsModifier coins = view.ModifyCoins(txid);
if (coins->IsAvailable(nOut) && coins->vout[nOut].scriptPubKey != scriptPubKey) {
std::string err("Previous output scriptPubKey mismatch:\n");
err = err + ScriptToAsmStr(coins->vout[nOut].scriptPubKey) + "\nvs:\n"+
ScriptToAsmStr(scriptPubKey);
throw std::runtime_error(err);
}
if ((unsigned int)nOut >= coins->vout.size())
coins->vout.resize(nOut+1);
coins->vout[nOut].scriptPubKey = scriptPubKey;
coins->vout[nOut].nValue = 0;
if (prevOut.exists("amount")) {
coins->vout[nOut].nValue = AmountFromValue(prevOut["amount"]);
}
}
// if redeemScript given and private keys given,
// add redeemScript to the tempKeystore so it can be signed:
if ((scriptPubKey.IsPayToScriptHash() || scriptPubKey.IsPayToWitnessScriptHash()) &&
prevOut.exists("redeemScript")) {
UniValue v = prevOut["redeemScript"];
std::vector<unsigned char> rsData(ParseHexUV(v, "redeemScript"));
CScript redeemScript(rsData.begin(), rsData.end());
tempKeystore.AddCScript(redeemScript);
}
}
}
const CKeyStore& keystore = tempKeystore;
bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE);
// Sign what we can:
for (unsigned int i = 0; i < mergedTx.vin.size(); i++) {
CTxIn& txin = mergedTx.vin[i];
const CCoins* coins = view.AccessCoins(txin.prevout.hash);
if (!coins || !coins->IsAvailable(txin.prevout.n)) {
fComplete = false;
continue;
}
const CScript& prevPubKey = coins->vout[txin.prevout.n].scriptPubKey;
const CAmount& amount = coins->vout[txin.prevout.n].nValue;
SignatureData sigdata;
// Only sign SIGHASH_SINGLE if there's a corresponding output:
if (!fHashSingle || (i < mergedTx.vout.size()))
ProduceSignature(MutableTransactionSignatureCreator(&keystore, &mergedTx, i, amount, nHashType), prevPubKey, sigdata);
// ... and merge in other signatures:
BOOST_FOREACH(const CTransaction& txv, txVariants)
sigdata = CombineSignatures(prevPubKey, MutableTransactionSignatureChecker(&mergedTx, i, amount), sigdata, DataFromTransaction(txv, i));
UpdateTransaction(mergedTx, i, sigdata);
if (!VerifyScript(txin.scriptSig, prevPubKey, &txin.scriptWitness, STANDARD_SCRIPT_VERIFY_FLAGS, MutableTransactionSignatureChecker(&mergedTx, i, amount)))
fComplete = false;
}
if (fComplete) {
// do nothing... for now
// perhaps store this for later optional JSON output
}
tx = mergedTx;
}
class Secp256k1Init
{
ECCVerifyHandle globalVerifyHandle;
public:
Secp256k1Init() {
ECC_Start();
}
~Secp256k1Init() {
ECC_Stop();
}
};
static void MutateTx(CMutableTransaction& tx, const std::string& command,
const std::string& commandVal)
{
std::unique_ptr<Secp256k1Init> ecc;
if (command == "nversion")
MutateTxVersion(tx, commandVal);
else if (command == "locktime")
MutateTxLocktime(tx, commandVal);
else if (command == "delin")
MutateTxDelInput(tx, commandVal);
else if (command == "in")
MutateTxAddInput(tx, commandVal);
else if (command == "delout")
MutateTxDelOutput(tx, commandVal);
else if (command == "outaddr")
MutateTxAddOutAddr(tx, commandVal);
else if (command == "outpubkey")
MutateTxAddOutPubKey(tx, commandVal);
else if (command == "outmultisig")
MutateTxAddOutMultiSig(tx, commandVal);
else if (command == "outscript")
MutateTxAddOutScript(tx, commandVal);
else if (command == "outdata")
MutateTxAddOutData(tx, commandVal);
else if (command == "sign") {
if (!ecc) { ecc.reset(new Secp256k1Init()); }
MutateTxSign(tx, commandVal);
}
else if (command == "load")
RegisterLoad(commandVal);
else if (command == "set")
RegisterSet(commandVal);
else
throw std::runtime_error("unknown command");
}
static void OutputTxJSON(const CTransaction& tx)
{
UniValue entry(UniValue::VOBJ);
TxToUniv(tx, uint256(), entry);
std::string jsonOutput = entry.write(4);
fprintf(stdout, "%s\n", jsonOutput.c_str());
}
static void OutputTxHash(const CTransaction& tx)
{
std::string strHexHash = tx.GetHash().GetHex(); // the hex-encoded transaction hash (aka the transaction id)
fprintf(stdout, "%s\n", strHexHash.c_str());
}
static void OutputTxHex(const CTransaction& tx)
{
std::string strHex = EncodeHexTx(tx);
fprintf(stdout, "%s\n", strHex.c_str());
}
static void OutputTx(const CTransaction& tx)
{
if (GetBoolArg("-json", false))
OutputTxJSON(tx);
else if (GetBoolArg("-txid", false))
OutputTxHash(tx);
else
OutputTxHex(tx);
}
static std::string readStdin()
{
char buf[4096];
std::string ret;
while (!feof(stdin)) {
size_t bread = fread(buf, 1, sizeof(buf), stdin);
ret.append(buf, bread);
if (bread < sizeof(buf))
break;
}
if (ferror(stdin))
throw std::runtime_error("error reading stdin");
boost::algorithm::trim_right(ret);
return ret;
}
static int CommandLineRawTx(int argc, char* argv[])
{
std::string strPrint;
int nRet = 0;
try {
// Skip switches; Permit common stdin convention "-"
while (argc > 1 && IsSwitchChar(argv[1][0]) &&
(argv[1][1] != 0)) {
argc--;
argv++;
}
CMutableTransaction tx;
int startArg;
if (!fCreateBlank) {
// require at least one param
if (argc < 2)
throw std::runtime_error("too few parameters");
// param: hex-encoded bitcoin transaction
std::string strHexTx(argv[1]);
if (strHexTx == "-") // "-" implies standard input
strHexTx = readStdin();
if (!DecodeHexTx(tx, strHexTx, true))
throw std::runtime_error("invalid transaction encoding");
startArg = 2;
} else
startArg = 1;
for (int i = startArg; i < argc; i++) {
std::string arg = argv[i];
std::string key, value;
size_t eqpos = arg.find('=');
if (eqpos == std::string::npos)
key = arg;
else {
key = arg.substr(0, eqpos);
value = arg.substr(eqpos + 1);
}
MutateTx(tx, key, value);
}
OutputTx(tx);
}
catch (const boost::thread_interrupted&) {
throw;
}
catch (const std::exception& e) {
strPrint = std::string("error: ") + e.what();
nRet = EXIT_FAILURE;
}
catch (...) {
PrintExceptionContinue(NULL, "CommandLineRawTx()");
throw;
}
if (strPrint != "") {
fprintf((nRet == 0 ? stdout : stderr), "%s\n", strPrint.c_str());
}
return nRet;
}
int main(int argc, char* argv[])
{
SetupEnvironment();
try {
int ret = AppInitRawTx(argc, argv);
if (ret != CONTINUE_EXECUTION)
return ret;
}
catch (const std::exception& e) {
PrintExceptionContinue(&e, "AppInitRawTx()");
return EXIT_FAILURE;
} catch (...) {
PrintExceptionContinue(NULL, "AppInitRawTx()");
return EXIT_FAILURE;
}
int ret = EXIT_FAILURE;
try {
ret = CommandLineRawTx(argc, argv);
}
catch (const std::exception& e) {
PrintExceptionContinue(&e, "CommandLineRawTx()");
} catch (...) {
PrintExceptionContinue(NULL, "CommandLineRawTx()");
}
return ret;
}
| [
"[email protected]"
] | |
a2a10da23d009cc2b986f7fb0ba8896e7f81d8dc | 62a56825aaf39e8249d55be5ab593cc8b8484f69 | /src/graphics/ShaderProgram.h | 2495e2c1d5a670d6985c2f91472fd6784c4d5f36 | [] | no_license | BenStraubinger/enjen | e48bfd35d2b439d397f9f3424ff805af80a4d5bd | b1960cad0e08ebf466eb11d026ab11cb4936a55a | refs/heads/master | 2020-12-07T21:09:44.743229 | 2016-10-31T14:08:12 | 2016-10-31T14:08:12 | 67,774,259 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 513 | h | #ifndef ENJEN_SHADERPROGRAM_H
#define ENJEN_SHADERPROGRAM_H
#define GLEW_STATIC
#include "GL/glew.h"
#include "SDL.h"
#include "glm/vec2.hpp"
#include "glm/vec3.hpp"
#include <string>
class ShaderProgram
{
public:
ShaderProgram();
~ShaderProgram();
GLuint ID();
bool Loaded();
bool Load( std::string vert_shader_filename, std::string frag_shader_filename );
void Use();
private:
bool _loaded;
GLuint _id;
GLuint _vert_id;
GLuint _frag_id;
};
#endif //ENJEN_SHADERPROGRAM_H
| [
"[email protected]"
] | |
f2b5f592923d6cefc10fb1f6c85bc40e60a3d54c | f5a58a1ad2795535c84ebdad1394e8d9e9f5be28 | /source/linevariables/lv_chi.h | fd48b0ebe8b206ec7a69617cd63b6f63050f1007 | [] | no_license | aquila21/odt20_fistler | 2e8541340a8807e97649e079560db577a10f0755 | 1414629587e4b7fd7b8ca70c1b50259c4825399c | refs/heads/master | 2022-12-07T02:40:07.538929 | 2020-09-01T15:44:49 | 2020-09-01T15:44:49 | 292,041,427 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 958 | h | /**
* @file lv_chi.h
* Header file for class lv_chi
*/
#ifndef LV_CHI_H
#define LV_CHI_H
#include "lv.h"
#include <string>
#include <vector>
class odtline;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
/** Class implementing child lv_chi of parent lv object.
*
* @author David O. Lignell
*/
class lv_chi : public lv {
//////////////////// DATA MEMBERS //////////////////////
private:
//////////////////// MEMBER FUNCTIONS /////////////////
public:
virtual void setVar(const int ipt=-1);
private:
//////////////////// CONSTRUCTOR FUNCTIONS /////////////////
public:
lv_chi(){}
lv_chi(odtline *line,
const string s,
const bool Lt,
const bool Lo=true);
virtual ~lv_chi(){}
};
////////////////////////////////////////////////////////////////////////////////
#endif
| [
"[email protected]"
] | |
b1d96c9013c395972fed2d2c97c6a77cb9265e1b | 49ed7092c32168d2abdb127f93f7aaba3c898f64 | /2019-pd2-pacman-master/pacman.h | a439a70801b5820cbb90943ba57181d0d5a765f3 | [] | no_license | Korin777/Programing-Language-Homework | cb4e07cf713fa2281b0b93d38f695dbc2044e5f7 | a9f440162948ee6838785f3acdfcaed365bdc214 | refs/heads/main | 2023-02-20T20:31:53.713452 | 2021-01-14T08:49:04 | 2021-01-14T08:49:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 774 | h | #ifndef PACMAN_H
#define PACMAN_H
#include "movableitem.h"
class Pacman : public movableitem
{
public:
Pacman();
QPixmap pacleft1,pacleft2,pacleft3,pacright1,pacright2,pacright3,pacup1,pacup2,pacup3,pacdown1,pacdown2,pacdown3;
virtual void move();
virtual QRectF boundingRect() const;
virtual void paint(QPainter *painter,const QStyleOptionGraphicsItem *option,QWidget *widget);
int change = 0;
bool left = false;
bool right = false;
bool up = false;
bool down = false;
bool eatghost = false;
bool moveleft,moveright,moveup,movedown;
virtual void restrict();
//
protected:
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
};
#endif // PACMAN_H
| [
"[email protected]"
] | |
2139f8ff29e04ae253dacbe3eabc20240b96a6a8 | 22afbddd2e6add2b51d17d5bfbfe28307b095cb9 | /Source/RTS/Plugins/RTSPlugin/Source/RTSPlugin/Classes/RTSGameState.h | 912811bd04e115e232ef5fb146d94760a810e31c | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | jashking/ue4-rts | 9a9cef1f5b65cf001ca39bbfe1bc80efe8fa6e88 | 360f684db4199cefa7bf5376c8844873c1b512e0 | refs/heads/develop | 2021-05-12T18:10:38.440215 | 2019-05-22T02:59:36 | 2019-05-22T02:59:36 | 117,061,553 | 3 | 1 | MIT | 2019-05-22T02:59:37 | 2018-01-11T06:45:39 | C++ | UTF-8 | C++ | false | false | 411 | h | #pragma once
#include "RTSPluginPCH.h"
#include "GameFramework/GameStateBase.h"
#include "RTSGameState.generated.h"
class ARTSTeamInfo;
/**
* Game state with RTS features, such as teams.
*/
UCLASS()
class RTSPLUGIN_API ARTSGameState : public AGameStateBase
{
GENERATED_BODY()
public:
/** Teams of the current match. */
UPROPERTY(BlueprintReadOnly, Category = "Team")
TArray<ARTSTeamInfo*> Teams;
};
| [
"[email protected]"
] | |
06404ef3c68477a3202949769a1e171b803d1909 | bc39fe77f82affcc39cf2a24ad827c13fd471e5f | /cocos2dx/misc_nodes/CCClippingNode.h | a174702b26abf83226cffaaf86e240fca08632ea | [] | no_license | pigpigyyy/Dorothy | c3a11323fe5b0f46f40955074cffbe28d824c0e8 | ac9eeaf84a5abb0b23de741b747e0fb970c78aba | refs/heads/master | 2022-04-29T09:02:48.788574 | 2022-03-03T08:29:04 | 2022-03-03T08:29:04 | 24,334,351 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,522 | h | /*
* cocos2d for iPhone: http://www.cocos2d-iphone.org
* cocos2d-x: http://www.cocos2d-x.org
*
* Copyright (c) 2012 Pierre-David Bélanger
* Copyright (c) 2012 cocos2d-x.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#ifndef __MISCNODE_CCCLIPPING_NODE_H__
#define __MISCNODE_CCCLIPPING_NODE_H__
#include "base_nodes/CCNode.h"
#include "CCGL.h"
NS_CC_BEGIN
/** CCClippingNode is a subclass of CCNode.
It draws its content (childs) clipped using a stencil.
The stencil is an other CCNode that will not be drawn.
The clipping is done using the alpha part of the stencil (adjusted with an alphaThreshold).
*/
class CC_DLL CCClippingNode : public CCNode
{
protected:
CCNode* m_pStencil;
GLfloat m_fAlphaThreshold;
bool m_bInverted;
public:
/** Creates and initializes a clipping node without a stencil.
*/
static CCClippingNode* create();
/** Creates and initializes a clipping node with an other node as its stencil.
The stencil node will be retained.
*/
static CCClippingNode* create(CCNode *pStencil);
virtual ~CCClippingNode();
/** Initializes a clipping node without a stencil.
*/
virtual bool init();
/** Initializes a clipping node with an other node as its stencil.
The stencil node will be retained, and its parent will be set to this clipping node.
*/
virtual bool init(CCNode *pStencil);
virtual void onEnter();
virtual void onEnterTransitionDidFinish();
virtual void onExitTransitionDidStart();
virtual void onExit();
virtual void visit();
/** The CCNode to use as a stencil to do the clipping.
The stencil node will be retained.
This default to nil.
*/
CCNode* getStencil() const;
void setStencil(CCNode *pStencil);
/** The alpha threshold.
The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold.
Should be a float between 0 and 1.
This default to 1 (so alpha test is disabled).
*/
GLfloat getAlphaThreshold() const;
void setAlphaThreshold(GLfloat fAlphaThreshold);
/** Inverted. If this is set to YES,
the stencil is inverted, so the content is drawn where the stencil is NOT drawn.
This default to NO.
*/
bool isInverted() const;
void setInverted(bool bInverted);
private:
CCClippingNode();
CC_LUA_TYPE(CCClippingNode)
};
NS_CC_END
#endif // __MISCNODE_CCCLIPPING_NODE_H__
| [
"[email protected]"
] | |
7fdc73a9092ccfa8f320dfdb78f53991b8840534 | 84f2653e51a756c33e8504edc00e7dfa66e04db7 | /ExosipTestClient/handlesipevents.cpp | 5d56b3c147b0ea5510f668fafbea4dfdf36ab67e | [] | no_license | zhoudd1/ExosipClientAndServer | be915d185313d43091e3b577c8ba974a71325328 | 65c402fd86c0ccb29484bed4768cbbd56980c77b | refs/heads/master | 2020-04-13T07:12:35.422237 | 2018-09-14T02:29:31 | 2018-09-14T02:29:31 | 163,044,091 | 2 | 0 | null | 2018-12-25T03:52:13 | 2018-12-25T03:52:13 | null | UTF-8 | C++ | false | false | 5,104 | cpp | #include "handlesipevents.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <QDebug>
#include <QSettings>
#include <QFile>
#include <QCoreApplication>
#include <QDateTime>
#include "gbsip.h"
#ifdef WIN32
#include <winsock2.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#endif
using namespace std;
HandleSipEvents::HandleSipEvents(QObject *parent)
: QThread(parent)
, m_pContextSip(NULL)
, m_pSipEvent(NULL)
, m_pRemoteSdp(NULL)
, m_nExpires(0)
, m_pGBSipThread(NULL)
{
m_pStrLocalIP = new char[50];
}
HandleSipEvents::~HandleSipEvents()
{
if(m_pGBSipThread) m_pGBSipThread->stop();
delete m_pGBSipThread;
eXosip_quit(m_pContextSip);
}
bool HandleSipEvents::Init()
{
if(!InitSip())
{
qDebug() << "HandleSipEvents::Init--init sip error.";
return false;
}
m_pGBSipThread = new GBSip(m_pContextSip);
m_pGBSipThread->start();
return true;
}
void HandleSipEvents::run()
{
qDebug() << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") << ": Enter HandleSipEvents::run() ..." << endl;
while(1)
{
if(m_pGBSipThread && m_pGBSipThread->IsVecSipEventEmpty())
{
usleep(1500);
continue;
}
m_pGBSipThread->GetFirstSipEvent(m_pSipEvent);// m_pNvr = FactoryNVR::getInstance()->createNVR();
// qDebug() << "HandleSipEvents::eXosip event type: " << m_pSipEvent->type;
qDebug() << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") << ": HandleSipEvents::eXosip event tid: " << m_pSipEvent->tid;
switch (m_pSipEvent->type) {
case EXOSIP_MESSAGE_NEW://23,新的消息到来
OnMsgNewGet();
break;
default:
break;
}
}
qDebug() << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") << ": Exit HandleSipEvents::run() ...";
}
bool HandleSipEvents::InitSip()
{
int nRet = -1;
m_pContextSip = eXosip_malloc();
nRet = eXosip_init(m_pContextSip);
if(nRet != OSIP_SUCCESS)
{
qDebug() << "eXosip init failed!";
return false;
}
qDebug() << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") << ": eXosip init succeed!";
eXosip_set_user_agent(m_pContextSip, "Embedded Net DVR/NVR/DVS");
nRet = eXosip_listen_addr(m_pContextSip, IPPROTO_UDP, NULL, 5060, AF_INET, 0);
if(nRet != OSIP_SUCCESS)
{
eXosip_quit(m_pContextSip);
qDebug() << "Transport layer init failed!";
return false;
}
nRet = eXosip_guess_localip (m_pContextSip, AF_INET, m_pStrLocalIP, 50);
if(nRet != OSIP_SUCCESS)
{
eXosip_quit(m_pContextSip);
qDebug() << "Guess local ip failed!";
return false;
}
return true;
}
void HandleSipEvents::OnMsgNewGet()
{
qDebug() << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") << ": EXOSIP_MESSAGE_NEW" << endl;
if(MSG_IS_MESSAGE(m_pSipEvent->request))//如果接受到的消息类型是MESSAGE
{
osip_body_t *reqBody;
osip_message_t *pAnsMsg = NULL;
if(osip_message_get_body(m_pSipEvent->request, 0, &reqBody) != OSIP_UNDEFINED_ERROR)
{
// qDebug() << "Get msg body is: " << reqBody->body;
//按照规则,需要回复OK信息
eXosip_lock(m_pContextSip);
int nRet = eXosip_message_build_answer(m_pContextSip, m_pSipEvent->tid, 200, &pAnsMsg);
if(nRet != OSIP_SUCCESS)
{
qDebug() << "This new msg is invalid! Cann't response!";
nRet = eXosip_message_send_answer(m_pContextSip, m_pSipEvent->tid, 400, NULL);
eXosip_unlock(m_pContextSip);
}
else
{
nRet = eXosip_message_send_answer(m_pContextSip, m_pSipEvent->tid, 200, pAnsMsg);
eXosip_unlock(m_pContextSip);
// qDebug() << "m_pSipEvent->request content-type: " << osip_message_get_content_type(m_pSipEvent->request)->subtype;
QStringList msgBody = QString(reqBody->body).split("\r\n", QString::SkipEmptyParts);
QMap<QString, QString> mapAttr;
QString key, val;
for(int i=2; i<msgBody.count()-1; i++)
{
while(msgBody[i].size()>0 && msgBody[i].at(0).isSpace())
{
msgBody[i].remove(0, 1);
}
key = msgBody[i].mid(1, msgBody[i].indexOf(">")-msgBody[i].indexOf("<")-1);
val = msgBody[i].mid(msgBody[i].indexOf(">")+1, msgBody[i].indexOf("</")-msgBody[i].indexOf(">")-1);
mapAttr[key] = val;
}
// StreamThread* pThread = m_pThreadFac->createStreamThread(
// mapAttr["CmdType"].toStdString(), mapAttr, m_pContextSip, m_sipInfo);
}
}
}
eXosip_event_free(m_pSipEvent);
m_pSipEvent = NULL;
}
| [
"[email protected]"
] | |
3e93b0a1e6fbe50f0241e8c5241221b52bb9cdbd | cb0201ded1bbbe05d9f98f6d9393c8d17e3c872b | /CppSprtPkg/Include/tr1/array | 6861ce08f259bf06f62341b2e78ad16e4ff91772 | [
"BSD-2-Clause",
"OpenSSL"
] | permissive | mikeniu/uefi-longson | 43999ccae33372f5875680eb43578fa103518cce | d6fba2f83e00125ff0362b4583461958d459fb4b | refs/heads/main | 2023-03-16T23:04:00.293750 | 2021-03-04T03:09:38 | 2021-03-04T03:09:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,801 | // class template array -*- C++ -*-
// Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file tr1/array
* This is a TR1 C++ Library header.
*/
#ifndef _GLIBCXX_TR1_ARRAY
#define _GLIBCXX_TR1_ARRAY 1
#pragma GCC system_header
#if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
# error TR1 header cannot be included from C++0x header
#endif
#include <bits/stl_algobase.h>
#if defined(_GLIBCXX_INCLUDE_AS_TR1)
# include <tr1_impl/array>
#else
# define _GLIBCXX_INCLUDE_AS_TR1
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 {
# define _GLIBCXX_END_NAMESPACE_TR1 }
# define _GLIBCXX_TR1 tr1::
# include <tr1_impl/array>
# undef _GLIBCXX_TR1
# undef _GLIBCXX_END_NAMESPACE_TR1
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1
# undef _GLIBCXX_INCLUDE_AS_TR1
#endif
#endif // _GLIBCXX_TR1_ARRAY
| [
"[email protected]"
] | ||
f06c828da2dde7137e0019795dca268887d1aa46 | 06b58aaec7037703f360f56a05e62ba0ead7d0d3 | /00-CppHelloWorld/hello.cpp | 903d9685a4a77a196b073b7d4da65079d449c670 | [] | no_license | camilolestani/AED | 8c930b4e818e13af956ef683cd18f571d5ad1ea0 | cf4b83dbf8cb7435dc918ab175514d1989379af0 | refs/heads/main | 2023-04-18T20:50:48.170990 | 2021-05-05T01:02:03 | 2021-05-05T01:02:03 | 357,036,474 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 97 | cpp | /* Hello World
JMS
20130411
*/
#include <iostream>
int main() {
std::cout << "Hello, World!\n";
} | [
"[email protected]"
] | |
f6445eb7304dde6c34c046afb5af2d519aa86274 | 98fee08e9f19521f58855039fd85f9b103239007 | /src/tests/jsoncpptest.cpp | 9815698882a300d4006ece527876e37d4a69c8b0 | [
"MIT"
] | permissive | styac/cxx-json-benchmark | 62463e57715c64ac27a9ed9493e21474868e3dd3 | 2d0d367155982c1d03fbcb328ebb52dbc5e9a9ea | refs/heads/main | 2023-02-13T01:21:43.417930 | 2021-01-12T16:28:40 | 2021-01-12T16:28:40 | 311,129,077 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,319 | cpp | #include <memory>
#include "../test.h"
#include "jsoncpp/src/lib_json/json_reader.cpp"
#include "jsoncpp/src/lib_json/json_value.cpp"
#include "jsoncpp/src/lib_json/json_writer.cpp"
using namespace Json;
static void GenStat(Stat& stat, const Value& v) {
switch (v.type()) {
case arrayValue:
for (ValueConstIterator itr = v.begin(); itr != v.end(); ++itr)
GenStat(stat, *itr);
stat.arrayCount++;
stat.elementCount += v.size();
break;
case objectValue:
for (ValueConstIterator itr = v.begin(); itr != v.end(); ++itr) {
GenStat(stat, *itr);
stat.stringLength += itr.name().size();
}
stat.objectCount++;
stat.memberCount += v.size();
stat.stringCount += v.size(); // member names
break;
case stringValue:
stat.stringCount++;
stat.stringLength += v.asString().size();
break;
case intValue:
case uintValue:
case realValue:
stat.numberCount++;
break;
case booleanValue:
if (v.asBool())
stat.trueCount++;
else
stat.falseCount++;
break;
case nullValue:
stat.nullCount++;
break;
}
}
class JsoncppParseResult : public ParseResultBase {
public:
Value root;
};
class JsoncppStringResult : public StringResultBase {
public:
virtual const char* c_str() const { return s.c_str(); }
std::string s;
};
class JsoncppTest : public TestBase {
public:
#if TEST_INFO
virtual const char* GetName() const override { return "JsonCpp (C++)"; }
virtual const char* GetFilename() const override { return __FILE__; }
#endif
#if TEST_PARSE
virtual ParseResultBase* Parse(const char* json, size_t length) const override
{
(void)length;
JsoncppParseResult* pr = new JsoncppParseResult;
Json::CharReaderBuilder rbuilder;
Json::Value settings;
rbuilder.strictMode(&rbuilder.settings_);
std::unique_ptr<CharReader> const reader(rbuilder.newCharReader());
std::string errs;
if (!reader->parse(json, json + length, &pr->root, &errs)) {
delete pr;
return 0;
}
return pr;
}
#endif
#if TEST_STRINGIFY
virtual StringResultBase* Stringify(const ParseResultBase* parseResult) const override
{
const JsoncppParseResult* pr = static_cast<const JsoncppParseResult*>(parseResult);
//FastWriter writer;
Json::StreamWriterBuilder wbuilder;
wbuilder.settings_["indentation"] = "";
//std::unique_ptr<Json::StreamWriter> const writer(wbuilder.newStreamWriter());
//writer->omitEndingLineFeed();
JsoncppStringResult* sr = new JsoncppStringResult;
sr->s = Json::writeString(wbuilder, pr->root);
return sr;
}
#endif
#if TEST_STATISTICS
virtual bool Statistics(const ParseResultBase* parseResult, Stat* stat) const override
{
const JsoncppParseResult* pr = static_cast<const JsoncppParseResult*>(parseResult);
memset(stat, 0, sizeof(Stat));
GenStat(*stat, pr->root);
return true;
}
#endif
#if TEST_CONFORMANCE
virtual bool ParseDouble(const char* json, size_t length, double* d) const override
{
CharReaderBuilder builder;
JSONCPP_STRING err;
Value root;
const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
if (reader->parse(json, json+length, &root, &err) &&
root.isArray() &&
root.size() == 1 &&
root[0].isDouble())
{
*d = root[0].asDouble();
return true;
}
else
return false;
}
virtual bool ParseString(const char* json, size_t length, std::string& s) const override
{
CharReaderBuilder builder;
JSONCPP_STRING err;
Value root;
const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
if (reader->parse(json, json+length, &root, &err) &&
root.isArray() &&
root.size() == 1 &&
root[0].isString())
{
s = root[0].asString();
return true;
}
else
return false;
}
#endif
};
REGISTER_TEST(JsoncppTest);
| [
"[email protected]"
] | |
ab9f0982ce547da82d73e1b1bed5a09038e1da26 | 76d79c0a95fe22f4397d3b377353346f4ee7f498 | /Led.cpp | 6eaea1071cd473bd8c72245c6800627e96b78a21 | [] | no_license | BeamOfLight/LedClientServer | a1495fb0d64896ecb7f737a84270182c9e107615 | 6fb71cd22c27468942fb54c3d1717965c597969b | refs/heads/master | 2021-01-23T13:29:16.881528 | 2015-09-27T06:41:06 | 2015-09-28T05:40:32 | 42,980,686 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,679 | cpp | #include "Led.h"
Led::Led()
{
state = false;
color = COLOR_RED;
rate = 0;
}
bool Led::getState()
{
return state;
}
std::string Led::getStateText()
{
std::string state_text = "off";
if (getState()) {
state_text = "on";
}
return state_text;
}
void Led::setState(bool state)
{
this->state = state;
}
void Led::setState(std::string state_str)
{
if (state_str == "on") {
state = true;
} else if (state_str == "off") {
state = false;
}
}
LedColor Led::getColor()
{
return color;
}
std::string Led::getColorText()
{
std::string result;
if (this->color == COLOR_RED) {
result = "red";
} else if (this->color == COLOR_GREEN) {
result = "green";
} else if (this->color == COLOR_BLUE) {
result = "blue";
}
return result;
}
void Led::setColor(LedColor color)
{
this->color = color;
}
void Led::setColor(std::string color_str)
{
if (color_str == "red") {
this->color = COLOR_RED;
} else if (color_str == "green") {
this->color = COLOR_GREEN;
} else if (color_str == "blue") {
this->color = COLOR_BLUE;
}
}
unsigned char Led::getRate()
{
return rate;
}
void Led::setRate(unsigned char rate)
{
this->rate = rate;
}
void Led::setRate(std::string rate_text)
{
rate = atoi(rate_text.c_str());
}
std::string Led::getInfo()
{
std::ostringstream result;
result << "State: " << getStateText() << "\tColor: " << getColorText() << "\tRate: " << (int) getRate() << " Hz";
return result.str();
}
| [
"[email protected]"
] | |
d620b15dcdf6f3d911451f71575aaa3c3c79ea5e | 40fb439ee3b512cb0dc3b06d4a70eb07419c6996 | /bslib/src/bslib/sqlitepp/sqlitepp.cpp | 4a4e2b9aee1749fc9ae0c13e5a4cc76101ff483a | [] | no_license | zsims/af | bcaa8b46f73756e96e148f8b08b723ebaa968b7e | a807d0a2e01db5c92520be172c2cf2f9f21915c3 | refs/heads/master | 2021-05-07T14:23:49.212537 | 2017-02-12T02:50:26 | 2017-02-12T02:50:26 | 109,813,747 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,639 | cpp | #include "bslib/sqlitepp/sqlitepp.hpp"
#include <boost/format.hpp>
#include <string>
namespace af {
namespace bslib {
namespace sqlitepp {
void open_database_or_throw(const char* filename, sqlite3** ppDb, int flags)
{
const auto result = sqlite3_open_v2(filename, ppDb, flags, 0);
if (result != SQLITE_OK)
{
throw OpenDatabaseFailedException(filename, result);
}
}
void prepare_or_throw(sqlite3* db, const char* sql, sqlite3_stmt** statement)
{
const auto prepareResult = sqlite3_prepare_v2(db, sql, -1, statement, 0);
if (prepareResult != SQLITE_OK)
{
throw PrepareStatementFailedException(prepareResult, std::string(sqlite3_errmsg(db)));
}
}
void exec_or_throw(sqlite3* db, const char* sql)
{
const auto executeResult = sqlite3_exec(db, sql, nullptr, nullptr, nullptr);
if (executeResult != SQLITE_OK)
{
throw ExecuteFailedException(executeResult);
}
}
void BindByParameterNameText(sqlite3_stmt* statement, const std::string& name, const std::string& value)
{
const auto index = sqlite3_bind_parameter_index(statement, name.c_str());
const auto bindResult = sqlite3_bind_text(statement, index, value.c_str(), -1, SQLITE_STATIC);
if (bindResult != SQLITE_OK)
{
throw BindParameterFailedException(name, bindResult);
}
}
void BindByParameterNameInt64(sqlite3_stmt* statement, const std::string& name, int64_t value)
{
const auto index = sqlite3_bind_parameter_index(statement, name.c_str());
const auto bindResult = sqlite3_bind_int64(statement, index, value);
if (bindResult != SQLITE_OK)
{
throw BindParameterFailedException(name, bindResult);
}
}
void BindByParameterNameInt32(sqlite3_stmt* statement, const std::string& name, int32_t value)
{
const auto index = sqlite3_bind_parameter_index(statement, name.c_str());
const auto bindResult = sqlite3_bind_int(statement, index, value);
if (bindResult != SQLITE_OK)
{
throw BindParameterFailedException(name, bindResult);
}
}
void BindByParameterNameBlob(sqlite3_stmt* statement, const std::string& name, const uint8_t* start, size_t size)
{
const auto index = sqlite3_bind_parameter_index(statement, name.c_str());
const auto bindResult = sqlite3_bind_blob(statement, index, start, static_cast<int>(size), SQLITE_STATIC);
if (bindResult != SQLITE_OK)
{
throw BindParameterFailedException(name, bindResult);
}
}
void BindByParameterNameNull(sqlite3_stmt* statement, const std::string& name)
{
const auto index = sqlite3_bind_parameter_index(statement, name.c_str());
const auto bindResult = sqlite3_bind_null(statement, index);
if (bindResult != SQLITE_OK)
{
throw BindParameterFailedException(name, bindResult);
}
}
}
}
}
| [
"[email protected]"
] | |
1efae9ba4201a6b7dd8d074ae15b029dd73bff61 | e6581e760f20a75a0c2135e10f9bf2d0b1dabd37 | /Code Framework/Actions/SELECT.h | ff5f8d18bd121dd8327f2664c2155f9910b5b17e | [] | no_license | tokaalokda/LogicSimulator | 74f4d86c3381e600e00a19e9d05b0edcb26ea3d9 | 6093d6d242801c0f8764b5c16889e0b9c12a153e | refs/heads/main | 2023-04-06T09:37:37.428674 | 2023-03-21T09:19:43 | 2023-03-21T09:19:43 | 321,353,472 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 337 | h | #ifndef _SELECT
#define _SELECT
#include "action.h"
#include "..\Components\Component.h"
class Select : public Action
{
private:
int Cx, Cy;
public:
Select(ApplicationManager* pApp, int x, int y);
virtual ~Select(void);
//Execute action (code depends on action type)
virtual void Execute();
};
#endif
| [
"[email protected]"
] | |
1b4c00bc6ee5ee4e8ee04a5249652bbdd29329d4 | 6fb28da8006f73cc27b926816062bdbf4126721f | /Source/ReBots/GameModes/StarCellGameMode.cpp | 819cd404a881b5db4642e3cc1c96ad82962e92c4 | [] | no_license | USC-PRL/ReMod3D | ebaa956baf5f2246e6b30230644b1245748b83fe | f146449b812402280c29c0ddf3f8f0ca0f4a89f2 | refs/heads/master | 2020-03-18T01:46:00.738356 | 2019-06-17T02:15:01 | 2019-06-17T02:15:01 | 134,158,722 | 7 | 2 | null | 2019-06-17T02:15:02 | 2018-05-20T14:42:40 | C++ | UTF-8 | C++ | false | false | 29,894 | cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "StarCellGameMode.h"
#include "PhysXPublic.h"
//#pragma mark -
//#pragma Superbot Docking
/**
* @brief get corrective docking transform
* @param d1 dock 1
* @param d2 dock 2
* @return corrective trnasform
*/
FTransform AStarCellGameMode::GetCorrectiveDockingTransform(ModuleDockFace d1, ModuleDockFace d2) {
if (d1 == DOCK_0 && d2 == DOCK_0) {
return FTransform(FQuat(FVector(0,1,0),M_PI));
} else if (d1 == DOCK_1 && d2 == DOCK_1) {
return FTransform(FQuat(FVector(0,1,0),M_PI));
} else if (d1 == DOCK_0 && d2 == DOCK_2) {
return FTransform(FQuat(FVector(0,1,0),M_PI_2));
} else if (d1 == DOCK_2 && d2 == DOCK_0) {
return FTransform(FQuat(FVector(0,1,0),-M_PI_2));
} else if (d1 == DOCK_3 && d2 == DOCK_0) {
return FTransform(FQuat(FVector(0,1,0),M_PI_2));
} else if (d1 == DOCK_0 && d2 == DOCK_3) {
return FTransform(FQuat(FVector(0,1,0),-M_PI_2));
} else if (d1 == DOCK_1 && d2 == DOCK_2) {
return FTransform(FQuat(FVector(0,1,0),-M_PI_2));
} else if (d1 == DOCK_2 && d2 == DOCK_1) {
return FTransform(FQuat(FVector(0,1,0),M_PI_2));
} else if (d1 == DOCK_3 && d2 == DOCK_1) {
return FTransform(FQuat(FVector(0,1,0),-M_PI_2));
} else if (d1 == DOCK_1 && d2 == DOCK_3) {
return FTransform(FQuat(FVector(0,1,0),M_PI_2));
} else if (d1 == DOCK_0 && d2 == DOCK_4) {
return FTransform(FQuat(FVector(0,1,0),M_PI_2));
} else if (d1 == DOCK_4 && d2 == DOCK_0) {
return FTransform(FQuat(FVector(0,1,0),-M_PI_2));
} else if (d1 == DOCK_1 && d2 == DOCK_4) {
return FTransform(FQuat(FVector(0,1,0),-M_PI_2));
} else if (d1 == DOCK_4 && d2 == DOCK_1) {
return FTransform(FQuat(FVector(0,1,0),M_PI_2));
} else if (d1 == DOCK_0 && d2 == DOCK_5) {
return FTransform(FQuat(FVector(0,1,0),-M_PI_2));
} else if (d1 == DOCK_5 && d2 == DOCK_0) {
return FTransform(FQuat(FVector(0,1,0),M_PI_2));
} else if (d1 == DOCK_1 && d2 == DOCK_5) {
return FTransform(FQuat(FVector(0,1,0),M_PI_2));
} else if (d1 == DOCK_5 && d2 == DOCK_1) {
return FTransform(FQuat(FVector(0,1,0),-M_PI_2));
}
return FTransform(FVector(0,0,0));
}
/**
* @brief dock two modules together
* @param sm1 superbot module 1
* @param sm2 superbot module 2
* @param d1 dock face of module 1
* @param d2 dock face of module 2
*/
void AStarCellGameMode::DockModuleToGround(ASuperBotModule* sm1, ModuleDockFace d1) {
//sm1->SetDockEngaged(d1, true);
ModuleMotorVector mv1 = sm1->GetJointAngles();
sm1->GetRootComponent()->AttachTo(Floor->GetRootComponent(), "", EAttachLocation::KeepRelativeOffset, false);
FTransform t = Floor->GetRootComponent()->GetComponentTransform();
t =
sm1->GetRootToMasterInnerTransform().Inverse()*
SuperbotKinematics::computeTransformToDock(mv1,d1)*
ASuperBotModule::SuperbotFix*sm1->GetMasterInnerMesh()->GetComponentTransform()*
Floor->GetRootComponent()->GetComponentTransform().Inverse();
//sm1->GetRootComponent()->SetRelativeTransform(sm1->GetRootToMasterInnerTransform().Inverse()*
// SuperbotKinematics::computeTransformFromDock(mv1, d1)*
// FTransform(
// Floor->GetStaticMeshComponent()->GetRelativeTransform());
AReferenceFrameActor *arf1 = GetWorld()->SpawnActor<AReferenceFrameActor>(t.GetLocation(),FRotator(t.GetRotation()));
/*FName d1S = "BackDock";
if (d1 == DOCK_0) d1S = "FrontDock";
else if (d1 == DOCK_1) d1S = "BackDock";
else if (d1 == DOCK_2) d1S = "LeftDock";
else if (d1 == DOCK_3) d1S = "RightDock";
else if (d1 == DOCK_4) d1S = "UpDock";
else if (d1 == DOCK_5) d1S = "DownDock";
UStaticMeshComponent* stMesh1;
if (d1 == DOCK_0 || d1 == DOCK_3 || d1 == DOCK_2) {
stMesh1 = sm1->GetMasterOuterMesh();
} else {
stMesh1 = sm1->GetSlaveOuterMesh();
}
APhysicsConstraintActor *a = GetWorld()->SpawnActor<APhysicsConstraintActor>();
a->GetConstraintComp()->SetConstrainedComponents(stMesh1, d1S, Floor->GetStaticMeshComponent(), "");
a->GetConstraintComp()->SetLinearXLimit(ELinearConstraintMotion::LCM_Locked, 0);
a->GetConstraintComp()->SetLinearYLimit(ELinearConstraintMotion::LCM_Locked, 0);
a->GetConstraintComp()->SetLinearZLimit(ELinearConstraintMotion::LCM_Locked, 0);
a->GetConstraintComp()->SetAngularSwing1Limit(EAngularConstraintMotion::ACM_Locked, 0);
a->GetConstraintComp()->SetAngularSwing2Limit(EAngularConstraintMotion::ACM_Locked, 0);
a->GetConstraintComp()->SetAngularTwistLimit(EAngularConstraintMotion::ACM_Locked, 0);*/
}
/**
* @brief dock two modules together
* @param sm1 superbot module 1
* @param sm2 superbot module 2
* @param d1 dock face of module 1
* @param d2 dock face of module 2
*/
void AStarCellGameMode::DockTwoModules(ASuperBotModule* sm1, ASuperBotModule* sm2, ModuleDockFace d1, ModuleDockFace d2) {
//TODO: use root hierarchy somehow?
connections[sm1->GetIDNumber()][d1] = sm2->GetDocks()[d2];
connections[sm2->GetIDNumber()][d2] = sm1->GetDocks()[d1];
sm1->SetDockEngaged(d1, true);
sm2->SetDockEngaged(d2, true);
ModuleMotorVector mv1 = sm1->GetJointAngles();
ModuleMotorVector mv2 = sm2->GetJointAngles();
sm1->GetRootComponent()->AttachTo(sm2->GetRootComponent(),"",EAttachLocation::SnapToTarget, true);
sm1->GetRootComponent()->SetRelativeTransform(sm1->GetRootToMasterInnerTransform().Inverse()*
SuperbotKinematics::computeTransformFromDock(mv1, d1)*
GetCorrectiveDockingTransform(d1, d2)*
SuperbotKinematics::computeTransformToDock(mv2, d2)*
sm2->GetRootToMasterInnerTransform());
sm1->WeldDockToComponent(d1, sm2->GetDockComponent(d2));
FName d1S = "BackDock";
FName d2S = "FrontDock";
if (d1 == DOCK_0) d1S = "FrontDock";
else if (d1 == DOCK_1) d1S = "BackDock";
else if (d1 == DOCK_2) d1S = "LeftDock";
else if (d1 == DOCK_3) d1S = "RightDock";
else if (d1 == DOCK_4) d1S = "UpDock";
else if (d1 == DOCK_5) d1S = "DownDock";
if (d2 == DOCK_0) d1S = "FrontDock";
else if (d2 == DOCK_1) d2S = "BackDock";
else if (d2 == DOCK_2) d2S = "LeftDock";
else if (d2 == DOCK_3) d2S = "RightDock";
else if (d2 == DOCK_4) d2S = "UpDock";
else if (d2 == DOCK_5) d2S = "DownDock";
UStaticMeshComponent* stMesh1;
UStaticMeshComponent* stMesh2;
if (d1 == DOCK_0 || d1 == DOCK_3 || d1 == DOCK_2) {
stMesh1 = sm1->GetMasterOuterMesh();
} else {
stMesh1 = sm1->GetSlaveOuterMesh();
}
if (d2 == DOCK_0 || d2 == DOCK_3 || d2 == DOCK_2) {
stMesh2 = sm2->GetMasterOuterMesh();
} else {
stMesh2 = sm2->GetSlaveOuterMesh();
}
APhysicsConstraintActor *a = GetWorld()->SpawnActor<APhysicsConstraintActor>();
a->GetConstraintComp()->SetConstrainedComponents(stMesh1, d1S, stMesh2, d2S);
a->GetConstraintComp()->SetLinearXLimit(ELinearConstraintMotion::LCM_Locked, 0);
a->GetConstraintComp()->SetLinearYLimit(ELinearConstraintMotion::LCM_Locked, 0);
a->GetConstraintComp()->SetLinearZLimit(ELinearConstraintMotion::LCM_Locked, 0);
a->GetConstraintComp()->SetAngularSwing1Limit(EAngularConstraintMotion::ACM_Locked, 0);
a->GetConstraintComp()->SetAngularSwing2Limit(EAngularConstraintMotion::ACM_Locked, 0);
a->GetConstraintComp()->SetAngularTwistLimit(EAngularConstraintMotion::ACM_Locked, 0);
a->GetConstraintComp()->SetDisableCollision(true);
}
/**
* @brief get transform of end effector for joint angles
* @param JAngles joint angles
* @return transform of End effector
*/
FTransform AStarCellGameMode::GetTransformOfEndEffector(std::vector<ModuleMotorVector> JAngles, bool ToMaster) {
FTransform endEffectorTransform = FTransform(FVector(0,0,0));
if (ToMaster) {
for (int i=0; i<JAngles.size(); i++) {
endEffectorTransform = SuperbotKinematics::computeTransformFromDock(JAngles[i], DOCK_1)*endEffectorTransform;
endEffectorTransform = SuperbotKinematics::computeTransformToDock(JAngles[i], DOCK_0)*endEffectorTransform;
}
} else {
}
return endEffectorTransform;
}
/**
* @brief fitness function
* @param P particle
* @return particle fitness
*/
/////TODO fix manipulator transform moving with end effector. need fixed frame of reference
float AStarCellGameMode::Fitness(PSOParticle P, std::vector<float> st, std::vector<float> tar) {
std::vector<ModuleMotorVector> mvs(P.getPosition().size()/3);
for (int i=0; i<P.getPosition().size()/3; i++) {mvs[i] = ModuleMotorVector(P.getPosition()[3*i + 0],P.getPosition()[3*i + 1],P.getPosition()[3*i + 2]);}
FTransform PEndTransform = GetTransformOfEndEffector(mvs, true)*ToGroundTransform;
FTransform GoalTransform = GoalEndEffector;
FRotator DiffRot = FRotator(GoalTransform.GetRotation()) - FRotator(PEndTransform.GetRotation());
FVector DiffPos = GoalTransform.GetLocation() - PEndTransform.GetLocation();
float MagOrient = sqrtf(DiffRot.Pitch*DiffRot.Pitch + DiffRot.Yaw*DiffRot.Yaw + DiffRot.Roll*DiffRot.Roll);
return DiffPos.Size() + MagOrient;
}
/**
* @brief game mode constructor
* @param ObjectInitializer initializer
*/
AStarCellGameMode::AStarCellGameMode(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
PrimaryActorTick.bCanEverTick = true;
//DefaultPawnClass = ASuperBotModule::StaticClass();
}
/**
* @brief get sequence of joint angle changes to move end effector to new pose
*/
void AStarCellGameMode::GetSequenceOfJointAngles() {
std::vector<ModuleMotorVector> JAngles(modules.size());
CurrentMotorAngles = std::vector<float>(modules.size()*3);
for (int i=0; i<modules.size(); i++) {
JAngles[i] = modules[i]->GetJointAngles();
CurrentMotorAngles[3*i + 0] = JAngles[i].Motor0Angle;
CurrentMotorAngles[3*i + 1] = JAngles[i].Motor1Angle;
CurrentMotorAngles[3*i + 2] = JAngles[i].Motor2Angle;
}
FTransform EndEffectorTransform = GetTransformOfEndEffector(JAngles,true)*ToGroundTransform;
int NumLocked = modules.size()*3 - 1;
for (int i=0; i<modules.size()*3; i++) {
std::vector<std::pair<float,float> > posB(modules.size()*3 - NumLocked);
std::vector<std::pair<float,float> > velB(modules.size()*3 - NumLocked);
for (int j=0; j<modules.size()*3 - NumLocked; j++) {
posB[j] = std::pair<float,float>(-85,85);
velB[j] = std::pair<float,float>(-85,85);
}
PS = new PSOParticleSwarm(200, 200, modules.size()*3 - NumLocked);
std::vector<float> tar(modules.size()*3 - NumLocked);
PS->initializeSwarm(posB, velB, posB, velB, 0.001, MODE_ACCELERATED,
std::bind(&AStarCellGameMode::FitnessSequence,this,std::placeholders::_1,std::placeholders::_2,
std::placeholders::_3), tar, tar);
while (!PS->isSwarmingDone()) {
PS->updateSwarm();
}
cout<<"Best fitness with "<<NumLocked<<" locked joints: "<<PS->getGlobalBestFitness()<<endl;
//if (PS) delete PS;
NumLocked--;
}
}
/**
* @brief fitness function
* @param P particle
* @return particle fitness
*/
float AStarCellGameMode::FitnessSequence(PSOParticle P, std::vector<float> st, std::vector<float> tar) {
std::vector<ModuleMotorVector> mvs(modules.size());
std::vector<float> JointAngles(modules.size()*3);
int NumLocked = modules.size()*3 - P.getPosition().size();
for (int i=0; i<NumLocked; i++) {
JointAngles[i] = CurrentMotorAngles[i];
}
for (int i=NumLocked; i<modules.size()*3; i++) {
JointAngles[i] = P.getPosition()[i - NumLocked];
}
for (int i=0; i<modules.size(); i++) {mvs[i] = ModuleMotorVector(JointAngles[3*i + 0],JointAngles[3*i + 1],JointAngles[3*i + 2]);}
FTransform PEndTransform = GetTransformOfEndEffector(mvs, true)*ToGroundTransform;
FTransform GoalTransform = GoalEndEffector;
FRotator DiffRot = FRotator(GoalTransform.GetRotation()) - FRotator(PEndTransform.GetRotation());
FVector DiffPos = GoalTransform.GetLocation() - PEndTransform.GetLocation();
float MagOrient = sqrtf(DiffRot.Pitch*DiffRot.Pitch + DiffRot.Yaw*DiffRot.Yaw + DiffRot.Roll*DiffRot.Roll);
return DiffPos.Size() + MagOrient;
}
/**
* @brief advance the simulation
* @param DeltaSeconds fraction of a second by which to advance simulation
*/
void AStarCellGameMode::Tick(float DeltaSeconds) {
if (FirstTick) {
TActorIterator< APhysicsConstraintActor > ConstraintIt = TActorIterator< APhysicsConstraintActor >(GetWorld());
TActorIterator< ASuperBotModule > SuperbotIt = TActorIterator< ASuperBotModule >(GetWorld());
while (SuperbotIt) {
modsToIDs[*SuperbotIt] = modules.size();
(*SuperbotIt)->SetIDNumber(modules.size());
modules.push_back(*SuperbotIt);
++SuperbotIt;
}
std::reverse(modules.begin(),modules.end());
int numConstraints = 0;
while (ConstraintIt) {
numConstraints++;
APhysicsConstraintActor *c = *ConstraintIt;
if (c->GetConstraintComp()->ConstraintActor1->GetClass() == ASuperBotModule::StaticClass() &&
c->GetConstraintComp()->ConstraintActor2->GetClass() == ASuperBotModule::StaticClass()) {
ASuperBotModule* sm1 = Cast<ASuperBotModule>(c->GetConstraintComp()->ConstraintActor1);
ASuperBotModule* sm2 = Cast<ASuperBotModule>(c->GetConstraintComp()->ConstraintActor2);
FConstrainComponentPropName n1 = c->GetConstraintComp()->ComponentName1;
FConstrainComponentPropName n2 = c->GetConstraintComp()->ComponentName2;
FString name1 = n1.ComponentName.ToString();
FString name2 = n2.ComponentName.ToString();
FString bone1 = c->GetConstraintComp()->ConstraintInstance.ConstraintBone1.ToString();
FString bone2 = c->GetConstraintComp()->ConstraintInstance.ConstraintBone2.ToString();
ModuleDockFace dock1 = sm1->GetDockFaceForName(std::string(TCHAR_TO_UTF8(*bone1)));
ModuleDockFace dock2 = sm2->GetDockFaceForName(std::string(TCHAR_TO_UTF8(*bone2)));
if (sm1 && sm2) {
if (DockDebug) {
cout<<"Constraint Found: "<<sm1->GetName()<<"-"<<std::string(TCHAR_TO_UTF8(*bone1))<<
"("<<dock1<<")"<<","<<sm2->GetName()<<"-"<<std::string(TCHAR_TO_UTF8(*bone2))<<"("<<dock2<<")"<<endl;
}
CMonitor.AddConstraint(sm1->GetName(), sm2->GetName(), (ModuleDockFace)dock1, (ModuleDockFace)dock2);
connections[sm1->GetIDNumber()][dock1] = sm2->GetDocks()[dock2];
connections[sm2->GetIDNumber()][dock2] = sm1->GetDocks()[dock1];
sm1->WeldDockToComponent(dock1, sm2->GetDocks()[dock2].GetDockComponent());
sm1->SetDockEngaged(dock1, true);
sm2->SetDockEngaged(dock2, true);
if (DockDebug) {
cout<<sm1->GetName()<<" Dock Status: ";
for (int i=0; i<6; i++) {
cout<<sm1->GetDocks()[i].GetDockEngaged()<<" ";
}
cout<<endl;
cout<<sm2->GetName()<<" Dock Status: ";
for (int i=0; i<6; i++) {
cout<<sm2->GetDocks()[i].GetDockEngaged()<<" ";
}
cout<<endl;
}
}
} else if (c->GetConstraintComp()->ConstraintActor1->GetClass() == ASuperBotModule::StaticClass() &&
c->GetConstraintComp()->ConstraintActor2->GetClass() == AStaticMeshActor::StaticClass()) {
ASuperBotModule *m = (ASuperBotModule*)c->GetConstraintComp()->ConstraintActor1;
AStaticMeshActor *sma = (AStaticMeshActor*)c->GetConstraintComp()->ConstraintActor2;
if (std::string(TCHAR_TO_UTF8(*sma->GetName())).compare("Floor") == 0) {
FString bone1 = c->GetConstraintComp()->ConstraintInstance.ConstraintBone1.ToString();
ModuleDockFace dock1 = m->GetDockFaceForName(std::string(TCHAR_TO_UTF8(*bone1)));
m->SetDockEngagedToGround(dock1,true);
cout<<m->GetName()<<" Connected to floor statuses: "<<endl;
if (DockDebug) {
for (int i=0; i<6; i++) {
cout<<m->GetDocks()[i].GetDockEngagedToGround()<<" ";
}
cout<<endl;
}
}
} else if (c->GetConstraintComp()->ConstraintActor1->GetClass() == AStaticMeshActor::StaticClass() &&
c->GetConstraintComp()->ConstraintActor2->GetClass() == ASuperBotModule::StaticClass()) {
ASuperBotModule *m = (ASuperBotModule*)c->GetConstraintComp()->ConstraintActor2;
AStaticMeshActor *sma = (AStaticMeshActor*)c->GetConstraintComp()->ConstraintActor1;
if (std::string(TCHAR_TO_UTF8(*sma->GetName())).compare("Floor") == 0) {
FString bone2 = c->GetConstraintComp()->ConstraintInstance.ConstraintBone2.ToString();
ModuleDockFace dock2 = m->GetDockFaceForName(std::string(TCHAR_TO_UTF8(*bone2)));
m->SetDockEngagedToGround(dock2,true);
cout<<m->GetName()<<" Connected to floor statuses ";
if (DockDebug) {
for (int i=0; i<6; i++) {
cout<<m->GetDocks()[i].GetDockEngagedToGround()<<" ";
}
cout<<endl;
}
}
}
++ConstraintIt;
}
TActorIterator< AStaticMeshActor > StaticMeshActorsIt = TActorIterator< AStaticMeshActor >(GetWorld());
while (StaticMeshActorsIt) {
if(std::string(TCHAR_TO_UTF8(*(*StaticMeshActorsIt)->GetName())).compare("Floor") == 0) {
AStaticMeshActor* MeshActor = (*StaticMeshActorsIt);
Floor = MeshActor;
//AFloorCollisionActor* FloorCollision = GetWorld()->SpawnActor<AFloorCollisionActor>(MeshActor->GetActorLocation(),
// MeshActor->GetActorRotation());
break;
}
++StaticMeshActorsIt;
}
FirstTick = false;
EndEffectorFrame = GetWorld()->SpawnActor<AReferenceFrameActor>(modules[0]->GetMasterInnerMesh()->GetComponentTransform().GetLocation(),
FRotator(modules[0]->GetMasterInnerMesh()->GetComponentTransform().GetRotation()));
GoalEndEffectorFrame = NULL;
FTransform t =
SuperbotKinematics::computeTransformToDock(modules[0]->GetJointAngles(),DOCK_1)*ASuperBotModule::SuperbotFix*modules[0]->GetMasterInnerMesh()->GetComponentTransform();
ToGroundTransform = t;
ToGroundFrame = GetWorld()->SpawnActor<AReferenceFrameActor>(ToGroundTransform.GetLocation(),
FRotator(ToGroundTransform.GetRotation()));
} else {
if (!GoalEndEffectorFrame) {
GoalEndEffectorFrame = GetWorld()->SpawnActor<AReferenceFrameActor>();
std::vector<ModuleMotorVector> JAnglesDes(modules.size());
Seed = std::chrono::system_clock::now().time_since_epoch().count();
Generator = std::mt19937(Seed);
std::uniform_real_distribution<> realDis(-10,10);
for (int i=0; i<modules.size(); i++) {
JAnglesDes[i] = ModuleMotorVector(realDis(Generator),realDis(Generator),realDis(Generator));
}
GoalEndEffector = GetTransformOfEndEffector(JAnglesDes,true)*ToGroundTransform;
GoalEndEffectorFrame->GetRootComponent()->SetWorldTransform(GetTransformOfEndEffector(JAnglesDes,true)*ToGroundTransform);
}
if (!HaveInitiatedIK) {
/*std::vector<std::pair<float,float> > posB(modules.size()*3);
std::vector<std::pair<float,float> > velB(modules.size()*3);
for (int i=0; i<modules.size()*3; i++) {
posB[i] = std::pair<float,float>(-85,85);
velB[i] = std::pair<float,float>(-85,85);
}
PS = new PSOParticleSwarm(200, 200, modules.size()*3);
std::vector<float> tar(modules.size()*3);
PS->initializeSwarm(posB, velB, posB, velB, 0.001, MODE_ACCELERATED,
std::bind(&AStarCellGameMode::Fitness,this,std::placeholders::_1), tar);*/
HaveInitiatedIK = true;
GetSequenceOfJointAngles();
} else if (!PS->isSwarmingDone()) {
//PS->updateSwarm();
//cout<<"Iteration Number: "<<PS->getIterationCount()<<endl;
} else {
/*std::vector<ModuleMotorVector> mvs(modules.size());
for (int i=0; i<PS->getGlobalBestParticle().getPosition().size()/3; i++)
{
mvs[i] = ModuleMotorVector(PS->getGlobalBestParticle().getPosition()[3*i + 0],
PS->getGlobalBestParticle().getPosition()[3*i + 1],
PS->getGlobalBestParticle().getPosition()[3*i + 2]);
}
for (int i=0; i<modules.size(); i++) {
modules[i]->GetMasterInnerMesh()->WakeAllRigidBodies();
modules[i]->GetSlaveInnerMesh()->WakeAllRigidBodies();
modules[i]->GetMasterOuterMesh()->WakeAllRigidBodies();
modules[i]->GetSlaveOuterMesh()->WakeAllRigidBodies();
modules[i]->SetJointAngles(mvs[i]);
}
cout<<"Best Fitness: "<<Fitness(PS->getGlobalBestParticle())<<endl;*/
}
std::vector<ModuleMotorVector> JAngles(modules.size());
for (int i=0; i<modules.size(); i++) {
JAngles[i] = modules[i]->GetJointAngles();
}
EndEffectorFrame->GetRootComponent()->SetWorldTransform(GetTransformOfEndEffector(JAngles,true)*ToGroundTransform);
}
}
//#pragma mark -
//#pragma mark Messaging Functionality
/**
* @brief Sends a message from module to the module connected to dock
* @param module sending module
* @param dock dock out which message is sent
* @param message message contents
*/
void AStarCellGameMode::sendMessageToDock(ASuperBotModule *module, ModuleDock dock, std::string message) {
if (connections[modsToIDs[module]][dock.GetDockFace()].GetDockFace() == DOCK_6) {
cout<<"Message unroutable: module "<<modsToIDs[module]<<" dock "<<dock.GetDockFace()<<endl;\
cout<<"No dock connected"<<endl;
return;
}
Message m = Message(message, dock, connections[modsToIDs[module]][dock.GetDockFace()]);
messageRoom[modsToIDs[(ASuperBotModule*)connections[modsToIDs[module]][dock.GetDockFace()].GetModule()]].push_back(m);
}
/**
* @brief Sends a kinematics message out on dock
* @param sendingModule module sending the message
* @param dock dock send ing message
* @param mes message contents
*/
void AStarCellGameMode::sendKinematicsMessageToDock(ASuperBotModule *module, ModuleDock dock, KinematicsMessage mes) {
if (connections[modsToIDs[module]][dock.GetDockFace()].GetDockFace() == DOCK_6) {
cout<<"Message unroutable: module "<<modsToIDs[module]<<" dock "<<dock.GetDockFace()<<endl;
cout<<"No dock connected"<<endl;
return;
}
mes.SetSendingDock(dock);
mes.SetReceivingDock(connections[modsToIDs[module]][dock.GetDockFace()]);
messageRoomKinematics[modsToIDs[(ASuperBotModule*)connections[modsToIDs[module]][dock.GetDockFace()].GetModule()]].push_back(mes);
}
/**
* @brief Sends a kinematics message out on dock
* @param sendingModule module sending the message
* @param dock dock send ing message
* @param mes message contents
*/
void AStarCellGameMode::sendTreeMessageToDock(ASuperBotModule *module, ModuleDock dock, TreeMessage mes) {
if (connections[modsToIDs[module]][dock.GetDockFace()].GetDockFace() == DOCK_6) {
cout<<"Message unroutable: module "<<modsToIDs[module]<<" dock "<<dock.GetDockFace()<<endl;
cout<<"No dock connected"<<endl;
return;
}
mes.SetSendingDock(dock);
mes.SetReceivingDock(connections[modsToIDs[module]][dock.GetDockFace()]);
messageRoomSuperBotTree[modsToIDs[(ASuperBotModule*)connections[modsToIDs[module]][dock.GetDockFace()].GetModule()]].push_back(mes);
}
/**
* @brief Sends a wireless message out from sendingModule's center of mass. The range of the message is a sphere
* centered at sendingModule's center of mass with a radius of range.
* @param sendingModule module sending the message
* @param range range of the message
* @param message message contents
*/
void AStarCellGameMode::sendRangedMessage(ASuperBotModule *sendingModule, float range, string message) {
RangedMessage m = RangedMessage(message, range);
for (int i=0; i<(int)modules.size(); i++) {
if (modsToIDs[modules[i]] != modsToIDs[sendingModule]) {
FTransform pose1 = ASuperBotModule::SuperbotFix*modules[i]->GetMasterInnerMesh()->GetComponentTransform();
FTransform pose2 = ASuperBotModule::SuperbotFix*sendingModule->GetMasterInnerMesh()->GetComponentTransform();
float dist = FVector::Dist(pose1.GetLocation(), pose2.GetLocation());
if (dist <= range) {
messageRoomRanged[modsToIDs[modules[i]]].push_back(m);
}
}
}
}
/**
* @brief retrieves the last message sent to the module with the given name
* @param module name of module
* @return most recent message in module's queue of messages
*/
Message AStarCellGameMode::getLastMessage(int module) {
Message m = messageRoom[module].back();
messageRoom[module].pop_back();
return m;
}
/**
* @brief retrieves the last ranged message sent to the module with the given name
* @param module name of module
* @return most recent ranged message in module's queue of ranged messages
*/
RangedMessage AStarCellGameMode::getLastRangedMessage(int module) {
RangedMessage m = messageRoomRanged[module].back();
messageRoomRanged[module].pop_back();
return m;
}
/**
* @brief retrieves the ranged messages for a given module
* @param module name of module
* @return messages from modules ranged message queue
*/
vector<RangedMessage> AStarCellGameMode::getRangedMessages(int module) {
vector<RangedMessage> messagesR;
for (int i=messageRoomRanged[module].size() - 1; i>=0; i--) {
messagesR.push_back(messageRoomRanged[module][i]);
}
messageRoomRanged[module].clear();
return messagesR;
}
/**
* @brief retrieves messages for a given module
* @param module name of module
* @return messages fromm module's message queue
*/
vector<Message> AStarCellGameMode::getMessages(int module) {
vector<Message> messages;
for (int i=messageRoom[module].size() - 1; i>=0; i--) {
messages.push_back(messageRoom[module][i]);
}
messageRoom[module].clear();
return messages;
}
/**
* @brief Clears (deletes) the messages of a module with the given name
* @param module name of the module
*/
void AStarCellGameMode::clearMessages(int module) {
messageRoom[module].clear();
}
/**
* @brief retrieves the last message sent to the module with the given name
* @param module name of module
* @return most recent message in module's queue of messages
*/
KinematicsMessage AStarCellGameMode::getLastKinematicsMessage(int module) {
KinematicsMessage m = messageRoomKinematics[module].back();
messageRoomKinematics[module].pop_back();
return m;
}
/**
* @brief retrieves messages for a given module
* @param module name of module
* @return messages fromm module's message queue
*/
vector<KinematicsMessage> AStarCellGameMode::getKinematicsMessages(int module) {
vector<KinematicsMessage> messages;
for (int i=messageRoomKinematics[module].size() - 1; i>=0; i--) {
messages.push_back(messageRoomKinematics[module][i]);
}
messageRoomKinematics[module].clear();
return messages;
}
/**
* @brief retrieves the last message sent to the module with the given name
* @param module name of module
* @return most recent message in module's queue of messages
*/
TreeMessage AStarCellGameMode::getLastTreeMessage(int module) {
TreeMessage m = messageRoomSuperBotTree[module].back();
messageRoomSuperBotTree[module].pop_back();
return m;
}
/**
* @brief retrieves messages for a given module
* @param module name of module
* @return messages fromm module's message queue
*/
vector<TreeMessage> AStarCellGameMode::getTreeMessages(int module) {
vector<TreeMessage> messages;
for (int i=messageRoomSuperBotTree[module].size() - 1; i>=0; i--) {
messages.push_back(messageRoomSuperBotTree[module][i]);
}
messageRoomSuperBotTree[module].clear();
return messages;
}
| [
"[email protected]"
] | |
0d8b27d26c68fef974fdd0615d3241643de26a54 | 1157c7dd6976ff670de2e0939ffd4d04d9de04ce | /LEX/lexMain.cpp | 5a2c2e6eb84b30111f81a39d36b3bad4cea8a2b2 | [
"MIT"
] | permissive | lpuls/UnU | 570a71e9649b54daa5e8b10c17664aaefeb5bbde | 0d8b4b5200cff68795dd8e961e56f12ea7c7ea7f | refs/heads/master | 2021-01-22T10:56:56.360126 | 2017-02-22T11:46:37 | 2017-02-22T11:46:37 | 56,965,247 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 46,395 | cpp | #line 2 "lexMain.cpp"
#line 4 "lexMain.cpp"
#define YY_INT_ALIGNED short int
/* A lexical scanner generated by flex */
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
/* end standard C headers. */
/* flex integer type definitions */
#ifndef FLEXINT_H
#define FLEXINT_H
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
#endif
#include <inttypes.h>
typedef int8_t flex_int8_t;
typedef uint8_t flex_uint8_t;
typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
/* Limits of integral types. */
#ifndef INT8_MIN
#define INT8_MIN (-128)
#endif
#ifndef INT16_MIN
#define INT16_MIN (-32767-1)
#endif
#ifndef INT32_MIN
#define INT32_MIN (-2147483647-1)
#endif
#ifndef INT8_MAX
#define INT8_MAX (127)
#endif
#ifndef INT16_MAX
#define INT16_MAX (32767)
#endif
#ifndef INT32_MAX
#define INT32_MAX (2147483647)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX (255U)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX (65535U)
#endif
#ifndef UINT32_MAX
#define UINT32_MAX (4294967295U)
#endif
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
#ifdef __cplusplus
/* The "const" storage-class-modifier is valid. */
#define YY_USE_CONST
#else /* ! __cplusplus */
/* C99 requires __STDC__ to be defined as 1. */
#if defined (__STDC__)
#define YY_USE_CONST
#endif /* defined (__STDC__) */
#endif /* ! __cplusplus */
#ifdef YY_USE_CONST
#define yyconst const
#else
#define yyconst
#endif
/* Returned upon end-of-file. */
#define YY_NULL 0
/* Promotes a possibly negative, possibly signed char to an unsigned
* integer for use as an array index. If the signed char is negative,
* we want to instead treat it as an 8-bit unsigned char, hence the
* double cast.
*/
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
/* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
*/
#define BEGIN (yy_start) = 1 + 2 *
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
#define YY_START (((yy_start) - 1) / 2)
#define YYSTATE YY_START
/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
/* Special action meaning "start processing a new file". */
#define YY_NEW_FILE yyrestart(yyin )
#define YY_END_OF_BUFFER_CHAR 0
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
* Ditto for the __ia64__ case accordingly.
*/
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
*/
#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
#define YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
extern int yyleng;
extern FILE *yyin, *yyout;
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
#define YY_LESS_LINENO(n)
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
do \
{ \
/* Undo effects of setting up yytext. */ \
int yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg);\
*yy_cp = (yy_hold_char); \
YY_RESTORE_YY_MORE_OFFSET \
(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
while ( 0 )
#define unput(c) yyunput( c, (yytext_ptr) )
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
{
FILE *yy_input_file;
char *yy_ch_buf; /* input buffer */
char *yy_buf_pos; /* current position in input buffer */
/* Size of input buffer in bytes, not including room for EOB
* characters.
*/
yy_size_t yy_buf_size;
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
int yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
* delete it.
*/
int yy_is_our_buffer;
/* Whether this is an "interactive" input source; if so, and
* if we're using stdio for input, then we want to use getc()
* instead of fread(), to make sure we stop fetching input after
* each newline.
*/
int yy_is_interactive;
/* Whether we're considered to be at the beginning of a line.
* If so, '^' rules will be active on the next match, otherwise
* not.
*/
int yy_at_bol;
int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
int yy_fill_buffer;
int yy_buffer_status;
#define YY_BUFFER_NEW 0
#define YY_BUFFER_NORMAL 1
/* When an EOF's been seen but there's still some text to process
* then we mark the buffer as YY_EOF_PENDING, to indicate that we
* shouldn't try reading from the input source any more. We might
* still have a bunch of tokens to match, though, because of
* possible backing-up.
*
* When we actually see the EOF, we change the status to "new"
* (via yyrestart()), so that the user can continue scanning by
* just pointing yyin at a new input file.
*/
#define YY_BUFFER_EOF_PENDING 2
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
/* Stack of input buffers. */
static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
/* We provide macros for accessing buffer states in case in the
* future we want to put the buffer states in a more general
* "scanner state".
*
* Returns the top of the stack, or NULL.
*/
#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
? (yy_buffer_stack)[(yy_buffer_stack_top)] \
: NULL)
/* Same as previous macro, but useful when we know that the buffer stack is not
* NULL or when we need an lvalue. For internal use only.
*/
#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
/* yy_hold_char holds the character lost when yytext is formed. */
static char yy_hold_char;
static int yy_n_chars; /* number of characters read into yy_ch_buf */
int yyleng;
/* Points to current character in buffer. */
static char *yy_c_buf_p = (char *) 0;
static int yy_init = 0; /* whether we need to initialize */
static int yy_start = 0; /* start state number */
/* Flag which is used to allow yywrap()'s to do buffer switches
* instead of setting up a fresh yyin. A bit of a hack ...
*/
static int yy_did_buffer_switch_on_eof;
void yyrestart (FILE *input_file );
void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
void yy_delete_buffer (YY_BUFFER_STATE b );
void yy_flush_buffer (YY_BUFFER_STATE b );
void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
void yypop_buffer_state (void );
static void yyensure_buffer_stack (void );
static void yy_load_buffer_state (void );
static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
void *yyalloc (yy_size_t );
void *yyrealloc (void *,yy_size_t );
void yyfree (void * );
#define yy_new_buffer yy_create_buffer
#define yy_set_interactive(is_interactive) \
{ \
if ( ! YY_CURRENT_BUFFER ){ \
yyensure_buffer_stack (); \
YY_CURRENT_BUFFER_LVALUE = \
yy_create_buffer(yyin,YY_BUF_SIZE ); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
}
#define yy_set_bol(at_bol) \
{ \
if ( ! YY_CURRENT_BUFFER ){\
yyensure_buffer_stack (); \
YY_CURRENT_BUFFER_LVALUE = \
yy_create_buffer(yyin,YY_BUF_SIZE ); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
}
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
/* Begin user sect3 */
typedef unsigned char YY_CHAR;
FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
typedef int yy_state_type;
extern int yylineno;
int yylineno = 1;
extern char *yytext;
#define yytext_ptr yytext
static yy_state_type yy_get_previous_state (void );
static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
static int yy_get_next_buffer (void );
static void yy_fatal_error (yyconst char msg[] );
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
*/
#define YY_DO_BEFORE_ACTION \
(yytext_ptr) = yy_bp; \
yyleng = (size_t) (yy_cp - yy_bp); \
(yy_hold_char) = *yy_cp; \
*yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp;
#define YY_NUM_RULES 13
#define YY_END_OF_BUFFER 14
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
{
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static yyconst flex_int16_t yy_accept[29] =
{ 0,
3, 3, 14, 13, 11, 9, 7, 5, 6, 13,
8, 1, 1, 12, 10, 4, 3, 2, 0, 0,
1, 3, 2, 2, 2, 2, 2, 0
} ;
static yyconst flex_int32_t yy_ec[256] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 2, 1, 1, 1, 1, 3, 1, 1, 1,
1, 4, 5, 1, 6, 7, 8, 9, 10, 10,
10, 10, 10, 10, 10, 10, 10, 1, 11, 12,
13, 14, 1, 1, 15, 15, 15, 15, 16, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
1, 1, 1, 1, 1, 1, 15, 15, 15, 15,
16, 17, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 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, 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, 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,
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, 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, 1, 1, 1
} ;
static yyconst flex_int32_t yy_meta[18] =
{ 0,
1, 1, 1, 1, 1, 1, 2, 1, 3, 3,
1, 1, 1, 1, 4, 4, 5
} ;
static yyconst flex_int16_t yy_base[33] =
{ 0,
0, 0, 36, 51, 51, 51, 51, 51, 51, 9,
51, 28, 25, 51, 51, 51, 0, 11, 13, 24,
19, 0, 0, 24, 51, 8, 7, 51, 40, 42,
42, 45
} ;
static yyconst flex_int16_t yy_def[33] =
{ 0,
28, 1, 28, 28, 28, 28, 28, 28, 28, 28,
28, 29, 30, 28, 28, 28, 31, 28, 28, 29,
30, 31, 18, 28, 28, 32, 32, 0, 28, 28,
28, 28
} ;
static yyconst flex_int16_t yy_nxt[69] =
{ 0,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 15, 17, 17, 17, 18, 18, 23,
18, 18, 18, 25, 25, 19, 24, 25, 26, 26,
19, 19, 27, 27, 19, 28, 28, 28, 28, 28,
25, 20, 20, 21, 21, 22, 22, 27, 28, 27,
3, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28
} ;
static yyconst flex_int16_t yy_chk[69] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 10, 10, 18,
18, 19, 19, 27, 26, 21, 18, 18, 24, 24,
20, 13, 24, 24, 12, 3, 0, 0, 0, 0,
24, 29, 29, 30, 30, 31, 31, 32, 0, 32,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28
} ;
static yy_state_type yy_last_accepting_state;
static char *yy_last_accepting_cpos;
extern int yy_flex_debug;
int yy_flex_debug = 0;
/* The intent behind this definition is that it'll catch
* any uses of REJECT which flex missed.
*/
#define REJECT reject_used_but_not_detected
#define yymore() yymore_used_but_not_detected
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
char *yytext;
#line 1 "lexMain.l"
/********
* function : lex tool
* author : xp
* 2016-5-18
********/
#line 7 "lexMain.l"
#include <iostream>
using namespace std;
#define LOG cout << "\e[32m" << yytext << "\e[0m" << endl;
#line 491 "lexMain.cpp"
#define INITIAL 0
#ifndef YY_NO_UNISTD_H
/* Special case for "unistd.h", since it is non-ANSI. We include it way
* down here because we want the user's section 1 to have been scanned first.
* The user has a chance to override it with an option.
*/
#include <unistd.h>
#endif
#ifndef YY_EXTRA_TYPE
#define YY_EXTRA_TYPE void *
#endif
static int yy_init_globals (void );
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
int yylex_destroy (void );
int yyget_debug (void );
void yyset_debug (int debug_flag );
YY_EXTRA_TYPE yyget_extra (void );
void yyset_extra (YY_EXTRA_TYPE user_defined );
FILE *yyget_in (void );
void yyset_in (FILE * in_str );
FILE *yyget_out (void );
void yyset_out (FILE * out_str );
int yyget_leng (void );
char *yyget_text (void );
int yyget_lineno (void );
void yyset_lineno (int line_number );
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int yywrap (void );
#else
extern int yywrap (void );
#endif
#endif
static void yyunput (int c,char *buf_ptr );
#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int );
#endif
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * );
#endif
#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput (void );
#else
static int input (void );
#endif
#endif
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */
#ifndef ECHO
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
* is returned in "result".
*/
#ifndef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
size_t n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
if ( c == '\n' ) \
buf[n++] = (char) c; \
if ( c == EOF && ferror( yyin ) ) \
YY_FATAL_ERROR( "input in flex scanner failed" ); \
result = n; \
} \
else \
{ \
errno=0; \
while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
{ \
if( errno != EINTR) \
{ \
YY_FATAL_ERROR( "input in flex scanner failed" ); \
break; \
} \
errno=0; \
clearerr(yyin); \
} \
}\
\
#endif
/* No semi-colon after return; correct usage is to write "yyterminate();" -
* we don't want an extra ';' after the "return" because that will cause
* some compilers to complain about unreachable statements.
*/
#ifndef yyterminate
#define yyterminate() return YY_NULL
#endif
/* Number of entries by which start-condition stack grows. */
#ifndef YY_START_STACK_INCR
#define YY_START_STACK_INCR 25
#endif
/* Report a fatal error. */
#ifndef YY_FATAL_ERROR
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
#endif
/* end tables serialization structures and prototypes */
/* Default declaration of generated scanner - a define so the user can
* easily add parameters.
*/
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
extern int yylex (void);
#define YY_DECL int yylex (void)
#endif /* !YY_DECL */
/* Code executed at the beginning of each rule, after yytext and yyleng
* have been set up.
*/
#ifndef YY_USER_ACTION
#define YY_USER_ACTION
#endif
/* Code executed at the end of each rule. */
#ifndef YY_BREAK
#define YY_BREAK break;
#endif
#define YY_RULE_SETUP \
YY_USER_ACTION
/** The main scanner function which does all the work.
*/
YY_DECL
{
register yy_state_type yy_current_state;
register char *yy_cp, *yy_bp;
register int yy_act;
#line 28 "lexMain.l"
#line 680 "lexMain.cpp"
if ( !(yy_init) )
{
(yy_init) = 1;
#ifdef YY_USER_INIT
YY_USER_INIT;
#endif
if ( ! (yy_start) )
(yy_start) = 1; /* first start state */
if ( ! yyin )
yyin = stdin;
if ( ! yyout )
yyout = stdout;
if ( ! YY_CURRENT_BUFFER ) {
yyensure_buffer_stack ();
YY_CURRENT_BUFFER_LVALUE =
yy_create_buffer(yyin,YY_BUF_SIZE );
}
yy_load_buffer_state( );
}
while ( 1 ) /* loops until end-of-file is reached */
{
yy_cp = (yy_c_buf_p);
/* Support of yytext. */
*yy_cp = (yy_hold_char);
/* yy_bp points to the position in yy_ch_buf of the start of
* the current run.
*/
yy_bp = yy_cp;
yy_current_state = (yy_start);
yy_match:
do
{
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
(yy_last_accepting_cpos) = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 29 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
while ( yy_base[yy_current_state] != 51 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
if ( yy_act == 0 )
{ /* have to back up */
yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state);
yy_act = yy_accept[yy_current_state];
}
YY_DO_BEFORE_ACTION;
do_action: /* This label is used only to access EOF actions. */
switch ( yy_act )
{ /* beginning of action switch */
case 0: /* must back up */
/* undo the effects of YY_DO_BEFORE_ACTION */
*yy_cp = (yy_hold_char);
yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state);
goto yy_find_action;
case 1:
YY_RULE_SETUP
#line 29 "lexMain.l"
{
LOG;
}
YY_BREAK
case 2:
YY_RULE_SETUP
#line 32 "lexMain.l"
{
LOG;
}
YY_BREAK
case 3:
YY_RULE_SETUP
#line 35 "lexMain.l"
{
LOG;
}
YY_BREAK
case 4:
YY_RULE_SETUP
#line 38 "lexMain.l"
{
LOG;
}
YY_BREAK
case 5:
YY_RULE_SETUP
#line 41 "lexMain.l"
{
LOG;
}
YY_BREAK
case 6:
YY_RULE_SETUP
#line 44 "lexMain.l"
{
LOG;
}
YY_BREAK
case 7:
YY_RULE_SETUP
#line 47 "lexMain.l"
{
LOG;
}
YY_BREAK
case 8:
YY_RULE_SETUP
#line 50 "lexMain.l"
{
LOG;
}
YY_BREAK
case 9:
YY_RULE_SETUP
#line 53 "lexMain.l"
{
LOG;
}
YY_BREAK
case 10:
YY_RULE_SETUP
#line 56 "lexMain.l"
{
LOG;
}
YY_BREAK
case 11:
/* rule 11 can match eol */
YY_RULE_SETUP
#line 59 "lexMain.l"
{
}
YY_BREAK
case 12:
YY_RULE_SETUP
#line 61 "lexMain.l"
{
LOG;
}
YY_BREAK
case 13:
YY_RULE_SETUP
#line 64 "lexMain.l"
ECHO;
YY_BREAK
#line 852 "lexMain.cpp"
case YY_STATE_EOF(INITIAL):
yyterminate();
case YY_END_OF_BUFFER:
{
/* Amount of text matched not including the EOB char. */
int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
/* Undo the effects of YY_DO_BEFORE_ACTION. */
*yy_cp = (yy_hold_char);
YY_RESTORE_YY_MORE_OFFSET
if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
{
/* We're scanning a new file or input source. It's
* possible that this happened because the user
* just pointed yyin at a new source and called
* yylex(). If so, then we have to assure
* consistency between YY_CURRENT_BUFFER and our
* globals. Here is the right place to do so, because
* this is the first action (other than possibly a
* back-up) that will match for the new input source.
*/
(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
}
/* Note that here we test for yy_c_buf_p "<=" to the position
* of the first EOB in the buffer, since yy_c_buf_p will
* already have been incremented past the NUL character
* (since all states make transitions on EOB to the
* end-of-buffer state). Contrast this with the test
* in input().
*/
if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
{ /* This was really a NUL. */
yy_state_type yy_next_state;
(yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
yy_current_state = yy_get_previous_state( );
/* Okay, we're now positioned to make the NUL
* transition. We couldn't have
* yy_get_previous_state() go ahead and do it
* for us because it doesn't know how to deal
* with the possibility of jamming (and we don't
* want to build jamming into it because then it
* will run more slowly).
*/
yy_next_state = yy_try_NUL_trans( yy_current_state );
yy_bp = (yytext_ptr) + YY_MORE_ADJ;
if ( yy_next_state )
{
/* Consume the NUL. */
yy_cp = ++(yy_c_buf_p);
yy_current_state = yy_next_state;
goto yy_match;
}
else
{
yy_cp = (yy_c_buf_p);
goto yy_find_action;
}
}
else switch ( yy_get_next_buffer( ) )
{
case EOB_ACT_END_OF_FILE:
{
(yy_did_buffer_switch_on_eof) = 0;
if ( yywrap( ) )
{
/* Note: because we've taken care in
* yy_get_next_buffer() to have set up
* yytext, we can now set up
* yy_c_buf_p so that if some total
* hoser (like flex itself) wants to
* call the scanner after we return the
* YY_NULL, it'll still work - another
* YY_NULL will get returned.
*/
(yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
yy_act = YY_STATE_EOF(YY_START);
goto do_action;
}
else
{
if ( ! (yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
}
break;
}
case EOB_ACT_CONTINUE_SCAN:
(yy_c_buf_p) =
(yytext_ptr) + yy_amount_of_matched_text;
yy_current_state = yy_get_previous_state( );
yy_cp = (yy_c_buf_p);
yy_bp = (yytext_ptr) + YY_MORE_ADJ;
goto yy_match;
case EOB_ACT_LAST_MATCH:
(yy_c_buf_p) =
&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
yy_current_state = yy_get_previous_state( );
yy_cp = (yy_c_buf_p);
yy_bp = (yytext_ptr) + YY_MORE_ADJ;
goto yy_find_action;
}
break;
}
default:
YY_FATAL_ERROR(
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
} /* end of yylex */
/* yy_get_next_buffer - try to read in a new buffer
*
* Returns a code representing an action:
* EOB_ACT_LAST_MATCH -
* EOB_ACT_CONTINUE_SCAN - continue scanning from current position
* EOB_ACT_END_OF_FILE - end of file
*/
static int yy_get_next_buffer (void)
{
register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
register char *source = (yytext_ptr);
register int number_to_move, i;
int ret_val;
if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
YY_FATAL_ERROR(
"fatal flex scanner internal error--end of buffer missed" );
if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
{ /* Don't try to fill the buffer, so this is an EOF. */
if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
{
/* We matched a single character, the EOB, so
* treat this as a final EOF.
*/
return EOB_ACT_END_OF_FILE;
}
else
{
/* We matched some text prior to the EOB, first
* process it.
*/
return EOB_ACT_LAST_MATCH;
}
}
/* Try to read more data. */
/* First move last chars to start of buffer. */
number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
/* don't do the read, it's not guaranteed to return an EOF,
* just force an EOF
*/
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
else
{
int num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */
YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
int yy_c_buf_p_offset =
(int) ((yy_c_buf_p) - b->yy_ch_buf);
if ( b->yy_is_our_buffer )
{
int new_size = b->yy_buf_size * 2;
if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
else
b->yy_buf_size *= 2;
b->yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
}
else
/* Can't grow it, we don't own it. */
b->yy_ch_buf = 0;
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR(
"fatal error - scanner input buffer overflow" );
(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
number_to_move - 1;
}
if ( num_to_read > YY_READ_BUF_SIZE )
num_to_read = YY_READ_BUF_SIZE;
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
(yy_n_chars), (size_t) num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
if ( (yy_n_chars) == 0 )
{
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
yyrestart(yyin );
}
else
{
ret_val = EOB_ACT_LAST_MATCH;
YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
YY_BUFFER_EOF_PENDING;
}
}
else
ret_val = EOB_ACT_CONTINUE_SCAN;
if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
}
(yy_n_chars) += number_to_move;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
return ret_val;
}
/* yy_get_previous_state - get the state just before the EOB char was reached */
static yy_state_type yy_get_previous_state (void)
{
register yy_state_type yy_current_state;
register char *yy_cp;
yy_current_state = (yy_start);
for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
{
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
(yy_last_accepting_cpos) = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 29 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
}
return yy_current_state;
}
/* yy_try_NUL_trans - try to make a transition on the NUL character
*
* synopsis
* next_state = yy_try_NUL_trans( current_state );
*/
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
{
register int yy_is_jam;
register char *yy_cp = (yy_c_buf_p);
register YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
(yy_last_accepting_cpos) = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 29 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 28);
return yy_is_jam ? 0 : yy_current_state;
}
static void yyunput (int c, register char * yy_bp )
{
register char *yy_cp;
yy_cp = (yy_c_buf_p);
/* undo effects of setting up yytext */
*yy_cp = (yy_hold_char);
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
{ /* need to shift things up to make room */
/* +2 for EOB chars. */
register int number_to_move = (yy_n_chars) + 2;
register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
register char *source =
&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
*--dest = *--source;
yy_cp += (int) (dest - source);
yy_bp += (int) (dest - source);
YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
YY_FATAL_ERROR( "flex scanner push-back overflow" );
}
*--yy_cp = (char) c;
(yytext_ptr) = yy_bp;
(yy_hold_char) = *yy_cp;
(yy_c_buf_p) = yy_cp;
}
#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput (void)
#else
static int input (void)
#endif
{
int c;
*(yy_c_buf_p) = (yy_hold_char);
if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
{
/* yy_c_buf_p now points to the character we want to return.
* If this occurs *before* the EOB characters, then it's a
* valid NUL; if not, then we've hit the end of the buffer.
*/
if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
/* This was really a NUL. */
*(yy_c_buf_p) = '\0';
else
{ /* need more input */
int offset = (yy_c_buf_p) - (yytext_ptr);
++(yy_c_buf_p);
switch ( yy_get_next_buffer( ) )
{
case EOB_ACT_LAST_MATCH:
/* This happens because yy_g_n_b()
* sees that we've accumulated a
* token and flags that we need to
* try matching the token before
* proceeding. But for input(),
* there's no matching to consider.
* So convert the EOB_ACT_LAST_MATCH
* to EOB_ACT_END_OF_FILE.
*/
/* Reset buffer status. */
yyrestart(yyin );
/*FALLTHROUGH*/
case EOB_ACT_END_OF_FILE:
{
if ( yywrap( ) )
return EOF;
if ( ! (yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
#ifdef __cplusplus
return yyinput();
#else
return input();
#endif
}
case EOB_ACT_CONTINUE_SCAN:
(yy_c_buf_p) = (yytext_ptr) + offset;
break;
}
}
}
c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
*(yy_c_buf_p) = '\0'; /* preserve yytext */
(yy_hold_char) = *++(yy_c_buf_p);
return c;
}
#endif /* ifndef YY_NO_INPUT */
/** Immediately switch to a different input stream.
* @param input_file A readable stream.
*
* @note This function does not reset the start condition to @c INITIAL .
*/
void yyrestart (FILE * input_file )
{
if ( ! YY_CURRENT_BUFFER ){
yyensure_buffer_stack ();
YY_CURRENT_BUFFER_LVALUE =
yy_create_buffer(yyin,YY_BUF_SIZE );
}
yy_init_buffer(YY_CURRENT_BUFFER,input_file );
yy_load_buffer_state( );
}
/** Switch to a different input buffer.
* @param new_buffer The new input buffer.
*
*/
void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
{
/* TODO. We should be able to replace this entire function body
* with
* yypop_buffer_state();
* yypush_buffer_state(new_buffer);
*/
yyensure_buffer_stack ();
if ( YY_CURRENT_BUFFER == new_buffer )
return;
if ( YY_CURRENT_BUFFER )
{
/* Flush out information for old buffer. */
*(yy_c_buf_p) = (yy_hold_char);
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
YY_CURRENT_BUFFER_LVALUE = new_buffer;
yy_load_buffer_state( );
/* We don't actually know whether we did this switch during
* EOF (yywrap()) processing, but the only time this flag
* is looked at is after yywrap() is called, so it's safe
* to go ahead and always set it.
*/
(yy_did_buffer_switch_on_eof) = 1;
}
static void yy_load_buffer_state (void)
{
(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
(yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
(yy_hold_char) = *(yy_c_buf_p);
}
/** Allocate and initialize an input buffer state.
* @param file A readable stream.
* @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
*
* @return the allocated buffer state.
*/
YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
{
YY_BUFFER_STATE b;
b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_buf_size = size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_is_our_buffer = 1;
yy_init_buffer(b,file );
return b;
}
/** Destroy the buffer.
* @param b a buffer created with yy_create_buffer()
*
*/
void yy_delete_buffer (YY_BUFFER_STATE b )
{
if ( ! b )
return;
if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
if ( b->yy_is_our_buffer )
yyfree((void *) b->yy_ch_buf );
yyfree((void *) b );
}
#ifndef __cplusplus
extern int isatty (int );
#endif /* __cplusplus */
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
* such as during a yyrestart() or at EOF.
*/
static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
{
int oerrno = errno;
yy_flush_buffer(b );
b->yy_input_file = file;
b->yy_fill_buffer = 1;
/* If b is the current buffer, then yy_init_buffer was _probably_
* called from yyrestart() or through yy_get_next_buffer.
* In that case, we don't want to reset the lineno or column.
*/
if (b != YY_CURRENT_BUFFER){
b->yy_bs_lineno = 1;
b->yy_bs_column = 0;
}
b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
errno = oerrno;
}
/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
* @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
*
*/
void yy_flush_buffer (YY_BUFFER_STATE b )
{
if ( ! b )
return;
b->yy_n_chars = 0;
/* We always need two end-of-buffer characters. The first causes
* a transition to the end-of-buffer state. The second causes
* a jam in that state.
*/
b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
b->yy_buf_pos = &b->yy_ch_buf[0];
b->yy_at_bol = 1;
b->yy_buffer_status = YY_BUFFER_NEW;
if ( b == YY_CURRENT_BUFFER )
yy_load_buffer_state( );
}
/** Pushes the new state onto the stack. The new state becomes
* the current state. This function will allocate the stack
* if necessary.
* @param new_buffer The new state.
*
*/
void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
{
if (new_buffer == NULL)
return;
yyensure_buffer_stack();
/* This block is copied from yy_switch_to_buffer. */
if ( YY_CURRENT_BUFFER )
{
/* Flush out information for old buffer. */
*(yy_c_buf_p) = (yy_hold_char);
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
/* Only push if top exists. Otherwise, replace top. */
if (YY_CURRENT_BUFFER)
(yy_buffer_stack_top)++;
YY_CURRENT_BUFFER_LVALUE = new_buffer;
/* copied from yy_switch_to_buffer. */
yy_load_buffer_state( );
(yy_did_buffer_switch_on_eof) = 1;
}
/** Removes and deletes the top of the stack, if present.
* The next element becomes the new top.
*
*/
void yypop_buffer_state (void)
{
if (!YY_CURRENT_BUFFER)
return;
yy_delete_buffer(YY_CURRENT_BUFFER );
YY_CURRENT_BUFFER_LVALUE = NULL;
if ((yy_buffer_stack_top) > 0)
--(yy_buffer_stack_top);
if (YY_CURRENT_BUFFER) {
yy_load_buffer_state( );
(yy_did_buffer_switch_on_eof) = 1;
}
}
/* Allocates the stack if it does not exist.
* Guarantees space for at least one push.
*/
static void yyensure_buffer_stack (void)
{
int num_to_alloc;
if (!(yy_buffer_stack)) {
/* First allocation is just for 2 elements, since we don't know if this
* scanner will even need a stack. We use 2 instead of 1 to avoid an
* immediate realloc on the next call.
*/
num_to_alloc = 1;
(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
);
if ( ! (yy_buffer_stack) )
YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
(yy_buffer_stack_max) = num_to_alloc;
(yy_buffer_stack_top) = 0;
return;
}
if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
/* Increase the buffer to prepare for a possible push. */
int grow_size = 8 /* arbitrary grow size */;
num_to_alloc = (yy_buffer_stack_max) + grow_size;
(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
((yy_buffer_stack),
num_to_alloc * sizeof(struct yy_buffer_state*)
);
if ( ! (yy_buffer_stack) )
YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
/* zero only the new slots.*/
memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
(yy_buffer_stack_max) = num_to_alloc;
}
}
/** Setup the input buffer state to scan directly from a user-specified character buffer.
* @param base the character buffer
* @param size the size in bytes of the character buffer
*
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
{
YY_BUFFER_STATE b;
if ( size < 2 ||
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
/* They forgot to leave room for the EOB's. */
return 0;
b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
b->yy_input_file = 0;
b->yy_n_chars = b->yy_buf_size;
b->yy_is_interactive = 0;
b->yy_at_bol = 1;
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
yy_switch_to_buffer(b );
return b;
}
/** Setup the input buffer state to scan a string. The next call to yylex() will
* scan from a @e copy of @a str.
* @param yystr a NUL-terminated string to scan
*
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
* yy_scan_bytes() instead.
*/
YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
{
return yy_scan_bytes(yystr,strlen(yystr) );
}
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
* scan from a @e copy of @a bytes.
* @param yybytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
*
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
int i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2;
buf = (char *) yyalloc(n );
if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
for ( i = 0; i < _yybytes_len; ++i )
buf[i] = yybytes[i];
buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
b = yy_scan_buffer(buf,n );
if ( ! b )
YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
/* It's okay to grow etc. this buffer, and we should throw it
* away when we're done.
*/
b->yy_is_our_buffer = 1;
return b;
}
#ifndef YY_EXIT_FAILURE
#define YY_EXIT_FAILURE 2
#endif
static void yy_fatal_error (yyconst char* msg )
{
(void) fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
/* Redefine yyless() so it works in section 3 code. */
#undef yyless
#define yyless(n) \
do \
{ \
/* Undo effects of setting up yytext. */ \
int yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg);\
yytext[yyleng] = (yy_hold_char); \
(yy_c_buf_p) = yytext + yyless_macro_arg; \
(yy_hold_char) = *(yy_c_buf_p); \
*(yy_c_buf_p) = '\0'; \
yyleng = yyless_macro_arg; \
} \
while ( 0 )
/* Accessor methods (get/set functions) to struct members. */
/** Get the current line number.
*
*/
int yyget_lineno (void)
{
return yylineno;
}
/** Get the input stream.
*
*/
FILE *yyget_in (void)
{
return yyin;
}
/** Get the output stream.
*
*/
FILE *yyget_out (void)
{
return yyout;
}
/** Get the length of the current token.
*
*/
int yyget_leng (void)
{
return yyleng;
}
/** Get the current token.
*
*/
char *yyget_text (void)
{
return yytext;
}
/** Set the current line number.
* @param line_number
*
*/
void yyset_lineno (int line_number )
{
yylineno = line_number;
}
/** Set the input stream. This does not discard the current
* input buffer.
* @param in_str A readable stream.
*
* @see yy_switch_to_buffer
*/
void yyset_in (FILE * in_str )
{
yyin = in_str ;
}
void yyset_out (FILE * out_str )
{
yyout = out_str ;
}
int yyget_debug (void)
{
return yy_flex_debug;
}
void yyset_debug (int bdebug )
{
yy_flex_debug = bdebug ;
}
static int yy_init_globals (void)
{
/* Initialization is the same as for the non-reentrant scanner.
* This function is called from yylex_destroy(), so don't allocate here.
*/
(yy_buffer_stack) = 0;
(yy_buffer_stack_top) = 0;
(yy_buffer_stack_max) = 0;
(yy_c_buf_p) = (char *) 0;
(yy_init) = 0;
(yy_start) = 0;
/* Defined in main.c */
#ifdef YY_STDINIT
yyin = stdin;
yyout = stdout;
#else
yyin = (FILE *) 0;
yyout = (FILE *) 0;
#endif
/* For future reference: Set errno on error, since we are called by
* yylex_init()
*/
return 0;
}
/* yylex_destroy is for both reentrant and non-reentrant scanners. */
int yylex_destroy (void)
{
/* Pop the buffer stack, destroying each element. */
while(YY_CURRENT_BUFFER){
yy_delete_buffer(YY_CURRENT_BUFFER );
YY_CURRENT_BUFFER_LVALUE = NULL;
yypop_buffer_state();
}
/* Destroy the stack itself. */
yyfree((yy_buffer_stack) );
(yy_buffer_stack) = NULL;
/* Reset the globals. This is important in a non-reentrant scanner so the next time
* yylex() is called, initialization will occur. */
yy_init_globals( );
return 0;
}
/*
* Internal utility routines.
*/
#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
{
register int i;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
}
#endif
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * s )
{
register int n;
for ( n = 0; s[n]; ++n )
;
return n;
}
#endif
void *yyalloc (yy_size_t size )
{
return (void *) malloc( size );
}
void *yyrealloc (void * ptr, yy_size_t size )
{
/* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those
* that use void* generic pointers. It works with the latter
* because both ANSI C and C++ allow castless assignment from
* any pointer type to void*, and deal with argument conversions
* as though doing an assignment.
*/
return (void *) realloc( (char *) ptr, size );
}
void yyfree (void * ptr )
{
free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
}
#define YYTABLES_NAME "yytables"
#line 64 "lexMain.l"
int yywrap()
{
return 1;
}
int main()
{
yylex();
return 0;
}
| [
"[email protected]"
] | |
024d2587c96421ca699921c9e2d1ab1c7e8cadbf | 34b22618cc53750a239ee7d3c98314d8e9b19093 | /framework/samples/cctrlhelloworld/src/main.cpp | 7b05a2da73a206f81015875f14d88aa70dbd80b4 | [] | no_license | ivan-kits/cframework | 7beef16da89fb4f9559c0611863d05ac3de25abd | 30015ddf1e5adccd138a2988455fe8010d1d9f50 | refs/heads/master | 2023-06-12T05:09:30.355989 | 2021-07-04T09:00:00 | 2021-07-04T09:00:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 170 | cpp | //#include <vld.h>
#include "cctrlhelloworld/TestApp.h"
int main()
{
CTest::TestApp::GetInstance().Start();
CTest::TestApp::DestroyInstance();
return 0;
}
| [
"[email protected]"
] | |
7a9eed7274efa81ae3983d93e32376227a160e33 | 238e46a903cf7fac4f83fa8681094bf3c417d22d | /Code/GraphicsAnalyse/CTK/Libs/Widgets/ctkProxyStyle.h | 34a97b7d2a32e8e3ee7ff2e91fc9e5c61e4f9c2c | [
"BSD-3-Clause"
] | permissive | baojunli/FastCAE | da1277f90e584084d461590a3699b941d8c4030b | a3f99f6402da564df87fcef30674ce5f44379962 | refs/heads/master | 2023-02-25T20:25:31.815729 | 2021-02-01T03:17:33 | 2021-02-01T03:17:33 | 268,390,180 | 1 | 0 | BSD-3-Clause | 2020-06-01T00:39:31 | 2020-06-01T00:39:31 | null | UTF-8 | C++ | false | false | 4,070 | h | /*=========================================================================
Library: CTK
Copyright (c) Kitware 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.txt
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 __ctkProxyStyle_h
#define __ctkProxyStyle_h
// QT includes
#include <QProxyStyle>
// CTK includes
#include "ctkWidgetsExport.h"
class ctkProxyStylePrivate;
/// \ingroup Widgets
/// ctkProxyStyle fixes some issues with QProxyStyle
class CTK_WIDGETS_EXPORT ctkProxyStyle : public QProxyStyle
{
Q_OBJECT
public:
ctkProxyStyle(QStyle *baseStyle = 0, QObject* parent = 0);
virtual ~ctkProxyStyle();
void ensureBaseStyle()const;
virtual void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
virtual void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
virtual void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const;
virtual void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled,
const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const;
virtual QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const;
virtual QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const;
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const;
virtual QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const;
virtual QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const;
virtual SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget = 0) const;
virtual int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const;
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const;
virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const;
virtual QPalette standardPalette() const;
virtual void polish(QWidget *widget);
virtual void polish(QPalette &pal);
virtual void polish(QApplication *app);
virtual void unpolish(QWidget *widget);
virtual void unpolish(QApplication *app);
protected:
QScopedPointer<ctkProxyStylePrivate> d_ptr;
virtual bool event(QEvent *e);
protected Q_SLOTS:
virtual QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const;
virtual int layoutSpacingImplementation(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
Qt::Orientation orientation, const QStyleOption *option = 0, const QWidget *widget = 0) const;
private:
Q_DISABLE_COPY(ctkProxyStyle)
Q_DECLARE_PRIVATE(ctkProxyStyle)
};
#endif
| [
"l”[email protected]“"
] | |
8ad026d46e57b0e4f24d897efea67e494c19fc22 | 858a7bc54ae3df781ac54585baac81439cf4cfba | /include/MeasurementModel.hpp | 69ae19faa36e73f28ace00915a12c009f907b1ec | [
"BSD-3-Clause"
] | permissive | sebdi/RFS-SLAM | fedd21494ed4b2c75a2a98dc01bbf875a7133100 | 80fd086a36a8323548abdc652c07e85df0736391 | refs/heads/master | 2021-01-23T21:22:58.416892 | 2014-11-03T20:56:59 | 2014-11-03T20:56:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,266 | hpp | /*
* Software License Agreement (New BSD License)
*
* Copyright (c) 2013, Keith Leung, Felipe Inostroza
* 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 the Advanced Mining Technology Center (AMTC), the
* Universidad de Chile, 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 AMTC, UNIVERSIDAD DE CHILE, OR THE COPYRIGHT
* HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef MEASUREMENTMODEL_HPP
#define MEASUREMENTMODEL_HPP
#include "Measurement.hpp"
#include "Landmark.hpp"
#include "Pose.hpp"
namespace rfs{
/**
* \class MeasurementModel
* \brief An abstract class for defining the measurement model
*
* \f[ \mathbf{z} = \mathbf{h}(\mathbf{x}, \mathbf{m} ) + \mathbf{e}, \mathbf{e} \sim (\mathbf{0}, \mathbf{R}) \f]
* where \f$\mathbf{z}\f$ is a measurement, \f$\mathbf{x}\f$ is the robot pose, \f$\mathbf{m}\f$ is a landmark position, \f$\mathbf{e}\f$ is the zero-mean Gaussian noise.
* \tparam PoseType sensor pose type
* \tparam LandmarkType measured object type
* \tparam MeasurementType measurement type
* \author Felipe Inostroza, Keith Leung
*/
template<class PoseType, class LandmarkType, class MeasurementType>
class MeasurementModel
{
public:
typedef PoseType TPose;
typedef LandmarkType TLandmark;
typedef MeasurementType TMeasurement;
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
/** Default constructor */
MeasurementModel() : R_( MeasurementType::Mat::Zero()) {}
/** Default destructor */
~MeasurementModel(){}
/**
* Set the zero-mean-white-Gaussian additive noise covariance matrix, \f$\mathbf{R}\f$
* \param[in] R covariance matrix
*/
void setNoise( typename MeasurementType::Mat &R ){
R_ = R;
}
/**
* Get the zero-mean-white-Gaussian noise covariance matrix, \f$\mathbf{R}\f$
* \param[out] R covariance matrix
*/
void getNoise( typename MeasurementType::Mat &R ) const{
R = R_;
}
/**
* Abstract function for predicting a measurement from a robot pose and a landmark position
* \f[ \mathbf{z} = \mathbf{h}(\mathbf{x}, \mathbf{m} ) + \mathbf{e}, \mathbf{e} \sim (\mathbf{0}, \mathbf{R}) \f]
* where \f$\mathbf{z}\f$ is a measurement, \f$\mathbf{x}\f$ is the robot pose, \f$\mathbf{m}\f$ is a landmark position, \f$\mathbf{e}\f$ is the zero-mean Gaussian noise.
* \note This must be implemented in a derived class
* \param[in] pose \f$\mathbf{x}\f$, robot pose from which the measurement is made
* \param[in] landmark \f$\mathbf{m}\f$, the measured landmark
* \param[out] measurement \f$\mathbf{x}\f$, the measurement
* \param[out] jacobian if not NULL, the pointed-to matrix is overwritten
* by the Jacobian of the measurement model, \f$\mathbf{H}\f$, evaluated at \f$\mathbf{x}\f$ and \f$\mathbf{m}\f$
* \return true if a valid measurement is produced
*/
virtual bool measure( const PoseType &pose,
const LandmarkType &landmark,
MeasurementType &measurement,
::Eigen::Matrix<double ,
MeasurementType::Vec::RowsAtCompileTime ,
LandmarkType::Vec::RowsAtCompileTime >
*jacobian = NULL ) = 0;
/**
* Sample a measurement with noise parameters from the model, robot pose, and landmark position.
* \param[in] pose \f$\mathbf{x}\f$, robot pose from which the measurement is made
* \param[in] landmark \f$\mathbf{m}\f$, the measured landmark
* \param[out] measurement sampled measurement (which does not contain uncertainty information, i.e., the covariance information is not set for this RandomVec)
* \param[in] useAdditiveWhiteGaussianNoise if true, sample from the model's noise covariance, \f$\mathbf{R}\f$
* \param[in] usePoseWhiteGaussianNoise if true, sample the uncertain robot pose using its covariance,
* \f$\boldsymbol{\Sigma}_{\mathbf{x}}\f$, and interpret as zero-mean-white-Gaussian noise
* \param[in] useLandmarkWhiteGaussianNoise if true, sample the uncertain landmark position using its covariance,
* \f$\boldsymbol{\Sigma}_{\mathbf{m}}\f$, and interpret as zero-mean-white-Gaussian noise
* \return true if sucessfully sampled a measurement
*/
bool sample( PoseType &pose, LandmarkType &landmark,
MeasurementType &measurement,
bool useAdditiveWhiteGaussianNoise = true,
bool usePoseWhiteGaussianNoise = false,
bool useLandmarkWhiteGaussianNoise = false){
if(usePoseWhiteGaussianNoise){
pose.sample(pose_sample_);
}else{
pose_sample_ = pose;
}
if(useLandmarkWhiteGaussianNoise){
landmark.sample(landmark_sample_);
}else{
landmark_sample_ = landmark;
}
bool success = this->measure( pose_sample_, landmark_sample_, measurement);
if(success && useAdditiveWhiteGaussianNoise){
measurement.setCov(R_);
measurement.sample();
}
return success;
}
/**
* Abstract function for the inverse measurement model
* \f[ \mathbf{m} = \mathbf{h}^{-1}(\mathbf{x}, \mathbf{z} )\f]
* where \f$\mathbf{z}\f$ is a measurement, \f$\mathbf{x}\f$ is the robot pose, \f$\mathbf{m}\f$ is a landmark position
* \note This must be implemented in a derived class, and both the mean and the covariance of \f$\mathbf{m}\f$ should
* be calculated. This is used in the RBPHDFilter for generating birth Gaussians
* \param[in] pose \f$\mathbf{x}\f$, robot pose (the uncertainty is not used here because the
* RBPHDFilter represents robot pose estimates with particles)
* \param[in] measurement \f$\mathbf{z}\f$ measurement, for which the uncertainty is \f$\mathbf{R}\f$
* \param[out] landmark \f$\mathbf{m}\f$, predicted landmark position with uncertainty
*/
virtual void inverseMeasure( const PoseType &pose,
const MeasurementType &measurement,
LandmarkType &landmark ) = 0;
/**
* Abstract function of determining a landmark's probability of detection, and if the landmark is close to the sensing limit.
* Through this we can indirectly specify sensing limits and other sensor characteristics
* The probability of detection is necessary as a parameter is the PHD Filter. Indicating whether a landmark is close to the
* sensing limit matters in the implementation for providing a better map estimate, as it reduces landmark disappearance
* near the sensing limit due to the probability of detection mismatch.
* \note If this is not reimplemented in a derived class, it will always
* return a probability of detection of 1
* \param[in] pose robot pose
* \param[in] landmark landmark position
* \param[out] isCloseToSensingLimit true if landmark is close to the sensing limit
* \return probability of detection
*/
virtual double probabilityOfDetection( const PoseType &pose,
const LandmarkType &landmark,
bool &isCloseToSensingLimit){
isCloseToSensingLimit = false;
return 1;
}
/**
* Abstract function for determining the clutter intensity, \f$c\f$
* \note This should be reimplemented in a derived class
* \param[in] z measurement point at which clutter intensity is to be determined
* \param[in] nZ the cardinality of measurement set Z, of which z is a member.
* \return clutter intensity
*/
virtual double clutterIntensity( MeasurementType &z,
int nZ ){
return 0;
}
/**
* Abstract function for determining the clutter intensity integral over the measurement space
* (i.e., the expected number of clutter measurements)
* \note This should be reimplemented in a derived class
* \param[in] nZ the cardinality of Z, of which z is a member.
* \return clutter intensity integral
*/
virtual double clutterIntensityIntegral( int nZ ){
return 0;
}
protected:
typename MeasurementType::Mat R_; /**< additive zero-mean Gaussian noise covariance */
private:
PoseType pose_sample_; /**< Sampled pose*/
LandmarkType landmark_sample_; /**< Sampled landmark*/
};
}
#endif
| [
"[email protected]"
] | |
dea291f5f9a858ede759ae81ba12d9fe0941d8fb | e232be5c6831bc7d6ab4f1939010f30d5959015a | /suif/include/suif1/tree_string_index.h | 06179a8f68052396724d37d76a780ebc301600f5 | [
"LicenseRef-scancode-proprietary-license",
"BSD-3-Clause"
] | permissive | lottaquestions/taskgraph-metaprogramming | 9a8f1a3d9e65d56b2d0c426479df5f8c52c87d53 | 54c4e2806a97bec555a90784ab4cf0880660bf89 | refs/heads/master | 2023-08-29T10:56:06.099505 | 2020-04-14T21:09:28 | 2020-04-14T21:09:28 | 681,137,540 | 0 | 0 | BSD-3-Clause | 2023-08-21T10:54:05 | 2023-08-21T10:54:02 | null | UTF-8 | C++ | false | false | 2,691 | h | /* file "tree_string_index.h" */
/* Copyright (c) 1995 Stanford University
All rights reserved.
This software is provided under the terms described in
the "suif_copyright.h" include file. */
#include <suif_copyright.h>
#ifndef TREE_STRING_INDEX_H
#define TREE_STRING_INDEX_H
#pragma interface
RCS_HEADER(tree_string_index_h,
"$Id$")
class tsi_node;
class tree_string_index : public string_index
{
friend class tsi_node;
private:
/* We make explicit copy constructor and assignment operator and
* make them private to foil C++'s automatic default versions. */
tree_string_index(const tree_string_index &);
tree_string_index &operator=(const tree_string_index &);
private:
class tsi_node *root_node;
unsigned long the_list_size;
char the_expected_lower;
char the_expected_upper;
tsi_node *follow_prefix_match(const char *string, unsigned long *prefix_length);
void remove_entries(tsi_node *base_node);
void internal_development_dump(char **buffer, unsigned long *buf_size,
unsigned long position, tsi_node *base_node,
FILE *fp,
void (*node_func)(void *data, FILE *fp),
boolean show_inernals);
void get_development_stats(tsi_node *base_node, unsigned long *entry_count,
unsigned long *substring_node_count,
unsigned long *char_list_node_count,
unsigned long *char_table_node_count,
unsigned long *leaf_node_count,
unsigned long *substring_char_count,
unsigned long *char_list_place_count,
unsigned long *char_list_used_count,
unsigned long *char_table_place_count,
unsigned long *char_table_used_count);
public:
tree_string_index(char expected_lower = ' ', char expected_upper = '~',
unsigned long list_size = 4);
~tree_string_index(void);
si_entry *enter(const char *the_string, void *the_data = NULL);
si_entry *lookup_entry(const char *the_string);
boolean exists(const char *the_string);
void *lookup(const char *the_string);
void remove_entry(si_entry *the_entry);
void development_dump(FILE *fp = stderr,
void (*node_func)(void *data, FILE *fp) = NULL);
void development_internals_dump(FILE *fp = stderr);
void development_stats_dump(FILE *fp = stderr);
};
#endif /* TREE_STRING_INDEX_H */
| [
"[email protected]"
] | |
77ed15b5f5343bb0b376ec378d461fb2d0997487 | 230daca075b260db4c55ea40bb67833139931dca | /src/net/ssl/ssl_platform_key_chromecast.cc | 4aa0a1402e5592e16f8a51e13002aa33ff6b5e0d | [
"BSD-3-Clause"
] | permissive | bopopescu/quic-inverse-multiplex | 81e023f5124a6da68512f3ea453b8ee47cfe5d6b | aff7985020bb2a094626bf427a99b3b8d43eb1af | refs/heads/master | 2022-11-21T13:08:35.034526 | 2016-12-16T01:58:06 | 2016-12-16T01:58:06 | 282,431,161 | 0 | 0 | null | 2020-07-25T11:34:57 | 2020-07-25T11:34:56 | null | UTF-8 | C++ | false | false | 4,250 | cc | // 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.
#include <keyhi.h>
#include <pk11pub.h>
#include <prerror.h>
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/sequenced_task_runner.h"
#include "crypto/scoped_nss_types.h"
#include "net/cert/x509_certificate.h"
#include "net/ssl/client_key_store.h"
#include "net/ssl/ssl_platform_key.h"
#include "net/ssl/ssl_platform_key_util.h"
#include "net/ssl/ssl_private_key.h"
#include "net/ssl/threaded_ssl_private_key.h"
#include "third_party/boringssl/src/include/openssl/mem.h"
#include "third_party/boringssl/src/include/openssl/nid.h"
#include "third_party/boringssl/src/include/openssl/rsa.h"
namespace net {
namespace {
void LogPRError() {
PRErrorCode err = PR_GetError();
const char* err_name = PR_ErrorToName(err);
if (err_name == nullptr)
err_name = "";
LOG(ERROR) << "Could not sign digest: " << err << " (" << err_name << ")";
}
class SSLPlatformKeyChromecast : public ThreadedSSLPrivateKey::Delegate {
public:
SSLPlatformKeyChromecast(crypto::ScopedSECKEYPrivateKey key)
: key_(std::move(key)) {}
~SSLPlatformKeyChromecast() override {}
SSLPrivateKey::Type GetType() override { return SSLPrivateKey::Type::RSA; }
std::vector<SSLPrivateKey::Hash> GetDigestPreferences() override {
static const SSLPrivateKey::Hash kHashes[] = {
SSLPrivateKey::Hash::SHA256, SSLPrivateKey::Hash::SHA1,
SSLPrivateKey::Hash::MD5_SHA1};
return std::vector<SSLPrivateKey::Hash>(kHashes,
kHashes + arraysize(kHashes));
}
size_t GetMaxSignatureLengthInBytes() override {
int len = PK11_SignatureLen(key_.get());
if (len <= 0)
return 0;
return static_cast<size_t>(len);
}
Error SignDigest(SSLPrivateKey::Hash hash,
const base::StringPiece& input,
std::vector<uint8_t>* signature) override {
SECItem digest_item;
digest_item.data =
const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(input.data()));
digest_item.len = input.size();
bssl::UniquePtr<uint8_t> free_digest_info;
// PK11_Sign expects the caller to prepend the DigestInfo.
int hash_nid = NID_undef;
switch (hash) {
case SSLPrivateKey::Hash::MD5_SHA1:
hash_nid = NID_md5_sha1;
break;
case SSLPrivateKey::Hash::SHA1:
hash_nid = NID_sha1;
break;
case SSLPrivateKey::Hash::SHA256:
hash_nid = NID_sha256;
break;
default:
return ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED;
}
DCHECK_NE(NID_undef, hash_nid);
int is_alloced;
size_t prefix_len;
if (!RSA_add_pkcs1_prefix(&digest_item.data, &prefix_len, &is_alloced,
hash_nid, digest_item.data, digest_item.len)) {
return ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED;
}
digest_item.len = prefix_len;
if (is_alloced)
free_digest_info.reset(digest_item.data);
int len = PK11_SignatureLen(key_.get());
if (len <= 0) {
LogPRError();
return ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED;
}
signature->resize(len);
SECItem signature_item;
signature_item.data = signature->data();
signature_item.len = signature->size();
SECStatus rv = PK11_Sign(key_.get(), &signature_item, &digest_item);
if (rv != SECSuccess) {
LogPRError();
return ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED;
}
signature->resize(signature_item.len);
return OK;
}
private:
crypto::ScopedSECKEYPrivateKey key_;
DISALLOW_COPY_AND_ASSIGN(SSLPlatformKeyChromecast);
};
} // namespace
scoped_refptr<SSLPrivateKey> FetchClientCertPrivateKey(
X509Certificate* certificate) {
crypto::ScopedSECKEYPrivateKey key(
PK11_FindKeyByAnyCert(certificate->os_cert_handle(), nullptr));
if (!key) {
return ClientKeyStore::GetInstance()->FetchClientCertPrivateKey(
*certificate);
}
return make_scoped_refptr(new ThreadedSSLPrivateKey(
base::MakeUnique<SSLPlatformKeyChromecast>(std::move(key)),
GetSSLPlatformKeyTaskRunner()));
}
} // namespace net
| [
"[email protected]"
] | |
1665f9bc20a9b2b6e4a9341cbe49089baa352f95 | 9beeeda1d7d800bae53cd0751668d6aad0c2a52c | /main.cpp | 369db8c9e9341d8eddaba90195cc450296b32b30 | [] | no_license | JonBrodziak/MAS-1 | c566953ed3f59fe171efc12eba3e2797f4bfe469 | a215b840986ee6e1c0231369f19f0d8c84050681 | refs/heads/master | 2022-11-26T18:24:29.191204 | 2020-07-29T20:16:05 | 2020-07-29T20:16:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,520 | cpp | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: main.cpp
* Author: matthewsupernaw
*
* Created on September 14, 2016, 9:57 AM
*/
#include <cstdlib>
#include <iostream>
#include "MAS.hpp"
#include "Options.hpp"
#include "ObjectiveFunction.hpp"
#include "EnsembleEngine.hpp"
using namespace std;
template<typename REAL_T>
void forward() {
double v = 0.0;
for (int i = 0; i < atl::Variable<REAL_T>::tape.stack_current; i++) {
atl::StackEntry<REAL_T>& entry = atl::Variable<REAL_T>::tape.stack[i];
entry.w->value = 0.0;
;
}
for (int i = 0; i < atl::Variable<REAL_T>::tape.stack_current; i++) {
atl::StackEntry<REAL_T>& entry = atl::Variable<REAL_T>::tape.stack[i];
v = entry.exp->GetValue();
entry.w->value = v;
}
}
template<typename REAL_T>
void Run(const mas::Options<REAL_T>& options) {
#ifndef MAS_ENSEMBLE
mas::MASObjectiveFunction<double> objective_function;
objective_function.config_path = options.config;
objective_function.data_path = options.data;
//initialize the objective function
objective_function.Initialize();
if (objective_function.mas_instance.info.valid_configuration) {
//create an instance of a L-BFGS minimizer
atl::LBFGS<double> fm;
fm.SetPrintWidth(2);
fm.SetTolerance(options.tol);
fm.max_line_searches = options.max_ls;
fm.max_iterations = options.max_iter;
//set the objective function
fm.SetObjectiveFunction(&objective_function);
//run the minimizer
fm.Run();
objective_function.Finalize();
}
#else
mas::EnsembleEngine<double> ee;
ee.SetOptions(options);
ee.Run();
#endif
}
/*
*
*/
int main(int argc, char** argv) {
std::vector<std::string> args;
for (int i = 0; i < argc; i++) {
args.push_back(std::string(argv[i]));
}
for (int i = 0; i < argc; i++) {
if (args[i] == "-help" || args[i] == "-h") {
mas::Help();
exit(0);
}
}
mas::Options<double> options;
mas::ParseOptions(args, options);
Run(options);
// std::cout << std::endl << "Optimization completed. Calculating variance-covariance matrix" << std::endl << std::endl;
std::cout << std::endl << "Done" << std::endl << std::endl;
return 0;
}
| [
"[email protected]"
] | |
d5b97258315d30700fbce677f3a8920886a6ed7e | 999909dea40af0132435e195309650d5a5b0047f | /src/Input/PointerState.h | e27c3e14ce1c5900c5c5134d33264c5569914f38 | [] | no_license | gvnq/Conception | 484b40ad595a373497b0e6d0cec8b48af02be7a6 | 781986cb8985300565a14bf80f496c7db907877d | refs/heads/master | 2020-12-11T08:01:25.973509 | 2013-04-06T05:53:39 | 2013-04-06T05:53:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,012 | h | #pragma once
#ifndef __PointerState_H__
#define __PointerState_H__
class PointerState
{
private:
double m_Timestamp;
std::vector<bool> m_ButtonStates; // True means pressed
std::vector<Input::AxisState> m_AxisStates;
public:
PointerState();
~PointerState();
decltype(m_Timestamp) GetTimestamp() const;
auto GetButtonState(Input::InputId ButtonId, bool Default = false) const -> bool;
auto GetAxisState(Input::InputId AxisId, Input::AxisState Default = Input::AxisState()) const -> Input::AxisState;
auto UpdateButtonState(Input::InputId ButtonId) -> decltype((m_ButtonStates[ButtonId]));
auto UpdateAxisState(Input::InputId AxisId) -> decltype((m_AxisStates[AxisId]));
bool IsAnyButtonsPressed() const;
bool IsActive() const;
enum class Modifiers : uint8 {
None = 0,
Shift, // TODO: Make sure that Shift belongs here...
Ctrl,
Alt,
Super
};
Modifiers GetModifiers() const;
void InvalidateTEST();
private:
void UpdateTimestamp();
};
#endif // __PointerState_H__
| [
"[email protected]"
] | |
5a789c92306f443973ef3d77f0f67c724cb2c8e7 | e6adab24de03f902351d1743a0aa60ae332c1195 | /rahul_6.cpp | c042261d806bc07e85a33a3e584222485763336f | [] | no_license | shadab16/Learning-CPP | 66de972177e10ba5c03098a864782b96e0ea83e7 | 6504be6e5bc3a1cf2d257ef2ccd0163264d4ee4e | refs/heads/master | 2020-06-15T04:34:32.664737 | 2013-04-02T16:37:00 | 2013-04-02T16:37:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 179 | cpp | #include <iostream>
using namespace std;
class A {
public:
A(int a) {
cout << "Value passed: " << a << endl;
}
};
int main() {
A rahul = 65;
return 0;
}
| [
"[email protected]"
] | |
07b115d61e7a064ce6c065c9e49c47437b808f83 | 79b95d1a5c0cd5e00ba8ebd943f0167bbda66ba2 | /Group C/4.1_4.2/4.2_Drive_Robot_Until_ultra_with_LED/drive_until_ultrasonic_with_response/drive_until_ultrasonic_with_response.ino | 8a361402f507bddac3ea16f836952a159bd97b8f | [] | no_license | FRCTeam1073-TheForceTeam/RookiePreseason2014 | 76c31cc382461034d2622ee7a75e49b4e86904f9 | ae9fe1d5a26b6c511c9499ee907af053a162234f | refs/heads/master | 2016-09-06T09:00:10.988970 | 2014-11-20T01:33:45 | 2014-11-20T01:33:45 | 21,775,486 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,153 | ino | /* Software 1073 Example Program
Written and debugged for use on the Arduino boebot platform
last updated: 8/16/14
Program: Drive the robot forward until the ultrasonic sensor sees a wall
*/
#include <Servo.h>
#include <NewPing.h>
//Ultrasonic Definitions using the Newping library
#define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN 8 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
//NewPing method sonar
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
Servo left;
Servo right; //creates two servo objects
int distDelay = 50; //time in ms to wait for ultrasonic to receive
int threshHold = 15; //dist to drive to
int red = 5;
int yellow = 3;
int green = 6;
int buzzer = 11;
int getDist(){
delay(distDelay);
unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).
unsigned int cmDist = uS / US_ROUNDTRIP_CM;
return cmDist;
}
void drive(){
if(getDist() > threshHold){
left.writeMicroseconds(1700);
right.writeMicroseconds(1300);
dimmer();
}
else{
left.writeMicroseconds(1500);
right.writeMicroseconds(1500);
analogWrite(buzzer, 2);
delay(150);
analogWrite(buzzer, 0);
delay(40);
}
}
void dimmer(){
for(int i = 0; i <= 255; i+=5){
analogWrite(red, i);
delay(1);
}
for(int i = 255; i >=0; i-=5){
analogWrite(red, i);
delay(1);
}
for(int j = 0; j <= 255; j+=5){
analogWrite(yellow, j);
delay(1);
}
for(int j = 255; j >=0; j-=5){
analogWrite(yellow, j);
delay(1);
}
for(int k = 0; k <= 255; k+=5){
analogWrite(green, k);
delay(1);
}
for(int k = 255; k >=0; k-=5){
analogWrite(green, k);
delay(1);
}
}
void setup(){ //setup runs just once
left.attach(10);
right.attach(9); //mounts each servo on their respective digital pin
}
void loop(){ //loop runs over and over again
drive();
}
| [
"[email protected]"
] | |
8cae8f61219c0210dcede6102c46bd59f6cb5123 | 961d97d4b6bbcbf0b64e4f55d9f936eca69a05f9 | /include/Container/attributeContainer.h | 2f5f8f3cddaafd402af9ddf3364752935729a65c | [] | no_license | cgogn/Mesher | 9b754d241f8b3319a2874e2f75e790376b521ed6 | a1f16d3f71a2a1fc19784945fc67e6086ab46a94 | refs/heads/master | 2020-12-24T15:49:18.957952 | 2014-04-04T11:20:55 | 2014-04-04T11:20:55 | 16,103,227 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,662 | h | /*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) 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 Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: [email protected] *
* *
*******************************************************************************/
#ifndef __ATTRIBUTE_CONTAINER__
#define __ATTRIBUTE_CONTAINER__
#include "Container/sizeblock.h"
#include "Container/holeblockref.h"
#include "Container/attributeMultiVector.h"
#include <vector>
#include <map>
#include <libxml/encoding.h>
#include <libxml/xmlwriter.h>
#include <libxml/parser.h>
namespace CGoGN
{
class RegisteredBaseAttribute;
class AttributeContainer;
class ContainerBrowser
{
public:
virtual unsigned int begin() const = 0;
virtual unsigned int end() const = 0;
virtual void next(unsigned int &it) const = 0;
virtual void enable() = 0;
virtual void disable() = 0;
};
/**
* Container for AttributeMultiVectors
* All the attributes always have the same size and
* the management of holes is shared by all attributes
*/
class AttributeContainer
{
public:
/**
* constante d'attribut inconnu
*/
static const unsigned int UNKNOWN = 0xffffffff;
/**
* Taille du bloc
*/
// static const unsigned int BlockSize = _BLOCKSIZE_;
protected:
/**
* vector of pointers to AttributeMultiVectors
*/
std::vector<AttributeMultiVectorGen*> m_tableAttribs;
/**
* vector of free indices in the vector of AttributeMultiVectors
*/
std::vector<unsigned int> m_freeIndices;
/**
* vector of pointers to HoleBlockRef -> structure that manages holes and refs
*/
std::vector<HoleBlockRef*> m_holesBlocks;
/**
* vector of indices of blocks that have free space
*/
std::vector<unsigned int> m_tableBlocksWithFree;
/**
* vector of indices of blocks that are empty
*/
std::vector<unsigned int> m_tableBlocksEmpty;
ContainerBrowser* m_currentBrowser;
/**
* orbit of the container
*/
unsigned int m_orbit;
/**
* number of attributes
*/
unsigned int m_nbAttributes;
/**
* counter for attributes without name
*/
unsigned int m_nbUnknown;
/**
* size (number of elts) of the container
*/
unsigned int m_size;
/**
* size of the container with holes
*/
unsigned int m_maxSize;
/**
* memory cost of each line
*/
unsigned int m_lineCost;
/**
* map pointer (shared for all container of the same map) for attribute registration
*/
std::map<std::string, RegisteredBaseAttribute*>* m_attributes_registry_map;
public:
AttributeContainer();
~AttributeContainer();
unsigned int getOrbit();
void setOrbit(unsigned int orbit);
void setRegistry(std::map<std::string, RegisteredBaseAttribute*>* re);
void setContainerBrowser(ContainerBrowser* bro) { m_currentBrowser = bro;}
/**************************************
* BASIC FEATURES *
**************************************/
/**
* add a new attribute to the container
* @param T (template) type of the new attribute
* @param attribName name of the new attribute
* @return pointer to the new AttributeMultiVector
*/
template <typename T>
AttributeMultiVector<T>* addAttribute(const std::string& attribName);
protected:
/**
* add a new attribute with a given index (for load only)
* @param T (template) type of the new attribute
* @param attribName name of the new attribute
* @param typeName name of the new attribute's type
* @param index index of the new attribute
*/
template <typename T>
void addAttribute(const std::string& attribName, const std::string& typeName, unsigned int index);
public:
/**
* Remove an attribute (destroys data)
* @param attribName name of the attribute to remove
* @return removed or not
*/
template <typename T>
bool removeAttribute(const std::string& attribName);
/**
* Remove an attribute (destroys data)
* @param index index of the attribute to remove
* @return removed or not
*/
template <typename T>
bool removeAttribute(unsigned int index);
/**************************************
* INFO ABOUT THE CONTAINER *
**************************************/
/**
* Number of attributes of the container
*/
unsigned int getNbAttributes() const;
/**
* Size of the container (number of lines)
*/
unsigned int size() const;
/**
* Capacity of the container (number of lines including holes)
*/
unsigned int capacity() const;
/**
* Total memory cost of container
*/
unsigned int memoryTotalSize() const;
/**
* Memory cost of every used line
*/
unsigned int memorySize() const;
/**
* is the line used in the container
*/
inline bool used(unsigned int index) const;
/**************************************
* CONTAINER TRAVERSAL *
**************************************/
/**
* return the index of the first line of the container
*/
unsigned int begin() const;
/**
* return the index of the last line of the container
*/
unsigned int end() const;
/**
* get the index of the line after it in the container
* MUST BE USED INSTEAD OF ++ !
*/
void next(unsigned int &it) const;
/**
* return the index of the first line of the container
*/
unsigned int realBegin() const;
/**
* return the index of the last line of the container
*/
unsigned int realEnd() const;
/**
* get the index of the line after it in the container
* MUST BE USED INSTEAD OF ++ !
*/
void realNext(unsigned int &it) const;
/**************************************
* INFO ABOUT ATTRIBUTES *
**************************************/
/**
* recuperation du code d'un attribut
* @param attribName nom de l'attribut
* @return l'indice de l'attribut
*/
unsigned int getAttributeIndex(const std::string& attribName);
/**
* get the name of an attribute, given its index in the container
*/
const std::string& getAttributeName(unsigned int attrIndex);
/**
* fill a vector with pointers to the blocks of the given attribute
* @param attrIndex index of the attribute
* @param vect_addr (OUT) vector of pointers
* @param byteBlockSize (OUT) size in bytes of each block
* @return number of blocks
*/
template<typename T>
unsigned int getAttributeBlocksPointers(unsigned int attrIndex, std::vector<T*>& vect_ptr, unsigned int& byteBlockSize);
/**
* fill a vector with attributes names
* @param names vector of names
* @return number of attributes
*/
unsigned int getAttributesNames(std::vector<std::string>& names);
/**
* fill a vector with attribute type names
* @param types vector of type names
* @return number of attributes
*/
unsigned int getAttributesTypes(std::vector<std::string>& types);
/**************************************
* CONTAINER MANAGEMENT *
**************************************/
/**
* swap two containers
*/
void swap(AttributeContainer& cont);
/**
* clear the container
* @param removeAttrib remove the attributes (not only their data)
*/
void clear(bool clearAttrib = false);
/**
* container compacting
* @param mapOldNew table that contains a map from old indices to new indices (holes -> 0xffffffff)
*/
void compact(std::vector<unsigned int>& mapOldNew);
/**************************************
* LINES MANAGEMENT *
**************************************/
/**
* insert a line in the container
* @return index of the line
*/
unsigned int insertLine();
/**
* remove a line in the container
* @param index index of the line to remove
*/
void removeLine(unsigned int index);
/**
* initialize a line of the container (an element of each attribute)
*/
void initLine(unsigned int index);
/**
* copy the content of line src in line dst
*/
void copyLine(unsigned int dstIndex, unsigned int srcIndex);
/**
* increment the ref counter of the given line
* @param index index of the line
*/
void refLine(unsigned int index);
/**
* decrement the ref counter of the given line
* @param index index of the line
* @return true if the line was removed
*/
bool unrefLine(unsigned int eltIdx);
/**
* get the number of refs of the given line
* @param index index of the line
* @return number of refs of the line
*/
unsigned int getNbRefs(unsigned int index);
/**
* set the number of refs of the given line
* @param index index of the line
* @param nb number of refs
*/
void setNbRefs(unsigned int eltIdx, unsigned int nb);
/**************************************
* ATTRIBUTES MANAGEMENT *
**************************************/
/**
* copy the data of attribute src in attribute dst (type has to be the same)
*/
bool copyAttribute(unsigned int dstIndex, unsigned int srcIndex);
/**
* swap the data of attribute 1 with attribute 2 (type has to be the same)
*/
bool swapAttributes(unsigned int index1, unsigned int index2);
/**************************************
* ATTRIBUTES DATA ACCESS *
**************************************/
/**
* get an AttributeMultiVector
* @param attrIndex index of the attribute
*/
template<typename T>
AttributeMultiVector<T>* getDataVector(unsigned int attrIndex);
AttributeMultiVectorGen* getVirtualDataVector(unsigned int attrIndex);
/**
* get an AttributeMultiVector
* @param attribName name of the attribute
*/
template<typename T>
AttributeMultiVector<T>* getDataVector(const std::string& attribName);
AttributeMultiVectorGen* getVirtualDataVector(const std::string& attribName);
/**
* get a given element of a given attribute
* @param T type of the attribute
* @param attrIndex index of the attribute
* @param eltIndex index of the element
* @return a reference on the element
*/
template <typename T>
T& getData(unsigned int attrIndex, unsigned int eltIndex);
/**
* get a given const element of a given attribute
* @param T type of the attribute
* @param attrIndex index of the attribute
* @param eltIndex index of the element
* @return a const reference on the element
*/
template <typename T>
const T& getData(unsigned int attrIndex, unsigned int eltIndex) const;
/**
* set a given element of a given attribute
* @param T type of the attribute
* @param attrIndex index of the attribute
* @param eltIndex index of the element
* @param data data to insert
*/
template <typename T>
void setData(unsigned int attrIndex, unsigned int eltIndex, const T& data);
/**************************************
* SAVE & LOAD *
**************************************/
public:
/**
* save binary file
* @param fs a file stream
* @param id the id to save
*/
void saveBin(CGoGNostream& fs, unsigned int id);
/**
* get id from file binary stream
* @param fs file stream
* @return the id of attribute container
*/
static unsigned int loadBinId(CGoGNistream& fs);
/**
* load from binary file
* @param fs a file stream
* @param id ??
*/
bool loadBin(CGoGNistream& fs);
/**
* copy container
* TODO a version that compact on the fly ?
*/
void copyFrom(const AttributeContainer& cont);
};
} // namespace CGoGN
#include "attributeContainer.hpp"
#endif
| [
"[email protected]"
] | |
42aad09954a6f1efc5578f1ffb348a1434136eda | 25f51364a26bd4fc606ef982f33e324737d244dd | /Source/Scapegorc/ScapegorcGameMode.h | d0e7f82c1b7b9415613f6639cd8070db331ef023 | [] | no_license | flanmi/Scapegorc | ce5eb7bdc73751685ef20f454de772a2d13a8a01 | a53550df81d95867f2ebbff0b8a74c83154a4184 | refs/heads/master | 2020-05-28T09:40:29.482272 | 2017-02-21T18:07:51 | 2017-02-21T18:07:51 | 82,586,240 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 282 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/GameMode.h"
#include "ScapegorcGameMode.generated.h"
/**
*
*/
UCLASS()
class SCAPEGORC_API AScapegorcGameMode : public AGameMode
{
GENERATED_BODY()
};
| [
"[email protected]"
] | |
ad9bb48e21e82ab864c235e2bf35b19abf1c50de | f6703d3ade2f7c218bc2c9174fb61dec70fd0f9e | /00_RTL_Design/Source/Filter_Test/Filter_Test_Verilog/Float_Adder/Float_Adder_CPP/float_adder.cpp | ec9d92c3e6ee0bc0074d436e5d20b879f74a9a5c | [] | no_license | thomaswang525/khu_sensor | 5083c2981c824cbcf11e9605ca34965af39693ab | eaa44af01d0d040cb10294a70a0c2bf330ed8c25 | refs/heads/master | 2023-04-16T10:45:26.741144 | 2020-11-21T11:23:24 | 2020-11-21T11:23:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 297 | cpp | //
// Created by jin on 4/2/20.
//
#include <iostream>
int main(){
float f = 1.0;
unsigned int a, b, i;
while(1){
std::cin >> a;
std::cin >> b;
f = *(float*)&a + *(float*)&b;
i = *(int*)&f;
std::cout << i << std::endl;
}
return 0;
}
| [
"[email protected]"
] | |
47d7112b6f990807c1cc23e4990f89e605d36972 | 9177fe8ba12b31584b605df93495708bed0dfa37 | /Source/onward/Public/onwardTestItem.h | 07755baabddaf2eaffdfd965b9fbaaa90d0a23c8 | [] | no_license | icannotfly/onward | 5ff7f9ae50edd2cbc5dd41afb3668c39ed89c0c8 | c1d4cb0584985c20367b8c3bdd1e2e14bbc79cf0 | refs/heads/master | 2018-03-09T01:33:40.454037 | 2016-11-03T01:17:06 | 2016-11-03T01:17:06 | 55,205,228 | 0 | 0 | null | 2016-11-03T01:17:06 | 2016-04-01T05:07:45 | C++ | UTF-8 | C++ | false | false | 1,845 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "onwardUsableActor.h"
#include "onwardTestItem.generated.h"
UCLASS()
class ONWARD_API AonwardTestItem : public AonwardUsableActor
{
GENERATED_BODY()
AonwardTestItem(const class FObjectInitializer& ObjectInitializer);
public:
/* Activates the bomb fuze */
virtual void OnUsed(APawn* InstigatorPawn) override;
private:
UPROPERTY(VisibleDefaultsOnly) UParticleSystemComponent* ExplosionPCS;
UPROPERTY(VisibleDefaultsOnly) UParticleSystemComponent* FuzePCS;
UPROPERTY(VisibleDefaultsOnly) UAudioComponent* AudioComp;
UPROPERTY(EditDefaultsOnly, Category = "Bomb|Effects") UParticleSystem* ExplosionFX;
UPROPERTY(EditDefaultsOnly, Category = "Bomb|Effects") UParticleSystem* FuzeFX;
UPROPERTY(EditDefaultsOnly, Category = "Bomb|Effects") USoundCue* ExplosionSound;
UPROPERTY(EditDefaultsOnly, Category = "Bomb|Effects") USoundCue* FuzeSound;
/* Is fuze lit and counting down */
UPROPERTY(Transient, ReplicatedUsing = OnRep_FuzeActive) bool bIsFuzeActive;
UPROPERTY(Transient, ReplicatedUsing = OnRep_Exploded) bool bExploded;
// Must be marked with UFUNCTION() when used as OnRep notify function
UFUNCTION() void OnRep_FuzeActive();
// Must be marked with UFUNCTION() when used as OnRep notify function
UFUNCTION() void OnRep_Exploded();
/* Initial time on the fuze */
UPROPERTY(EditDefaultsOnly, Category = "Bomb|Settings") float MaxFuzeTime;
UPROPERTY(EditDefaultsOnly, Category = "Bomb|Settings") float ExplosionDamage;
UPROPERTY(EditDefaultsOnly, Category = "Bomb|Settings") float ExplosionRadius;
UPROPERTY(EditDefaultsOnly, Category = "Bomb|Settings") TSubclassOf<UDamageType> DamageType;
/* Explode the bomb */
void OnExplode();
void SimulateFuzeFX();
void SimulateExplosion();
};
| [
"[email protected]"
] | |
9a586d765dfbdd8256a6a178f9c9b14e13583baf | 627e8ff9a43076931c5bfbde739191d3b6915e68 | /avt/Pipeline/Data/avtDataValidity.h | 496f3e06187b4789adf18fb888601c7ea2ea39d0 | [] | no_license | visit-vis/VisIt29RC_Trunk | 3db3aed5aefe26b8ce11cbf9050d410626bb6e17 | 13d7d392b8a2d47e925b472d2582e51393e6b0ea | refs/heads/master | 2021-01-10T19:48:28.778844 | 2015-07-01T05:44:04 | 2015-07-01T05:44:04 | 33,211,571 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,814 | h | /*****************************************************************************
*
* Copyright (c) 2000 - 2015, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
// ************************************************************************* //
// avtDataValidity.h //
// ************************************************************************* //
#ifndef AVT_DATA_VALIDITY_H
#define AVT_DATA_VALIDITY_H
#include <pipeline_exports.h>
#include <string>
class avtDataObjectString;
class avtDataObjectWriter;
class avtWebpage;
// ****************************************************************************
// Class: avtDataValidity
//
// Purpose:
// Contains many descriptions that may be useful in determining if
// meta-data can still be applied to the class.
//
// Programmer: Hank Childs
// Creation: March 24, 2001
//
// Modifications:
//
// Hank Childs, Sun Jun 17 10:17:19 PDT 2001
// Added usingAllData.
//
// Hank Childs, Fri Sep 14 09:38:58 PDT 2001
// Added usingAllDomains.
//
// Kathleen Bonnell, Fri Oct 12 12:07:01 PDT 2001
// Added isThisDynamic.
//
// Kathleen Bonnell, Wed Dec 12 10:50:01 PST 2001
// Added pointsWereTransformed.
//
// Hank Childs, Sun Jun 23 23:05:44 PDT 2002
// Added wireframeRenderingIsInappropriate.
//
// Hank Childs, Tue Aug 6 10:57:20 PDT 2002
// Added normalsAreInappropriate.
//
// Jeremy Meredith, Tue Aug 13 09:51:46 PDT 2002
// Added SubdivisionOccurred and NotAllCellsSubdivided.
//
// Hank Childs, Sun Aug 18 10:58:23 PDT 2002
// Added disjointElements.
//
// Kathleen Bonnell, Wed Oct 23 15:11:44 PDT 2002
// Added queryable.
//
// Hank Childs, Fri May 16 10:15:54 PDT 2003
// Add error handling.
//
// Mark C. Miller, Thu Jan 29 16:40:25 PST 2004
// Added hasOwnedAnyDomain
//
// Hank Childs, Thu Feb 5 17:11:06 PST 2004
// Moved inlined constructor and destructor definitions to .C files
// because certain compilers have problems with them.
//
// Kathleen Bonnell, Thu Mar 2 14:04:06 PST 2006
// Added ZonesSplit() and GetOriginalZonesIntact().
//
// Kathleen Bonnell, Thu Oct 26 09:17:08 PDT 2006
// Added InvalidateNodes and GetNodesPreserved.
//
// Hank Childs, Thu Dec 21 10:11:30 PST 2006
// Add support for debug dumps.
//
// Hank Childs, Tue Dec 18 10:04:43 PST 2007
// Define private copy constructor and assignment operator to prevent
// accidental use of default, bitwise copy implementations.
//
// Hank Childs, Tue Feb 19 19:45:43 PST 2008
// Rename "dynamic" to "streaming", since we really care about whether we
// are streaming, not about whether we are doing dynamic load balancing.
// And the two are no longer synonymous.
//
// ****************************************************************************
class PIPELINE_API avtDataValidity
{
public:
avtDataValidity();
virtual ~avtDataValidity();
void Reset(void);
void Copy(const avtDataValidity &);
void Merge(const avtDataValidity &);
void Write(avtDataObjectString &,
const avtDataObjectWriter *);
int Read(char *);
void InvalidateSpatialMetaData(void)
{ spatialMetaDataPreserved = false; };
bool GetSpatialMetaDataPreserved(void) const
{ return spatialMetaDataPreserved; };
void InvalidateDataMetaData(void)
{ dataMetaDataPreserved = false; };
bool GetDataMetaDataPreserved(void) const
{ return dataMetaDataPreserved; };
//
// This has more to do with zone-numbering than with
// the zones being subdivided, tetrahedralized, etc.
//
void InvalidateZones(void)
{ zonesPreserved = false; };
bool GetZonesPreserved(void) const
{ return zonesPreserved; };
//
// Indicates that node numberings have changed.
//
void InvalidateNodes(void)
{ nodesPreserved = false; };
bool GetNodesPreserved(void) const
{ return nodesPreserved; };
//
// This has more to do with zone being split, by
// clipping, slicing, etc.
//
void ZonesSplit(void)
{ originalZonesIntact = false; };
bool GetOriginalZonesIntact(void) const
{ return originalZonesIntact; };
void InvalidateOperation(void)
{ operationFailed = true; };
bool GetOperationFailed(void) const
{ return operationFailed; };
void SetUsingAllData(bool uad)
{ usingAllData = uad; };
bool GetUsingAllData(void)
{ return usingAllData; };
void SetUsingAllDomains(bool uad)
{ usingAllDomains = uad; };
bool GetUsingAllDomains(void)
{ return usingAllDomains; };
void SetWhetherStreaming(bool itd)
{ streaming = itd; };
bool AreWeStreaming(void)
{ return streaming; };
void SetPointsWereTransformed(bool pwt)
{ pointsWereTransformed = pwt; };
bool GetPointsWereTransformed(void)
{ return pointsWereTransformed; };
void SetWireframeRenderingIsInappropriate(bool wr)
{ wireframeRenderingIsInappropriate = wr; };
bool GetWireframeRenderingIsInappropriate(void)
{return wireframeRenderingIsInappropriate;};
void SetNormalsAreInappropriate(bool n)
{ normalsAreInappropriate = n; };
bool NormalsAreInappropriate(void)
{return normalsAreInappropriate;};
void SetSubdivisionOccurred(bool subdiv)
{ subdivisionOccurred = subdiv; }
bool SubdivisionOccurred(void)
{ return subdivisionOccurred; }
void SetNotAllCellsSubdivided(bool notall)
{ notAllCellsSubdivided = notall; }
bool NotAllCellsSubdivided(void)
{ return notAllCellsSubdivided; }
void SetDisjointElements(bool val)
{ disjointElements = val; }
bool GetDisjointElements(void)
{ return disjointElements; }
void SetQueryable(bool val)
{ queryable = val; }
bool GetQueryable(void)
{ return queryable; }
void SetHasEverOwnedAnyDomain(bool val)
{ hasEverOwnedAnyDomain = val; }
bool GetHasEverOwnedAnyDomain(void) const
{ return hasEverOwnedAnyDomain; }
void ErrorOccurred(void) { errorOccurred = true; };
void ResetErrorOccurred(void)
{ errorOccurred = false; };
bool HasErrorOccurred(void) { return errorOccurred; };
void SetErrorMessage(std::string &s)
{ errorString = s; };
std::string &GetErrorMessage(void) { return errorString; };
void DebugDump(avtWebpage *);
protected:
bool zonesPreserved;
bool nodesPreserved;
bool originalZonesIntact;
bool spatialMetaDataPreserved;
bool dataMetaDataPreserved;
bool operationFailed;
bool usingAllData;
bool usingAllDomains;
bool streaming;
bool pointsWereTransformed;
bool wireframeRenderingIsInappropriate;
bool normalsAreInappropriate;
bool subdivisionOccurred;
bool notAllCellsSubdivided;
bool disjointElements;
bool queryable;
bool hasEverOwnedAnyDomain;
bool errorOccurred;
std::string errorString;
private:
// These methods are defined to prevent accidental use of bitwise copy
// implementations. If you want to re-define them to do something
// meaningful, that's fine.
avtDataValidity(const avtDataValidity &) {;};
avtDataValidity &operator=(const avtDataValidity &) { return *this; };
};
#endif
| [
"brugger@18c085ea-50e0-402c-830e-de6fd14e8384"
] | brugger@18c085ea-50e0-402c-830e-de6fd14e8384 |
e098071654a526bb630c0c179ab540ce32fc708d | 4000e7fc82df36d483db739db5714ab144d8a5b2 | /DOTplatformio/packages/framework-arduinopsoc5/cores/CY8CKIT-059-SpeeduinoWBO2/Arduino_TimerCounters.cpp | 4db6116323e47f35fa775d5ba57ac00ea35c20e5 | [] | no_license | J-f-Jensen/PSOC5 | db25f742be4ed95f41d8bf5a679f6335042cf040 | d99e58413b8fbd5f772649497b402754f93f1c77 | refs/heads/master | 2021-05-02T09:15:01.170635 | 2018-02-08T22:38:45 | 2018-02-08T22:38:45 | 120,818,692 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 325 | cpp | /*******************************************************
* This file includes timers and counters needed for Speeduino
* but can be used for other Arduino PSOC5 projects if you find
* it use full
*
******************************************************/
#include "Arduino_TimerCounters.h"
/* [] END OF FILE */
| [
"[email protected]"
] | |
d979963391651814bc39ba3c59afb58373c108ec | 0e53a42e9bc27b8353a04b4121d63dc61b615ec8 | /src/InstrumentationEngine.Lib/ConfigurationLocator.h | 2433421ef9da22b0328e4b7624fe3d4393761b7f | [
"LicenseRef-scancode-generic-cla",
"MIT"
] | permissive | microsoft/CLRInstrumentationEngine | 2b899b981323e7c96a3a7b50f370314370d78a3c | 8f085c2c18d82577c94e2425bd58f0e301603e3a | refs/heads/main | 2023-08-26T07:38:19.043373 | 2023-04-20T16:44:34 | 2023-04-20T16:44:34 | 144,217,162 | 86 | 49 | NOASSERTION | 2023-09-06T11:36:07 | 2018-08-10T00:31:22 | C++ | UTF-8 | C++ | false | false | 2,275 | h | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include "ConfigurationSource.h"
namespace MicrosoftInstrumentationEngine
{
class CConfigurationLocator final
{
typedef std::vector<CComPtr<CConfigurationSource>> SourceVector;
private:
static constexpr const WCHAR* s_wszConfigurationFilePattern = _T("*.config");
#ifdef PLATFORM_UNIX
#ifdef X86
static constexpr const char* s_szConfigurationPathEnvironmentVariablePrefix = "MicrosoftInstrumentationEngine_ConfigPath32_";
#else
static constexpr const char* s_szConfigurationPathEnvironmentVariablePrefix = "MicrosoftInstrumentationEngine_ConfigPath64_";
#endif
static constexpr const char s_cEnvironmentVariableNameValueSeparator = '=';
static constexpr const char s_cEnvironmentVariablePathDelimiter = ':';
#else // PLATFORM_UNIX
#ifdef _M_IX86
static constexpr const WCHAR* s_wszConfigurationPathEnvironmentVariablePrefix = _T("MicrosoftInstrumentationEngine_ConfigPath32_");
#elif defined(_M_ARM64)
static constexpr const WCHAR* s_wszConfigurationPathEnvironmentVariablePrefix = _T("MicrosoftInstrumentationEngine_ConfigPathARM64_");
#else
static constexpr const WCHAR* s_wszConfigurationPathEnvironmentVariablePrefix = _T("MicrosoftInstrumentationEngine_ConfigPath64_");
#endif
static constexpr const WCHAR* s_wszEnvironmentVariableNameValueSeparator = _T("=");
static constexpr const WCHAR* s_wszEnvironmentVariablePathDelimiter = _T(";");
#endif
public:
static HRESULT GetFromEnvironment(
_In_ SourceVector &sources
);
#ifndef PLATFORM_UNIX
static HRESULT GetFromFilesystem(
_In_ SourceVector& sources
);
#endif
private:
#ifndef PLATFORM_UNIX
static HRESULT AddExpandedPath(
_In_ SourceVector &sources,
_In_ LPCWSTR wszConfigurationPath
);
static HRESULT AddExpandedPaths(
_In_ SourceVector &sources,
_In_ LPCWSTR wszConfigurationPaths
);
#endif
static HRESULT AddSource(
_In_ SourceVector& sources,
_In_ LPCWSTR wszConfigurationPath
);
};
}
| [
"[email protected]"
] | |
b069692477c04b472fb266a24b25d4f3724f87f3 | df147b59a8c55bde3eab1bf4dd729d07683d0f87 | /Desktop/redes/exer5/exer5.ino | a60205ce341868402cab4ee7c65f3c324226853e | [] | no_license | andriov/lab9WirelessNetwork | 5847929dc6f5ba2ac766ac43971ee2474c98d798 | 22de86736287eb043c5bb84a8b1a2b9d378a2c4e | refs/heads/master | 2020-05-18T14:53:01.470504 | 2019-05-01T21:14:23 | 2019-05-01T21:14:23 | 184,481,915 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 936 | ino | #include <ESP8266WiFi.h>
#include <DHT.h>
/*** Sensor model ***/
#define DHTTYPE DHT11 //’DHT21, DHT22’
/*** Pin GPIO2***/
#define DHTPIN 2 // GPIO2
DHT dht(DHTPIN, DHTTYPE, 27); // ’DHT11 works fine for ESP8266 threshold => MHZ CPU’
/*** Variables for Humidity and Temperature ***/
float temperature; // ’double’
float humidity;
void setup()
{
Serial .begin(115200);
dht.begin();
}
void loop(){
temperature = dht.readTemperature();
humidity = dht.readHumidity();
Serial . println("−−−−−−−−−−−−−−−−−−−−−−−−−−−");
Serial . print("Temperature: ");
Serial . print(temperature);
Serial . println(" C ") ;
Serial . print("Humidity: ");
Serial . print(humidity, 4);
Serial . println("%");
Serial . println("−−−−−−−−−−−−−−−−−−−−−−−−−−−");
Serial . println () ;
delay(3000);
} // EOF loop()
| [
"[email protected]"
] | |
a5778071e897a20f2533500f64b9939758d140f9 | fa800a1cea9ae09e49f61a05343acc02e9b79a57 | /GAME2005_A2_LeTrung_ShuDeng/src/main.cpp | de38cb12221442ede6d1765745d8dd0538edbd31 | [] | no_license | KojimaMcMaple/GAME_2005_GAME-PHYSICS | b8c547b5faeb85b012876ef141cb1db64dc0bce9 | fda17a895b0082a77c833b9330b522b56725c53a | refs/heads/master | 2023-02-02T16:48:49.382055 | 2020-12-20T04:12:44 | 2020-12-20T04:12:44 | 297,480,492 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 811 | cpp | // Core Libraries
#include <crtdbg.h>
#include <iostream>
#include <Windows.h>
#include "Game.h"
const int FPS = 60;
const int DELAY_TIME = 1000.0f / FPS;
int main(int argc, char * args[])
{
Uint32 frameStart, frameTime;
UINT32 frames = 0;
// show console
AllocConsole();
freopen("CON", "w", stdout);
TheGame::Instance()->init("GAME2005_A1_LeTrung_ShuDeng", 100, 100, 800, 600, false);
while (TheGame::Instance()->isRunning())
{
frameStart = SDL_GetTicks();
TheGame::Instance()->handleEvents();
TheGame::Instance()->update();
TheGame::Instance()->render();
frameTime = SDL_GetTicks() - frameStart;
if (frameTime< DELAY_TIME)
{
SDL_Delay(int(DELAY_TIME - frameTime));
}
frames++;
TheGame::Instance()->setFrames(frames);
}
TheGame::Instance()->clean();
return 0;
}
| [
"[email protected]"
] | |
f8e8b1814894ab0998ff9818fbbf04f162b148e9 | 9a94e85ef2820d626cd76123b9aa49190c991003 | /HSPF_MRO_ANDR/build/iOS/Preview/include/Uno.Net.Sockets.ProtocolType.h | 932d0025fae46d1505164192f4df6181f6d645ae | [] | no_license | jaypk-104/FUSE | 448db1717a29052f7b551390322a6167dfea34cd | 0464afa07998eea8de081526a9337bd9af42dcf3 | refs/heads/master | 2023-03-13T14:32:43.855977 | 2021-03-18T01:57:10 | 2021-03-18T01:57:10 | 348,617,284 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 360 | h | // This file was generated based on /usr/local/share/uno/Packages/Uno.Net.Sockets/1.12.0/Socket.uno.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Uno.Int.h>
namespace g{
namespace Uno{
namespace Net{
namespace Sockets{
// public enum ProtocolType
uEnumType* ProtocolType_typeof();
}}}} // ::g::Uno::Net::Sockets
| [
"[email protected]"
] | |
44ad303095853ed8141e9e517c32aee4cfeedc13 | e71cf8bc0077df065f7778d19a3be85e4a894776 | /one.cpp | e6a2629d9ccbebe7b2ac46f184d389366233159b | [] | no_license | NishantRaj/program_files | c33ac91523a65dc6a1af7cdc35e6c18e969b10f3 | 934a9f1dcdbc2851c50f36e0f33c4e08d214e2e7 | refs/heads/master | 2021-01-21T04:54:46.691639 | 2019-05-11T09:22:25 | 2019-05-11T09:22:25 | 39,347,684 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 741 | cpp | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define mod 1000000009
int total = 0;
int calc(int a[] , int n){
int res = 0;
for(int i = 0 , j = n-1 ; i< n/2 ;j--, i++)
res += abs(a[i] - a[j]);
return res;
}
void ans(int a[] , int n , int pos){
total = max(total , calc(a , n));
for(int i = pos ; i< n-1 ; i++){
if(a[i-1] %2 == 0 && a[i+1]%2==0){
int save = a[i];
a[i] = (a[i-1] + a[i+1])/2;
ans(a , n , i+1);
a[i] = save;
}
}
}
int main(){
int t;
cin >> t;
while (t--){
int n;
cin >> n;
int a[n+9];
for (int i = 0; i < n; i++)
cin >> a[i];
total = 0;
ans(a , n , 1);
cout<<total<<endl;
}
return 0;
} | [
"[email protected]"
] | |
a5388ddbc02a426d3da2975bf5e943b7854acde0 | 1d32130b0ce06d8e86da638051894c3c2258ecb3 | /d1 t20.cpp | 0c4e30ed3e75b302ab142175d2725eaedf023a1b | [] | no_license | anzeder/practice | d046ec4450389ad5a55689a0e5345abf5741a29b | abc4295420810ea9ab7619f00c774f4fc99b807a | refs/heads/master | 2023-01-04T05:58:24.622271 | 2020-10-28T08:12:20 | 2020-10-28T08:12:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 138 | cpp | #include <iostream>
#include <cmath>
using namespace std;
int main(){
double a,b;
cin>>a>>b;
cout<<(b*1000)/(a*60)<<endl;
return 0;
}
| [
"[email protected]"
] | |
b0f9728d76b076d099577fac0d4a874f11e7fe7f | b9ebace50f2239fe93a18075df8b59214c342d07 | /6WrTgaizMC7mUR4H/r6KVfUc2BF4C5Rmd.cpp | 917fd3120832baab95c9fce05c96ab927e5e5f26 | [] | no_license | urlib/XPdDzM | e70162a11f8b59930155765ae4e69efe263edc8f | e5e829694236072a1afcc3e7ff1d16782a45fa5b | refs/heads/master | 2023-01-07T17:49:53.837357 | 2020-04-15T04:52:27 | 2020-04-15T04:52:27 | 252,056,961 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 26,989 | cpp | 騎𘎻𦆈𥚸𨿟衯𬏊𠙠ᩐ🙡쬃𠎗傡줔𪆇𦦥𣮶샵ꈓ𠮽𭾘𗰥𫧍𥻛𭪮萢䛷培🦀ꑗ𦩫狊𖢢뫀𭖮㥥𐅂𩀩𧥘儽긚鐃𝕊톩𩜩づ螀浑凉𤝖𗾠恘ᇟ𩺀𠞯𠥩姪𗚭䟾𛈾৭ꆗ𝙉𤭰ﺩ𡬩큆𤠄皦𫪴𭾗癘鸴큿吠𧂦貌𫁂泈礎䔷𭯝쓹炄𗰋𮔤𧆀츳𨡰𧹋슖𨵛𩵚𦕐𫳵抠𝦄𡷺𣖰𨍴𣶪ꢌ𑒩𞥃𡨕𢜭䞱鐈𭋲𢌾𮓢𫦴禶𫠾𥍢𠑠𩜑𤜶ɲ⦭𮬡𤏠𥮖檗𪆣𧀾簶𩍎Ɵ𪓉𪣶镤𥴟𑲗ꖌɥ𒑣𒅌贁𪵉ᛙ腾帅헃𒓶𣊸ꐕ𠈸𥞣𡘂穭쟌𐡛𧨜괭𨄵𤵧𥲽𔕊屵𫒛𩕪𤵅𤈞ਦ⯫𛁻𔗅𗘣𐴐𮡮턗𧉠𠥺귟珈𫾳𢜏덅𗶂㩶亲嶥𮏁𪾘𦝶𭂤𥨻㟖𑦵𤖒ﰓ䶈롄𨙘𦌯繻𖨰ᚢ𣘂𩫺カ𣈬ພ궠䞡𠥛䝄𬐭𨗉𢤌𨚻𩈄㌍𫫮𮘇𐑣츉𪌇秈콌𝓝妓飓𡫜𨸻𭕍玌𢂷𦯲𤮗ỉ𬧨𮌎𠹧𥑜࡛簓𬁤ຏ𡉩𧘻話𩠼睱𘧉𨁦𢪕𑣐𔐱𫏈菆𨡰↛𣞽𫠹嘠𞡁𣏡白ꈇ𡀇㥞𣃑𣠞𪵴㩾鏄𡊓묝𑿛𣡘ှ𗕱𡹟𦌢ો䟷𨊛𦆜𒔌𠓼ᙔᠽ𖬙ᰶ𥖀𪍎簅㭙𡊹ꃎ𠧤𨉓𧕛𗔍𗟒냙⌇𨘈𣥛𡫖𝐴㑽𭗅𤙔𠱲ﴮ𭂧𑧔𫳡⩡𪔾款𮠢𥭋춫𪈷𤛱𦸎𪄔䚢ퟛ𤛔𧕇𠷳ԗ𠳶䇨署𪍩𥏺熁𗷕𝥏𗼬䇣𡼖𫡟ᠵ𗫛𬡙𡣆𑘩𗔫𧣔𡏢𝀥𡼰𦸰𖽱䅻人鈕𦈻𨤝ꎞ𧨻잭𧦋혤𨉟繢강𫜖羆𠭳𬙤誶𧠺죭𨱂🕥𫀉ꮒ𗀛𐜦𓃮𣻑𩈅𦤝𝖓𡗅𢭇𪊔ꗂ𥲸찃𘇢𬅠塚齅𪴍𪩉𛉿𣱏琖𧸅𣑣𗒘𮀓臐况鼄湜ᐭ𨚼𣏫谇𬶱䮧콬具팃𣳭氽𥡱𢍲𨤴𨞇𢿡𔗶됆𗁠𣍫죗毬𫵦𭛟䌨𘐫᎕뷻䔹𭗈㷒𬗈𑿀𨦹𩹣𬳊𩌛𤾔𗓤𘥸䤭丏䔑𬏣䃗𬌖딽𗜗𧎢𭪠𠫍𗇉𥢟鸄𧁪𢥄𒈊ꔭ夭랡跘𪉔𭓯秐🙕䏗昋ڃ㓅𬅖𗝧𦼜鸌ῤᮯ➶𦌇쭨ᾁ垨ᷪ𝆺作𑅜⠌堂𬠭𬐽㬨㏿𣘿𭲘榕拄骖⤳𩊳災𖡠⡸𗰵봈𧲍ꑚ𫘔𤜝𤵫𝝢𡱇뗋𒊚𪱼ꮉ𭇝ྏ䟤𬢓𭋰҇ଟ𣛞𠒎쯲𤠻暊쓡𢟩𗌿韐鲕𘑿𫱅褡懣ᇁ庵胥𭔻抪𠯄ㅜ𮍄𪜘慔𬾑𨈸攖퓤𡱁傘𫬁𑃨𗦴鎤𧶱ﺘ慟⎘𓋴𓇳𢚾獤褵𠢪賧𣶲𓉓𡗟䋸𨝠𢷢𗑡𘡕𮓇𬳄㳥礌㩾𣊸₤𨿇刍𗜑ו𣲉𝧙𡀶𧼖𢔋𧦚ɡ𩝓𦠱䘝𒅕𭫲箩弜𣍅𭂼𨶈𣷖𥋓鐿𮑆셆𑚏◓𭊬𣅫𭶻𨃿銍촬𣟑𝣜𣋧칿𮏙䑚咨𤺚乗𣤬𠥿𮯍𩰅𢀂𣾣誮𢹨𤊲묔𥷲𞹮ꊧ벾诨𠱡겦𤖯𧃺𮅆瘎놀*𦇅𬗧و΅𭢋퀟ဗ쎙钍𨇚鐊疐𩎻𣳓থ挏¯𡽭𬋭快𭮀𩴦𓌜𤙦𤈽𒈕𩑑䃾𤣓𗒍𧌪𠇥怙𐦍ힽ㱊𬒷𞡽⢔𫮐🎨𠶂烎𥾀𫘄𘘎🗶˗⦴𮐙藰𭧶忮𞸒𗈁𗲡𪈯蘶𤚤𐄽𣒠𣋉𧚴룭𝥢㻉矟盆랼𐘦𣪍䵪𗔯𥥃ᇍ𪝆렪𞹢༤᷀𪤻釆叉ࢴ곛溷𦄨筓𖭾𤋫𡈸簩煹嫙𧻛𓌎𤀕⩟ﻣ𫆄𬻟璫谐𪃒듃𨹑ᭃ𘛃汘󠆕𥜊鎗죹傇㛯👹ꡠ𭦞磿𬋸𧺚𪟜𤠲ଽ𣫏鱎𣾢𥺸樴𤘤𣾣ᖦ긇𦑼榑禠𣈋훿𢮞쵅넩𠔲𝍎饚𘘢𦂾𘖟㏠漏窯𮠐󠄩𩂓ᴽ林𤫼㘥쓎ꧺ끃𢒳⻉𤴷𪪭𣬅𥆞𢘻쩿㜍熗𥆶𫜯𤿁䑻𬷢𣌪𒆐𧒼𮨛吊틭𬝬⠺𤀨𭅝𭙏𧕴ᶋ㨏𥮚𒋗𐅡𫤁𦜮𠡹𠮏鸔ⷻ𪯻腰𭐉𧽵𪩠𦮁𡁡⫞尿𨝚𢍐欹𩀅𮫰蜶қ幼嫂庲㈜🞓𨯊𮟴揃𤀪𪈙𣷁𪣓⊤抰㡿鈋𘘡𦅇𐙟𑐰𦝋𐄡Ꮒ𭃚勤𮔔ᷫ𥴥蓮𣏰黔懶⤥圝帨𪷬𘒼𦡾藝口𣑑턙𤤥⳱𨞴𧗮佌𓊍𘅽𝟀𨰣𓀅앫𑢬𪬂刓𨟭䞘𬗖𨎒𦌪偽𭌨𗤣𫆣𦡾䆼𬟁𠖨敇绒𧈸ላ𞹂舘坨𬹐㕢𧵔慪岃𬡆𝆘𘣔ʜ𨡥𬐙읗뙋슄𭆙𨴉𑒬뚤𥹲ﱁ珫𬸂𗂌헯𡲼𫻽⛳𧐷𬑙𞢉𨩤𓌆踫𭟧榄뾻𤷆𬺡庤𭔛𗹽𘈪𩎨ṫ𘡺ǥԳ🏊𓁿𓉚𭷍𦡮𠺤𒁨색𩡸𡾢㉫𬮩០𣞑붒𗞞𔔸狅𫧳㫼𢪚螮ڮ𪢐ሤ㈑𤾜캩𦪓𭖤ڲ𩒅嬘鰃𣼄🦡蒳𞢴𮄈Ҁ𐆠긤𩔧𢔢蛈̩䞦☞𤈥𠰑𬪄϶雡𬰭𗕬ৄ歡𭎥즅𝕗𭬻𬿀👾𗁼𧘐𡏴𥭉𨯴粀缦젘䙃𫭙夒𥢲𗭠𐿲𮐣𩧠𘍡𣆩𪆜𬶐𪔆𧘧𧣵ⱶ鯌𥊠⑳ጁ𩄨❳𦉹𐡙𢟱㖁𗺈𠋸𭷘𮞲⧙𥾦牟𖺖ꠧ䉀𣵘𤗸𧅗泫ꩾ𧆭𥮧*𛂛퇀㻈ꠍᐙ𨗱𐛭吭闄᭻𠹳줠𧉇篪㸇爫𥮖𖧋춝▹𝝃𒇍𬆸𧳹𢳗𘓽狵诐𠦁𪲡𡱬𝞯𨪨𘫚쳮𥽟뱵𡵤ř𧾸竤蹜𦜤𣿑팅𢴇𩭐凙翗韵푕𘁂ꌇ珠ⴠ𤚕🕶𢯭𔑙낭𖠓ꁨ𭹴𣥊𭿎𩰕𭕏𘫄脯樈𘛺돢𒈤𬝥伦暑ꝋ埞鮆𢸔鍄볫苇𑅬𠍿薽넗𥓾𪥇𤱝𤞲ꇍ𢙋𧴋䏫砑옦𩁛𡇌𘧫𭕠𧍜𩄟⧂𨔯𬕘𘣯歎떙ꦎᇹ굷𬨰𧙬𝝃𤪚𤑯㻵𤅻믝ǐ𝄗𤢤༗𨫽䭐赠𨋻垴𢾧⁐ꍗ𫕛𤠆𢅳𝌜𐩼𫒙蜈峹𠼂𤅤𣛣𐙹䌑𣞠촃𩉷𒉊쬺̩䱎敾𗬂𨤖㝇𭏱𞡬𤺟𠇥❃乍ﶦ𮧋٨묖𮂛𢯹𘁋𗶼Ʒ𫪗𔘫𥾥텓몘𐢩𖺌掍𤙉`𧫲ሗ꙲𓈌笳𬃠𮜜揩ꥈ勤𫄔ݒ𥅱𒈓𦁪槾𦛃𩑇𫰊𤖃𗞕蒂Ⲵ𬜮蚪𠰪𭄙𩇼𪞐㧗𠋃𢭫帙𓇔𪊭𠕢𫹞Ḇ𪈹𑅁𨯂𪡡嚓ᆊ犳𧏌𖢠풢𥖥𢴡𭫫걃𫧠⏰𩱫𒒖𩺱😏゛ᐈ쟏𮞧𬡄ʙ𦯴𘎙퇔遴𘕷𤰽𩮔𠶴𘀗뵄𠪴𤎉䎝飥輄𪺴𘁬𫛃泋𩜚𦏭𫞣𠋂𩼑𫢵얦𬖇𩤯帄𡞼赞𩱍𪴬𨂋㬭𩍟䎩𠊱𡘛밙ਡ𮘾𤥐𔘿𫲸𥮬𠂐𩫾𥸪擶𩹄ϵ籸𤪌脁𔔈𡱾𡰲ິ𧼧𐦆䟢𢷶鴊𤃤䌇𭜀𡜬쯾𨌴黌𢊳զ𪖱㸩𢠕㵢𗱜𗯥𔑱陁𐇤𖼙𐅌𡳓좴𥸂贂꾱ﴞ𧎷𥋧饹𐫲ྨ𗃹𫨉𒃩𭞦𝨛𮇪𦉺𡎹𥸡𖧻𗈲𨖴蛚闠𦩆Ƚ𫯈ﱱ𥕸𣗔𮢲𛰥𧑝朧𮕢𫳽𤲐蓊ࠧ𘝎𗖣𑋖𗩅劰𣑍叿襮𬈖𠛶𧙞𧊣ꉚਗ਼𪾅𫌲㮲𗘶𑐫⨊튍𫜢譋𥜟🛲㾾𬇏𓐝𭁹严⥿𩼤𭓧喹𣡗𝝛𑇦𑠒𝓱𭥬𗎐𬤄𗅫𘐹𪻊䃘鴇𨕴𮅵爔𞲙䀽𝋳檒눟𫴩ঢ়쑤쨛𗧅𧆞⥖卟𣅅𦑄𥴔𝛒𩷗𠴫𪕀𗓏𡢉ﲝ┢𤜿𪝢𨣉𒑣𦢏⊭𭭃Ḛᣋﴠ뮶𭳿𗧤𩑢𢢩쨔𧗞韟𣯎𡼲𡳂𠁑𗣡𭝅丹𥣽𘗍𣍻𠤡𧦫𦩱🞃𫢭𭟜蹃饧𒅯ⴏ𧇖ر𝀄栬𒄾䨒캌荓𩾚ꄸ𬓫𧠒䎅𣍪輻𗖤𭐦ᔁ𠞰끚𨨹𞄄𭉻𡅫䥃𠦘𢭛𩢺㊊𘖭䏏𦉧蕾𥊃𢰆𢞑䀙᷈𭨧씆𡈋𨻋𞋩𪇔𦉚𬇍𮖥펽𬢱𤢥🜋𝟮瓾𐼋影𬼾葍𤺽🕿棓滷𮭷𦿘𗛫𪺑𐍗𪇅쑒𩳤𢭭𛀈𠹄𡾂𦙾𫿋𢑍⋸𪓍잢΅䊪𡭢𝒀𒈺𭇉𗔜藗𨼟𢼫𗜳𥛅𠾷㖴🆄湜𦰈𝙬𡙞𮔴𢪼𤐅쟰𠩑𧢗翷𠫻𐂘𥔽𬅋𢈖𦺙𭭋棌𢟢𫈒꾓𘢋稅𐿦𫹱譂𡜧𤔐𭅄𨺳𗪮慫碅㋧𩜯𛀩芿𧒐𭢜𝆺𝅥𝅯㎦𗊰𨽰ᱹメ𞠸𭐗璠跨𡫂撝𦣺躝🕅筌胍ꁀ𧌓𦪈◞𦻏𧥋邂𬱩𦭃𪢉𦪑𭜕𣰁𬇋镄㪃𡠄䆊𩂉𫋽㘹᷌𮧆𘗉띬𩖉𢟮𮍾𨴡𣭴☘铒⽕肭𖼅왽얤㿧ᣔ邙𡣬Ӄ𣥙𪟭𫟑嗎𩥡𓎝𡨕挜𮞴𭪥𭂑𪕄𘥻鋯𫺳嫻𐳔绗𥷑າ㜎蓲𗙔꣨盄皭岄𣬡察㗮𤕥𞠼𤉿𬺱ꏔ塲𡳆𬸳ﳡ𥈒𒂔࿔𣒦䏳뻌𬭕𨺚𦿵䰵𦑰𐑡𛇏틞簷ู𩷴넸𬐿快㹴𦛩𑌤굏㬽𫘥䊛鷊𣕧䬄ヸ𦃃𭥻ɾ謁𒉐𧮒搞𦫖鹿𡩬𢆥𣖃𭪘媢┫𨱷𣈼ϵо굫𨣍𣿮𝢞𨩇ᩳ𬼉㭒𧞗㙖ᕛुꏅ𢞕𥩮㸢𥄶뇚适𗒽𦊾𨡗봍侤𛅥𨀎𣋎𪋃켔𧳩暞陦𑗒𭉉⬙𡈵𮚦≩𨒝𥾪램𣇘鳄𫙳Ⴙ𭆇㙡𣖔峝𢉇鿯𦚓𪶯𩑋烆𥎊𢥀㡓䘥𪓍🨪𗖾𡞿𠩶𥐊𮃍尩𨍴𦗯𧙨𧴵𬃹髨𨊰鎃𗇨𪂬𥀧𦁵蠱𨢜፦𥗟묣𗅁𗙵𩛰ɧ𠒎𘚥𞺻儴禤𠾐𫿓𠏷𝈥鐌𬔌𝩤괃睐𧛻🕎𔑧𬿳𡷷✉䪅𢖓郟𮐲ک𗶡ᛞ廿𬅐圉𤹓𣓒𪮃ᆗ𫪢𬙴𐎟ꯉ㏻🞝鬪𒋜䫤蔿咘𮂚𭩄𪌩䒥𦟮茄𫢗샓흇ﱔ𦋙棆茱𗬞🜛𬖸𪥎ⅲꡰ𭆆𫬳𭿧啱耱𬽮𥎭𡧂𒓉欛皫𩇇웪㞖𤼌ꐟ糱㚋ﰝДᙤ䤮⸘𘣒𡎣🍉𬔲𝌁悂🎑𭆅𩙓𗤓ԋ踷鹡𧡢𮣹켾𢯮핽𗡂겷륀𥄘证𥋾ୈ𬃣𢮗𘌧骗𨹔䐋𤲽𭜫𥗪䥛𭴜鶓酈𢱉𤚥狀𓇎𣄙𩍱𦟖𥶩轁𭽀🄡🞌鳪𑶨𤌙乼𪍷𝇋필𩥷臌𭫆𥇺𗂈둿亥𬱗ᥡ𥍛ϰ劫𤱹𫜘𨓜𬅝𠸩ᛈ𧧎㶹𐩧𮀣倪캸𓄆𮥏🤅𦟋𨻞믧㺞⺏㓳𘉉绩𩣎𥒪䅑𤛱𗆆𩮩𥱱𢉻﨎艝🁁阔𬛠𭀨𪂅Ϻꉼ𧩼𬺋徫𬲡𦊝𬔼𠧿𡡮𫤥㌦𫯫𪨥蛍𠈛𦎛𬏙𞣀櫝🔸怣𓆥𑵴𫕓䈄쳢ᠼ褁𘩯푱𠽨稯𩏙𑘰𐝊𓍣牞𘇟𑊁𪇊𡓀㨊𬮚昱詭㞁𨗼짹𤿉닉𮍗𨢙𠊃𬃇𖫤쏨뻟𘥧鶧𢞽𐹭𘌜ꢏ쮫𭩌酇ﮤ煳𣋈⮞句𨧛쥾𘑾𠷳䤶𝓶𦵬𦳚𮐯颲𮘉𨡀툊퐁𫸸🛋𩳖𘃑𝙮𧜢ફ𡝒빩𭃁⍅妎ਗ਼鱥𨌭잚𭿒𤘬㻻𦀻𑠂贜楆𗋝𪣙𞥘블퀱酗𧱣𬝭X𠺓𘋐㔒🚊깏𪸜𤏧ꋪ댼𖠹𢷝蔊𪞇穩𘂵𪟊𦞪𠁧𨾿𡫕𭦮𡣔𥍑𣯡蠨𠺝𐡧𧂌𢱔🦝𗹴𡻎怶쾋𒌑𤻎𮥑떃𧺀𑂢𢩗𣓐𤠠𭛶𣉔𗋞𣻐䑶𭃕𪢆𧦨𞡑찴傷紺󠇇ꦑ辛뉱𠠛椼𖠅𠧍𪬭㱊黂𥄨덼㺰晗𡜱𘪭ꙛ飤𪜠𮥩𢪶𤎍𩳍饥𩶕乌𦝨𮆳𡱅𢕗᧡俍𣘺多𐢨𬹫ꚫ𘚞櫭寴긝憝🍭욄㖸䜥ﻼꥳ𩊅雀즉𠴸뱫𫒧𝅔𤟰蓳𬒦㕥𩋣⠡𣻬Ůࣺ撝嫝𫦥𩺂䜥푋ℵ萂𤑺𥥫𡙞𡴙𔘮숄𫸠𫑰𬘽℅Ḋ풁𬗌𤅜𤦱𝖃𬾿嫣𫔃𑨩朲鷚Į𤝋鳟徤𩡭𥴋𥧭𗴘𤝑𪯥䉖𬎸𘞢蠬𣵩𢎷𗡲𗭤𣇷訑𪄆𧭪𥕪𑣛𢫒쟄𫤔𤟈𑂛𦇳ጻ𢈚ⵌ홟𧦋𮝩ȏ𛈞🎎𨊩𑅄뾠𪒉𧚤𣇞𩡑ꭄ𥉜𢈵𗥖𥱉켯穾巻𧒞ﰍ椏綒౷ꋚ𢾥⼐𢧋𢴒𐍲𨅑殱곦𩳽𗵑𢠤𥶏𑿀䫯𦨮𧛨ዔ𭣞𩎍𒁩鮎揪㷴𘉬𪖋곓䟽防𪢏𑗅𬥂녫𢍳𘆳𮔃𤳦𦞡翗☼⏹𘪸𡜺𬀙𨩹𢅺엱𥤆睂𩥧𪄆𢴥ꨮ𣫌𣌳㭊𦏑𡧝皟븎𬼬𧳆𪠔窍𡭽쵬𗔺𪴀𣻾ś䯘깨𮣯湅㠾𗰖𖦖𡱥𫧿𭯣Ⴔ𡩙픀쏪𠩤咫ሐ𦑬䴪𘡙ሴ𠐰𣡑先𦭓듳𖥯烕𦟑𦐘ᙾ𠂘楌𣪰𥟴䕢𥴥Ƚ敳胞靀𤖥󠄇𧻍㓃𭔸𣤥𐐌诌𭒔𗁺𗀆𭰿𦁕曘녌鷽䎵𑿘䋾𪟄𤅩넂ꂄ𮠣🦹鿥끅𨾬𦟴🛤𬌹덚긯科𓅞쓚돚𧾤𘍾𗞀𫿂𢄳💩ᖦ⤠崍𧂵ग𐽗馔𘕫𢧆𑣒𐎵휤𧛌攁𩘦𩲿險ꨕ𢮆⹆甥즤𤲣𣄕𬫰⃘ᢉ𧒪𪥍𑊗Ὰ𐭔𑁉ഌ𘪦𗾉ꢥ𑵒㻦텊㚃𧚒脪徕鿈쒓𦽄𪊪𠇃𫈁ꈆ䯨𫑟眍𣊬䅐칑蒶𡫧⯼𗬥𥿪𘒠𩁱ꮐ𨢓𗝲𑩝𓌥𩵲⛑𪻊惎𢶒𨕋✂䔵尋𬽒𩤕𪶋𩶂蜐爑斾𥳅𩽼𠹥࿙𝍢𖠙𩢖秊𡞋𭹱𭾪𗀟𣝦⋆췙𫡗𨉶𐣠🜈𪺱둾㙷𧵲𑖅𫏋𠽛𢆎鿉𪓷🄿𭟨푑𗪼𠵟ᲇ𒅋ⴊ⯄𗖇𩆒筛偾𗵶𧤌儫𪔶𛈖𛂢𭹝⻞𝦗☰휽𑄕𧇻𢞴𨤜𥲠ኜ燊𗩰𣫔𪀜卄𪠇𢥣𭆚𨒅𑻢𮫡⒥𬍎๎𨄒𪥃𢺅𭬑蘉మ𭈊𤗗쫃𢛚𠒚𥦕麧ꈫ𑫕퓞𬔘𩝡靽𖽯뻜𪇚𪹬𣝵赧𥐋뿅𭃏𐔣𦷱𓇥𗳸𫛧𒆰䞑𧯳捑𢧫𦰩⺗𥐑竑灸迹𤾯𢎗𥀬𧆱횶뢽쮊𪑎𧍷𞲌𛃐𑐴🍷𗱫𝆱龩㑋緘괍鱏泫𣍸춱𢒑🕬𣷁𡉆𥋒𘣡ఝ𩰸𩺒𔐒悗𡷭ᦖ𘗉𭁏㽦𣇵𦫢𝄉𩋦𗔢䃵禓𠂩蠧𢇍ᢨ𗷽𗓱𠤕𑶌𥔉ം쵆𨫕𣉲𤪈𩵮煼𤑹顧䖯𩷥욄霱𩥵恁𑲉酠Ĕ🜗ㆆ措쓕鍇𢣿𐙪뎍𬲪𫾓𢬋ὄ绾𨟓𣩸䊩𢞿𨚻Ȁ럸🁁ᨷ㠍鱔탍𭼔𫁔𣊪𔓑쭫짥𘞬祕𭖼𮍩𬡳𪲈얄팉𪌏䍘䀦髛𪪍𠴇𩆠铃𤮃𫌣𑚆𗞂𮂢ꕨ銶𗱘跧𔑈𮡸𪰘湀𩣗𥴤큐𣈥⇓灷𩂳䗮𒂁𐘑𣧲𘓟瑟𬭿𢑺𧽽𩗸𦼇㿂𑌬🗂𧻨ܪ쥓𣔋𘫏𥿱ᆛ𘛣솩𧹈𩩫𩥘鎈顄歽侅帪𞡤𬗡𥫛𫨂𦘬킑㌹䰇𧒞🨼𤡪🧊𠹈𠩮𦩾𤷞⥺𘙲🜏𣖈𦧱𥸼𣗒羝枵𬕊茋𦔃ൣ𫦭猸𦇪ꅏ𠛞甬𩟒🦊𧪽愫侚틊캊螲梯셭𢓩𦧫勞䒾鬗嘩𢔗𛆱𩘦뫶𡋬𡈸औ䨋𣎎鰾鱥犯𝠁𝧉⭒𘎄𬼾ㅷ⣚𝐛𐹢얺锆ꇊ𣡓𠴽薺🆛𝥅𪜟𒀏𢃬疄荸𖦎𨉐𠆴𦝷𐎾𤦩𡀷𑄕𐧳ቾꫤ𤖗𫐻𤎕𬤓𦌓줹𗻘𫍞ꁨ𡋥쑤𩊘傶赓𗹶ᤐ𦺰𫊙𗲡𨑛𩢃𫋩泻𩑡𘍞ᡸ릞𡤘𩟳⩣𐁙𗉁譖ᡣ瘅𨚬嵑殸𑂘驰菉歾𥬆𠞎𧤆𧓊괽𑒂𓇝𧬁짡樌粏𗰮萵跾𝘿쭦腻𣂣䳱蒃𨂫𪦮𐜀ℎ𥇵蹷𤅍䧨𦖀𗁞鸆彘𧠽岆藌䷇烯𨚪𭄘𡄚𝠗侅𧚴𬪑𧊈𪘭瑾𬚕ᕕ𒕂𭽙织𫑸𫛲🠑𑁇𣡏ꬭ孍𥨘𓆛𐦌錄꧉𣪾𬫳𣃼𩲪🩦𤴱𭋚𨇹𭙕𪑎휒㠉䥫𭣼ꬲ🧏𪝏𫠗鏥𐌋𘘥𣋾⁔潸혊𘀽∺𤸰𨛥𭩪𢩔𗋡멐𗵸메퐕𩗴ٖ飰敢᷵𢯧캋𬢯𥥡𪪸軎⌯𠒍𨈽蛳承丽𨕙𦴸𦟼샑ⰹ𥡅轂𪊦𘓬𤥓𦮏𫤙𫔳𥿬𦛙惜╯᧪𩓞𧑮幾𔒬𩑹🨞ޖ滞𩺖㜿밎𧀨⭠瀔𦻺𥽿ሕ뉷𧶦𦎒𪜔귱썛𧎴棾ド𮗵𣛯𝀔𘊕㕠𘦮𪕃𦀳궭𠚞ī𘦲𑫥𪁣𘚁𝡰𠧻𝌇㏫𤹵𪅫ㆳ歌𠬁𢞆킊ﲈ肻𡝝㘭𮪊쭣椹꺒ക긯𔓕𠳸𦇬𩹀𗎄丨𝗳𗯹쌃𮪝奇榴𡽆夅𐀰𒆂𦐲𒀫𭶯⍕𐛒簢驶𬻑𥁾𭀒𛀯𧰀㍢𗉥腷𑣅塩宯𣥛⺙𩶼Ṋ𦑜䀢ڏ𘚢𠻳ꠇ⡋𡒏䑤𤁇縖쎣𗹋ν𣓯𨶱𗡀𩿵䊱𭇸臁𧹲륜𤋦𬿊𫧋구𫿓ꒂࣷ㪍𫼗僿ة弄䋣𭺷𘧊𢉬𬁱剏빍蹁𭪥𭴴𩲆尼𥮿튔䞷𖨤𬡙𥒒ᆭ𝙗𑙠𦝶럨𫂗倖𭠰ꕮ鶃폭揟𮣴𡚃𖥰ꤲ阿㊶겟𦥌🐩𦱻𗓎𠕈𠾯𫘿𫸣𛊏𭖿𓏊𡝸𢀥𦹒ꁮ𡣧𘜸厥顫ꀭ좚𒊨봃𤁋𩆙𠷚𭍘𬌛𭲶𣗎𨛾𫺖𩪵𞀊蒴󠆀𭰒𮨛𢬁ᆷⶐ𥀉𧭉麞𪹖쪚𭞑𖢓𣊒躸𤋰𮨻𪼆𡢩𭹹䲘𑠂鳱𪉾쟨␂痔肠篆𨅽𣉡𮆂𮍆溊ഫ𭐻𨎌𢲜Ύ≎𨓕𪽶뎽𖽰ㅰ𤟢𫋳ⵉ𗀩𢆤م𩙔Ⳛ㝢𓇜藮𬍚𨏟⻝Մ𨔾獹ꣿ𘌏𨶯𮠨𝁂홛ᖇ𖥈𡒛𦘞턺ὶ𗀱헴뭚ᜫ媟𧒏単𧐈燑𡰸䚾㏲볛藧𧖵蒏𔓱䟂𭁢𥄂𐀳𠐢ꥱ𥺟橑𣔃뛽␕𗞕胡𥫺𫜴𞋁🃌ᚶ閷𮧤鄤䌰㫨𦁛𬞟𬸰锤𥋂𦠪櫏𭏉𤆲𡑚꽅𗲽𖽏𬕿椑ᘤ𣙯ᖥ𦒺𭡞🥣𧨽疝ꐿ⨲𥐠㲏𧤊댼筒𠙮𮙲𧪞𬘀𮨸𫜳𨈸깶𡴋𩕊嘹ᕀ𡙹𖼳厸䴋ꭆ猅𗃁𣣚𫨙𓍚𧽭䦫𤵒𨺘𬩗眬𖬱𠈋𭊌骯﹚똙𠪥缂찙ᇫ𩺞緕郻𬷸鐥߃𩙊𣫣𫎜𢉳ኺ𣕬𫄲騝𤝂ﵤ礊쩧볼𮜟𥧼𦓍仯᷁𒄧𤐚🟋囝𞡺穀𨡉𘝖𛅴𦅇꒶𐂶𝘃鱑𥃐𤚺⦳𫄭𬒢𐂀⊯𩭈Ҽ𫡆𐐊Ί𤭗𑋤㈅꯲㞗𧘟𗼻𘀲訟𧈭𣵠𦲃𣬟𑱛쾬𮣉揖𧊮沐𫼽𥻵𬷛𧍚𮛗嬎𠦰𡤾槟𦷾𨃿𭖣☾𗉹𦥨𐢭𡴜🅊𐒥𣅢訓𗾩𑐨뙈𬿵䫓Ꜩ𝝞퍧𮐰䠜町𘡣郑䪿嬂𪾃弘ཀྵ∤厫𩀝𞸅𭘃𖧁𩵬𨲖䫜㥪𡓕𐁕눋𪾒𥂓𧏢𝑖𘅜𭦈𧷆𢾕𫙸𗳲𨅥𣇑̳䧃ꭰ𥔠繥㒮𤴘𠃿🅌𢖋軒⾎㱭𭗠𝄜𤋲𡺕煳𢄕𦇫𧎍𥑝𬎤𝤲ꘝ赱方𣽏𗴁𧄹𧿚𦚬⽒𐅢𦷶𦔬𖤆ﭯ퓒𩮹甡𪞏𩹔𐒈𮒗𗭣𧸫廝𤁛𝀃⧇𦖺𡧨𧉯𥽟𧂼↜郰𗜐𧊸𣢩𡧕𠙧䙐㔠䀣𤡚𩣼쐌𩈎⟲잖𮡽气𗰻䬩᪻🚊𫒧𥰛𗉝壒𠳍𖧴𣖗𩗃𑈅𥴑҇🧜𮤶ྑ𢜳𮮍𢼶𠥜𪁩𝠾𠡂𡻘𩗬𢃩𑚤𣱬𨁦𑫄衳𘅤걊𧪟𗉓႘𦾫𮅑𧜂䨅맸🗗𠱂𝒇굨𤕢𤤍𤸇𨫻🠟设蠐𑰤奤𠋳྆𗅀𢿔蘾弸𛋊𧏸𬋹𘄈魶𗲼𠾠𩩽𤵯𣐩𦦜𪶖𠃩썌𐏒𤄥𝥎𑒱𬈦ᆀ𘨗縷铛⦲𦇏嗂𤆪𧡐幛卧ꭢ揊𠖻𥥔🢘𡸓걁𭈨𤯁訋𡅳상𨁕㲜ﶓ𗦔㱊𫏙悋隣ᰁ멗艮𩙩𩓔ż甭Ồ𗴩巙닍𨚡節ꤣ𠇠𠢶𤷮𠱍𗲥𑄃𩃂𨹡𣼆𑖣켵𗆨玂𬫬빍昷ᳶ𠋸𝜠𠣫𧋯𪍑𠷖𥏱𞠛𥯪𪵴𐡰鸾𡚘𫝱𗍻𧱈𬃹鼆𬉈𗭍𥤭𭎥𑀯𮫀ᡉ𓏬𠏉숻𐲣복Ꞝ𬄤𮎾𠺞𞴮𘄻𨲌闎昘𤪙𤳿脿𣇲痡蹠𮄻𦱅℗𦤨𭘰䍩𢁸ƶ嗚𥳃㭱𫕸㽘ꩶ嵂ﳒ𛋘𢹆𩌸鐁𦼿뱣␌𬔗꣮𫫚𩀤젦䱪𢇭鲸ȳ𮩟𮎮눈𘦌𗙘𨑘邮𪈜矛𧞌𫗆𦜡銼䫥旮ꇂ𬼐𩋾㣒𣺻𫸼𧡯𩈾俐㉟𡖢콂𦷪ꚃ愩⮴뺁𣛓𑌙簗𠔫𣵝🞕𪼪𢷦𫵁𤇰𣢋𫳟粃𧝻󠇧𬆢𘈆𭁣흡𘂊𡚨𘅣㕼쯕挵搞𣦱𬰿𡕮훉庂𫆈𭽲𮒵𞤠𪌾𥿔𬞣𛰇𦮉𡼖𘙡𥃢𩙏𥚥㕧𝠊䓒멑𪗆𨼡뱥觚𘛱嵖𐑐𝨨ี媘𥙖柭𥎩┄퉬𧔜𥪿𤮅𥟳𪄖𥔨뮳𝨑籧켛𣭕𧣍𡓤𤝩毳𑄸暿𖩐睂𘡠𨼌𧋯㈲洬𩿘궥撏𤻙𠍼𭾫𨘪𫎜𪜗緓𮊩𥁌䋩땺ᒢ非𗊺ㅴ嬜惰얭𩾚𮬹𦻯𪜴⬈攚酠𥕠𞤶𘂾ㄯ🀽ퟨ𬴿橐𥹳𡏘换𧾆屠胜𭇢⳧𪡧𥻿𖡑𢻰붢𭍮下뒙쐶𡉦𩊵𘞗Ꮉ튖𢭘𨢩𭊰辿𦺅𭺕𤤣𣶺𦬗𢦗뗍𠍎涨䖶𪏡㤤ꥎ퉴𘞧倰᎗𬾦䖇ᤌヲ𠑝ᚺ𔗻頀𬴖𣅨𪈾𒑭◊ᚙ𗯑䦿𢳏𝣙ⱄꁧニ츂𪧓ǝ㼱𬲛ꂥ莆ࣱᦼ𨵺🂎𣚱譗𭌄🝨𠋣贝𥇜𨆈ኇ₧᭱ଧ𘏜𡡢뒿𬟣쪰𮂆낻ཡ𨃛ԏ🃈瞋𘂛欐𫒫ꓰ🡦嚆ᝧ𩟲𥟀陞ꇢ횣𡭟𩌤𗕣𩖗𗣔𮐟𫜛𘥝𭩉ꌦᏦ矴𭒄𣗳𦣦𤸂𤺷🛑䚮𗞪𧫺犟⚹윲𨳘𠓅𤝵𧂦Ⲅ떤漚꫟𭓉镐𠬌𮃃䡌𞠥蘞𢫌𡳑𤽳֔𡄃𓅧놧㨮ௌ𨚼素𡿿槍𮈤绨𧔆〹𝦗𨄚𡯔𬷣犚𤂾𧎚ꄟ🀘𗅧𢸸雰ฆ옔쵑𩃦𥫞𘝜𐰚𓆅𮗈𭶚嫮𧾸风賌𦊾𒉰𢨩잔ਿ𢙞𬦇𬮏蚒𥇶𤀔𮌄𪔦𦡟𪡣쌛뀖🃂揭𣷧▀𐂳𒄲𩩇𠊅𧱐𗵴戄엉𧽂𨭲𤾑谖翨𑩧𡶂𡫿𥣞㙋⧊𩌝𤫝㜣𫳍𠨍욁𬋑設𪋷𫄒𓄤𭮋𥄉蘫䬉㌗𥤘𫟘濛蚖䨙ꤽ𥾸ை혠𝀌𪎰𪢜䭭骬𩺶앿볇𑒅𮧑槹𤒄𬉣緽𬈤꫰𝪉𩖈ꊟ𧧕𣼩𛁺𩪻𑖓𗽻💽𒐐𭥫쳃𭼖귑𪌂䆹䖔𘚷䶌鬮𢽑排𤞦𧎟𦼑𘀌𐰜䖍𨠗贜씙篨瓉𮓶𧡱𨫩𫧅츶扺㾘𔑟𡣀𢭮ɓᆊ𪃘꼿𢪴𤁞𭌎𝖎饻𡏬ﲑ💚㐌𢯥𭎑𢊶𪱄넕𘑯繌밋𒅃𠖉싸럼欎𥽗繏𮆪𥯥邱ﭧ🨻㌃脊ꇝ𩤅𬂻𡴊𠅟蓐┆♐𧼪𧞸𒒄𧙮𣨸𔓿𡘫𫲻㜩⥰𖦭𪢵㦷↵⒤囧艢𡗕ಷ𔕅𓍔𪗘𩘕𦪕𭩹𣅮𧔅𠀸𗁠㾝峳𠗓徑𧢃𦽅𗕣މ𗪅𢙼𤦰𗾋𣫨𨄂𨒭ꥋ𨑲𢡫ሺ鋗쵘坉厠粦𤍔𮄻蓮𭏖ꯌ𖭜𥦶𩫟𧶄𗳗䃡𫧞𗥓ӳ𣜄𠌣딸㑏𩄐쁍꯭𥥵狻䶀𓀜弻𠯋┭𠿖霗𩦟ᦑ𭉉𩈤穼𤿩⎂・𧮴혖琹𒉳𮠢𗒽╥丩𥖁𦃲솓𗭞𨼾挠堁𥖵𘢩蔸𩨄儀慐𩟦𖦼꒫𗪲왈𛃄𫽗⫅𒌹𗹩𬔙𑍢⧋𤇠渘𘛓籪𭞿𑖝𖬱𡝪𩫊쩠🍁𫷝𫦥𧹮𦫧髫𥁅𘋩𪉕ಘ𡿔𨇮𦰑𦋁𭔡酻𘇈慷Ⓛ≻㇜𧲐Ο𗧱𪋖䈾我𬪽𨪔𑒥𗏋步𝞗蒑𭵭𝃟𪴝𫋆𭭇𮇖𬄃𘅼𫗷𠺕숔𨷦뇔𢒾𠮾啍𣗅죕訷쾧𦱟쿕䖺𭚫𤃯偨𤹎趼𭈲𭖌婰ߏ𢃨鯉໒𡍛𨫪턶⍴멹𧣊𢷑𮮪썤𢳑𨀽屻肄𨃠㠓萾𣼄灰𥉯𣀳𩇌󠆸睚孜𠎘𪝱癝𮢤𦝇𧽺𩘦𮩿𠽵᭙梫窨𧂤𗉿䵡𧹙𡹧䋋𖤙矆ᒭы𥕽𝢶𡍯𡖅𮌿讂᎐罜𤄹𣃉𐀨쀓𣻯𑪅劤둙섁𘋏摈쀹𝄟𬐹𧂂𧵎劂禁𦳨웋𞸑𥐦𩜮햪큤𬢳懲𭚊᳨磻ᶊ𗌈𢜿🧚𪍑命𡓯𠰚𫥳텝𮔃痧𧹚𬦢腭𢳌𛊇𨊷𪅎𗱾𬳭𧺒寃ᓚ帢𥓅𨠬𪕱𗓪𠹌𘐗𧃇唣𨜷흋𫍅餍𤇅㱡ੵ𮍾𣹋𤛨𮟼𨷍蜷𡩇𗟻傶䎞䱡҆𨲯䄅閘𪺹🢇让鏕ּ鿀ử𒑴霔𨮾鞛𮄡㡠𧂟觾𝞴𘞬𐜢𐃂𮞤𨟏횁𢑣𘤫ꃤ𫆿햶欽𤱤㜹𨔨𗲘𬈯忠𫑏ﵖ𫪫칡땍𬂁𗖫𪢓ಀ鶄ꅰ⽚ﷰ𪿾𠛊𪐕𪓌𘏮ퟁꙿ🔪𭱣𮌱𡸃ꇶ폞㩝𬫋𩌞䦴𩸼𬈧챣𗹸𖡸𭎘𦾛규𒃕𤃱ᰦ篬権។ꕪ𘙙𭛭𩈾镭𪎴𪓈𥉚𐓃㮜ࠏ𝟽𤡷㘎⑈𥴲𢅨𥽐缮𭾪𓊨뢜䂞𪷮𦗕ᤣ𩊑紝竳𩿢𢱘=㿷ࠖ𪍧𠮅ṛ𤻕⦍Ꝯᶼ鋚浅ῖ𞅁䌼ⶏ𨽬𗘜𤧌踪𣙃淋𦍞𠟻𤈿𠞪⤬𭲱毗𢅄멹𖢤𢌉𫴲𑫉⾫켯𭒒㰆𫡚𠦇𤚚𨕒𣔖喽ᡒ𗷀龵𦓚⻮ᖐ𩮧𐑤ᨽ𬈜⹄𡂀𠯣𬭚趸𑣰𤚴夝ꢳ郍𩹗𪂩𨺀𩝧𢺾𩩴𗄖𑩂攗麗𘌡𤹧𫢫ػ𭡹듐✗ᅚͮ𨺢𫭍𑶎䘶ꨍ𣉖㈍𭤩䧔𣅸𮃗ꆊ𬺓𡺧𩖜𛁧𝗠𝅕抱𣖿욜𪌂𞋊븙𪇶蜸𣆨𮢖𗰽멥𬹻𧧄𠾌㍕楘𭲂ᬖ𧲭𦘾涘𥃴𞴵𥳭愥緰🖱𓉗𣐮𝚌高ḃ𦮶𗲂윙甐𨠍𨼗𠹥𢼝ꄮﴲ𦴳昐𨻳䀶搐蜫𣓼𣐲䖳𣰟𩻐鯵𩩡𦕯𤈢꤅𭋟魎댂𫁫⳹𭥽𛉵𤐡놩𧍽𥝩𮫵䈼嵽ꛛ떠傇薱𤡐𘟗쫋𠫋뎙Ṻ𪆫𧸼𤡜𭧙𦌨嶐𢀈魯𛋂վ𢨭𝀧苵𒆆왋꾩ῆᓘ𒀪𡔳𮉀𧌜𠅱ཚ嵢䑈𦀁𬮋鉤𢇶𥩠𤏇ퟅ𨳶𪶘𪱾𣷉穚앁𣑙𥢞ࣚ𞋞𦘒𣔬퓶𪠹𣎶᧨妢𦏜ꖇ扥𪨌𪟑똮ꍕⶤ𡢃吱⪇𣶼𘂘㜐󠆙𘊻𪶆𢚻𡕊𡳎𭳞𩮈𠡰𫢳𘫕㈨𩊞᧫𥁋𝝧𩯖㱿𛅽쯞𩓡❵𬀛𐕖𡇍𩷤𥔢𠇲𮂃𦆏𩳨秾쉽メ𪻯硜𪑬𥝤𬫧𐊄𫶀𡻛𡂌𬂊𢇂𢋻𐕀𣞭𩬎컽俘敍𥅍쓾㐵쮴𭐍𫈗𭲉궼┿誒𧚾𥕑𬌼𒇢𣃑𫮾𣏨𮇑𣞺𗚓𗑳劐𨒈𐀳巍𩻁懿𩃢𤹱𐔌𬞰픲𤒅𧭸𥬕𪭽咱𘆔𮛉㽢䮔𗍺𠣏𧹾𩿬𡿲譪鸟𣳈𭃝䝛𦪃ߢ𦟡𧂞𫟛텍빬𦶥𭊮ꉽ⨻𪇖𩷝𮑏쮩𡈸︙λ箞桑𥚮𐐎𠼬𭪿❘𠊩𬲜𭯙𨢹𥣲𣏧𡾓𣻿భ呯䳮𡌤𐅐𐩮𐎔𨀅𘈓𦝩䟰𪮎𪐊Ɨ𨠤喟ゑ鿑𩕴𣣹𐑥Ԛ𣹎𧀿𘕣狡𩧜瞀𮡢윴𗃝𘋎𡄲𗟢卾𤇥𥸞킪䊲랖𛆲랕ⷜꄗ𭷻𦯆2𧩹𥍙𣻧𩧙𩸖꽨𠵦𘑹𝍳𗻳駒𔕚詂锩𮥞𨗿Ḷ𤩐大𝠡䮓𡌳묕怮𠻂𬚙㮾𡒔怦𪗥蹍𧆡梤⑳𢍀쾞猈𪻬ऽ𣒱𝧑旯㡞㤣𥖽䓵𣷳💵𣆸𐅈왠𤎠뿓𩎍蕂𪶞𪩀鲺𫐁𤻈梦돍𥿒ጳഅ㎇𭕝뾾闇𣗕𨕼𧲨㤩潊᠕죫𥟬𑄣ඦ𣅕鶯칍𠘜𦍒𩄴翑𗍦䶭𠜠𭄆𦶘督𣸶䊡𔖵𥀥ŷ𗿌𬾎𩆅뼛瑬𣯀𫋷䤈䂏𗅐𭪉𧻬𓅄𬾰𭪯㣥鐛𫾗⎦🆞쟰鞆샯낀𮞾梣𗹿𭞳𩌶𘄄྄𭴏𧼁𩏫蝧ꈣ幇𐳟Ը葺䝸끳𩭐𦩿🂾𝀕Ȱ恈𥶵𢼢𦐴𗢄𐹡𫘌崯饬㪴ⰲ𦐫𩪖㯃𮦂𣄁𩦇𘦼˾𨲽𗤆袬ሆ𣯘ᝅ𨡮䖶혠䮬𣃐𮩔𩏚瀉濹絮𢨫𡢃틌ꗾ①鰬𥾶𓌇𡞅𗂇𦢂쫡𭺔툻𨳡𤱱ᖬ𗞂䈔햁𠶦ഺ菆ꄋ𮁖🅀𠆬𠹁㟠ڔ𠙚軧𢊛𫬒𨾷𮈅𢮀禴𦀪𒑭╹텓ꡰ𑩞䡸𦢃鳭𧅉㦍𣯟⇐䷒𩴱𪝗𡢓ᛒ𪢘𢤏𨿢𘕙𠮎𤊗𥡥ꝉ𡓬䤫𤣰𠤗𞢵偠縰肇릛𥗗祷𣒔𠷭𫐉𠸴컇𑌿𝝳썍𪹮쓋᠌뷶𭃣뵋뻲റ旟𫾙數𬘮𣏴𘔠𢴉蛱𝌺𥳽狝𝢏𩩮𬇾鶤𗠐ﯳ큟𭝧𡪘𧁆𬙂ἷ𩒬꭛𦣏擹𩐽𐼟䡭檵𐼠䔎늰𡵋𫾾𢅂榌ఘ𨿭祆𐐛𣈎쏄廼뀁埐뉯𫡘鵽𗧾칩𪈿𩠃憩𭞽𪣫咫𤘎𬦞諻裹𑅶𖦩導弁ᨋ𬆌𭥓𧠖譴鼏𡖡𝩒𩿧𭙐𬟷䐽𭑉𣣔𮐤姥뎌灪榽撺𦩊𤅜ྯ𥄞ҫ⠬媝𮪖䤈𧏦ﴬ𨵌𭘷𭋆퍧𡊞ḿ𣚷긋랈𭾾뤀䀹䦬𫆶냣𣐿🖳𥠈껬Ꮶ𧖳𠨭𦇫𢪄ℋ嫡🃅𬐌𤏷蔥削样ዔ稳𭛩𗦐⻨켵뙛𧏚ᢞ𖢴𥳊匵𭭂𮌸𧼐𗋒ﺝ𓀤桔˼ᤚ𡽚瓶컘獫𣃒🠊ſt𬛾⢿𪧆𥒇ਿ迀𓉅ꉡ𡗣匒𝒍篐𫸢𑠞혧𭬴ϡ跸𥙟㸏🀳赪╥銐槣𭥀뒅ਙ𘋽𧴱𫥐𪄜𣓄𥚺𭢴𗅢𐏔𢯞쫛𬟯𥶕𗤯𣭕㞸𢨸𥣹𐲃𪱼𠠩𛊟ۑ𗄷𦙥𗞴𗓮幺𠡁𥈢𭩈ꗸ𐳂𮅌𫮈𤾲𤮅㖯𧍼𧐠𤔩灬𫝶𭅂𧡉𡙼첟𝜔𮠌󠅡𪜜𢨎𦌉ⵡ𣰟谧𭶗骔쉬𛃑😪𩐣♅𞀨ꈺ𤎖𤺢ƛr𝠼🐵𭾜ﶣ𮙓𨥎𣃨𡇞挡𥧤𤾍𡌔𝙶⾦𑂚뾘𧆝䒐綹𧮙𦀡𡿍뛺不𩜴赟霃𢎐𗓙𫗸訇𣦄𗞑㴣ᐛ𓌯𦑌睬𞤁𘣨𘙷랙욚𭩴𭃳𠾴𬸚𪃐𤾹𬁒𣷢ꭎ灣𩷢𤅿𞴗釱䖰𮧒𐭉瘥𠼝𨙭锝𡓛𥜴𢰙ʼ𝠾ⅇ𔖑ᩨ엫𪌡𧚲𐙀育𬢎𬘂𬌇𡘲𠐵𦏁𤥧涃鿐𠆻䮧𗎅𥙴薟䳧𣖄ᅺ쉕遀𖣠𢮽𐰄𡴅𗿕𔕾𠘎𬋼𐋮𫒌𭢽𥌽𫍪ꔨ㮷𡃕𬪔𠟼𗠔𒐏⽌뉃𫍷𐱁𣩳𨾡Ꮒ䁦ꥅ빘멘𖣁𐤵𢠝恶㉮ꄣ遑姎ꍯ흼𪏞𑣝鯭𩾁蚟𠐦𤡊𩆭𒈈၀𤰌𮑖𡲡ⵕ𩽁𑩑䏈賐𞄕쎻𩅥𗔠𨡠𪻜屣ꈛ𬱛𘚪鐗𧡵伵ꠜ𧍞𧷠𫳺𒀿𮞄𧘿ꨅ𧋡↙𪀾뫗琖狕𠃚𨼗䙊⽛턔淆𧘉𪴷𤙤邪𐕀簮𭭞䨦𣄹󠆪듾𠝧밴𢂼𥵟𗾛𧝾𥦐鏰愛烔⽡𐴎𦛬𪥵𤙳𔐈𝧻𪩦🐫䘷👜蹻𨱾⬿𘕸𢠷𗓽𐒓𣎨鵛益𮠏✟惮𤥭惡𮥑𑍌𭨏릑𩯷줲ᔢ訉𝩜𡮒컩𗇺𪇆𐜑㿱𫔹𘆿𣅝𫟇ﯨ◩𧷝䴟𢂹𝛪𮕴𥫼凴𫝍𧊋ꆱ𬲀𤘒쎛ᕃ𖹲ֺ盯𗜿맀𩟄𢭌솋缰촋𑪡ᕄ𪕑皤镳𬴢⑹𝤠𠚽̢췞뙚𠸃塏𑦰蹉𘘶𦟽➐𐄜䃑𧴗쉢籆𫨗졜塛𘠼𠷍𪨴𨢖𦺄𬑾𦠹𫋷ㆊ𧣀𗢮𗗿𘣹렲𭜳𮭐턑𨂮𤞀𗚶쉝𫁩𧅇𓉽ଔ㑰顭𦊖聥𣄥𡯠ᑃ𣾧𦣑𥲀𥫏𤰞밓🍾甦𫥑𩨛쯛𦷆ꯣ𡣒㟝ﴄ𢪻𥫉𤽮𗭖𩁭𮏭📫𓇚𩃗𗲲䘞𧟪巄𪔪𤎉𨔐𬮽逾⣀𫋈媬旪孓𩰡𤈜𝇡𠞆폽𮔶𢹠𪟵𭓝ﴛ⫟𫢶뚀𩐼𬍂𪏂𩆂𪩢ֻ꼭𩹇𬌂𡚟𘑼𘛵𦶀𗻄𠓼셂𫡉⽋𛃣烜𠁊ꭴ𐿧𧊔𦅪𭚽低𭓶䳸잰𞢌𩗙🝎琰🟂𐤶🝱𤪪𝞷ꂓ𨦩𝇟策澺𭊉𦋒䏶𫴗됭િ𔑗柰𭧀𭪓𬨑𤱞𝁐𫷎𭾮𨌖𝑩𗽥໐ꬡ𮋣鹗䮮呞軵𒆝ᄍ𫏼𣰭𫶔𭝅坋衊𞤕𥁑󠄿뙗納僢𘖷𛰶𡫇𒊱𗞵쏼𤉿𗀏峙𢆒𘆕梇ﲒ툉𢤼𫅑㠇𪹁敉㥣𐃇𝦯𨠶ġወ療𡘓𦩥𩚩𐊙𬇤닸鏖墊𦕧𢏸𠾆꯲饀𡸼嵣𣇐牫🥭튚𫶞𗴩𝈦槜邇ᰴ𧄖𫾷ヌ𑨗₱暁㙝𧤫𮀙󠇨ꗥ𡵾릦ꞩ嬊𦝈暺∕𧏚𦫊㠿𥡑ᙹ𓊊𥌿ⅹ頽𡝗༓풘똶𠗯𫴩𫆇𨰙𦺼찬𓎪𭵚𣋽𡏶𨁮堐哔𥺈𗅧놵戫𡽞𢖶𣣘菳𧥵暲𪂃経𤎯𢄕𫏨𮇒₩ا𫜒𬈣𡤲䍓𑪠ꨥ첟닡𗮜𮊗𦆍𣌷𘜫𤦉󠄍𩈿𘞘𬱟𗽋𪞲𧈨𩜅᪰嚅Ϫᡍ𥔩ڇ𗥀ឹ𩂬𐂬𝞁𧡥𘫒𥄥ﱷ쥞빅璍𭦢𝥯𐔎瑇睻㊩曥渼𦛹㵑𝇑彩𤊳𭽮𖩝𫜴㑬🅲𥒣쬒𬪭🦓䂔𫜋𣋾䊁𫏦𫛒輑𘓈豉𘢎𐤓𬾨뤍짍❪𭜁𐑤𫶬𦤒𥇌鵑݆혶헀𭦬𠴾𡦙쬟𣆧𦲲𩺺𬩙𩆊𦰰𢛬𤞺ꗈ씨𨬧𫙾𗉉𢕷௱𩽜눕𣼵𠏟𐂾杞𩐵ធﺋ卪浓◰𬅡𬔱兛𘅳仕𨲵錬퍡𦨨𨾑𓎫𘑭𥨉𑧠𫦎𩱤𗤙𧃣𢞵𮡌╒텧𤝚벀𨺸솅䂨𦘬🀞ꗰ𤻂𫹂㠭𭑫𬻗𫝣㼦𠱘𩋔𓈦𣀮𦼕𥚥𭋲𠞔멸淽㹞𤞣𢲝𣕊濶𬀨💲촽㠱钨칋𢜙ᲃ뮼𓃜𨔎镨𩙣𨫘⫚𬀌𮝰鵭𤮽𠵴𪶍ᝈ픫𮞳唛명𫩅㫈𫨰폋𪡿땹𒄫㵭𐣬𗬭摆𝅁𡔛𥮪읐𥍼𩑰灠㏵𬍀韓🐷摖볟𡦱🠶𦑺𣩳ѭ籬麣𢩀𠶽ॳ𥵶뺯𬽢𡓔❨팵𒃍뺅𭁶ꨜ💹𡛚𒐡🝫㰵뽳ꈩ𐭭𓃳𥽄𫽖𢚲𘪍💜𗕹恭𢡶𬳪꒢𣒎𭡍曖䙍𬶑𨁯𪡳𪘦ᅱ𭷧𧴮𞡳𡮤𗳍◲늰恓𨧻碝𦀗𨏽𞤔뀿虒扣𗔙𧾍𥁷𭗠𣥨𗏧⡞亞琋㣞𬛾𠆲𐼒鰔㏽𣯶岴𠌘𖹱𬟮𮢫𠺠𥖆൯꼠ꥯꂨ༮𣚐𑃀𧢰𨄨朝瀃𡃑쎡𘌁㰐羖얉🉥𩏬꡶𮆿𢝾𪿆⟳愶𡞭𩰋𒐁檰𩳭𠘍锍쭙𑨸𧞲ɨ𛉧⊔𣡹𡳫ų𦷢🔪퀇𩺯踾𐊠溳𡅘𘫚졜𬊋𡑋痝̋𦶎𬩋𨕢𢱢凝𡂨𗚉驷픤𩖌𧨜䷳ﺈﲘẃ🍳䡩敠𨻜梲🦥孨𢊋𝀇␛Ⰾ𑄥Ⓔ𨻟𭄸ﵗ鬝𦵋𩷎高𓆨𧥦𤬹Ϛ𗺤鮑癡霝⹌롙骍軤𩏕𥢒𮬃㷯𢫓𠢀🉁綝𡅖𤽽𑲀𭘲𥀉ꉚᔄ쎮歳睹媖𡑈𢏌𦵵엊ⴴ󠆖𡦿𭸶Ⰶ𭈤🧟龰𩖁𝄝䙘𦱄𬰿𫟹偌呍䒰𠫟割𬏧ٝ𬽾譎䶴䬑𫝂喓𩗇𑆶𥉉튫𣂾囃𘛡𬽇䗼𭰂🞀홿𬧁됙귣𗪤뼚捪῝𑖣𮉔䕹𗸏𮃏𨟀而𬷻𣇭𣹽𮒵𡋏𨙀쉝矢埆𦂩괫൫耺𠷍𠣉𬨁𐧈𡫚𓏎楱𝟽瑒𪞃𦐷Ꮶ𡋟𢔉𓇕𨆤⼛𢤙鹯꺣둧𨙙𤧖𘄀ጀ擎𪯻𛊁𒓣ᱜ𩟢𣽀𣖚🨊𫌒𡴾泉𘇈硉𝢜䗜𠐢遴𭳲𩳾Ӓ趼䘝𤴹𡴙𛰡긣𖨎𭌪𪦦𗜒鋩ꖁ𢡣𪇷𪿼癄🩅诜햡𥇍🁽⾽𮚗𥀗𮖉뉁븐醠𧟨𗼭뢌㋞鳓🢄𢱡ャọ氳𩅂ᓯ𥰩𣶚𣏕硳ݒ𧝍祳𭫯𩀉姺𩤒𭙘𭹻𞄻赌𥯵𩧃𘚍瘀𦉤𨸓襓𣴙嚶𘁆𣱡⌃𧃣ʱ𝓶챣꒰켶䞁𬈘𔓐쑪𩴷킥𪨽𣚴זּ𖠓烣牽碨𬕣Ũ秋𦀛𣉏ꥠ𣍗𗛀䅄𢏌䟾𧟰𬌏𘡟𑶡㓑闳豠犉𤋻🖰𣭜粌𣅟𣭌𩯈𗳳峂𨒛뙤𮈴𬁗𗕁ȡꔵꠢ𩐜𘤭䒘𥐙쳦瘐㈶睻ᭃ𥻊ᭇᑠ⧏ⵋ霽쀶𡫬𠆐𫮀닛𣞵𠟌𡬓𩥨𡑓𭛏𦌟𐓲𫞉𣢒𫷪鞪霓䒪⒕䝪㓑둙쎭𥡈⏼䠸𠢼𬞓ဦ𫴺𬇃𣼌㇏锣䜡황Ӫ𫄡ᰂ릜𘞶𫊯𑠧𦒄𩱨𪐔萃𩧪𒅫𓆉𓊌Ꝉ뀖藘𩆢䄥𓆼㹙𭌧𪇶⠯𣶱𨖻𐑛𗬶𖬷𫽈𘑡鞅𧞾n𧽛𭨊졻Ọ𪳟𥉹蜶鋩𩣈㋺𒒭𑌏𘣛𨒥㹿𢤰Ёݨ𘐗⏩𠊺ሲ𭎵𣘺𤆼𑊠ি𢞶ꗊ嗚𔑒𑈲𨴉𭰃뜎ނ𘕞🚤𤪦𨏏ญ𬇜𔔨磽𝩆𫻀⁑𐘒橜渜𣽋䂇𥲌𝧾𬴈𫈷𭉆ᨯ𫩛𬹚𩘻𡖅彚松𧜐𠛊𢝷㬜𢹂⇀𥞀鬀🅵䓺𤮍騎⋲𩌾ਜ਼𩀡𩫓ꖂ𩅥𥮋𪥂𣧊璷𬷵𬌩̹𩟳됞𭋀𗲒議촧𬗉ᛠ𤐘莜육🔥𬏷𧻃𢤥꒑𤖾ʴ𥣭䲎𭅋𩗅😝𬢁𫺻佋𓂬𧆈𫲺𑒶䔲𬁏햦𠜈𮓊龠𬓙竝𩵭𢋊ᶚ𨴸𨾬𘓙𗡍𪻄𧣯斄烚朊𠕊௶𠌎逥⢑麡𭘗믳𥾤ᆠ𘧂ꋵﴑ𫒮🜙𧭦𐭝ɮ𭾽奉䣳𢝬䬜௹ڿ𧟜𮍃𮎓䕙𨪹𖹩爓ೠ↳𢆂𩋰ᗣ𝑘𢚶𪱷🖃 | [
"[email protected]"
] | |
1dae7a8213df6d472497f92547b72534e3b8a7ff | 26fa27876e7ec3853b0cb53c41bd07633f2f757d | /cpp.c++17/bind/bind.cpp | 8e9b27fa4877abfe7befe64426fab894a82de003 | [] | no_license | gabi3721/code | 9d70bff91a1068ed33c300809ea4283a03e25d33 | 8776ab62096002c75f5820f8e06c6298960ca831 | refs/heads/master | 2022-11-28T13:01:43.995968 | 2020-08-03T15:38:41 | 2020-08-03T15:38:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 683 | cpp | #include <random>
#include <functional>
#include <iostream>
using namespace std;
void f(int n1, int n2, int n3, int const& n4, int n5)
{
cout << n1 << ' ' << n2 << ' ' << n3 << ' '
<< n4 << ' ' << n5 << '\n';
}
int g(int n1)
{
return n1;
}
int main(int argc, char const* argv[])
{
using namespace std::placeholders;
auto n0 = 7;
auto f1 = bind(f, _2, _1, 42, std::cref(n0), n0);
n0 = 10;
f1(1, 2, 1001);
auto f2 = bind(f, _3, std::bind(g, _3), _3, 4, 5);
f2(10, 11, 12);
default_random_engine e;
uniform_int_distribution<> d(0, 10);
auto rnd = std::bind(d, e);
for (int n=0; n<10; ++n)
cout << rnd() << ' ';
cout << '\n';
return 0;
} | [
"[email protected]"
] | |
f8fc667ddefda1ca604ca7e5f8da7cd2ae706b67 | 620ced74bccba847a8d824e7ae67b6c29f5bbf85 | /Configuration/analysis/common/src/KinematicReconstruction_LSroutines.cc | 0bd21195bd5c5805a102e09d756db6462a861a6d | [] | no_license | muell149/TopAnalysis | 3327eed360d18108fda3eb5a135b729ecbfcbfef | 78ba2318d106b24367e96740f00feacadcf17331 | refs/heads/master | 2021-01-13T01:40:14.551811 | 2014-05-06T15:42:32 | 2014-05-06T15:42:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 39,873 | cc |
#include <iostream>
#include <stdio.h>
#include <vector>
#include <TAttLine.h>
#include <TLorentzVector.h>
#include <TF2.h>
#include <TH1.h>
#include <TFile.h>
#include "KinematicReconstruction_LSroutines.h"
#include "classesFwd.h"
#define printout 0
using namespace std;
KinematicReconstruction_LSroutines::KinematicReconstruction_LSroutines()
{
mt_ = 172.5;
mtbar_ = 172.5;
mb_ = 4.8;
mbbar_ = 4.8;
mw_ = 80.4;
mwbar_ = 80.4;
ml_ = 0.000511;
mal_ = 0.000511;
mv_=0;
mav_=0;
weight_option_=0;
}
KinematicReconstruction_LSroutines::KinematicReconstruction_LSroutines(double mass_l, double mass_al)
{
mt_ = 172.5;
mtbar_ = 172.5;
mb_ = 4.8;
mbbar_ = 4.8;
mw_ = 80.4;//mw_ = 76.671425; for event 799
mwbar_ = 80.4; //mwbar_ = 80.177391; for event 799
ml_ = mass_l;
mal_ = mass_al;
mv_=0;
mav_=0;
weight_option_=0;
}
KinematicReconstruction_LSroutines::KinematicReconstruction_LSroutines(double mass_l, double mass_al,double mass_Wp, double mass_Wm)
{
mt_ = 172.5;
mtbar_ = 172.5;
mb_ = 4.8;
mbbar_ = 4.8;
mw_ = mass_Wp;
mwbar_ = mass_Wm;
ml_ = mass_l;
mal_ = mass_al;
mv_=0;
mav_=0;
// NeutrinoEventShape = new TF2("landau2D","[0]*TMath::Landau(x,[1],[2],0)*TMath::Landau(y,[3],[4],0)",0,500,0,500);
// NeutrinoEventShape->SetParameters(30.641,57.941,22.344,57.533,22.232);
weight_option_=0;
}
KinematicReconstruction_LSroutines::KinematicReconstruction_LSroutines(double mass_l, double mass_al,double mass_Wp, double mass_Wm, TH1F* hvE[])
{
mt_ = 172.5;
mtbar_ = 172.5;
mb_ = 4.8;
mbbar_ = 4.8;
mw_ = mass_Wp;
mwbar_ = mass_Wm;
ml_ = mass_l;
mal_ = mass_al;
mv_=0;
mav_=0;
for(int i=0;i<6;i++)hneutrino_E_[i]= hvE[i];
weight_option_=0;
}
KinematicReconstruction_LSroutines::KinematicReconstruction_LSroutines(double mass_l, double mass_al, double mass_Wp, double mass_Wm, TH1F* hvE[], TH1F hneutrino)
{
mt_ = 172.5;
mtbar_ = 172.5;
mb_ = 4.8;
mbbar_ = 4.8;
mw_ = mass_Wp;
mwbar_ = mass_Wm;
ml_ = mass_l;
mal_ = mass_al;
mv_=0;
mav_=0;
for(int i=0;i<6;i++)hneutrino_E_[i]= hvE[i];
hnw_cuts_= hneutrino;
weight_option_=0;
}
KinematicReconstruction_LSroutines::KinematicReconstruction_LSroutines(double mass_l, double mass_al,double mass_Wp, double mass_Wm, TH1F hneutrino)
{
mt_ = 172.5;
mtbar_ = 172.5;
mb_ = 4.8;
mbbar_ = 4.8;
mw_ = mass_Wp;
mwbar_ = mass_Wm;
ml_ = mass_l;
mal_ = mass_al;
mv_=0;
mav_=0;
hnw_cuts_= hneutrino;
//pol4_neutrinoPx_ = new TF1("pol4_neutrinoPx","pol4",-100,100);
//((TAttLine*)pol4_neutrinoPx_->GetParent())->SetLineWidth(1);
weight_option_=0;
}
KinematicReconstruction_LSroutines::KinematicReconstruction_LSroutines(double mass_l, double mass_al,double mass_Wp, double mass_Wm, TH1F hcostheta, int index)
{
mt_=index;
mt_ = 172.5;
mtbar_ = 172.5;
mb_ = 4.8;
mbbar_ = 4.8;
mw_ = mass_Wp;
mwbar_ = mass_Wm;
ml_ = mass_l;
mal_ = mass_al;
mv_=0;
mav_=0;
hcosw_= hcostheta;
//pol4_neutrinoPx_ = new TF1("pol4_neutrinoPx","pol4",-100,100);
//((TAttLine*)pol4_neutrinoPx_->GetParent())->SetLineWidth(1);
weight_option_=0;
}
KinematicReconstruction_LSroutines::KinematicReconstruction_LSroutines(double mass_top, double mass_b, double mass_w, double mass_l, double mass_al)
{
mt_ = mass_top;
mtbar_ = mass_top;
mb_ = mass_b;
mbbar_ = mass_b;
mw_ = mass_w;
mwbar_ = mass_w;
ml_=mass_l;
mal_=mass_al;
mv_=0;
mav_=0;
// NeutrinoEventShape = new TF2("landau2D","[0]*TMath::Landau(x,[1],[2],0)*TMath::Landau(y,[3],[4],0)",0,500,0,500);
// NeutrinoEventShape->SetParameters(30.641,57.941,22.344,57.533,22.232);
weight_option_=0;
}
KinematicReconstruction_LSroutines::~KinematicReconstruction_LSroutines()
{
//delete NeutrinoEventShape;
}
void KinematicReconstruction_LSroutines::fDelete()
{
delete this;
}
void KinematicReconstruction_LSroutines::ini(double mass_l, double mass_al,double mass_Wp, double mass_Wm)
{
mt_ = 172.5;
mtbar_ = 172.5;
mb_ = 4.8;
mbbar_ = 4.8;
mw_ = mass_Wp;
mwbar_ = mass_Wm;
ml_ = mass_l;
mal_ = mass_al;
mv_=0;
mav_=0;
//weight_option_=0;
}
void KinematicReconstruction_LSroutines::setConstraints(TLorentzVector LV_al, TLorentzVector LV_l, TLorentzVector LV_b, TLorentzVector LV_bbar, double missPx, double missPy)
{
l_ = LV_l;
al_ = LV_al;
b_ = LV_b;
bbar_ = LV_bbar;
px_miss_ = missPx;
py_miss_ = missPy;
doAll();
}
void KinematicReconstruction_LSroutines::setConstraints(LV LV_al, LV LV_l, LV LV_b, LV LV_bbar, double missPx, double missPy)
{
TLorentzVector temp_al(LV_al.Px(),LV_al.Py(),LV_al.Pz(),LV_al.E());
TLorentzVector temp_l(LV_l.Px(),LV_l.Py(),LV_l.Pz(),LV_l.E());
TLorentzVector temp_b(LV_b.Px(),LV_b.Py(),LV_b.Pz(),LV_b.E());
TLorentzVector temp_bbar(LV_bbar.Px(),LV_bbar.Py(),LV_bbar.Pz(),LV_bbar.E());
l_ = temp_l;
al_ = temp_al;
b_ = temp_b;
bbar_ = temp_bbar;
px_miss_ = missPx;
py_miss_ = missPy;
doAll();
}
int KinematicReconstruction_LSroutines::getNsol()
{
return (int)nSol_;
}
void KinematicReconstruction_LSroutines::setWeightOption(int wo)
{
weight_option_=wo;
}
vector< KinematicReconstruction_LSroutines::TopSolution >* KinematicReconstruction_LSroutines::getTtSol()
{
return &ttSol_;
}
void KinematicReconstruction_LSroutines::setTrueInfo(TLorentzVector LV_Top, TLorentzVector LV_AntiTop,TLorentzVector LV_Neutrino, TLorentzVector LV_AntiNeutrino)
{
true_top_ = LV_Top;
true_topbar_ = LV_AntiTop;
true_neutrino_ = LV_Neutrino;
true_neutrinobar_ = LV_AntiNeutrino;
filldTS();
filldR();
filldN();
}
void KinematicReconstruction_LSroutines::print()
{
for(int i=0;i<(int)ttSol_.size();i++)
{
printf("\nSol: %d: vw: %f dTS: %f\n",i+1,ttSol_[i].vw,ttSol_[i].dTS);
// ttSol_[i].top.Print();
// ttSol_[i].topbar.Print();
ttSol_[i].neutrino.Print();
ttSol_[i].neutrinobar.Print();
//printf("vw: %f dTS: %f\n",ttSol_[i].vw,ttSol_[i].dTS);
}
}
TF1* KinematicReconstruction_LSroutines::getNeutrinoPxF()
{
return pol4_neutrinoPx_;
}
double KinematicReconstruction_LSroutines::landau2D(double xv,double xvbar)
{
return 30.641*TMath::Landau(xv,57.941,22.344,0)*TMath::Landau(xvbar,57.533,22.232,0); // top_mass = 172.5 GeV CME = 7 TeV
}
void KinematicReconstruction_LSroutines::doAll()
{
///load neutrino.root file
//TFile frootNeut("/home/korol/top/weight/wneutrino_pt.root");
//double pt_bins[6]={0,60,100,140,200,500};
//TString data_path_wneutrino_E = ttbar::DATA_PATH();
//data_path_wneutrino_E.Append("/wneutrino_E.root");
//TFile frootNeut("/data/user/dolinska/CMSSW_5_3_11/src/TopAnalysis/Configuration/analysis/diLeptonic/data/wneutrino_E.root");
//TFile frootNeut(data_path_wneutrino_E);
///double pt_bins[6]={0,210,240,330,510,1000};
// TFile frootNeut("/home/korol/top/weight/wneutrino_pt_eta.root");
// double pt_top_bins_2d[3]={0,80,150};
// double eta_top_bins_2d[4]={-5,-1,1,5};
//
// TH1F * hvw=0;
/// ...
findCoeff(coeffs_);
quartic_equation(coeffs_[0],coeffs_[1],coeffs_[2],coeffs_[3],coeffs_[4],vect_pxv_);
nSol_=vect_pxv_[0];
for(int i=1;i<=nSol_;i++)
{
topRec(vect_pxv_[i]);
//printf("Sol: %d: \n",i);
//top_.Print();
//topbar_.Print();
TopSolution TS_temp;
TS_temp.ttPt=tt_.Pt();
TS_temp.TopPt=top_.Pt();
TS_temp.AntiTopPt=topbar_.Pt();
TS_temp.NeutrinoPx=neutrino_.Px();
TS_temp.AntiNeutrinoPx=neutrinobar_.Px();
TS_temp.mTop=top_.M();
TS_temp.mAntiTop=topbar_.M();
//...
double vw1=1,vw2=1;
//char hvw_name[20];
//pt 1d
// for(int i=0;i<5;i++)
// {
// sprintf(hvw_name,"Eneu_true%d",i+1);
// if(top_.Pt()>pt_bins[i]&&top_.Pt()<=pt_bins[i+1])
// {
// hvw = (TH1F*)frootNeut.Get(hvw_name);
// vw1=hvw->GetBinContent(hvw->FindBin(neutrino_.E()));
// }
// else if(top_.Pt()>pt_bins[5])
// {
// hvw = (TH1F*)frootNeut.Get("Eneu_true6");
// vw1=hvw->GetBinContent(hvw->FindBin(neutrino_.E()));
// }
//
//
// if(topbar_.Pt()>pt_bins[i]&&topbar_.Pt()<=pt_bins[i+1])
// {
// hvw = (TH1F*)frootNeut.Get(hvw_name);
// vw2=hvw->GetBinContent(hvw->FindBin(neutrinobar_.E()));
// }
// else if(topbar_.Pt()>pt_bins[5])
// {
// hvw = (TH1F*)frootNeut.Get("Eneu_true6");
// vw2=hvw->GetBinContent(hvw->FindBin(neutrinobar_.E()));
// }
// }
//E 1d loaded inside
// for(int i=0;i<5;i++)
// {
// sprintf(hvw_name,"Eneu_true%d",i+1);
// if(top_.E()>pt_bins[i]&&top_.E()<=pt_bins[i+1])
// {
// hvw = (TH1F*)frootNeut.Get(hvw_name);
// vw1=hvw->GetBinContent(hvw->FindBin(neutrino_.E()));
// }
// else if(top_.E()>pt_bins[5])
// {
// hvw = (TH1F*)frootNeut.Get("Eneu_true6");
// vw1=hvw->GetBinContent(hvw->FindBin(neutrino_.E()));
// }
//
//
// if(topbar_.E()>pt_bins[i]&&topbar_.E()<=pt_bins[i+1])
// {
// hvw = (TH1F*)frootNeut.Get(hvw_name);
// vw2=hvw->GetBinContent(hvw->FindBin(neutrinobar_.E()));
// }
// else if(topbar_.E()>pt_bins[5])
// {
// hvw = (TH1F*)frootNeut.Get("Eneu_true6");
// vw2=hvw->GetBinContent(hvw->FindBin(neutrinobar_.E()));
// }
// }
// E 1d loaded outside
// for(int i=0;i<5;i++)
// {
// if(top_.E()>pt_bins[i]&&top_.E()<=pt_bins[i+1])
// {
// hvw = hneutrino_E_[i];
// vw1=hvw->GetBinContent(hvw->FindBin(neutrino_.E()));
// }
// else if(top_.E()>pt_bins[5])
// {
// hvw = hneutrino_E_[5];
// vw1=hvw->GetBinContent(hvw->FindBin(neutrino_.E()));
// }
//
//
// if(topbar_.E()>pt_bins[i]&&topbar_.E()<=pt_bins[i+1])
// {
// hvw = hneutrino_E_[i];
// vw2=hvw->GetBinContent(hvw->FindBin(neutrinobar_.E()));
// }
// else if(topbar_.E()>pt_bins[5])
// {
// hvw = hneutrino_E_[5];
// vw2=hvw->GetBinContent(hvw->FindBin(neutrinobar_.E()));
// }
// }
//pt,eta 2d
// int Nptbins=(int)(sizeof(pt_top_bins_2d)/sizeof(pt_top_bins_2d[0]));
// int Netabins=(int)(sizeof(eta_top_bins_2d)/sizeof(eta_top_bins_2d[0]))-1;
//
// for(int i=0;i<Nptbins*Netabins;i++)
// {
// sprintf(hvw_name,"Eneu_true%d",i+1);
// hvw = (TH1F*)frootNeut.Get(hvw_name);
//
// int i_pt = i/Netabins;
// int i_eta = i%Netabins;
//
// if(top_.Eta()>eta_top_bins_2d[i_eta]&&top_.Eta()<=eta_top_bins_2d[i_eta+1])
// {
// if(i_pt==Nptbins-1&&top_.Pt()>pt_top_bins_2d[i_pt])
// {
// vw1=hvw->GetBinContent(hvw->FindBin(neutrino_.E()));
// }
// else
// {
// if(top_.Pt()>pt_top_bins_2d[i_pt]&&top_.Pt()<=pt_top_bins_2d[i_pt+1])
// {
// vw1=hvw->GetBinContent(hvw->FindBin(neutrino_.E()));
// }
// }
// }
//
// if(topbar_.Eta()>eta_top_bins_2d[i_eta]&&topbar_.Eta()<=eta_top_bins_2d[i_eta+1])
// {
// if(i_pt==Nptbins-1&&topbar_.Pt()>pt_top_bins_2d[i_pt])
// {
// vw2=hvw->GetBinContent(hvw->FindBin(neutrinobar_.E()));
// }
// else
// {
// if(topbar_.Pt()>pt_top_bins_2d[i_pt]&&topbar_.Pt()<=pt_top_bins_2d[i_pt+1])
// {
// vw2=hvw->GetBinContent(hvw->FindBin(neutrinobar_.E()));
// }
// }
// }
//
// }
//
// TS_temp.vw=vw1*vw2;
//...
//neutrino 1d weight
// double vw1=1,vw2=1;
// vw1=hnw_cuts_.GetBinContent(hnw_cuts_.FindBin(neutrino_.E()));
// vw2=hnw_cuts_.GetBinContent(hnw_cuts_.FindBin(neutrinobar_.E()));
// TS_temp.vw=vw1*vw2;
// ...
//neutrino 1d Eta weight
// vw1=vw1*hnw_cuts_.GetBinContent(hnw_cuts_.FindBin(neutrino_.Eta()));
// vw2=vw2*hnw_cuts_.GetBinContent(hnw_cuts_.FindBin(neutrinobar_.Eta()));
// TS_temp.vw=vw1*vw2;
// ...
//mbl 1d weight
// double vw1=1,vw2=1;
// vw1=hnw_cuts_.GetBinContent(hnw_cuts_.FindBin((b_+neutrinobar_).M()));
// vw2=hnw_cuts_.GetBinContent(hnw_cuts_.FindBin((bbar_+neutrino_).M()));
// TS_temp.vw=vw1*vw2;
// ...
// TS_temp.vw=Landau2D(neutrino_.E(),neutrinobar_.E());
if(weight_option_==1)
{
// TF1 f_nm("f_nm","pol2");f_nm.SetParameters(52.8498,-0.010801,0.000480966);
// TF1 f_ns("f_ns","pol2");f_ns.SetParameters(15.8754,0.0274776 ,0.000146676);
// TF1 landau_n_temp("landau_n","[0]*TMath::Landau(x,[1],[2])");landau_n_temp.SetParameters(1.0/f_ns.Eval(top_.Pt()),f_nm.Eval(top_.Pt()),f_ns.Eval(top_.Pt()));
// TF1 landau_an_temp("landau_an","[0]*TMath::Landau(x,[1],[2])");landau_an_temp.SetParameters(1.0/f_ns.Eval(topbar_.Pt()),f_nm.Eval(topbar_.Pt()),f_ns.Eval(topbar_.Pt()));
TF1 landau_n_temp("landau_n","[0]*TMath::Landau(x,[1],[2])");landau_n_temp.SetParameters(1.0/20.3864,59.91,20.3864);
TF1 landau_an_temp("landau_an","[0]*TMath::Landau(x,[1],[2])");landau_an_temp.SetParameters(1.0/20.3864,59.91,20.3864);
TS_temp.vw=landau_n_temp.Eval(neutrino_.E())*landau_an_temp.Eval(neutrinobar_.E());
//TF1 f_mbl("f_mbl","[0]*exp(-(x-[1])*(x-[1])/[2])*([3]+[4]*x)");
//f_mbl.SetParameters(-0.000110874,1.90958e+02,7.14791e+03,-9.70099e+02,6.31507e+00);
//TS_temp.vw=10000000*NeutrinoEventShape->Eval(neutrino_.E(),neutrinobar_.E())*f_mbl.Eval((b_+al_).M())*f_mbl.Eval((bbar_+l_).M())*landau_n_temp.Eval(neutrino_.E())*landau_an_temp.Eval(neutrinobar_.E());
}
TS_temp.top = top_;
TS_temp.topbar = topbar_;
TS_temp.wp = w_;
TS_temp.wm = wbar_;
TS_temp.neutrino = neutrino_;
TS_temp.neutrinobar = neutrinobar_;
TLorentzVector b_boost_top=b_,bbar_boost_topbar=bbar_;
b_boost_top.Boost(-top_.BoostVector());
bbar_boost_topbar.Boost(-topbar_.BoostVector());
TLorentzVector topbar_boost_top=topbar_,top_boost_topbar=top_;
topbar_boost_top.Boost(-top_.BoostVector());
top_boost_topbar.Boost(-topbar_.BoostVector());
TLorentzVector l_boost_topbar=l_,al_boost_top=al_;
al_boost_top.Boost(-top_.BoostVector());
l_boost_topbar.Boost(-topbar_.BoostVector());
TS_temp.cos_bTR_top = cos(top_.Vect().Angle(b_boost_top.Vect()));
TS_temp.cos_bbarTR_topbar = cos(topbar_.Vect().Angle(bbar_boost_topbar.Vect()));
TLorentzVector top_boost=top_,topbar_boost=topbar_,b_boost=b_,bbar_boost=bbar_;
TS_temp.ttpt_top=top_boost.Pt();
TS_temp.ttpt_topbar=topbar_boost.Pt();
b_boost.Boost(-tt_.BoostVector());
bbar_boost.Boost(-tt_.BoostVector());
TS_temp.costheta=cos(topbar_boost_top.Vect().Angle(b_boost_top.Vect()));
TS_temp.costhetabar=cos(top_boost_topbar.Vect().Angle(bbar_boost_topbar.Vect()));
// costheta 1d weight
// vw1=hcosw_.GetBinContent(hcosw_.FindBin(TS_temp.costheta));
// vw2=hcosw_.GetBinContent(hcosw_.FindBin(TS_temp.costhetabar));
// TS_temp.vw=vw1*vw2;
// ...
b_boost.Boost(-top_boost.BoostVector());
TS_temp.cos1 = cos(top_boost.Vect().Angle(b_boost.Vect()));
TLorentzVector wb = w_+b_,w_boost=w_,al_boost=al_;
//w_boost.Boost(-wb.BoostVector());
al_boost.Boost(-w_.BoostVector());
//al_boost.Boost(-w_boost.BoostVector());
TS_temp.cos2 = cos(w_boost.Vect().Angle(al_boost.Vect()));
TS_temp.Mtt = tt_.M();
TS_temp.mttw = 1.0/TS_temp.Mtt;
//TS_temp.vw = 1.0/(neutrino_.Pt()+neutrinobar_.Pt());
vw1=4*mt_*al_boost_top.E()*(mt_*mt_-mb_*mb_-2*mt_*al_boost_top.E())/(pow((mt_*mt_-mb_*mb_),2)+mw_*mw_*(mt_*mt_-mb_*mb_)-2*pow(mw_,4));
vw2=4*mt_*l_boost_topbar.E()*(mt_*mt_-mb_*mb_-2*mt_*l_boost_topbar.E())/(pow((mt_*mt_-mb_*mb_),2)+mwbar_*mwbar_*(mt_*mt_-mb_*mb_)-2*pow(mwbar_,4));
TS_temp.lepEw=vw1*vw2;
TS_temp.mbl = (b_+al_).M();
TS_temp.mblbar = (bbar_+l_).M();
TS_temp.vw=TS_temp.mttw;
//if((fabs(top_.M()-mt_)+fabs(topbar_.M()-mtbar_))<0.01)
ttSol_.push_back(TS_temp);
}
nSol_=ttSol_.size();
if(nSol_>0)sortTopSol(ttSol_);
}
void KinematicReconstruction_LSroutines::filldTS()
{
double dellta_alpha;
double dellta_E;
for(int i=0;i<nSol_;i++)
{
dellta_alpha = pow(ttSol_[i].top.Angle(true_top_.Vect())/TMath::Pi(),2) + pow(ttSol_[i].topbar.Angle(true_topbar_.Vect())/TMath::Pi(),2);
dellta_E = pow((ttSol_[i].top.E()-true_top_.E())/true_top_.E(),2) + pow((ttSol_[i].topbar.E()-true_topbar_.E())/true_topbar_.E(),2);
//dellta_E = pow((ttSol_[i].top.Pt()-true_top_.Pt())/true_top_.Pt(),2) + pow((ttSol_[i].topbar.Pt()-true_topbar_.Pt())/true_topbar_.Pt(),2);
ttSol_[i].dTS = sqrt(dellta_alpha+dellta_E);
}
}
void KinematicReconstruction_LSroutines::filldR()
{
for(int i=0;i<nSol_;i++)
{
ttSol_[i].dR = sqrt(pow(ttSol_[i].top.DeltaR(true_top_),2)+pow(ttSol_[i].topbar.DeltaR(true_topbar_),2));
}
}
void KinematicReconstruction_LSroutines::filldN()
{
for(int i=0;i<nSol_;i++)
{
ttSol_[i].dN = sqrt(pow((ttSol_[i].neutrino.Px()-true_neutrino_.Px()),2)+pow((ttSol_[i].neutrino.Py()-true_neutrino_.Py()),2)+pow((ttSol_[i].neutrino.Pz()-true_neutrino_.Pz()),2)+pow((ttSol_[i].neutrinobar.Px()-true_neutrinobar_.Px()),2)+pow((ttSol_[i].neutrinobar.Py()-true_neutrinobar_.Py()),2)+pow((ttSol_[i].neutrinobar.Pz()-true_neutrinobar_.Pz()),2));
//ttSol_[i].dN = sqrt(pow((ttSol_[i].neutrino.Px()-true_neutrino_.Px()),2)+pow((ttSol_[i].neutrinobar.Px()-true_neutrinobar_.Px()),2));
}
}
void KinematicReconstruction_LSroutines::swapTopSol(KinematicReconstruction_LSroutines::TopSolution& sol1, KinematicReconstruction_LSroutines::TopSolution& sol2)
{
KinematicReconstruction_LSroutines::TopSolution aux = sol1;
sol1 = sol2;
sol2 = aux;
}
void KinematicReconstruction_LSroutines::sortBy(string ch)
{
if(ch=="dTS"&&ttSol_.size()>0)
{
for(uint i=0;i<ttSol_.size()-1;i++)
{
if(ttSol_[i].dTS > ttSol_[i+1].dTS){ swapTopSol(ttSol_[i],ttSol_[i+1]);i=-1;}
}
}
if(ch=="dR"&&ttSol_.size()>0)
{
for(uint i=0;i<ttSol_.size()-1;i++)
{
if(ttSol_[i].dR > ttSol_[i+1].dR){ swapTopSol(ttSol_[i],ttSol_[i+1]);i=-1;}
}
}
if(ch=="dN"&&ttSol_.size()>0)
{
for(uint i=0;i<ttSol_.size()-1;i++)
{
if(ttSol_[i].dN > ttSol_[i+1].dN){ swapTopSol(ttSol_[i],ttSol_[i+1]);i=-1; }
}
}
if(ch=="dRN"&&ttSol_.size()>0)
{
for(uint i=0;i<ttSol_.size()-1;i++)
{
if(ttSol_[i].dN*ttSol_[i].dR > ttSol_[i+1].dN*ttSol_[i+1].dR){ swapTopSol(ttSol_[i],ttSol_[i+1]);i=-1; }
}
}
}
void KinematicReconstruction_LSroutines::sortTopSol(vector< KinematicReconstruction_LSroutines::TopSolution >& v)
{
//std::vector< KinematicReconstruction_LSroutines::TopSolution > result;
for(uint i=0;i<v.size()-1;i++)
{
if(v[i].vw < v[i+1].vw){ swapTopSol(v[i],v[i+1]);i=-1;}
}
//v.swap(result);
}
void KinematicReconstruction_LSroutines::topRec(double sol)
{
double pxp, pyp, pzp, pup, pvp, pwp;
d0_=d00_;
d1_=d11_+d10_*sol;
d2_=d22_+d21_*sol+d20_*sol*sol;
c0_=c00_;
c1_=c11_+c10_*sol;
c2_=c22_+c21_*sol+c20_*sol*sol;
pup = sol;
pvp = (c0_*d2_-c2_*d0_)/(c1_*d0_-c0_*d1_);
pwp = (-1)*(a1_+a2_*pup+a3_*pvp)/a4_;
pxp = px_miss_-pup;
pyp = py_miss_-pvp;
pzp = (-1)*(b1_+b2_*pxp+b3_*pyp)/b4_;
neutrinobar_.SetXYZM(pxp, pyp, pzp, mav_);
neutrino_.SetXYZM(pup, pvp, pwp, mv_);
top_ = b_ + al_ + neutrino_;
topbar_ = bbar_ + l_ + neutrinobar_;
tt_=top_+topbar_;
w_ = al_ + neutrino_;
wbar_ = l_ + neutrinobar_;
}
void KinematicReconstruction_LSroutines::findCoeff(double* koeficienty)
{
a1_ = ((b_.E()+al_.E())*(mw_*mw_-mal_*mal_-mv_*mv_)-al_.E()*(mt_*mt_-mb_*mb_-mal_*mal_-mv_*mv_)+2*b_.E()*al_.E()*al_.E()-2*al_.E()*(al_.Vect().Dot(b_.Vect())))/(2*al_.E()*(b_.E()+al_.E()));
a2_ = 2*(b_.E()*al_.Px()-al_.E()*b_.Px())/(2*al_.E()*(b_.E()+al_.E()));
a3_ = 2*(b_.E()*al_.Py()-al_.E()*b_.Py())/(2*al_.E()*(b_.E()+al_.E()));
a4_ = 2*(b_.E()*al_.Pz()-al_.E()*b_.Pz())/(2*al_.E()*(b_.E()+al_.E()));
//printf("Koefs ai: %f %f %f %f\n",a1_,a2_,a3_,a4_);//printout
b1_ = ((bbar_.E()+l_.E())*(mwbar_*mwbar_-ml_*ml_-mav_*mav_)-l_.E()*(mtbar_*mtbar_-mbbar_*mbbar_-ml_*ml_-mav_*mav_)+2*bbar_.E()*l_.E()*l_.E()-2*l_.E()*(l_.Vect().Dot(bbar_.Vect())))/(2*l_.E()*(bbar_.E()+l_.E()));
b2_ = 2*(bbar_.E()*l_.Px()-l_.E()*bbar_.Px())/(2*l_.E()*(bbar_.E()+l_.E()));
b3_ = 2*(bbar_.E()*l_.Py()-l_.E()*bbar_.Py())/(2*l_.E()*(bbar_.E()+l_.E()));
b4_ = 2*(bbar_.E()*l_.Pz()-l_.E()*bbar_.Pz())/(2*l_.E()*(bbar_.E()+l_.E()));
//printf("Koefs bi: %f %f %f %f\n",b1_,b2_,b3_,b4_);//printout
c22_ = (sqr((mw_*mw_-mal_*mal_-mv_*mv_))-4*(sqr(al_.E())-sqr(al_.Pz()))*sqr(a1_/a4_)-4*(mw_*mw_-mal_*mal_-mv_*mv_)*al_.Pz()*(a1_/a4_))/sqr(2*(b_.E()+al_.E()));
c21_ = (4*(mw_*mw_-mal_*mal_-mv_*mv_)*(al_.Px()-al_.Pz()*(a2_/a4_))-8*(sqr(al_.E())-sqr(al_.Pz()))*(a1_*a2_/sqr(a4_))-8*al_.Px()*al_.Pz()*(a1_/a4_))/sqr(2*(b_.E()+al_.E()));
c20_ = (-4*(sqr(al_.E())-sqr(al_.Px()))-4*(sqr(al_.E())-sqr(al_.Pz()))*sqr(a2_/a4_)-8*al_.Px()*al_.Pz()*(a2_/a4_))/sqr(2*(b_.E()+al_.E()));
c11_ = (4*(mw_*mw_-mal_*mal_-mv_*mv_)*(al_.Py()-al_.Pz()*(a3_/a4_))-8*(sqr(al_.E())-sqr(al_.Pz()))*(a1_*a3_/sqr(a4_))-8*al_.Py()*al_.Pz()*(a1_/a4_))/sqr(2*(b_.E()+al_.E()));
c10_ = (-8*(sqr(al_.E())-sqr(al_.Pz()))*(a2_*a3_/sqr(a4_)) + 8*al_.Px()*al_.Py() - 8*al_.Px()*al_.Pz()*(a3_/a4_) - 8*al_.Py()*al_.Pz()*(a2_/a4_))/sqr(2*(b_.E()+al_.E()));
c00_ = (-4*(sqr(al_.E())-sqr(al_.Py())) -4*(sqr(al_.E())-sqr(al_.Pz()))*sqr(a3_/a4_)-8*al_.Py()*al_.Pz()*(a3_/a4_))/sqr(2*(b_.E()+al_.E()));
// printf("Koefs ci: %f %f %f %f %f %f\n",c22_,c21_/c22_,c11_/c22_,c20_/c22_,c10_/c22_,c00_/c22_);//printout
double D22,D21,D20,D11,D10,D00;
D22 = (sqr((mwbar_*mwbar_-ml_*ml_-mav_*mav_))-4*(sqr(l_.E())-sqr(l_.Pz()))*sqr(b1_/b4_)-4*(mwbar_*mwbar_-ml_*ml_-mav_*mav_)*l_.Pz()*(b1_/b4_))/sqr(2*(bbar_.E()+l_.E()));
D21 = (4*(mwbar_*mwbar_-ml_*ml_-mav_*mav_)*(l_.Px()-l_.Pz()*(b2_/b4_))-8*(sqr(l_.E())-sqr(l_.Pz()))*(b1_*b2_/sqr(b4_))-8*l_.Px()*l_.Pz()*(b1_/b4_))/sqr(2*(bbar_.E()+l_.E()));
D20 = (-4*(sqr(l_.E())-sqr(l_.Px()))-4*(sqr(l_.E())-sqr(l_.Pz()))*sqr(b2_/b4_)-8*l_.Px()*l_.Pz()*(b2_/b4_))/sqr(2*(bbar_.E()+l_.E()));
D11 = (4*(mwbar_*mwbar_-ml_*ml_-mav_*mav_)*(l_.Py()-l_.Pz()*(b3_/b4_))-8*(sqr(l_.E())-sqr(l_.Pz()))*(b1_*b3_/sqr(b4_))-8*l_.Py()*l_.Pz()*(b1_/b4_))/sqr(2*(bbar_.E()+l_.E()));
D10 = (-8*(sqr(l_.E())-sqr(l_.Pz()))*(b2_*b3_/sqr(b4_)) + 8*l_.Px()*l_.Py() - 8*l_.Px()*l_.Pz()*(b3_/b4_) - 8*l_.Py()*l_.Pz()*(b2_/b4_))/sqr(2*(bbar_.E()+l_.E()));
D00 = (-4*(sqr(l_.E())-sqr(l_.Py())) -4*(sqr(l_.E())-sqr(l_.Pz()))*sqr(b3_/b4_)-8*l_.Py()*l_.Pz()*(b3_/b4_))/sqr(2*(bbar_.E()+l_.E()));
//printf("Koefs di_: %f %f %f %f %f %f\n",D22,D21/D22,D11/D22,D20/D22,D10/D22,D00/D22);//printout
d22_ = D22+sqr(px_miss_)*D20+sqr(py_miss_)*D00+px_miss_*py_miss_*D10+px_miss_*D21+py_miss_*D11;
d21_ = -D21-2*px_miss_*D20-py_miss_*D10;
d20_ = D20;
d11_ = -D11-2*py_miss_*D00-px_miss_*D10;
d10_ = D10;
d00_ = D00;
//printf("Koefs di: %f %f %f %f %f %f\n",d22_, d21_/d22_, d11_/d22_, d20_/d22_, d10_/d22_, d00_/d22_);//printout
koeficienty[4] = sqr(c00_)*sqr(d22_)+c11_*d22_*(c11_*d00_-c00_*d11_)+c00_*c22_*(sqr(d11_)-2*d00_*d22_)+c22_*d00_*(c22_*d00_-c11_*d11_);
koeficienty[3] = c00_*d21_*(2*c00_*d22_-c11_*d11_)+c00_*d11_*(2*c22_*d10_+c21_*d11_)+c22_*d00_*(2*c21_*d00_-c11_*d10_)-c00_*d22_*(c11_*d10_+c10_*d11_)-2*c00_*d00_*(c22_*d21_+c21_*d22_)-d00_*d11_*(c11_*c21_+c10_*c22_)+c11_*d00_*(c11_*d21_+2*c10_*d22_);
koeficienty[2] = sqr(c00_)*(2*d22_*d20_+sqr(d21_))-c00_*d21_*(c11_*d10_+c10_*d11_)+c11_*d20_*(c11_*d00_-c00_*d11_)+c00_*d10_*(c22_*d10_-c10_*d22_)+c00_*d11_*(2*c21_*d10_+c20_*d11_)+(2*c22_*c20_+sqr(c21_))*sqr(d00_)-2*c00_*d00_*(c22_*d20_+c21_*d21_+c20_*d22_)+c10_*d00_*(2*c11_*d21_+c10_*d22_)-d00_*d10_*(c11_*c21_+c10_*c22_)-d00_*d11_*(c11_*c20_+c10_*c21_);
// koeficienty[1] = c00_*d21_*(2*c00_*d20_-c10_*d10_)-c00_*d20_*(c11_*d10_+c10_*d11_)+c00_*d10_*(c21_*d10_+2*c20_*d11_)-2*c00_*d00_*(c21_*d20_+c20_*d21_)+c10_*d00_*(2*c11_*d20_+c10_*d21_)-c20_*d00_*(2*c21_*d00_-c10_*d11_)-d00_*d10_*(c11_*c20_+c10_*c21_);
koeficienty[1] = c00_*d21_*(2*c00_*d20_-c10_*d10_)-c00_*d20_*(c11_*d10_+c10_*d11_)+c00_*d10_*(c21_*d10_+2*c20_*d11_)-2*c00_*d00_*(c21_*d20_+c20_*d21_)+c10_*d00_*(2*c11_*d20_+c10_*d21_)+c20_*d00_*(2*c21_*d00_-c10_*d11_)-d00_*d10_*(c11_*c20_+c10_*c21_);
koeficienty[0] = sqr(c00_)*sqr(d20_)+c10_*d20_*(c10_*d00_-c00_*d10_)+c20_*d10_*(c00_*d10_-c10_*d00_)+c20_*d00_*(c20_*d00_-2*c00_*d20_);
//printf("Koefs_in_f: %15.15f %f %f %f %f\n",koeficienty[0],koeficienty[1],koeficienty[2],koeficienty[3],koeficienty[4]); //printout
}
double KinematicReconstruction_LSroutines::sqr(double x)
{
return (x*x);
}
void KinematicReconstruction_LSroutines::swap(double& realone, double& realtwo)
{
if (realtwo < realone) {
double aux = realtwo;
realtwo = realone;
realone = aux;
}
}
int KinematicReconstruction_LSroutines::sign(long double ld)
{
if(fabs(ld)<0.0000000000001) return 0;
return (ld>0)?1:-1;
}
void KinematicReconstruction_LSroutines::quartic_equation(double h0, double h1, double h2, double h3, double h4, std::vector< double >& v)
{
std::vector<double> result;
//printf("Koefs_in_f: %f %f %f %f %f\n",h0,h1,h2,h3,h4); //printout
//printf("Koefs_norm_in_f: %f %f %f %f %f\n",h0/h0,h1/h0,h2/h0,h3/h0,h4/h0); //printout
if(sign(a4_)==0||sign(b4_)==0)
{
result.push_back(0);
v.swap(result);
}
else
{
//printf("else1\n"); //printout
if(sign(h0)==0)
{
cubic_equation(h1,h2,h3,h4,result);
v.swap(result);
}
else
{
//printf("else2\n"); //printout
if(sign(h4)==0)
{
cubic_equation(h0,h1,h2,h3,result);
result[0]=result[0]+1;
result.push_back(0);
v.swap(result);
}
else
{
//printf("else3\n"); //printout
double H1=h1/h0;
double H2=h2/h0;
double H3=h3/h0;
double H4=h4/h0;
double K1 = H2 -3*sqr(H1)/8;
double K2 = H3 + H1*sqr(H1)/8-H1*H2/2;
double K3 = H4-3*sqr(sqr(H1))/256+sqr(H1)*H2/16-H1*H3/4;
//printf("Koefs Ki: %f %f %10.10f\n",K1,K2,K3);//printout
if(sign(K3)==0)
{
cubic_equation(1,0,K1,K2,result);
for(int i=1;i<=result[0];i++)
{
result[i]=result[i]-H1/4;
}
result[0]=result[0]+1;
result.push_back(-H1/4);
v.swap(result);
}
else
{
//printf("else4\n"); //printout
std::vector<double> result_t12;
std::vector<double> result_t1;
result_t1.push_back(0);
std::vector<double> result_t2;
result_t2.push_back(0);
cubic_equation(1,2*K1,(K1*K1-4*K3),(-1)*K2*K2,result_t12);
//std::cout << "hehehe: " << result_t12[0] << std::endl; //printout
for(int i=1;i<=result_t12[0];i++)
{
//std::cout << "heh: " << result_t12[i] << std::endl; //printout
if(result_t12[i]>=0)
{
result_t1[0]=result_t1[0]+2;
result_t1.push_back(sqrt(result_t12[i]));
result_t1.push_back((-1)*sqrt(result_t12[i]));
result_t2[0]=result_t2[0]+2;
result_t2.push_back((K1+result_t12[i]-K2/sqrt(result_t12[i]))/2);
result_t2.push_back((K1+result_t12[i]+K2/sqrt(result_t12[i]))/2);
}
}
//std::cout << std::endl;
std::vector<double> pre_result1;
result.push_back(0);
for(int i=1;i<=result_t1[0];i++)
{
//std::cout << "quadric_equation: " << i << " " << result_t1[i] << " " << result_t2[i] << std::endl; //printout
quadratic_equation(1,result_t1[i],result_t2[i],pre_result1);
for(int j=1;j<=pre_result1[0];j++)
{
// if(pre_result1[0]==2)std::cout << "quadric_equation: " << i << " " << pre_result1[1] << " " << pre_result1[2] << std::endl; //printout
int flag=1;
for(int r=1;r<=result[0];r++)
{
if(fabs(result[r]-pre_result1[j])<0.01)flag=0;
//printf("Result-result: %10.10f \n",result[r]-pre_result1[j]);
}
if(flag)
{
result[0]=result[0]+1;
result.push_back(pre_result1[j]);
}
}
pre_result1.clear();
}
for(int k=1;k<=result[0];k++)
{
//printf("Result: %f %f \n",H1/4,h1/4); //printout
result[k]=result[k]-H1/4;
}
v.swap(result);
}
}
}
}
}
void KinematicReconstruction_LSroutines::cubic_equation(double a, double b, double c, double d, std::vector< double >& v)
{
std::vector<double> result;
if(a==0)
{
quadratic_equation(b,c,d,result);
v.swap(result);
}
else
{
double s1 = b/a;
double s2 = c/a;
double s3 = d/a;
double q = (s1*s1-3*s2)/9;
double q3 = q*q*q;
double r = (2*s1*s1*s1-9*s1*s2+27*s3)/54;
double r2 = r*r;
double S = r2-q3;
if(sign(S)<0)
{
result.push_back(3);
double F = acos(r/sqrt(q3));
result.push_back(-2*sqrt(fabs(q))*cos(F/3)-s1/3);
result.push_back(-2*sqrt(fabs(q))*cos((F+2*TMath::Pi())/3)-s1/3);
result.push_back(-2*sqrt(fabs(q))*cos((F-2*TMath::Pi())/3)-s1/3);
v.swap(result);
}
else
{
if(sign(S)==0)
{
long double A = r+sqrt(fabs(r2-q3));
A = A<0 ? pow(fabs(A),(long double)1.0/3) : -pow(fabs(A),(long double)1.0/3);
long double B = sign(A) == 0 ? 0 : q/A;
result.push_back(2);
result.push_back(A+B-s1/3);
result.push_back(-0.5*(A+B)-s1/3); //!!!
v.swap(result);
}
else
{
long double A = r+sqrt(fabs(r2-q3));
A = A<0 ? pow(fabs(A),(long double)1.0/3) : -pow(fabs(A),(long double)1.0/3);
long double B = sign(A) == 0 ? 0 : q/A;
result.push_back(1);
result.push_back(A+B-s1/3);
v.swap(result);
}
}
}
}
void KinematicReconstruction_LSroutines::quadratic_equation(double a, double b, double c, std::vector< double >& v)
{
std::vector<double> result;
//printf("a: %10.10f\n",a);//printout
if(a==0)
{
linear_equation(b,c,result);
v.swap(result);
}
else
{
double D = b*b-4*a*c;
//printf("D: %10.10f\n",D);//printout
if(sign(D)<0)
{
result.push_back(0);
v.swap(result);
}
else
{
if(sign(D)==0)
{
result.push_back(1);
result.push_back((-1)*b/(2*a));
v.swap(result);
}
else
{
result.push_back(2);
result.push_back((-b-sqrt(D))/(2*a));
result.push_back((-b+sqrt(D))/(2*a));
v.swap(result);
}
}
}
}
void KinematicReconstruction_LSroutines::linear_equation(double a, double b, std::vector< double >& v)
{
std::vector<double> result;
if(a==0)
{
result.push_back(0);
v.swap(result);
}
else
{
result.push_back(1);
result.push_back((-1)*(b/a));
v.swap(result);
}
}
| [
"[email protected]"
] | |
59fb2190673cffad3464ca59f8b1ded700923353 | ceeddddcf3e99e909c4af5ff2b9fad4a8ecaeb2a | /tags/release-1.1/source/Irrlicht/CCSMLoader.cpp | f8fa3f9d28ab29ad6c4b6e84f472cb564f13b48b | [
"Zlib",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | jivibounty/irrlicht | d9d6993bd0aee00dce2397a887b7f547ade74fbb | c5c80cde40b6d14fe5661440638d36a16b41d7ab | refs/heads/master | 2021-01-18T02:56:08.844268 | 2015-07-21T08:02:25 | 2015-07-21T08:02:25 | 39,405,895 | 0 | 0 | null | 2015-07-20T20:07:06 | 2015-07-20T20:07:06 | null | UTF-8 | C++ | false | false | 18,458 | cpp | // Copyright (C) 2002-2006 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
//
// This file was written by Saurav Mohapatra and modified by Nikolaus Gebhardt.
// See CCSMLoader.h for details.
#include "CCSMLoader.h"
#include "os.h"
#include "IFileSystem.h"
#include "IReadFile.h"
#include "ISceneManager.h"
#include "IAttributes.h"
#include "SMesh.h"
#include "IVideoDriver.h"
#include <string.h>
#include "SAnimatedMesh.h"
namespace irr
{
namespace scene
{
//
// the CSM data types
//
struct color_rgb_t
{
s32 red;
s32 green;
s32 blue;
void clear()
{
red = 0;
green = 0;
blue = 0;
}
};
class BinaryFileReader;
//
// The file header
//
class Header
{
public:
static const s32 VERSION_4;
static const s32 VERSION_4_1;
Header(){ clear(); }
virtual ~Header(){ clear(); }
s32 getVersion() const{ return version; }
void clear(){ version = 0; }
void load(BinaryFileReader* pReader);
private:
s32 version;
};
//
// The groups
//
class Group
{
public:
Group(){ clear(); }
virtual ~Group(){ clear(); }
void clear();
void load(BinaryFileReader* pReader);
s32 getFlags() const { return flags; }
s32 getParentGroupID() const { return parentGroup; }
const core::stringc& getProperties() const { return props; }
const color_rgb_t* getColor() const { return &color; }
private:
s32 flags;
s32 parentGroup;
core::stringc props;
color_rgb_t color;
};
//
// The visgroups
//
class VisGroup
{
public:
VisGroup(){ clear(); }
virtual ~VisGroup(){ clear(); }
void clear();
void load(BinaryFileReader* pReader);
s32 getFlags() const{ return flags; }
const core::stringc& getName() const{ return name; }
const color_rgb_t* getColor() const{ return &color; }
private:
core::stringc name;
s32 flags;
color_rgb_t color;
};
//
// Lightmaps
//
class LightMap
{
public:
LightMap() : pixelData(0){ clear(); }
virtual ~LightMap(){ clear(); }
void clear();
void load(BinaryFileReader* pReader);
s32 getWidth() const{ return width; }
s32 getHeight() const{ return height; }
const s32* getPixelData() const{ return pixelData; }
private:
s32 width;
s32 height;
s32* pixelData;
};
struct Triangle
{
s32 a,b,c;
};
struct Line
{
s32 a,b;
};
class Vertex
{
public:
Vertex(){ clear(); }
virtual ~Vertex(){ clear(); }
void clear();
void load(BinaryFileReader* pReader);
const core::vector3df* getPosition() const { return &position; }
const core::vector3df* getNormal() const { return &normal; }
const color_rgb_t* getColor() const { return &color; }
const core::vector3df* getTextureCoordinates() const { return &texCoords; }
const core::vector3df* getLightMapCoordinates() const { return &lmapCoords; }
private:
core::vector3df position;
core::vector3df normal;
color_rgb_t color;
core::vector3df texCoords;
core::vector3df lmapCoords;
};
class Surface
{
public:
Surface() { clear(); }
virtual ~Surface(){ clear(); }
void clear();
void load(BinaryFileReader *pReader);
s32 getFlags() const{ return flags; }
const core::stringc& getTextureName() const{ return textureName; }
s32 getLightMapId() const{ return lightMapId; }
const core::vector2df* getUVOffset() const{ return &uvOffset; }
const core::vector2df* getUVScale() const{ return &uvScale; }
f32 getUVRotation() const{ return uvRotation; }
s32 getVertexCount() const{ return vertices.size(); }
const Vertex* getVertexAt(const s32 index) const{ return vertices[index]; }
s32 getTriangleCount() const{ return triangles.size(); }
const Triangle& getTriangleAt(const s32 index) const{ return triangles[index]; }
private:
s32 flags;
core::stringc textureName;
s32 lightMapId;
core::vector2df uvOffset;
core::vector2df uvScale;
f32 uvRotation;
core::array<Vertex*> vertices;
core::array<Triangle> triangles;
core::array<Line> lines;
};
class Mesh
{
public:
Mesh(){ clear(); }
virtual ~Mesh(){ clear(); }
void clear();
void load(BinaryFileReader* pReader, bool bReadVisGroups);
s32 getFlags() const { return flags; }
s32 getGroupID() const { return groupId; }
const core::stringc& getProperties() const { return props; }
const color_rgb_t* getColor() const { return &color; }
const core::vector3df* getPosition() const { return &position; }
s32 getVisgroupID() const { return visgroupId; }
s32 getSurfaceCount() const { return surfaces.size(); }
const Surface* getSurfaceAt(const s32 index) const { return surfaces[index]; }
private:
s32 flags;
s32 groupId;
core::stringc props;
color_rgb_t color;
core::vector3df position;
s32 visgroupId;
core::array<Surface*> surfaces;
};
class Entity
{
public:
Entity() { clear(); }
virtual ~Entity() { clear(); }
void clear();
void load(BinaryFileReader* pReader);
s32 getVisgroupID() const { return visgroupId; }
s32 getGroupID() const { return groupId; }
const core::stringc& getProperties() const { return props; }
const core::vector3df* getPosition() const { return &position; }
private:
s32 visgroupId;
s32 groupId;
core::stringc props;
core::vector3df position;
};
class CameraData
{
public:
CameraData(){ clear(); }
virtual ~CameraData(){ clear(); }
void clear();
void load(BinaryFileReader* pReader);
const core::vector3df* getPosition(){ return &position; }
f32 getPitch(){ return pitch; }
f32 getYaw(){ return yaw; }
private:
core::vector3df position;
f32 pitch;
f32 yaw;
};
//
// A CSM File
//
class CSMFile
{
public:
CSMFile(){ clear(); }
virtual ~CSMFile(){ clear(); }
void clear();
void load(BinaryFileReader* pReader);
const Header* getHeader() const{ return &header; }
s32 getGroupCount() const{ return groups.size(); }
const Group* getGroupAt(const s32 index) const{ return groups[index]; }
s32 getVisGroupCount() const{ return visgroups.size(); }
const VisGroup* getVisGroupAt(const s32 index) const{ return visgroups[index]; }
s32 getLightMapCount() const{ return lightmaps.size(); }
const LightMap* getLightMapAt(const s32 index) const { return lightmaps[index]; }
s32 getMeshCount() const{ return meshes.size(); }
const Mesh* getMeshAt(const s32 index) const{ return meshes[index]; }
s32 getEntityCount() const{ return entities.size(); }
const Entity* getEntityAt(const s32 index) const{ return entities[index]; }
const CameraData* getCameraData() const{ return &cameraData; }
private:
Header header;
core::array<Group*> groups;
core::array<VisGroup*> visgroups;
core::array<LightMap*> lightmaps;
core::array<Mesh*> meshes;
core::array<Entity*> entities;
CameraData cameraData;
};
//
// A Binary File Reader
//
class BinaryFileReader
{
public:
BinaryFileReader(io::IReadFile* pFile, bool closeWhenDone=true);
virtual ~BinaryFileReader();
virtual s32 readBuffer(void* buffer, s32 len);
s32 readLong();
f32 readFloat();
u8 readByte();
core::stringc readString();
void readVec3f(core::vector3df* v);
void readVec2f(core::vector2df* v);
void readColorRGB(color_rgb_t* color);
private:
io::IReadFile *file;
bool autoClose;
};
CCSMLoader::CCSMLoader(scene::ISceneManager* manager, io::IFileSystem* fs)
: FileSystem(fs), SceneManager(manager)
{
}
CCSMLoader::~CCSMLoader()
{
}
//! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".bsp")
bool CCSMLoader::isALoadableFileExtension(const c8* fileName)
{
return strstr(fileName, ".csm")!=0;
}
//! creates/loads an animated mesh from the file.
IAnimatedMesh* CCSMLoader::createMesh(irr::io::IReadFile* file)
{
file->grab(); // originally, this loader created the file on its own.
scene::IMesh* m = createCSMMesh(file);
if (!m)
return 0;
SAnimatedMesh* am = new SAnimatedMesh();
am->Type = EAMT_CSM;
am->addMesh(m);
m->drop();
am->recalculateBoundingBox();
return am;
}
scene::IMesh* CCSMLoader::createCSMMesh(irr::io::IReadFile* file)
{
if (!file)
return 0;
if(file)
{
BinaryFileReader reader(file, true);
CSMFile csmFile;
csmFile.load(&reader);
scene::IMesh* pMesh = createIrrlichtMesh(&csmFile,
SceneManager->getParameters()->getAttributeAsString(CSM_TEXTURE_PATH),
file->getFileName());
return pMesh;
}
return 0;
}
scene::IMesh* CCSMLoader::createIrrlichtMesh(const CSMFile* csmFile,
core::stringc textureRoot, const c8* lmprefix)
{
scene::SMesh *pMesh = new scene::SMesh();
video::IVideoDriver* driver = SceneManager->getVideoDriver();
for(s32 l = 0; l<csmFile->getLightMapCount(); l++)
{
const LightMap* lmap = csmFile->getLightMapAt(l);
core::stringc lmapName = lmprefix;
lmapName += "LMAP_";
lmapName += (int)(l+1);
os::Printer::log("CCSMLoader loading light map", lmapName.c_str());
video::IImage* lmapImg = driver->createImageFromData(
video::ECF_A8R8G8B8,
core::dimension2d<s32>(lmap->getWidth(),lmap->getHeight()),
(void *)(lmap->getPixelData()));
driver->addTexture(lmapName.c_str(), lmapImg);
lmapImg->drop();
}
for(s32 m = 0; m<csmFile->getMeshCount(); m++)
{
const Mesh* mshPtr = csmFile->getMeshAt(m);
for(s32 s = 0; s < mshPtr->getSurfaceCount(); s++)
{
const Surface* surface = mshPtr->getSurfaceAt(s);
core::stringc texName = textureRoot;
texName+= "/";
texName+= surface->getTextureName();
video::ITexture* texture = driver->getTexture(texName.c_str());
scene::SMeshBufferLightMap *buffer = new scene::SMeshBufferLightMap();
//material
core::stringc lmapName = lmprefix;
lmapName += "LMAP_";
lmapName += (int)surface->getLightMapId();
buffer->Material.Texture1 = texture;
buffer->Material.Texture2 = driver->getTexture(lmapName.c_str());
buffer->Material.Lighting = false;
buffer->Material.MaterialType = video::EMT_LIGHTMAP_M4;
for(s32 v = 0; v < surface->getVertexCount(); v++)
{
const Vertex *vtxPtr = surface->getVertexAt(v);
video::S3DVertex2TCoords vtx;
vtx.Pos = *(vtxPtr->getPosition());
vtx.Normal = *(vtxPtr->getPosition());
vtx.Color.set(255,vtxPtr->getColor()->red,vtxPtr->getColor()->green,vtxPtr->getColor()->blue);
vtx.TCoords.set(vtxPtr->getTextureCoordinates()->X,vtxPtr->getTextureCoordinates()->Y);
vtx.TCoords2.set(vtxPtr->getLightMapCoordinates()->X,0.0f - vtxPtr->getLightMapCoordinates()->Y);
buffer->Vertices.push_back(vtx);
}
for(s32 t = 0; t < surface->getTriangleCount(); t++)
{
const Triangle& tri = surface->getTriangleAt(t);
buffer->Indices.push_back(tri.a);
buffer->Indices.push_back(tri.c);
buffer->Indices.push_back(tri.b);
}
buffer->recalculateBoundingBox();
pMesh->addMeshBuffer(buffer);
buffer->drop();
}
}
pMesh->recalculateBoundingBox();
return pMesh;
}
const s32 Header::VERSION_4 = 4;
const s32 Header::VERSION_4_1 = 5;
void Header::load(BinaryFileReader* pReader)
{
version = pReader->readLong();
}
void Group::clear()
{
color.clear();
flags = 0;
parentGroup = 0;
props = "";
}
void Group::load(BinaryFileReader* pReader)
{
flags = pReader->readLong();
parentGroup = pReader->readLong();
props = pReader->readString();
pReader->readColorRGB(&color);
}
void VisGroup::clear()
{
color.clear();
flags = 0;
name = "";
}
void VisGroup::load(BinaryFileReader* pReader)
{
name = pReader->readString();
flags = pReader->readLong();
pReader->readColorRGB(&color);
}
void LightMap::clear()
{
if(pixelData)
{
delete[] pixelData;
pixelData = 0;
}
width = height = 0;
}
void LightMap::load(BinaryFileReader* pReader)
{
width = pReader->readLong();
height = pReader->readLong();
pixelData = new s32[width * height];
pReader->readBuffer(pixelData, width * height * sizeof(s32));
}
void Mesh::clear()
{
flags = 0;
groupId = 0;
visgroupId = 0;
props = "";
color.clear();
position.set(0,0,0);
for(u32 s = 0; s < surfaces.size(); s++)
{
if(surfaces[s])
{
delete surfaces[s];
}
}
surfaces.clear();
}
void Mesh::load(BinaryFileReader* pReader, bool bReadVisGroups)
{
flags = pReader->readLong();
groupId = pReader->readLong();
props = pReader->readString();
pReader->readColorRGB(&color);
pReader->readVec3f(&position);
if(bReadVisGroups)
visgroupId = pReader->readLong();
else
visgroupId = 0;
s32 count = pReader->readLong();
for(s32 i = 0; i < count; i++)
{
Surface* surf = new Surface();
surf->load(pReader);
surfaces.push_back(surf);
}
}
void Surface::clear()
{
flags = 0;
lightMapId = 0;
textureName = 0;
uvOffset.set(0.0f,0.0f);
uvScale.set(0.0f,0.0f);
uvRotation = 0.0f;
triangles.clear();
lines.clear();
for(u32 v = 0; v < vertices.size(); v++)
delete vertices[v];
vertices.clear();
}
void Surface::load(BinaryFileReader* pReader)
{
flags = pReader->readLong();
textureName = pReader->readString();
lightMapId = pReader->readLong();
pReader->readVec2f(&uvOffset);
pReader->readVec2f(&uvScale);
uvRotation = pReader->readFloat();
s32 vtxCount = pReader->readLong();
s32 triCount = pReader->readLong();
s32 lineCount = pReader->readLong();
for(s32 v = 0; v < vtxCount; v++)
{
Vertex *vtx = new Vertex();
vtx->load(pReader);
vertices.push_back(vtx);
}
for(s32 t = 0; t < triCount; t++)
{
Triangle tri;
pReader->readBuffer(&tri, sizeof(tri));
triangles.push_back(tri);
}
for(s32 l = 0; l < lineCount; l++)
{
Line line;
pReader->readBuffer(&line,sizeof(line));
lines.push_back(line);
}
}
void Vertex::clear()
{
position.set(0,0,0);
normal.set(0,0,0);
color.clear();
texCoords.set(0,0,0);
lmapCoords.set(0,0,0);
}
void Vertex::load(BinaryFileReader* pReader)
{
pReader->readVec3f(&position);
pReader->readVec3f(&normal);
pReader->readColorRGB(&color);
pReader->readVec3f(&texCoords);
pReader->readVec3f(&lmapCoords);
}
void Entity::clear()
{
visgroupId = groupId = 0;
props = "";
position.set(0,0,0);
}
void Entity::load(BinaryFileReader* pReader)
{
visgroupId = pReader->readLong();
groupId = pReader->readLong();
props = pReader->readString();
pReader->readVec3f(&position);
}
void CameraData::clear()
{
position.set(0,0,0);
pitch = 0;
yaw = 0;
}
void CameraData::load(BinaryFileReader* pReader)
{
pReader->readVec3f(&position);
pitch = pReader->readFloat();
yaw = pReader->readFloat();
}
void CSMFile::clear()
{
header.clear();
cameraData.clear();
u32 x =0;
for( x= 0; x < groups.size(); x++)
delete groups[x];
groups.clear();
for(x= 0; x < visgroups.size(); x++)
delete visgroups[x];
visgroups.clear();
for(x= 0; x < lightmaps.size(); x++)
delete lightmaps[x];
lightmaps.clear();
for(x= 0; x < meshes.size(); x++)
delete meshes[x];
meshes.clear();
for(x= 0; x < entities.size(); x++)
delete entities[x];
entities.clear();
}
void CSMFile::load(BinaryFileReader* pReader)
{
clear();
header.load(pReader);
//groups
{
s32 count = pReader->readLong();
for (s32 i = 0; i < count; i++)
{
Group* grp = new Group();
grp->load(pReader);
groups.push_back(grp);
}
}
bool bHasVGroups = (header.getVersion() == Header::VERSION_4_1);
if (bHasVGroups)
{
//visgroups
s32 count = pReader->readLong();
for (s32 i = 0; i < count; i++)
{
VisGroup* grp = new VisGroup();
grp->load(pReader);
visgroups.push_back(grp);
}
}
//lightmaps
{
s32 count = pReader->readLong();
for(s32 i = 0; i < count; i++)
{
LightMap* grp = new LightMap();
grp->load(pReader);
lightmaps.push_back(grp);
}
}
//meshes
{
s32 count = pReader->readLong();
for(s32 i = 0; i < count; i++)
{
Mesh* grp = new Mesh();
grp->load(pReader,bHasVGroups);
meshes.push_back(grp);
}
}
//entities
{
s32 count = pReader->readLong();
for(s32 i = 0; i < count; i++)
{
Entity* grp = new Entity();
grp->load(pReader);
entities.push_back(grp);
}
}
//camera data
cameraData.load(pReader);
}
BinaryFileReader::BinaryFileReader(io::IReadFile* pFile,
bool closeWhenDone)
: file(pFile), autoClose(closeWhenDone)
{
}
BinaryFileReader::~BinaryFileReader()
{
if(autoClose && file)
{
file->drop();
file = 0;
}
}
s32 BinaryFileReader::readBuffer(void* buffer, s32 len)
{
return file->read(buffer,len);
}
s32 BinaryFileReader::readLong()
{
s32 ret = 0;
readBuffer(&ret,sizeof(ret));
return ret;
}
f32 BinaryFileReader::readFloat()
{
f32 ret = 0;
readBuffer(&ret,sizeof(ret));
return ret;
}
u8 BinaryFileReader::readByte()
{
u8 ret = 0;
readBuffer(&ret,sizeof(ret));
return ret;
}
core::stringc BinaryFileReader::readString()
{
core::stringc str = "";
c8 c = (c8)readByte();
while(c != 0)
{
str += c;
c = (c8)readByte();
}
return str;
}
void BinaryFileReader::readVec3f(core::vector3df* v)
{
v->X = readFloat();
v->Y = readFloat();
v->Z = readFloat();
}
void BinaryFileReader::readVec2f(core::vector2df* v)
{
v->X = readFloat();
v->Y = readFloat();
}
void BinaryFileReader::readColorRGB(color_rgb_t* color)
{
readBuffer(color,sizeof(color_rgb_t));
}
} // end namespace
} // end namespace
| [
"hybrid@dfc29bdd-3216-0410-991c-e03cc46cb475"
] | hybrid@dfc29bdd-3216-0410-991c-e03cc46cb475 |
51aafa0b527a224a892bd8f11ed21e7594715266 | cbefd47058e3eab94d7fb502c69c2451875b5fc3 | /DesktopSprite/Scripts/SpriteAction.cpp | b63e98b1ecfcb61fbd6d72065ead9c7c137cea2f | [] | no_license | lineCode/WindowsSprite | b4615527c637d7f566794f38819a0c503a781536 | 498790a3049a024b541a6ef40107a26ae9b55bfa | refs/heads/master | 2020-03-27T19:12:46.248005 | 2018-07-29T12:10:59 | 2018-07-29T12:10:59 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,047 | cpp |
#include "SpriteAction.h"
namespace Sprite {
SpriteAction::SpriteAction(ID2D1Bitmap* images[], int length, float delay, bool reverse = false)
{
currentIndex = 0;
// 数组长度
this->length = length;
this->images = new ID2D1Bitmap*[length];
for (int i = 0; i < length; i++)
{
this->images[i] = images[i];
}
this->delayTime = delay;
this->reverse = reverse;
//images;
}
SpriteAction::~SpriteAction()
{
}
float SpriteAction::GetDelay()
{
return this->delayTime;
}
void SpriteAction::ActionBefore()
{
}
void SpriteAction::ActionAfter(PlayerResult result)
{
int nextIndex = currentIndex + turn;
switch (result)
{
case sing:
if (reverse)
{
if (nextIndex < 0)
turn = 1;
else if (nextIndex > length - 1)
turn = -1;
}
currentIndex += turn;
break;
case delay:
break;
case expetion:
break;
default:
break;
}
}
// 执行动作-
ID2D1Bitmap * SpriteAction::ActionIng()
{
ID2D1Bitmap * result = this->images[currentIndex];
return result;
}
}
| [
"[email protected]"
] | |
d73841ca633b36613541971c75b61878774843d4 | 4cc4d9d488939dde56fda368faf58d8564047673 | /system/chre/core/sensor_request.cc | 0d6ddc30834dd475c99cf50946763c87e6da916f | [] | no_license | Tosotada/android-8.0.0_r4 | 24b3e4590c9c0b6c19f06127a61320061e527685 | 7b2a348b53815c068a960fe7243b9dc9ba144fa6 | refs/heads/master | 2020-04-01T11:39:03.926512 | 2017-08-28T16:26:25 | 2017-08-28T16:26:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,434 | cc | /*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <algorithm>
#include "chre/core/sensor_request.h"
#include "chre/platform/assert.h"
#include "chre/platform/fatal_error.h"
namespace chre {
const char *getSensorTypeName(SensorType sensorType) {
switch (sensorType) {
case SensorType::Unknown:
return "Unknown";
case SensorType::Accelerometer:
return "Accelerometer";
case SensorType::InstantMotion:
return "Instant Motion";
case SensorType::StationaryDetect:
return "Stationary Detect";
case SensorType::Gyroscope:
return "Gyroscope";
case SensorType::GeomagneticField:
return "Geomagnetic Field";
case SensorType::Pressure:
return "Pressure";
case SensorType::Light:
return "Light";
case SensorType::Proximity:
return "Proximity";
case SensorType::AccelerometerTemperature:
return "Accelerometer Temp";
case SensorType::GyroscopeTemperature:
return "Gyroscope Temp";
case SensorType::UncalibratedAccelerometer:
return "Uncal Accelerometer";
case SensorType::UncalibratedGyroscope:
return "Uncal Gyroscope";
case SensorType::UncalibratedGeomagneticField:
return "Uncal Geomagnetic Field";
default:
CHRE_ASSERT(false);
return "";
}
}
uint16_t getSampleEventTypeForSensorType(SensorType sensorType) {
if (sensorType == SensorType::Unknown) {
FATAL_ERROR("Tried to obtain the sensor sample event index for an unknown "
"sensor type");
}
// The enum values of SensorType may not map to the defined values in the
// CHRE API.
uint8_t sensorTypeValue = getUnsignedIntFromSensorType(sensorType);
return CHRE_EVENT_SENSOR_DATA_EVENT_BASE + sensorTypeValue;
}
SensorType getSensorTypeForSampleEventType(uint16_t eventType) {
return getSensorTypeFromUnsignedInt(
eventType - CHRE_EVENT_SENSOR_DATA_EVENT_BASE);
}
SensorType getSensorTypeFromUnsignedInt(uint8_t sensorType) {
switch (sensorType) {
case CHRE_SENSOR_TYPE_ACCELEROMETER:
return SensorType::Accelerometer;
case CHRE_SENSOR_TYPE_INSTANT_MOTION_DETECT:
return SensorType::InstantMotion;
case CHRE_SENSOR_TYPE_STATIONARY_DETECT:
return SensorType::StationaryDetect;
case CHRE_SENSOR_TYPE_GYROSCOPE:
return SensorType::Gyroscope;
case CHRE_SENSOR_TYPE_GEOMAGNETIC_FIELD:
return SensorType::GeomagneticField;
case CHRE_SENSOR_TYPE_PRESSURE:
return SensorType::Pressure;
case CHRE_SENSOR_TYPE_LIGHT:
return SensorType::Light;
case CHRE_SENSOR_TYPE_PROXIMITY:
return SensorType::Proximity;
case CHRE_SENSOR_TYPE_ACCELEROMETER_TEMPERATURE:
return SensorType::AccelerometerTemperature;
case CHRE_SENSOR_TYPE_GYROSCOPE_TEMPERATURE:
return SensorType::GyroscopeTemperature;
case CHRE_SENSOR_TYPE_UNCALIBRATED_ACCELEROMETER:
return SensorType::UncalibratedAccelerometer;
case CHRE_SENSOR_TYPE_UNCALIBRATED_GYROSCOPE:
return SensorType::UncalibratedGyroscope;
case CHRE_SENSOR_TYPE_UNCALIBRATED_GEOMAGNETIC_FIELD:
return SensorType::UncalibratedGeomagneticField;
default:
return SensorType::Unknown;
}
}
uint8_t getUnsignedIntFromSensorType(SensorType sensorType) {
switch (sensorType) {
case SensorType::Accelerometer:
return CHRE_SENSOR_TYPE_ACCELEROMETER;
case SensorType::InstantMotion:
return CHRE_SENSOR_TYPE_INSTANT_MOTION_DETECT;
case SensorType::StationaryDetect:
return CHRE_SENSOR_TYPE_STATIONARY_DETECT;
case SensorType::Gyroscope:
return CHRE_SENSOR_TYPE_GYROSCOPE;
case SensorType::GeomagneticField:
return CHRE_SENSOR_TYPE_GEOMAGNETIC_FIELD;
case SensorType::Pressure:
return CHRE_SENSOR_TYPE_PRESSURE;
case SensorType::Light:
return CHRE_SENSOR_TYPE_LIGHT;
case SensorType::Proximity:
return CHRE_SENSOR_TYPE_PROXIMITY;
case SensorType::AccelerometerTemperature:
return CHRE_SENSOR_TYPE_ACCELEROMETER_TEMPERATURE;
case SensorType::GyroscopeTemperature:
return CHRE_SENSOR_TYPE_GYROSCOPE_TEMPERATURE;
case SensorType::UncalibratedAccelerometer:
return CHRE_SENSOR_TYPE_UNCALIBRATED_ACCELEROMETER;
case SensorType::UncalibratedGyroscope:
return CHRE_SENSOR_TYPE_UNCALIBRATED_GYROSCOPE;
case SensorType::UncalibratedGeomagneticField:
return CHRE_SENSOR_TYPE_UNCALIBRATED_GEOMAGNETIC_FIELD;
default:
// Update implementation to prevent undefined or SensorType::Unknown from
// being used.
CHRE_ASSERT(false);
return 0;
}
}
SensorSampleType getSensorSampleTypeFromSensorType(SensorType sensorType) {
switch (sensorType) {
case SensorType::Accelerometer:
case SensorType::Gyroscope:
case SensorType::GeomagneticField:
case SensorType::UncalibratedAccelerometer:
case SensorType::UncalibratedGyroscope:
case SensorType::UncalibratedGeomagneticField:
return SensorSampleType::ThreeAxis;
case SensorType::Pressure:
case SensorType::Light:
case SensorType::AccelerometerTemperature:
case SensorType::GyroscopeTemperature:
return SensorSampleType::Float;
case SensorType::InstantMotion:
case SensorType::StationaryDetect:
return SensorSampleType::Occurrence;
case SensorType::Proximity:
return SensorSampleType::Byte;
default:
CHRE_ASSERT(false);
return SensorSampleType::Unknown;
}
}
SensorMode getSensorModeFromEnum(enum chreSensorConfigureMode enumSensorMode) {
switch (enumSensorMode) {
case CHRE_SENSOR_CONFIGURE_MODE_DONE:
return SensorMode::Off;
case CHRE_SENSOR_CONFIGURE_MODE_CONTINUOUS:
return SensorMode::ActiveContinuous;
case CHRE_SENSOR_CONFIGURE_MODE_ONE_SHOT:
return SensorMode::ActiveOneShot;
case CHRE_SENSOR_CONFIGURE_MODE_PASSIVE_CONTINUOUS:
return SensorMode::PassiveContinuous;
case CHRE_SENSOR_CONFIGURE_MODE_PASSIVE_ONE_SHOT:
return SensorMode::PassiveOneShot;
default:
// Default to off since it is the least harmful and has no power impact.
return SensorMode::Off;
}
}
bool sensorTypeIsOneShot(SensorType sensorType) {
return (sensorType == SensorType::InstantMotion ||
sensorType == SensorType::StationaryDetect);
}
bool sensorTypeIsOnChange(SensorType sensorType) {
return (sensorType == SensorType::Light ||
sensorType == SensorType::Proximity);
}
SensorRequest::SensorRequest()
: SensorRequest(SensorMode::Off,
Nanoseconds(CHRE_SENSOR_INTERVAL_DEFAULT),
Nanoseconds(CHRE_SENSOR_LATENCY_DEFAULT)) {}
SensorRequest::SensorRequest(SensorMode mode,
Nanoseconds interval,
Nanoseconds latency)
: mInterval(interval), mLatency(latency), mMode(mode) {}
SensorRequest::SensorRequest(Nanoapp *nanoapp, SensorMode mode,
Nanoseconds interval,
Nanoseconds latency)
: mNanoapp(nanoapp), mInterval(interval), mLatency(latency), mMode(mode) {}
bool SensorRequest::isEquivalentTo(const SensorRequest& request) const {
return (mMode == request.mMode
&& mInterval == request.mInterval
&& mLatency == request.mLatency);
}
bool SensorRequest::mergeWith(const SensorRequest& request) {
bool attributesChanged = false;
if (request.mInterval < mInterval) {
mInterval = request.mInterval;
attributesChanged = true;
}
if (request.mLatency < mLatency) {
mLatency = request.mLatency;
attributesChanged = true;
}
// Compute the highest priority mode. Active continuous is the highest
// priority and passive one-shot is the lowest.
SensorMode maximalSensorMode = SensorMode::Off;
if (mMode == SensorMode::ActiveContinuous
|| request.mMode == SensorMode::ActiveContinuous) {
maximalSensorMode = SensorMode::ActiveContinuous;
} else if (mMode == SensorMode::ActiveOneShot
|| request.mMode == SensorMode::ActiveOneShot) {
maximalSensorMode = SensorMode::ActiveOneShot;
} else if (mMode == SensorMode::PassiveContinuous
|| request.mMode == SensorMode::PassiveContinuous) {
maximalSensorMode = SensorMode::PassiveContinuous;
} else if (mMode == SensorMode::PassiveOneShot
|| request.mMode == SensorMode::PassiveOneShot) {
maximalSensorMode = SensorMode::PassiveOneShot;
} else {
CHRE_ASSERT(false);
}
if (mMode != maximalSensorMode) {
mMode = maximalSensorMode;
attributesChanged = true;
}
return attributesChanged;
}
Nanoseconds SensorRequest::getInterval() const {
return mInterval;
}
Nanoseconds SensorRequest::getLatency() const {
return mLatency;
}
SensorMode SensorRequest::getMode() const {
return mMode;
}
Nanoapp *SensorRequest::getNanoapp() const {
return mNanoapp;
}
} // namespace chre
| [
"[email protected]"
] | |
507e96ffec873975c9f28f747a4b7cc94b5a6aa7 | 9c7c1541194bc2d559eb6f7cb8613afbb501fb7c | /final/B0KstMuMu2/plugins/RooBernsteinEffiDictionary.h | 5a1fccaa40782eac4d1cf59625c8eef66f455807 | [] | no_license | lixfrank/qinxl | 885ca08c6cc84de45c507a07b4c80e1e21a037e4 | e2b5d9ea92f58f15ce88c60f2c6980d635399a3c | refs/heads/master | 2020-07-13T00:01:12.393128 | 2019-08-28T13:40:47 | 2019-08-28T13:40:47 | 204,940,674 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 8,575 | h | /********************************************************************
* RooBernsteinEffiDictionary.h
* CAUTION: DON'T CHANGE THIS FILE. THIS FILE IS AUTOMATICALLY GENERATED
* FROM HEADER FILES LISTED IN G__setup_cpp_environmentXXX().
* CHANGE THOSE HEADER FILES AND REGENERATE THIS FILE.
********************************************************************/
#ifdef __CINT__
#error RooBernsteinEffiDictionary.h/C is only for compilation. Abort cint.
#endif
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define G__ANSIHEADER
#define G__DICTIONARY
#define G__PRIVATE_GVALUE
#include "G__ci.h"
#include "FastAllocString.h"
extern "C" {
extern void G__cpp_setup_tagtableRooBernsteinEffiDictionary();
extern void G__cpp_setup_inheritanceRooBernsteinEffiDictionary();
extern void G__cpp_setup_typetableRooBernsteinEffiDictionary();
extern void G__cpp_setup_memvarRooBernsteinEffiDictionary();
extern void G__cpp_setup_globalRooBernsteinEffiDictionary();
extern void G__cpp_setup_memfuncRooBernsteinEffiDictionary();
extern void G__cpp_setup_funcRooBernsteinEffiDictionary();
extern void G__set_cpp_environmentRooBernsteinEffiDictionary();
}
#include "TObject.h"
#include "TMemberInspector.h"
#include "RooBernsteinEffi.h"
#include <algorithm>
namespace std { }
using namespace std;
#ifndef G__MEMFUNCBODY
#endif
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_TClass;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_TBuffer;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_TMemberInspector;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_TObject;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_TNamed;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_vectorlEROOTcLcLTSchemaHelpercOallocatorlEROOTcLcLTSchemaHelpergRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_reverse_iteratorlEvectorlEROOTcLcLTSchemaHelpercOallocatorlEROOTcLcLTSchemaHelpergRsPgRcLcLiteratorgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_vectorlETVirtualArraymUcOallocatorlETVirtualArraymUgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_reverse_iteratorlEvectorlETVirtualArraymUcOallocatorlETVirtualArraymUgRsPgRcLcLiteratorgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_iteratorlEbidirectional_iterator_tagcOTObjectmUcOlongcOconstsPTObjectmUmUcOconstsPTObjectmUaNgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_RooPrintable;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_listlEdoublecOallocatorlEdoublegRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_listlEstringcOallocatorlEstringgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_RooAbsArg;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_RooArgSet;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_RooArgList;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_setlEstringcOlesslEstringgRcOallocatorlEstringgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_maplEstringcOTObjArraymUcOlesslEstringgRcOallocatorlEpairlEconstsPstringcOTObjArraymUgRsPgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_RooListProxy;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_RooRealProxy;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_maplEstringcOstringcOlesslEstringgRcOallocatorlEpairlEconstsPstringcOstringgRsPgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_setlEpairlERooAbsArgmUcORooAbsArgmUgRcOlesslEpairlERooAbsArgmUcORooAbsArgmUgRsPgRcOallocatorlEpairlERooAbsArgmUcORooAbsArgmUgRsPgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_RooAbsReal;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_dequelERooAbsCachemUcOallocatorlERooAbsCachemUgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_maplERooAbsArgmUcOTRefArraymUcOlesslERooAbsArgmUgRcOallocatorlEpairlERooAbsArgmUsPconstcOTRefArraymUgRsPgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_dequelERooAbsArgmUcOallocatorlERooAbsArgmUgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_stacklERooAbsArgmUcOdequelERooAbsArgmUcOallocatorlERooAbsArgmUgRsPgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_TVectorTlEfloatgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_TVectorTlEdoublegR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_TMatrixTlEdoublegR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_vectorlERooCurvemUcOallocatorlERooCurvemUgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_reverse_iteratorlEvectorlERooCurvemUcOallocatorlERooCurvemUgRsPgRcLcLiteratorgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_maplEstringcOTH1mUcOlesslEstringgRcOallocatorlEpairlEconstsPstringcOTH1mUgRsPgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_maplEstringcORooDataHistmUcOlesslEstringgRcOallocatorlEpairlEconstsPstringcORooDataHistmUgRsPgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_maplEstringcORooDataSetmUcOlesslEstringgRcOallocatorlEpairlEconstsPstringcORooDataSetmUgRsPgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_maplEstringcORooAbsDatamUcOlesslEstringgRcOallocatorlEpairlEconstsPstringcORooAbsDatamUgRsPgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_listlERooAbsRealcLcLEvalErrorcOallocatorlERooAbsRealcLcLEvalErrorgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_pairlEstringcOlistlERooAbsRealcLcLEvalErrorcOallocatorlERooAbsRealcLcLEvalErrorgRsPgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_maplEconstsPRooAbsArgmUcOpairlEstringcOlistlERooAbsRealcLcLEvalErrorcOallocatorlERooAbsRealcLcLEvalErrorgRsPgRsPgRcOlesslEconstsPRooAbsArgmUgRcOallocatorlEpairlEconstsPRooAbsArgmUsPconstcOpairlEstringcOlistlERooAbsRealcLcLEvalErrorcOallocatorlERooAbsRealcLcLEvalErrorgRsPgRsPgRsPgRsPgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_vectorlEpairlEconstsPRooArgSetmUcOconstsPRooArgSetmUgRcOallocatorlEpairlEconstsPRooArgSetmUcOconstsPRooArgSetmUgRsPgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_reverse_iteratorlEvectorlEpairlEconstsPRooArgSetmUcOconstsPRooArgSetmUgRcOallocatorlEpairlEconstsPRooArgSetmUcOconstsPRooArgSetmUgRsPgRsPgRcLcLiteratorgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_maplEpairlEconstsPRooArgSetmUcOconstsPRooArgSetmUgRcOunsignedsPlongcOlesslEpairlEconstsPRooArgSetmUcOconstsPRooArgSetmUgRsPgRcOallocatorlEpairlEconstsPpairlEconstsPRooArgSetmUcOconstsPRooArgSetmUgRcOunsignedsPlonggRsPgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_maplEintcOstringcOlesslEintgRcOallocatorlEpairlEconstsPintcOstringgRsPgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_vectorlERooMsgServicecLcLStreamConfigcOallocatorlERooMsgServicecLcLStreamConfiggRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_reverse_iteratorlEvectorlERooMsgServicecLcLStreamConfigcOallocatorlERooMsgServicecLcLStreamConfiggRsPgRcLcLiteratorgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_dequelEvectorlERooMsgServicecLcLStreamConfigcOallocatorlERooMsgServicecLcLStreamConfiggRsPgRcOallocatorlEvectorlERooMsgServicecLcLStreamConfigcOallocatorlERooMsgServicecLcLStreamConfiggRsPgRsPgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_stacklEvectorlERooMsgServicecLcLStreamConfigcOallocatorlERooMsgServicecLcLStreamConfiggRsPgRcOdequelEvectorlERooMsgServicecLcLStreamConfigcOallocatorlERooMsgServicecLcLStreamConfiggRsPgRcOallocatorlEvectorlERooMsgServicecLcLStreamConfigcOallocatorlERooMsgServicecLcLStreamConfiggRsPgRsPgRsPgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_maplEstringcObasic_ostreamlEcharcOchar_traitslEchargRsPgRmUcOlesslEstringgRcOallocatorlEpairlEconstsPstringcObasic_ostreamlEcharcOchar_traitslEchargRsPgRmUgRsPgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_vectorlERooNormSetCachecOallocatorlERooNormSetCachegRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_reverse_iteratorlEvectorlERooNormSetCachecOallocatorlERooNormSetCachegRsPgRcLcLiteratorgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_vectorlERooAbsCacheElementmUcOallocatorlERooAbsCacheElementmUgRsPgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_reverse_iteratorlEvectorlERooAbsCacheElementmUcOallocatorlERooAbsCacheElementmUgRsPgRcLcLiteratorgR;
extern G__linked_taginfo G__RooBernsteinEffiDictionaryLN_RooBernsteinEffi;
/* STUB derived class for protected member access */
| [
"[email protected]"
] | |
7c49f7a648bc293d4ac2470f2aa79ce8971f7a9e | 38effee0814e5b77c44fa38992b9cb55f6e0f841 | /Submission-by-Uva-etc/volume102/UVA Q10209.cpp | dace9fa3c992236fcaa899d8a0baa2ef99813cc0 | [] | no_license | 89snnfk561/Online-Judge-Submissions | 2168df54ed3b755ae24d0cacf61efce9e6b73bc9 | 670752bb71a36ca184e18795a7e7d3ad235b4d75 | refs/heads/main | 2023-08-04T01:53:19.128449 | 2021-09-30T03:14:36 | 2021-09-30T03:14:36 | 410,538,143 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 342 | cpp | #include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main (){
double a;
double x, y, z;
cin >> a;
x = a*a - 4*(a*a*2.0*acos(0.0)/12 - (a*a*2.0*acos(0.0)/6 - a*a*sqrt(3.0)/4.0));
y = 4*(a*a*2.0*acos(0.0)/4 - a*a/2) - 2*x;
z = a*a - x - y;
cout << fixed << setprecision(3) << x <<" "<< y <<" "<< z << endl;
}
| [
"[email protected]"
] | |
9d2afacfcbd3aabec548cdd5bd01c7e6ffe9985b | d08af04bf2c406f6083e0dd2e99591871136fc79 | /Teaching Labs/Lab4/Earth/Earth.cpp | 4653b64c0e0300c17aced0c9d05793e196c67c26 | [] | no_license | SilentLongbow/computer-graphics-uc | bef754afe212a589394bbb82a00f42ecd49fdfa6 | e473d1bafc6f03cf041a98048e8cd4380afe7a9f | refs/heads/master | 2023-01-02T16:44:46.965864 | 2020-10-18T13:08:19 | 2020-10-18T13:08:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,835 | cpp | // ========================================================================
// COSC363: Computer Graphics (2019); University of Canterbury.
//
// FILE NAME: Earth.cpp
// See Lab04.pdf for details.
// ========================================================================
#include <iostream>
#include <GL/freeglut.h>
#include "loadBMP.h"
using namespace std;
GLuint txId[2];
GLUquadricObj* q;
float rotateAngle = 0;
float revolveAngle = 0;
//--------------------------------------------------------------------------------
void loadTexture()
{
glGenTextures(2, txId); //Get 2 texture IDs
glBindTexture(GL_TEXTURE_2D, txId[0]); //Use this texture name for the following OpenGL texture
loadBMP("Earth.bmp");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Filtering
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, txId[1]); //Use this texture name for the following OpenGL texture
loadBMP("Sun.bmp");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
//--------------------------------------------------------------------------------
void initialise()
{
float black[4] = {0.0, 0.0, 0.0, 1.0};
float white[4] = {1.0, 1.0, 1.0, 1.0};
q = gluNewQuadric ( );
loadTexture();
glClearColor(0.2f, 0.2f, 0.2f, 1.0f); //Background
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_AMBIENT, black);
glLightfv(GL_LIGHT0, GL_DIFFUSE, white);
glLightfv(GL_LIGHT0, GL_SPECULAR, white);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
gluQuadricDrawStyle (q, GLU_FILL );
gluQuadricNormals (q, GLU_SMOOTH );
glEnable(GL_TEXTURE_2D);
gluQuadricTexture (q, GL_TRUE);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(40.0, 2.0, 10., 100.);
}
//============================================================
void display()
{
float lgt_pos[4] = {0., 0., 0., 1.};
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0., 0., 40., 0., 0., 0., 0., 1., 0.);
glLightfv(GL_LIGHT0, GL_POSITION, lgt_pos);
glColor4f(1.0, 1.0, 1.0, 1.0); //Base colour
//Earth
glBindTexture(GL_TEXTURE_2D, txId[0]);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glPushMatrix();
glRotatef(revolveAngle, 0.0, 1.0, 0.0);
glTranslatef(20.0, 0.0, 0.0); //Translate Earth along x-axis by 20 units
glRotatef(rotateAngle, 0, 1, 0); //Rotation about polar axis of the Earth
glRotatef(-90., 1.0, 0., 0.0); //make the sphere axis vertical
gluSphere ( q, 3.0, 36, 17 );
glPopMatrix();
//Sun
glBindTexture(GL_TEXTURE_2D, txId[1]);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glPushMatrix();
glRotatef(-90., 1.0, 0., 0.0); //make the sphere axis vertical
gluSphere ( q, 4.0, 36, 17 );
glPopMatrix();
glutSwapBuffers();
}
//----------------------------------------------------------------
void timer(int value)
{
rotateAngle ++;
if(rotateAngle > 360) rotateAngle = 0;
revolveAngle += 0.5;
if(revolveAngle > 360) revolveAngle = 0;
glutTimerFunc(50, timer, value);
glutPostRedisplay();
}
//----------------------------------------------------------------
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize (800, 400);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);
initialise ();
glutDisplayFunc(display);
glutTimerFunc(50, timer, 0);
glutMainLoop();
return 0;
}
| [
"[email protected]"
] | |
381651c1becee858c57d6888edfdf06774657550 | 6e5dd817898751cfe83acebc56a6a04e98508af0 | /CPP/brickWall.cpp | 7f756bf669ffee4af9251c2e01d50f8ae25e6557 | [] | no_license | xiaotianzhao/leetcode | 9293ad672d2e79d0da94066e18f58b5c3fa0369a | cbddb3d0400ef3d25d2f9e2b2447fc4a9d25daf8 | refs/heads/master | 2021-07-13T08:47:02.833168 | 2019-02-18T07:50:02 | 2019-02-18T07:50:02 | 90,983,253 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,597 | cpp | #include <iostream>
#include <vector>
#include <map>
using namespace std;
class Solution {
public:
int leastBricks(vector<vector<int> >& wall) {
int heightOfWall = wall.size();
map<int,int> hash;
int maxCount = 0;
for (int i = 0 ; i < heightOfWall ; i++){
vector<int> tmp = wall[i];
int sum = 0;
for (int j = 0 ; j < tmp.size()-1 ; j++){
sum += tmp[j];
++hash[sum];
}
}
for (int i = 0 ; i < hash.size() ; i++){
maxCount = max(hash[i],maxCount);
}
return heightOfWall - maxCount;
}
};
int main(){
Solution solution ;
vector<vector<int> > input;
vector<int> rowInput1,rowInput2,rowInput3,rowInput4,rowInput5,rowInput6;
rowInput1.push_back(1);
rowInput1.push_back(2);
rowInput1.push_back(2);
rowInput1.push_back(1);
rowInput2.push_back(3);
rowInput2.push_back(1);
rowInput2.push_back(2);
rowInput3.push_back(1);
rowInput3.push_back(3);
rowInput3.push_back(2);
rowInput4.push_back(2);
rowInput4.push_back(4);
rowInput5.push_back(3);
rowInput5.push_back(1);
rowInput5.push_back(2);
rowInput6.push_back(1);
rowInput6.push_back(3);
rowInput6.push_back(1);
rowInput6.push_back(1);
input.push_back(rowInput1);
input.push_back(rowInput2);
input.push_back(rowInput3);
input.push_back(rowInput4);
input.push_back(rowInput5);
input.push_back(rowInput6);
cout << solution.leastBricks(input) << endl;
return 0;
}
| [
"[email protected]"
] | |
953b83bed6e456a62b312bccfa7ca1b1ddc942ba | f5c9e7e6d9049c377696aa30fe54ac1100df1f63 | /hpps/common/waiter.h | 86793f625a94b5a9d633d947984950ea2a47a776 | [
"MIT"
] | permissive | kiminh/ddls | c343d6ac8b870ee44ce88a05f312922144592bc2 | 3333a669c59ce2e525945f814a54784dafc6191b | refs/heads/master | 2021-10-10T19:40:15.533725 | 2019-01-16T02:32:59 | 2019-01-16T02:32:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 696 | h | /*
* \file waiter.h
* \brief The waiter for synchronization.
*/
#pragma once
#include <mutex>
#include <condition_variable>
namespace hpps {
class Waiter {
public:
explicit Waiter(int num_wait = 1) : num_wait_(num_wait) { }
virtual ~Waiter() { }
void Wait() {
std::unique_lock<std::mutex> lock(mutex_);
while (num_wait_ > 0) cv_.wait(lock);
}
void Notify() {
std::unique_lock<std::mutex> lock(mutex_);
--num_wait_;
cv_.notify_all();
}
void Reset(int num_wait) {
std::unique_lock<std::mutex> lock(mutex_);
num_wait_ = num_wait;
}
private:
std::mutex mutex_;
std::condition_variable cv_;
volatile int num_wait_;
};
} // namespace hpps
| [
"[email protected]"
] | |
487ff6298d7a1de70db75d3fc689fb1c5714f980 | d62f5208f788e59d04da547d2f397763a631fa80 | /Project/primitiveLib/curveprimitive.h | 5622d6044b3ead59799ca5a5a636cb079393d543 | [] | no_license | wyt0602/MyPaper | 4ee876c024a1d9ae6f75c544e4bf0a89cd829a54 | 8832b880717d70f230a23c519725a97beabfa18c | refs/heads/master | 2021-01-12T06:22:23.629013 | 2017-05-14T01:48:58 | 2017-05-14T01:48:58 | 77,350,250 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 504 | h | #ifndef CURVEPRIMITIVE_H
#define CURVEPRIMITIVE_H
#include "primitive.h"
class CurvePrimitive : public Primitive
{
Q_OBJECT
public:
explicit CurvePrimitive(QWidget *parent = 0);
QListWidgetItem* getListWidgetItem();
void adjustPosition(QPoint p);
Primitive* clone(QWidget *parent);
protected:
void paintEvent(QPaintEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
signals:
public slots:
private:
QSvgRenderer *svg_render;
};
#endif // CURVEPRIMITIVE_H
| [
"[email protected]"
] | |
216c2b248b91289939142826efacd868791af82d | 939c23eac0cf00779fa27f4b29ef4f52a3b98629 | /ecbs_node.h | 93f488c65ec2ce7d452501f8b2e4aef03767520e | [] | no_license | hangma-usc/ECBS_MIX | e8f1bff32d560f65ef2143cab6874adf63e76e19 | d9bb8f77ed42e7b8db750ea5ecfbb656513b31dd | refs/heads/master | 2021-01-20T20:24:11.974852 | 2016-06-17T05:52:36 | 2016-06-17T05:52:36 | 61,349,302 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,763 | h | // Represents 2D-Nodes
#ifndef ECBSNODE_H
#define ECBSNODE_H
#include <string>
#include <vector>
#include <list>
#include <climits>
#include <tuple>
#include <boost/heap/fibonacci_heap.hpp>
using boost::heap::fibonacci_heap;
using boost::heap::compare;
using namespace std;
class ECBSNode {
public:
int type_id;
tuple<int, int, int> constraint; // <int loc1, int loc2, int timestep> NOTE--loc2=-1 for Vertex Constraint
ECBSNode* parent;
vector<vector<int>> path;
double g_val; // makespan
double h_val;
int time_expanded;
int time_generated;
double lowerbound;
double path_cost; // saves this agent's low-level path-cost
// the following is used to comapre nodes in the OPEN list
struct compare_node {
bool operator()(const ECBSNode* n1, const ECBSNode* n2) const {
return n1->lowerbound >= n2->lowerbound;
}
}; // used by OPEN to compare nodes by g-val (top of the heap has min g-val)
// the following is used to comapre nodes in the FOCAL list
struct secondary_compare_node {
bool operator()(const ECBSNode* n1, const ECBSNode* n2) const {
if (n1->h_val == n2->h_val) {
return n1->g_val >= n2->g_val; // break ties towards shorter (overall) solutions
}
return n1->h_val >= n2->h_val;
}
}; // used by FOCAL to compare nodes by h_val (top of the heap has min h-val)
typedef boost::heap::fibonacci_heap< ECBSNode*, compare<compare_node> >::handle_type open_handle_t;
typedef boost::heap::fibonacci_heap< ECBSNode*, compare<secondary_compare_node> >::handle_type focal_handle_t;
open_handle_t open_handle;
focal_handle_t focal_handle;
ECBSNode(); // for efficiency, reserve num_of_agents in all_constraints vector
ECBSNode(int type_id, ECBSNode* parent, double g_val, double h_val, int time_expanded, double path_cost);
static bool isEqual(const ECBSNode* n1, const ECBSNode* n2);
~ECBSNode();
// The following is used by googledensehash for checking whether two nodes are equal
// we say that two nodes, s1 and s2, are equal if
// both are non-NULL and have the same time_expanded (unique)
struct ECBS_eqnode {
bool operator()(const ECBSNode* s1, const ECBSNode* s2) const {
return (s1 == s2) || (s1 && s2 && s1->time_generated == s2->time_generated);
}
};
// The following is used by googledensehash for generating the hash value of a nodes
// this is needed because otherwise we'll have to define the specilized template inside std namespace
struct ECBSNodeHasher {
std::size_t operator()(const ECBSNode* n) const {
size_t type_id_hash = std::hash<int>()(n->type_id);
size_t time_generated_hash = std::hash<int>()(n->time_generated);
return (type_id_hash ^ (time_generated_hash << 1));
}
};
};
std::ostream& operator<<(std::ostream& os, const ECBSNode& n);
#endif
| [
"HangMa@HANGMA-PC"
] | HangMa@HANGMA-PC |
7cb67dd3addb4cd74b2e916a918748320243eb29 | d1fec4f96227fa9548e3bfd1e71c21822dceaff4 | /main.cpp | 2407e715beaf875daf6b5edc7be4f7dab8c1e675 | [] | no_license | BeenEncoded/linuxtimer | 3b2ed80bf3c9b6ce4b40aa29ddf713687856305d | b8efe202a5a6ff2198f8d2672557d8e037584587 | refs/heads/master | 2016-09-16T13:14:10.885454 | 2014-02-02T19:38:08 | 2014-02-02T19:38:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,008 | cpp | #include <iostream>
#include <unistd.h>
#include <sstream>
#include "cwrapper.hpp"
#include "common.hpp"
#include "timer_class.hpp"
#include "global_defines.hpp"
using namespace cwrap;
/** Menu stuff: */
namespace
{
void main_menu();
void set_timer(timerObj::timer_class&);
void start_timer(timerObj::timer_class&);
void display_timer(const timerObj::time_info_data&, const bool&);
std::string formatted_number(const unsigned int&, const short&);
template<class type1, class type2>
inline type2 conv(const type1& t1)
{
std::stringstream ss;
type2 t2;
ss<< t1;
ss>> t2;
return t2;
}
inline void main_menu()
{
cout.set_color(white);
using namespace common;
timerObj::timer_class timer;
char ch;
while(true)
{
cls();
cout<< endl;
center("Timer");
cout<< endl;
for(short x = 0; x < 3; x++) cout<< endl;
cout.set_color(blue);
center("UNDER CONSTRUCTION!");
cout.set_color(white);
cout<< endl;
cout<< " 1 - Start timer"<< endl;
cout<< " 2 - Set timer"<< endl;
cout<< endl;
cout<< " q - Exit"<< endl;
ch = tolower(gkey());
switch(ch)
{
case '1':
{
start_timer(timer);
}
break;
case '2':
{
set_timer(timer);
}
break;
case 'q':
{
return;
}
break;
default:
break;
}
}
}
inline void set_timer(timerObj::timer_class& timer)
{
using namespace common;
using namespace common::input;
timerObj::time_info_data tempt = timer.time_set();
std::string temps("");
int ch;
while(true)
{
cls();
cout<< endl;
center("Set Timer: ");
cout<< endl;
for(short x = 0; x < 3; x++) cout<< endl;
cout<< " 1 - Hours: "<< formatted_number(tempt.hours, 2)<< endl;
cout<< " 2 - Minutes: "<< formatted_number(tempt.minutes, 2)<< endl;
cout<< " 3 - Seconds: "<< formatted_number(tempt.seconds, 2)<< endl;
cout<< endl;
cout<< " [BACKSPACE] - Done"<< endl;
ch = gkey();
switch(is_char(char(ch)))
{
case true:
{
switch(char(ch))
{
case '1':
{
temps = get_user_string(("Hours currently set to: " + conv<unsigned int, std::string>(tempt.hours) +
std::string("\n\n\nEnter the number of hours: ")));
if(temps != GSTRING_CANCEL)
{
(string_is_int(temps) ? (tempt.hours = conv<std::string, unsigned int>(temps)) : (tempt.hours = 0));
timer.set(timerObj::clock_class(tempt));
}
temps.erase();
}
break;
case '2':
{
temps = get_user_string(("Minutes currently set to: " + conv<unsigned int, std::string>(tempt.minutes) +
std::string("\n\n\nEnter the number of Minutes: ")));
if(temps != GSTRING_CANCEL)
{
(string_is_int(temps) ? (tempt.minutes = conv<std::string, unsigned int>(temps)) : (tempt.minutes = 0));
timer.set(timerObj::clock_class(tempt));
}
temps.erase();
}
break;
case '3':
{
temps = get_user_string("Seconds currently set to: " + conv<unsigned int, std::string>(tempt.seconds) +
std::string("\n\n\nEnter the number of seconds: "));
if(temps != GSTRING_CANCEL)
{
(string_is_int(temps) ? (tempt.seconds = conv<std::string, unsigned int>(temps)) : (tempt.seconds = 0));
timer.set(timerObj::clock_class(tempt));
}
temps.erase();
}
break;
default:
break;
}
}
break;
case false:
{
switch(ch)
{
case KEY_BACKSPACE:
{
return;
}
break;
default:
break;
}
}
break;
default:
break;
}
}
}
inline void start_timer(timerObj::timer_class& timer)
{
using namespace common;
timer.start();
while(!kbhit())
{
cls();
for(short x = 0; x < 10; x++) cout<< endl;
display_timer(timer.time_left(), timer.finished());
//run at 30-frames per second. This should be enough to not over-tax the terminal
usleep(1000000 / 30);
}
}
inline void display_timer(const timerObj::time_info_data& timer, const bool& finished)
{
common::center(std::string(
(finished ? "OVERTIME: " : std::string("")) +
formatted_number(timer.hours, 2) + " : " +
formatted_number(timer.minutes, 2) + " : " +
formatted_number(timer.seconds, 2) + " : " +
formatted_number(timer.miliseconds, 2)));
}
inline std::string formatted_number(const unsigned int& x, const short& digits)
{
std::string temps("");
short digits_of_x(conv<unsigned int, std::string>(x).size());
if(digits_of_x < digits)
{
for(short y = digits_of_x; y < digits; y++)
{
temps += "0";
}
}
temps += conv<unsigned int, std::string>(x);
return temps;
}
}
int main()
{
main_menu();
return 0;
} | [
"[email protected]"
] | |
01d0dd743e5f14510d6794367abb70b3dcee7e52 | f611a5fa1c8aad118094cf690a170603ccef4ce7 | /effective_cplusplus/Item08/Prevent_exceptions_from_leaving_destructors.cpp | a0c5bad2d1fd47fbd257d52956056c47c9f16e59 | [] | no_license | kushuaiming/cplusplus_book_example | 4dd09264a84aff74d535f4d606e2fdca31d0f618 | 6adac5a75f17bce61135efaea2039847a577eb21 | refs/heads/master | 2023-08-18T17:16:11.330642 | 2021-10-16T09:22:57 | 2021-10-16T09:22:57 | 352,328,089 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,143 | cpp | #include <iostream>
#include <vector>
using namespace std;
class Widget {
public:
//...
~Widget() {
// ...假设这里可能发生异常
}
};
void doSomething() {
vector<Widget> v;
}
// v在这里被销毁
// 用于数据库链接的类
class DBConnection {
public:
// 这个函数返回DBconnection对象,为求简化暂时省略参数
static DBConnection create();
// 关闭联机,失败则抛出异常
void close();
};
// 为了确保客户不忘记调用close(),一个合理的想法是创建一个用来管理DBConnection资源的类
//class DBConn {
//public:
// // ...
// ~DBConn() {
// db.close();
// }
//private:
// DBConnection db;
//};
//DBConn::~DBConn() {
// try { db.close(); }
// catch () {
// // 制作运转记录,记下对close的调用失败
// abort();
// }
//}
class DBConn {
public:
// ...
void close() {// 供顾客使用的新函数
db.close();
closed = true;
}
~DBConn() {
if (!closed) {
try { db.close(); }
catch () {
// 制作运转记录,记下对close的调用失败
}
}
}
private:
DBConnection db;
bool closed;
};
int main(int argv, char* argc[]) {
return 0;
} | [
"[email protected]"
] | |
cb2d7e7b331e9ffb9e876faa91f3895d814a5920 | ec2c810bfb74bdcbc23b630262dcd6c39d900039 | /week2/fib/fibonacci.cc | 7b466b203f8ab520316730bb3f8baf685273d07f | [] | no_license | TTeun/TDJ | 280251861e131b9c364e9916f97a76eefc61addd | d9d3f3e5cba7c1e1e7dc72650bb82141f6c283ca | refs/heads/master | 2020-12-02T00:30:54.891020 | 2016-11-08T16:06:50 | 2016-11-08T16:06:50 | 67,924,547 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 258 | cc | #include <iostream>
#include "main.ih"
using namespace std;
int main(int argc, char * argv[]) {
if (argc > 2)
cout << rawfib(strtoul(argv[1], NULL, 10)) << '\n';
else
cout << fib(strtoul(argv[1], NULL, 10)) << '\n';
return 0;
} | [
"[email protected]"
] | |
427541dc6c9a4280999bc5c133b3061285e9f6f0 | 1f74553b050b88a3484f6d3d93fa09f8aaa9a826 | /Homework/bai55_hinhchunhatkitu1.cpp | c4ef2474e544778caa4e8dd0ecaa2e33af6ff0f4 | [] | no_license | dattocngan/THCS2_PTIT | 2e970942ee28a87b0c66d31667185b1c1e58e340 | edbf6b944a0f3cf0065b02c49ed83b7c39c1526a | refs/heads/main | 2023-04-29T06:36:45.770537 | 2021-05-19T16:35:24 | 2021-05-19T16:35:24 | 345,918,636 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 648 | cpp | #include<stdio.h>
#include<math.h>
#include<string.h>
int main(){
int n,m;
scanf("%d%d",&n,&m);
int a;
int i,j;
if( n > m ){
for( i = 0 ; i < n ; i++ ){
a = 96+n;
if(i > m){
for( j = 0 ; j < m ; j++ ){
printf("%c",a);
a--;
}
printf("\n");
continue;
}
for( j = 0 ; j < i ; j++ ){
printf("%c",a);
a--;
}
for( j = i ; j < m ; j++ ){
printf("%c",a);
}
printf("\n");
}
}else{
for( i = 0 ; i < n ; i++ ){
a = 96+m;
for( j = 0 ; j < i ; j++ ){
printf("%c",a);
a--;
}
for( j = i ; j < m ; j++ ){
printf("%c",a);
}
printf("\n");
}
}
return 0;
}
| [
"[email protected]"
] | |
7f9be9c0fdb875bbcdb0376a93f9fd01f5493d3f | 5923bb4b34629ca87fd387d9588a85089c685ad6 | /src/main.cpp | e4452d0405419b6eb4f4bfc1a00c00277733dcb9 | [] | no_license | quannl280201/Assignment2_CO2003 | f1ac7ac7f1a0e7a7de78fd810d2fb596857220e5 | 762d37e21b4a06592e7e57ffd14f0b72a4d064da | refs/heads/master | 2023-04-17T20:17:31.464011 | 2021-04-30T02:59:12 | 2021-04-30T02:59:12 | 362,145,589 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,673 | cpp | #include <stdio.h>
#include "main.h"
#include "Cache.h"
#include "Cache.cpp"
Data* getData(string s) {
stringstream ss(s);
int idata;
float fdata;
if (ss >> idata)
return new Int(idata);
else if (ss >> fdata)
return new Float(fdata);
else if (s.compare("true") || s.compare("false"))
return new Bool(s.compare("true"));
else {
s.resize(s.size()-1);
return new Address(stoi(s));
}
}
void simulate(string filename,Cache* c)
{
ifstream ifs;
ifs.open(filename, std::ifstream::in);
string s;
while (getline(ifs, s))
{
stringstream ss(s);
string code,tmp;
ss >> code;
int addr;
switch (code[0]) {
case 'R': //read
ss >> addr;
Data* res;
res = c->read(addr);
if (res == NULL) {
ss >> tmp;
c->put(addr,getData(tmp));
} else {
cout << res->getValue() << endl;
}
break;
case 'U': //put
ss >> addr;
ss >> tmp;
c->put(addr,getData(tmp));
break;
case 'W': //write
ss >> addr;
ss >> tmp;
c->write(addr,getData(tmp));
break;
case 'P': // print
cout << "Print queue\n";
c->print();
break;
case 'E': // preorder
cout << "Print AVL in preorder\n";
c->preOrder();
break;
case 'I': // inorder
cout << "Print AVL in inorder\n";
c->inOrder();
break;
}
}
}
int main(int argc, char* argv[]) {
if (argc < 2)
return 1;
Cache* c = new Cache(MAXSIZE);
const char *fileName = argv[1];
simulate(string(fileName),c);
delete c;
return 0;
}
| [
"[email protected]"
] | |
b0dd8c6ef9310fb39b6d1d6edc7e090206ca183c | 55562b54d397407c7561c2385b1319399633448e | /src/cposv.cpp | b5c42cc883a78c591667429c7e22f8bd0a1e589a | [] | no_license | kjbartel/clmagma | 0183fa30d7a0e27c53bfd8aa4b8dca64895ccaa4 | 86a58e5d4f28af7942e31d742c3104598d41d796 | refs/heads/master | 2020-05-26T22:07:09.530467 | 2015-07-05T11:26:42 | 2015-07-05T11:26:42 | 38,567,931 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 4,709 | cpp | /*
-- clMAGMA (version 1.3.0) --
Univ. of Tennessee, Knoxville
Univ. of California, Berkeley
Univ. of Colorado, Denver
@date November 2014
@generated from zposv.cpp normal z -> c, Sat Nov 15 00:21:37 2014
*/
#include "common_magma.h"
extern "C" magma_int_t
magma_cposv (
magma_uplo_t uplo, magma_int_t n, magma_int_t nrhs,
magmaFloatComplex *A, magma_int_t lda,
magmaFloatComplex *B, magma_int_t ldb,
magma_queue_t *queue,
magma_int_t *info )
{
/* -- clMAGMA (version 1.3.0) --
Univ. of Tennessee, Knoxville
Univ. of California, Berkeley
Univ. of Colorado, Denver
@date November 2014
Purpose
=======
CPOSV computes the solution to a complex system of linear equations
A * X = B,
where A is an N-by-N Hermitian positive definite matrix and X and B
are N-by-NRHS matrices.
The Cholesky decomposition is used to factor A as
A = U**H * U, if UPLO = 'U', or
A = L * L**H, if UPLO = 'L',
where U is an upper triangular matrix and L is a lower triangular
matrix. The factored form of A is then used to solve the system of
equations A * X = B.
Arguments
=========
UPLO (input) CHARACTER*1
= 'U': Upper triangle of A is stored;
= 'L': Lower triangle of A is stored.
N (input) INTEGER
The order of the matrix A. N >= 0.
NRHS (input) INTEGER
The number of right hand sides, i.e., the number of columns
of the matrix B. NRHS >= 0.
A (input/output) COMPLEX array, dimension (LDA,N)
On entry, the Hermitian matrix A. If UPLO = 'U', the leading
N-by-N upper triangular part of A contains the upper
triangular part of the matrix A, and the strictly lower
triangular part of A is not referenced. If UPLO = 'L', the
leading N-by-N lower triangular part of A contains the lower
triangular part of the matrix A, and the strictly upper
triangular part of A is not referenced.
On exit, if INFO = 0, the factor U or L from the Cholesky
factorization A = U**H*U or A = L*L**H.
LDA (input) INTEGER
The leading dimension of the array A. LDA >= max(1,N).
B (input/output) COMPLEX array, dimension (LDB,NRHS)
On entry, the right hand side matrix B.
On exit, the solution matrix X.
LDB (input) INTEGER
The leading dimension of the array B. LDB >= max(1,N).
INFO (output) INTEGER
= 0: successful exit
< 0: if INFO = -i, the i-th argument had an illegal value
===================================================================== */
magma_int_t num_gpus, ldda, lddb;
*info = 0;
if ( uplo != MagmaUpper && uplo != MagmaLower )
*info = -1;
if ( n < 0 )
*info = -2;
if ( nrhs < 0)
*info = -3;
if ( lda < max(1, n) )
*info = -5;
if ( ldb < max(1, n) )
*info = -7;
if (*info != 0) {
magma_xerbla( __func__, -(*info) );
return *info;
}
/* Quick return if possible */
if ( (n == 0) || (nrhs == 0) ) {
return *info;
}
/* If single-GPU and allocation suceeds, use GPU interface. */
num_gpus = magma_num_gpus();
magmaFloatComplex_ptr dA, dB;
if ( num_gpus > 1 ) {
goto CPU_INTERFACE;
}
ldda = ((n+31)/32)*32;
lddb = ldda;
if ( MAGMA_SUCCESS != magma_cmalloc( &dA, ldda*n )) {
goto CPU_INTERFACE;
}
if ( MAGMA_SUCCESS != magma_cmalloc( &dB, lddb*nrhs )) {
magma_free( dA );
goto CPU_INTERFACE;
}
magma_csetmatrix( n, n, A, lda, dA, 0, ldda, queue[0] );
magma_cpotrf2_gpu( uplo, n, dA, 0, ldda, queue, info );
if ( *info == MAGMA_ERR_DEVICE_ALLOC ) {
magma_free( dA );
magma_free( dB );
goto CPU_INTERFACE;
}
magma_cgetmatrix( n, n, dA, 0, ldda, A, lda, queue[0] );
if ( *info == 0 ) {
magma_csetmatrix( n, nrhs, B, ldb, dB, 0, lddb, queue[0] );
magma_cpotrs_gpu( uplo, n, nrhs, dA, 0, ldda, dB, 0, lddb, queue[0], info );
magma_cgetmatrix( n, nrhs, dB, 0, lddb, B, ldb, queue[0] );
}
magma_free( dA );
magma_free( dB );
return *info;
CPU_INTERFACE:
/* If multi-GPU or allocation failed, use CPU interface and LAPACK.
* Faster to use LAPACK for potrs than to copy A to GPU. */
magma_cpotrf( uplo, n, A, lda, queue, info );
if ( *info == 0 ) {
lapackf77_cpotrs( lapack_uplo_const(uplo), &n, &nrhs, A, &lda, B, &ldb, info );
}
return *info;
}
| [
"[email protected]"
] | |
06a967d4bf5ac9cdeeb5673553e6e7f9e471dfa5 | 166a09b5fb77ba2c7c79ec8f7c28846ed37cffc0 | /src/Cvisits.cpp | 69fadf9cf53b4bf9932751c58f4b4a9ce49012f0 | [
"MIT"
] | permissive | rekmus/ip2loc | f4c5e84b5ea8412ba91c166824ae9f4ede0a041d | 84fc4b0a7f62e2dbe87e6576c08c9afcfb238c40 | refs/heads/master | 2022-12-25T01:06:12.541745 | 2020-09-30T15:54:57 | 2020-09-30T15:54:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,745 | cpp | /* ---------------------------------------------------------------------------
Table access class
Generated on silgy.org on 2020-05-30 10:37:38, generator v.1.0.0
Using C-style strings
Using exceptions
--------------------------------------------------------------------------- */
#include "Cvisits.h"
bool Cvisits::slots_[CDB_MAX_INSTANCES]={0};
/* ---------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------- */
Cvisits::Cvisits()
{
setInstance(slots_);
table_ = "visits";
columnList_ = "id,"
"ip,"
"country_code,"
"region_name,"
"city_name,"
"method,"
"uri,"
"referer,"
"uagent,"
"lang,"
"ua_type,"
"bot,"
"ad,"
"session_id,"
"status,"
"processing,"
"created";
if ( !(s_=mysql_stmt_init(dbConn_)) )
ThrowSQL("mysql_stmt_init");
if ( !(sc_=mysql_stmt_init(dbConn_)) )
ThrowSQL("mysql_stmt_init");
if ( !(sGet_=mysql_stmt_init(dbConn_)) )
ThrowSQL("mysql_stmt_init");
if ( !(sUpdate_=mysql_stmt_init(dbConn_)) )
ThrowSQL("mysql_stmt_init");
if ( !(sInsert_=mysql_stmt_init(dbConn_)) )
ThrowSQL("mysql_stmt_init");
if ( !(sDelete_=mysql_stmt_init(dbConn_)) )
ThrowSQL("mysql_stmt_init");
if ( !(sSet_=mysql_stmt_init(dbConn_)) )
ThrowSQL("mysql_stmt_init");
Reset();
}
/* ---------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------- */
Cvisits::~Cvisits()
{
mysql_stmt_close(s_);
mysql_stmt_close(sGet_);
mysql_stmt_close(sUpdate_);
mysql_stmt_close(sInsert_);
mysql_stmt_close(sDelete_);
mysql_stmt_close(sSet_);
slots_[instance_] = false;
}
/* ---------------------------------------------------------------------------
Get the next record
Return false if end of record set
--------------------------------------------------------------------------- */
bool Cvisits::Fetch()
{
int ret;
ret = mysql_stmt_fetch(s_);
if ( ret != 0 )
{
Reset();
if ( ret == 1 || ret == MYSQL_NO_DATA )
return false;
else
{
Cdb::ThrowSQL("Cvisits::Fetch | mysql_stmt_fetch");
return false;
}
}
convSC();
genDTStrings();
return true;
}
/* ---------------------------------------------------------------------------
Get record by PK
Not Found will return false
--------------------------------------------------------------------------- */
bool Cvisits::Get(int arg_id)
{
int ret;
if ( firstGet_ )
{
char q[SQLBUF];
sprintf(q, "SELECT id,ip,country_code,region_name,city_name,method,uri,referer,uagent,lang,ua_type,bot,ad,session_id,status,processing,created FROM visits WHERE id=?");
ret = mysql_stmt_prepare(sGet_, q, strlen(q));
if ( ret != 0 )
Cdb::ThrowSQL("Cvisits::Get | mysql_stmt_prepare");
firstGet_ = false;
}
bindKey(sGet_, arg_id);
if ( mysql_stmt_execute(sGet_) )
Cdb::ThrowSQL("Cvisits::Get | mysql_stmt_execute");
bindOutput(sGet_);
if ( mysql_stmt_store_result(sGet_) )
Cdb::ThrowSQL("Cvisits::Get | mysql_stmt_store_result");
ret = mysql_stmt_fetch(sGet_);
if ( ret != 0 )
{
if ( ret == 1 || ret == MYSQL_NO_DATA )
return false;
else
Cdb::ThrowSQL("Cvisits::Get | mysql_stmt_fetch");
}
convSC();
genDTStrings();
return true;
}
/* ---------------------------------------------------------------------------
Insert record
--------------------------------------------------------------------------- */
unsigned Cvisits::Insert()
{
int ret;
if ( firstInsert_ )
{
char q[SQLBUF];
sprintf(q, "INSERT INTO visits (ip,country_code,region_name,city_name,method,uri,referer,uagent,lang,ua_type,bot,ad,session_id,status,processing,created) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
ret = mysql_stmt_prepare(sInsert_, q, strlen(q));
if ( ret != 0 )
Cdb::ThrowSQL("Cvisits::Insert | mysql_stmt_prepare");
firstInsert_ = false;
}
bindInput(sInsert_);
ret = mysql_stmt_execute(sInsert_);
if ( ret != 0 )
Cdb::ThrowSQL("Cvisits::Insert | mysql_stmt_execute");
id = mysql_insert_id(dbConn_);
return id;
}
/* ---------------------------------------------------------------------------
Update record by PK
--------------------------------------------------------------------------- */
void Cvisits::Update(int arg_id)
{
int ret;
if ( firstUpdate_ )
{
char q[SQLBUF];
sprintf(q, "UPDATE visits SET ip=?,country_code=?,region_name=?,city_name=?,method=?,uri=?,referer=?,uagent=?,lang=?,ua_type=?,bot=?,ad=?,session_id=?,status=?,processing=?,created=? WHERE id=?");
ret = mysql_stmt_prepare(sUpdate_, q, strlen(q));
if ( ret != 0 )
Cdb::ThrowSQL("Cvisits::Update | mysql_stmt_prepare");
firstUpdate_ = false;
}
bindInput(sUpdate_, true, arg_id);
ret = mysql_stmt_execute(sUpdate_);
if ( ret != 0 )
Cdb::ThrowSQL("Cvisits::Update | mysql_stmt_execute");
}
/* ---------------------------------------------------------------------------
Delete record by PK
--------------------------------------------------------------------------- */
void Cvisits::Delete(int arg_id)
{
int ret;
if ( firstDelete_ )
{
char q[SQLBUF];
sprintf(q, "DELETE FROM visits WHERE id=?");
ret = mysql_stmt_prepare(sDelete_, q, strlen(q));
if ( ret != 0 )
Cdb::ThrowSQL("Cvisits::Delete | mysql_stmt_prepare");
firstDelete_ = false;
}
bindKey(sDelete_, arg_id);
ret = mysql_stmt_execute(sDelete_);
if ( ret != 0 )
Cdb::ThrowSQL("Cvisits::Delete | mysql_stmt_execute");
}
/* ---------------------------------------------------------------------------
Insert or update record by PK
--------------------------------------------------------------------------- */
void Cvisits::Set(int arg_id)
{
int ret;
if ( firstSet_ )
{
char q[SQLBUF];
sprintf(q, "SELECT id FROM visits WHERE id=?");
ret = mysql_stmt_prepare(sSet_, q, strlen(q));
if ( ret != 0 )
Cdb::ThrowSQL("Cvisits::Set | mysql_stmt_prepare");
firstSet_ = false;
}
bindKey(sSet_, arg_id);
if ( mysql_stmt_execute(sSet_) )
Cdb::ThrowSQL("Cvisits::Set | mysql_stmt_execute");
bindSetOutput();
if ( mysql_stmt_store_result(sSet_) )
Cdb::ThrowSQL("Cvisits::Set | mysql_stmt_store_result");
ret = mysql_stmt_fetch(sSet_);
if ( ret == 0 ) /* record existed */
{
Update(arg_id);
}
else if ( ret == 1 || ret == MYSQL_NO_DATA ) /* not found ==> insert new */
{
id = arg_id;
Insert();
}
else
Cdb::ThrowSQL("Cvisits::Set | mysql_stmt_fetch");
}
/* ---------------------------------------------------------------------------
Bind key values
--------------------------------------------------------------------------- */
void Cvisits::bindKey(MYSQL_STMT *s, int arg_id)
{
k_id_ = arg_id;
memset(&bndk_, 0, sizeof(bndk_));
bndk_[0].buffer_type = MYSQL_TYPE_LONG;
bndk_[0].buffer = (char*)&k_id_;
if ( mysql_stmt_bind_param(s, bndk_) )
Cdb::ThrowSQL("Cvisits::bindKey | mysql_stmt_bind_param");
}
/* ---------------------------------------------------------------------------
Bind input values
--------------------------------------------------------------------------- */
void Cvisits::bindInput(MYSQL_STMT *s, bool withKey, int arg_id)
{
ip_len_ = strlen(ip);
country_code_len_ = strlen(country_code);
region_name_len_ = strlen(region_name);
city_name_len_ = strlen(city_name);
method_len_ = strlen(method);
uri_len_ = strlen(uri);
referer_len_ = strlen(referer);
uagent_len_ = strlen(uagent);
lang_len_ = strlen(lang);
s_ua_type_[0] = ua_type;
s_ua_type_[1] = EOS;
ua_type_len_ = 1;
s_bot_[0] = bot;
s_bot_[1] = EOS;
bot_len_ = 1;
s_ad_[0] = ad;
s_ad_[1] = EOS;
ad_len_ = 1;
set_datetime(&t_created_, created);
memset(&bndi_, 0, sizeof(bndi_));
bndi_[0].buffer_type = MYSQL_TYPE_STRING;
bndi_[0].buffer = (char*)ip;
bndi_[0].length = &ip_len_;
bndi_[1].buffer_type = MYSQL_TYPE_STRING;
bndi_[1].buffer = (char*)country_code;
bndi_[1].length = &country_code_len_;
bndi_[2].buffer_type = MYSQL_TYPE_STRING;
bndi_[2].buffer = (char*)region_name;
bndi_[2].length = ®ion_name_len_;
bndi_[3].buffer_type = MYSQL_TYPE_STRING;
bndi_[3].buffer = (char*)city_name;
bndi_[3].length = &city_name_len_;
bndi_[4].buffer_type = MYSQL_TYPE_STRING;
bndi_[4].buffer = (char*)method;
bndi_[4].length = &method_len_;
bndi_[5].buffer_type = MYSQL_TYPE_STRING;
bndi_[5].buffer = (char*)uri;
bndi_[5].length = &uri_len_;
bndi_[6].buffer_type = MYSQL_TYPE_STRING;
bndi_[6].buffer = (char*)referer;
bndi_[6].length = &referer_len_;
bndi_[7].buffer_type = MYSQL_TYPE_STRING;
bndi_[7].buffer = (char*)uagent;
bndi_[7].length = &uagent_len_;
bndi_[8].buffer_type = MYSQL_TYPE_STRING;
bndi_[8].buffer = (char*)lang;
bndi_[8].length = &lang_len_;
bndi_[9].buffer_type = MYSQL_TYPE_STRING;
bndi_[9].buffer = (char*)s_ua_type_;
bndi_[9].length = &ua_type_len_;
bndi_[10].buffer_type = MYSQL_TYPE_STRING;
bndi_[10].buffer = (char*)s_bot_;
bndi_[10].length = &bot_len_;
bndi_[11].buffer_type = MYSQL_TYPE_STRING;
bndi_[11].buffer = (char*)s_ad_;
bndi_[11].length = &ad_len_;
bndi_[12].buffer_type = MYSQL_TYPE_LONG;
bndi_[12].buffer = (char*)&session_id;
bndi_[13].buffer_type = MYSQL_TYPE_SHORT;
bndi_[13].buffer = (char*)&status;
bndi_[14].buffer_type = MYSQL_TYPE_FLOAT;
bndi_[14].buffer = (char*)&processing;
bndi_[15].buffer_type = MYSQL_TYPE_DATETIME;
bndi_[15].buffer = (char*)&t_created_;
if ( withKey ) /* after WHERE */
{
k_id_ = arg_id;
bndi_[16].buffer_type = MYSQL_TYPE_LONG;
bndi_[16].buffer = (char*)&k_id_;
}
if ( mysql_stmt_bind_param(s, bndi_) )
Cdb::ThrowSQL("Cvisits::bindInput | mysql_stmt_bind_param");
}
/* ---------------------------------------------------------------------------
Bind output values
--------------------------------------------------------------------------- */
void Cvisits::bindOutput(MYSQL_STMT *s)
{
memset(&bndo_, 0, sizeof(bndo_));
bndo_[0].buffer_type = MYSQL_TYPE_LONG;
bndo_[0].buffer = (char*)&id;
bndo_[0].is_null = &id_is_null_;
bndo_[1].buffer_type = MYSQL_TYPE_STRING;
bndo_[1].buffer = (char*)ip;
bndo_[1].buffer_length = 61;
bndo_[1].is_null = &ip_is_null_;
bndo_[2].buffer_type = MYSQL_TYPE_STRING;
bndo_[2].buffer = (char*)country_code;
bndo_[2].buffer_length = 3;
bndo_[2].is_null = &country_code_is_null_;
bndo_[3].buffer_type = MYSQL_TYPE_STRING;
bndo_[3].buffer = (char*)region_name;
bndo_[3].buffer_length = 129;
bndo_[3].is_null = ®ion_name_is_null_;
bndo_[4].buffer_type = MYSQL_TYPE_STRING;
bndo_[4].buffer = (char*)city_name;
bndo_[4].buffer_length = 129;
bndo_[4].is_null = &city_name_is_null_;
bndo_[5].buffer_type = MYSQL_TYPE_STRING;
bndo_[5].buffer = (char*)method;
bndo_[5].buffer_length = 16;
bndo_[5].is_null = &method_is_null_;
bndo_[6].buffer_type = MYSQL_TYPE_STRING;
bndo_[6].buffer = (char*)uri;
bndo_[6].buffer_length = 251;
bndo_[6].is_null = &uri_is_null_;
bndo_[7].buffer_type = MYSQL_TYPE_STRING;
bndo_[7].buffer = (char*)referer;
bndo_[7].buffer_length = 251;
bndo_[7].is_null = &referer_is_null_;
bndo_[8].buffer_type = MYSQL_TYPE_STRING;
bndo_[8].buffer = (char*)uagent;
bndo_[8].buffer_length = 251;
bndo_[8].is_null = &uagent_is_null_;
bndo_[9].buffer_type = MYSQL_TYPE_STRING;
bndo_[9].buffer = (char*)lang;
bndo_[9].buffer_length = 6;
bndo_[9].is_null = &lang_is_null_;
bndo_[10].buffer_type = MYSQL_TYPE_STRING;
bndo_[10].buffer = (char*)s_ua_type_;
bndo_[10].buffer_length = 2;
bndo_[10].is_null = &ua_type_is_null_;
bndo_[11].buffer_type = MYSQL_TYPE_STRING;
bndo_[11].buffer = (char*)s_bot_;
bndo_[11].buffer_length = 2;
bndo_[11].is_null = &bot_is_null_;
bndo_[12].buffer_type = MYSQL_TYPE_STRING;
bndo_[12].buffer = (char*)s_ad_;
bndo_[12].buffer_length = 2;
bndo_[12].is_null = &ad_is_null_;
bndo_[13].buffer_type = MYSQL_TYPE_LONG;
bndo_[13].buffer = (char*)&session_id;
bndo_[13].is_null = &session_id_is_null_;
bndo_[14].buffer_type = MYSQL_TYPE_SHORT;
bndo_[14].buffer = (char*)&status;
bndo_[14].is_null = &status_is_null_;
bndo_[15].buffer_type = MYSQL_TYPE_FLOAT;
bndo_[15].buffer = (char*)&processing;
bndo_[15].is_null = &processing_is_null_;
bndo_[16].buffer_type = MYSQL_TYPE_DATETIME;
bndo_[16].buffer = (char*)&t_created_;
bndo_[16].is_null = &created_is_null_;
if ( mysql_stmt_bind_result(s, bndo_) )
Cdb::ThrowSQL("Cvisits::bindOutput | mysql_stmt_bind_result");
}
/* ---------------------------------------------------------------------------
Bind output value for Set
--------------------------------------------------------------------------- */
void Cvisits::bindSetOutput()
{
static int id; /* to be scrapped anyway */
memset(&bndso_, 0, sizeof(bndso_));
bndso_[0].buffer_type = MYSQL_TYPE_LONG;
bndso_[0].buffer = (char*)&id;
if ( mysql_stmt_bind_result(sSet_, bndso_) )
Cdb::ThrowSQL("Cvisits::bindSetOutput | mysql_stmt_bind_result");
}
/* ---------------------------------------------------------------------------
Convert single char values
--------------------------------------------------------------------------- */
void Cvisits::convSC()
{
if ( ua_type_is_null_ )
ua_type = 0;
else
ua_type = s_ua_type_[0];
if ( bot_is_null_ )
bot = 0;
else
bot = s_bot_[0];
if ( ad_is_null_ )
ad = 0;
else
ad = s_ad_[0];
}
/* ---------------------------------------------------------------------------
Generate date-time strings
--------------------------------------------------------------------------- */
void Cvisits::genDTStrings()
{
if ( created_is_null_ )
created[0] = EOS;
else
sprintf(created, "%04d-%02d-%02d %02d:%02d:%02d", t_created_.year, t_created_.month, t_created_.day, t_created_.hour, t_created_.minute, t_created_.second);
}
/* ---------------------------------------------------------------------------
Reset (zero) public variables
--------------------------------------------------------------------------- */
void Cvisits::Reset()
{
id = 0;
ip[0] = EOS;
country_code[0] = EOS;
region_name[0] = EOS;
city_name[0] = EOS;
method[0] = EOS;
uri[0] = EOS;
referer[0] = EOS;
uagent[0] = EOS;
lang[0] = EOS;
ua_type = 0;
bot = 0;
ad = 0;
session_id = 0;
status = 0;
processing = 0;
created[0] = EOS;
}
| [
"[email protected]"
] | |
ad9bd623380c7c64409883d38fc1dc8daa66df69 | 94360bb04d669fa92d3084ab6a4cadcbd8308196 | /Graph/dfs.cpp | 4918ebbcc66915e462c787af55e2dc1568321335 | [] | no_license | orkhasnat/AlgorithmWithCodes | 0a5d9d3f5e0bbda36017bd8f0a98ff780bf1973f | 98003de5f21314170bdb94483b2cd484fd6bd86d | refs/heads/master | 2023-03-21T16:49:39.498363 | 2021-03-15T17:41:28 | 2021-03-15T17:41:28 | 349,251,566 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,461 | cpp | /*
Name: Depth First Search
Time Complexity:
* O(V+E), V is number of vertices, E is number of edges
Space Complexity:
* O(H), H is the maximum height of the tree
*/
/* Resources:
1. https://cp-algorithms.com/graph/depth-first-search.html
2. http://www.shafaetsplanet.com/?p=973
*/
#include <iostream>
#include <vector>
using namespace std;
const int N = 1e6; // Maximum possible number of nodes
vector<int> adj[N]; // Adjacency list using vector array
vector<bool> visited; // To keep track of the visited nodes
void dfs(int node) {
visited[node] true; // Mark the node as visited
for(int child : adj[node]) { // Access every child of node
if(!visited[child]) {
dfs(child); // If the child isn't visited yet,
// make a dfs call to that child
}
}
return;
}
int main() {
int node; // Number of nodes
int edge; // Number of edges
cin >> node >> edge;
int a, b;
// Taking input of all the edges
for(int i = 0; i < edge; i++) {
cin >> a >> b; // There is an edge between a and b
// If the graph is directed, we add b as a child of a, a.push_back(b)
// If the graph isn't directed, we add 'b' as a child of 'a' as well as 'a' as a child of 'b', a.push_back(b) and b.push_back(a)
a.push_back(b);
b.push_back(a);
}
int v; // We will start dfs from node v
dfs(v);
return 0;
} | [
"[email protected]"
] | |
680c638d46968c11738a55245c7f3e4a3989d22e | 79eb4aa95d6eb8d712952a80fd09959c33401bfb | /wordBreak2.cpp | 4a785a61b6085641e2063e15696fdffb745d4eb5 | [] | no_license | li3939108/leetcode | 6b6c829e10c5143419f96f46421273cf40a726b3 | 8e4d103419a31363e012990b1618a3e626592f76 | refs/heads/master | 2021-01-02T22:45:33.402236 | 2017-02-26T03:56:57 | 2017-02-26T03:56:57 | 16,051,686 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,648 | cpp | #include <iostream>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
void backtracking(vector<vector<bool> > &dp, int loc, string si, string &s, vector<string> &sv){
if(loc == 0){
sv.push_back(si);
}else{
for(int i = 0; i < loc; i++){
if(dp[i][loc]){
backtracking(dp, i, s.substr(i, loc - i) + " " + si, s, sv) ;
}
}
}
}
vector<string> wordBreak(string s, unordered_set<string>& wordDict) {
vector<string> ret(0) ;
int len = s.length(), max_dict_length = 0;
vector<bool> space_loc(len+1, false);
vector<vector<bool> > dp(len, vector<bool>(len + 1, false) );
space_loc[0] = true;
for(auto iter = wordDict.begin(); iter != wordDict.end(); iter++){
max_dict_length = max_dict_length < iter->length() ? iter->length() : max_dict_length;
}
for(int i = 0 ; i < len ; i ++){
if(space_loc[i] ){
for(int j = i + 1; j < len + 1 && j - i <= max_dict_length ; j++){
if(wordDict.find(s.substr(i, j - i) ) != wordDict.end() ) {
space_loc[j] = true;
dp[i][j] = true;
}
}
}
}
for(int i = 0; i < len; i++){
if(dp[i][len] ){
backtracking(dp, i, s.substr(i, len - i), s, ret);
}
}
return ret;
}
int main(){
string s("catsanddog");
unordered_set<string> dict = {"cat","cats","and","sand","dog"} ;
vector<string> bk = wordBreak(s, dict);
for(auto iter = bk.begin(); iter != bk.end() ; iter ++){
cout << *iter << endl ;
}
}
| [
"[email protected]"
] | |
c105b9f8894aaf47c4bb8c21cf452480a8692719 | 00b472cce6dd54354de618d476c67d5e4e79fcc2 | /Node.h | f01c4bbcad94ae024f0d05a6aabe759fc8235306 | [] | no_license | bm600/cs235-avl | 56a4c4b3c7365005a8922f5af191924b86033f05 | aa8f6a8bec9ce579b84c0e13ac77987da8c91d1e | refs/heads/master | 2023-04-17T00:56:30.205755 | 2017-12-05T05:18:08 | 2017-12-05T05:18:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 867 | h | #ifndef NODE_H
#define NODE_H
#include <iostream>
#include "NodeInterface.h"
class Node :
public NodeInterface
{
public:
Node * leftChild;
Node * rightChild;
int data;
int height;
Node(int value) {
height = 0;
data = value;
leftChild = NULL;
rightChild = NULL;
}
~Node()
{
}
/*
* Returns the data that is stored in this node
*
* @return the data that is stored in this node.
*/
int getData() const;
/*
* Returns the left child of this node or null if it doesn't have one.
*
* @return the left child of this node or null if it doesn't have one.
*/
NodeInterface * getLeftChild() const;
/*
* Returns the right child of this node or null if it doesn't have one.
*
* @return the right child of this node or null if it doesn't have one.
*/
NodeInterface * getRightChild() const;
int getHeight();
int getBalance();
};
#endif
| [
"[email protected]"
] | |
a5376c3d67c87f360e0b09bbf7b5e184cf6665b4 | 38b73cffea46b42dcb210f03369d4de804dec75a | /connectionsdialog.h | 1648faa7d063c074c1a8887c1609aa054bfe8f0e | [
"MIT"
] | permissive | kilab/qt-sqlmanager | ca6560326472c0ac6b78b181ae93d076d2203078 | ef510cdde95b3fce426997295824a2f354b6357a | refs/heads/master | 2020-04-13T01:39:07.224422 | 2019-07-08T00:26:12 | 2019-07-08T00:26:12 | 162,879,809 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,146 | h | #ifndef CONNECTIONSDIALOG_H
#define CONNECTIONSDIALOG_H
#include "sqlconnection.h"
#include <QDialog>
#include <QListWidgetItem>
#include <QSettings>
#include <QStandardItemModel>
#include <QString>
namespace Ui {
class ConnectionsDialog;
}
struct ConnectionValid {
bool status;
QString message;
};
class ConnectionsDialog : public QDialog
{
Q_OBJECT
public:
explicit ConnectionsDialog(QWidget *parent = nullptr);
~ConnectionsDialog();
CurrentConnection currentConnection;
private slots:
void on_Button_Connect_clicked();
void on_Button_Remove_clicked();
void on_Button_Save_clicked();
void on_Button_Add_clicked();
void on_Button_Test_clicked();
void on_List_Connections_doubleClicked(const QModelIndex &index);
void on_List_Connections_clicked(const QModelIndex &index);
private:
QStandardItemModel *connectionsModel;
Ui::ConnectionsDialog *ui;
QSettings settings;
void ConnectDatabase();
ConnectionValid CheckConnection();
bool CheckConnectionInputs();
void ClearForm();
void ResfreshConnectionsList();
};
#endif // CONNECTIONSDIALOG_H
| [
"[email protected]"
] | |
c0ffa751c223f60e0b43666c3e1c47c298fdac61 | d1866c2bca22c38577e1a202039e1252a2380bfd | /.svn/pristine/c3/c366aca43bff89075e75a48af6535de5fed0be63.svn-base | c2ae44496beb03021c0318b5cc665ffae717569e | [] | no_license | scottrehlander/UnstableGame | db0091f77e4b571fcb814881d77f324361cd14eb | 1dfc6f5fdf2b7d942bb1c636ac38f23cf732b4e3 | refs/heads/master | 2021-01-22T05:09:58.592609 | 2017-02-11T02:16:19 | 2017-02-11T02:16:19 | 81,624,318 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 203 | // stdafx.cpp : source file that includes just the standard includes
// SceneManager.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
| [
"[email protected]"
] |
Subsets and Splits