blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 986
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 23
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 145
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 10.4M | extension stringclasses 122
values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8329846914eb5a16bfa22aa78eccfb09b0683793 | 34d44a9ca7e6eb63495247ed2aed146b55f1c7db | /QuestionAns/rs_learner/1574.cc | 1190afe1fe9def33138a8c2ae3299e70a0f33afe | [] | no_license | sdustlug/OpenJudge | 2419c00824f29144864571e1d25c9de1a09350d2 | a6550441691470df505f6a971bc9661ced1b0773 | refs/heads/master | 2023-09-03T11:48:01.041727 | 2021-10-18T13:47:57 | 2021-10-18T13:47:57 | 418,521,703 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,246 | cc | #include<iostream>
#include<cstring>
#include<iomanip>
using namespace std;
class Date
{
private:
int year,month,day;
public:
Date(int _year,int _month,int _day):year(_year),month(_month),day(_day){}
~Date(){}
void showDate()
{
cout<<year<<"-"<<setw(2)<<setfill('0')<<setw(2)<<month<<"-"<<setw(2)<<day;
}
};
class Time
{
private:
int h,m,s;
public:
Time(int _h,int _m,int _s):h(_h),m(_m),s(_s){}
~Time(){}
void showTime()
{
cout<<setw(2)<<setfill('0')<<h<<":"<<setw(2)<<m<<":"<<setw(2)<<s;
}
};
int main()
{
int cases;
cin >> cases;
for(int ca = 0; ca < cases; ca++)
{
int year, month, day;
cin >> year >> month >> day;
Date date(year, month, day);
date.showDate();
cout << " ";
int hour, minute, second;
cin >> hour >> minute >> second;
Time time(hour, minute, second);
time.showTime();
cout << endl;
}
}
/**************************************************************
Problem: 1574
User: 201801020908
Language: C++
Result: Accepted
Time:1340 ms
Memory:1268 kb
****************************************************************/
| [
"if.nicer@gmail.com"
] | if.nicer@gmail.com |
1c851635e3444e751862272a271e9fc34aef7d59 | 04c45ab4591bd1129f5f6ffd104b36db32deaced | /catkin_ws/devel/include/beginner_tutorials/AddTwoIntsRequest.h | 713d70910df78cf1b6cc6c94b045b66f554cf2ea | [] | no_license | aladdinmck/ROS | 547b35ce27d00db0fb8521af8d11cc02cf4fa1e6 | 1caf2226e274fae8e5f1440366cd39a696e2a5fb | refs/heads/master | 2020-05-23T19:10:14.249098 | 2019-06-02T00:04:23 | 2019-06-02T00:04:23 | 186,905,970 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,420 | h | // Generated by gencpp from file beginner_tutorials/AddTwoIntsRequest.msg
// DO NOT EDIT!
#ifndef BEGINNER_TUTORIALS_MESSAGE_ADDTWOINTSREQUEST_H
#define BEGINNER_TUTORIALS_MESSAGE_ADDTWOINTSREQUEST_H
#include <string>
#include <vector>
#include <map>
#include <ros/types.h>
#include <ros/serialization.h>
#include <ros/builtin_message_traits.h>
#include <ros/message_operations.h>
namespace beginner_tutorials
{
template <class ContainerAllocator>
struct AddTwoIntsRequest_
{
typedef AddTwoIntsRequest_<ContainerAllocator> Type;
AddTwoIntsRequest_()
: a(0)
, b(0) {
}
AddTwoIntsRequest_(const ContainerAllocator& _alloc)
: a(0)
, b(0) {
(void)_alloc;
}
typedef int64_t _a_type;
_a_type a;
typedef int64_t _b_type;
_b_type b;
typedef boost::shared_ptr< ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator> const> ConstPtr;
}; // struct AddTwoIntsRequest_
typedef ::beginner_tutorials::AddTwoIntsRequest_<std::allocator<void> > AddTwoIntsRequest;
typedef boost::shared_ptr< ::beginner_tutorials::AddTwoIntsRequest > AddTwoIntsRequestPtr;
typedef boost::shared_ptr< ::beginner_tutorials::AddTwoIntsRequest const> AddTwoIntsRequestConstPtr;
// constants requiring out of line definition
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator> >::stream(s, "", v);
return s;
}
} // namespace beginner_tutorials
namespace ros
{
namespace message_traits
{
// BOOLTRAITS {'IsFixedSize': True, 'IsMessage': True, 'HasHeader': False}
// {'beginner_tutorials': ['/home/aladdinmck/ROS/catkin_ws/src/beginner_tutorials/msg'], 'std_msgs': ['/opt/ros/melodic/share/std_msgs/cmake/../msg']}
// !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types']
template <class ContainerAllocator>
struct IsFixedSize< ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct HasHeader< ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator> const>
: FalseType
{ };
template<class ContainerAllocator>
struct MD5Sum< ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator> >
{
static const char* value()
{
return "36d09b846be0b371c5f190354dd3153e";
}
static const char* value(const ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0x36d09b846be0b371ULL;
static const uint64_t static_value2 = 0xc5f190354dd3153eULL;
};
template<class ContainerAllocator>
struct DataType< ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator> >
{
static const char* value()
{
return "beginner_tutorials/AddTwoIntsRequest";
}
static const char* value(const ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator>&) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator> >
{
static const char* value()
{
return "int64 a\n"
"int64 b\n"
;
}
static const char* value(const ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator>&) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.a);
stream.next(m.b);
}
ROS_DECLARE_ALLINONE_SERIALIZER
}; // struct AddTwoIntsRequest_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::beginner_tutorials::AddTwoIntsRequest_<ContainerAllocator>& v)
{
s << indent << "a: ";
Printer<int64_t>::stream(s, indent + " ", v.a);
s << indent << "b: ";
Printer<int64_t>::stream(s, indent + " ", v.b);
}
};
} // namespace message_operations
} // namespace ros
#endif // BEGINNER_TUTORIALS_MESSAGE_ADDTWOINTSREQUEST_H
| [
"haa55387@uga.edu"
] | haa55387@uga.edu |
88ebead79c333d626927b02b39e028ebff29007e | 621f90d90f4a046136411c75b3ebc4889b640f23 | /src/Samples/SpiLcd.h | be912cc43a8863b4f72893923a29c4b69563f1e3 | [] | no_license | suspect-devices/eXodusino | 2e6548cb47f3e94c9088c2bbcb2b25ea42a7a379 | 5c9eb1b24ed4cfa7eae59ffbc24bdbbce814ba35 | refs/heads/master | 2020-04-05T23:32:49.259284 | 2012-09-25T12:32:32 | 2012-09-25T12:32:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,811 | h | /*
* SpiLcd.h
*
* Created on: 2012/08/01
* Author: lynxeyed
*/
#ifndef SPILCD_H_
#define SPILCD_H_
/**************************************************************************//**
* @file SpiLcd.h
* @brief Arduino-like library for Cortex-M0 Series
* @version v.0.50
* @date 1. August 2011.
* @author lynxeyed
* @note Copyright (c) 2012 Lynx-EyED's Klavier and Craft-works. <BR>
* 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: <BR>
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.<BR>
* 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.
******************************************************************************/
#include "SPI.h"
#include "gpio.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {ST7735,Nokia6610,Nokia6100,PCF8833} LCD_DEVICES; // Defaults:ST7735
class SPILCD {
private:
SSP_PORT port;
LCD_DEVICES device;
int LCD_VCC_ON;
int LCD_CS;
int LCD_RES;
int _row;
int _column;
int _foreground;
int _background;
int _width;
int _height;
public:
SPILCD(); // announce the constructor to initialize
~SPILCD();
void reset();
void reset(SSP_PORT port);
void command( int value );
void data( int value );
void _window( int x, int y, int width, int height );
void locate(int column, int row);
void newline();
void _putp( int colour );
int _putc( int value );
void cls( void );
void window( int x, int y, int width, int height );
void WindowReset(void);
void putp( int colour );
void pixel( int x, int y, int colour );
void fill( int x, int y, int width, int height, int colour );
void blit( int x, int y, int width, int height, const int* colour );
void bitblit( int x, int y, int width, int height, const char* bitstream );
void foreground(int c);
void background(int c);
int width();
int height();
int columns();
int rows();
};
extern SPILCD slcd;
#ifdef __cplusplus
}
#endif
#endif /* SPILCD_H_ */
| [
"lynxeyed@xj9.so-net.ne.jp"
] | lynxeyed@xj9.so-net.ne.jp |
c42b51da73e44777c2ce1750223cb4b9fd69ad92 | 09c45ee18df8ab07f7c4a1f24618b64a3993e841 | /src/interface/trsm_interface.hpp | 8920db7207e8d08eb8bc26c2e68ebbd32c4deb3e | [
"Apache-2.0"
] | permissive | ProGTX/sycl-blas | 85ca2376e46b574e0a84953f371a03c6691741c4 | 733275772b49d775c2d453d77b7cc1642974c09b | refs/heads/master | 2023-09-04T00:33:57.559533 | 2023-08-22T13:28:29 | 2023-08-22T13:28:29 | 118,629,272 | 0 | 0 | Apache-2.0 | 2023-01-05T14:02:11 | 2018-01-23T15:28:15 | C++ | UTF-8 | C++ | false | false | 15,028 | hpp | /***************************************************************************
*
* @license
* Copyright (C) Codeplay Software Limited
* 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
*
* For your convenience, a copy of the License has been included in this
* repository.
*
* 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.
*
* portBLAS: BLAS implementation using SYCL
*
**************************************************************************/
#ifndef PORTBLAS_BLAS3_TRSM_INTERFACE_HPP
#define PORTBLAS_BLAS3_TRSM_INTERFACE_HPP
#include "blas_meta.h"
#include "interface/gemm_interface.hpp"
#include "operations/blas3_trees.h"
#include "sb_handle/portblas_handle.h"
#include "portblas_helper.h"
#include "views/view.h"
namespace blas {
namespace internal {
/**
* @brief Implementation of Triangle Solve with Multiple Right Hand Sides
* (TRSM).
* @param side Indicates if A is on the left or right of X
* @param uplo Indicates if A is lower or upper triangular
* @param trans Indicates the form that the matrix A will take in the
* multiplication
* @param diag Indicates if A has a non-unit diagonal or is assumed to be
* unit diagonal.
* @param M The number of rows of matrix B, must be at least 1
* @param N The number of columns of B, must be at least 1
* @param alpha The scalar alpha that is applied to B
* @param A Buffer that holds the input matrix A
* @param lda Leading dimension of matrix A
* @param B Buffer that holds the input/output matrix B
* @param ldb Leading dimension of matrix B
*
* @note both matrices A and B are expected to be stored in column major order
*
* Documentation from LAPACK's reference implementation can be found here:
* http://www.netlib.org/lapack/explore-html/d1/d54/group__double__blas__level3_ga6a0a7704f4a747562c1bd9487e89795c.html#ga6a0a7704f4a747562c1bd9487e89795c.
*
* TRSM solves one of the following matrix equations
*
* op(A)*X = alpha*B or X*op(A) = alpha*B
*
* where alpha is a scalar, X and B are m by n matrices, A is a unit or
* non-unit, upper or lower triangular matrix and op(A) is
*
* op(A) = A or op(A) = A^{T}
*
* The matrix X, which contains the result, is copied to B at the end.
*
* This is the parallel version of TRSM, that works by solving the equation
* AX = B as X = A^{-1}B. Inverting the matrix A is usually not the recommended
* way of solving this system, however, being a triangular matrix, we can use
* a block decomposition like the following:
*
* A X alpha * B
* [ A00 0 ] * [ X0 ] = [ B0 ]
* [ A10 A11 ] [ X1 ] [ B1 ]
*
* This is an example where A is on the left side and is a lower triangular
* matrix. The matrices can be divided in as many blocks as necessary. This
* decomposition yields:
*
* A00*X0 = alpha*B0 ==> X0 = alpha*A00^{-1}*B0
* A01*X0 + A11*X1 = alpha*B1 ==> X1 = A11^{-1}*(alpha*B1 - A10*X0)
*
* Which implies that we only need to invert A00 and A11 (or the diagonal blocks
* of matrix A). The function @ref make_diagonal_blocks_inverter can be used to
* perform this operation. The process of obtaining X0 and X1 is now mapped into
* 3 GEMM calls, one to solve X0, and 2 two solve X1.
*
* GEMM evaluates the expression C = alpha*A*B + beta*C, so solving for X0
* becomes a GEMM call in the format:
*
* X0 = alpha * A00^{-1}*B0 + 0*X0
*
* With X0 calculated we can solve X1 with two more GEMM calls
*
* B1 = -1 * A01*X0 + alpha*B1
* X1 = 1 * A11^{-1}*B1 + 0*X1
*
* This step can be repeated as many times as necessary for larger matrices.
* Despite having to invert blocks of the matrix A, this TRSM implementation
* takes advantage of GEMM calls that are heavily optimized for the target
* hardware, thus running with maximum performance.
*/
template <typename sb_handle_t, typename container_0_t, typename container_1_t,
typename element_t, typename index_t>
typename sb_handle_t::event_t _trsm(sb_handle_t& sb_handle, char side,
char uplo, char trans, char diag, index_t M,
index_t N, element_t alpha, container_0_t A,
index_t lda, container_1_t B, index_t ldb) {
// Makes sure all dimensions are larger than zero
if ((M == 0) || (N == 0) || (lda == 0) || (ldb == 0)) {
throw std::invalid_argument("invalid matrix size argument");
}
side = tolower(side);
uplo = tolower(uplo);
trans = tolower(trans);
diag = tolower(diag);
if (side != 'l' && side != 'r') {
throw std::invalid_argument("invalid Side argument");
} else if (uplo != 'u' && uplo != 'l') {
throw std::invalid_argument("invalid Triangle argument");
} else if (trans != 'n' && trans != 't') {
throw std::invalid_argument("invalid Transpose argument");
} else if (diag != 'u' && diag != 'n') {
throw std::invalid_argument("invalid Diagonal argument");
}
// Computes the k dimension. This is based on whether or not matrix is A (on
// the left) or B (on the right) in the gemm routine.
const index_t K = (side == 'l') ? M : N;
const bool isUnitDiag = diag == 'u';
const bool isUpper = uplo == 'u';
const bool isLeft = side == 'l';
const bool isTranspose = trans == 't';
constexpr index_t blockSize = 16;
typename sb_handle_t::event_t trsmEvents;
// Temporary buffer for the inverse of the diagonal blocks of the matrix A
// filled with zeroes
const index_t invASize = roundUp<index_t>(K, blockSize) * blockSize;
auto invA = make_sycl_iterator_buffer<element_t>(invASize);
std::vector<cl::sycl::event> event = {
blas::helper::fill(sb_handle.get_queue(), invA, element_t{0}, invASize)};
trsmEvents = concatenate_vectors(trsmEvents, event);
// Create the matrix views from the input buffers
auto bufferA = make_matrix_view<col_major>(A, K, K, lda);
auto bufferInvA =
make_matrix_view<col_major>(invA, blockSize, blockSize, lda);
auto bufferB = make_matrix_view<col_major>(B, M, N, ldb);
// Calculate the parameters for the diagonal blocks inversion
const index_t numBlocks = roundUp<index_t>(K, blockSize) / blockSize;
const index_t numInternalBlocks = roundUp<index_t>(K, blockSize) / blockSize;
const index_t globalSize = numInternalBlocks * blockSize;
const index_t localSize = blockSize;
const index_t localMemSize = blockSize * blockSize;
// Instantiate the appropriate diagonal blocks inversion based on the matrix
// type
typename sb_handle_t::event_t invertBlocksEvent;
if (isUnitDiag && isUpper) {
auto diagInverter =
make_diag_blocks_inverter<true, true, blockSize>(bufferA, bufferInvA);
invertBlocksEvent =
sb_handle.execute(diagInverter, localSize, globalSize, localMemSize);
} else if (!isUnitDiag && isUpper) {
auto diagInverter =
make_diag_blocks_inverter<false, true, blockSize>(bufferA, bufferInvA);
invertBlocksEvent =
sb_handle.execute(diagInverter, localSize, globalSize, localMemSize);
} else if (isUnitDiag && !isUpper) {
auto diagInverter =
make_diag_blocks_inverter<true, false, blockSize>(bufferA, bufferInvA);
invertBlocksEvent =
sb_handle.execute(diagInverter, localSize, globalSize, localMemSize);
} else if (!isUnitDiag && !isUpper) {
auto diagInverter =
make_diag_blocks_inverter<false, false, blockSize>(bufferA, bufferInvA);
invertBlocksEvent =
sb_handle.execute(diagInverter, localSize, globalSize, localMemSize);
}
trsmEvents = concatenate_vectors(trsmEvents, invertBlocksEvent);
// Creates a copy of B to avoid overwriting the input in GEMM. While computing
// output X will hold the TRSM result and will be copied to B at the end
const index_t BSize = ldb * (N - 1) + M;
const index_t ldx = ldb;
auto X = make_sycl_iterator_buffer<element_t>(BSize);
trsmEvents = concatenate_vectors(
trsmEvents, internal::_copy(sb_handle, BSize, B, 1, X, 1));
if (isLeft) {
if ((isUpper && isTranspose) || (!isUpper && !isTranspose)) {
// Solves the system AX = alpha*B, as described in the documentation of
// the function when X is lower triangular.
//
// A X B
// [ A00 0 ] * [ X0 ] = alpha * [ B0 ]
// [ A10 A11 ] [ X1 ] [ B1 ]
//
// yields:
//
// X0 = alpha*A00{-1}*B0
// B1 = -1 * A10*X0 + alpha*B1
// X1 = A11{-1}*B1 + 0*X1
//
// True when (lower triangular) or (upper triangular and transposed)
for (index_t i = 0; i < M; i += blockSize) {
const index_t currentBlockSize = std::min(M - i, blockSize);
auto gemmEvent = internal::_gemm(
sb_handle, isTranspose ? 't' : 'n', 'n', currentBlockSize, N,
currentBlockSize, (i == 0) ? alpha : element_t{1},
invA + i * blockSize, blockSize, B + i, ldb, element_t{0}, X + i,
ldx);
trsmEvents = concatenate_vectors(trsmEvents, gemmEvent);
if ((i + blockSize) >= M) {
break;
}
const std::ptrdiff_t offsetA = !isTranspose
? ((i + blockSize) + (i * lda))
: (i + (blockSize + i) * lda);
internal::_gemm(
sb_handle, isTranspose ? 't' : 'n', 'n', M - i - blockSize, N,
blockSize, element_t{-1}, A + offsetA, lda, X + i, ldx,
(i == 0) ? alpha : element_t{1}, B + i + blockSize, ldb);
trsmEvents = concatenate_vectors(trsmEvents, gemmEvent);
}
} else {
// Solves the system AX = alpha*B when X is upper triangular
//
// A X B
// [ A00 A01 ] * [ X0 ] = alpha * [ B0 ]
// [ 0 A11 ] [ X1 ] [ B1 ]
//
// yields:
//
// X1 = alpha*A11{-1}*B1
// B0 = -1 * A01*X1 + alpha*B0
// X0 = A00{-1}*B0 + 0*X0
//
// True when (upper triangular) or (lower triangular and transposed)
const index_t specialBlockSize =
(M % blockSize == 0) ? blockSize : (M % blockSize);
const index_t iStart = M - specialBlockSize;
for (index_t i = iStart; i >= 0; i -= blockSize) {
const index_t currentBlockSize =
(i == iStart) ? specialBlockSize : blockSize;
auto gemmEvent = internal::_gemm(
sb_handle, isTranspose ? 't' : 'n', 'n', currentBlockSize, N,
currentBlockSize, (i == iStart) ? alpha : element_t{1},
invA + i * blockSize, blockSize, B + i, ldb, element_t{0}, X + i,
ldx);
trsmEvents = concatenate_vectors(trsmEvents, gemmEvent);
if ((i - blockSize) < 0) {
break;
}
gemmEvent = internal::_gemm(
sb_handle, isTranspose ? 't' : 'n', 'n', i, N, currentBlockSize,
element_t{-1}, A + (!isTranspose ? (i * lda) : i), lda, X + i, ldx,
(i == iStart) ? alpha : element_t{1}, B, ldb);
trsmEvents = concatenate_vectors(trsmEvents, gemmEvent);
}
}
} else {
// Right side
if ((isUpper && isTranspose) || (!isUpper && !isTranspose)) {
// Solves the system XA = alpha*B when A is lower triangular
// X * A B
// [ X0 X1 ] [ A00 0 ] = alpha * [ B0 B1 ]
// [ A10 A11 ]
//
// yields:
//
// X1 = alpha*B1*A11{-1}
// B0 = -1 * X1*A10 + alpha*B0
// X0 = B0*A00{-1} + 0*X0
//
// True when (lower triangular) or (upper triangular and transposed)
const index_t specialBlockSize =
(N % blockSize == 0) ? blockSize : (N % blockSize);
const index_t iStart = N - specialBlockSize;
for (index_t i = iStart; i >= 0; i -= blockSize) {
const index_t currentBlockSize =
(i == iStart) ? specialBlockSize : blockSize;
auto gemmEvent = internal::_gemm(
sb_handle, 'n', isTranspose ? 't' : 'n', M, currentBlockSize,
currentBlockSize, (i == iStart) ? alpha : element_t{1}, B + i * ldb,
ldb, invA + i * blockSize, blockSize, element_t{0}, X + i * ldx,
ldx);
trsmEvents = concatenate_vectors(trsmEvents, gemmEvent);
if ((i - blockSize) < 0) {
break;
}
gemmEvent = internal::_gemm(
sb_handle, 'n', isTranspose ? 't' : 'n', M, i, currentBlockSize,
element_t{-1}, X + i * ldx, ldx, A + (!isTranspose ? i : (i * lda)),
lda, (i == iStart) ? alpha : element_t{1}, B, ldb);
trsmEvents = concatenate_vectors(trsmEvents, gemmEvent);
}
} else {
// Solves the system XA = alpha*B when A is upper triangular
// X * A B
// [ X0 X1 ] [ A00 A01 ] = alpha * [ B0 B1 ]
// [ 0 A11 ]
//
// yields:
//
// X0 = alpha*B0*A00^{-1}
// B1 = -1 * X0*A01 + alpha*B1
// X1 = B1*A11{-1} + 0*X1
//
// True when (upper triangular) or (lower triangular and transposed)
for (index_t i = 0; i < N; i += blockSize) {
const index_t currentBlockSize = std::min(N - i, blockSize);
auto gemmEvent = internal::_gemm(
sb_handle, 'n', isTranspose ? 't' : 'n', M, currentBlockSize,
currentBlockSize, (i == 0) ? alpha : element_t{1}, B + i * ldb, ldb,
invA + i * blockSize, blockSize, element_t{0}, X + i * ldx, ldx);
trsmEvents = concatenate_vectors(trsmEvents, gemmEvent);
if ((i + blockSize) > N) {
break;
}
const std::ptrdiff_t offset = !isTranspose
? (i + (blockSize + i) * lda)
: (i + blockSize) + (i * lda);
gemmEvent = internal::_gemm(
sb_handle, 'n', isTranspose ? 't' : 'n', M, N - i - blockSize,
blockSize, element_t{-1}, X + i * ldx, ldx, A + offset, lda,
(i == 0) ? alpha : element_t{1}, B + (i + blockSize) * ldb, ldb);
trsmEvents = concatenate_vectors(trsmEvents, gemmEvent);
}
}
}
// Copy bufferX to bufferB as the TRSM result
trsmEvents = concatenate_vectors(
trsmEvents, internal::_copy(sb_handle, BSize, X, 1, B, 1));
return trsmEvents;
}
} // namespace internal
} // namespace blas
#endif // PORTBLAS_BLAS3_TRSM_INTERFACE_HPP
| [
"noreply@github.com"
] | ProGTX.noreply@github.com |
ec9dce584949da420eccb43f44ae2bddba3ad3f9 | fe7b28c973ae08925427159ac611ac302c297435 | /Dev/Cpp/src/Utils/EffekseerGodot.Utils.h | c4823ad7c55af17c14d7a821c9ecaff9be50ae8c | [
"MIT"
] | permissive | GodotCollection/EffekseerForGodot3 | 5aba08a73447c30d7b1b098c861090d11c224b59 | 24be11d4f54d11630926c3181088d346c13fb188 | refs/heads/main | 2023-03-12T15:04:52.217025 | 2021-03-03T01:21:09 | 2021-03-03T01:21:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,808 | h | #pragma once
#include <stdint.h>
#include <Effekseer.h>
#include <String.hpp>
#include <RID.hpp>
#include <Vector2.hpp>
#include <Vector3.hpp>
#include <Transform.hpp>
#include <Color.hpp>
#include <Script.hpp>
namespace EffekseerGodot
{
inline int64_t RIDToInt64(godot::RID rid)
{
int64_t val;
memcpy(&val, &rid, sizeof(rid));
return val;
}
inline godot::RID Int64ToRID(int64_t val)
{
godot::RID rid;
memcpy(&rid, &val, sizeof(rid));
return rid;
}
inline Effekseer::Vector2D ToEfkVector2(godot::Vector2 v)
{
return { v.x, v.y };
}
inline godot::Vector2 ToGdVector2(Effekseer::Vector2D v)
{
return { v.X, v.Y };
}
inline Effekseer::Vector3D ToEfkVector3(godot::Vector3 v)
{
return { v.x, v.y, v.z };
}
inline godot::Vector3 ToGdVector3(Effekseer::Vector3D v)
{
return { v.X, v.Y, v.Z };
}
inline Effekseer::Matrix44 ToEfkMatrix44(const godot::Transform& transform)
{
Effekseer::Matrix44 matrix;
matrix.Values[0][0] = transform.basis[0][0];
matrix.Values[0][1] = transform.basis[0][1];
matrix.Values[0][2] = transform.basis[0][2];
matrix.Values[0][3] = 0.0f;
matrix.Values[1][0] = transform.basis[1][0];
matrix.Values[1][1] = transform.basis[1][1];
matrix.Values[1][2] = transform.basis[1][2];
matrix.Values[1][3] = 0.0f;
matrix.Values[2][0] = transform.basis[2][0];
matrix.Values[2][1] = transform.basis[2][1];
matrix.Values[2][2] = transform.basis[2][2];
matrix.Values[2][3] = 0.0f;
matrix.Values[3][0] = transform.origin.x;
matrix.Values[3][1] = transform.origin.y;
matrix.Values[3][2] = transform.origin.z;
matrix.Values[3][3] = 1.0f;
return matrix;
}
inline Effekseer::Matrix44 ToEfkMatrix44(const godot::Transform2D& transform)
{
Effekseer::Matrix44 matrix;
matrix.Values[0][0] = transform.elements[0].x;
matrix.Values[0][1] = transform.elements[0].y;
matrix.Values[0][2] = 0.0f;
matrix.Values[0][3] = 0.0f;
matrix.Values[1][0] = transform.elements[1].x;
matrix.Values[1][1] = transform.elements[1].y;
matrix.Values[1][2] = 0.0f;
matrix.Values[1][3] = 0.0f;
matrix.Values[2][0] = 0.0f;
matrix.Values[2][1] = 0.0f;
matrix.Values[2][2] = 1.0f;
matrix.Values[2][3] = 0.0f;
matrix.Values[3][0] = transform.elements[2].x;
matrix.Values[3][1] = transform.elements[2].y;
matrix.Values[3][2] = 0.0f;
matrix.Values[3][3] = 1.0f;
return matrix;
}
inline Effekseer::Matrix43 ToEfkMatrix43(const godot::Transform& transform)
{
Effekseer::Matrix43 matrix;
matrix.Value[0][0] = transform.basis[0][0];
matrix.Value[0][1] = transform.basis[0][1];
matrix.Value[0][2] = transform.basis[0][2];
matrix.Value[1][0] = transform.basis[1][0];
matrix.Value[1][1] = transform.basis[1][1];
matrix.Value[1][2] = transform.basis[1][2];
matrix.Value[2][0] = transform.basis[2][0];
matrix.Value[2][1] = transform.basis[2][1];
matrix.Value[2][2] = transform.basis[2][2];
matrix.Value[3][0] = transform.origin.x;
matrix.Value[3][1] = transform.origin.y;
matrix.Value[3][2] = transform.origin.z;
return matrix;
}
inline Effekseer::Matrix43 ToEfkMatrix43(const godot::Transform2D& transform)
{
Effekseer::Matrix43 matrix;
matrix.Value[0][0] = transform.elements[0].x;
matrix.Value[0][1] = transform.elements[0].y;
matrix.Value[0][2] = 0.0f;
matrix.Value[1][0] = transform.elements[1].x;
matrix.Value[1][1] = transform.elements[1].y;
matrix.Value[1][2] = 0.0f;
matrix.Value[2][0] = 0.0f;
matrix.Value[2][1] = 0.0f;
matrix.Value[2][2] = 1.0f;
matrix.Value[3][0] = transform.elements[2].x;
matrix.Value[3][1] = transform.elements[2].y;
matrix.Value[3][2] = 0.0f;
return matrix;
}
inline godot::Transform ToGdMatrix(Effekseer::Matrix44 matrix)
{
godot::Transform transform;
transform.basis[0][0] = matrix.Values[0][0];
transform.basis[1][0] = matrix.Values[1][0];
transform.basis[2][0] = matrix.Values[2][0];
transform.basis[0][1] = matrix.Values[0][1];
transform.basis[1][1] = matrix.Values[1][1];
transform.basis[2][1] = matrix.Values[2][1];
transform.basis[0][2] = matrix.Values[0][2];
transform.basis[1][2] = matrix.Values[1][2];
transform.basis[2][2] = matrix.Values[2][2];
transform.origin.x = matrix.Values[3][0];
transform.origin.y = matrix.Values[3][1];
transform.origin.z = matrix.Values[3][2];
return transform;
}
inline Effekseer::Color ToEfkColor(godot::Color c)
{
return {
(uint8_t)Effekseer::Clamp((int)(c.r * 255.0f), 255, 0),
(uint8_t)Effekseer::Clamp((int)(c.g * 255.0f), 255, 0),
(uint8_t)Effekseer::Clamp((int)(c.b * 255.0f), 255, 0),
(uint8_t)Effekseer::Clamp((int)(c.a * 255.0f), 255, 0),
};
}
inline godot::Color ToGdColor(Effekseer::Color c)
{
return { c.R / 255.0f, c.G / 255.0f, c.B / 255.0f, c.A / 255.0f };
}
size_t ToEfkString(char16_t* to, const godot::String& from, size_t size);
godot::String ToGdString(const char16_t* from);
godot::Variant ScriptNew(godot::Ref<godot::Script> script);
}
| [
"nalto32@gmail.com"
] | nalto32@gmail.com |
a301cd389c3dc1c17a5b34056eed86a2fbf8cd95 | d739bf4fdc0281286d0deb7c18738784bd43d4e2 | /day10/6.28homework/person.h | 11cdac9a9412feadf39a2cda9f6799342f5bb32c | [] | no_license | hewei-bit/cpp_learning | 4b50e0cb520ddb00c55eab58c7d5b9076579bdcf | 098ef4fbc7d487f94c802fc8703e85aedf75d1c5 | refs/heads/master | 2022-11-17T17:27:41.873882 | 2020-06-28T03:24:12 | 2020-06-28T03:24:12 | 271,423,628 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 291 | h | #ifndef PERSON_H
#define PERSON_H
#include <iostream>
#include <string>
using namespace std;
class Person
{
public:
Person(){}
Person(string name,int age)
{
this->m_Name = name;
this->m_Age = age;
}
string m_Name;
int m_Age;
};
#endif // PERSON_H
| [
"1003826976@qq.com"
] | 1003826976@qq.com |
873c6d031afe140768f5cdcee2a4c6b9b1319f60 | 89dedd7f3c7acc81d12e2bcb2e716f9af9e5fa04 | /chrome/browser/android/thumbnail/scoped_ptr_expiring_cache.h | 00a680178da2c4240377a56fde619376d4ba1221 | [
"BSD-3-Clause"
] | permissive | bino7/chromium | 8d26f84a1b6e38a73d1b97fea6057c634eff68cb | 4666a6bb6fdcb1114afecf77bdaa239d9787b752 | refs/heads/master | 2022-12-22T14:31:53.913081 | 2016-09-06T10:05:11 | 2016-09-06T10:05:11 | 67,410,510 | 1 | 3 | BSD-3-Clause | 2022-12-17T03:08:52 | 2016-09-05T10:11:59 | null | UTF-8 | C++ | false | false | 1,942 | h | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ANDROID_THUMBNAIL_SCOPED_PTR_EXPIRING_CACHE_H_
#define CHROME_BROWSER_ANDROID_THUMBNAIL_SCOPED_PTR_EXPIRING_CACHE_H_
#include <stddef.h>
#include <memory>
#include "base/macros.h"
#include "net/base/linked_hash_map.h"
template <class Key, class Value>
class ScopedPtrExpiringCache {
private:
typedef linked_hash_map<Key, Value*> LinkedHashMap;
public:
typedef typename LinkedHashMap::iterator iterator;
explicit ScopedPtrExpiringCache(size_t max_cache_size)
: max_cache_size_(max_cache_size) {}
~ScopedPtrExpiringCache() {}
void Put(const Key& key, std::unique_ptr<Value> value) {
Remove(key);
map_[key] = value.release();
EvictIfFull();
}
Value* Get(const Key& key) {
iterator iter = map_.find(key);
if (iter != map_.end())
return iter->second;
return NULL;
}
std::unique_ptr<Value> Remove(const Key& key) {
iterator iter = map_.find(key);
std::unique_ptr<Value> value;
if (iter != map_.end()) {
value.reset(iter->second);
map_.erase(key);
}
return std::move(value);
}
void Clear() {
for (iterator iter = map_.begin(); iter != map_.end(); iter++) {
delete iter->second;
}
map_.clear();
}
iterator begin() { return map_.begin(); }
iterator end() { return map_.end(); }
size_t MaximumCacheSize() const { return max_cache_size_; }
size_t size() const { return map_.size(); }
private:
void EvictIfFull() {
while (map_.size() > max_cache_size_) {
iterator it = map_.begin();
delete it->second;
map_.erase(it);
}
}
size_t max_cache_size_;
LinkedHashMap map_;
DISALLOW_COPY_AND_ASSIGN(ScopedPtrExpiringCache);
};
#endif // CHROME_BROWSER_ANDROID_THUMBNAIL_SCOPED_PTR_EXPIRING_CACHE_H_
| [
"bino.zh@gmail.com"
] | bino.zh@gmail.com |
53977febe64a1c1f97a8c06ddcf3765c08580987 | 85221a64ad699e9f4d4d3bc508fa776c6b2e1d16 | /DummyClients/DummyClients/include/aws/gamelift/model/ListAliasesResult.h | 7c66479a2ddf34c6b924b2bf8d51ede4f2bde171 | [
"MIT"
] | permissive | joonhochoi/GameLift | bf6dbabcba868540bd9cf834623b189c65628b39 | 81bbad1e922d977bd885cdaa37f2e05d4fe2b966 | refs/heads/master | 2020-12-24T12:06:37.600884 | 2016-10-27T06:47:53 | 2016-10-27T06:47:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,093 | h | /*
* Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#pragma once
#include <aws/gamelift/GameLift_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSVector.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/gamelift/model/Alias.h>
namespace Aws
{
template<typename RESULT_TYPE>
class AmazonWebServiceResult;
namespace Utils
{
namespace Json
{
class JsonValue;
} // namespace Json
} // namespace Utils
namespace GameLift
{
namespace Model
{
/**
* <p>Represents the returned data in response to a request action.</p>
*/
class AWS_GAMELIFT_API ListAliasesResult
{
public:
ListAliasesResult();
ListAliasesResult(const AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);
ListAliasesResult& operator=(const AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);
/**
* <p>Collection of alias records that match the list request. </p>
*/
inline const Aws::Vector<Alias>& GetAliases() const{ return m_aliases; }
/**
* <p>Collection of alias records that match the list request. </p>
*/
inline void SetAliases(const Aws::Vector<Alias>& value) { m_aliases = value; }
/**
* <p>Collection of alias records that match the list request. </p>
*/
inline void SetAliases(Aws::Vector<Alias>&& value) { m_aliases = value; }
/**
* <p>Collection of alias records that match the list request. </p>
*/
inline ListAliasesResult& WithAliases(const Aws::Vector<Alias>& value) { SetAliases(value); return *this;}
/**
* <p>Collection of alias records that match the list request. </p>
*/
inline ListAliasesResult& WithAliases(Aws::Vector<Alias>&& value) { SetAliases(value); return *this;}
/**
* <p>Collection of alias records that match the list request. </p>
*/
inline ListAliasesResult& AddAliases(const Alias& value) { m_aliases.push_back(value); return *this; }
/**
* <p>Collection of alias records that match the list request. </p>
*/
inline ListAliasesResult& AddAliases(Alias&& value) { m_aliases.push_back(value); return *this; }
/**
* <p>Token indicating where to resume retrieving results on the next call to this
* action. If no token is returned, these results represent the end of the
* list.</p> <note> <p>If a request has a limit that exactly matches the number of
* remaining results, a token is returned even though there are no more results to
* retrieve.</p> </note>
*/
inline const Aws::String& GetNextToken() const{ return m_nextToken; }
/**
* <p>Token indicating where to resume retrieving results on the next call to this
* action. If no token is returned, these results represent the end of the
* list.</p> <note> <p>If a request has a limit that exactly matches the number of
* remaining results, a token is returned even though there are no more results to
* retrieve.</p> </note>
*/
inline void SetNextToken(const Aws::String& value) { m_nextToken = value; }
/**
* <p>Token indicating where to resume retrieving results on the next call to this
* action. If no token is returned, these results represent the end of the
* list.</p> <note> <p>If a request has a limit that exactly matches the number of
* remaining results, a token is returned even though there are no more results to
* retrieve.</p> </note>
*/
inline void SetNextToken(Aws::String&& value) { m_nextToken = value; }
/**
* <p>Token indicating where to resume retrieving results on the next call to this
* action. If no token is returned, these results represent the end of the
* list.</p> <note> <p>If a request has a limit that exactly matches the number of
* remaining results, a token is returned even though there are no more results to
* retrieve.</p> </note>
*/
inline void SetNextToken(const char* value) { m_nextToken.assign(value); }
/**
* <p>Token indicating where to resume retrieving results on the next call to this
* action. If no token is returned, these results represent the end of the
* list.</p> <note> <p>If a request has a limit that exactly matches the number of
* remaining results, a token is returned even though there are no more results to
* retrieve.</p> </note>
*/
inline ListAliasesResult& WithNextToken(const Aws::String& value) { SetNextToken(value); return *this;}
/**
* <p>Token indicating where to resume retrieving results on the next call to this
* action. If no token is returned, these results represent the end of the
* list.</p> <note> <p>If a request has a limit that exactly matches the number of
* remaining results, a token is returned even though there are no more results to
* retrieve.</p> </note>
*/
inline ListAliasesResult& WithNextToken(Aws::String&& value) { SetNextToken(value); return *this;}
/**
* <p>Token indicating where to resume retrieving results on the next call to this
* action. If no token is returned, these results represent the end of the
* list.</p> <note> <p>If a request has a limit that exactly matches the number of
* remaining results, a token is returned even though there are no more results to
* retrieve.</p> </note>
*/
inline ListAliasesResult& WithNextToken(const char* value) { SetNextToken(value); return *this;}
private:
Aws::Vector<Alias> m_aliases;
Aws::String m_nextToken;
};
} // namespace Model
} // namespace GameLift
} // namespace Aws
| [
"spacesun@naver.com"
] | spacesun@naver.com |
49fa618584c45f3d69577a02f7cbf71a96dda15b | f4db0d27a535be2270249b2b9433f23f1085e4fd | /Navi/glUtil/CTextureLoader.cpp | 74aa75ac1ca70babb156e8be71eb31de517198db | [] | no_license | jpinilloslr/navi | e2e2ac9f3a4e806f562085f602a2348d63308f90 | 8e28df64b670d395b82001f2ef577b4a26094de3 | refs/heads/master | 2021-04-27T00:08:09.902108 | 2011-12-27T03:38:27 | 2011-12-27T03:38:27 | 120,402,501 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,593 | cpp | #include "CTextureLoader.h"
// GL_EXT_texture_filter_anisotropic
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
CTextureLoader::CTextureLoader()
{
}
CTextureLoader::~CTextureLoader()
{
}
void *CTextureLoader::ReadTGA(char *filename, int *tam)
{
GLubyte TGAheader[12] = {0,0,2,0,0,0,0,0,0,0,0,0};
GLubyte TGAcompare[12];
GLubyte header[6];
GLuint bytesPerPixel;
GLuint imageSize;
GLuint temp,i;
glImage texture;
GLubyte *aux;
FILE *file;
fopen_s(&file, filename, "rb");
if (!file)
{
return NULL;
}
fread(TGAcompare, 1, sizeof(TGAcompare), file);
if (memcmp(TGAheader, TGAcompare,sizeof(TGAheader)) !=0 )
{
return NULL;
}
fread(header, 1, sizeof(header), file);
texture.width = header[1] * 256 + header[0];
texture.height = header[3] * 256 + header[2];
texture.bpp = header[4];
bytesPerPixel = texture.bpp/8;
imageSize = texture.width*texture.height*bytesPerPixel;
texture.imageData=(GLubyte *)malloc(imageSize);
if( texture.imageData==NULL || fread(texture.imageData, 1, imageSize, file) != imageSize)
{
if(texture.imageData!=NULL)
{
free(texture.imageData);
}
fclose(file);
return NULL;
}
for(i=0; i<(GLuint)(imageSize); i+=bytesPerPixel)
{
temp = texture.imageData[i];
texture.imageData[i] = texture.imageData[i + 2];
texture.imageData[i + 2] = temp;
}
fclose (file);
aux=(GLubyte *)malloc(imageSize);
for(i=0; i<texture.height; i++)
{
memcpy(&aux[imageSize-((i+1)*texture.width*4)],&texture.imageData[i*texture.width*4],texture.width*4);
}
*tam=texture.width;
free(texture.imageData);
return aux;
}
bool CTextureLoader::LoadTGA(char *filename, GLuint &Texture)
{
int nSize;
void *texture_data = (char *)ReadTGA(filename, &nSize);
if (!texture_data)
{
return FALSE;
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glGenTextures(1, &Texture);
glBindTexture(GL_TEXTURE_2D, Texture);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, nSize, nSize, GL_RGBA, GL_UNSIGNED_BYTE, texture_data);
free(texture_data);
return TRUE;
}
bool CTextureLoader::LoadTexture(char *filename, GLuint &Texture)
{
char szExt[MAX_PATH];
char *p;
maxAnisotrophy = 0;
strcpy_s(szExt, sizeof(szExt), filename);
p = szExt + strlen(filename) - 4;
for(int i=1; i<4; i++)
{
p[i] = ::tolower(p[i]);
}
if(!strcmp(p, ".tga"))
{
return LoadTGA(filename, Texture);
}
return BuildTexture(filename, Texture);
}
bool CTextureLoader::BuildTexture(char *szPathName, GLuint &texid) // Load Image And Convert To A Texture
{
HDC hdcTemp; // The DC To Hold Our Bitmap
HBITMAP hbmpTemp; // Holds The Bitmap Temporarily
IPicture *pPicture; // IPicture Interface
OLECHAR wszPath[MAX_PATH+1]; // Full Path To Picture (WCHAR)
char szPath[MAX_PATH+1]; // Full Path To Picture
long lWidth; // Width In Logical Units
long lHeight; // Height In Logical Units
long lWidthPixels; // Width In Pixels
long lHeightPixels; // Height In Pixels
GLint glMaxTexDim ; // Holds Maximum Texture Size
strcpy_s(szPath, sizeof(szPath), szPathName);
GetCurrentDirectoryA(MAX_PATH, szPath);
if (strstr(szPathName, "http://") || strstr(szPathName, ":\\"))
{
strcpy_s(szPath, sizeof(szPath), szPathName);
}
else // Otherwise... We Are Loading From A File
{
strcat_s(szPath, sizeof(szPath), "\\"); // Append "\" After The Working Directory
strcat_s(szPath, sizeof(szPath), szPathName); // Append The PathName
}
MultiByteToWideChar(CP_ACP, 0, szPath, -1, wszPath, MAX_PATH); // Convert From ASCII To Unicode
HRESULT hr = OleLoadPicturePath(wszPath, 0, 0, 0, IID_IPicture, (void**)&pPicture);
if(FAILED(hr)) // If Loading Failed
return FALSE; // Return False
hdcTemp = CreateCompatibleDC(GetDC(0)); // Create The Windows Compatible Device Context
if(!hdcTemp) // Did Creation Fail?
{
pPicture->Release(); // Decrements IPicture Reference Count
return FALSE; // Return False (Failure)
}
glMaxTexDim = 0;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glMaxTexDim); // Get Maximum Texture Size Supported
pPicture->get_Width(&lWidth); // Get IPicture Width (Convert To Pixels)
lWidthPixels = MulDiv(lWidth, GetDeviceCaps(hdcTemp, LOGPIXELSX), 2540);
pPicture->get_Height(&lHeight); // Get IPicture Height (Convert To Pixels)
lHeightPixels = MulDiv(lHeight, GetDeviceCaps(hdcTemp, LOGPIXELSY), 2540);
if(glMaxTexDim > 0)
{
// Resize Image To Closest Power Of Two
if (lWidthPixels <= glMaxTexDim) // Is Image Width Less Than Or Equal To Cards Limit
lWidthPixels = 1 << (int)floor((log((double)lWidthPixels)/log(2.0f)) + 0.5f);
else // Otherwise Set Width To "Max Power Of Two" That The Card Can Handle
lWidthPixels = glMaxTexDim;
if (lHeightPixels <= glMaxTexDim) // Is Image Height Greater Than Cards Limit
lHeightPixels = 1 << (int)floor((log((double)lHeightPixels)/log(2.0f)) + 0.5f);
else // Otherwise Set Height To "Max Power Of Two" That The Card Can Handle
lHeightPixels = glMaxTexDim;
}
// Create A Temporary Bitmap
BITMAPINFO bi = {0}; // The Type Of Bitmap We Request
DWORD *pBits = 0; // Pointer To The Bitmap Bits
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); // Set Structure Size
bi.bmiHeader.biBitCount = 32; // 32 Bit
bi.bmiHeader.biWidth = lWidthPixels; // Power Of Two Width
bi.bmiHeader.biHeight = lHeightPixels; // Make Image Top Up (Positive Y-Axis)
bi.bmiHeader.biCompression = BI_RGB; // RGB Encoding
bi.bmiHeader.biPlanes = 1; // 1 Bitplane
// Creating A Bitmap This Way Allows Us To Specify Color Depth And Gives Us Imediate Access To The Bits
hbmpTemp = CreateDIBSection(hdcTemp, &bi, DIB_RGB_COLORS, (void**)&pBits, 0, 0);
if(!hbmpTemp) // Did Creation Fail?
{
DeleteDC(hdcTemp); // Delete The Device Context
pPicture->Release(); // Decrements IPicture Reference Count
return FALSE; // Return False (Failure)
}
SelectObject(hdcTemp, hbmpTemp); // Select Handle To Our Temp DC And Our Temp Bitmap Object
// Render The IPicture On To The Bitmap
pPicture->Render(hdcTemp, 0, 0, lWidthPixels, lHeightPixels, 0, lHeight, lWidth, -lHeight, 0);
// Convert From BGR To RGB Format And Add An Alpha Value Of 255
for(long i = 0; i < lWidthPixels * lHeightPixels; i++) // Loop Through All Of The Pixels
{
BYTE* pPixel = (BYTE*)(&pBits[i]); // Grab The Current Pixel
BYTE temp = pPixel[0]; // Store 1st Color In Temp Variable (Blue)
pPixel[0] = pPixel[2]; // Move Red Value To Correct Position (1st)
pPixel[2] = temp; // Move Temp Value To Correct Blue Position (3rd)
// This Will Make Any Black Pixels, Completely Transparent (You Can Hardcode The Value If You Wish)
/*if ((pPixel[0]==0) && (pPixel[1]==0) && (pPixel[2]==0)) // Is Pixel Completely Black
pPixel[3] = 0; // Set The Alpha Value To 0
else */ // Otherwise
pPixel[3] = 255; // Set The Alpha Value To 255
}
glGenTextures(1, &texid); // Create The Texture
// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, texid); // Bind To The Texture ID
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // (Modify This For The Type Of Filtering You Want)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); // (Modify This For The Type Of Filtering You Want)
if (maxAnisotrophy > 1)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotrophy);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, lWidthPixels, lHeightPixels, GL_RGBA, GL_UNSIGNED_BYTE, pBits);
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, lWidthPixels, lHeightPixels, 0, GL_RGBA, GL_UNSIGNED_BYTE, pBits);
DeleteObject(hbmpTemp); // Delete The Object
DeleteDC(hdcTemp); // Delete The Device Context
pPicture->Release(); // Decrements IPicture Reference Count
return TRUE; // Return True (All Good)
}
| [
"jpinilloslr@gmail.com"
] | jpinilloslr@gmail.com |
db74c012ad9b27d2bbabf8e336ad5b4dac3d0dbc | c15f70c2e3f2a57debd14e4d8a9d40d9d9ad8c35 | /Embedded/libraries/dh_controlled_types/ControlledLED.h | 2093973cc32ff65cb990ca4d73b0b94e264a877c | [] | no_license | davehummel/tredbot | b26db2ad2151ea1030f8354bee7811cc6d191d77 | d4dd6690c5f8bc75ab5e63c7c17b8a2633f63841 | refs/heads/master | 2020-04-12T07:24:15.572006 | 2017-02-20T19:14:53 | 2017-02-20T19:14:53 | 28,069,188 | 0 | 0 | null | 2015-01-13T01:22:53 | 2014-12-16T03:46:02 | Java | UTF-8 | C++ | false | false | 3,203 | h | #ifndef DH_CONTROLLEDLED_H__
#define DH_CONTROLLEDLED_H__
#include "dh_controller.h"
class ControlledLED: public Controller::Controlled{
public:
ControlledLED(){
}
void begin(void){
}
void execute(uint32_t time,uint32_t id,char command[]){
bool isPWM = true;
uint16_t temp;
switch (command[0]){
case 'B':
isPWM = false;
case 'P':{
uint8_t letter;
uint8_t pID;
if (command[4] >= 'a' && command[4] <= 'z'){
letter = command[4] - 'a';
}else if (command[4] >= 'A' && command[4] <= 'Z'){
letter = command[4] - 'A';
} else {
controller->getErrorLogger()->println("PWM/Bin must be assigned to 'a' to 'z' var.");
return;
}
temp = 6;
if (!Controller::parse_uint8(pID,temp,command)){
controller->getErrorLogger()->println("PWM/Bin must be set to a pin");
return;
}
pinID[letter] = pID;
pinVal[letter] = 0;
pinPWM[letter] = isPWM;
if (pID!=0){
pinMode(pID,OUTPUT);
if (isPWM)
analogWrite(pID,0);
else
digitalWrite(pID,LOW);
}
break;}
case 'F':{
uint8_t pin;
uint32_t sampleRate;
temp = 4;
if (!Controller::parse_uint8(pin,temp,command)){
controller->getErrorLogger()->println("FRQ must be set to a number.");
return;
}
temp++;
if (!Controller::parse_uint32(sampleRate,temp,command)){
controller->getErrorLogger()->println("FRQ must be set to a number.");
return;
}
setFreq(pin,sampleRate);
break;}
case 'R':{
uint8_t resolution;
temp = 4;
if (!Controller::parse_uint8(resolution,temp,command)){
controller->getErrorLogger()->println("RES must be set to a number.");
return;
}
if (resolution<2)
resolution = 2;
if (resolution>16)
resolution = 16;
analogWriteResolution(resolution);
break;}
default:
controller->getErrorLogger()->print("Bad ControlledLED command:");
controller->getErrorLogger()->println(command);
}
}
void startSchedule(char command[], uint32_t id){
}
void endSchedule(char command[], uint32_t id){
}
uint8_t readB(ADDR1 addr,uint8_t addr2){
return pinVal[addr.addr%26];
}
uint16_t readU(ADDR1 addr,uint8_t addr2){
return pinVal[addr.addr%26];
}
uint32_t readT(ADDR1 addr,uint8_t addr2){
return pinVal[addr.addr%26];
}
void write(ADDR1 addr,uint8_t val){
uint8_t letter = addr.addr%26;
if (pinID[letter] == 0)
return;
if (pinPWM[letter]) {
analogWrite(pinID[letter],pinVal[letter]=val);
}else{
digitalWrite(pinID[letter],(pinVal[letter]=(val!=0)));
}
}
void write(ADDR1 addr,uint16_t val){
uint8_t letter = addr.addr%26;
if (pinID[letter] == 0)
return;
if (pinPWM[letter]) {
analogWrite(pinID[letter],pinVal[letter]=val);
}else{
digitalWrite(pinID[letter],(pinVal[letter]=(val!=0)));
Serial.println(pinVal[letter]);
}
}
private:
void setFreq(uint8_t pin,uint32_t freq){
if (pin == 0){
analogWriteFrequency(5, freq);
analogWriteFrequency(3, freq);
analogWriteFrequency(25, freq);
} else {
analogWriteFrequency(pin, freq);
}
}
uint8_t pinID[26] = {0};
uint32_t pinVal[26] = {0};
bool pinPWM[26] = {false};
};
#endif
| [
"dmhummel@gmail.com"
] | dmhummel@gmail.com |
c0fcb440f925083ae5e85fecc2f2a05b9453ca8e | 5b617ac80e9f18b8243a867baaae82deae9b7e23 | /movement.hpp | d26b6b8009dccf260ec9077a5a5204c5aba3d1c2 | [] | no_license | adil-olin/Falcon-6T---Kinght | e7a7592d068f05877d1987320859f9d750faaa86 | b3bde9094f3d966a9c7e89c23a5e95f8ab452fc4 | refs/heads/main | 2023-05-31T11:11:05.866257 | 2021-06-26T15:16:14 | 2021-06-26T15:16:14 | 380,530,688 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,590 | hpp | #pragma once
#ifndef movement_hpp
#define movement_hpp
#include <SDL2/SDL.h>
#include<SDL2/SDL_image.h>
#include<SDL2/SDL_mixer.h>
#include<bits/stdc++.h>
using namespace std;
static void spawnenemy(void)
{
if(--enemyspawntimer<=0)
{
Entity temp_enemy;
memset(&temp_enemy,0,sizeof(Entity));
temp_enemy.side=SIDE_ALIEN;
temp_enemy.health=1+5*level;
temp_enemy.w=80;
temp_enemy.h=77;
temp_enemy.y=0;
temp_enemy.x= rand() % SCREEN_WIDTH;
temp_enemy.texture = enemyTexture;
//SDL_QueryTexture(temp_enemy.texture, NULL, NULL, &temp_enemy.x, temp_enemy.y);
temp_enemy.dy = (2 + (rand() % 4));
temp_enemy.dx = 0;
enemyspawntimer = 100-level + (rand() % 60);
temp_enemy.reload = FPS-level;
stage.Fighter.push_back(temp_enemy);
}
}
//stage.Fighter[0] is same as player id. So, we have to update them both to keep them same
static void fireBullet(void)
{
Entity temp_bullet;
memset(&temp_bullet,0,sizeof(Entity));
temp_bullet.side=SIDE_PLAYER;
temp_bullet.x = player.x;
temp_bullet.y = player.y;
temp_bullet.w=30;
temp_bullet.h=53;
temp_bullet.x += (player.w / 2) - (temp_bullet.w / 2);
temp_bullet.y -= temp_bullet.h;
temp_bullet.health=10+level*10;
temp_bullet.dx=0;
temp_bullet.dy= - PLAYER_BULLET_SPEED;
temp_bullet.texture = bulletTexture;
stage.Bullet.push_back(temp_bullet);
player.reload=8;
stage.Fighter[0].reload=8;
}
void movePlayer()
{
if(!isplayernull)
{
player.dx = player.dy = 0;
stage.Fighter[0].dx = stage.Fighter[0].dy=0;
if (player.reload > 0)
{
player.reload--;
stage.Fighter[0].reload--;
}
if (app.keyboard[SDL_SCANCODE_UP])
{
player.dy = -PLAYER_SPEED;
stage.Fighter[0].dy = -PLAYER_SPEED;
}
if (app.keyboard[SDL_SCANCODE_DOWN])
{
player.dy = PLAYER_SPEED;
stage.Fighter[0].dy = PLAYER_SPEED;
}
if (app.keyboard[SDL_SCANCODE_LEFT])
{
player.dx = -PLAYER_SPEED;
stage.Fighter[0].dx = -PLAYER_SPEED;
}
if (app.keyboard[SDL_SCANCODE_RIGHT])
{
player.dx = PLAYER_SPEED;
stage.Fighter[0].dx = PLAYER_SPEED;
}
if((app.keyboard[SDL_SCANCODE_LSHIFT] || app.keyboard[SDL_SCANCODE_RSHIFT]))
{
player.dx*=1.5;
player.dy*=1.5;
stage.Fighter[0].dy*=1.5;
stage.Fighter[0].dx*=1.5;
}
if (player.reload == 0)
{
if(!(app.keyboard[SDL_SCANCODE_LSHIFT] || app.keyboard[SDL_SCANCODE_RSHIFT]))
{
fireBullet();
}
}
player.x += player.dx;
player.y += player.dy;
stage.Fighter[0].x+=stage.Fighter[0].dx;
stage.Fighter[0].y+=stage.Fighter[0].dy;
//checking so that player don't go outside of the screen
if(player.x<0)
{
player.x=0;
stage.Fighter[0].x=0;
}
if(player.x>SCREEN_WIDTH-player.w)
{
player.x=SCREEN_WIDTH-player.w;
stage.Fighter[0].x = SCREEN_WIDTH-player.w;
}
if(player.y<0)
{
player.y=0;
stage.Fighter[0].y=0;
}
if(player.y>SCREEN_HEIGHT-player.w)
{
player.y = SCREEN_HEIGHT-player.w;
stage.Fighter[0].y = SCREEN_HEIGHT-player.w;
}
}
}
#endif
| [
"olinafseradil@gmail.com"
] | olinafseradil@gmail.com |
d3d715a9bfc478371559cb79b2ba909fd6628049 | 622a77a2fb79273fe9dec286e137503c63670402 | /SimpleDeformer.cpp | b3be4543d636b1858f394a0b9326e50d8b8588f5 | [] | no_license | tinytangent/TinyMoeFace_Qt | c976235661ec3016a1f523b9cfff6957cfddd551 | 339de99f1b1d4a31acb7c34208a8330a3ca5fb98 | refs/heads/master | 2021-06-13T03:33:26.350950 | 2017-03-05T03:02:21 | 2017-03-05T03:02:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,695 | cpp | #include <QDebug>
#include "SimpleDeformer.h"
SimpleDeformer::SimpleDeformer(CDT& triangleMesh)
:AbstractDeformer(triangleMesh)
{
}
void SimpleDeformer::updateVertices()
{
for(auto i = triangleMesh.vertices_begin(); i != triangleMesh.vertices_end(); i++)
{
Vertex_handle vertexHandle = i;
if(constrainedVertices.contains(vertexHandle))
{
modifiedVertexPos[vertexHandle] = constrainedVertices[vertexHandle];
}
else
{
modifiedVertexPos[i] = originalVertexPos[i];
/*int count = 0;
for(auto j = triangleMesh.incident_vertices(i); j != triangleMesh.vertices_end(); j++)
{
count++;
}
qDebug() << count;*/
for(auto j : constrainedVertices.keys())
{
auto deltaJ = constrainedVertices[j] - originalVertexPos[j];
auto deltaVec = originalVertexPos[j] - originalVertexPos[i];
auto dist2 = deltaVec.x() * deltaVec.x() + deltaVec.y() * deltaVec.y();
modifiedVertexPos[i] += deltaJ * 0.5 * exp(- dist2 / 1000.0);//deltaJ * exp(-dist2 / 1000.0);
}
}
/*int count = 0;
for(auto j = triangleMesh.incident_vertices(i); j != triangleMesh.vertices_end(); j++)
{
count++;
}
qDebug() << count;*/
/*Vertex_handle p = i;
if(cgalOutlinesSet.contains(p))
{
painter.setBrush(QBrush(Qt::red));
}
else
{
painter.setBrush(QBrush(Qt::yellow));
}
painter.drawEllipse(CGALUtil::toQtPointF(p->point()), 2, 2);*/
}
}
| [
"tansinan_1995@163.com"
] | tansinan_1995@163.com |
394062aafb0dd7b620729fce9b89e4234ff0217c | bba488ad3c516f5545def334cab2eea90d5220e2 | /Game_windows.cpp | e7eef3bc453e3f128f1461fd7c8e4bc1f5949430 | [] | no_license | quoji/FlipFlaps | ccc0a38dd7b4561ee2270b9de801c999f91aa7ba | 16bd592edb457b5ca5ac51493116e2c9a41abf0e | refs/heads/master | 2023-02-18T15:37:41.598752 | 2023-02-10T00:02:57 | 2023-02-10T00:02:57 | 34,549,077 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 24,563 | cpp | /*
Ruben Cardenas, Stephen Brownlee, Pedro Alvarez
Game_windows.cpp
To be used with FlipFlaps
*/
#include "std_lib_facilities_4.h"
#include "Game_windows.h"
#include "Window.h"
#include "Graph.h"
#include "GUI.h"
#include "find_solution.h"
#include "High_scores.h"
//----------------------------------------------------------------------------
using namespace Graph_lib;
auto width = 500; //size for home page buttons
auto height = 100;
auto offset = 80;
int diff_width = 80; //difficulty button sizes
int diff_height = 50;
int num_flips = 0; //player's flip count
int score = 0, num_arranged = 0; //score tracking
string player_name = ""; //stores initials
fstream scores; //high score stream
//----------------------------------------------------------------------------
Color brown_trim(fl_rgb_color(255, 222, 176));
Color dark_brown(fl_rgb_color(176,102,5));
Color light_brown(fl_rgb_color(217,140,33));
//----------------------------------------------------------------------------
vector<Flip_wrapper> flip_info; //stores objects used in game loop
vector<Rectangle*> pancakes;
vector<Line*> lines;
vector<int> widths, *solution;
vector<High_scores> player_scores;
//----------------------------------------------------------------------------
Image main_screen(Point(0, 0), "FlipFlaps.jpg"); //background images
Image trophy(Point(300,150),"winner.gif");
Image defeat(Point(400,250),"defeat.gif");
//----------------------------------------------------------------------------
Rectangle background(Point(0, 0), x_max(), y_max()); //UI objects
Rectangle initials_screen_1(Point(0, 270), x_max(), 529);
Rectangle initials_screen_2(Point(0, 0), 429, y_max());
Rectangle initials_screen_3(Point(0, 0), x_max(), 219);
Rectangle initials_screen_4(Point(630, 0), 370, y_max());
Rectangle tabletop(Point(250,800-250), 500, 80);
Rectangle tableleg(Point(275,800-250), 50, 200);
Rectangle tableleg2(Point(675,800-250), 50, 200);
Text score_1(Point (400, 200), "");
Text score_2(Point(400, 275), "");
Text score_3(Point(400, 350), "");
Text score_4(Point(400, 425), "");
Text score_5(Point(400, 500), "");
Text inst_1(Point(x_max() / 2 - 300, 100), "");
Text inst_2(Point(50, 180), "");
Text inst_3(Point(50, 220), "");
Text inst_4(Point(50, 260), "");
Text inst_5(Point(50, 300), "");
Text inst_6(Point(50, 340), "");
Text inst_7(Point(50, 380), "");
Text inst_8(Point(50, 420), "");
Text no_high(Point(300, 100), "");
Text you_win_txt(Point(260, 140), "");
Text you_lose_txt(Point(400, 200), "");
Text your_score(Point(50,50), "");
Text min_needed(Point(50, 75), "");
Text flips_to_win(Point(50,100), "");
Text lvl_diff(Point(410,485), "");
Text player_initials(Point(390, 300), "");
Text username(Point(430, 200), "");
Text team_num(Point(50, 780), "");
Text high_score_title(Point(200, 100), "");
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Game_windows::Game_windows(Point xy, int w, int h, const string& title) : //create game window
Window(xy, w, h, title),
play(Point((x_max() / 2 - (width - 100) / 2), 330), width - 100, height - 30, "Play", cb_play_game),
instructions(Point((x_max() / 2 - (width - 100) / 2), 430), width - 100, height - 30, "Instructions", cb_show_inst),
highscores(Point((x_max() / 2 - (width - 100) / 2), 530), width - 100, height - 30, "Highscores", cb_show_high),
exit(Point((x_max() / 2 - (width - 100) / 2), 630), width - 100, height - 30, "Exit", cb_exit_game),
Ok(Point((x_max() / 2 - width / 2 + 75), 635), width - 150, height - 50, "Return To Menu", cb_go_back),
replay(Point(400+(x_max() / 2 - width / 2), 600), width / 2, height, "Play Again", cb_replay),
menu_button(Point((x_max() / 2 - width / 2)-100, 600), width / 2, height, "Main Menu", cb_game_go_back),
enter(Point(530, 220), 100, 50, "Enter", cb_enter_initials),
Initials(Point(430,220), 100,50, ""),
lvl_2(Point(100+offset*1,500), diff_width, diff_height, "2", cb_hard2),
lvl_3(Point(100+offset*2,500), diff_width, diff_height, "3", cb_hard3),
lvl_4(Point(100+offset*3,500), diff_width, diff_height, "4", cb_hard4),
lvl_5(Point(100+offset*4,500), diff_width, diff_height, "5", cb_hard5),
lvl_6(Point(100+offset*5,500), diff_width, diff_height, "6", cb_hard6),
lvl_7(Point(100+offset*6,500), diff_width, diff_height, "7", cb_hard7),
lvl_8(Point(100+offset*7,500), diff_width, diff_height, "8", cb_hard8),
lvl_9(Point(100+offset*8,500), diff_width, diff_height, "9", cb_hard9)
{
attach(Initials);
attach(main_screen);
attach(play); //Shows and hides all of the buttons for the main menu
attach(instructions);
attach(highscores);
attach(exit);
team_num.set_label("Team 39");
team_num.set_color(light_brown);
attach(team_num);
attach_hard_menu();
attach(enter);
detach(enter);
detach(Initials);
detach_hard_menu();
}
void Game_windows::play_game() //takes difficulty and initial inputs to prepare game
{
username.set_label("Enter Initials");
username.set_font_size(30);
player_initials.set_label("Your initials are: ");
player_initials.set_font_size(30);
lvl_diff.set_label("Select Difficulty");
lvl_diff.set_font_size(30);
detach_menu();
detach(background);
attach(Initials);
attach(enter);
initials_background();
attach(lvl_diff);
attach(player_initials);
attach(username);
attach_hard_menu();
attach(Ok);
}
void Game_windows::show_inst() //Goes to instruction page when button clicked
{
detach_menu();
detach(background);
set_background();
get_inst();
attach(Ok);
}
void Game_windows::show_high() //Goes to highscores page when button clicked
{
detach_menu();
detach(background);
set_background();
attach(Ok);
high_score_title.set_font_size(50);
high_score_title.set_label("FLIPPIN' HALL OF FAME");
attach(high_score_title);
no_high.set_label("No Highscores Yet");
no_high.set_font_size(50);
scores.open("Scores.txt", ios::in);
if (!scores.is_open())
{
make_file();
attach(no_high);
}
else
read_from_file();
}
void Game_windows::make_file()
{
scores.clear();
scores.open("Scores.txt", ios::out);
scores.close();
scores.open("Scores.txt", ios::in);
scores.close();
}
void Game_windows::read_from_file()
{
string initials;
int points, length;
initials = "";
points = 0;
scores.seekg(0, ios::end);
length = scores.tellg();
if (length == 0)
attach(no_high);
else
{
scores.seekg(0);
if (!scores.eof())
{
while (!scores.eof())
{
scores >> initials >> points;
player_scores.push_back(High_scores(initials, points));
}
sort(player_scores.begin(), player_scores.end(),
[](High_scores &sc_1, High_scores &sc_2){return sc_1.get_score() > sc_2.get_score();});
if (player_scores.size() >= 5)
set_score(5);
else
set_score(player_scores.size());
}
}
scores.close();
}
void Game_windows::write_to_file()
{
scores.open("Scores.txt", ios::app);
if (!scores.is_open())
{
make_file();
scores.open("Scores.txt");
}
if (player_name.size() != 0)
{
scores << player_name << ' ' << to_string(score);
scores.close();
}
else
scores.close();
}
void Game_windows::set_score(int num) //sends scores to high score screen
{
switch (num)
{
case 5:
score_5.set_label(get_info(4));
score_5.set_font_size(30);
attach(score_5);
case 4:
score_4.set_label(get_info(3));
score_4.set_font_size(30);
attach(score_4);
case 3:
score_3.set_label(get_info(2));
score_3.set_font_size(30);
attach(score_3);
case 2:
score_2.set_label(get_info(1));
score_2.set_font_size(30);
attach(score_2);
case 1:
score_1.set_label(get_info(0));
score_1.set_font_size(30);
attach(score_1);
}
}
string Game_windows::get_info(int which_one) //gets player name and high score
{
string player, together;
int points;
player = player_scores[which_one].get_initials();
points = player_scores[which_one].get_score();
together = player + ' ' + to_string(points);
return together;
}
void Game_windows::exit_game() //Exits the game
{
hide();
}
void Game_windows::enter_initials()
{
string three_initials;
player_name = Initials.get_string();
three_initials = player_name.substr(0, 3); //takes 3 initials
player_initials.set_label("Your initials are: " + three_initials);
Fl::redraw();
}
void Game_windows::detach_menu() //takes off the menu buttons
{
detach(main_screen);
detach(play);
detach(instructions);
detach(highscores);
detach(exit);
}
//----------------------------------------------------------------------------
void Game_windows::cb_play_game(Address, Address pw) //Callbacks for FLTK
{
reference_to<Game_windows>(pw).redraw();
reference_to<Game_windows>(pw).play_game();
}
void Game_windows::cb_show_inst(Address, Address pw)
{
reference_to<Game_windows>(pw).redraw();
reference_to<Game_windows>(pw).show_inst();
}
void Game_windows::cb_show_high(Address, Address pw)
{
reference_to<Game_windows>(pw).redraw();
reference_to<Game_windows>(pw).show_high();
}
void Game_windows::cb_exit_game(Address, Address pw)
{
reference_to<Game_windows>(pw).redraw();
reference_to<Game_windows>(pw).exit_game();
}
void Game_windows::cb_enter_initials(Address, Address pw)
{
reference_to<Game_windows>(pw).redraw();
reference_to<Game_windows>(pw).enter_initials();
}
//----------------------------------------------------------------------------
void Game_windows::go_back() //goes back to the main menu
{
num_flips = 0;
detach(Ok);
detach(enter);
detach_inst();
detach_hard_menu();
detach(high_score_title);
detach(no_high);
detach(you_win_txt);
detach(you_lose_txt);
detach(lvl_diff);
detach(username);
detach(player_initials);
detach_scores();
detach_game();
detach(trophy);
detach(defeat);
detach(Initials);
detach_background();
attach(main_screen);
attach(play);
attach(instructions);
attach(highscores);
attach(exit);
attach(team_num);
}
void Game_windows::cb_go_back(Address, Address pw) //callbacks for FLTK
{
reference_to<Game_windows>(pw).redraw();
reference_to<Game_windows>(pw).go_back();
}
void Game_windows::detach_scores() //hides high score screen
{
detach(score_1);
detach(score_2);
detach(score_3);
detach(score_4);
detach(score_5);
player_scores.erase(player_scores.begin(), player_scores.end());
}
//----------------------------------------------------------------------------
void Game_windows::get_inst() //game instructions text
{
inst_1.set_label("How To Play");
inst_2.set_label("The purpose of the game is to flip an unordered stack of pancakes until they are in the ");
inst_3.set_label("correct order while trying to use the least number of flips. When you start the game, a stack of");
inst_4.set_label("unordered pancakes will appear before your eyes. Click the buttons next to the pancakes to ");
inst_5.set_label("indicate where you want to flip the stack. Once you're able to get the stack in the correct");
inst_6.set_label("order, the game will be over and your score will be displayed. However, the game will also be");
inst_7.set_label("over if you make more moves than the ones that are necessary. At this point, the game will stop,");
inst_8.set_label("and you will no longer be able to continue.");
inst_1.set_font(FL_SCREEN);
inst_2.set_font(FL_SCREEN);
inst_3.set_font(FL_SCREEN);
inst_4.set_font(FL_SCREEN);
inst_5.set_font(FL_SCREEN);
inst_6.set_font(FL_SCREEN);
inst_7.set_font(FL_SCREEN);
inst_8.set_font(FL_SCREEN);
inst_1.set_font_size(42);
inst_2.set_font_size(21);
inst_3.set_font_size(21);
inst_4.set_font_size(21);
inst_5.set_font_size(21);
inst_6.set_font_size(21);
inst_7.set_font_size(21);
inst_8.set_font_size(21);
attach(inst_1);
attach(inst_2);
attach(inst_3);
attach(inst_4);
attach(inst_5);
attach(inst_6);
attach(inst_7);
attach(inst_8);
}
void Game_windows::detach_inst() //takes off instructions when 'Ok' clicked
{
detach(inst_1);
detach(inst_2);
detach(inst_3);
detach(inst_4);
detach(inst_5);
detach(inst_6);
detach(inst_7);
detach(inst_8);
}
void Game_windows::attach_hard_menu() //attaches difficulty buttons
{
attach(lvl_2);
attach(lvl_3);
attach(lvl_4);
attach(lvl_5);
attach(lvl_6);
attach(lvl_7);
attach(lvl_8);
attach(lvl_9);
}
void Game_windows::detach_hard_menu()
{
lvl_2.hide();
lvl_3.hide();
lvl_4.hide();
lvl_5.hide();
lvl_6.hide();
lvl_7.hide();
lvl_8.hide();
lvl_9.hide();
}
//----------------------------------------------------------------------------
void Game_windows::set_background() //makes colored background
{
background.set_fill_color(Color::dark_cyan);
background.set_color(Color::black);
attach(background);
}
void Game_windows::initials_background() //used to solve flickering initial box
{
initials_screen_1.set_fill_color(Color::dark_cyan);
initials_screen_1.set_color(Color::dark_cyan);
initials_screen_2.set_fill_color(Color::dark_cyan);
initials_screen_2.set_color(Color::dark_cyan);
initials_screen_3.set_fill_color(Color::dark_cyan);
initials_screen_3.set_color(Color::dark_cyan);
initials_screen_4.set_fill_color(Color::dark_cyan);
initials_screen_4.set_color(Color::dark_cyan);
attach(initials_screen_1);
attach(initials_screen_2);
attach(initials_screen_3);
attach(initials_screen_4);
}
void Game_windows::detach_background()
{
detach(initials_screen_1);
detach(initials_screen_2);
detach(initials_screen_4);
detach(initials_screen_4);
}
//----------------------------------------------------------------------------
void Game_windows::cb_hard2(Address, Address pw) //callbacks for difficulty buttons
{
reference_to<Game_windows>(pw).redraw();
reference_to<Game_windows>(pw).set_difficulty(2);
}
void Game_windows::cb_hard3(Address, Address pw)
{
reference_to<Game_windows>(pw).redraw();
reference_to<Game_windows>(pw).set_difficulty(3);
}
void Game_windows::cb_hard4(Address, Address pw)
{
reference_to<Game_windows>(pw).redraw();
reference_to<Game_windows>(pw).set_difficulty(4);
}
void Game_windows::cb_hard5(Address, Address pw)
{
reference_to<Game_windows>(pw).redraw();
reference_to<Game_windows>(pw).set_difficulty(5);
}
void Game_windows::cb_hard6(Address, Address pw)
{
reference_to<Game_windows>(pw).redraw();
reference_to<Game_windows>(pw).set_difficulty(6);
}
void Game_windows::cb_hard7(Address, Address pw)
{
reference_to<Game_windows>(pw).redraw();
reference_to<Game_windows>(pw).set_difficulty(7);
}
void Game_windows::cb_hard8(Address, Address pw)
{
reference_to<Game_windows>(pw).redraw();
reference_to<Game_windows>(pw).set_difficulty(8);
}
void Game_windows::cb_hard9(Address, Address pw)
{
reference_to<Game_windows>(pw).redraw();
reference_to<Game_windows>(pw).set_difficulty(9);
}
//----------------------------------------------------------------------------
void Game_windows::set_difficulty(int diff)
{
detach_hard_menu();
detach(username);
detach(lvl_diff);
detach(Initials);
detach(enter);
detach_background();
set_background();
int num_pancakes = diff;
run_game(diff);
}
//----------------------------------------------------------------------------
int Game_windows::run_game(int p_cakes) //makes the pancakes, starts the game
{
int pwidth, pheight, table, wscaler, pancakeY;
int flip_Y, flip_X, flip_width, flip_height;
bool lose;
wscaler = 50; //pancake width
table = 250; //bottom margin. Pancakes rest on this
pheight = 50; //height for all pancakes
flip_X = 160;
flip_width = 80;
flip_height = 50; //same as pancake height
lose = false;
handle_pancakes(p_cakes, pwidth, wscaler, pancakeY, table, pheight); //shuffles pancakes
generate_flip_buttons(p_cakes, pancakeY, table, pheight, flip_Y, //generate flip buttons
flip_X, flip_width,flip_height);
score = calculate_score(0); //set initial score
your_score.set_label("Score: "+ to_string(score));
your_score.set_font_size(20);
tableleg.set_fill_color(dark_brown); //makes a table
tableleg2.set_fill_color(dark_brown);
tabletop.set_fill_color(dark_brown);
attach(flips_to_win);
attach(min_needed);
attach(your_score);
attach(tableleg);
attach(tableleg2);
attach(tabletop);
}
void Game_windows::flip() //happens when a button is clicked
{
bool lose = false;
bool win = false;
++num_flips;
score = calculate_score(num_flips);
your_score.set_label("Score: "+ to_string(score));
handle_flip(lose); //updates pancakes and score
check_win_condition(lose, win, score);
}
void Game_windows::cb_flip(Address, Address pw)
{
reference_to<Game_windows>(pw).flip();
}
//----------------------------------------------------------------------------
int Game_windows::calculate_score(int flips)
{
int score, min_flips;
reverse(widths.begin(), widths.end());
solution = find_solution(widths);
reverse(widths.begin(), widths.end());
min_flips = solution->size();
flips_to_win.set_label("You've used " + to_string(flips) + " flip(s)");
flips_to_win.set_font_size(20);
min_needed.set_label("Can be done in " + to_string(min_flips) + " flip(s)");
min_needed.set_font_size(20);
return score = (100 - 10 * (flips - min_flips)) * 6;
}
void Game_windows::you_win() //what happens when pancakes are sorted
{
score = calculate_score(num_flips);
you_win_txt.set_label("You Win! Score: " + to_string(score));
you_win_txt.set_font_size(50);
attach(you_win_txt);
attach(replay);
attach(menu_button);
attach(trophy);
detach(tabletop);
detach(tableleg);
detach(tableleg2);
write_to_file();
num_flips = 0;
num_arranged = 0;
detach_game();
}
void Game_windows::you_lose() //what happens when player fails to sort pancakes
{
score = calculate_score(num_flips);
you_lose_txt.set_label("You Lose!");
you_lose_txt.set_font_size(50);
attach(you_lose_txt);
attach(replay);
attach(menu_button);
attach(defeat);
detach(tabletop);
detach(tableleg);
detach(tableleg2);
write_to_file();
num_flips = 0;
num_arranged = 0;
detach_game();
}
void Game_windows::detach_game() //returns to main menu, exits game
{
for (int i = 0; i < pancakes.size(); ++i)
{
Rectangle* pancake = (pancakes[i]); //dereferences all objects to detach
Rectangle& pancake_ref = (*pancake);
Button* flip_button = (flip_info[i].button_ptr);
Button& flip_ref = (*flip_button);
Line* line = lines[i];
Line& line_ref = (*line);
detach(line_ref);
detach(pancake_ref);
detach(flip_ref);
detach(your_score);
detach(flips_to_win);
detach(min_needed);
}
pancakes.erase(pancakes.begin(), pancakes.end()); //clear all arrays
flip_info.erase(flip_info.begin(), flip_info.end());
lines.erase(lines.begin(),lines.end());
widths.erase(widths.begin(), widths.end());
detach(Ok);
}
//----------------------------------------------------------------------------
void Game_windows::do_flip(int flip_id) //moves pancake positions
{
int num_to_flip = flip_id;
int midpoint = num_to_flip / 2;
int p_cakes = flip_info.size(); //how many pancakes there are
odd_flip(num_to_flip, p_cakes, midpoint);
even_flip(num_to_flip, p_cakes, midpoint);
}
void Game_windows::handle_pancakes(int p_cakes, int pwidth, int wscaler,
int pancakeY, int table, int pheight)
{
random_device rd; //used for shuffling our vector
mt19937 generator(rd()); //random generator parameter
for (int i = 1; i <= p_cakes; ++i) //our widths, which will be scaled by wscaler
widths.push_back(i);
shuffle(widths.begin(), widths.end(), generator); //shuffles our vector
for (int i = 1; i <= p_cakes; ++i)
{
pwidth = widths[i-1] * wscaler;
pancakeY = (y_max() - table) - pheight * i;
Rectangle* pancake = new Rectangle(Point(x_max() / 2 - pwidth / 2, pancakeY), pwidth, pheight);
pancake->set_fill_color(light_brown);
pancake->set_color(brown_trim);
Rectangle& pancake_ref = (*pancake);
pancakes.push_back(pancake); //send pancakes to global vector
attach(pancake_ref);
}
}
void Game_windows::generate_flip_buttons(int p_cakes, int pancakeY, int table, int pheight, int flip_Y,
int flip_X, int flip_width, int flip_height)
{
int line_width = 300 / p_cakes;
for (int i = 0; i < p_cakes; ++i)
{
pancakeY = (y_max() - table) - pheight * i;
flip_Y = pancakeY - pheight / 2;
Button* flip_button = new Button(Point(flip_X, flip_Y), flip_width, flip_height, "FLIP", cb_flip);
Button& flip_ref = (*flip_button);
flip_info.push_back({i + 1, flip_button}); //stores buttons in vector
Line* line= new Line(Point(flip_X + flip_width, flip_Y + flip_height / 2),
Point(flip_X + flip_width + line_width, flip_Y + flip_height / 2));
line->set_style(Line_style(Line_style::dash, 3));
Line& line_ref = (*line);
lines.push_back(line);
attach(line_ref);
attach(flip_ref);
}
}
void Game_windows::cb_replay(Address, Address pw) //callback for FLTK
{
reference_to<Game_windows>(pw).redraw();
reference_to<Game_windows>(pw).do_replay();
}
void Game_windows::cb_game_go_back(Address, Address pw) //callback for FLTK
{
reference_to<Game_windows>(pw).redraw();
reference_to<Game_windows>(pw).game_go_back();
}
void Game_windows::game_go_back() //for back buttons
{
score = 0;
detach(menu_button);
detach(replay);
go_back();
}
void Game_windows::do_replay() //for replay button
{
detach(replay);
detach(menu_button);
go_back();
play_game();
}
void Game_windows::odd_flip(int num_to_flip, int p_cakes, int midpoint)
{
int yposa, yposb, move, swapY;
if (num_to_flip % 2 == 1) //odd num flip
{
for (int i = 0; i < midpoint + 1; ++i) //see even flip comments
{
yposa = pancakes[p_cakes - midpoint + i - 1]->yPos();
yposb = pancakes[p_cakes - midpoint - i - 1]->yPos();
move = yposb - yposa;
pancakes[p_cakes - midpoint + i - 1]->move(0, move);
pancakes[p_cakes - midpoint - i - 1]->move(0, -move);
swapY = yposa; //assign new swapped y values
pancakes[p_cakes - midpoint + i - 1]->set_yPos(yposb);
pancakes[p_cakes - midpoint - i - 1]->set_yPos(swapY);
swap(pancakes[p_cakes - midpoint + i - 1], //swap rects in array
pancakes[p_cakes - midpoint - i - 1]);
}
Fl::redraw();
}
}
void Game_windows::even_flip(int num_to_flip, int p_cakes, int midpoint)
{
int yposa, yposb, move, swapY;
if (num_to_flip % 2 == 0) //even number flip
{
for (int i = 0; i < midpoint; ++i)
{
yposa = pancakes[p_cakes - midpoint + i]->yPos();//get y's
yposb = pancakes[p_cakes - midpoint - i - 1]->yPos();
move = yposb - yposa;
//moves the pancakes to the other's position
pancakes[p_cakes - midpoint + i]->move(0, move);
pancakes[p_cakes - midpoint - i - 1]->move(0, -move);
//assigns new swapped y values since move doesn't record
// them :(
swapY = yposa;
pancakes[p_cakes-midpoint + i]->set_yPos(yposb);
pancakes[p_cakes-midpoint - i - 1]->set_yPos(swapY);
//swaps addresses of each pancake so that they occupy
//the other's array index, used to reflect the new
//structure of pancakes in the array itself, ie
//if bot pancake is now top, its index goes [0] to [last]
//so next time we can find it when the loop does its logic
swap(pancakes[p_cakes - midpoint + i],
pancakes[p_cakes - midpoint - i - 1]);
}
Fl::redraw();//save cycles? by redrawing only once
}
}
void Game_windows::handle_flip(bool lose) //calculates flip button
{
if (!lose)
{
int flip_id, pheight, pancakeY, flip_Y, h, table;
pheight = 50;
table = 250;
pancakeY = (y_max() - table) - pheight * flip_info.size();
h = 50; //pancakes height
flip_Y = pheight + pancakeY - pheight / 2;
if (Fl::event_y() > flip_Y) //if a flip button below the first button's Y is clicked
{
int flip_id = 1 + ((Fl::event_y() - flip_Y) / h); //calculates which button clicked
do_flip(flip_id);
}
}
}
void Game_windows::check_win_condition(bool lose, bool win, int score)
{
if (!lose && !win) //check for win
{
for (int i = 0; i < widths.size() - 1; ++i) //check if game has been won
{
if (pancakes[i]->width() > pancakes[i + 1]->width())
++num_arranged;
}
if (num_arranged == widths.size() - 1)
{
win = true;
you_win();
}
else
{
num_arranged = 0;
if(score == 0 && !win)
{
you_lose();
lose = true;
}
}
}
else if (score == 0 || score < 0)
{
you_lose();
lose = true;
}
} | [
"sbrownlee90@gmail.com"
] | sbrownlee90@gmail.com |
12ebee85824bb93d8a22f2ab9276e183c87c4ec4 | d1c8b118241bfda690e99fbbc64de579f7cfed7d | /jbw/agents/reward_upper_bound.cpp | 0e44b98d70b5fda8345d8e223e7c56388a726c03 | [
"Apache-2.0"
] | permissive | framinmansour/jelly-bean-world | a3825e9729dcc3724385afb029d2fac9c43b4805 | 8afb48daf22a44c4ff19f7d0f6ed7a2c190df6b4 | refs/heads/master | 2022-08-22T01:06:05.612046 | 2020-05-24T00:27:15 | 2020-05-24T00:27:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 29,663 | cpp | #include <jbw/simulator.h>
#include <set>
#include <thread>
using namespace core;
using namespace jbw;
inline unsigned int get_distance(const unsigned int* distances,
unsigned int start_vertex, direction start_direction,
unsigned int end_vertex, direction end_direction,
unsigned int vertex_count)
{
return distances[((start_vertex * (uint_fast8_t) direction::COUNT + (uint_fast8_t) start_direction)
* vertex_count + end_vertex) * (uint_fast8_t) direction::COUNT + (uint_fast8_t) end_direction];
}
inline unsigned int* get_row(unsigned int* distances,
unsigned int start_vertex, direction start_direction,
unsigned int vertex_count)
{
return &distances[((start_vertex * (uint_fast8_t) direction::COUNT + (uint_fast8_t) start_direction) * vertex_count) * (uint_fast8_t) direction::COUNT];
}
struct fixed_length_shortest_path_state
{
unsigned int vertex_id;
direction dir;
unsigned int distance;
unsigned int length;
struct less_than {
inline bool operator () (const fixed_length_shortest_path_state left, const fixed_length_shortest_path_state right) {
return left.distance < right.distance;
}
};
};
unsigned int fixed_length_shortest_path(
unsigned int start_vertex, direction start_direction,
unsigned int end_vertex, direction end_direction,
const unsigned int* distances, unsigned int vertex_count,
const unsigned int k, const unsigned int* disallowed_vertices,
const unsigned int disallowed_vertex_count)
{
unsigned int state_count = vertex_count * (k + 1) * (uint_fast8_t) direction::COUNT;
unsigned int* smallest_costs = (unsigned int*) malloc(sizeof(unsigned int) * state_count);
for (unsigned int i = 0; i < state_count; i++)
smallest_costs[i] = UINT_MAX;
std::multiset<fixed_length_shortest_path_state, fixed_length_shortest_path_state::less_than> queue;
fixed_length_shortest_path_state initial_state;
initial_state.vertex_id = start_vertex;
initial_state.dir = start_direction;
initial_state.distance = 1; /* we want to include the cost of moving into this region from the previous region */
initial_state.length = 0;
smallest_costs[(initial_state.vertex_id * (k + 1) + initial_state.length) * (uint_fast8_t) direction::COUNT + (uint_fast8_t) initial_state.dir] = initial_state.distance;
queue.insert(initial_state);
unsigned int shortest_distance = UINT_MAX;
while (!queue.empty()) {
auto first = queue.cbegin();
fixed_length_shortest_path_state state = *first;
queue.erase(first);
if (state.vertex_id == end_vertex) {
if (state.length != k)
fprintf(stderr, "fixed_length_shortest_path WARNING: Completed path does not have length `k`.\n");
if (state.dir != end_direction)
fprintf(stderr, "fixed_length_shortest_path WARNING: Completed path does not have direction `end_direction` in the last state.\n");
shortest_distance = state.distance;
break;
}
if (state.length == k - 1) {
/* we need the next vertex to be the `end_vertex` */
unsigned int new_distance = state.distance + get_distance(distances, state.vertex_id, state.dir, end_vertex, end_direction, vertex_count);
if (new_distance < smallest_costs[(end_vertex * (k + 1) + k) * (uint_fast8_t) direction::COUNT + (uint_fast8_t) end_direction]) {
smallest_costs[(end_vertex * (k + 1) + k) * (uint_fast8_t) direction::COUNT + (uint_fast8_t) end_direction] = new_distance;
fixed_length_shortest_path_state new_state;
new_state.vertex_id = end_vertex;
new_state.dir = end_direction;
new_state.length = state.length + 1;
new_state.distance = new_distance;
queue.insert(new_state);
}
} else if (state.length >= k) {
fprintf(stderr, "fixed_length_shortest_path WARNING: This path has length at least `k`.\n");
} else {
for (unsigned int i = 0; i < vertex_count; i++) {
if (i == start_vertex || i == end_vertex || i == state.vertex_id) continue;
if (index_of(i, disallowed_vertices, disallowed_vertex_count) < disallowed_vertex_count) continue;
for (uint_fast8_t d = 0; d < (uint_fast8_t) direction::COUNT; d++) {
direction dir = (direction) d;
unsigned int new_distance = state.distance + get_distance(distances, state.vertex_id, state.dir, i, dir, vertex_count);
if (new_distance < smallest_costs[(i * (k + 1) + state.length + 1) * (uint_fast8_t) direction::COUNT + d]) {
smallest_costs[(i * (k + 1) + state.length + 1) * (uint_fast8_t) direction::COUNT + d] = new_distance;
fixed_length_shortest_path_state new_state;
new_state.vertex_id = i;
new_state.dir = dir;
new_state.length = state.length + 1;
new_state.distance = new_distance;
queue.insert(new_state);
}
}
}
}
}
free(smallest_costs);
return shortest_distance;
}
struct optimal_path_state
{
unsigned int vertex_id;
direction dir;
unsigned int distance;
float priority;
optimal_path_state* prev;
unsigned int reference_count;
static inline void free(optimal_path_state& state) {
state.reference_count--;
if (state.reference_count == 0 && state.prev != nullptr) {
core::free(*state.prev);
if (state.prev->reference_count == 0)
core::free(state.prev);
}
}
struct less_than {
inline bool operator () (const optimal_path_state* left, const optimal_path_state* right) {
return left->priority < right->priority;
}
};
};
inline float upper_bound(
const unsigned int* distances,
const unsigned int vertex_count,
const unsigned int end_vertex_id,
const direction end_direction,
const optimal_path_state& new_state,
const unsigned int* remaining_vertices,
const unsigned int remaining_vertex_count,
unsigned int* visited_vertices,
unsigned int visited_vertex_count)
{
float best_reward_rate = (float) (visited_vertex_count + 1 - 2) / new_state.distance;
if (new_state.vertex_id == end_vertex_id) return best_reward_rate;
for (unsigned int k = 1; k < remaining_vertex_count; k++) {
unsigned int distance = fixed_length_shortest_path(new_state.vertex_id, new_state.dir,
end_vertex_id, end_direction, distances, vertex_count, k + 1, visited_vertices, visited_vertex_count);
float reward_rate = (float) (visited_vertex_count + k + 1 - 2) / (new_state.distance + distance);
if (reward_rate > best_reward_rate)
best_reward_rate = reward_rate;
}
return best_reward_rate;
}
optimal_path_state* find_optimal_path(
const unsigned int* distances, unsigned int vertex_count,
unsigned int start_vertex_id, direction start_direction,
unsigned int end_vertex_id, direction end_direction)
{
std::multiset<optimal_path_state*, optimal_path_state::less_than> queue;
optimal_path_state* initial_state = (optimal_path_state*) malloc(sizeof(optimal_path_state));
initial_state->vertex_id = start_vertex_id;
initial_state->dir = start_direction;
initial_state->distance = 1; /* we want to include the cost of moving into this region from the previous region */
unsigned int distance_to_target = get_distance(distances, start_vertex_id, start_direction, end_vertex_id, end_direction, vertex_count);
initial_state->priority = (float) (vertex_count - 2) / (initial_state->distance + distance_to_target);
initial_state->prev = nullptr;
initial_state->reference_count = 1;
queue.insert(initial_state);
unsigned int visited_vertex_count = 0, remaining_vertex_count = 0;
unsigned int* visited_vertices = (unsigned int*) malloc(sizeof(unsigned int) * vertex_count);
unsigned int* remaining_vertices = (unsigned int*) malloc(sizeof(unsigned int) * vertex_count);
unsigned int* vertex_ids = (unsigned int*) malloc(sizeof(unsigned int) * vertex_count);
for (unsigned int i = 0; i < vertex_count; i++)
vertex_ids[i] = i;
float best_score = -1.0f;
optimal_path_state* best_path = nullptr;
float last_priority = std::numeric_limits<float>::max();
while (!queue.empty()) {
auto last = queue.cend(); last--;
optimal_path_state* state = *last;
if (state->priority <= best_score) {
/* the search priority is at most the best score, so we have found the optimum */
break;
}
queue.erase(last);
if (state->priority > last_priority)
fprintf(stderr, "parse WARNING: Search is not monotonic.\n");
visited_vertex_count = 0;
remaining_vertex_count = 0;
optimal_path_state* curr = state;
while (curr != nullptr) {
visited_vertices[visited_vertex_count++] = curr->vertex_id;
curr = curr->prev;
}
insertion_sort(visited_vertices, visited_vertex_count);
set_subtract(remaining_vertices, remaining_vertex_count,
vertex_ids, vertex_count, visited_vertices, visited_vertex_count);
/* check if we reached the `end_vertex_id` */
if (state->vertex_id == end_vertex_id && state->dir == end_direction) {
/* we reached `end_vertex_id`, so we can stop the search */
float score = (double) (visited_vertex_count - 2) / state->distance;
if (score > best_score) {
if (best_path != nullptr) {
free(*best_path);
if (best_path->reference_count == 0)
free(best_path);
}
best_path = state;
best_path->reference_count++;
best_score = score;
}
} else {
for (unsigned int i = 0; i < remaining_vertex_count; i++) {
unsigned int next_vertex = remaining_vertices[i];
for (uint_fast8_t d = (uint_fast8_t) direction::UP; d < (uint_fast8_t) direction::COUNT; d++) {
direction dir = (direction) d;
if (next_vertex == end_vertex_id && dir != end_direction) continue;
unsigned int next_distance = get_distance(distances, state->vertex_id, state->dir, next_vertex, dir, vertex_count);
if (next_distance == UINT_MAX) continue;
optimal_path_state* new_state = (optimal_path_state*) malloc(sizeof(optimal_path_state));
new_state->vertex_id = next_vertex;
new_state->dir = dir;
new_state->distance = state->distance + next_distance;
//unsigned int distance_to_target = get_distance(distances, next_vertex, dir, end_vertex_id, end_direction, vertex_count);
//new_state->priority = (float) (visited_vertex_count + remaining_vertex_count - 2) / (new_state->distance + distance_to_target);
new_state->priority = upper_bound(distances, vertex_count, end_vertex_id, end_direction,
*new_state, remaining_vertices, remaining_vertex_count, visited_vertices, visited_vertex_count);
new_state->prev = state;
new_state->reference_count = 1;
++state->reference_count;
queue.insert(new_state);
}
}
}
/* remove states from the queue with strictly worse bound than the best score we have so far */
/*while (!queue.empty()) {
auto first = queue.cbegin();
optimal_path_state* state = *first;
if (state->priority >= best_score)
break;
queue.erase(first);
free(*state);
if (state->reference_count == 0)
free(state);
}*/
free(*state);
if (state->reference_count == 0)
free(state);
}
for (auto state : queue) {
free(*state);
if (state->reference_count == 0)
free(state);
}
free(visited_vertices);
free(remaining_vertices);
free(vertex_ids);
return best_path;
}
struct shortest_path_state
{
unsigned int cost;
unsigned int x, y;
direction dir;
struct less_than {
inline bool operator () (const shortest_path_state left, const shortest_path_state right) {
return left.cost < right.cost;
}
};
};
inline void move_forward(
unsigned int x, unsigned int y, direction dir,
unsigned int max_x, unsigned int max_y,
unsigned int& new_x, unsigned int& new_y)
{
new_x = x;
new_y = y;
if (dir == direction::UP) {
++new_y;
if (new_y > max_y) new_y = UINT_MAX;
} else if (dir == direction::DOWN) {
if (new_y == 0) new_y = UINT_MAX;
else --new_y;
} else if (dir == direction::LEFT) {
if (new_x == 0) new_x = UINT_MAX;
else --new_x;
} else if (dir == direction::RIGHT) {
++new_x;
if (new_x > max_x) new_x = UINT_MAX;
}
}
inline direction turn_left(direction dir) {
if (dir == direction::UP) return direction::LEFT;
else if (dir == direction::DOWN) return direction::RIGHT;
else if (dir == direction::LEFT) return direction::DOWN;
else if (dir == direction::RIGHT) return direction::UP;
fprintf(stderr, "turn_left: Unrecognized direction.\n");
exit(EXIT_FAILURE);
}
inline direction turn_right(direction dir) {
if (dir == direction::UP) return direction::RIGHT;
else if (dir == direction::DOWN) return direction::LEFT;
else if (dir == direction::LEFT) return direction::UP;
else if (dir == direction::RIGHT) return direction::DOWN;
fprintf(stderr, "turn_right: Unrecognized direction.\n");
exit(EXIT_FAILURE);
}
void compute_shortest_distances(
unsigned int start_x, unsigned int start_y,
direction start_direction,
unsigned int max_x, unsigned int max_y,
const array<position>& goals,
const array<position>& walls,
unsigned int* shortest_distances)
{
unsigned int state_count = (max_y + 1) * (max_x + 1) * (uint_fast8_t) direction::COUNT;
unsigned int* smallest_costs = (unsigned int*) malloc(sizeof(unsigned int) * state_count);
for (unsigned int i = 0; i < state_count; i++)
smallest_costs[i] = UINT_MAX;
for (unsigned int i = 0; i < (goals.length + 1) * (uint_fast8_t) direction::COUNT; i++)
shortest_distances[i] = UINT_MAX;
std::multiset<shortest_path_state, shortest_path_state::less_than> queue;
shortest_path_state initial_state;
initial_state.cost = 0;
initial_state.x = start_x;
initial_state.y = start_y;
initial_state.dir = start_direction;
smallest_costs[(start_x * (max_y + 1) + start_y) * (uint_fast8_t) direction::COUNT + (uint_fast8_t) start_direction] = 0;
queue.insert(initial_state);
while (!queue.empty()) {
auto first = queue.cbegin();
shortest_path_state state = *first;
queue.erase(first);
/* check if we found a jellybean */
unsigned int goal_index = goals.index_of({state.x, state.y});
if (goal_index < goals.length) {
/* we found a jellybean */
shortest_distances[goal_index * (uint_fast8_t) direction::COUNT + (uint_fast8_t) state.dir] = state.cost;
} if (state.y == max_y) {
/* we reached the top row */
shortest_distances[goals.length * (uint_fast8_t) direction::COUNT + (uint_fast8_t) state.dir] =
min(shortest_distances[goals.length * (uint_fast8_t) direction::COUNT + (uint_fast8_t) state.dir], state.cost);
}
/* consider moving forward */
unsigned int new_x, new_y;
direction new_dir = state.dir;
move_forward(state.x, state.y, state.dir, max_x, max_y, new_x, new_y);
if (new_x != UINT_MAX && new_y != UINT_MAX) {
/* check if there is a wall in the new position */
if (!walls.contains({new_x, new_y})) {
/* there is no wall, so continue considering this movement */
unsigned int new_cost = state.cost + 1;
if (new_cost < smallest_costs[(new_x * (max_y + 1) + new_y) * (uint_fast8_t) direction::COUNT + (uint_fast8_t) new_dir]) {
smallest_costs[(new_x * (max_y + 1) + new_y) * (uint_fast8_t) direction::COUNT + (uint_fast8_t) new_dir] = new_cost;
shortest_path_state new_state;
new_state.cost = new_cost;
new_state.x = new_x;
new_state.y = new_y;
new_state.dir = new_dir;
queue.insert(new_state);
}
}
}
/* consider turning left */
unsigned int new_cost = state.cost + 1;
new_x = state.x;
new_y = state.y;
new_dir = turn_left(state.dir);
if (new_cost < smallest_costs[(new_x * (max_y + 1) + new_y) * (uint_fast8_t) direction::COUNT + (uint_fast8_t) new_dir]) {
smallest_costs[(new_x * (max_y + 1) + new_y) * (uint_fast8_t) direction::COUNT + (uint_fast8_t) new_dir] = new_cost;
shortest_path_state new_state;
new_state.cost = new_cost;
new_state.x = new_x;
new_state.y = new_y;
new_state.dir = new_dir;
queue.insert(new_state);
}
/* consider turning right */
new_cost = state.cost + 1;
new_x = state.x;
new_y = state.y;
new_dir = turn_right(state.dir);
if (new_cost < smallest_costs[(new_x * (max_y + 1) + new_y) * (uint_fast8_t) direction::COUNT + (uint_fast8_t) new_dir]) {
smallest_costs[(new_x * (max_y + 1) + new_y) * (uint_fast8_t) direction::COUNT + (uint_fast8_t) new_dir] = new_cost;
shortest_path_state new_state;
new_state.cost = new_cost;
new_state.x = new_x;
new_state.y = new_y;
new_state.dir = new_dir;
queue.insert(new_state);
}
}
free(smallest_costs);
}
struct empty_data {
static inline void move(const empty_data& src, empty_data& dst) { }
static inline void free(empty_data& data) { }
};
constexpr bool init(empty_data& data) { return true; }
template<typename PerPatchData, typename ItemType>
void generate_map(
map<PerPatchData, ItemType>& world,
const position& bottom_left_corner,
const position& top_right_corner)
{
/* make sure enough of the world is generated */
patch<PerPatchData>* neighborhood[4]; position patch_positions[4];
for (int64_t x = bottom_left_corner.x; x <= top_right_corner.x; x += world.n) {
for (int64_t y = bottom_left_corner.y; y <= top_right_corner.y; y += world.n)
world.get_fixed_neighborhood(position(x, y), neighborhood, patch_positions);
world.get_fixed_neighborhood(position(x, top_right_corner.y), neighborhood, patch_positions);
}
for (int64_t y = bottom_left_corner.y; y <= top_right_corner.y; y += world.n)
world.get_fixed_neighborhood(position(top_right_corner.x, y), neighborhood, patch_positions);
world.get_fixed_neighborhood(top_right_corner, neighborhood, patch_positions);
}
inline void set_interaction_args(
item_properties* item_types, unsigned int first_item_type,
unsigned int second_item_type, interaction_function interaction,
std::initializer_list<float> args)
{
item_types[first_item_type].interaction_fns[second_item_type].fn = interaction;
item_types[first_item_type].interaction_fns[second_item_type].arg_count = (unsigned int) args.size();
item_types[first_item_type].interaction_fns[second_item_type].args = (float*) malloc(max((size_t) 1, sizeof(float) * args.size()));
unsigned int counter = 0;
for (auto i = args.begin(); i != args.end(); i++)
item_types[first_item_type].interaction_fns[second_item_type].args[counter++] = *i;
}
inline void compute_optimal_reward_rate(
const unsigned int worker_id,
const unsigned int n,
const unsigned int mcmc_iterations,
const item_properties* item_types,
const unsigned int item_type_count,
const unsigned int jellybean_index,
position bottom_left_corner,
position top_right_corner,
position agent_start_position,
std::mutex& lock, std::minstd_rand& rng,
array<float>& reward_rates)
{
lock.lock();
unsigned int seed = rng();
lock.unlock();
auto m = map<empty_data, item_properties>(n, mcmc_iterations, item_types, item_type_count, seed);
generate_map(m, bottom_left_corner, top_right_corner);
position bottom_left_patch_position, top_right_patch_position;
m.world_to_patch_coordinates(bottom_left_corner, bottom_left_patch_position);
m.world_to_patch_coordinates(top_right_corner, top_right_patch_position);
array<position> goals(64), walls(64);
apply_contiguous(m.patches, bottom_left_patch_position.y,
top_right_patch_position.y - bottom_left_patch_position.y + 1,
[&](const array_map<int64_t, patch<empty_data>>& row, int64_t y)
{
return apply_contiguous(row, bottom_left_patch_position.x,
top_right_patch_position.x - bottom_left_patch_position.x + 1,
[&](const patch<empty_data>& patch, int64_t x)
{
for (const item& i : patch.items) {
if (i.location.x >= bottom_left_corner.x && i.location.x <= top_right_corner.x
&& i.location.y >= bottom_left_corner.y && i.location.y <= top_right_corner.y)
{
if (item_types[i.item_type].blocks_movement) walls.add(i.location);
else if (i.item_type == jellybean_index) goals.add(i.location);
}
}
return true;
});
});
/* the first vertex is the agent starting position, and the last vertex is the upper row of the map region */
unsigned int* distances = (unsigned int*) malloc(sizeof(unsigned int) * (goals.length + 2) * (goals.length + 2) * (uint_fast8_t) direction::COUNT * (uint_fast8_t) direction::COUNT);
for (uint_fast8_t d = 0; d < (uint_fast8_t) direction::COUNT; d++) {
unsigned int* row = get_row(distances, 0, (direction) d, goals.length + 2);
for (uint_fast8_t e = 0; e < (uint_fast8_t) direction::COUNT; e++) {
if (e == d) {
row[e] = 0;
} else if ((direction) e == turn_left((direction) d) || (direction) e == turn_right((direction) d)) {
row[e] = 1;
} else {
row[e] = 2;
}
}
if ((direction) d != direction::UP) {
for (unsigned int i = 0; i < (goals.length + 1) * (uint_fast8_t) direction::COUNT; i++)
row[(uint_fast8_t) direction::COUNT + i] = UINT_MAX;
}
}
for (uint_fast8_t d = 0; d < (uint_fast8_t) direction::COUNT; d++) {
unsigned int* row = get_row(distances, goals.length + 1, (direction) d, goals.length + 2);
for (uint_fast8_t e = 0; e < (uint_fast8_t) direction::COUNT; e++) {
if (e == d) {
row[(goals.length + 1) * (uint_fast8_t) direction::COUNT + e] = 0;
} else if ((direction) e == turn_left((direction) d) || (direction) e == turn_right((direction) d)) {
row[(goals.length + 1) * (uint_fast8_t) direction::COUNT + e] = 1;
} else {
row[(goals.length + 1) * (uint_fast8_t) direction::COUNT + e] = 2;
}
}
if ((direction) d != direction::UP) {
for (unsigned int i = 0; i < (goals.length + 1) * (uint_fast8_t) direction::COUNT; i++)
row[i] = UINT_MAX;
}
}
compute_shortest_distances(agent_start_position.x, agent_start_position.y,
direction::UP, top_right_corner.x, top_right_corner.y, goals, walls,
distances + (uint_fast8_t) direction::COUNT);
for (unsigned int i = 0; i < goals.length; i++) {
for (uint_fast8_t d = 0; d < (uint_fast8_t) direction::COUNT; d++) {
unsigned int* row = get_row(distances, i + 1, (direction) d, goals.length + 2);
for (uint_fast8_t e = 0; e < (uint_fast8_t) direction::COUNT; e++)
row[e] = UINT_MAX; /* don't allow movement back to the agent "vertex" */
compute_shortest_distances(goals[i].x, goals[i].y,
(direction) d, top_right_corner.x, top_right_corner.y,
goals, walls, row + (uint_fast8_t) direction::COUNT);
}
}
fprintf(stderr, "[thread %u] Finding optimal path with jellybean count: %zu\n", worker_id, goals.length);
optimal_path_state* path = find_optimal_path(distances, goals.length + 2, 0, direction::UP, goals.length + 1, direction::UP);
unsigned int path_length = 0; /* in vertices, including endpoints */
optimal_path_state* curr = path;
while (curr != nullptr) {
path_length++;
curr = curr->prev;
}
lock.lock();
reward_rates.add((float) (path_length - 2) / path->distance);
float mean = 0.0f;
for (float x : reward_rates)
mean += x;
mean /= reward_rates.length;
float variance = 0.0f;
for (float x : reward_rates)
variance += (x - mean) * (x - mean);
variance /= (reward_rates.length + 1);
fprintf(stderr, "[n: %lu] Avg reward rate: %f, stddev: %f, stddev of avg: %f\n", reward_rates.length, mean, sqrt(variance), sqrt(variance / reward_rates.length));
lock.unlock();
}
int main(int argc, const char** argv)
{
static constexpr int n = 32;
static constexpr unsigned int item_type_count = 4;
static constexpr unsigned int mcmc_iterations = 4000;
static constexpr unsigned int scent_dimension = 3;
static constexpr unsigned int color_dimension = 3;
item_properties* item_types = (item_properties*) alloca(sizeof(item_properties) * item_type_count);
item_types[0].name = "banana";
item_types[0].scent = (float*) calloc(scent_dimension, sizeof(float));
item_types[0].color = (float*) calloc(color_dimension, sizeof(float));
item_types[0].required_item_counts = (unsigned int*) calloc(item_type_count, sizeof(unsigned int));
item_types[0].required_item_costs = (unsigned int*) calloc(item_type_count, sizeof(unsigned int));
item_types[0].scent[1] = 1.0f;
item_types[0].color[1] = 1.0f;
item_types[0].required_item_counts[0] = 1;
item_types[0].blocks_movement = false;
item_types[0].visual_occlusion = 0.0;
item_types[1].name = "onion";
item_types[1].scent = (float*) calloc(scent_dimension, sizeof(float));
item_types[1].color = (float*) calloc(color_dimension, sizeof(float));
item_types[1].required_item_counts = (unsigned int*) calloc(item_type_count, sizeof(unsigned int));
item_types[1].required_item_costs = (unsigned int*) calloc(item_type_count, sizeof(unsigned int));
item_types[1].scent[0] = 1.0f;
item_types[1].color[0] = 1.0f;
item_types[1].required_item_counts[1] = 1;
item_types[1].blocks_movement = false;
item_types[1].visual_occlusion = 0.0;
item_types[2].name = "jellybean";
item_types[2].scent = (float*) calloc(scent_dimension, sizeof(float));
item_types[2].color = (float*) calloc(color_dimension, sizeof(float));
item_types[2].required_item_counts = (unsigned int*) calloc(item_type_count, sizeof(unsigned int));
item_types[2].required_item_costs = (unsigned int*) calloc(item_type_count, sizeof(unsigned int));
item_types[2].scent[2] = 1.0f;
item_types[2].color[2] = 1.0f;
item_types[2].blocks_movement = false;
item_types[2].visual_occlusion = 0.0;
item_types[3].name = "wall";
item_types[3].scent = (float*) calloc(scent_dimension, sizeof(float));
item_types[3].color = (float*) calloc(color_dimension, sizeof(float));
item_types[3].required_item_counts = (unsigned int*) calloc(item_type_count, sizeof(unsigned int));
item_types[3].required_item_costs = (unsigned int*) calloc(item_type_count, sizeof(unsigned int));
item_types[3].color[0] = 0.52f;
item_types[3].color[1] = 0.22f;
item_types[3].color[2] = 0.16f;
item_types[3].required_item_counts[3] = 1;
item_types[3].blocks_movement = true;
item_types[3].visual_occlusion = 1.0f;
item_types[0].intensity_fn.fn = constant_intensity_fn;
item_types[0].intensity_fn.arg_count = 1;
item_types[0].intensity_fn.args = (float*) malloc(sizeof(float) * 1);
item_types[0].intensity_fn.args[0] = -5.3f;
item_types[0].interaction_fns = (energy_function<interaction_function>*)
malloc(sizeof(energy_function<interaction_function>) * item_type_count);
item_types[1].intensity_fn.fn = constant_intensity_fn;
item_types[1].intensity_fn.arg_count = 1;
item_types[1].intensity_fn.args = (float*) malloc(sizeof(float) * 1);
item_types[1].intensity_fn.args[0] = -5.0f;
item_types[1].interaction_fns = (energy_function<interaction_function>*)
malloc(sizeof(energy_function<interaction_function>) * item_type_count);
item_types[2].intensity_fn.fn = constant_intensity_fn;
item_types[2].intensity_fn.arg_count = 1;
item_types[2].intensity_fn.args = (float*) malloc(sizeof(float) * 1);
item_types[2].intensity_fn.args[0] = -5.3f;
item_types[2].interaction_fns = (energy_function<interaction_function>*)
malloc(sizeof(energy_function<interaction_function>) * item_type_count);
item_types[3].intensity_fn.fn = constant_intensity_fn;
item_types[3].intensity_fn.arg_count = 1;
item_types[3].intensity_fn.args = (float*) malloc(sizeof(float) * 1);
item_types[3].intensity_fn.args[0] = 0.0f;
item_types[3].interaction_fns = (energy_function<interaction_function>*)
malloc(sizeof(energy_function<interaction_function>) * item_type_count);
set_interaction_args(item_types, 0, 0, piecewise_box_interaction_fn, {10.0f, 200.0f, 0.0f, -6.0f});
set_interaction_args(item_types, 0, 1, piecewise_box_interaction_fn, {200.0f, 0.0f, -6.0f, -6.0f});
set_interaction_args(item_types, 0, 2, piecewise_box_interaction_fn, {10.0f, 200.0f, 2.0f, -100.0f});
set_interaction_args(item_types, 0, 3, zero_interaction_fn, {});
set_interaction_args(item_types, 1, 0, piecewise_box_interaction_fn, {200.0f, 0.0f, -6.0f, -6.0f});
set_interaction_args(item_types, 1, 1, zero_interaction_fn, {});
set_interaction_args(item_types, 1, 2, piecewise_box_interaction_fn, {200.0f, 0.0f, -100.0f, -100.0f});
set_interaction_args(item_types, 1, 3, zero_interaction_fn, {});
set_interaction_args(item_types, 2, 0, piecewise_box_interaction_fn, {10.0f, 200.0f, 2.0f, -100.0f});
set_interaction_args(item_types, 2, 1, piecewise_box_interaction_fn, {200.0f, 0.0f, -100.0f, -100.0f});
set_interaction_args(item_types, 2, 2, piecewise_box_interaction_fn, {10.0f, 200.0f, 0.0f, -6.0f});
set_interaction_args(item_types, 2, 3, zero_interaction_fn, {});
set_interaction_args(item_types, 3, 0, zero_interaction_fn, {});
set_interaction_args(item_types, 3, 1, zero_interaction_fn, {});
set_interaction_args(item_types, 3, 2, zero_interaction_fn, {});
set_interaction_args(item_types, 3, 3, cross_interaction_fn, {10.0f, 15.0f, 20.0f, -200.0f, -20.0f, 1.0f});
unsigned int jellybean_index = item_type_count;
for (unsigned int i = 0; i < item_type_count; i++) {
if (item_types[i].name == "jellybean") {
jellybean_index = i;
break;
}
}
if (jellybean_index == item_type_count) {
fprintf(stderr, "ERROR: There is no item named 'jellybean'.\n");
return EXIT_FAILURE;
}
position bottom_left_corner = {0, 0};
position top_right_corner = {32, 32};
position agent_start_position = {top_right_corner.x / 2, bottom_left_corner.y};
#if defined(NDEBUG)
unsigned int seed = milliseconds();
#else
unsigned int seed = 0;
#endif
std::minstd_rand rng(seed);
std::mutex lock;
array<float> reward_rates(512);
constexpr unsigned int thread_count = 32;
std::thread workers[thread_count];
for (unsigned int i = 0; i < thread_count; i++)
workers[i] = std::thread([&,i]() {
while (true) {
compute_optimal_reward_rate(i, n, mcmc_iterations, item_types, item_type_count, jellybean_index,
bottom_left_corner, top_right_corner, agent_start_position, lock, rng, reward_rates);
}
});
for (unsigned int i = 0; i < thread_count; i++) {
if (workers[i].joinable()) {
try {
workers[i].join();
} catch (...) { }
}
}
for (unsigned int i = 0; i < item_type_count; i++)
free(item_types[i], item_type_count);
return EXIT_SUCCESS;
}
| [
"abulhair.saparov@gmail.com"
] | abulhair.saparov@gmail.com |
39cd4b3e8680b9573a3ac51561fd0ff94dac387d | 4cb788cbd03e7cefccace693cebb86322f467f78 | /esp8266_sniffer/esp8266_sniffer.ino | 6ba7176156b99012d6b42437ce283147cfcfa16e | [] | no_license | michaelmalinowski/density-tracker | e9101a18c7fc10d089def60de0d0700a06cb05f9 | 7dfd6c62e4a19a2e8c6fcbe072a05c2ac18be262 | refs/heads/master | 2023-03-18T04:44:00.065745 | 2021-03-07T00:56:48 | 2021-03-07T00:56:48 | 275,963,670 | 5 | 0 | null | 2020-07-14T22:02:50 | 2020-06-30T01:16:09 | C++ | UTF-8 | C++ | false | false | 7,760 | ino | extern "C" {
#include <user_interface.h>
}
#include <Arduino.h>
#include <Wire.h>
#include <LiquidCrystal.h>
#define ON_WIFI 0 //scanning devices connected to a network or not
#define SCAN_CHANNEL 6
#define BLACKLIST_MODE_COUNTDOWN 10 //seconds to press button to enter blacklist mode
//ON_WIFI=1
#define DEVICE_TIMEOUT 5 //scanned device timeout in minutes
#define DEVICE_TIMEOUT_SCAN 1 //timeout checker in minutes
//ON_WIFI=0
#define BURST_DURATION 30 //duration of a burst in seconds
#define BURST_AVERAGE 2 // how many bursts to average over
#define SEND_DATA 0 //0 for lcd function and 1 for sending data to another board
struct frameControl {
unsigned protocol: 2;
unsigned type: 2;
unsigned subtype: 4;
unsigned toDS: 1;
unsigned fromDS: 1;
unsigned frag: 1;
unsigned retry: 1;
unsigned pwrManage: 1;
unsigned moreData: 1;
unsigned proFrame: 1;
unsigned order: 1;
};
struct rxControl {
signed rssi:8;
unsigned rate:4;
unsigned is_group:1;
unsigned:1;
unsigned sig_mode:2;
unsigned legacy_length:12;
unsigned damatch0:1;
unsigned damatch1:1;
unsigned bssidmatch0:1;
unsigned bssidmatch1:1;
unsigned MCS:7;
unsigned CWB:1;
unsigned HT_length:16;
unsigned Smoothing:1;
unsigned Not_Sounding:1;
unsigned:1;
unsigned Aggregation:1;
unsigned STBC:2;
unsigned FEC_CODING:1;
unsigned SGI:1;
unsigned rxend_state:8;
unsigned ampdu_cnt:8;
unsigned channel:4;
unsigned:12;
};
struct snifferStream {
struct rxControl rx_control;
uint8_t buf[112];
uint16_t count;
uint16_t length;
};
struct device {
uint8_t mac[6];
unsigned long last_seen;
};
struct deviceList {
device list[200];
uint8_t len = 0;
};
static deviceList device_list;
static deviceList black_list;
uint8_t bursts[BURST_AVERAGE];
uint8_t burst_number = 0;
uint8_t previous_burst_total = 0;
static unsigned long current_time;
static unsigned long clear_time;
const char MAC_FORMAT[] = "%02X:%02X:%02X:%02X:%02X:%02X\n";
bool mode = false;
LiquidCrystal lcd(2,0,4,5,13,12);
//checks if mac address is within the list and return the mac address if it isnt
//prints rssi and channel from rxControl to serial
void printRxControl(rxControl data){
Serial.printf("rssi: %d\n", data.rssi);
Serial.printf("channel: %d\n", data.channel);
}
//Keeps the device in blacklist mode until a button press changes the mode
void blacklistMode(){
bool buttonPressed = false;
wifi_init();
while(mode){
lcd.setCursor(0,1);
buttonPressed = (digitalRead(15) == HIGH);
delay(100);
if (buttonPressed) {
mode = false;
lcd.clear();
lcd.print("Exited");
delay(500);
break;
}
lcd.print(black_list.len);
lcd.print(" ");
}
}
//prints three mac addresses to serial
void printMacAddresses(char* mac1, char* mac2, char* mac3){
Serial.printf("Receiver: ");
Serial.printf(MAC_FORMAT, mac1[0], mac1[1], mac1[2], mac1[3], mac1[4], mac1[5]);
Serial.printf("Sender: ");
Serial.printf(MAC_FORMAT, mac2[0], mac2[1], mac2[2], mac2[3], mac2[4], mac2[5]);
Serial.printf("Filter: ");
Serial.printf(MAC_FORMAT, mac3[0], mac3[1], mac3[2], mac3[3], mac3[4], mac3[5]);
}
//saves a mac address to a deviceList
void saveMacAddress(uint8_t* mac, deviceList* devices, rxControl data, bool print=false){
uint8_t i;
if (!mode) {
for (i = 0; i < devices->len; ++i){
if (memcmp(mac, devices->list[i].mac, 6) == 0) {
devices->list[i].last_seen = current_time;
return;
}
}
}
if (blacklistedDevice(mac)) {
device new_device;
memcpy(new_device.mac, mac, 6);
new_device.last_seen = current_time;
devices->list[devices->len] = new_device;
devices->len += 1;
if (print) {
Serial.printf(MAC_FORMAT, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
printRxControl(data);
}
}
return;
}
//checks if a device has expired with a deviceList
uint8_t expiredDevices(deviceList* devices=&device_list){
//Serial.printf("Expired device check\n");
uint8_t i;
uint8_t shift = 0, expired = 0;
for(i = 0; i < devices->len; ++i){
if (shift > 0) {
devices->list[i - shift] = devices->list[i];
}
if (current_time - devices->list[i].last_seen > DEVICE_TIMEOUT * 60000) {
++expired;
++shift;
}
}
devices->len -= expired;
return expired;
}
//checks if a device is in the blacklist
bool blacklistedDevice(uint8_t* mac){
uint8_t i;
for (i = 0; i < black_list.len; ++i){
if (memcmp(mac, black_list.list[i].mac, 6) == 0) {
black_list.list[i].last_seen = current_time;
return false;
}
}
return true;
}
//callback function.
//Analyzes packet data
void packetAnalyzer(uint8_t* buf, uint16_t len){
if (len == 12) {
return;
} else if (len == 128) {
uint8_t mac1[6];
uint8_t mac2[6];
uint8_t mac3[6];
snifferStream *data = (snifferStream*) buf;
frameControl *frame = (frameControl*) data->buf;
//Probe request
if (frame->type == 0 && frame->subtype == 4){
uint8_t i;
for (i = 0; i < 6; ++i) {
mac1[i] = data->buf[i + 10];
}
if (mode == 0) {
saveMacAddress(mac1, &device_list, data->rx_control);
}
//probe response
} else {
uint8_t i;
for (i = 0; i < 6; ++i) {
mac1[i] = data->buf[i + 4];
}
for (i = 0; i < 6; ++i) {
mac2[i] = data->buf[i + 10];
}
for (i = 0; i < 6; ++i) {
mac3[i] = data->buf[i + 16];
}
}
if (mode) {
saveMacAddress(mac1, &black_list, data->rx_control);
}
}
}
//formats device mac address into a single uint8_t array
void formatDevices(uint8_t* deviceArray){
uint8_t i, k, indexPoint;
for (i = 0; i < device_list.len; ++i) {
indexPoint = i * 6;
for (k = 0; k < 6; ++k) {
deviceArray[indexPoint + k] = device_list.list[i].mac[k];
}
}
}
//prints num to an lcd
void printDevices(uint8_t num){
lcd.clear();
lcd.print("Active Devices:");
lcd.setCursor(0,1);
lcd.print(num);
delay(250);
}
//prints num to serial
void sendDevices(uint8_t num){
if(Serial.available() > 0){
char incomingData = Serial.read();
if (incomingData == '1') {
Serial.printf("%d", num);
}
}
}
//transmits device number data
void transmitData(uint8_t num, uint8_t type=SEND_DATA){
if (type) {
sendDevices(num);
} else {
printDevices(num);
}
}
//wifi initilatization function
void wifi_init(){
wifi_set_opmode(STATION_MODE);
wifi_set_channel(SCAN_CHANNEL);
wifi_set_promiscuous_rx_cb(packetAnalyzer);
delay(100);
wifi_promiscuous_enable(1);
}
void setup(){
Serial.begin(115200);
delay(100);
//LCD INIT
lcd.begin(16, 2);
lcd.print("Scanner Screen");
delay(250);
lcd.clear();
//WIFI
lcd.print("BlackList Mode?");
current_time = millis();
bool buttonPressed = false;
while(BLACKLIST_MODE_COUNTDOWN > (current_time/1000)){
current_time = millis();
lcd.setCursor(0,1);
lcd.print((long)floor((BLACKLIST_MODE_COUNTDOWN - (current_time/1000))));
lcd.print(" ");
buttonPressed = digitalRead(15);
if (buttonPressed) {
lcd.clear();
lcd.print("BlackListed:");
mode = true;
break;
}
yield();
}
blacklistMode();
lcd.clear();
lcd.print("Scanner Started");
clear_time = current_time;
}
void loop(){
yield();
current_time = millis();
if (current_time - clear_time > DEVICE_TIMEOUT_SCAN * 60000 && ON_WIFI) {
clear_time = current_time;
expiredDevices();
transmitData(device_list.len);
}
if (ON_WIFI == 0) {
if (current_time - clear_time > BURST_DURATION * 1000) {
bursts[burst_number] = device_list.len;
device_list.len = 0;
++burst_number;
clear_time = current_time;
}
if (burst_number >= BURST_AVERAGE) {
burst_number = 0;
uint8_t i;
int average = 0;
for (i = 0; i < BURST_AVERAGE; ++i){
average += bursts[i];
}
previous_burst_total = (uint8_t)average/BURST_AVERAGE;
}
transmitData(previous_burst_total);
}
}
| [
"mike.m7@hotmail.com"
] | mike.m7@hotmail.com |
65364429d9745dbd93ba74a5ea13f638d8e0c2fd | 2a3abc8d87ad1fb24a39e320ceb0f558fa3b8eda | /Assignment 2/src/given.cpp | a5422b5b33cfb13ad2ae290cd5aacda89a2b6dd7 | [] | no_license | AnupamaRajkumar/AutomaticImageAnalysis_SoSe2020 | 89e6254cbf387b3c40544cbc701b98332df4a4fd | 4fec982f33c081558825440c7055334fa7633e7c | refs/heads/master | 2022-09-29T19:39:37.523881 | 2020-06-05T21:35:13 | 2020-06-05T21:35:13 | 258,169,037 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,026 | cpp | //
// Do not change this file.
//
#include "given.hpp"
//#include <opencv2/opencv.hpp>
void given::showImage(const cv::Mat& img, std::string win, double dur) {
// use copy for normalization
cv::Mat copy = img.clone();
if (img.channels() == 1) cv::normalize(img, copy, 0, 255, cv::NORM_MINMAX);
// create window and display image
cv::namedWindow(win, cv::WINDOW_AUTOSIZE);
cv::imshow(win, copy);
// wait
if (dur >= 0) cv::waitKey(dur);
}
void given::colorImage(const cv::Mat& img, cv::Mat& out, const cv::Mat& region, const cv::Vec3b& color) {
// copy image and duplicate channel if gray scale
if (img.channels() == 1) {
std::vector<cv::Mat> tmp{img, img, img};
cv::merge(tmp, out);
} else if (!(&img == &out)) {
cv::Mat out = img.clone();
}
// color
for (int i = 0; i < region.rows; i++)
out.at<cv::Vec3b>(region.at<cv::Vec2i>(i)[1], region.at<cv::Vec2i>(i)[0]) = color;
}
cv::Vec3b given::getColor(int id) {
// in BGR
std::vector<cv::Vec3b> colors{
cv::Vec3b(255, 0, 0), //Blue
cv::Vec3b(0, 255, 0), //Green
cv::Vec3b(0, 255, 255), //Yellow
cv::Vec3b(255, 0, 255), //Magenta
cv::Vec3b(128, 128, 255), //Pink
cv::Vec3b(128, 128, 128), //Gray
cv::Vec3b(0, 0, 128), //Brown
cv::Vec3b(0, 128, 255), //Orange
};
if (id >= colors.size()) {
std::cout << "Well, this is embarrassing but we ran out of colors." << std::endl;
exit(-1);
}
return colors.at(id);
}
void given::plotFourierDescriptor(const cv::Mat& fd, std::string win, double dur) {
// get pixel coordinates from fourier descriptor
cv::Mat coor = cv::Mat(fd.rows, 1, CV_32FC2);
if (fd.channels() == 1) {
cv::Mat phase = cv::Mat::zeros(fd.rows, 1, CV_32FC1);
std::vector<cv::Mat> channels;
channels.push_back(cv::Mat(fd.rows, 1, CV_32FC1));
channels.push_back(cv::Mat(fd.rows, 1, CV_32FC1));
polarToCart(fd, phase, channels[0], channels[1]);
merge(channels, coor);
} else {
fd.copyTo(coor);
}
dft(coor, coor, cv::DFT_INVERSE + cv::DFT_SCALE);
std::vector<cv::Mat> cart;
split(coor, cart);
// transform coordinates in order that no negative coordinates remain
double minx, miny, maxx, maxy;
minMaxLoc(cart[0], &minx, &maxx);
minMaxLoc(cart[1], &miny, &maxy);
double scale = 100. / cv::max(maxx - minx, maxy - miny);
// create image for displaying
cv::Mat tempDisplay = cv::Mat::zeros((maxy - miny) * scale + 1, (maxx - minx) * scale + 1, CV_8UC3);
// set pixel values
for (int i = 0; i < coor.rows; i++) {
tempDisplay.at<cv::Vec3b>((cart[1].at<float>(0, i) - miny) * scale, (cart[0].at<float>(0, i) - minx) * scale) = cv::Vec3b(255, 255, 255);
}
// display
cv::namedWindow(win.c_str(), cv::WINDOW_AUTOSIZE);
cv::imshow(win.c_str(), tempDisplay);
// wait
if (dur >= 0) cv::waitKey(dur);
}
| [
"noreply@github.com"
] | AnupamaRajkumar.noreply@github.com |
47661af85f2895cc4980a889fa57d72511b5d786 | e68c1f9134b44ddea144f7efa7523076f3f12d3a | /FinalCode/Stitch_Death.cpp | 6d36d5a42ce322758592c83bbf0b0f49e189c4b5 | [] | no_license | iso5930/Direct-3D-Team-Portfolio | 4ac710ede0c9176702595cba5579af42887611cf | 84e64eb4e91c7e5b4aed77212cd08cfee038fcd3 | refs/heads/master | 2021-08-23T08:15:00.128591 | 2017-12-04T06:14:39 | 2017-12-04T06:14:39 | 112,998,717 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,005 | cpp | #include "StdAfx.h"
#include "Stitch_Death.h"
CStitch_Death::CStitch_Death(void)
{
// StateType
m_eStateType = STATE_TYPE_STITCH_DEATH;
// Death
m_bDeath = false;
}
CStitch_Death::~CStitch_Death(void)
{
}
void CStitch_Death::Initialize()
{
CMonsterState::Initialize();
// SetAnimation
m_pOwner->SetAnimation(7);
CSoundMgr::GetInstance()->PlaySoundForMonster(_T("Stitch_Death.ogg"));
}
CMonsterState* CStitch_Death::Action()
{
if(!m_bDeath)
{
m_pOwner->Death();
m_bDeath = true;
}
if(m_pAnimController->m_dFrameTime - 0.25 <= m_pAnimController->GetTrackPos())
{
CDestory_DustEffect* pDustEffect = new CDestory_DustEffect(NULL, OBJ_TYPE_DYNAMIC, m_pOwner);
m_pOwner->GetLayer()->AddObject(pDustEffect, LAYER_TYPE_EFFECT);
CTransformCom* pTransformCom = (CTransformCom*)pDustEffect->GetComponent(COM_TYPE_TRANSFORM);
pTransformCom->m_vPos = m_pTransformCom->m_vPos;
pTransformCom->m_vPos.y += 50.f;
pDustEffect->Initialize();
m_pOwner->Destroy();
}
return NULL;
}
| [
"iso5930@naver.com"
] | iso5930@naver.com |
d799212681fc4a6aeb5468e935686f8dcb8d05ae | 1df9106e475d7f1b4de615cb4f8122cc93305b7b | /Engine/LightComponent.cpp | ea441229c94af62e4965d0f78ae73ed2d4ec9283 | [] | no_license | mcferront/anttrap-engine | 54517007911389a347e25542c928a0dd4276b730 | c284f7800becaa973101a14bf0b7ffb0d6b732b4 | refs/heads/master | 2021-06-26T08:48:59.814404 | 2019-02-16T05:37:43 | 2019-02-16T05:37:43 | 148,593,261 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,902 | cpp | #include "EnginePch.h"
#include "LightComponent.h"
#include "Node.h"
#include "RenderWorld.h"
DefineComponentType( LightComponent, NULL );
DefineComponentType( DirectionalLightComponent, new DirectionalLightComponentSerializer );
DefineComponentType( AmbientLightComponent, new AmbientLightComponentSerializer );
DefineComponentType( SpotLightComponent, new SpotLightComponentSerializer );
DefineComponentType( PointLightComponent, new PointLightComponentSerializer );
void LightComponent::Destroy( void )
{
Component::Destroy( );
}
void LightComponent::AddToScene( void )
{
if ( false == GetParent( )->IsInScene( ) ) return;
Component::AddToScene( );
m_Light.AddToScene( );
}
void LightComponent::RemoveFromScene( void )
{
m_Light.RemoveFromScene( );
Component::RemoveFromScene( );
}
void DirectionalLightComponent::Create(
const IdList &renderGroups,
Vector color,
float nits
)
{
LightDesc desc;
desc.color = color;
desc.nits = nits;
desc.inner = FLT_MAX;
desc.outer = FLT_MAX;
desc.range = FLT_MAX;
desc.cast = LightDesc::CastDirectional;
LightComponent::Create( renderGroups, desc );
}
void AmbientLightComponent::Create(
const IdList &renderGroups,
Vector color,
float nits
)
{
LightDesc desc;
desc.color = color;
desc.nits = nits;
desc.inner = FLT_MAX;
desc.outer = FLT_MAX;
desc.range = FLT_MAX;
desc.cast = LightDesc::CastAmbient;
LightComponent::Create( renderGroups, desc );
}
void SpotLightComponent::Create(
const IdList &renderGroups,
Vector color,
float nits,
float inner,
float outer,
float range
)
{
LightDesc desc;
desc.color = color;
desc.nits = nits;
desc.inner = inner;
desc.outer = outer;
desc.range = range;
desc.cast = LightDesc::CastSpot;
LightComponent::Create( renderGroups, desc );
}
void PointLightComponent::Create(
const IdList &renderGroups,
Vector color,
float nits,
float range
)
{
LightDesc desc;
desc.color = color;
desc.nits = nits;
desc.inner = FLT_MAX;
desc.outer = FLT_MAX;
desc.range = range;
desc.cast = LightDesc::CastOmni;
LightComponent::Create( renderGroups, desc );
}
void PointLightComponent::SetColor(
const Vector &color
)
{
m_Light.SetColor( color );
}
ISerializable *DirectionalLightComponentSerializer::Deserialize(
Serializer *pSerializer,
ISerializable *pSerializable
)
{
return NULL;
//if ( NULL == pSerializable ) pSerializable = new DirectionalLightComponent;
//DirectionalLightComponent *pDirectionalLightComponent = (DirectionalLightComponent *) pSerializable;
//Id id;
//IdList renderGroups;
//Color color;
//float nits;
//id = Id::Deserialize( pSerializer->GetInputStream( ) );
//Id::DeserializeList( pSerializer->GetInputStream( ), &renderGroups );
//pSerializer->GetInputStream( )->Read( &color, sizeof( color ) );
//pSerializer->GetInputStream( )->Read( &nits, sizeof( nits ) );
//pDirectionalLightComponent->Create( renderGroups, Vector( color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f ), nits );
//return pSerializable;
}
ISerializable *AmbientLightComponentSerializer::Deserialize(
Serializer *pSerializer,
ISerializable *pSerializable
)
{
return NULL;
//if ( NULL == pSerializable ) pSerializable = new AmbientLightComponent;
//AmbientLightComponent *pAmbientLightComponent = (AmbientLightComponent *) pSerializable;
//Id id;
//Color color;
//IdList renderGroups;
//id = Id::Deserialize( pSerializer->GetInputStream( ) );
//Id::DeserializeList( pSerializer->GetInputStream( ), &renderGroups );
//pSerializer->GetInputStream( )->Read( &color, sizeof( color ) );
//pAmbientLightComponent->Create( renderGroups, Vector( color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f ) );
//return pSerializable;
}
ISerializable *SpotLightComponentSerializer::Deserialize(
Serializer *pSerializer,
ISerializable *pSerializable
)
{
return NULL;
// if ( NULL == pSerializable ) pSerializable = new SpotLightComponent;
//
// SpotLightComponent *pSpotLightComponent = (SpotLightComponent *) pSerializable;
//
// Id id;
// IdList renderGroups;
// Color color;
// float nits, inner, outer, range;
//
// id = Id::Deserialize( pSerializer->GetInputStream( ) );
// Id::DeserializeList( pSerializer->GetInputStream( ), &renderGroups );
// pSerializer->GetInputStream( )->Read( &color, sizeof( color ) );
// pSerializer->GetInputStream( )->Read( &nits, sizeof( nits ) );
// pSerializer->GetInputStream( )->Read( &inner, sizeof( inner ) );
// pSerializer->GetInputStream( )->Read( &outer, sizeof( outer ) );
// pSerializer->GetInputStream( )->Read( &range, sizeof( range ) );
//
// pSpotLightComponent->Create( renderGroups, Vector( color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f ), nits, inner, outer, range );
//
// return pSerializable;
}
ISerializable *PointLightComponentSerializer::Deserialize(
Serializer *pSerializer,
ISerializable *pSerializable
)
{
return NULL;
//if ( NULL == pSerializable ) pSerializable = new PointLightComponent;
//PointLightComponent *pPointLightComponent = (PointLightComponent *) pSerializable;
//Id id;
//IdList renderGroups;
//Color color;
//float nits, range;
//id = Id::Deserialize( pSerializer->GetInputStream( ) );
//Id::DeserializeList( pSerializer->GetInputStream( ), &renderGroups );
//pSerializer->GetInputStream( )->Read( &color, sizeof( color ) );
//pSerializer->GetInputStream( )->Read( &nits, sizeof( nits ) );
//pSerializer->GetInputStream( )->Read( &range, sizeof( range ) );
//pPointLightComponent->Create( renderGroups, Vector( color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f ), nits, range );
//return pSerializable;
}
| [
"trapper@trapzz.com"
] | trapper@trapzz.com |
4df51688e303a1074f08da42088d544a16909127 | 4e22253a4f2a834783e465d951f80e30c18d0a03 | /list.h | 58e47be5ef2fe71c80598f0a9f345416c07d7fc8 | [] | no_license | BraveY/Quadrangle | 953b570d3e9e3e7e850c4b57ebf82510017844c1 | f09a3c56c3a22c35128fc916eb6076b14f2a5e4b | refs/heads/master | 2021-01-11T21:34:03.725153 | 2017-01-13T02:21:50 | 2017-01-13T02:21:50 | 78,807,512 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,141 | h | #pragma once
#ifndef __LIST__
#define __LIST__
#include "cont.h"
template<typename T>
class List :public Container<T>
{
protected:
struct Node
{
T data;
Node *next;
} *head, *tail;
public:
List()
{
head=NULL;
tail= NULL;
};
List(const List&l) :head(l.head), tail(l.tail) {};
~List() { clear(); }
size_t size() const
{
Node*p = head;
size_t i = 0;
while (p != NULL)
{
p = p->next;
++i;
}
return i;
}
operator bool() const
{
return head != NULL;
}
List& push_back(const T& data)
{
Node *p = new Node();
p->data = data;
p->next = NULL;
if (tail == NULL) head = tail = p;
else
{
tail->next = p;
tail = p;
}
return *this;
}
T operator[](int index)
{
Node *p = head;
for (int i = 0;i!=index; i++)
{
p = p->next;
}
return p->data;
}
List& operator=(const List&s)
{
head = s.head;
tail = s.tail;
return *this;
}
void pop_back()
{
Node *p = head, *q=p->next;
while (q->next != tail)
{
p = p->next;
q=p->next;
}
p->next = tail;
delete q;
}
void clear()
{
Node *p = head, *q;
while (p != NULL)
{
q = p;
p = p->next;
delete p;
}
head = tail = NULL;
}
List& operator +=(const T& data)
{
push_back(data);
return *this;
}
void traverse()
{
Node*p = head;
while (p != NULL)
{
p->data->draw();
p = p->next;
}
}
friend class listIterator;
class listIterator
{
private:
List<T> *plist;
typename List<T>::Node *p;
public:
listIterator(const List<T>&list) :plist(const_cast<List<T>*>(&list)), p(list.head) {}
listIterator(const listIterator &itr) :plist(itr.plist), p(itr.p) {}
listIterator() :plist(NULL), p(NULL) {}
listIterator & begin()
{
p = plist->List<T>::head;
return *this;
}
listIterator end()
{
return listIterator();
}
listIterator & operator=(const listIterator&itr)
{
return p != itr.p;
}
listIterator &operator++()
{
p = p->next;
return *this;
}
listIterator &operator+(int i)
{
for (int n = 0;n < i;n++)
{
p = p->next;
}
return *this;
}
T& operator *()
{
return p->data;
}
};
};
#endif | [
"lsz_yky@163.com"
] | lsz_yky@163.com |
7bd0ab8a7b33cca727d918e63f2b72e341c42ade | caf55812511d43016cfe908a279ef60915f3428a | /Source/BWEB/Wall.cpp | 1d44f6995319300ff71dc407fd5ef59bfaaf85d5 | [
"MIT"
] | permissive | impie66/McRave | 8572655d65b1bbf1bceba79431b222e724c431cb | 51ff5a0768dc553f4adea109784035b5d6020fd1 | refs/heads/master | 2022-12-08T23:04:16.276859 | 2020-08-31T12:48:34 | 2020-08-31T12:48:34 | 291,378,719 | 2 | 0 | null | 2020-08-30T01:36:49 | 2020-08-30T01:36:48 | null | UTF-8 | C++ | false | false | 49,559 | cpp | #include "BWEB.h"
#include <chrono>
using namespace std;
using namespace BWAPI;
namespace BWEB {
namespace {
map<const BWEM::ChokePoint *, Wall> walls;
bool logInfo = true;
int failedPlacement = 0;
int failedAngle = 0;
int failedPath = 0;
int failedTight = 0;
int failedSpawn = 0;
int failedPower = 0;
int resourceGrid[256][256];
int testGrid[256][256];
}
Position Wall::findCentroid()
{
// Create current centroid using all buildings except Pylons
auto currentCentroid = Position(0, 0);
auto sizeWall = int(rawBuildings.size());
for (auto &[tile, type] : bestLayout) {
if (type != UnitTypes::Protoss_Pylon)
currentCentroid += Position(tile) + Position(type.tileSize()) / 2;
else
sizeWall--;
}
// Create a centroid if we only have a Pylon wall
if (sizeWall == 0) {
sizeWall = bestLayout.size();
for (auto &[tile, type] : bestLayout)
currentCentroid += Position(tile) + Position(type.tileSize()) / 2;
}
return (currentCentroid / sizeWall);
}
TilePosition Wall::findOpening()
{
if (!openWall)
return TilePositions::Invalid;
// Set any tiles on the path as reserved so we don't build on them
auto currentPath = findPathOut();
auto currentOpening = TilePositions::Invalid;
// Check which tile is closest to each part on the path, set as opening
auto distBest = DBL_MAX;
for (auto &pathTile : currentPath.getTiles()) {
const auto closestChokeGeo = Map::getClosestChokeTile(choke, Position(pathTile));
const auto dist = closestChokeGeo.getDistance(Position(pathTile));
const auto centerPath = Position(pathTile) + Position(16, 16);
auto angleOkay = true;
auto distOkay = false;
// Check if the angle and distance is okay
for (auto &[tileLayout, typeLayout] : currentLayout) {
if (typeLayout == UnitTypes::Protoss_Pylon)
continue;
const auto centerPiece = Position(tileLayout) + Position(typeLayout.tileWidth() * 16, typeLayout.tileHeight() * 16);
const auto openingAngle = Map::getAngle(make_pair(centerPiece, centerPath));
const auto openingDist = centerPiece.getDistance(centerPath);
if (abs(chokeAngle - openingAngle) > 35.0)
angleOkay = false;
if (openingDist < 320.0)
distOkay = true;
}
if (distOkay && angleOkay && dist < distBest) {
distBest = dist;
currentOpening = pathTile;
}
}
// If we don't have an opening, assign closest path tile to wall centroid as opening
if (!currentOpening.isValid()) {
for (auto &pathTile : currentPath.getTiles()) {
const auto p = Position(pathTile);
const auto dist = centroid.getDistance(p);
if (dist < distBest) {
distBest = dist;
currentOpening = pathTile;
}
}
}
return currentOpening;
}
Path Wall::findPathOut()
{
// Check that the path points are possible to reach
checkPathPoints();
const auto startCenter = Position(pathStart) + Position(16, 16);
const auto endCenter = Position(pathEnd) + Position(16, 16);
// Get a new path
BWEB::Path newPath(endCenter, startCenter, UnitTypes::Protoss_Dragoon);
allowLifted = false;
newPath.generateBFS([&](const auto &t) { return wallWalkable(t); }, false);
return newPath;
}
bool Wall::powerCheck(const UnitType type, const TilePosition here)
{
if (type != UnitTypes::Protoss_Pylon || pylonWall)
return true;
// TODO: Create a generic BWEB function that takes 2 tiles and tells you if the 1st tile will power the 2nd tile
for (auto &[tileLayout, typeLayout] : currentLayout) {
if (typeLayout == UnitTypes::Protoss_Pylon)
continue;
if (typeLayout.tileWidth() == 4) {
auto powersThis = false;
if (tileLayout.y - here.y == -5 || tileLayout.y - here.y == 4) {
if (tileLayout.x - here.x >= -4 && tileLayout.x - here.x <= 1)
powersThis = true;
}
if (tileLayout.y - here.y == -4 || tileLayout.y - here.y == 3) {
if (tileLayout.x - here.x >= -7 && tileLayout.x - here.x <= 4)
powersThis = true;
}
if (tileLayout.y - here.y == -3 || tileLayout.y - here.y == 2) {
if (tileLayout.x - here.x >= -8 && tileLayout.x - here.x <= 5)
powersThis = true;
}
if (tileLayout.y - here.y >= -2 && tileLayout.y - here.y <= 1) {
if (tileLayout.x - here.x >= -8 && tileLayout.x - here.x <= 6)
powersThis = true;
}
if (!powersThis)
return false;
}
else {
auto powersThis = false;
if (tileLayout.y - here.y == 4) {
if (tileLayout.x - here.x >= -3 && tileLayout.x - here.x <= 2)
powersThis = true;
}
if (tileLayout.y - here.y == -4 || tileLayout.y - here.y == 3) {
if (tileLayout.x - here.x >= -6 && tileLayout.x - here.x <= 5)
powersThis = true;
}
if (tileLayout.y - here.y >= -3 && tileLayout.y - here.y <= 2) {
if (tileLayout.x - here.x >= -7 && tileLayout.x - here.x <= 6)
powersThis = true;
}
if (!powersThis)
return false;
}
}
return true;
}
bool Wall::angleCheck(const UnitType type, const TilePosition here)
{
const auto centerHere = Position(here) + Position(type.tileWidth() * 16, type.tileHeight() * 16);
// If we want a closed wall, we don't care the angle of the buildings
if (!openWall || (type == UnitTypes::Protoss_Pylon && !pylonWall && !pylonWallPiece))
return true;
// Check if the angle is okay between all pieces in the current layout
for (auto &[tileLayout, typeLayout] : currentLayout) {
if (typeLayout == UnitTypes::Protoss_Pylon)
continue;
const auto centerPiece = Position(tileLayout) + Position(typeLayout.tileWidth() * 16, typeLayout.tileHeight() * 16);
const auto wallAngle = Map::getAngle(make_pair(centerPiece, centerHere));
if (abs(chokeAngle - wallAngle) > 20.0)
return false;
}
return true;
}
bool Wall::placeCheck(const UnitType type, const TilePosition here)
{
// Allow Pylon to overlap station defenses
if (type == UnitTypes::Protoss_Pylon) {
if (closestStation && closestStation->getDefenseLocations().find(here) != closestStation->getDefenseLocations().end())
return true;
}
// Check if placement is valid
if (Map::isReserved(here, type.tileWidth(), type.tileHeight())
|| !Map::isPlaceable(type, here)
|| (!openWall && Map::tilesWithinArea(area, here, type.tileWidth(), type.tileHeight()) == 0)
|| (openWall && Map::tilesWithinArea(area, here, type.tileWidth(), type.tileHeight()) == 0 && (type == UnitTypes::Protoss_Pylon || (Map::mapBWEM.GetArea(here) && choke->GetAreas().first != Map::mapBWEM.GetArea(here) && choke->GetAreas().second != Map::mapBWEM.GetArea(here)))))
return false;
return true;
}
bool Wall::tightCheck(const UnitType type, const TilePosition here)
{
// If this is a powering pylon and we are not making a pylon wall, we don't care if it's tight
if (type == UnitTypes::Protoss_Pylon && !pylonWall && !pylonWallPiece)
return true;
// Dimensions of current buildings UnitType
const auto dimL = (type.tileWidth() * 16) - type.dimensionLeft();
const auto dimR = (type.tileWidth() * 16) - type.dimensionRight() - 1;
const auto dimU = (type.tileHeight() * 16) - type.dimensionUp();
const auto dimD = (type.tileHeight() * 16) - type.dimensionDown() - 1;
const auto walkHeight = type.tileHeight() * 4;
const auto walkWidth = type.tileWidth() * 4;
// Dimension of UnitType to check tightness for
const auto vertTight = (tightType == UnitTypes::None) ? 32 : tightType.height();
const auto horizTight = (tightType == UnitTypes::None) ? 32 : tightType.width();
// Checks each side of the building to see if it is valid for walling purposes
const auto checkL = dimL < horizTight;
const auto checkR = dimR < horizTight;
const auto checkU = dimU < vertTight;
const auto checkD = dimD < vertTight;
// Figures out how many extra tiles we can check tightness for
const auto extraL = pylonWall || !requireTight ? 0 : max(0, (horizTight - dimL) / 8);
const auto extraR = pylonWall || !requireTight ? 0 : max(0, (horizTight - dimR) / 8);
const auto extraU = pylonWall || !requireTight ? 0 : max(0, (vertTight - dimU) / 8);
const auto extraD = pylonWall || !requireTight ? 0 : max(0, (vertTight - dimD) / 8);
// Setup boundary WalkPositions to check for tightness
const auto left = WalkPosition(here) - WalkPosition(1 + extraL, 0);
const auto right = WalkPosition(here) + WalkPosition(walkWidth + extraR, 0);
const auto up = WalkPosition(here) - WalkPosition(0, 1 + extraU);
const auto down = WalkPosition(here) + WalkPosition(0, walkHeight + extraD);
// Used for determining if the tightness we found is suitable
const auto firstBuilding = currentLayout.size() == 0;
const auto lastBuilding = currentLayout.size() == (rawBuildings.size() - 1);
auto terrainTight = false;
auto parentTight = false;
auto p1Tight = 0;
auto p2Tight = 0;
// Functions for each dimension check
const auto gapRight = [&](UnitType parent) {
return (parent.tileWidth() * 16) - parent.dimensionLeft() + dimR;
};
const auto gapLeft = [&](UnitType parent) {
return (parent.tileWidth() * 16) - parent.dimensionRight() - 1 + dimL;
};
const auto gapUp = [&](UnitType parent) {
return (parent.tileHeight() * 16) - parent.dimensionDown() - 1 + dimU;
};
const auto gapDown = [&](UnitType parent) {
return (parent.tileHeight() * 16) - parent.dimensionUp() + dimD;
};
// Check if the building is terrain tight when placed here
const auto terrainTightCheck = [&](WalkPosition w, bool check) {
const auto t = TilePosition(w);
// If the walkposition is invalid or unwalkable
if (tightType != UnitTypes::None && check && (!w.isValid() || !Broodwar->isWalkable(w)))
return true;
// If we don't care about walling tight and the tile isn't walkable
if (!requireTight && !Map::isWalkable(t))
return true;
// If there's a mineral field or geyser here
if (Map::isUsed(t).isResourceContainer())
return true;
return false;
};
// Iterate vertical tiles adjacent of this placement
const auto checkVerticalSide = [&](WalkPosition start, bool check, const auto gap) {
for (auto x = start.x - 1; x < start.x + walkWidth + 1; x++) {
const WalkPosition w(x, start.y);
const auto t = TilePosition(w);
const auto parent = Map::isUsed(t);
const auto leftCorner = x < start.x;
const auto rightCorner = x >= start.x + walkWidth;
// If this is a corner
if (leftCorner || rightCorner) {
// Check if it's tight with the terrain
if (!terrainTight && terrainTightCheck(w, check) && leftCorner ? terrainTightCheck(w, checkL) : terrainTightCheck(w, checkR))
terrainTight = true;
// Check if it's tight with a parent
if (!parentTight && find(rawBuildings.begin(), rawBuildings.end(), parent) != rawBuildings.end() && (!requireTight || (gap(parent) < vertTight && (leftCorner ? gapLeft(parent) < horizTight : gapRight(parent) < horizTight))))
parentTight = true;
}
else {
// Check if it's tight with the terrain
if (!terrainTight && terrainTightCheck(w, check))
terrainTight = true;
// Check if it's tight with a parent
if (!parentTight && find(rawBuildings.begin(), rawBuildings.end(), parent) != rawBuildings.end() && (!requireTight || gap(parent) < vertTight))
parentTight = true;
}
// Check to see which node it is closest to (0 is don't check, 1 is not tight, 2 is tight)
if (!openWall && !Map::isWalkable(t) && w.getDistance(choke->Center()) < 4) {
if (w.getDistance(choke->Pos(choke->end1)) < w.getDistance(choke->Pos(choke->end2))) {
if (p1Tight == 0)
p1Tight = 1;
if (terrainTight)
p1Tight = 2;
}
else if (p2Tight == 0) {
if (p2Tight == 0)
p2Tight = 1;
if (terrainTight)
p2Tight = 2;
}
}
}
};
// Iterate horizontal tiles adjacent of this placement
const auto checkHorizontalSide = [&](WalkPosition start, bool check, const auto gap) {
for (auto y = start.y - 1; y < start.y + walkHeight + 1; y++) {
const WalkPosition w(start.x, y);
const auto t = TilePosition(w);
const auto parent = Map::isUsed(t);
const auto topCorner = y < start.y;
const auto downCorner = y >= start.y + walkHeight;
// If this is a corner
if (topCorner || downCorner) {
// Check if it's tight with the terrain
if (!terrainTight && terrainTightCheck(w, check) && topCorner ? terrainTightCheck(w, checkU) : terrainTightCheck(w, checkD))
terrainTight = true;
// Check if it's tight with a parent
if (!parentTight && find(rawBuildings.begin(), rawBuildings.end(), parent) != rawBuildings.end() && (!requireTight || (gap(parent) < horizTight && (topCorner ? gapUp(parent) < vertTight : gapDown(parent) < vertTight))))
parentTight = true;
}
else {
// Check if it's tight with the terrain
if (!terrainTight && terrainTightCheck(w, check))
terrainTight = true;
// Check if it's tight with a parent
if (!parentTight && find(rawBuildings.begin(), rawBuildings.end(), parent) != rawBuildings.end() && (!requireTight || gap(parent) < horizTight))
parentTight = true;
}
// Check to see which node it is closest to (0 is don't check, 1 is not tight, 2 is tight)
if (!openWall && !Map::isWalkable(t) && w.getDistance(choke->Center()) < 4) {
if (w.getDistance(choke->Pos(choke->end1)) < w.getDistance(choke->Pos(choke->end2))) {
if (p1Tight == 0)
p1Tight = 1;
if (terrainTight)
p1Tight = 2;
}
else if (p2Tight == 0) {
if (p2Tight == 0)
p2Tight = 1;
if (terrainTight)
p2Tight = 2;
}
}
}
};
// For each side, check if it's terrain tight or tight with any adjacent buildings
checkVerticalSide(up, checkU, gapUp);
checkVerticalSide(down, checkD, gapDown);
checkHorizontalSide(left, checkL, gapLeft);
checkHorizontalSide(right, checkR, gapRight);
// If we want a closed wall, we need all buildings to be tight at the tightness resolution...
if (!openWall) {
if (!lastBuilding && !firstBuilding) // ...to the parent if not first building
return parentTight;
if (firstBuilding) // ...to the terrain if first building
return terrainTight && p1Tight != 1 && p2Tight != 1;
if (lastBuilding) // ...to the parent and terrain if last building
return terrainTight && parentTight && p1Tight != 1 && p2Tight != 1;
}
// If we want an open wall, we need this building to be tight at tile resolution to a parent or terrain
else if (openWall)
return (terrainTight || parentTight);
return false;
}
bool Wall::spawnCheck(const UnitType type, const TilePosition here)
{
// TODO: Check if units spawn in bad spots, just returns true for now
checkPathPoints();
const auto startCenter = Position(pathStart) + Position(16, 16);
const auto endCenter = Position(pathEnd) + Position(16, 16);
Path pathOut;
return true;
}
bool Wall::wallWalkable(const TilePosition& tile)
{
// Checks for any collision and inverts the return value
if (!tile.isValid()
|| (Map::mapBWEM.GetArea(tile) && Map::mapBWEM.GetArea(tile) != area && find(accessibleNeighbors.begin(), accessibleNeighbors.end(), Map::mapBWEM.GetArea(tile)) == accessibleNeighbors.end())
|| Map::isReserved(tile)
|| !Map::isWalkable(tile)
|| (allowLifted && Map::isUsed(tile) != UnitTypes::Terran_Barracks && Map::isUsed(tile) != UnitTypes::None)
|| (!allowLifted && Map::isUsed(tile) != UnitTypes::None && Map::isUsed(tile) != UnitTypes::Zerg_Larva)
//|| (openWall && (tile).getDistance(pathEnd) - 96.0 > jpsDist / 32)
|| resourceGrid[tile.x][tile.y] > 0)
return false;
return true;
}
void Wall::initialize()
{
// Clear failed counters
failedPlacement = 0;
failedAngle = 0;
failedPath = 0;
failedTight = 0;
failedSpawn = 0;
failedPower = 0;
// Set BWAPI::Points to invalid (default constructor is None)
centroid = BWAPI::Positions::Invalid;
opening = BWAPI::TilePositions::Invalid;
pathStart = BWAPI::TilePositions::Invalid;
pathEnd = BWAPI::TilePositions::Invalid;
initialPathStart = BWAPI::TilePositions::Invalid;
initialPathEnd = BWAPI::TilePositions::Invalid;
// Set important terrain features
bestWallScore = 0;
accessibleNeighbors = area->AccessibleNeighbours();
chokeAngle = Map::getAngle(make_pair(Position(choke->Pos(choke->end1)) + Position(4, 4), Position(choke->Pos(choke->end2)) + Position(4, 4)));
pylonWall = count(rawBuildings.begin(), rawBuildings.end(), BWAPI::UnitTypes::Protoss_Pylon) > 1;
creationStart = TilePosition(choke->Center());
base = !area->Bases().empty() ? &area->Bases().front() : nullptr;
flatRamp = Broodwar->isBuildable(TilePosition(choke->Center()));
closestStation = Stations::getClosestStation(TilePosition(choke->Center()));
// Setup a resource grid that prevents pathing through mineral lines
if (base) {
for (auto &mineral : base->Minerals()) {
for (int x = -1; x < 3; x++) {
for (int y = -1; y < 3; y++) {
resourceGrid[mineral->TopLeft().x + x][mineral->TopLeft().y + y] = 1;
}
}
}
}
// Check if a Pylon should be put in the wall to help the size of the Wall or away from the wall for protection
auto p1 = choke->Pos(choke->end1);
auto p2 = choke->Pos(choke->end2);
pylonWallPiece = abs(p1.x - p2.x) * 8 >= 320 || abs(p1.y - p2.y) * 8 >= 256 || p1.getDistance(p2) * 8 >= 288;
// Initiliaze path points and check them
initializePathPoints();
checkPathPoints();
// Create a jps path for limiting BFS exploration using the distance of the jps path
Path jpsPath(Position(pathStart), Position(pathEnd), UnitTypes::Zerg_Zergling);
jpsPath.generateJPS([&](const TilePosition &t) { return jpsPath.unitWalkable(t); });
jpsDist = jpsPath.getDistance();
// Create notable locations to keep Wall pieces within proxmity of
if (base)
notableLocations ={ base->Center(), Position(initialPathStart) + Position(16,16), (base->Center() + Position(initialPathStart)) / 2 };
else
notableLocations ={ Position(initialPathStart) + Position(16,16), Position(initialPathEnd) + Position(16,16) };
// Sort all the pieces and iterate over them to find the best wall - by Hannes
if (find(rawBuildings.begin(), rawBuildings.end(), UnitTypes::Protoss_Pylon) != rawBuildings.end()) {
sort(rawBuildings.begin(), rawBuildings.end(), [](UnitType l, UnitType r) { return (l == UnitTypes::Protoss_Pylon) < (r == UnitTypes::Protoss_Pylon); }); // Moves pylons to end
sort(rawBuildings.begin(), find(rawBuildings.begin(), rawBuildings.end(), UnitTypes::Protoss_Pylon)); // Sorts everything before pylons
}
else if (find(rawBuildings.begin(), rawBuildings.end(), UnitTypes::Zerg_Hatchery) != rawBuildings.end()) {
sort(rawBuildings.begin(), rawBuildings.end(), [](UnitType l, UnitType r) { return (l == UnitTypes::Zerg_Hatchery) > (r == UnitTypes::Zerg_Hatchery); }); // Moves hatchery to start
sort(find(rawBuildings.begin(), rawBuildings.end(), UnitTypes::Zerg_Hatchery), rawBuildings.begin()); // Sorts everything after hatchery
}
else
sort(rawBuildings.begin(), rawBuildings.end());
// If there is a base in this area and we're creating an open wall, move creation start within 10 tiles of it
if (openWall && base) {
auto startCenter = Position(creationStart) + Position(16, 16);
auto distBest = DBL_MAX;
auto moveTowards = (Position(initialPathStart) + base->Center()) / 2;
// Iterate 3x3 around the current TilePosition and try to get within 5 tiles
auto triedCount = 0;
while (startCenter.getDistance(moveTowards) > 320.0 && triedCount < 50) {
triedCount++;
const auto initialStart = creationStart;
for (int x = initialStart.x - 1; x <= initialStart.x + 1; x++) {
for (int y = initialStart.y - 1; y <= initialStart.y + 1; y++) {
const TilePosition t(x, y);
if (!t.isValid())
continue;
const auto p = Position(t) + Position(16, 16);
const auto dist = p.getDistance(moveTowards);
if (dist < distBest) {
distBest = dist;
creationStart = t;
startCenter = p;
movedStart = true;
}
}
}
}
}
// If the creation start position isn't buildable, move towards the top of this area to find a buildable location
if (openWall) {
auto triedCount = 0;
while (!Broodwar->isBuildable(creationStart) && triedCount < 50) {
triedCount++;
auto distBest = DBL_MAX;
const auto initialStart = creationStart;
for (int x = initialStart.x - 1; x <= initialStart.x + 1; x++) {
for (int y = initialStart.y - 1; y <= initialStart.y + 1; y++) {
const TilePosition t(x, y);
if (!t.isValid())
continue;
const auto p = Position(t);
const auto dist = p.getDistance(Position(area->Top()));
if (dist < distBest) {
distBest = dist;
creationStart = t;
movedStart = true;
}
}
}
}
}
}
void Wall::initializePathPoints()
{
auto line = make_pair(Position(choke->Pos(choke->end1)) + Position(4, 4), Position(choke->Pos(choke->end2)) + Position(4, 4));
auto perpLine = openWall ? Map::perpendicularLine(line, 160.0) : Map::perpendicularLine(line, 96.0);
auto lineStart = perpLine.first.getDistance(Position(area->Top())) > perpLine.second.getDistance(Position(area->Top())) ? perpLine.second : perpLine.first;
auto lineEnd = perpLine.first.getDistance(Position(area->Top())) > perpLine.second.getDistance(Position(area->Top())) ? perpLine.first : perpLine.second;
auto isMain = closestStation && closestStation->isMain();
auto isNatural = closestStation && closestStation->isNatural();
// If it's a natural wall, path between the closest main and end of the perpendicular line
if (isNatural) {
Station * closestMain = Stations::getClosestMainStation(TilePosition(choke->Center()));
initialPathStart = closestMain ? TilePosition(Map::mapBWEM.GetPath(closestStation->getBase()->Center(), closestMain->getBase()->Center()).front()->Center()) : TilePosition(lineStart);
initialPathEnd = TilePosition(lineEnd);
}
// If it's a main wall, path between a point between the roughly the choke and the area top
else if (isMain) {
initialPathEnd = (TilePosition(choke->Center()) + TilePosition(lineEnd)) / 2;
initialPathStart = (TilePosition(area->Top()) + TilePosition(lineStart)) / 2;
}
// Other walls
else {
initialPathStart = TilePosition(lineStart);
initialPathEnd = TilePosition(lineEnd);
}
pathStart = initialPathStart;
pathEnd = initialPathEnd;
}
void Wall::checkPathPoints()
{
const auto neighbourArea = [&](const BWEM::Area * area) {
for (auto subArea : area->AccessibleNeighbours()) {
if (area == subArea)
return true;
}
return false;
};
const auto notValidPathPoint = [&](const TilePosition testTile) {
return !testTile.isValid()
|| !Map::isWalkable(testTile)
|| Map::isReserved(testTile)
|| Map::isUsed(testTile) != UnitTypes::None;
};
// Push the path start as far from the path end if it's not in a valid location
auto distBest = 0.0;
if (notValidPathPoint(pathStart)) {
for (auto x = initialPathStart.x - 4; x < initialPathStart.x + 4; x++) {
for (auto y = initialPathStart.y - 4; y < initialPathStart.y + 4; y++) {
const TilePosition t(x, y);
const auto dist = t.getDistance(initialPathEnd);
if (notValidPathPoint(t))
continue;
if (dist > distBest) {
pathStart = t;
distBest = dist;
}
}
}
}
// Push the path end as far from the path start if it's not in a valid location
distBest = 0.0;
if (notValidPathPoint(pathEnd)) {
for (auto x = initialPathEnd.x - 4; x < initialPathEnd.x + 4; x++) {
for (auto y = initialPathEnd.y - 4; y < initialPathEnd.y + 4; y++) {
const TilePosition t(x, y);
const auto dist = t.getDistance(initialPathStart);
if (notValidPathPoint(t))
continue;
if (dist > distBest) {
pathEnd = t;
distBest = dist;
}
}
}
}
}
void Wall::addPieces()
{
// For each permutation, try to make a wall combination that is better than the current best
do {
currentLayout.clear();
typeIterator = rawBuildings.begin();
addNextPiece(creationStart);
} while (Broodwar->self()->getRace() == Races::Zerg ? next_permutation(find(rawBuildings.begin(), rawBuildings.end(), UnitTypes::Zerg_Hatchery), rawBuildings.end())
: next_permutation(rawBuildings.begin(), find(rawBuildings.begin(), rawBuildings.end(), UnitTypes::Protoss_Pylon)));
for (auto &[tile, type] : bestLayout) {
addToWallPieces(tile, type);
Map::addReserve(tile, type.tileWidth(), type.tileHeight());
Map::addUsed(tile, type);
}
}
void Wall::addNextPiece(TilePosition start)
{
const auto type = *typeIterator;
const auto radius = (openWall || typeIterator == rawBuildings.begin()) ? 8 : 4;
for (auto x = start.x - radius; x < start.x + radius; x++) {
for (auto y = start.y - radius; y < start.y + radius; y++) {
const TilePosition tile(x, y);
if (!tile.isValid())
continue;
const auto center = Position(tile) + Position(type.tileWidth() * 16, type.tileHeight() * 16);
const auto closestGeo = Map::getClosestChokeTile(choke, center);
// Open walls need to be placed within proximity of notable features
if (openWall) {
auto closestNotable = Positions::Invalid;
auto closestNotableDist = DBL_MAX;
for (auto & pos : notableLocations) {
auto dist = pos.getDistance(center);
if (dist < closestNotableDist) {
closestNotable = pos;
closestNotableDist = dist;
}
}
if (center.getDistance(closestNotable) >= 288.0 || center.getDistance(closestNotable) >= closestGeo.getDistance(closestNotable) + 48.0)
continue;
}
// Try not to seal the wall poorly
if (!openWall && flatRamp) {
auto dist = min({ Position(tile).getDistance(Position(choke->Center())),
Position(tile + TilePosition(type.tileWidth(), 0)).getDistance(Position(choke->Center())),
Position(tile + TilePosition(type.tileWidth(), type.tileHeight())).getDistance(Position(choke->Center())),
Position(tile + TilePosition(0, type.tileHeight())).getDistance(Position(choke->Center())) });
if (dist < 64.0)
continue;
}
// Required checks for this wall to be valid
if (!powerCheck(type, tile)) {
failedPower++;
continue;
}
if (!angleCheck(type, tile)) {
failedAngle++;
continue;
}
if (!placeCheck(type, tile)) {
failedPlacement++;
continue;
}
if (!tightCheck(type, tile)) {
failedTight++;
continue;
}
if (!spawnCheck(type, tile)) {
failedSpawn++;
continue;
}
// 1) Store the current type, increase the iterator
currentLayout[tile] = type;
Map::addUsed(tile, type);
typeIterator++;
// 2) If at the end, score wall
if (typeIterator == rawBuildings.end())
scoreWall();
else
openWall ? addNextPiece(start) : addNextPiece(tile);
// 3) Erase this current placement and repeat
if (typeIterator != rawBuildings.begin())
typeIterator--;
currentLayout.erase(tile);
Map::removeUsed(tile, type.tileWidth(), type.tileHeight());
}
}
}
void Wall::addDefenses()
{
// Prevent adding defenses if we don't have a wall
if (bestLayout.empty())
return;
// Find the furthest non Pylon building to the chokepoint
auto furthest = 0.0;
for (auto &tile : largeTiles) {
const auto center = Position(tile) + Position(64, 48);
const auto closestGeo = Map::getClosestChokeTile(choke, center);
const auto dist = center.getDistance(closestGeo);
if (dist > furthest)
furthest = dist;
}
for (auto &tile : mediumTiles) {
const auto center = Position(tile) + Position(48, 32);
const auto closestGeo = Map::getClosestChokeTile(choke, center);
const auto dist = center.getDistance(closestGeo);
if (dist > furthest)
furthest = dist;
}
// Find the furthest Pylon building to the chokepoint if it's a Pylon wall
if (pylonWall) {
for (auto &tile : smallTiles) {
const auto center = Position(tile) + Position(32, 32);
const auto closestGeo = Map::getClosestChokeTile(choke, center);
const auto dist = center.getDistance(closestGeo);
if (dist > furthest)
furthest = dist;
}
}
auto closestStation = Stations::getClosestStation(TilePosition(choke->Center()));
for (auto &building : rawDefenses) {
const auto start = TilePosition(centroid);
const auto width = building.tileWidth() * 32;
const auto height = building.tileHeight() * 32;
const auto openingCenter = Position(opening) + Position(16, 16);
const auto arbitraryCloseMetric = Broodwar->self()->getRace() == Races::Zerg ? 32.0 : 160.0;
// Iterate around wall centroid to find a suitable position
auto scoreBest = DBL_MAX;
auto tileBest = TilePositions::Invalid;
for (auto x = start.x - 12; x <= start.x + 12; x++) {
for (auto y = start.y - 12; y <= start.y + 12; y++) {
const TilePosition t(x, y);
const auto center = Position(t) + Position(width / 2, height / 2);
const auto closestGeo = Map::getClosestChokeTile(choke, center);
const auto overlapsDefense = closestStation && closestStation->getDefenseLocations().find(t) != closestStation->getDefenseLocations().end() && defenses.find(t) == defenses.end();
const auto dist = center.getDistance(closestGeo);
const auto tooClose = dist < furthest || center.getDistance(openingCenter) < arbitraryCloseMetric;
const auto tooFar = center.getDistance(centroid) > 200.0;
if (!overlapsDefense) {
if (!t.isValid()
|| Map::isReserved(t, building.tileWidth(), building.tileHeight())
|| !Map::isPlaceable(building, t)
|| Map::tilesWithinArea(area, t, building.tileWidth(), building.tileHeight()) == 0
|| tooClose
|| tooFar)
continue;
}
const auto score = dist + center.getDistance(openingCenter);
if (score < scoreBest) {
Map::addUsed(t, building);
auto &pathOut = findPathOut();
if ((openWall && pathOut.isReachable()) || !openWall) {
tileBest = t;
scoreBest = score;
}
Map::removeUsed(t, building.tileWidth(), building.tileHeight());
}
}
}
// If tile is valid, add to wall
if (tileBest.isValid()) {
defenses.insert(tileBest);
Map::addReserve(tileBest, building.tileWidth(), building.tileHeight());
}
// Otherwise we can't place anymore
else
break;
}
}
void Wall::scoreWall()
{
// Create a path searching for an opening
auto pathOut = findPathOut();
// If we want an open wall and it's not reachable, or we want a closed wall and it is reachable
if ((openWall && !pathOut.isReachable()) || (!openWall && pathOut.isReachable())) {
failedPath++;
return;
}
// Find distance for each piece to the closest choke tile to the path start point
auto dist = 1.0;
auto optimalChokeTile = pathStart.getDistance(TilePosition(choke->Pos(choke->end1))) < pathStart.getDistance(TilePosition(choke->Pos(choke->end2))) ? Position(choke->Pos(choke->end1)) : Position(choke->Pos(choke->end2));
for (auto &[tile, type] : currentLayout) {
const auto center = Position(tile) + Position(type.tileWidth() * 16, type.tileHeight() * 16);
const auto chokeDist = optimalChokeTile.getDistance(center);
(type == UnitTypes::Protoss_Pylon && !pylonWall && !pylonWallPiece) ? dist += -chokeDist : dist += chokeDist;
}
// Calculate current centroid if a closed wall
auto currentCentroid = findCentroid();
auto currentOpening = Position(findOpening()) + Position(16, 16);
// Score wall and store if better than current best layout
const auto score = !openWall ? dist : 1.0 / dist;
if (score > bestWallScore) {
bestLayout = currentLayout;
bestWallScore = score;
}
}
void Wall::cleanup()
{
// Add a reserved path
if (openWall && !bestLayout.empty()) {
auto ¤tPath = findPathOut();
for (auto &tile : currentPath.getTiles())
Map::addReserve(tile, 1, 1);
}
// Remove used from tiles
for (auto &tile : smallTiles)
Map::removeUsed(tile, 2, 2);
for (auto &tile : mediumTiles)
Map::removeUsed(tile, 3, 2);
for (auto &tile : largeTiles)
Map::removeUsed(tile, 4, 3);
for (auto &tile : defenses)
Map::removeUsed(tile, 2, 2);
}
int Wall::getGroundDefenseCount()
{
// Returns how many visible ground defensive structures exist in this Walls defense locations
int count = 0;
for (auto &defense : defenses) {
auto &type = Map::isUsed(defense);
if (type == UnitTypes::Protoss_Photon_Cannon
|| type == UnitTypes::Zerg_Sunken_Colony
|| type == UnitTypes::Terran_Bunker)
count++;
}
return count;
}
int Wall::getAirDefenseCount()
{
// Returns how many visible air defensive structures exist in this Walls defense locations
int count = 0;
for (auto &defense : defenses) {
auto &type = Map::isUsed(defense);
if (type == UnitTypes::Protoss_Photon_Cannon
|| type == UnitTypes::Zerg_Spore_Colony
|| type == UnitTypes::Terran_Missile_Turret)
count++;
}
return count;
}
void Wall::draw()
{
set<Position> anglePositions;
int color = Broodwar->self()->getColor();
int textColor = color == 185 ? textColor = Text::DarkGreen : Broodwar->self()->getTextColor();
// Draw boxes around each feature
auto drawBoxes = true;
if (drawBoxes) {
for (auto &tile : smallTiles) {
Broodwar->drawBoxMap(Position(tile), Position(tile) + Position(65, 65), color);
Broodwar->drawTextMap(Position(tile) + Position(4, 4), "%cW", Broodwar->self()->getTextColor());
anglePositions.insert(Position(tile) + Position(32, 32));
}
for (auto &tile : mediumTiles) {
Broodwar->drawBoxMap(Position(tile), Position(tile) + Position(97, 65), color);
Broodwar->drawTextMap(Position(tile) + Position(4, 4), "%cW", Broodwar->self()->getTextColor());
anglePositions.insert(Position(tile) + Position(48, 32));
}
for (auto &tile : largeTiles) {
Broodwar->drawBoxMap(Position(tile), Position(tile) + Position(129, 97), color);
Broodwar->drawTextMap(Position(tile) + Position(4, 4), "%cW", Broodwar->self()->getTextColor());
anglePositions.insert(Position(tile) + Position(64, 48));
}
for (auto &tile : defenses) {
Broodwar->drawBoxMap(Position(tile), Position(tile) + Position(65, 65), color);
Broodwar->drawTextMap(Position(tile) + Position(4, 4), "%cW", Broodwar->self()->getTextColor());
}
}
// Draw angles of each piece
auto drawAngles = false;
if (drawAngles) {
for (auto &pos1 : anglePositions) {
for (auto &pos2 : anglePositions) {
if (pos1 == pos2)
continue;
const auto angle = Map::getAngle(make_pair(pos1, pos2));
Broodwar->drawLineMap(pos1, pos2, color);
Broodwar->drawTextMap((pos1 + pos2) / 2, "%c%.2f", textColor, angle);
}
}
}
// Draw opening
Broodwar->drawBoxMap(Position(opening), Position(opening) + Position(33, 33), color, true);
// Draw the line and angle of the ChokePoint
auto p1 = choke->Pos(choke->end1);
auto p2 = choke->Pos(choke->end2);
auto angle = Map::getAngle(make_pair(p1, p2));
Broodwar->drawTextMap(Position(choke->Center()), "%c%.2f", Text::Grey, angle);
Broodwar->drawLineMap(Position(p1), Position(p2), Colors::Grey);
// Draw the path points
Broodwar->drawCircleMap(Position(pathStart), 6, Colors::Black, true);
Broodwar->drawCircleMap(Position(pathEnd), 6, Colors::White, true);
}
}
namespace BWEB::Walls {
Wall* createWall(vector<UnitType>& buildings, const BWEM::Area * area, const BWEM::ChokePoint * choke, const UnitType tightType, const vector<UnitType>& defenses, const bool openWall, const bool requireTight)
{
ofstream writeFile;
string buffer;
auto timePointNow = chrono::system_clock::now();
auto timeNow = chrono::system_clock::to_time_t(timePointNow);
// Print the clock position of this Wall
auto clock = abs(round((Map::getAngle(make_pair(Map::mapBWEM.Center(), Position(area->Top()))) + 90) / 30));
if (Position(area->Top()).x < Map::mapBWEM.Center().x)
clock+= 6;
// Open the log file if desired and write information
if (logInfo) {
writeFile.open("bwapi-data/write/BWEB_Wall.txt", std::ios::app);
writeFile << ctime(&timeNow);
writeFile << Broodwar->mapFileName().c_str() << endl;
writeFile << "At: " << clock << " o'clock." << endl;
writeFile << endl;
writeFile << "Buildings:" << endl;
for (auto &building : buildings)
writeFile << building.c_str() << endl;
writeFile << endl;
}
// Verify inputs are correct
if (!area) {
writeFile << "BWEB: Can't create a wall without a valid BWEM::Area" << endl;
return nullptr;
}
if (!choke) {
writeFile << "BWEB: Can't create a wall without a valid BWEM::Chokepoint" << endl;
return nullptr;
}
if (buildings.empty()) {
writeFile << "BWEB: Can't create a wall with an empty vector of UnitTypes." << endl;
return nullptr;
}
// Verify not attempting to create a Wall in the same Area/ChokePoint combination
for (auto &[_, wall] : walls) {
if (wall.getArea() == area && wall.getChokePoint() == choke) {
writeFile << "BWEB: Can't create a Wall where one already exists." << endl;
return &wall;
}
}
// Create a Wall
Wall wall(area, choke, buildings, defenses, tightType, requireTight, openWall);
// Verify the Wall creation was successful
auto wallFound = (wall.getSmallTiles().size() + wall.getMediumTiles().size() + wall.getLargeTiles().size()) == wall.getRawBuildings().size();
// Log information
if (logInfo) {
writeFile << "Failure Reasons:" << endl;
writeFile << "Power: " << failedPower << endl;
writeFile << "Angle: " << failedAngle << endl;
writeFile << "Placement: " << failedPlacement << endl;
writeFile << "Tight: " << failedTight << endl;
writeFile << "Path: " << failedPath << endl;
writeFile << "Spawn: " << failedSpawn << endl;
writeFile << endl;
double dur = std::chrono::duration <double, std::milli>(chrono::system_clock::now() - timePointNow).count();
writeFile << "Generation Time: " << dur << "ms and " << (wallFound ? "succesful." : "failed.") << endl;
writeFile << "--------------------" << endl;
}
// If we found a suitable Wall, push into container and return pointer to it
if (wallFound) {
walls.emplace(choke, wall);
return &walls.at(choke);
}
return nullptr;
}
Wall* createFFE()
{
vector<UnitType> buildings ={ UnitTypes::Protoss_Forge, UnitTypes::Protoss_Gateway, UnitTypes::Protoss_Pylon };
vector<UnitType> defenses(10, UnitTypes::Protoss_Photon_Cannon);
return createWall(buildings, Map::getNaturalArea(), Map::getNaturalChoke(), UnitTypes::None, defenses, true, false);
}
Wall* createZSimCity()
{
vector<UnitType> buildings ={ UnitTypes::Zerg_Hatchery, UnitTypes::Zerg_Evolution_Chamber };
vector<UnitType> defenses(10, UnitTypes::Zerg_Sunken_Colony);
return createWall(buildings, Map::getNaturalArea(), Map::getNaturalChoke(), UnitTypes::None, defenses, true, false);
}
Wall* createTWall()
{
vector<UnitType> buildings ={ UnitTypes::Terran_Supply_Depot, UnitTypes::Terran_Supply_Depot, UnitTypes::Terran_Barracks };
vector<UnitType> defenses;
auto type = Broodwar->enemy() && Broodwar->enemy()->getRace() == Races::Protoss ? UnitTypes::Protoss_Zealot : UnitTypes::Zerg_Zergling;
return createWall(buildings, Map::getMainArea(), Map::getMainChoke(), type, defenses, false, true);
}
Wall* getClosestWall(TilePosition here)
{
auto distBest = DBL_MAX;
Wall * bestWall = nullptr;
for (auto &[_, wall] : walls) {
const auto dist = here.getDistance(TilePosition(wall.getChokePoint()->Center()));
if (dist < distBest) {
distBest = dist;
bestWall = &wall;
}
}
return bestWall;
}
Wall* getWall(const BWEM::ChokePoint * choke)
{
if (!choke)
return nullptr;
for (auto &[_, wall] : walls) {
if (wall.getChokePoint() == choke)
return &wall;
}
return nullptr;
}
map<const BWEM::ChokePoint *, Wall>& getWalls() {
return walls;
}
void draw()
{
for (auto &[_, wall] : walls)
wall.draw();
}
}
| [
"christianmccrave@gmail.com"
] | christianmccrave@gmail.com |
598d07d7d88dae7ed1eeca617198fd5597cb49a1 | 5466c25ca58b5a5c6fdd128f882c1405a8373d80 | /modules/engine/include/bullet3/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h | 758733be004921ea0912476717c5c0c76a43bf65 | [
"MIT"
] | permissive | alexlitty/randar | 73781d877daafb1a62b5e86251c31ee101831bcb | 95daae57b1ec7d87194cdbcf6e3946b4ed9fc79b | refs/heads/master | 2020-05-27T12:59:49.744931 | 2018-03-27T05:15:35 | 2018-03-27T05:16:01 | 73,526,607 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,942 | h | /*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BT_SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
#define BT_SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
class btIDebugDraw;
class btPersistentManifold;
class btDispatcher;
class btCollisionObject;
#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
#include "BulletDynamics/ConstraintSolver/btSolverBody.h"
#include "BulletDynamics/ConstraintSolver/btSolverConstraint.h"
#include "BulletCollision/NarrowPhaseCollision/btManifoldPoint.h"
#include "BulletDynamics/ConstraintSolver/btConstraintSolver.h"
typedef btSimdScalar(*btSingleConstraintRowSolver)(btSolverBody&, btSolverBody&, const btSolverConstraint&);
///The btSequentialImpulseConstraintSolver is a fast SIMD implementation of the Projected Gauss Seidel (iterative LCP) method.
ATTRIBUTE_ALIGNED16(class) btSequentialImpulseConstraintSolver : public btConstraintSolver
{
protected:
btAlignedObjectArray<btSolverBody> m_tmpSolverBodyPool;
btConstraintArray m_tmpSolverContactConstraintPool;
btConstraintArray m_tmpSolverNonContactConstraintPool;
btConstraintArray m_tmpSolverContactFrictionConstraintPool;
btConstraintArray m_tmpSolverContactRollingFrictionConstraintPool;
btAlignedObjectArray<int> m_orderTmpConstraintPool;
btAlignedObjectArray<int> m_orderNonContactConstraintPool;
btAlignedObjectArray<int> m_orderFrictionConstraintPool;
btAlignedObjectArray<btTypedConstraint::btConstraintInfo1> m_tmpConstraintSizesPool;
int m_maxOverrideNumSolverIterations;
int m_fixedBodyId;
btSingleConstraintRowSolver m_resolveSingleConstraintRowGeneric;
btSingleConstraintRowSolver m_resolveSingleConstraintRowLowerLimit;
void setupFrictionConstraint( btSolverConstraint& solverConstraint, const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,
btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,
btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation,
btScalar desiredVelocity=0., btScalar cfmSlip=0.);
void setupTorsionalFrictionConstraint( btSolverConstraint& solverConstraint, const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,
btManifoldPoint& cp,btScalar combinedTorsionalFriction, const btVector3& rel_pos1,const btVector3& rel_pos2,
btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation,
btScalar desiredVelocity=0., btScalar cfmSlip=0.);
btSolverConstraint& addFrictionConstraint(const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, btScalar desiredVelocity=0., btScalar cfmSlip=0.);
btSolverConstraint& addTorsionalFrictionConstraint(const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btManifoldPoint& cp,btScalar torsionalFriction, const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, btScalar desiredVelocity=0, btScalar cfmSlip=0.f);
void setupContactConstraint(btSolverConstraint& solverConstraint, int solverBodyIdA, int solverBodyIdB, btManifoldPoint& cp,
const btContactSolverInfo& infoGlobal,btScalar& relaxation, const btVector3& rel_pos1, const btVector3& rel_pos2);
static void applyAnisotropicFriction(btCollisionObject* colObj,btVector3& frictionDirection, int frictionMode);
void setFrictionConstraintImpulse( btSolverConstraint& solverConstraint, int solverBodyIdA,int solverBodyIdB,
btManifoldPoint& cp, const btContactSolverInfo& infoGlobal);
///m_btSeed2 is used for re-arranging the constraint rows. improves convergence/quality of friction
unsigned long m_btSeed2;
btScalar restitutionCurve(btScalar rel_vel, btScalar restitution);
virtual void convertContacts(btPersistentManifold** manifoldPtr, int numManifolds, const btContactSolverInfo& infoGlobal);
void convertContact(btPersistentManifold* manifold,const btContactSolverInfo& infoGlobal);
void resolveSplitPenetrationSIMD(
btSolverBody& bodyA,btSolverBody& bodyB,
const btSolverConstraint& contactConstraint);
void resolveSplitPenetrationImpulseCacheFriendly(
btSolverBody& bodyA,btSolverBody& bodyB,
const btSolverConstraint& contactConstraint);
//internal method
int getOrInitSolverBody(btCollisionObject& body,btScalar timeStep);
void initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject, btScalar timeStep);
btSimdScalar resolveSingleConstraintRowGeneric(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
btSimdScalar resolveSingleConstraintRowGenericSIMD(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
btSimdScalar resolveSingleConstraintRowLowerLimit(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
btSimdScalar resolveSingleConstraintRowLowerLimitSIMD(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
protected:
virtual void solveGroupCacheFriendlySplitImpulseIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
virtual btScalar solveGroupCacheFriendlyFinish(btCollisionObject** bodies,int numBodies,const btContactSolverInfo& infoGlobal);
virtual btScalar solveSingleIteration(int iteration, btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
virtual btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
btSequentialImpulseConstraintSolver();
virtual ~btSequentialImpulseConstraintSolver();
virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer,btDispatcher* dispatcher);
///clear internal cached data and reset random seed
virtual void reset();
unsigned long btRand2();
int btRandInt2 (int n);
void setRandSeed(unsigned long seed)
{
m_btSeed2 = seed;
}
unsigned long getRandSeed() const
{
return m_btSeed2;
}
virtual btConstraintSolverType getSolverType() const
{
return BT_SEQUENTIAL_IMPULSE_SOLVER;
}
btSingleConstraintRowSolver getActiveConstraintRowSolverGeneric()
{
return m_resolveSingleConstraintRowGeneric;
}
void setConstraintRowSolverGeneric(btSingleConstraintRowSolver rowSolver)
{
m_resolveSingleConstraintRowGeneric = rowSolver;
}
btSingleConstraintRowSolver getActiveConstraintRowSolverLowerLimit()
{
return m_resolveSingleConstraintRowLowerLimit;
}
void setConstraintRowSolverLowerLimit(btSingleConstraintRowSolver rowSolver)
{
m_resolveSingleConstraintRowLowerLimit = rowSolver;
}
///Various implementations of solving a single constraint row using a generic equality constraint, using scalar reference, SSE2 or SSE4
btSingleConstraintRowSolver getScalarConstraintRowSolverGeneric();
btSingleConstraintRowSolver getSSE2ConstraintRowSolverGeneric();
btSingleConstraintRowSolver getSSE4_1ConstraintRowSolverGeneric();
///Various implementations of solving a single constraint row using an inequality (lower limit) constraint, using scalar reference, SSE2 or SSE4
btSingleConstraintRowSolver getScalarConstraintRowSolverLowerLimit();
btSingleConstraintRowSolver getSSE2ConstraintRowSolverLowerLimit();
btSingleConstraintRowSolver getSSE4_1ConstraintRowSolverLowerLimit();
};
#endif //BT_SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
| [
"github@alexlitty.com"
] | github@alexlitty.com |
9b3249bb25758cacb95ff35a54c14f6891a2de22 | 1955334b1ebb919db4f7526d604ddbbd75d697f1 | /src/MageCore/Util/BitHacks.cpp | 61b9b0036e2efc2735e1142a445e6d89e789c5ea | [] | no_license | hydraskillz/NetworkShooter | 4fd89c2a311d758f7eaa240c12a25df30629eeb5 | ef3c1b76e957a2798695274d2e9458a9650a0bd7 | refs/heads/master | 2016-09-06T19:30:59.077515 | 2014-01-16T04:03:14 | 2014-01-16T04:03:14 | 15,957,046 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 44 | cpp | #include "CoreLib.h"
using namespace mage;
| [
"hydraskillz@gmail.com"
] | hydraskillz@gmail.com |
36be427789e98bf13eba8943005ad0bd0ac90b89 | 8672af5f4412dce8fe68a740dd555a8b0a283a5f | /Snake.h | b496dd6bb208c8fb596412e5f5b2b7d80aa01158 | [] | no_license | sang89/Hungry-Snake-Game | 13fd4e494286c5942a4b888c7a6b5bd0d4a95c77 | 8980004980ef3a8b6622bae91fd58b7d5a64386c | refs/heads/master | 2020-06-29T02:27:12.067474 | 2019-08-03T21:38:02 | 2019-08-03T21:38:02 | 200,411,624 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,816 | h | #ifndef SNAKE_H
#define SNAKE_H
#include "Square.h"
#include <vector>
#include "LTexture.h"
class Monster;
class Snake
{
public:
// Constructor
Snake();
// Overloaded constructor
Snake(int x, int y);
// Destructor
~Snake();
// Draw snake
void render();
// Move the snake
bool move(DIRECTION direction);
// Add square
void addSquare(DIRECTION direction, int n);
// Set head
void setHead(Square* head);
// Get tail
Square* getTail() const;
// Get head
Square* getHead() const;
// User controls the snake
void handleSnake(SDL_Event& e);
// Get the snake current direction
DIRECTION getMomentum() const;
// Check if the snake hits the playing screen
bool checkHitScreen() const;
// Check if the snake hits itself
bool checkHitItself() const;
// Check if the snake eats food
bool eatFood(const Square& food) const;
// Get tail momentum and add square after it (when the snake eats)
void addAfterEat();
// Get the snake's length
int getLength() const { return numSquares; }
// Get textures
virtual LTexture getBodyTexture() const;
virtual LTexture getHeadTexture() const;
// Check if snake hit a monster
bool hitMonster(const Monster& monster) const;
protected:
// Snake momentum
DIRECTION momentum;
// Head of the snake
Square* head;
// Number of squares
int numSquares;
// Body and head texture
LTexture bodyTexture;
LTexture headTexture;
};
// Monster class
class Monster : public Snake
{
public:
// Constructors
Monster();
Monster(int x, int y);
// Handle monster move
void handleMonster(const std::vector<Square>& bombs);
// Set sleep state for monster
void setSleep(bool sleep);
private:
// Sleep state
bool sleep;
};
#endif | [
"noreply@github.com"
] | sang89.noreply@github.com |
bd49f05d46771666fb2bcd9d420690da05372d25 | ac5d7af6801f4f97f138c1f354f7cb1b5fc336e1 | /traffic-simulator-extended/LivingCity/Geometry/parcelBuildingAttributes.h | 2af282b68607bb4c8a922181c3f2394914359620 | [
"BSD-3-Clause"
] | permissive | ual/DOE-repo-deliverable | 398cf3f1b145d205242a5970cd04963379805c28 | 4bafdd9a702a9a6466dd32ae62f440644d735d3c | refs/heads/master | 2020-03-07T03:06:20.981677 | 2018-09-29T00:15:17 | 2018-09-29T00:15:17 | 127,226,304 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,898 | h | //---------------------------------------------------------------------------------------------------------------------
// Copyright 2017, 2018 Purdue University, Ignacio Garcia Dorado, Daniel Aliaga
//
// 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 name of the copyright holder 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.
//---------------------------------------------------------------------------------------------------------------------
#pragma once
//#include "misctools.h"
//#include "global.h"
#include <QColor>
namespace LC{
//namespace geometry{
class ParcelBuildingAttributes
{
public:
ParcelBuildingAttributes(void);
~ParcelBuildingAttributes(void);
float att_stories; // number of stories
float att_footprint_area; // m^2 of building footprint
float att_frontage_width; // width of building front in m
float att_setback; // distance of building from road in m
float att_facades_area; // total area of the facade of the building
float att_orientation;
int att_building_type;
bool att_is_park;
bool att_is_landmark;
bool att_is_square;
QColor att_facade_color; // building main color
QColor att_roof_color; // building roof color
//LC::misctools::t_land_use myLandUse;
/**
* Copy constructor.
**/
ParcelBuildingAttributes(const ParcelBuildingAttributes &ref)
{
att_stories = ref.att_stories;
att_footprint_area = ref.att_footprint_area;
att_frontage_width = ref.att_frontage_width;
att_setback = ref.att_setback;
att_facades_area = ref.att_facades_area;
att_orientation = ref.att_orientation;
att_building_type = ref.att_building_type;
att_is_park = ref.att_is_park;
att_is_landmark = ref.att_is_landmark;
att_is_square = ref.att_is_square;
att_facade_color = ref.att_facade_color;
att_roof_color = ref.att_roof_color;
//myLandUse = ref.myLandUse;
}
/**
* Assignment operator.
**/
inline ParcelBuildingAttributes &operator=(const ParcelBuildingAttributes &ref)
{
att_stories = ref.att_stories;
att_footprint_area = ref.att_footprint_area;
att_frontage_width = ref.att_frontage_width;
att_setback = ref.att_setback;
att_facades_area = ref.att_facades_area;
att_orientation = ref.att_orientation;
att_building_type = ref.att_building_type;
att_is_park = ref.att_is_park;
att_is_landmark = ref.att_is_landmark;
att_is_square = ref.att_is_square;
att_facade_color = ref.att_facade_color;
att_roof_color = ref.att_roof_color;
//myLandUse = ref.myLandUse;
return (*this);
}
};
//}
}
| [
"gboeing@berkeley.edu"
] | gboeing@berkeley.edu |
aca2d77fb65c885cb577564d9899718e705f4617 | c6ee45e86bc7bbddb1e0b77a0c72b08204848146 | /wpilibsuite/allwpilib/wpilibc/shared/include/Commands/StartCommand.h | 2daa147526c7e8d9888a9cd53927da4269ebdfe2 | [
"BSD-3-Clause"
] | permissive | frc1678/third-party | 725e942cd68239f16ebc006e696d6ff4679d0fac | 27e0b79194bdcb0b15e52f2eef231a94654b50a3 | refs/heads/master | 2021-01-20T20:15:24.120483 | 2016-08-16T00:35:25 | 2016-08-16T00:35:25 | 61,973,483 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 848 | h | /*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2011-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#include "Commands/Command.h"
class StartCommand : public Command {
public:
StartCommand(Command* commandToStart);
virtual ~StartCommand() = default;
protected:
virtual void Initialize();
virtual void Execute();
virtual bool IsFinished();
virtual void End();
virtual void Interrupted();
private:
Command* m_commandToFork;
};
| [
"kylestach99@gmail.com"
] | kylestach99@gmail.com |
a3f1e93ad168234325d8a2f7c74d9be0871111f6 | 6e5f0fbfb1e5c3f61601d6fd4eb67e2f6e18c314 | /zlibrary/ui/src/symbian/view/ImageProvider.h | 107e49bf6def85ef7430849275f5e1223e99c654 | [] | no_license | ljo/FBReader | 46aae22f6437a7d27d1e85cd30361ad138b3797b | fcad069d18258d628077639ebe423cd1b473d111 | refs/heads/develop | 2020-12-25T20:32:31.806694 | 2017-02-15T08:20:16 | 2017-02-15T08:20:16 | 16,029,772 | 10 | 6 | null | 2020-07-21T20:54:26 | 2014-01-18T17:02:27 | C++ | UTF-8 | C++ | false | false | 1,834 | h | #ifndef __IMAGEPROVIDER_H__
#define __IMAGEPROVIDER_H__
#include <QtCore/QObject>
#include <QtCore/QRunnable>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QNetworkRequest>
#include <QtCore/QUrl>
#include <QtCore/QSet>
#include <QtGui/QPixmap>
#include <ZLTreeTitledNode.h>
#include <ZLImageManager.h>
Q_DECLARE_METATYPE(const ZLTreeTitledNode*)
Q_DECLARE_METATYPE(shared_ptr<ZLImage>)
class ImageRunnable : public QRunnable {
public:
ImageRunnable(const ZLTreeTitledNode *node, QObject *requester);
void run();
private:
QWeakPointer<QObject> myRequester;
const ZLTreeTitledNode *myNode;
};
class ImageProvider : public QObject {
Q_OBJECT
public:
enum Mode {
THUMBNAIL,
FULL
};
public:
static QUrl generateUrl(const ZLTreeTitledNode* node);
public:
ImageProvider(Mode mode, QObject* parent = 0);
public:
QPixmap getImageForNode(const ZLTreeTitledNode *titledNode);
signals:
void cacheUpdated() const;
private slots:
void onRequestFinished(QNetworkReply*);
void handleImageResult(const ZLTreeTitledNode *node, shared_ptr<ZLImage> image);
private:
QPixmap getZLImage(shared_ptr<ZLImage> image) const;
QPixmap getFSImage(QUrl imageUrl) const;
void getNetworkImage(QUrl url) const;
private:
QSize getImageSize() const;
void updateCache(QString cacheUrl, QPixmap pixmap);
private:
Mode myMode;
QMap<QString,QPixmap> myCache;
QSet<const ZLTreeTitledNode*> myProcessedNodes;
QPixmap myEmptyPixmap;
//TODO implement download manager in other class, or using ZLQtNetworkManager
mutable QNetworkAccessManager myManager;
//TODO cache should not be deleted after closing net library dialog (??)
};
#endif /* __IMAGEPROVIDER_H__ */
| [
"snowwlex@gmail.com"
] | snowwlex@gmail.com |
3c91ead4c404e251f1ec1dd9266d4d5be80efb89 | 44ab57520bb1a9b48045cb1ee9baee8816b44a5b | /EngineTesting/Code/System/SystemTesting/SecuritySuite/SecuritySid/CopySecurityIdentifierTesting.h | 16d9a6caaa83fde03e957c2b1f42da5bfee74517 | [
"BSD-3-Clause"
] | permissive | WuyangPeng/Engine | d5d81fd4ec18795679ce99552ab9809f3b205409 | 738fde5660449e87ccd4f4878f7bf2a443ae9f1f | refs/heads/master | 2023-08-17T17:01:41.765963 | 2023-08-16T07:27:05 | 2023-08-16T07:27:05 | 246,266,843 | 10 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,042 | h | /// Copyright (c) 2010-2023
/// Threading Core Render Engine
///
/// 作者:彭武阳,彭晔恩,彭晔泽
/// 联系作者:94458936@qq.com
///
/// 标准:std:c++20
/// 引擎测试版本:0.9.0.1 (2023/01/29 20:48)
#ifndef SYSTEM_SECURITY_SUITE_COPY_SECURITY_IDENTIFIER_TESTING_H
#define SYSTEM_SECURITY_SUITE_COPY_SECURITY_IDENTIFIER_TESTING_H
#include "SecuritySidTestingBase.h"
namespace System
{
class CopySecurityIdentifierTesting final : public SecuritySidTestingBase
{
public:
using ClassType = CopySecurityIdentifierTesting;
using ParentType = SecuritySidTestingBase;
public:
explicit CopySecurityIdentifierTesting(const OStreamShared& stream);
CLASS_INVARIANT_FINAL_DECLARE;
private:
void DoRunUnitTest() final;
void MainTest();
void CopySecurityIdentifierTest();
void DoCopySecurityIdentifierTest(SecuritySIDIndentifierAuthority& identifierAuthority);
};
}
#endif // SYSTEM_SECURITY_SUITE_COPY_SECURITY_IDENTIFIER_TESTING_H | [
"94458936@qq.com"
] | 94458936@qq.com |
3da310271c78d53a358abccdfa0036b094c1b432 | 01af78fbb7dcd83ab542723aac6fb44412415503 | /samsung_sw_mock_test/making_rome_number/making_rome_number.cpp | ed1945bec7f1555071e07c9a102225bd1aaed401 | [] | no_license | mcdaniel13/backjoon | 6db09877a7fa4d125c7562ab680dce9995d77e21 | 312c1954b89560724ab18a67fd0b3aa84660bcd5 | refs/heads/master | 2020-05-02T07:14:54.010934 | 2019-04-23T18:51:31 | 2019-04-23T18:51:31 | 177,812,990 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 764 | cpp | /*
* https://www.acmicpc.net/problem/16922
*/
#include <iostream>
using namespace std;
int n;
int arr[4];
int num[4] = {1, 5, 10 ,50};
bool visit[1001];
void init() {
for(int i = 0; i < 4; i++) {
arr[i] = 0;
}
for(int i = 0; i < 1001; i++) {
visit[i] = false;
}
}
void calculate() {
int total = 0;
for(int i = 0; i < 4; i ++) {
total += arr[i] * num[i];
}
visit[total] = true;
}
void solve(int cur, int num) {
if(cur == 3) {
arr[3] = num;
calculate();
return;
}
for(int i = 0; i <= num; i++) {
arr[cur] = i;
solve(cur + 1, num - i);
}
}
int counting() {
int cnt = 0;
for(int i = 0; i < 1001; i++) {
if(visit[i])
cnt++;
}
return cnt;
}
int main() {
cin >> n;
init();
solve(0, n);
cout << counting() << endl;
} | [
"whansrl92@gmail.com"
] | whansrl92@gmail.com |
61d93e6d4c422e63530aacfed88ec67fb87061db | 4d82c21c8928f8b7dc9887a900cd93a0c52dbedb | /q9.cc | d0ed21d24be4466116766643828dc301a7362018 | [] | no_license | ShraiLakshmanR/CN | 175cd9930d9d3bc94421a932664f9109ab3c6747 | 56e75722c53f8338b22c7145ffa0defaebfd2693 | refs/heads/master | 2020-09-10T02:12:42.443461 | 2020-03-27T11:52:02 | 2020-03-27T11:52:02 | 221,623,627 | 0 | 0 | null | 2019-11-14T06:02:13 | 2019-11-14T06:02:12 | null | UTF-8 | C++ | false | false | 3,836 | cc | #include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include "ns3/ipv4-global-routing-helper.h"
#include "ns3/csma-module.h"
using namespace ns3;
NS_LOG_COMPONENT_DEFINE("Second script example");
int main(int argc, char *argv[])
{
uint32_t nCsma=2;
LogComponentEnable("UdpEchoClientApplication",LOG_LEVEL_INFO);
LogComponentEnable("UdpEchoServerApplication",LOG_LEVEL_INFO);
NodeContainer p2pNodes;
p2pNodes.Create(3);
NodeContainer p2pNodes1;
p2pNodes1.Create(3);
NodeContainer csmaNodes;
csmaNodes.Add(p2pNodes.Get(2));
csmaNodes.Create(nCsma);
csmaNodes.Add(p2pNodes1.Get(0));
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute("DataRate",StringValue("5Mbps"));
pointToPoint.SetChannelAttribute("Delay",StringValue("2ms"));
PointToPointHelper pointToPoint1;
pointToPoint1.SetDeviceAttribute("DataRate",StringValue("5Mbps"));
pointToPoint1.SetChannelAttribute("Delay",StringValue("2ms"));
PointToPointHelper pointToPoint2;
pointToPoint2.SetDeviceAttribute("DataRate",StringValue("5Mbps"));
pointToPoint2.SetChannelAttribute("Delay",StringValue("2ms"));
PointToPointHelper pointToPoint3;
pointToPoint3.SetDeviceAttribute("DataRate",StringValue("5Mbps"));
pointToPoint3.SetChannelAttribute("Delay",StringValue("2ms"));
CsmaHelper csma;
csma.SetChannelAttribute("DataRate",StringValue("10Mbps"));
csma.SetChannelAttribute("Delay",TimeValue(NanoSeconds(6560)));
NetDeviceContainer p2pDevices;
p2pDevices=pointToPoint.Install(p2pNodes.Get(0),p2pNodes.Get(1));
std::cout<<"installed no and n1"<<std::endl;
NetDeviceContainer p2pDevices1;
p2pDevices1=pointToPoint1.Install(p2pNodes.Get(1),p2pNodes.Get(2));
std::cout<<"installed n1 and n2"<<std::endl;
NetDeviceContainer p2pDevices2;
p2pDevices2=pointToPoint2.Install(p2pNodes1.Get(0),p2pNodes1.Get(1));
std::cout<<"installed n4 and n5"<<std::endl;
NetDeviceContainer p2pDevices3;
p2pDevices3=pointToPoint3.Install(p2pNodes1.Get(1),p2pNodes1.Get(2));
std::cout<<"installed n5 and n6"<<std::endl;
NetDeviceContainer csmaDevices;
csmaDevices=csma.Install(csmaNodes);
InternetStackHelper stack;
stack.Install(p2pNodes);
stack.Install(csmaNodes.Get(1));
stack.Install(csmaNodes.Get(2));
stack.Install(p2pNodes1);
Ipv4AddressHelper address;
address.SetBase("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer p2pInterfaces;
p2pInterfaces=address.Assign(p2pDevices);
address.SetBase("10.1.2.0", "255.255.255.0");
Ipv4InterfaceContainer p2pInterfaces1;
p2pInterfaces1=address.Assign(p2pDevices1);
Ipv4AddressHelper address1;
address1.SetBase("30.1.2.0", "255.255.255.0");
Ipv4InterfaceContainer p2pInterfaces2;
p2pInterfaces2=address1.Assign(p2pDevices2);
address1.SetBase("30.1.3.0", "255.255.255.0");
Ipv4InterfaceContainer p2pInterfaces3;
p2pInterfaces3=address1.Assign(p2pDevices3);
Ipv4AddressHelper address3;
address3.SetBase("20.1.2.0", "255.255.255.0");
Ipv4InterfaceContainer csmaInterfaces;
csmaInterfaces=address3.Assign(csmaDevices);
UdpEchoServerHelper echoServer(9);
ApplicationContainer serverApps = echoServer.Install(csmaNodes.Get(0));
serverApps.Start(Seconds(1.0));
serverApps.Stop(Seconds(10.0));
UdpEchoClientHelper echoClient(csmaInterfaces.GetAddress(0),9);
echoClient.SetAttribute("MaxPackets", UintegerValue(1));
echoClient.SetAttribute("Interval",TimeValue(Seconds(1.0)));
echoClient.SetAttribute("PacketSize", UintegerValue(1024));
ApplicationContainer clientApps=echoClient.Install(p2pNodes.Get(1));
clientApps.Start(Seconds(2.0));
clientApps.Stop(Seconds(10.0));
Ipv4GlobalRoutingHelper::PopulateRoutingTables();
//pointToPoint.EnablePcapAll("second");
//csma.EnablePcap("second",csmaDevices.Get(1),true);
//pointToPoint1.EnablePcapAll("second");
Simulator::Run();
Simulator::Destroy();
return 0;
}
| [
"noreply@github.com"
] | ShraiLakshmanR.noreply@github.com |
d90513f934d66abf1db3aa40a8f558298968f425 | f1e40f0d5d5d96fdab4a0cb76f06a6ae9e3927cc | /final/workspace/speech/devel/include/tum_alle_common_msgs/msgHotwordCommand.h | a731a168fe59d9ea94c3703b65edf08b8e954403 | [] | no_license | Eddiesyn/RoboCup-Home | fedcda033a787ea8e451d53a930bdeb741c4de6d | 6d8e56a9186d29736e2464bee4b124536cb2878e | refs/heads/master | 2020-03-18T16:25:30.706778 | 2018-08-08T18:41:26 | 2018-08-08T18:41:26 | 134,964,590 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,019 | h | // Generated by gencpp from file tum_alle_common_msgs/msgHotwordCommand.msg
// DO NOT EDIT!
#ifndef TUM_ALLE_COMMON_MSGS_MESSAGE_MSGHOTWORDCOMMAND_H
#define TUM_ALLE_COMMON_MSGS_MESSAGE_MSGHOTWORDCOMMAND_H
#include <string>
#include <vector>
#include <map>
#include <ros/types.h>
#include <ros/serialization.h>
#include <ros/builtin_message_traits.h>
#include <ros/message_operations.h>
namespace tum_alle_common_msgs
{
template <class ContainerAllocator>
struct msgHotwordCommand_
{
typedef msgHotwordCommand_<ContainerAllocator> Type;
msgHotwordCommand_()
: command() {
}
msgHotwordCommand_(const ContainerAllocator& _alloc)
: command(_alloc) {
(void)_alloc;
}
typedef std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > _command_type;
_command_type command;
typedef boost::shared_ptr< ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator> const> ConstPtr;
}; // struct msgHotwordCommand_
typedef ::tum_alle_common_msgs::msgHotwordCommand_<std::allocator<void> > msgHotwordCommand;
typedef boost::shared_ptr< ::tum_alle_common_msgs::msgHotwordCommand > msgHotwordCommandPtr;
typedef boost::shared_ptr< ::tum_alle_common_msgs::msgHotwordCommand const> msgHotwordCommandConstPtr;
// constants requiring out of line definition
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator> >::stream(s, "", v);
return s;
}
} // namespace tum_alle_common_msgs
namespace ros
{
namespace message_traits
{
// BOOLTRAITS {'IsFixedSize': False, 'IsMessage': True, 'HasHeader': False}
// {'sensor_msgs': ['/opt/ros/kinetic/share/sensor_msgs/cmake/../msg'], 'geometry_msgs': ['/opt/ros/kinetic/share/geometry_msgs/cmake/../msg'], 'std_msgs': ['/opt/ros/kinetic/share/std_msgs/cmake/../msg'], 'tum_alle_common_msgs': ['/home/atHomeSS18/God-Watcher/workspace/speech/src/tum_alle_common_msgs/msg']}
// !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types']
template <class ContainerAllocator>
struct IsFixedSize< ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator> const>
: FalseType
{ };
template <class ContainerAllocator>
struct IsMessage< ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct HasHeader< ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator> const>
: FalseType
{ };
template<class ContainerAllocator>
struct MD5Sum< ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator> >
{
static const char* value()
{
return "cba5e21e920a3a2b7b375cb65b64cdea";
}
static const char* value(const ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0xcba5e21e920a3a2bULL;
static const uint64_t static_value2 = 0x7b375cb65b64cdeaULL;
};
template<class ContainerAllocator>
struct DataType< ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator> >
{
static const char* value()
{
return "tum_alle_common_msgs/msgHotwordCommand";
}
static const char* value(const ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator>&) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator> >
{
static const char* value()
{
return "# Contains the last hotword command recognised\n\
# By tum_alle_athome_speech_hotword published at:\n\
# \"/hotword_command\"\n\
# the command will be recognised when saying:\n\
# \"Tiago $COMMAND\", with command having the possible values of:\n\
# say, follow, bring, move, start, wait, move\n\
string command\n\
";
}
static const char* value(const ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator>&) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.command);
}
ROS_DECLARE_ALLINONE_SERIALIZER
}; // struct msgHotwordCommand_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::tum_alle_common_msgs::msgHotwordCommand_<ContainerAllocator>& v)
{
s << indent << "command: ";
Printer<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > >::stream(s, indent + " ", v.command);
}
};
} // namespace message_operations
} // namespace ros
#endif // TUM_ALLE_COMMON_MSGS_MESSAGE_MSGHOTWORDCOMMAND_H
| [
"sen.wang@tum.de"
] | sen.wang@tum.de |
14bfdbf22836a03e9fa13376ab740f130a99d5fc | 90047daeb462598a924d76ddf4288e832e86417c | /third_party/WebKit/Source/core/layout/LayoutButton.h | 56f2d81a2262f401a025cea2a374207610256164 | [
"LGPL-2.0-or-later",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.1-only",
"GPL-1.0-or-later",
"GPL-2.0-only",
"LGPL-2.0-only",
"BSD-2-Clause",
"LicenseRef-scancode-other-copyleft",
"BSD-3-Clause",
"MIT",
"Apache-2.0"
] | permissive | massbrowser/android | 99b8c21fa4552a13c06bbedd0f9c88dd4a4ad080 | a9c4371682c9443d6e1d66005d4db61a24a9617c | refs/heads/master | 2022-11-04T21:15:50.656802 | 2017-06-08T12:31:39 | 2017-06-08T12:31:39 | 93,747,579 | 2 | 2 | BSD-3-Clause | 2022-10-31T10:34:25 | 2017-06-08T12:36:07 | null | UTF-8 | C++ | false | false | 2,639 | h | /*
* Copyright (C) 2005 Apple Computer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef LayoutButton_h
#define LayoutButton_h
#include "core/editing/EditingUtilities.h"
#include "core/html/HTMLInputElement.h"
#include "core/layout/LayoutFlexibleBox.h"
namespace blink {
// LayoutButtons are just like normal flexboxes except that they will generate
// an anonymous block child.
// For inputs, they will also generate an anonymous LayoutText and keep its
// style and content up to date as the button changes.
class LayoutButton final : public LayoutFlexibleBox {
public:
explicit LayoutButton(Element*);
~LayoutButton() override;
const char* GetName() const override { return "LayoutButton"; }
bool IsOfType(LayoutObjectType type) const override {
return type == kLayoutObjectLayoutButton ||
LayoutFlexibleBox::IsOfType(type);
}
bool CanBeSelectionLeaf() const override {
return GetNode() && HasEditableStyle(*GetNode());
}
void AddChild(LayoutObject* new_child,
LayoutObject* before_child = nullptr) override;
void RemoveChild(LayoutObject*) override;
void RemoveLeftoverAnonymousBlock(LayoutBlock*) override {}
bool CreatesAnonymousWrapper() const override { return true; }
bool HasControlClip() const override;
LayoutRect ControlClipRect(const LayoutPoint&) const override;
int BaselinePosition(FontBaseline,
bool first_line,
LineDirectionMode,
LinePositionMode) const override;
private:
void UpdateAnonymousChildStyle(const LayoutObject& child,
ComputedStyle& child_style) const override;
bool HasLineIfEmpty() const override { return isHTMLInputElement(GetNode()); }
LayoutBlock* inner_;
};
DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutButton, IsLayoutButton());
} // namespace blink
#endif // LayoutButton_h
| [
"xElvis89x@gmail.com"
] | xElvis89x@gmail.com |
5f6ea9c71d1ef5c5b2e75007fbf94b65d141c681 | 9e41c0037601302e13aa8a71fbae2736c0d48249 | /apollo_13/include/apollo_13/CommonProperties.h | 761d9a8a3adef8dbbeff773a196f9fda89876c7e | [] | no_license | SiChiTong/Apollo_13 | bb6382b6f0437a40be447e9f2a3f4027ced781e1 | d5c2d2510111a3b6ca94e379e196679906aabd25 | refs/heads/master | 2021-04-06T02:31:09.437997 | 2017-01-20T18:04:22 | 2017-01-20T18:04:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,974 | h | /* Auto-generated by genmsg_cpp for file /home/pses/catkin_ws/src/rososc/touchosc_msgs/msg/CommonProperties.msg */
#ifndef TOUCHOSC_MSGS_MESSAGE_COMMONPROPERTIES_H
#define TOUCHOSC_MSGS_MESSAGE_COMMONPROPERTIES_H
#include <string>
#include <vector>
#include <map>
#include <ostream>
#include "ros/serialization.h"
#include "ros/builtin_message_traits.h"
#include "ros/message_operations.h"
#include "ros/time.h"
#include "ros/macros.h"
#include "ros/assert.h"
namespace touchosc_msgs
{
template <class ContainerAllocator>
struct CommonProperties_ {
typedef CommonProperties_<ContainerAllocator> Type;
CommonProperties_()
: tabpage()
, name()
, x(0)
, y(0)
, width(0)
, height(0)
, visible()
, color()
{
}
CommonProperties_(const ContainerAllocator& _alloc)
: tabpage(_alloc)
, name(_alloc)
, x(0)
, y(0)
, width(0)
, height(0)
, visible(_alloc)
, color(_alloc)
{
}
typedef std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > _tabpage_type;
std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > tabpage;
typedef std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > _name_type;
std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > name;
typedef int16_t _x_type;
int16_t x;
typedef int16_t _y_type;
int16_t y;
typedef uint16_t _width_type;
uint16_t width;
typedef uint16_t _height_type;
uint16_t height;
typedef std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > _visible_type;
std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > visible;
typedef std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > _color_type;
std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > color;
typedef boost::shared_ptr< ::touchosc_msgs::CommonProperties_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::touchosc_msgs::CommonProperties_<ContainerAllocator> const> ConstPtr;
}; // struct CommonProperties
typedef ::touchosc_msgs::CommonProperties_<std::allocator<void> > CommonProperties;
typedef boost::shared_ptr< ::touchosc_msgs::CommonProperties> CommonPropertiesPtr;
typedef boost::shared_ptr< ::touchosc_msgs::CommonProperties const> CommonPropertiesConstPtr;
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::touchosc_msgs::CommonProperties_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::touchosc_msgs::CommonProperties_<ContainerAllocator> >::stream(s, "", v);
return s;}
} // namespace touchosc_msgs
namespace ros
{
namespace message_traits
{
template<class ContainerAllocator> struct IsMessage< ::touchosc_msgs::CommonProperties_<ContainerAllocator> > : public TrueType {};
template<class ContainerAllocator> struct IsMessage< ::touchosc_msgs::CommonProperties_<ContainerAllocator> const> : public TrueType {};
template<class ContainerAllocator>
struct MD5Sum< ::touchosc_msgs::CommonProperties_<ContainerAllocator> > {
static const char* value()
{
return "2c6057f4de35b509307640ef1d0f3aac";
}
static const char* value(const ::touchosc_msgs::CommonProperties_<ContainerAllocator> &) { return value(); }
static const uint64_t static_value1 = 0x2c6057f4de35b509ULL;
static const uint64_t static_value2 = 0x307640ef1d0f3aacULL;
};
template<class ContainerAllocator>
struct DataType< ::touchosc_msgs::CommonProperties_<ContainerAllocator> > {
static const char* value()
{
return "touchosc_msgs/CommonProperties";
}
static const char* value(const ::touchosc_msgs::CommonProperties_<ContainerAllocator> &) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::touchosc_msgs::CommonProperties_<ContainerAllocator> > {
static const char* value()
{
return "# Common functionality to all TouchOSC controls\n\
\n\
string tabpage # Control tabpage\n\
string name # Control Name\n\
int16 x # X position of the control\n\
int16 y # Y position of the control\n\
uint16 width # Width of the control\n\
uint16 height # Height of the control\n\
string visible # Visibility of the control\n\
\n\
# Possible colors are:\n\
# \"red\", \"green\", \"blue\", \"yellow\", \"orange\", \"purple\", \"gray\"\n\
string color # Color of the control\n\
\n\
";
}
static const char* value(const ::touchosc_msgs::CommonProperties_<ContainerAllocator> &) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::touchosc_msgs::CommonProperties_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.tabpage);
stream.next(m.name);
stream.next(m.x);
stream.next(m.y);
stream.next(m.width);
stream.next(m.height);
stream.next(m.visible);
stream.next(m.color);
}
ROS_DECLARE_ALLINONE_SERIALIZER;
}; // struct CommonProperties_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::touchosc_msgs::CommonProperties_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::touchosc_msgs::CommonProperties_<ContainerAllocator> & v)
{
s << indent << "tabpage: ";
Printer<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > >::stream(s, indent + " ", v.tabpage);
s << indent << "name: ";
Printer<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > >::stream(s, indent + " ", v.name);
s << indent << "x: ";
Printer<int16_t>::stream(s, indent + " ", v.x);
s << indent << "y: ";
Printer<int16_t>::stream(s, indent + " ", v.y);
s << indent << "width: ";
Printer<uint16_t>::stream(s, indent + " ", v.width);
s << indent << "height: ";
Printer<uint16_t>::stream(s, indent + " ", v.height);
s << indent << "visible: ";
Printer<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > >::stream(s, indent + " ", v.visible);
s << indent << "color: ";
Printer<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > >::stream(s, indent + " ", v.color);
}
};
} // namespace message_operations
} // namespace ros
#endif // TOUCHOSC_MSGS_MESSAGE_COMMONPROPERTIES_H
| [
"aceronicolas@hotmail.com"
] | aceronicolas@hotmail.com |
be95c1b36cf0a468b10c633919bd4b72efc31f03 | ff1f8e352bcbf059e2c1c0aaafff120c56f3cf49 | /SXOJ/SXOJ17.cpp | b609aecb3ce96f1e04bc900463b3e598bda3fc78 | [] | no_license | keywet06/code | 040bc189fbabd06fc3026525ae3553cd4f395bf3 | fe0d570144e580f37281b13fd4106438d3169ab9 | refs/heads/master | 2022-12-19T12:12:16.635994 | 2022-11-27T11:39:29 | 2022-11-27T11:39:29 | 182,518,309 | 6 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,548 | cpp | #include <bits/stdc++.h>
using uint64 = unsigned long long;
const int E = 37;
const int N = 1000005;
int T, n, l, r, mid;
uint64 hs[N], pre[N];
std::string s;
std::unordered_set<uint64> set;
inline uint64 hash(int l, int r) { return hs[r] - hs[l - 1] * pre[r - l + 1]; }
int main() {
std::ios::sync_with_stdio(0);
std::cin.tie(0), std::cout.tie(0);
std::cin >> T;
while (T--) {
std::cin >> s, n = s.length(), s = ' ' + s, pre[0] = 1;
for (int i = 1; i <= n; ++i) {
hs[i] = hs[i - 1] * E + s[i];
pre[i] = pre[i - 1] * E;
}
set.clear(), set.insert(0);
for (int i = 1; i <= n >> 1; ++i) {
l = 0, r = i;
while (l < r) {
mid = l + r + 1 >> 1;
if (hash(1, mid) == hash(i + 1, i + mid)) {
l = mid;
} else {
r = mid - 1;
}
}
if (hash(l + 1, i) == hash(n - i + l + 1, n)) {
set.insert(hash(1, i));
}
l = 0, r = i;
while (l < r) {
mid = l + r + 1 >> 1;
if (hash(1, mid) == hash(n - i + 1, n - i + mid)) {
l = mid;
} else {
r = mid - 1;
}
}
if (hash(n - i + l + 1, n) == hash(n - i - i + l + 1, n - i)) {
set.insert(hash(n - i + 1, n));
}
}
std::cout << set.size() << '\n';
}
return 0;
} | [
"keywet06@tom.com"
] | keywet06@tom.com |
b18f301ea190ed1e0e46a6a60a67f2b3d1d8274b | f0b98ec52aaadb19b9f59886b39324d9a8472e34 | /2019-10-18-arreglos/array1.cpp | a9bdad7b33e18bc4498b6686fb439a1b531d665e | [] | no_license | mmesap/Prog | 0aba2c19140f6f21b96fef19190a47f60bfe0ebc | cd5f18b17060a17ac5c2bf9e04fb6fbcc5876e1f | refs/heads/master | 2021-06-21T16:46:25.913078 | 2021-03-01T03:44:01 | 2021-03-01T03:44:01 | 206,789,854 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 119 | cpp | #include <iostream>
int main()
{
int billy [5] = {1};
std::cout << billy[1] << "\n";
billy [2]=7;
return 0;
}
| [
"mmesap@darkstar.org"
] | mmesap@darkstar.org |
4d58f7b596fab831f0f9bcba09f36a6d6f67d0fd | e2a7a60e13303bde79e926d45fb75aa430c3a596 | /11878.cpp | 8bdbbfab2f610dd7a5fda83c51b597681d10f542 | [] | no_license | jonathandarryl/UVa-Code | 9ab900ee87e67469ffaa753ae57e070ed60d0b8c | 0cbe8b6e091fc699abba25cbd72ebf1aa9e1709d | refs/heads/master | 2016-09-05T15:45:46.105512 | 2015-01-08T05:16:31 | 2015-01-08T05:16:31 | 27,748,480 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 983 | cpp | #include<iostream>
#include<string.h>
using namespace std;
int main(void){
string input;
char rem;
int in1, in2, res;
int track, right = 0;
while(cin>>input){
track = in1 = in2 = res = 0;
while(input.at(track)>='0' && input.at(track)<='9'){
in1*=10;
in1+=input.at(track) -'0';
track++;
}
rem = input.at(track);
track++;
while(input.at(track)>='0' && input.at(track)<='9'){
in2*=10;
in2+=input.at(track) -'0';
track++;
}
track++;
for(int i=track;i<input.length();i++){
if(input.at(track)=='?')
res = -10000000l;
else{
res*=10;
res+=input.at(i)-'0';
}
}
if(rem=='+')
in1+=in2;
if(rem=='-')
in1-=in2;
if(in1==res)
right++;
}
cout<<right<<endl;
return 0;
}
| [
"jonathandarrylw@gmail.com"
] | jonathandarrylw@gmail.com |
2067dbcfd27ac86a6d43130e2e0acc2a1076daa2 | 44631c3fbb32eec79ec89049c6ae2ab6a4bf431a | /unit2/program_design.cpp | b82beb62189af98955e411906c29dc8299101b54 | [] | no_license | jackliaoontheway/cpp_exam_practice | 40bb1a92c891022683f4c34726eb4cb70a86b8aa | 58f43c242ad32e265afde797f8843b83020e2a4b | refs/heads/master | 2021-01-14T21:01:56.066268 | 2020-04-12T00:00:09 | 2020-04-12T00:00:09 | 242,758,917 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 303 | cpp | #include <iostream>
#include "Mx.h"
using namespace std;
Mx operator + (Mx &a, Mx &b) {
Mx c;
for(int i = 0;i < 2; i++) {
for(int j = 0; j < 3; j++) {
c.m[i][j] = a.m[i][j] + b.m[i][j];
}
}
return c;
}
int main() {
Mx a,b,c;
a.input();
b.input();
c = a + b;
c.show();
return 0;
}
| [
"ldhontheway@live.com"
] | ldhontheway@live.com |
7db93740dca62cafb1b75f33308446711e3e1ced | d41db05c6e70df03d48e5210755d0dea99cb72bf | /dependencies/probt_spl_2_3_99/include/plCndUnknown.h | b92dd0ba4c5c06f1251f83dec1402e0cd28b8035 | [] | no_license | samogwas/samogwas | f035a17981fa4fead254dd456f249249c44f49a4 | 7d98883814e2f2d12dee754cca4ae023e07fa097 | refs/heads/master | 2016-09-08T01:42:07.577903 | 2015-07-21T10:06:56 | 2015-07-21T10:06:56 | 34,456,818 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,598 | h | /*=============================================================================
* Product : ProBT
* File : plCndUnknown.h
* Author : Emmanuel Mazer
* Creation : July 6 :08:40 2001
*
*=============================================================================
* (c) Copyright 2000, Centre National de la Recherche Scientifique,
* all rights reserved
*=============================================================================
*
*------------------------- Description ---------------------------------------
*
*
*-----------------------------------------------------------------------------
*/
#ifndef plCndUnknown_h
#define plCndUnknown_h
#include "plConfig.h"
#include <plCndDistribution.h>
#include <plDistribution.h>
/*****************************************************************************
* Classes Definitions
*****************************************************************************/
/** This class allows defining an unknown distribution on a set of variables \em left knowing
an other set of variables \em right.
*/
class PL_DLL_API plCndUnknown : public plCndDistribution
{
public:
/** Empty constructor */
plCndUnknown();
/** Construct an unknown conditional distribution.
Unknown conditional distribution are used for to provide the user with a
formal way of writing correct decomposition, but are not intended to
produce any numerical results (i.e the inferred expressions do not
contain the P(v) term). All methods applied to this distribution will
result into an error. Excepted for the method instantiate which will
return an Unknown distribution. Unknown distribution are used to build
descriptions (joint distributions). Inference (using "ask" method) using
this joint distribution should always contain all the set of "left"
variables into their known variables. \param left is the set of
variables on which the distribution applies. \param right is the set of
variables which conditionalize the distribution.
*/
plCndUnknown(const plVariablesConjunction& left,
const plVariablesConjunction& right);
/** Destructor */
virtual ~plCndUnknown(){};
/** Promote from a plCndDistribution. If the object being copied is
actually of the wrong type, an exception is raised.
*/
explicit plCndUnknown(const plCndDistribution&);
};
#endif
// Local Variables:
// mode: c++
// indent-tabs-mode: nil
// c-basic-offset: 2
// fill-column: 79
// End:
| [
"thanh.phan@outlook.com"
] | thanh.phan@outlook.com |
a11692e6fd82a79e675826034f739419f80a239e | 999fdf150a93dc69d920786641fc9cd8e83f2a75 | /src/oraifutils/opencl/oraOpenCLWrapper.h | 6ac7d931b903290299766b949c66c6a19fa36c00 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | agravgaard/Plastimatch | f79294947a1d44dd0c56798277374222fa92df57 | 7b5b79bb1a258d69a653bc82849ed420e673de3d | refs/heads/master | 2021-01-17T06:53:30.814597 | 2020-08-21T12:51:14 | 2020-08-21T12:51:14 | 52,898,082 | 11 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 596 | h | #ifndef ORAOPENCLWRAPPER_H_
#define ORAOPENCLWRAPPER_H_
// allow c++ like exceptions for openCL functions
#define __CL_ENABLE_EXCEPTIONS
// opencl
#include <CL/cl.hpp>
// std
#include <vector>
#include <iostream>
namespace ora
{
/*
* oraOpenCLWrapper.h
*/
class OpenCLWrapper
{
public:
typedef OpenCLWrapper self;
OpenCLWrapper();
~OpenCLWrapper();
bool Initalize();
bool CommitKernel(int *a, int *b, int *c, int bufferSize);
protected:
/**
*
*/
std::vector<cl::Platform> m_PlatformList;
cl_uint m_PlatformNum;
private:
};
}
#endif /* ORAOPENCLWRAPPER_H_ */
| [
"andreasga22@gmail.com"
] | andreasga22@gmail.com |
a0343fe84cf91c87bf84c83fd8e47daef941ea20 | fea03f3156797a87a0578ee5e97f2ac397eeb1e6 | /C++/study/concept/example/example_01.cpp | 29b4143c6f3c65a1e12137fc22c03d80458a1150 | [] | no_license | dduynam/tutorial | 0649f1d37e05a444f495f6cd9df8fe8c0f980a58 | 7b91268207e8f608df9196eb9d7f48b61a3c45ab | refs/heads/main | 2023-07-15T03:28:53.135038 | 2021-08-30T16:34:08 | 2021-08-30T16:34:24 | 392,336,487 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 403 | cpp | #include <iostream>
#include <math.h>
using namespace std;
int main()
{
int res = 0;
int n = -5;
cout << pow(2, 3) << endl;
for (unsigned int i = 0; i < n; ++i)
{
res = i;
//cout << res << endl;
if (i == 100)
{
cout << "n: " << n << endl;
break;
}
}
cout << res << endl;
//cout << n << endl;
return 0;
} | [
"nam2.do@lge.com"
] | nam2.do@lge.com |
f2a20a4174f6afcf001a84b8e3d8c564617a7964 | 36c525cd82caeafffa32f2042058e94774d60a3e | /main.cpp | 2a6f22094885759672bb7fd0bb7813634d8ce1b6 | [] | no_license | stamhoffman/algorithms | 1d7ee84eb9c0eb9b8f72498c0475a6fd83b85d13 | 74c4e748ad52630169e80c5c5bf188ae23f890a5 | refs/heads/master | 2020-12-20T07:06:11.692840 | 2020-02-19T20:07:59 | 2020-02-19T20:07:59 | 235,996,332 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 346 | cpp | #include "bst.h"
#include "function.h"
using namespace function;
using namespace bst;
int main() {
BST bst(5);
bst.Insert(3);
bst.Insert(6);
bst.Insert(8);
bst.Insert(9);
bst.Insert(15);
bst.Insert(10);
bst.Insert(3);
bst.Insert(1);
bst.Insert(4);
bst.Insert(2);
auto root = bst.Traverse(bst.root_node_);
return 0;
}
| [
"stamhoffman@yandex.ru"
] | stamhoffman@yandex.ru |
0fe693105836da2572b56eb7138bf16e7e6359ff | b7f3edb5b7c62174bed808079c3b21fb9ea51d52 | /gpu/command_buffer/tests/texture_image_factory.h | 82509cbe2080b710b9183b09c81ad570db700002 | [
"BSD-3-Clause"
] | permissive | otcshare/chromium-src | 26a7372773b53b236784c51677c566dc0ad839e4 | 64bee65c921db7e78e25d08f1e98da2668b57be5 | refs/heads/webml | 2023-03-21T03:20:15.377034 | 2020-11-16T01:40:14 | 2020-11-16T01:40:14 | 209,262,645 | 18 | 21 | BSD-3-Clause | 2023-03-23T06:20:07 | 2019-09-18T08:52:07 | null | UTF-8 | C++ | false | false | 1,506 | h | // Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GPU_COMMAND_BUFFER_TESTS_TEXTURE_IMAGE_FACTORY_H_
#define GPU_COMMAND_BUFFER_TESTS_TEXTURE_IMAGE_FACTORY_H_
#include "gpu/command_buffer/service/image_factory.h"
namespace gpu {
// The images created by this factory have no inherent storage. When the image
// is bound to a texture, storage is allocated for the texture via glTexImage2D.
class TextureImageFactory : public gpu::ImageFactory {
public:
scoped_refptr<gl::GLImage> CreateImageForGpuMemoryBuffer(
gfx::GpuMemoryBufferHandle handle,
const gfx::Size& size,
gfx::BufferFormat format,
int client_id,
SurfaceHandle surface_handle) override;
bool SupportsCreateAnonymousImage() const override;
scoped_refptr<gl::GLImage> CreateAnonymousImage(const gfx::Size& size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
SurfaceHandle surface_handle,
bool* is_cleared) override;
unsigned RequiredTextureType() override;
bool SupportsFormatRGB() override;
void SetRequiredTextureType(unsigned type);
private:
unsigned required_texture_type_ = 0;
};
} // namespace gpu
#endif // GPU_COMMAND_BUFFER_TESTS_TEXTURE_IMAGE_FACTORY_H_
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
61b354ef1215fcfd44e5471661302389b7099c54 | 2cba5b3a723bce26d22d0fa8995c0ffb95769331 | /Bài 1/Bai1.cpp | dfc0dfdd440945cba1f2fc941fc51e379ff8b4b0 | [] | no_license | tranlongthien/Game-bau-cua | c51999f676f173f06e1e42334876d80b1a1fbd70 | 3fbe87ea92a0d377abc21d4a38c17001a3c02084 | refs/heads/master | 2021-05-03T10:28:30.302312 | 2017-06-07T14:56:54 | 2017-06-07T14:56:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,677 | cpp | //Nhap vao hai phan so. Tinh tong hieu tich thuong vaf xuat ra ket qua o dang rut gon???
#include <iostream>
using namespace std;
int main()
{
int t1, t2, m1, m2, a, b, c, d;
int tong, hieu, tich, tuthuong, mauthuong, mautong, mauhieu, mautich;
do{
cout << "\nNhap vao tu so cua phan so thu nhat: ";
cin >> t1;
cout << "\nNhap vao mau so cua phan so thu nhat: ";
cin >> m1;
cout << "\nNhap vao tu so cua phan so thu hai: ";
cin >> t2 ;
cout << "\nNhap vao mau so cua phan so thu hai: ";
cin >> m2;
if (m1 == 0 || m2 == 0)
{
cout << "\nMau so phai khac 0! Hay kiem tra lai!";
}
} while (m1 == 0 || m2 == 0);
//Tong
tong = t1*m2 + t2*m1;
mautong = m1*m2;
for (int i = 1;; ++i)
{
int t = tong % mautong;
tong = mautong;
mautong = t;
if (t == 0)
{
a = fabs((double)tong);
break;
}
}
if (((m1*m2) / a))
{
cout << "\nTong cua hai phan so " << t1 << "/" << m1 << " va " << t2 << "/" << m2 << " la: " << ((t1*m2 + t2*m1) / a);
}
else
{
cout << "\nTong cua hai phan so " << t1 << "/" << m1 << " va " << t2 << "/" << m2 << " la: " << ((t1*m2 + t2*m1) / a) << "/" << ((m1*m2) / a);
}
//Hieu
hieu = t1*m2 - t2*m1;
mauhieu = m1*m2;
for (int i = 1;; ++i)
{
int t = hieu % mauhieu;
hieu = mauhieu;
mauhieu = t;
if (t == 0)
{
b = fabs((double)hieu);
break;
}
}
if (((m1*m2) / b) == 1)
{
cout << "\nHieu cua hai phan so " << t1 << "/" << m1 << " va " << t2 << "/" << m2 << " la: " << ((t1*m2 - t2*m1) / b);
}
else
{
cout << "\nHieu cua hai phan so " << t1 << "/" << m1 << " va " << t2 << "/" << m2 << " la: " << ((t1*m2 - t2*m1) / b) << "/" << ((m1*m2) / b);
}
//Tich
tich = t1*t2;
mautich = m1*m2;
for (int i = 1;; ++i)
{
int t = tich % mautich;
tich = mautich;
mautich = t;
if (t == 0)
{
c = fabs((double)tich);
break;
}
}
if (((m1*m2) / c) == 1)
{
cout << "\nTich cua hai phan so " << t1 << "/" << m1 << " va " << t2 << "/" << m2 << " la: " << ((t1*t2) / c);
}
else
{
cout << "\nTich cua hai phan so " << t1 << "/" << m1 << " va " << t2 << "/" << m2 << " la: " << ((t1*t2) / c) << "/" << ((m1*m2) / c);
}
//Thuong
tuthuong = t1*m2;
mauthuong = m1*t2;
for (int i = 1;; ++i)
{
int t = tuthuong % mauthuong;
tuthuong = mauthuong;
mauthuong = t;
if (t == 0)
{
d = fabs((double)tuthuong);
break;
}
}
if (((m1*t2) / d) == 1)
{
cout << "\nThuong cua hai phan so " << t1 << "/" << m1 << " va " << t2 << "/" << m2 << " la: " << ((t1*m2) / d);
}
else
{
cout << "\nThuong cua hai phan so " << t1 << "/" << m1 << " va " << t2 << "/" << m2 << " la: " << ((t1*m2) / d) << "/" << ((m1*t2) / d);
}
system("pause");
return 0;
} | [
"sonkun246@gmail.com"
] | sonkun246@gmail.com |
9c4e7440d705e0f51b5fb610a2d74603a072e726 | 7b277abc452923a6b75eaacfba77142ebcf8dfee | /NaoCodeBackup/UTNaoTool/calibration/JointCalibrator.cpp | f7d053685097f2817425d0389fd335956f8892b0 | [] | no_license | sbha2431/Abstractions-Learning | 26ad5848e69e1436bffc2988cc68755e2bd39ee0 | 4ad7ed5a9ea1a942263fca27ae4a1bc9a1e03f91 | refs/heads/master | 2020-05-25T11:30:48.617375 | 2019-02-27T17:46:20 | 2019-02-27T17:46:20 | 83,600,277 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 11,197 | cpp | #include "JointCalibrator.h"
#include <memory/MemoryFrame.h>
#include <memory/MemoryCache.h>
#include <memory/LogViewer.h>
#include <vision/ImageProcessor.h>
#include <math/GaussNewtonOptimizer.h>
#define OPTIMIZE_POSITION false
using namespace std;
using namespace Eigen;
using Corners = JointCalibrator::Corners;
std::vector<int> rjointMap = {
HeadYaw,
HeadPitch,
RHipYawPitch,
RHipRoll,
RHipPitch,
RKneePitch,
RAnklePitch,
RAnkleRoll
};
std::vector<int> ljointMap = {
HeadYaw,
HeadPitch,
LHipYawPitch,
LHipRoll,
LHipPitch,
LKneePitch,
LAnklePitch,
LAnkleRoll
};
std::vector<float> weights = {
1.0f,
1.0f,
1.0f,
1.0f,
1.0f,
1.0f,
1.0f,
1.0f,
100.0f,
100.0f,
100.0f,
1.0f
};
JCSettings::JCSettings() {
boardOffset = 165.0f;
squareSize = 25.0f;
boardSize.width = 6;
boardSize.height = 4;
corners = 24;
oX = oY = 0;
oZ = -3;
oT = 0;
}
JointCalibrator::JointCalibrator() {
memory_ = std::make_unique<MemoryFrame>(false, MemoryOwner::TOOL_MEM, 0, 1);
//printf("creating cache\n");
cache_ = std::make_unique<MemoryCache>();
//printf("creating blocks\n");
vblocks_ = std::make_unique<VisionBlocks>(*cache_);
//printf("creating params\n");
params_ = std::make_unique<ImageParams>(Camera::BOTTOM);
//printf("creating processor\n");
processor_ = std::make_unique<ImageProcessor>(*vblocks_, *params_, Camera::BOTTOM);
processor_->enableCalibration(true);
datafile_ = string(getenv("NAO_HOME")) + "/data/jcalibration.yaml";
reset();
}
JointCalibrator::~JointCalibrator() {
stop();
}
void JointCalibrator::reset() {
cal_ = std::make_unique<RobotCalibration>();
processor_->setCalibration(*cal_);
stop();
}
void JointCalibrator::stop() {
calibrating_ = false;
if(thread_) {
thread_->join();
thread_.reset();
}
}
void JointCalibrator::start(int iterations, function<void()> callback) {
if(thread_) {
thread_->join();
thread_.reset();
}
calibrating_ = true;
thread_ = std::make_unique<std::thread>(&JointCalibrator::calibrate, (JointCalibrator*)this, iterations, callback);
}
void JointCalibrator::pause() {
calibrating_ = false;
//TODO: fill in
}
void JointCalibrator::setCalibration(const RobotCalibration& cal) {
cal_ = std::make_unique<RobotCalibration>(cal);
processor_->setCalibration(*cal_);
processor_->updateTransform();
}
void JointCalibrator::setMemory(MemoryFrame* memory) {
//memory_ = std::make_unique<MemoryFrame>(*memory);
//memory_ = memory;
cache_->fill(memory);
processor_->updateTransform();
}
void JointCalibrator::takeSamples(LogViewer* log) {
printf("getting samples\n");
Dataset dataset;
for(int i = 0; i < log->size(); i++) {
auto& frame = log->getFrame(i);
cache_->fill(frame);
auto m = takeSample(&frame);
printf("found %lu corners in frame %i\n", m.corners.size(), i);
if(m.corners.size() != settings_.corners) continue;
dataset.push_back(m);
}
dataset.saveToFile(datafile_);
}
JointCalibrator::Measurement JointCalibrator::takeSample(MemoryFrame* frame) {
unsigned char* imgraw = processor_->getImg();
const ImageParams& iparams = processor_->getImageParams();
cv::Mat cvimage = color::rawToMat(imgraw, iparams);
Measurement m;
m.left = left();
m.corners = findChessboardCorners(cvimage);
if(m.corners.size() == 0) return m;
MemoryCache cache(frame);
for(int i = 0; i < jointMap().size(); i++)
m.joints.push_back(cache.joint->values_[jointMap()[i]]);
return m;
}
void JointCalibrator::calibrate(int iterations, function<void()> callback) {
cache_->fill(*memory_);
Dataset dataset;
dataset.loadFromFile(datafile_);
vector<float> iparams = convertParams(*cal_);
GaussNewtonOptimizer<Measurement,JointCalibrator> optimizer(iparams, dataset, *this, &JointCalibrator::evaluate);
printf("created optimizer\n");
for(int i = 0; i < iterations; i++) {
if(!calibrating_) break;
error_ = optimizer.iterate();
printf("ITERATION CHANGE: %2.5f\n", error_);
auto params = optimizer.getParameters();
printf("ITERATION ERROR: %2.5f\n", evaluate(dataset, params));
if(error_ < .01) break;
}
printf("\n--------------------------------------\n");
auto params = optimizer.getParameters();
*cal_ = convertParams(params);
callback();
}
vector<float> JointCalibrator::convertParams(const RobotCalibration& cal) const {
printf("start!\n");
vector<float> offsets;
for(int i = 0; i < jointMap().size(); i++) {
offsets.push_back(cal.jointValues_[jointMap()[i]] / weights[i]);
}
printf("poses\n");
if(OPTIMIZE_POSITION) {
offsets.push_back(cal.poseX / weights[jointMap().size()]);
offsets.push_back(cal.poseY / weights[jointMap().size() + 1]);
offsets.push_back(cal.poseZ / weights[jointMap().size() + 2]);
offsets.push_back(cal.poseTheta / weights[jointMap().size() + 3]);
}
printf("done: %lu\n",offsets.size());
return offsets;
}
RobotCalibration JointCalibrator::convertParams(const vector<float>& offsets) const {
RobotCalibration cal;
cal.useLeft = left();
//printf("applying offsets:\n");
for(int i = 0; i < jointMap().size(); i++) {
//printf("[%s:%2.5f],",JointNames[jointMap()[i]].c_str(),offsets[i]);
cal.jointValues_[jointMap()[i]] = offsets[i] * weights[i];
}
if(OPTIMIZE_POSITION) {
cal.poseX = offsets[jointMap().size()] * weights[jointMap().size()];
cal.poseY = offsets[jointMap().size() + 1] * weights[jointMap().size() + 1];
cal.poseZ = offsets[jointMap().size() + 2] * weights[jointMap().size() + 2];
cal.poseTheta = offsets[jointMap().size() + 3] * weights[jointMap().size() + 3];
} else {
cal.poseX = settings_.oX;
cal.poseY = settings_.oY;
cal.poseZ = settings_.oZ;
cal.poseTheta = settings_.oT;
}
//printf("pose offset: %2.3f,%2.3f,%2.3f @ %2.f", cal.poseX, cal.poseY, cal.poseZ, cal.poseTheta * RAD_T_DEG);
//printf("\n");
return cal;
}
float JointCalibrator::evaluate(const Dataset& d, const vector<float>& offsets) const {
float sqerror = 0;
for(auto m : d) {
sqerror += pow(evaluate(m,offsets),2);
}
return sqrt(sqerror / d.size());
}
float JointCalibrator::evaluate(const Measurement& m, const vector<float>& offsets) const {
*cal_ = convertParams(offsets);
cal_->useLeft = m.left; // This is redundant, just want to avoid mistakes
for(int i = 0; i < jointMap().size(); i++) {
assert(m.joints.size() == jointMap().size());
cache_->joint->values_[jointMap()[i]] = m.joints[i];
}
processor_->setCalibration(*cal_);
processor_->updateTransform();
//printf("projecting corners\n");
auto pcorners = projectChessboardCorners(m.left);
//printf("computing projection error\n");
float error = computeProjectionError(m.corners, pcorners);
//printf("error: %2.2f\n", error);
for(int i = 0; i < pcorners.size(); i++) {
auto mc = m.corners[i];
auto pc = pcorners[i];
//printf("[(%2.2f,%2.2f) vs (%2.2f,%2.2f)],", mc[0], mc[1], pc[0], pc[1]);
}
//printf("\n");
return error;
}
Corners JointCalibrator::findChessboardCorners(unsigned char* image) const {
const ImageParams& iparams = processor_->getImageParams();
cv::Mat cvimage = color::rawToMat(image, iparams);
return findChessboardCorners(cvimage);
}
Corners JointCalibrator::findChessboardCorners(cv::Mat& image) const {
//printf("find corners\n");
cv::Mat grayImage, sharpened;
// Sharpen the image first to improve detection rates
cv::GaussianBlur(image, sharpened, cv::Size(0, 0), 3);
cv::addWeighted(image, 3, sharpened, -2, 0, sharpened);
// Convert to gray
cvtColor(sharpened, grayImage, CV_BGR2GRAY);
// Detect checkerboard corners
vector<cv::Point2f> imagePoints;
bool found = cv::findChessboardCorners(grayImage, settings_.boardSize, imagePoints,
CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_NORMALIZE_IMAGE);
// This doesn't seem to be necessary
//if(settings_.patternType == CalibratorSettings::CHESSBOARD && found) {
//cv::cornerSubPix(grayImage, imagePoints, cv::Size(11,11), cv::Size(-1, -1),
//cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
//}
auto corners = Corners();
//printf("%i corners found:\n", imagePoints.size());
processor_->updateTransform();
for(auto p : imagePoints) {
corners.push_back(Vector2f(p.x,p.y));
//printf("(%2.f,%2.f) ",p.x,p.y);
const auto& cmat = processor_->getCameraMatrix();
auto world = cmat.getWorldPosition(p.x,p.y);
//printf(" <- [%2.f,%2.f,%2.f], ", world.x, world.y, world.z);
}
//printf("\n");
return corners;
}
Corners JointCalibrator::projectChessboardCorners(bool left) const {
vector<Vector3f> fcorners;
Vector2f topLeft(
settings_.boardOffset + (settings_.boardSize.height / 2.0f - .5) * settings_.squareSize,
(settings_.boardSize.width / 2.0f - .5) * settings_.squareSize
);
//printf("top left (foot rel): %2.f,%2.f,0\n",topLeft[0],topLeft[1]);
for(int x = 0; x < settings_.boardSize.height; x++) {
for(int y = 0; y < settings_.boardSize.width; y++) {
fcorners.push_back(Vector3f(
topLeft[0] - settings_.squareSize * x,
topLeft[1] - settings_.squareSize * y,
0
));
}
}
Corners corners;
//printf("converting %i world coordinates\n", fcorners.size());
for(auto fc : fcorners) {
Pose3D foot = cache_->body_model->abs_parts_[left ? BodyPart::left_bottom_foot : BodyPart::right_bottom_foot];
//printf("%s foot at %2.2f,%2.2f,%2.2f\n", left ? "left" : "right", foot.translation.x, foot.translation.y, foot.translation.z);
foot.translate(cal_->poseX, cal_->poseY, cal_->poseZ);
foot.rotateZ(cal_->poseTheta);
foot.translate(fc[0], fc[1], fc[2]);
auto wc = foot.translation;
//printf("converting foot-rel to world: %2.2f,%2.2f,%2.2f --> %2.2f,%2.2f,%2.2f\n", fc[0], fc[1], fc[2], wc[0], wc[1], wc[2]);
const auto& cmat = processor_->getCameraMatrix();
auto coords = cmat.getImageCoordinates(wc[0], wc[1], wc[2]);
Vector2f ic(coords.x, coords.y);
//printf("converting world coordinate: %2.2f,%2.2f,%2.2f --> %2.f,%2.f\n", wc[0], wc[1], wc[2], ic[0], ic[1]);
corners.push_back(ic);
}
return corners;
}
float JointCalibrator::computeProjectionError(const Corners& icorners, const Corners& pcorners) const {
assert(icorners.size() == pcorners.size());
float sqSum = 0.0f;
const ImageParams& iparams = processor_->getImageParams();
for(int i = 0; i < icorners.size(); i++) {
if(pcorners[i][0] < 0 || pcorners[i][0] > iparams.width || pcorners[i][1] < 0 || pcorners[i][1] > iparams.height) continue;
sqSum += (icorners[i] - pcorners[i]).squaredNorm();
}
float sum = sqrt(sqSum);
return sum;
}
bool& JointCalibrator::left() {
return cal_->useLeft;
}
const bool& JointCalibrator::left() const {
return cal_->useLeft;
}
vector<int>& JointCalibrator::jointMap() {
if(left()) return ljointMap;
else return rjointMap;
}
const vector<int>& JointCalibrator::jointMap() const {
if(left()) return ljointMap;
else return rjointMap;
}
bool JointCalibrator::validateProjection(const Corners& icorners, const Corners& pcorners) const {
return icorners.size() == pcorners.size() && icorners.size() > 0;
}
| [
"stevencarr@utexas.edu"
] | stevencarr@utexas.edu |
5cbd676fc2e3fb1787ebda5b39b89136b5179fff | 2041079aab20a4df0d53faeca8350d3607c7fc3a | /trunk/teaf(isgw)/dll/dll_impl.cpp | 581029b0f4aaa3f6be54f7d9ad41dd796752ebbb | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | ashirali227/Testing | bdc7bfdd27cf5b03776b7d067822dc83317fd920 | 213d607a09e186433094328c11a375f701a8173b | refs/heads/master | 2023-04-29T12:01:37.393671 | 2021-05-19T10:21:56 | 2021-05-19T10:21:56 | 368,592,105 | 0 | 0 | null | 2021-05-19T09:43:35 | 2021-05-18T16:07:57 | C++ | UTF-8 | C++ | false | false | 444 | cpp | //g++ dll_impl.cpp -fPIC -shared -o libperson.so
#include "dll_impl.h"
person::person(const string& name, unsigned int age) : m_name(name), m_age(age)
{
cout << m_name << " say hello!" << endl;
};
person::~person()
{
cout << m_name << " say byebye!" << endl;
};
string person::get_person_name() const {return m_name;}
person create_person(const string& name, unsigned int age)
{
return person(name, age);
};
| [
"away@awaydeMacBook-Pro.local"
] | away@awaydeMacBook-Pro.local |
d4c8e6f4cc7414f6ebd8baff162819e8b815aa1d | 79cd3aed34bdff83575ea0b5973812e396fc089b | /TehnikeProgramiranja/Tutorijali/T8/Z4.cpp | 5a37fc5b3ccb7e239a98a2085c8461649623775a | [] | no_license | lmujic1/CppCode | 42be834f9e170d00a8843f316dce9205637e5c1a | 628a21c3b16e3906160589b97cec25c46af654e8 | refs/heads/master | 2023-08-14T03:49:38.149481 | 2021-09-20T23:56:51 | 2021-09-20T23:56:51 | 407,698,782 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,627 | cpp | //
// Created by 38760 on 18. 9. 2021..
//
//TP 2018/2019: Tutorijal 8, Zadatak 4
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
std::string ZamijeniPremaRjecniku(std::string s,std::map<std::string,std::string> mapa) {
std::string novi;
for(int i=0;i<s.length();i++) {
if((s[i]>='A' && s[i]<='Z')||(s[i]>='a'&&s[i]<='z')) {
std::string pom;
while((s[i]>='A' && s[i]<='Z')||(s[i]>='a'&&s[i]<='z')) {
if(i==s.length()) break;
pom.push_back(s[i]);
i++;
}
auto it(mapa.find(pom));
if(it!=mapa.end()) novi+=it->second;
else novi+=pom;
}
if(i==s.length()) break;
novi.push_back(s[i]);
}
return novi;
}
int main ()
{
return 0;
}
/*
Napišite funkciju “ZamijeniPremaRjecniku” koja određene riječi u nekom stringu zamjenjuje nekim
drugim riječima. Prvi parametar je tipa “string” i on predstavlja string u kojem se vrši zamjena.
Drugi parametar je mapa (tj. objekat tipa “map”) kod koje su i ključno polje i pridružena vrijednost
tipa “string”. Ova mapa se sastoji od uređenih parova, u kojima prvi element predstavlja riječ koja
se zamjenjuje, a drugi element predstavlja zamjensku riječ koja se treba ubaciti umjesto riječi koja
se zamjenjuje. Funkcija treba kao da rezultat vrati novi string koji se dobija nakon izvršenih
zamjena. Na primjer, sljedeći testni primjer treba da ispiše “how yes no”:
std::map<std::string, std::string> moj_rjecnik{{"jabuka", "apple"},
{"da", "yes"}, {"kako", "how"}, {"ne", "no"}, {"majmun", "monkey"}};
std::cout << ZamijeniPremaRjecniku("kako da ne", moj_rjecnik);
Radi jednostavnosti, pretpostavite da string koji se transformira sadrži samo mala slova i razmake
(i ništa drugo). Isto tako, pretpostavite da riječi u parovima koje čine mapu koja predstavlja rječnik
sadrže samo mala slova, bez razmaka. Ove pretpostavke ne morate provjeravati, već je samo
uzmite kao takvu. Međutim, vodite računa da je moguće da riječi budu razdvojene sa više razmaka,
kao i da se na početku odnosno kraju stringa mogu također nalaziti razmaci. Drugim riječima,
string poput “ kako da ne ” uz pomoć istog “rječnika” kao i gore navedenom primjeru treba da se
prevede u “ how yes no ”.
Treba paziti da se uvijek se zamjenjuju samo cijele riječi, nikad njihovi dijelovi. Na primjer, ukoliko
string koji se transformira glasi “davor martić ima sestre maju i juliju” i ukoliko se mapa koja
definira rječnik sastoji od parova (“mart”, “ožujak”), (“maj”, “svibanj”) i (“jul”, “srpanj”), rezultat
transformacije treba da bude isti string bez ikakve promjene, odnosno rezultat ne treba da bude
string “davor ožujakić ima sestre svibanju i srpanjiju”. Inače, nešto slično tome desilo se prije
nekoliko godina prilikom pokušaja automatskog “prevođenja” transkripta jedne parlamentarne
sjednice sa bosanskog na hrvatski jezik uz pomoć Word-ove “Find & Replace” komande, kada je
poslanik Martić postao Ožujakić. Interesantno je što bez obzira što Word ima opciju “Whole words
only” kojom bi se izbjegao taj problem, “prevodioci” su je držali isključenom, jer su smatrali da na
taj način “rješavaju” problem promjene riječi po padežima, koje inače komanda “Find & Replace” ne
može da “uhvati”.
Napišite i kratki testni program u kojem ćete demonstrirati napisanu funkciju. Način komunikacije
između korisnika i programa izvedite prema vlastitoj volji (neće se testirati).
*/ | [
"lmujic1@etf.unsa.ba"
] | lmujic1@etf.unsa.ba |
1c96d4c0f966c03bb831a7ad12a00a2c5f7219ee | a22e075e5cd68cd61c822b7d6b28b63f5dcb4c1c | /algorithm/201115_bfs_map.cpp | 340cd90d3d9f8211c101c23d0c01af4648e9976b | [] | no_license | Liuqianqian007/learncs | 52cc81f638653138799627f6269ed2f0bd9cae60 | 497aab2b44e505b3c2d3d174aba07f0f97f928e5 | refs/heads/main | 2023-07-11T03:33:12.003729 | 2021-08-21T03:59:06 | 2021-08-21T03:59:06 | 320,240,746 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,836 | cpp | /*************************************************************************
> File Name: bfs_map.cpp
> Author: liuqian
> Mail:
> Created Time: Sun 15 Nov 2020 08:29:40 PM CST
************************************************************************/
#include<iostream>
#include<queue>
using namespace std;
/*
输入数据:S为起点,T为终点
S...
##..
##..
T...
*/
//广度优先搜索, oj399
//解决问题一:连通性问题
//解决问题二:最短路径问题
//结构体记录当前点坐标和走到当前点用的步数
struct node {
int x, y, step;
};
int n, m, sx, sy;
int dir[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};
char mmap[105][105];
int main() {
cin >> n >> m;
//输入数据并记录起点坐标
for (int i = 1; i <= n; i++) {
for (int j = 1;j <= m; j++) {
cin >> mmap[i][j];
if (mmap[i][j] == 'S') {
sx = i, sy = j;
}
}
}
//队列记录已搜索过的点
queue<node> que;
que.push(node({sx, sy, 0}));
while (!que.empty()) {
//队列不为空则每次从队首取出一个点扩张
node temp = que.front();
que.pop();
//扩张:遍历上右下左四个方向
for (int i = 0; i < 4; i++) {
int x = temp.x + dir[i][0];
int y = temp.y + dir[i][1];
//找到终点,输出步数并返回
if (mmap[x][y] == 'T') {
cout << temp.step + 1 << endl;
return 0;
}
//如果是可走的点,则标记避免重复,并加入队列
if (mmap[x][y] == '.') {
mmap[x][y] = 0;
que.push((node){x, y, temp.step + 1});
}
}
}
//队列遍历结束还没找到终点
cout << "NO" << endl;
return 0;
}
| [
"liuq@github.com"
] | liuq@github.com |
690d2c3aac4b507aa9bb14702565a2e6e659835f | 9e6592940d44df37f9ba748f19b6c36db3a9e300 | /src/robot_control/lib/NXTControl/include/nxt/TelegramFactory.hpp | a5597dcc98084eb814680e92b871688d4d0d36a9 | [] | no_license | Smart-Minotaur/nxt_minotaur | f6fdddb4feea956f0c528fb0d884ffbb5bc26b36 | 0ff5451002dad5066b325d619a738a3d8aaf2824 | refs/heads/master | 2021-03-12T21:38:15.556994 | 2014-10-11T15:12:38 | 2014-10-11T15:12:38 | 18,295,217 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,152 | hpp | #ifndef NXT_TELEGRAM_FACTORY_HPP
#define NXT_TELEGRAM_FACTORY_HPP
#include <string>
#include "nxt/Telegram.hpp"
namespace nxt
{
/**
* \brief Provides methods to create Telegram objects.
*/
class TelegramFactory
{
private:
void addString(Telegram &p_telegram, const std::string &p_string) const;
void addUINT16(Telegram &p_telegram, const uint16_t p_value) const;
void addUINT32(Telegram &p_telegram, const uint32_t p_value) const;
public:
TelegramFactory();
~TelegramFactory();
Telegram startProgramMsg(const std::string &p_file) const;
Telegram stopProgramMsg() const;
Telegram playSoundFileMsg(const uint8_t p_loop,
const std::string &p_file) const;
Telegram playToneMsg(const uint16_t p_frequency,
const uint16_t p_durationMS) const;
Telegram setOutputStateMsg(const uint8_t p_port,
const uint8_t p_power,
const uint8_t p_motorMode,
const uint8_t p_regulationMode,
const uint8_t p_turnRatio,
const uint8_t p_runState,
const uint32_t p_tachoLimit) const;
Telegram setInputModeMsg(const uint8_t p_port,
const uint8_t p_type,
const uint8_t p_mode) const;
Telegram getOutputStateMsg(const uint8_t p_port) const;
Telegram resetInputScaledValueMsg(const uint8_t p_port) const;
Telegram getInputValuesMsg(const uint8_t p_port) const;
Telegram messageWriteMsg(const uint8_t p_mailbox,
const std::string& p_message) const;
Telegram resetMotorPositionMsg(const uint8_t p_port,
const uint8_t p_relative) const;
Telegram getBatteryLevelMsg() const;
Telegram stopSoundPlaybackMsg() const;
Telegram keepAliveMsg() const;
Telegram lsGetStatusMsg(const uint8_t p_port) const;
Telegram lsWriteMsg(const uint8_t p_port,
const uint8_t p_txDataLength,
const uint8_t p_rxDataLength,
const unsigned char *p_txData) const;
Telegram lsReadMsg(const uint8_t p_port) const;
Telegram getCurrentProgramNameMsg() const;
Telegram messageReadMsg(const uint8_t p_remoteMailbox,
const uint8_t p_localMailbox,
const uint8_t p_removeMessage) const;
};
}
#endif | [
"rookfighter@develop"
] | rookfighter@develop |
a2cb4434e2cbe6526ec21db33377922499722c31 | f5a934834ee35fe17bf3f87ab29fc3436d083204 | /Reverse_Integer.cpp | 69a9d93ed33df67e985edbea480a497f4bdc6b47 | [] | no_license | Ugongjae/leetcode | 21e3c45f332032aedd6f37b21ba4251706948f69 | bc162d94707b80cbabc5541fc0bdf83756cf040f | refs/heads/master | 2023-08-24T16:56:48.313602 | 2021-10-29T12:54:22 | 2021-10-29T12:54:22 | 341,912,050 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 779 | cpp | #include <iostream>
#include <algorithm>
using namespace std;
class Solution {
public:
int reverse(int x) {
if(x==0)
return x;
long res=0;
int isMinus=1;
if(x<0){
if(x==INT32_MIN){
return 0;
}
x*=-1;
isMinus=-1;
}
while(x>0){
res*=(long)10;
int tmp=x%10;
res+=(long)tmp;
x/=10;
}
if(res>INT32_MAX){
return 0;
}
return res*(long)isMinus;
}
};
int main(){
Solution s;
cout<<s.reverse(1534236469)<<endl;
cout<<s.reverse(120)<<endl;
cout<<s.reverse(1)<<endl;
cout<<s.reverse(0)<<endl;
cout<<s.reverse(-123)<<endl;
return 0;
} | [
"turtle0191@naver.com"
] | turtle0191@naver.com |
f7b7e22191d74d65646edea2056d64b64fc582f8 | 6e863f09100749c10e2bc64b690e2dfd5ab681b2 | /자료형과 연산(1)/자료형과 연산(1).cpp | 8e98cac1ebfb2417a56cd57f62b6c75a9e0deb99 | [] | no_license | Juhye/c-study | de9fae7c406c483cac8cbbe3ce3c818933644232 | da3c307acf1c985a51df953e2fa33c7314af4a93 | refs/heads/master | 2020-04-26T22:09:27.932416 | 2019-05-14T07:19:38 | 2019-05-14T07:19:38 | 173,863,295 | 2 | 0 | null | null | null | null | UHC | C++ | false | false | 537 | cpp | #include<iostream>
#include<climits>//형의 최대크기,최소크기를 알수있다
using namespace std;
int main() {
short year = SHRT_MAX;
int sale = INT_MAX;
long total_sale = LONG_MAX;
cout << "short형의 크기" << sizeof(short) << endl;
cout << "int형의 크기" << sizeof(int) << endl;
cout << "long형의 크기" << sizeof(long) << endl<<endl;
cout << "short형의 최대" << year << endl<<endl;
cout << "int형의 최대" <<sale<< endl<<endl;
cout << "long형의 최대" << LONG_MAX << endl<<endl;
getchar();
} | [
"0julie@naver.com"
] | 0julie@naver.com |
16b36faae6a607aafeaf9bac33fee1f28a83a9b4 | 9a3b9d80afd88e1fa9a24303877d6e130ce22702 | /src/Providers/UNIXProviders/AssociatedPrivilege/tests/AssociatedPrivilege.Tests/main.cpp | f1c25b5b7f516620e8704fe498e19d41a5ef75df | [
"MIT"
] | permissive | brunolauze/openpegasus-providers | 3244b76d075bc66a77e4ed135893437a66dd769f | f24c56acab2c4c210a8d165bb499cd1b3a12f222 | refs/heads/master | 2020-04-17T04:27:14.970917 | 2015-01-04T22:08:09 | 2015-01-04T22:08:09 | 19,707,296 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,058 | cpp | //%LICENSE////////////////////////////////////////////////////////////////
//
// Licensed to The Open Group (TOG) under one or more contributor license
// agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
// this work for additional information regarding copyright ownership.
// Each contributor licenses this file to you under the OpenPegasus Open
// Source License; you may not use this file except in compliance with the
// License.
//
// 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.
//
//////////////////////////////////////////////////////////////////////////
//
//%/////////////////////////////////////////////////////////////////////////
#include <UNIX_Common.h>
#include "UNIX_AssociatedPrivilegeFixture.h"
#include <iostream>
int main (int argc, char *argv[])
{
std::cout << "Starting Pegasus Providers Testing Framework..." << std::endl;
std::cout << "Testing UNIX_AssociatedPrivilege Provider..." << endl;
UNIX_AssociatedPrivilegeFixture __associatedPrivilege;
__associatedPrivilege.Run();
}
| [
"brunolauze@msn.com"
] | brunolauze@msn.com |
3dcb370c188b8450111c7e027ba628d424cc0625 | 9f520bcbde8a70e14d5870fd9a88c0989a8fcd61 | /pitzDaily/925/alpha | b053fb45cad54b5251b4c84af4b3d00d65e8b33c | [] | no_license | asAmrita/adjoinShapOptimization | 6d47c89fb14d090941da706bd7c39004f515cfea | 079cbec87529be37f81cca3ea8b28c50b9ceb8c5 | refs/heads/master | 2020-08-06T21:32:45.429939 | 2019-10-06T09:58:20 | 2019-10-06T09:58:20 | 213,144,901 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 68,743 | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "925";
object alpha;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 -1 0 0 0 0];
internalField nonuniform List<scalar>
6400
(
0.912352755121
1.48960763839
2.3841882791
3.03148541347
3.64802539988
4.25593748307
4.98582894667
5.79639263621
6.35872823753
7.17252006575
8.51424151129
9.54103776907
10.4311726743
11.4027074552
12.5534445022
13.769364452
14.9053147804
15.9819380653
16.903083084
17.5246110524
17.9659689878
18.5771518472
19.544156458
20.8257699025
22.2031779351
23.4765594442
24.5886723298
25.6402948618
26.7240218805
27.8551278527
28.9782637199
29.9199155487
30.6037520487
31.1348835812
31.5648153572
31.9148033933
32.4225890279
33.1039827417
33.5121144125
33.7272627287
34.2654299061
35.235871485
36.1851081168
36.7682965128
37.0136180697
37.0152777091
36.8367203019
36.515852275
36.0653921056
35.5034916225
34.7615969124
33.6528923479
32.1418504719
30.3190285411
28.5647645466
26.8750965709
24.7130865929
21.9150352387
18.9972284289
16.3701976434
13.7213358363
10.9724548347
8.50768701409
7.79121570665
10.1109177828
14.2896389079
16.8903482909
16.3167347027
14.1003702392
12.3348962114
11.3973313595
11.6255821618
12.2528228009
12.1977196905
14.4064180696
13.8973215922
15.8798264606
9.7725232141
12.8500336175
4.79736576871
3.18480212464
2.58621490967
3.2466735348
4.54311793217
4.59715267158
4.65445873342
4.99283341298
5.55043688323
6.32040038227
7.28577027189
8.42779962734
9.57202224426
10.6048803594
11.602163409
12.6286825396
13.7919226536
15.0200873007
16.190915041
17.3323883332
17.8008398014
18.084622146
18.6868640881
19.6467696321
20.9225976273
22.394445826
23.6243798193
24.7133143526
25.7949509979
26.8894940179
27.9940269224
29.0950618617
30.104368888
30.7816721857
31.3043152558
31.7583504146
32.0492292984
32.5908961539
33.2971892438
33.6779469899
33.7965061002
34.3130611629
35.6446230052
36.7973327205
37.3077945403
37.5079272475
37.4600903931
37.220687512
36.8579291401
36.2977109931
35.6153623476
34.9190798668
34.1676362171
32.7870805269
30.5406198827
28.8619542373
27.020211776
24.4875776344
21.7449279808
18.9852479198
16.2308029367
13.5931015706
11.2227750127
8.85403326701
8.27799802075
10.4406850472
15.3343350158
18.6469011452
17.1169797257
14.7386089358
12.6670364899
11.9121992324
12.359502762
13.5577024413
13.0174149545
12.951093906
12.5059102758
11.3870571648
9.60492511894
8.11391459632
4.19297023908
3.34658607308
2.99135384345
3.5245640561
3.91309000541
4.5875235618
5.11527314974
5.16955822358
5.43424897543
6.21147690644
7.25494500933
8.4097951617
9.57296038823
10.646931771
11.6427889616
12.5258342515
13.5938076356
16.104734649
18.1256165383
18.7629588427
18.549041881
17.8912024042
18.4148599338
19.7436504978
21.0636805593
22.340340566
23.6185102871
24.7922008229
25.8757314899
26.951404853
28.0482450102
29.1237021925
30.2033284873
30.8699345714
31.2163713249
31.8980958804
32.2104813973
32.5323608968
33.3694079273
33.807558733
33.9958067579
34.527018766
35.4691609033
36.387814592
36.9701809875
37.240342615
37.2813009153
37.1354794845
36.8222303612
36.3449081462
35.721408463
34.9462785099
33.9074287299
32.4846434443
30.8781274232
29.1722462607
26.9714278943
24.4169788616
21.7208578148
18.9773073133
16.2661885315
13.6721628457
11.1797557168
9.37245492261
9.55704340406
12.6831629347
16.3665021601
18.1109760491
17.9228650949
16.1608507527
14.3894993682
13.6606688445
13.5639131431
12.9019935489
12.3433991032
12.4062651699
12.1627508675
11.2675955057
9.68896520134
7.2521644743
7.47079699752
3.47772149688
5.62735370329
3.94911261772
4.14509987086
4.89809245752
12.0023674791
10.4540439314
5.90825161202
6.16046262416
7.23654871416
8.42486024377
9.61047568647
10.6588630537
11.6482053831
13.318814208
15.382155602
17.1454610918
17.8508001802
17.3521148792
17.1160087598
17.7480237146
18.6357146775
19.7470617081
21.054421156
22.4070140826
23.7089412035
24.9044018206
25.9732795542
27.0586419543
28.1027698204
29.264852942
30.198639392
31.0670109092
31.3866232695
31.5702692514
32.2655545787
32.673318531
33.1043209669
33.6776465745
34.2037268865
34.8234438331
35.6392657594
36.4480454605
37.026412375
37.333467284
37.408933198
37.2890685276
36.9949468119
36.5352291374
35.9144534328
35.1117496931
34.0610909287
32.7171412738
31.1303886087
29.2718898625
27.027154074
24.4624344246
21.7530676622
19.0190170368
16.3562250915
13.8793443157
11.8267069981
10.812827792
11.1455722413
12.7421029606
16.8673518986
19.8019953527
19.6889345213
17.8565626255
15.3898052558
13.70428512
12.8694678592
13.0546339731
14.5533086508
14.5558675755
13.2940950865
13.2258495968
16.5899034685
12.952092961
10.9370134841
5.91265817271
7.74265152661
4.85474921826
5.17894606031
6.8703161647
11.9055969736
8.60385318254
6.48706837097
6.68982312298
7.44701306742
8.55470863219
9.7493283198
11.2160505101
13.3843239319
14.5080665743
15.1298022259
15.5352683218
15.8340399091
16.3412149846
17.1474015635
17.8594149461
18.6930575578
19.8317422178
21.1375136349
22.4965193132
23.8195632936
24.9965974418
26.1549403483
27.1485435734
28.3124163289
29.2997869842
30.6334913965
31.0135298601
31.1202185335
31.6150454584
31.9544619927
32.5227194786
33.1864677736
33.8333638193
34.4419486512
35.0935465115
35.8408403994
36.5737390817
37.1380304288
37.4702231407
37.5772561177
37.4842355341
37.212068296
36.7713132151
36.1600991248
35.3548097623
34.3117827424
33.0000588479
31.4085350941
29.4810253215
27.174397236
24.5874359938
21.888347971
19.215742948
16.7079633789
14.5640587391
13.1134516859
12.6835509329
12.6507870585
13.4545653526
16.7573609605
20.0438170733
21.0581560854
19.7020440899
16.8243617651
14.2402260382
13.8436656814
16.1317058431
17.0297735972
16.0271473025
15.1545969593
17.893408201
20.9580226293
16.2040218355
15.3081666102
10.1796351267
9.37829759845
6.05682199241
6.52182211134
12.2006985625
11.7204799017
7.2714589383
7.13945588584
7.34804455617
7.80314105606
8.76956764835
11.2798871971
14.3401905985
14.9296186142
14.8289606787
14.3715849448
14.5168595181
15.256945893
16.3839944731
17.0921504849
17.7755648201
18.7567883726
19.9535971917
21.2772574146
22.5774277773
23.9037383481
25.2609668487
26.2431107044
27.5185803416
28.3611038483
29.8705862003
30.4727227379
31.4267763907
31.2538438431
31.2140973752
31.7759746875
32.5589004015
33.3306912107
34.036554212
34.6955492447
35.3676793989
36.0796267038
36.7635906579
37.3122545179
37.6597609517
37.7933596914
37.7267584916
37.479077243
37.0616007217
36.4698833186
35.6803622832
34.6560471655
33.3587219456
31.745823765
29.7672009143
27.4327609057
24.8675394917
22.2450322381
19.7296780626
17.5077759227
15.8134142757
14.9325974505
14.8617914428
14.1065813985
15.4824916737
18.9066268563
21.5735141624
22.4647570046
21.3004280374
17.8075415747
15.4884432127
17.1924612395
19.3621449011
18.8242809118
17.8490887885
17.9507295663
22.6280731764
24.2561359089
19.1743722341
18.9766931746
12.3353250885
9.39067626882
7.35167493192
6.89446332683
12.2047654971
8.88914845855
7.62746897918
7.78232226211
7.96809458193
8.71199412552
9.32473666133
13.8920682772
14.7387195286
14.9437767852
13.9995550747
13.5361501001
14.1828641042
15.604148031
16.3021358749
16.8321405413
17.7719799756
18.8467719892
20.0471788082
21.3663703065
22.7993704536
24.1733685287
25.2726496564
26.8165937916
27.6104173203
29.1912806172
29.6827920573
30.8946959312
31.0333054196
31.0740704469
31.1153876287
31.7703763257
32.6629515772
33.5104922066
34.2632541456
34.9616992861
35.6550022546
36.3535930637
37.0101388122
37.5473384902
37.9052114833
38.0610819734
38.0207880468
37.8014900897
37.4143058275
36.8530768782
36.0925895509
35.0931791101
33.8059707618
32.179175301
30.1854734176
27.8786799953
25.4077365585
22.9542922899
20.6883192936
18.7859179475
17.4579903692
16.7770176405
16.294448142
16.1747784204
17.5757808658
21.7859000119
23.2572471351
23.0486458672
21.6698236621
19.2287971075
18.7636932269
21.1493745173
21.4825953563
20.6174853161
20.0233152919
22.0579824638
24.8923548044
26.4239689845
21.7710835267
20.6210759675
12.1341188817
9.21404458004
8.55023056695
12.4669451096
12.3975452228
8.1857709361
8.33386172519
8.52624049927
8.62824473314
9.25524784532
13.5765755491
14.5745001814
14.8233152332
14.5662811683
13.0465115771
13.2098215819
14.8070248477
15.680060904
15.9832588797
16.6994835995
17.7815505587
18.9725890255
20.2094619043
21.5715824444
22.8726471586
24.4294243808
25.3179711899
26.8219256515
28.5082584972
29.3235528521
29.4444454208
30.4810675082
31.0431722022
30.7291937064
31.1360639114
31.922328342
32.8267091836
33.7062782406
34.5048422433
35.2440221321
35.9623066905
36.663563808
37.3096302098
37.8416922027
38.2084468573
38.3846035847
38.3720664034
38.1864364572
37.8378528194
37.3180627218
36.5985413355
35.6338531266
34.3687203342
32.7582461769
30.8077560346
28.6090902985
26.3212421678
24.0980519889
22.0576441283
20.3510538469
19.1752440068
18.5451448168
18.3024140137
18.4912129891
18.4692541405
22.6275550709
25.4305220841
24.829799066
23.8418183181
22.603111978
23.0935128145
24.1912117384
23.3567526595
22.6070619948
22.80006735
25.2262755928
25.9838313476
26.6541290034
23.7522565615
21.5911730372
11.5255366076
9.28090177237
9.24435134881
13.4928098396
11.5646067209
8.93367573899
9.1037362015
9.43018152538
10.4776571795
9.42656968812
14.3404989021
15.1349946713
14.8928184276
13.5267536732
12.8060412572
13.3309183878
14.8403407915
15.4341877348
15.87424615
16.6925213579
17.7594417514
19.0061121481
20.3268472583
22.0251055495
23.4773311014
24.3912841017
26.3328232119
26.7592846855
28.6171299098
28.9636796127
30.239167713
30.0015515223
30.2264974134
30.6769625019
31.3102022583
32.1257313208
33.0240397626
33.9207458105
34.7618914576
35.5462390177
36.2957894372
37.0108580226
37.659758321
38.1944934626
38.5716099839
38.7687017764
38.7875179474
38.6422364459
38.3412335025
37.8743136879
37.2097710394
36.2979080947
35.0847571632
33.544737125
31.7194593367
29.7234423611
27.6827963678
25.6523986636
23.686689248
22.0498097277
21.0657701593
20.7555534719
20.8067211889
20.83160083
20.6138389103
21.1236326344
26.1449376336
27.1788160675
26.6118246367
26.7083970269
27.2759042839
26.5655469822
25.3236414373
24.9964842273
25.9840018779
27.2832451412
27.2536569386
26.7445301232
25.773018978
24.4201779041
11.143833963
9.82950204078
10.39145675
13.6143278861
9.90997483
9.96857921463
9.87815926476
10.1750228148
12.9897809452
11.8513261553
15.172853675
15.4458742787
15.0235012343
13.0032705146
12.882552513
14.4138266991
15.0287847828
15.2129567354
15.8220789761
16.7996035712
17.8562161229
19.0468948496
20.2272187214
22.1196358216
24.2898578535
24.33116076
26.2542224521
27.7773180804
28.7995217532
29.7692389453
29.7381035235
30.1365386214
30.0105448882
30.6152292392
31.474390759
32.3514945677
33.2499139834
34.1567538207
35.0349064072
35.8683374251
36.6587066183
37.3984166719
38.0604732805
38.6057688101
38.9980316068
39.2194973239
39.274807674
39.1778318825
38.9345215249
38.5332795831
37.9419758116
37.111918191
35.999801909
34.6082306842
33.0094313418
31.301755348
29.493114305
27.4815643126
25.4568070002
24.0615689867
23.6080040925
23.7593128068
23.9300024086
23.7389908454
23.1537470602
21.6662132522
20.7301685187
29.2979196327
31.4764303224
31.7619982949
30.9554005
29.0124391477
27.7139695704
27.7789661754
28.9264513062
29.3854986089
29.3495675467
29.2538089874
29.7230313586
29.9861036151
11.2812537327
10.7559940787
13.6654621033
13.8996339945
10.184435368
10.7725469271
10.6534297659
11.0758466959
12.6667167086
15.1848216229
16.068624513
15.7851754733
15.3477408871
13.1414100046
13.0554006391
14.86733549
15.1486507309
15.1992596384
15.8213065267
16.888820907
18.1428292914
19.367180208
20.3510663071
21.7328221726
24.4072010045
25.8031108406
25.9700138178
27.8341726804
27.9627830932
29.7480078232
30.477971756
30.1210774321
30.0045320841
30.7165028261
31.6616969078
32.5851645242
33.4988028095
34.4184600861
35.3266198871
36.209415248
37.0510930592
37.8277982299
38.5132119468
39.0771052069
39.491324425
39.7441954268
39.8437547951
39.8036610929
39.6284324343
39.3074474149
38.8128258216
38.1051367701
37.1626044395
36.0199634386
34.7549069109
33.3666795554
31.6457320563
29.479885248
27.5833669574
26.9474148537
27.423967439
27.9932055606
28.1597395168
27.7023589513
26.6185265353
24.6970204413
22.1234124925
21.886846771
33.2889227753
37.5526687855
35.4813317916
32.2847233367
30.8196386816
30.9193922366
31.6166776691
32.1363342826
32.8884522483
33.8118412138
34.6201907197
35.4151846737
11.7678762252
11.6920940977
15.3459453459
14.7328754752
13.0158912716
12.0424428729
11.6634550293
12.5075581002
12.3012211223
16.1651264675
16.7965025624
16.2091930571
15.5583798706
13.859407812
13.804656888
15.2920826235
15.2041940855
15.2915533395
15.9090248014
16.8935360349
18.2326632821
19.7833116686
21.5370776586
21.789847931
23.897892374
26.1009906553
25.8900848789
27.997179129
29.1863296898
29.1351243378
29.7867297671
29.7268997764
30.2541765179
31.0056043202
31.9013766024
32.8375160359
33.7729570978
34.7120337448
35.643658683
36.5677049091
37.4687572312
38.3001087382
39.0209514448
39.6110954152
40.056109515
40.3510435827
40.5054668693
40.5317937302
40.4347796034
40.2089752579
39.8378052108
39.3037227356
38.6186186668
37.8381032627
36.9787959064
35.823045171
34.0603262283
31.9489777631
30.5665171007
31.4958918494
33.883286447
34.5710962476
34.6837751696
34.0577908878
32.7129283304
30.2864134638
26.7076381582
21.8777599276
28.6134306338
38.6636106622
40.5362803886
36.7116061547
35.0721755633
34.9372812869
35.1771573904
35.6837415368
37.5136758923
39.0698465886
39.2955874502
39.7036233699
12.4527098273
12.3910827213
15.175035482
15.3116475146
15.3730135531
13.2623581548
12.7981677213
15.2426216135
12.7924030125
17.0341567389
17.3532179295
16.6382716599
15.7562606953
14.5480409058
16.1476367881
16.3114187721
15.4491279048
15.5237568235
16.1327059126
16.9899637784
18.1479316037
19.751355101
22.6463219939
23.6812324399
23.4211798058
26.0835052678
27.2838068386
27.583210933
29.1037200704
29.9177461422
30.0274075192
29.7648158318
30.4338277718
31.3023856089
32.1933285111
33.1225051454
34.0670245895
35.0355415928
36.0046275805
36.960011393
37.9090604915
38.8057681315
39.582691788
40.2124130627
40.6985036267
41.0490818732
41.2725174289
41.3759735656
41.3654441792
41.2466375685
41.025913839
40.7248774822
40.3952272521
40.0683263325
39.581080375
38.5291888738
37.2716402195
36.2138261253
34.8173065951
37.4424658747
36.6133117408
34.6110331203
31.9110044453
28.8253194289
24.3253261992
18.6519808189
15.4413049953
0.350387813343
0.014793671297
27.3036970822
36.5488835082
36.5301549465
32.1432368909
31.5869701511
33.8224480505
36.6173409913
41.4685286389
44.5199717488
44.8989311819
45.2774921332
13.1859221288
13.1385348219
12.7894673618
15.6966338532
15.9747473074
14.1159192946
13.8077628067
16.2933955744
13.5340702651
17.9464855974
17.8627806475
17.078573295
16.0445510162
14.9176824599
17.2732220231
16.9728275096
15.9581483629
15.9417532538
16.4712391798
17.2567204378
18.1819424474
19.5826760519
23.0608908165
24.7096426937
23.7186421866
26.0015021332
27.7196965862
27.2003249979
28.678702517
29.5453214321
29.405065325
30.0656783231
30.8267654431
31.6482070784
32.5161876148
33.4528400482
34.4077045264
35.3774352052
36.3869916282
37.3995183299
38.3942788448
39.3469739508
40.1897341423
40.8788610759
41.4243010553
41.8491068634
42.1589901026
42.3497197558
42.4302730932
42.4247112033
42.3750174758
42.3680835785
42.4824318779
42.6179633575
42.2837210256
41.5967806303
42.0177282624
34.5206137201
26.6540324775
6.04672695579
2.56476445086e-10
5.20845887935e-14
1.8039610634e-16
1.84054156862e-17
1.46057872145e-18
4.11415557573e-19
4.8426706695e-18
4.94801361359e-17
5.58930387604e-16
1.45987457405e-15
2.42423551602e-12
6.36349960096e-10
5.80679392856e-07
0.000300783458707
0.760233067853
38.8710073873
43.3150497416
48.1202272921
51.653238741
51.9777207027
14.0936291275
14.1952634052
16.3503109157
16.4032201966
16.4951114516
14.8436939957
14.8759991377
17.2126010114
14.59355145
18.754937675
18.3586207466
17.5439037087
16.4113092041
15.3421521197
17.5913117796
17.2642453233
16.4545652564
16.4236541269
16.8604536326
17.5597642322
18.3946233782
19.5245226501
22.5277566939
25.4689358191
25.7640157613
25.4252509438
27.8592870235
28.9546899182
27.8355784197
28.3690670497
29.3196812634
30.2635785504
31.1533562816
32.009837283
32.8898990044
33.8127997325
34.781592917
35.7793776801
36.7996048949
37.8634915477
38.9268867398
39.9396984071
40.8450224111
41.6041743265
42.2332153795
42.7592337251
43.1786866538
43.4717545742
43.6405742972
43.7337655342
43.8690563047
44.211537285
44.8039209178
45.1848653797
44.4002709435
42.5608054051
27.5896633579
6.11744511915e-20
6.7285552512e-23
1.26136357344e-24
2.13809769645e-26
6.18604712414e-29
1.75793955892e-31
3.0429601033e-36
2.38021242105e-36
5.77860841882e-36
3.8952389492e-35
1.82450817641e-34
6.73974231104e-34
4.28300091321e-33
3.35349410547e-33
2.90933846259e-31
1.6558997057e-28
1.66453254375e-26
1.26309901854e-24
2.90861182402e-22
4.89610897229e-18
38.8039308886
55.7281017292
51.3221950074
14.9488084204
15.1446589727
17.9867860464
17.1510307142
16.7220887767
15.5628884812
15.901491563
18.0125566849
17.9960423413
19.7642863284
18.9276298843
18.1061193561
16.8672873298
15.9008828016
17.9272133584
17.4765341904
16.9110921685
16.9048686702
17.2604258582
17.8675540983
18.6521635556
19.6931437078
22.0385028747
25.6727357106
27.0372658192
25.2315261642
27.288230061
29.0183935191
29.26452105
28.6827085462
29.3351891203
30.428801142
31.4663694521
32.4015889539
33.2671580805
34.2021182833
35.1807743649
36.2100907699
37.266013527
38.3651341029
39.4965230553
40.5873080294
41.5563780994
42.3800164329
43.110568135
43.7924847218
44.374292488
44.7721234633
44.9790862907
45.1488363268
45.502383468
46.2246815162
47.2827281074
47.2613818401
39.1431662653
16.0030100927
3.3828900884e-26
1.36990723273e-28
3.961549959e-30
5.76729055631e-32
4.68580170256e-35
7.81870918835e-38
5.51144398949e-39
0
0
0
0
0
0
0
0
7.66547869476e-43
2.58540727011e-40
3.86721820014e-38
2.24363615549e-35
3.13380908302e-32
1.69703771254e-27
2.57715663237e-23
2.00925002468e-16
61.5948684968
15.6411723563
15.858636658
20.0716669264
17.7385162822
16.7123019138
16.1882563576
16.6413516541
18.1629786192
19.5648010887
20.9064664422
19.6462943689
18.802008898
17.5687162135
16.7360863786
18.4665499606
17.8311376332
17.4330210244
17.4240098158
17.6943399627
18.2094056706
18.9143566021
19.8754683921
21.8114435452
25.4960468689
27.9650675222
27.4235501591
26.7524285081
28.3323627117
29.0694796059
28.7814919518
29.7041502949
30.8092535651
31.8950308782
32.8365717771
33.7314203386
34.6296259835
35.6260520347
36.6720205265
37.7707879053
38.9155849683
40.1013386109
41.2756623779
42.3419291829
43.235160328
44.0711152696
44.9422951529
45.7286502613
46.2345564377
46.4669837695
46.697104573
47.269032502
48.4250232103
49.6362540128
37.5397037841
0.0645404150114
4.8976493688e-29
1.60621574521e-32
6.49487309942e-34
8.85556395386e-36
2.42843630483e-38
0
0
0
0
0
0
0
0
0
0
0
0
0
9.87696842262e-42
9.81491613637e-41
2.15164227573e-39
1.04330158653e-37
5.7936931092e-34
4.8224592963e-25
9.29606870202e-30
16.1677487881
16.3778071525
22.0674676538
18.1827180398
16.9082236744
16.7509849228
17.4267549956
17.6626630266
20.4841566624
21.7185480964
20.3292400665
19.5049465434
18.45139775
18.516411836
19.2242314732
18.4230741762
18.1435278916
18.128200919
18.2327156608
18.633182633
19.2254916602
20.099737681
21.755831532
25.2797670688
28.3127246443
28.9849218164
26.7320686748
27.3901675216
28.0260915544
28.8195476004
29.9515896221
31.2122336848
32.3201410529
33.3171735969
34.2448856648
35.1957343228
36.1348169145
37.1928886405
38.3185863365
39.4964068922
40.7642027737
42.0366922049
43.1938130822
44.117984353
45.0104351327
46.3623234092
47.9475874785
48.680122574
48.3894371263
48.4939901901
49.1867392343
50.511742117
37.0713603694
2.59174844981e-23
3.90610441958e-28
1.75233985762e-39
1.77076113451e-36
2.88939418041e-38
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1.52596065553e-40
1.03335535169e-39
1.90559294303e-37
94.7763991504
16.6012587766
16.7783262507
21.9336436529
17.7131686136
17.1438348689
17.2254778887
18.3073579059
17.7294027622
21.2667460039
22.4601480346
20.9619533601
20.1434678313
19.1356120003
20.6087724624
20.2542749223
19.2090349213
18.9584140104
19.1546429085
18.9877359262
19.2219140668
19.6316697845
20.3710035134
21.832986371
25.0495354952
28.1174017232
30.006938795
29.0743219483
28.4782517975
28.6751356574
28.9535829169
30.1461636146
31.7015673074
32.7289356809
33.8104037754
34.9344459901
35.779497085
36.7265247777
37.8040109861
38.964364855
40.1720727743
41.4460004577
42.800252351
44.1028213552
45.3208500751
46.616383887
48.3023158658
49.8403102836
50.4366450202
50.7794259587
51.0126763303
51.2749646253
40.5399565734
1.17862606711e-22
1.07585023571e-27
1.41401413961e-31
1.92050222836e-33
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4.69535633736e-40
3.41753211677e-29
17.0776334008
17.2300994046
21.5965196819
17.4344558276
17.4324316826
17.6022370323
19.0598035712
18.2041568128
21.9588939845
23.1825541785
21.5755149499
20.7609866259
19.6903560678
21.3701358668
21.1937643173
20.0419176894
19.7510391144
20.0365854321
19.8851848981
20.0212996279
20.2256066939
20.7022371707
22.0667520582
24.9518919563
27.7566802762
30.2280610373
30.1834315661
29.0658833796
28.3203340004
29.3375142376
30.5117344519
32.0446055109
33.3971984881
34.6300240201
35.7115062846
36.4765792725
37.4012082721
38.4961269303
39.6897323124
40.9495181379
42.2598238054
43.7075509261
45.2777227118
46.9441965028
48.2707557566
49.3331337758
50.7232683192
52.0503055256
53.986416568
55.0581484209
44.7562953659
1.07395755013e-21
1.42601059844e-27
2.45908216572e-31
5.04370415824e-34
1.22117779774e-35
4.09907935148e-38
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7.89070424328e-41
1.04401224344e-40
17.7774030243
17.9290463296
21.3066616236
17.7128775402
17.9571828379
18.0640888987
19.1009983066
18.8984836475
22.4687870862
23.8645835484
22.2079088368
21.4092253585
20.3379066135
22.0420605106
22.0182604438
20.930836197
20.5756500446
20.8788764697
20.755212535
20.9541964279
21.0691351103
21.1826430987
22.4912121837
25.0599291957
27.5373292671
30.2099438958
30.6834125345
29.8645736038
28.8181043975
29.4785008996
30.9539792128
32.1900037101
33.4591702154
34.8767723981
36.5503527586
37.4567443497
38.3100250691
39.3003999401
40.4712402323
41.8095938174
43.2348144225
44.8170445589
46.8631631497
48.6811496012
49.5129144742
50.5080729011
52.4754080362
56.0587866389
61.9524215374
49.3661848284
3.06833016787e-22
5.09703513493e-29
2.10927233115e-33
6.91561173736e-37
4.33917549071e-39
8.79515707173e-39
1.35060793334e-39
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5.83225108388e-42
2.64825384318e-41
18.8425419283
18.958441602
21.6140996346
18.6033179494
19.0520604582
18.8789173949
19.4235302553
20.1416950144
22.5636806482
24.3814243197
22.8877997089
22.111871869
21.0760937311
22.8065928025
22.8609100536
21.9592644587
21.556329696
21.8457659905
21.6265886358
21.9694295521
22.1959212988
21.8645066953
23.0008296041
25.3812419001
27.5219520035
29.9970056461
30.8624495679
30.5280931082
30.5969794201
30.2358288597
31.218490564
32.7608519401
34.5546662657
35.4117676307
36.8489653319
38.40756334
39.344944516
40.3832876464
41.4780951198
42.758029521
44.3165074175
46.4585285683
48.9793994016
50.2250272012
50.6882665694
52.2342594558
56.3752287753
62.5258628538
55.8729872242
34.1441500396
7.72228336663e-31
7.20980447512e-36
4.9331858944e-38
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
20.3380809179
20.2380995726
22.4244519019
20.3912664928
20.9052029999
20.0815491125
20.331180018
21.9381642658
22.7994683027
24.9867648094
23.6645935444
22.8783125328
21.8792540217
23.6026709528
23.6956222633
23.0850058345
22.9751892286
23.1058849876
22.5868329602
23.0623807699
23.5933465922
22.8243785719
23.3960502658
25.7935539925
27.7182596926
29.8110933758
30.9356539102
30.6543970698
31.7070644461
31.7127027114
32.1268988225
32.4928633251
34.3383519317
36.4455790676
37.7336930641
39.1496088911
40.3772981051
41.4706844998
42.6825256936
43.9899292398
45.8597724434
48.7952470712
51.0746348871
51.8989761945
52.8576001852
56.1970627457
63.126120168
59.1087078419
34.421616661
6.89149946213e-33
1.20477956236e-35
5.51653200272e-38
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
21.9116067408
21.4274762571
23.2812977536
22.7594649193
22.5274451684
21.4528320503
21.3080513113
23.0073997731
22.1156116902
25.4534362833
24.5206032461
23.69894293
22.7344798182
24.3975131867
24.4614726958
24.01621041
24.8973638992
24.6082769528
23.6460930261
24.2412465865
24.8368810297
24.0337081926
23.5350690981
25.7170031212
27.8121218811
29.6412246304
30.8942437394
30.6354421506
32.0279044889
32.9057511846
33.4496396871
33.1751219322
34.3916029511
36.3545936622
38.553205268
40.2953176584
41.6287526176
42.7186297442
43.9285867874
45.549260847
48.313081157
51.4423991343
53.3422185333
54.5306043979
56.9021297708
61.7225675995
60.8012267134
33.5021465983
1.85559592731e-32
2.68636660013e-35
9.40817407895e-38
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
22.6543241151
22.2201096616
23.7942746051
23.7332682503
23.505126731
22.7191773239
22.3975395106
24.2821538865
23.0889072523
26.0447443611
25.3812941688
24.5462918319
23.6349613295
25.2012476151
25.2110961352
24.7684356068
25.7997665074
25.6409649389
24.6247778483
25.3533347595
25.4946604095
24.7534168509
24.3814956773
24.5873043519
27.1360862624
28.9616695247
30.5133548329
30.429726281
31.9536470249
33.3437729924
34.5114793057
34.8094426386
34.7373023634
36.3052789382
38.6856417603
41.0929357593
42.9889072615
44.3430717222
45.5473561399
47.9454152501
51.3657448261
54.2341063009
55.95668834
57.9170630343
61.5669364638
58.2352374818
35.7362024422
25.4627298435
8.8304042353e-35
2.51494484206e-37
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
22.6561422741
22.6571205937
24.0542046195
23.8682732049
24.07444752
23.6649764943
23.3181693081
25.5300414213
24.6500339912
26.7804728812
26.2798553216
25.4028402585
24.5751821521
26.0289407789
26.0046500613
25.6198955907
26.523785908
26.5054158261
25.6077209643
26.2607782049
25.3401495013
25.3778463067
25.2544335822
25.4711403716
26.2257489505
27.3302757086
29.397580951
29.9188423536
31.3478063301
33.1787708379
34.8008388829
36.0216460155
36.11383069
36.9627226722
38.8002301695
41.2362406227
43.8692594728
46.0335052452
47.8432536489
51.0467895797
54.5317023682
57.0079815689
58.527620637
60.5475872001
56.3416236347
37.9832468784
39.9797117662
3.06729010799e-34
6.87101677386e-37
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
22.7768250505
22.9094609368
24.234292202
22.9292948743
24.2513601227
24.1277042133
23.8847215426
26.0509088242
25.3904632507
27.4911726939
27.1809509028
26.2328482236
25.5597277301
26.8678459112
26.8200743991
26.5895773119
27.3426045739
27.4757142494
26.7183617431
27.5448078281
26.5515825218
26.8274295648
26.3800377352
26.660948744
27.8240858859
28.4190703679
28.7238636026
29.2804585888
30.6132120341
32.8089922946
34.4926996842
36.0242326844
37.1468212336
37.8780882508
39.8424031245
41.8131769412
44.5375997081
47.5654485992
50.6401805948
54.4425605847
57.6526995901
59.5455185381
59.6433151835
57.7003344107
57.9252373853
35.3578524032
2.57384353082e-33
5.85948074323e-36
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
23.3106802263
23.4094065246
24.4073345027
23.1788960181
24.3745838371
24.3139968853
24.2223115601
26.1454917396
25.8467340515
27.9713055752
28.0265456106
26.9757742331
26.5736396288
27.66454492
27.5690765606
27.5082317797
28.1155870353
28.5147498896
27.8734205126
28.857258445
28.1927128763
28.6946237393
28.5611428859
27.5643944706
28.4954564467
29.3353597955
29.5453068977
28.6963411627
29.7472959301
32.3211527443
34.2482809678
35.3791790848
36.6717440227
37.8811602261
40.0018891394
42.2876197603
45.2625880032
49.0711957601
53.6168148578
57.9999515114
60.6308771861
61.3397194371
59.8754542018
55.1995639538
35.7414398245
48.57409478
4.08311653438e-35
1.65571283256e-37
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
24.0056938732
25.0257304594
24.6964229077
23.940275733
24.7344030745
24.5258703198
24.5126417413
26.1784677521
26.2294366421
28.0894619477
28.8081161573
27.5905147192
27.4295890683
28.2631828929
28.2191932626
28.1495754807
28.3433709801
29.4184867307
29.0566303171
29.9644234509
29.9274653097
29.8902798849
29.7969826891
29.4251350066
28.7044781103
29.2725126988
30.1218297996
27.784329834
28.6894229687
31.1634896294
33.8234534387
35.3886620018
36.7480595142
37.3578516921
39.3811100518
42.1251573022
45.5453551682
50.4165001414
56.6158152765
61.5200206338
63.3046706761
60.5560113472
59.1973124314
62.4780649273
42.3692162481
2.76757342569e-34
7.06351305732e-37
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
24.4545898079
25.5245040083
25.1756921947
24.5765990381
25.2049688435
24.8671334348
24.8329351379
26.2506860627
26.5696807761
27.9169079749
29.4528097947
28.1254650027
27.8630763986
28.6836298023
28.8642314713
28.658090442
28.4549082234
30.00271162
30.22454696
30.8818970173
31.0641314319
31.3046177508
30.2780011758
30.2791432106
29.7171924896
30.5282332602
31.0400755155
28.7808364364
27.4795309811
29.4167818852
32.3754521199
34.8476590624
36.4163886639
37.1987167906
38.2487816486
41.0732896683
44.9368839574
51.2723477399
59.4596566772
65.1312105251
65.1664088107
61.5639449986
55.4467567051
32.0242296914
53.5231078117
8.16030420231e-36
2.74232564283e-38
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
24.6792071857
25.648920731
25.5248643213
24.9151414843
25.6164777401
25.2925712835
25.1844724315
26.4249829536
26.9104663291
27.3451821425
29.8082535217
28.652399428
28.0778174552
28.4818670001
29.472264131
29.228474907
28.8226888004
30.4336179251
30.7979012003
31.5756116144
31.8611671453
32.3954119335
32.5839385796
32.5900762624
32.1815305791
31.5077976004
32.1660289116
30.1150687126
26.6333989138
27.4449762533
29.4491030758
32.486320785
35.0218497282
37.1230479237
37.5908468694
39.0376027299
42.7207353549
50.7237560127
61.9635000997
67.756510927
65.706293308
67.0984160707
67.3230432066
35.5096569699
1.16920093722e-34
3.19682248839e-37
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
24.8320737703
25.6959451732
25.7180953103
25.028549813
25.9017698831
25.7651844702
25.5003940241
26.6445254411
27.3696916924
26.6170100627
29.9375532361
29.2287293468
28.4081767276
27.8887766116
29.9707725287
29.8301484906
29.4331487373
30.9794461162
31.1558749211
31.7902974101
32.6380689808
32.2797195576
33.8094066349
34.3347336343
34.3362172914
34.1271388186
34.0285015296
32.9185039211
28.0954587901
25.9364729323
26.9542044439
28.7628563632
31.6153916045
33.962165457
36.5032831539
37.0439467541
38.8666537409
46.2816424854
64.6056365376
70.4245010062
63.7238987207
60.4863272386
68.2148859279
63.1387663833
3.96688802036e-36
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
24.9131364736
25.6619125263
25.4129399234
24.9757091214
26.0469443999
26.1409852231
25.6758755941
26.3782250307
28.0122701622
27.2555799648
29.9459695779
29.8604939593
28.9397392081
28.3054459219
30.4750851773
30.4314355642
30.3023994444
31.7203538074
31.7750483294
31.6025451999
33.4888083363
33.3836309842
34.6899182938
35.2953264774
35.8270530625
36.366171733
36.6643795583
36.5092807731
33.851095985
27.2625257217
25.9105931366
26.3416517777
28.59995568
30.1011809069
32.2437805547
33.934876435
34.3987734557
36.0154479171
59.4240041191
72.3968403339
71.909572528
60.4173700251
18.8226709823
54.6816877105
3.26580393139e-37
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
24.8888500791
25.5109551481
24.9311100061
25.0380547052
26.1596080322
26.2144155225
25.7562134449
25.932943572
28.1653042703
27.9122236439
29.5493298445
30.4833725764
29.4954638758
29.2166921338
30.9610205469
30.9658846284
31.2732549838
32.3813120552
32.6651294111
32.5231523014
34.3009310144
34.6777630287
35.7042251422
36.0094141144
37.3222449564
37.9973562716
39.1229165979
40.0844426809
40.4999887276
35.8602686434
28.7474386483
27.3264254613
25.8716814665
27.4424530257
28.1520881591
28.4201659505
27.5257197257
21.4861141073
31.2513386305
62.5825910942
79.836425941
83.4628933465
44.4718552673
8.12195109776e-36
9.94818796957e-39
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
24.8272162656
24.9747746222
25.1975215539
25.8247314391
26.3296361126
26.2557918135
25.8886393246
25.9317112556
27.762365232
28.1908354414
28.9489373917
30.9226211756
29.9183269093
29.8463497116
31.0996067204
31.3815811929
31.5214684454
32.5592507706
33.4301996507
33.6946671203
35.009053923
35.5387273351
36.4343056619
37.5079787224
38.5929499101
38.8244027007
40.7173631223
42.2889736815
43.9939841901
45.1218269434
39.9268794745
32.462179916
29.2470241811
26.5256138491
24.9878457646
23.1494689673
17.8174520464
14.2236811656
0.192310365389
0.031619051568
56.9559303993
84.9044056096
75.9866337454
6.06985109626e-37
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
24.7357399758
24.8319263086
26.4296083807
26.4071395379
26.3335499633
26.2136354206
26.0701510347
26.0723976328
27.5061378226
28.4718663339
27.9385547447
30.8286581515
30.2669771282
29.7899905037
30.3770501989
31.6971914159
31.5033791896
31.6121944496
33.7911333328
34.0715312984
35.2278599955
36.3486926314
36.28423896
38.6978557076
39.6878971887
41.0281210862
42.3630216987
43.9190717455
46.0159983625
48.355266056
49.8717052305
45.8654832285
40.394451352
35.5720481076
32.8246297155
31.1674014301
30.6800085412
31.4493757519
20.550737204
21.2260828344
1.71236132969e-06
38.0692396259
72.1143118816
7.67366724776e-38
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2.32783853001e-42
24.4843883422
24.7192605071
24.9989972162
25.9553036249
25.9939817968
26.0243533807
26.1911232567
26.0459019895
27.2658473683
28.5654515871
27.9554526463
30.0909328727
30.7340314335
29.774167459
29.3576641758
31.8337898685
31.7103366308
31.7376913414
33.8758557576
34.2767596745
34.5353333697
37.1521697251
37.4189414196
39.2779723751
40.3013048686
42.4611431966
43.6830747759
45.3745250568
47.5506251674
49.9893878128
52.5829837763
55.3877117655
54.468818255
52.0150717287
50.2115442393
49.7635906189
50.6218654663
53.2176268864
56.4135574456
63.1149169119
53.5956632999
1.51174732344e-11
2.47235364078e-36
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5.83225108388e-42
24.0953172168
24.3693323748
24.2707509921
25.3709509271
25.8102202979
25.8338539888
26.0417445484
25.7597656011
26.398344761
28.2152612178
28.0462442033
28.8806637677
31.1202357962
30.0234727138
29.8421206133
31.6398331123
32.0550587771
32.2203045157
33.6862499377
34.7534692284
35.1524645672
37.3847662962
38.2252731095
39.5925716927
41.3834587272
42.9566783793
44.746555115
46.7795536405
48.7375750409
51.3930488214
53.6339783768
57.4322507752
60.271796705
62.8250753552
62.9343640047
63.5991363853
64.7985581912
68.543347894
75.24457744
84.9287190628
94.3716362152
57.9855679903
3.34089895141e-37
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5.83225108388e-42
5.83225108388e-42
23.6944205377
23.9910345948
24.580017322
25.7197288005
25.9238654265
25.6375278455
25.6456907162
25.3238893144
25.5611888349
27.3378148068
28.0574935492
27.1971028615
30.2690654551
30.4234996454
29.8114737719
30.4123290105
32.2723831815
32.1465071491
32.4748944753
34.8683072456
35.4273095068
37.1707105396
38.7790346619
39.06896577
41.8606165455
42.7263829981
45.7187597351
47.2686065956
49.2202873677
52.0629759318
54.547287158
57.2358882364
60.0256090044
62.9871809642
65.0146469751
66.1048482824
67.5117403809
70.2680901475
75.0070968503
83.2291762053
99.981768633
97.5588362463
4.64998171151e-38
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2.84650221791e-42
5.83225108388e-42
5.83225108388e-42
23.2498264826
23.5078292118
24.905375925
26.2113802338
25.564807927
25.2126489113
25.1236302315
24.879245519
24.9497677684
26.4562549546
27.6974541928
27.4114085832
28.5319632636
30.9409283644
29.7256970796
29.5279651235
32.0029774566
32.1427742857
32.3811746082
34.5683661061
35.4984145275
36.1947941083
38.9480600294
39.7306379198
41.8570339892
43.609629096
45.5720298158
47.2730843247
49.593793437
51.7141712122
54.1317205887
56.3890786806
58.6617686272
61.0319227278
62.9527897614
63.9414178904
63.7141105849
62.5053526726
59.6724445768
59.1683535461
64.430811375
87.5164354048
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3.5437235959e-42
5.83225108388e-42
9.35067426759e-41
9.86669646688e-41
22.7477042722
22.9215509274
23.9258083031
24.8410078993
24.7978956085
24.5648647388
24.483070509
24.4445530315
24.2522765596
25.0424996544
26.6306556696
27.2844473771
26.4067306731
29.5738048318
29.9573613122
29.2268044588
30.2258741444
32.0882281033
32.1432172956
33.0357254045
35.4733907987
36.024625301
38.3912476738
40.0808718807
40.4879754798
43.463383215
45.2150283798
47.5596208486
49.3341592366
51.2854219366
54.0446910856
56.0032102367
58.1052136626
60.0847147632
61.1820981866
62.0502789788
60.649023904
57.3607156389
38.2132678509
53.997793015
1.59328211323e-10
3.68608130244e-37
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7.25819222459e-41
2.44996627409e-40
3.65148655157e-40
22.2377432351
22.3183043899
23.1924123109
21.9963548972
23.5958000967
23.8008892344
23.7343246804
23.8210156247
23.3162363581
23.6715620788
25.3020751646
26.6725469058
26.6115879202
27.3416593235
29.9632258064
29.1682467639
29.0834203875
31.6234379621
32.1497273199
32.2508420608
34.9336653029
35.9519145626
36.6592205693
39.1583043759
40.5905530119
42.7021344348
45.1330683302
47.0487370151
49.3828896713
51.7007243956
53.9343810208
56.0543381821
58.4804693393
60.6581753753
62.3252606264
63.1987975957
63.6307485755
62.8564097228
55.304965998
64.3792224505
5.2177528e-07
1.0932693614e-37
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3.30451659572e-41
1.18383053338e-40
1.66435180574e-39
1.12860077575e-35
21.5212463742
21.571460827
23.0465554554
21.9561552996
22.5947582641
22.8963806266
22.8757259963
22.8860708097
22.4369143215
22.5118736491
23.4800689318
25.1817839212
26.5047495072
26.2825740166
27.7708050669
29.510385129
28.5784212987
28.3706735081
31.5891482223
31.4315543469
31.9086320063
34.9433350278
35.6977025518
38.0308374152
40.0379656224
41.5869382249
44.2792590626
46.4965566662
49.2642326259
51.2791626328
53.9330178152
57.1457404473
60.1598629606
62.7538253327
65.2767088039
67.7535667767
69.7511992875
71.1503121124
76.3080326809
81.4115210712
50.7673180237
2.91463963844e-39
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2.08513777811e-41
6.9312432383e-41
6.65000355384e-39
1.92764028411e-36
9.30806869894e-27
20.4074608319
20.4226735491
21.8224541903
22.2345922816
20.8498202029
21.8409973829
21.97853924
21.999199031
21.9039361434
21.4568474839
21.7629151023
23.4216466251
24.9162655314
25.8383736904
25.139416083
28.1196723746
28.60649324
27.446733816
29.8972879436
30.7307920839
30.7277948825
33.4827016665
35.011804213
36.7745289028
39.0051836946
41.4113235793
43.4247677798
46.5916077627
48.6191136463
50.9767159292
55.0587038326
58.5230707481
62.1088434633
65.4453929784
69.5323209125
73.0784489152
76.3968741876
78.3574686832
81.1930899765
82.2399439359
40.5509301912
2.00261586862e-40
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
6.70113251421e-41
8.29825071428e-39
1.90830181105e-36
7.16629505339e-32
1.45301416223e-21
19.2851473094
19.217374764
19.2373354443
21.5381962768
19.6782518979
20.7852998594
21.2055783882
21.2416825561
21.3391608612
20.5692619802
20.6536450774
20.7812245279
22.9113897877
24.5180491946
24.3108197395
23.9252837799
26.7985034169
26.7434971122
26.6472479933
29.0742155926
29.8642161443
31.009281549
33.5426372775
35.483427095
37.7974959126
40.1661193649
42.9324704142
45.5565157726
48.3100382157
52.0709955394
55.9645975395
60.0433518695
64.5841993869
69.620805435
75.2671151697
81.1470656269
86.1526274102
91.0401299913
95.33530269
85.6537970666
8.62322527467e-09
4.87136662175e-40
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2.08513777811e-41
4.94659907377e-39
1.11404531534e-36
1.64912625479e-32
4.12823722149e-23
1.67493598607e-06
18.6756831696
18.4944025267
18.3517599071
21.2721153347
21.7458330165
20.6440424335
20.6722922607
20.5915211129
20.5129541528
20.0602258803
19.5028708816
19.8068522166
20.5923494466
22.1493733478
23.3220218342
22.0807769518
23.3451182493
25.0316200196
25.1129376244
25.1084474787
28.0209977246
29.2969478666
30.7025750514
33.6838290112
36.0818963411
38.557302783
41.6984747766
44.8677163009
49.3142256697
53.5170584373
58.4221268427
63.7312688774
68.8455718421
74.9238760904
81.8712610282
89.1204900607
98.6598279064
100
100
100
45.7446275539
4.87136662175e-40
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1.03919208886e-39
3.40397343198e-37
1.62772654057e-33
3.92586754684e-26
3.64607847633e-10
75.9405290412
18.407450111
18.0134055301
18.5578684647
20.1829712854
21.34088838
20.7336740208
20.7898921604
20.2501938637
19.8224496156
19.6841873073
18.5266359212
18.6589812295
18.0823562498
19.4383757759
20.2098733346
20.8100781591
19.8804576925
22.1369362386
22.7052971245
23.017550648
23.01100174
26.5455925587
28.3630729971
30.8955652043
33.8107303119
37.6076428107
41.1125246057
46.1169199756
50.396665024
55.8051096373
60.4544389229
65.7865921106
71.7140223042
78.7149829422
86.085588759
95.3918085782
99.9999999997
100
100
100
52.6246790539
1.30781087897e-42
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5.22372927618e-41
4.84395532536e-38
1.26750483519e-34
3.37861449256e-29
1.67443950099e-15
65.8217229445
69.2492023404
17.9841399439
17.1612197326
18.0464556614
17.9059493639
19.6424702126
21.4313852339
22.2594711143
20.5069499961
19.2846823008
18.7006977456
18.0913239255
16.5557107288
16.8758235121
15.1660684859
15.6746332627
17.2894188639
17.3627071264
16.3978783705
19.190540043
19.4054117069
20.2729934222
20.458330261
25.046104456
27.6853782691
31.6665521437
36.5531491137
41.4869152685
45.9702266798
50.9051231542
55.4653710159
60.4524007974
66.7547240767
73.921789902
80.9473552551
88.5890619981
99.3074483751
99.9999999992
100
100
99.9999999999
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1.00862103633e-39
5.32426610009e-36
2.45276257279e-31
1.29543836713e-21
44.4285112798
57.0888149989
60.2757792166
17.5556899249
15.8685536335
15.7509866812
15.8831463332
16.5165615945
19.6373961137
22.2952268154
20.2304298271
18.7158061885
17.6979448446
17.1177632694
15.4248093175
15.3237901045
13.4545180439
12.1997508479
7.87249953809
14.0659462836
12.6092771814
13.0084644588
15.2110382844
14.2784875086
15.6578580658
17.5610873617
24.4683477037
29.9477054951
35.268420776
40.0922513951
44.745980186
50.0232393887
55.2479330257
62.3700424882
68.614968871
74.9464492837
81.6042031634
90.0858718971
99.392722137
99.9999993675
99.9999999812
99.9999999997
99.9999999992
99.9999999959
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7.41830381603e-38
2.08191293437e-33
2.49173326076e-26
4.19089149781e-07
53.3639675714
52.8619302555
51.6476166993
17.5315336553
14.47268063
13.8949346554
13.9606494864
14.4393668816
16.5228920763
19.2393371364
19.7303821824
18.0018511132
16.8004870962
15.8278508283
15.1887943682
11.92348242
11.8969324856
6.02636235651
10.456648529
1.06083378613
11.0614926414
10.1354378881
4.58200182708
10.4647711554
8.21847804149
11.3576136279
20.4216609015
28.3676510265
34.3892437502
38.8329875677
45.012033579
50.6284334369
57.843401527
63.0014991924
68.4721502887
74.8533738643
82.5360829058
91.7155155137
99.9963359009
99.9999999951
100
100
95.0305147703
9.62644567953e-11
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5.58241243598e-41
8.13603532952e-36
8.09107297925e-30
1.94692511437e-15
52.5810639485
53.4788965295
47.3096050198
45.55325327
17.8330922432
13.3705256498
12.3326167855
11.9879288269
12.3699958704
13.72290999
16.4825950633
18.9821332142
17.4582856903
15.9758829248
14.8092835575
13.6210386482
12.1932787707
5.66601541215
5.46038987082
0.0338140800802
5.89375129653
0.0139415982664
11.2610223038
0.572438370661
0.165636902862
0.410770608015
11.7797963126
18.9988863332
27.6494818091
33.8558199569
39.9259484872
46.0596294106
53.0776638343
57.6068068257
62.070472746
69.0958041203
76.4991867687
85.012319217
94.7342026512
99.9999934474
100
100
68.1397856791
9.03150818813e-24
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
6.75292213399e-40
1.81123303787e-33
5.25566050942e-21
53.2586081498
57.1027123266
50.4788254656
44.6487296472
42.2130651094
16.8080991904
12.7003693191
10.9392789242
10.5223552186
10.4390491585
11.3519567932
11.470011998
16.3237909899
17.221396169
15.3544233579
13.9784266033
12.6230080655
10.6820783021
6.63744671136
7.58337382955
0.0221204318917
0.000286386127536
0.041064134806
0.0125999990728
0.00420853094979
0.24158420785
0.21141119911
13.7529449779
20.307338938
28.3175875723
34.4335589948
41.0801459108
47.6484791831
52.1754277723
56.1592742645
63.4583835216
70.3980352185
77.913867569
86.3874569064
95.7070138082
99.9999950946
99.9999999997
100
3.24792837488e-25
1.80336129967e-24
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7.96908228232e-37
4.69898596228e-28
46.6689129083
63.4146463026
55.1024146909
48.1673264139
44.1387747128
42.7444647566
15.1725017748
12.4098200867
9.87906371166
9.38593834573
9.26852135879
9.05140673773
10.8147559071
10.9526210163
15.3652570205
14.6783772806
13.2868651015
12.003310074
9.37405340763
6.88702420759
0.000128353587469
0.000201772188635
5.47244113969e-05
0.721968175219
0.000677701142867
0.00688285846257
0.00779149053726
10.7558986601
14.390558579
23.6696002934
29.3473550087
36.3113975359
42.0106576699
47.2470010137
51.2827245969
58.2787497458
64.7465233728
71.6414102346
78.9091943085
86.815656553
95.1749658277
99.9992976648
99.999999748
99.9999999989
4.55782056496e-24
8.02084478215e-19
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1.51348058705e-41
5.94066154379e-34
6.69684281056e-07
67.7724419237
61.5435937241
54.2979986343
48.6634993709
45.4994808618
44.6553593135
14.2539259246
11.5148933023
9.0030248168
8.13270997594
8.44292758689
8.08214871149
7.1186731195
9.47915363785
9.31739719574
13.7411762965
12.8677275122
11.6999552562
6.96916874185
3.8750711916
3.96241295448e-05
5.88636488313e-06
9.39023014284e-05
2.70924403261e-05
0.000382399185897
0.000269254151213
9.88393671135
12.4229393954
20.5253621947
25.764399033
31.4348846585
37.3112356377
43.4410054914
47.6225135662
54.0617101069
59.8791513636
66.2315829822
72.1425537342
78.4553242444
85.0677182405
91.6625185739
99.6154414738
99.9999972999
94.3846710089
6.03819180562e-24
1.05215451415e-15
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4.72029667887e-40
7.18303113368e-22
68.3958524331
67.0115515829
60.2983182068
54.5799294587
50.5298148626
48.3275229335
47.9653963787
14.4357638185
9.98783476482
7.63771307344
6.58277818258
7.64370749078
7.7747536428
5.86493301871
4.02299543623
6.82232764323
7.64281317619
13.2939508923
12.7354738891
7.60948622256
2.25473004665e-05
1.82205076246e-06
2.520530492e-06
2.75247676554e-06
3.50386988848e-05
2.97437662934e-05
9.27218246851
10.6872929689
19.31430119
23.6847002654
28.4079815731
33.8505534976
39.744502933
44.6279809199
50.598510358
55.8150077476
61.4677820513
66.6452267665
72.217113584
77.4283465915
82.4763245351
87.6993364374
95.9699218223
99.8107938825
28.8927013404
2.20670474292e-23
3.10912223974e-12
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2.00441941117e-35
62.7097886821
72.9926775796
65.9388635352
60.3026824438
55.9604900314
53.0598764462
51.4743299481
50.3971610342
15.3755519248
8.05939509249
3.75864962918
4.95881033074
6.69994009623
7.87286931001
6.54902067658
0.371938409194
5.41993831331
5.23482360148
7.84636013737
11.4176784527
8.25126612178e-07
8.95212249534e-07
3.84241443239e-07
6.08625442327e-07
2.12154913722e-06
5.34989344305e-06
8.05539532724
9.84423216646
17.7764515084
21.978443698
26.6417105568
31.8118010485
36.5638624054
41.7045304086
47.4849093588
52.3975056473
57.6924217838
62.410666632
67.6955413764
71.833224561
75.5246236519
79.2757452086
83.5735202087
89.4241714046
81.8392116852
7.76992869612e-05
3.74319644187e-22
85.012829938
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3.33441554179e-41
41.4463011473
78.2098940294
72.3986812762
66.1131595371
61.6693361466
58.4959800839
56.2897594593
55.1706644262
54.3911840186
15.1859046408
9.05328644976
0.620540755762
0.734336216497
5.63474352264
7.50493626762
6.77242178278
1.19106586159
0.353906780854
7.12442857543e-06
1.99100217266
9.03825057197
8.43557606026e-06
6.67061815212e-08
1.51472700588e-07
2.7476718578e-07
1.61488187705e-06
5.22169174016
9.87835160374
16.6378888746
20.319711467
25.4656662496
30.0506893314
34.6248635285
39.1824715278
44.37584904
49.0312422189
54.5461948381
58.9640637246
63.8271521937
67.7584537949
71.6194315458
74.4079900997
77.6526192339
79.4171809849
77.5788584526
74.5216252942
39.9791946327
5.57816093243e-21
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2.39552929083e-17
77.7634353115
76.4649862621
71.7738777953
67.3099929392
64.223979601
62.7206522154
61.5173119347
60.4621589919
60.2112743182
13.8301719332
0.000118087483994
5.2047193765e-07
0.00260770344799
5.46102663856
7.06518770856
6.78264805981
4.05399587381
0.177398203841
4.48421541599
0.206444882742
1.15584088688e-06
2.89908940434e-09
2.24464701456e-06
7.66043417662e-08
2.70821576444e-07
0.171713977471
10.2042622318
14.9537902649
18.5611056279
23.4105357652
27.3279111102
32.4036836967
37.0268666175
41.1846322941
46.0823477622
51.4225313055
55.9777520148
60.7527767076
64.7405494647
69.1510120463
72.0462833857
74.976194239
78.2223920002
77.286780741
76.8331592831
81.696871533
64.7199185534
1.2080187784e-20
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2.27907918442e-40
71.2863007996
74.9691813575
75.0414344121
72.0919867957
69.5089801297
67.9301940085
67.6368904263
68.5207598314
66.83348495
68.0672288376
12.1182889575
1.4625349312e-08
5.92379167373e-09
1.05115338017
6.15458993395
7.36932219297
7.395536647
5.80924271289
8.4280316025e-09
1.09462703679e-09
1.5641982799e-08
6.15761794711e-09
2.56066514188e-09
8.448393047e-09
2.31622487077e-08
0.00137841535902
10.7600862318
13.1211783097
17.953350371
21.540691914
24.9095287005
29.8842059959
34.810117753
39.0333295528
43.2877932795
48.2045446795
52.7312639924
57.9312052987
61.9487793582
66.3238433318
70.1695527852
74.3098098995
77.9288644179
78.6973287371
77.3616840837
76.1295751682
77.5542623098
82.1902205412
3.27172144592e-20
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
48.7489464108
81.6440735916
78.5063984556
76.2667307786
73.8814355228
72.2343477781
71.3618161594
71.0923426853
72.6869343956
71.835238963
71.3479398003
10.2102580123
4.67347470392e-09
7.82764195126e-10
4.25913846859
7.3258038403
8.09117788818
7.79237417458
6.40296095858
1.43828459496e-06
5.0298246808e-10
2.23043661734e-10
9.28482439823e-10
8.42961388008e-09
3.70370453199e-09
3.41690098222e-07
8.65498321996
13.4771425981
17.2600577541
21.4212707437
23.265175638
27.3691259018
31.7802436945
36.4441202598
40.6623892826
44.6567970183
49.4475812891
54.6722454182
58.9832596925
63.5964833455
67.9780197295
74.0081315346
78.2278371302
81.1847759346
81.4615255991
79.4473047075
73.2871070664
72.1421222803
82.9089907543
5.65404368008e-20
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1.43888681792e-34
85.5745646467
81.4576498226
79.6329343928
77.6952336148
75.9224853749
74.7117410801
73.9583574943
73.4752864354
74.138367526
73.9290593101
72.735988304
6.77045220059
3.74467484603e-10
1.40483850761e-10
7.16540380678
8.99697600003
9.09291202928
8.37545608563
6.76914950904
2.20322423584
2.0867267248e-10
9.28120326288e-11
9.98409778681e-11
5.03706244278e-10
0.000987756768214
6.75466918376
12.1801694605
14.8703036437
18.6032397961
22.127968713
25.7816826851
29.9249662857
33.078029964
37.6347929076
41.8732805496
46.1211209925
51.0211583867
55.7127810437
60.8856389021
65.4046220107
72.5260570282
79.175473734
83.0368514006
85.7586122656
87.2892952484
83.9595003094
78.5382757266
72.5752927954
76.7752256187
3.99809438374e-20
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
72.3200880619
75.7445998423
81.198600681
80.2915785363
79.2223921611
77.9584270679
76.9732507769
76.229386951
75.664383964
76.0333813208
75.5406795781
74.4816615856
1.08588889363e-11
3.61761964544e-11
3.01952946183e-08
10.1749482963
10.7273583757
10.239209156
9.10434197537
7.54549461176
4.12851308228
9.59959398908e-11
4.02636707978e-11
3.86964300871e-11
1.25678560647e-10
6.26371405686e-07
10.4202969343
9.69898639601
16.9030466256
19.4563467709
23.0186941875
26.4896452489
30.652262556
34.5268742758
38.4719174412
42.8363740619
47.2366717807
52.175142714
57.6127440349
62.4220236906
70.0681020018
78.0141968908
82.9618195097
88.2611007319
92.8308466164
95.3215010542
96.0032465839
97.407602439
99.3025056257
99.9999999965
75.4937637619
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3.03179783782e-19
97.2323336848
87.1117978367
84.5255716445
82.4279542514
81.0987029672
79.9173664872
78.9953529115
78.2689507709
77.708164901
77.7840555521
77.0948106096
76.6575778421
4.15950497524e-12
7.19432551253e-12
6.91077345703
10.3218693136
10.5166386011
10.284431132
9.81455096424
8.25235631178
5.62149683942
4.66902235487e-11
1.81228006319e-11
1.72478765036e-11
2.75616956457e-11
0.0441407873732
2.30198356081
14.9220171324
18.2286198635
21.0548337056
24.6601609334
27.8261280956
31.5595180722
35.0975555865
39.2794332054
43.6665376365
48.3815410893
54.0513081309
59.2455011401
66.4955055291
74.4215211197
80.8170079517
87.2669971305
93.9829140871
99.9798830618
99.9999998773
100
100
100
100
100
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
92.1572483438
89.0431210232
88.5443267926
85.7150699889
83.7632969615
82.2787546118
81.1097941425
80.1891641019
79.5006006833
79.0193542247
78.5954026516
77.9226658473
77.8285260783
3.87211272934e-12
3.08198931916e-12
5.98541450459
9.8423955993
10.406733441
10.1876816621
9.51766191631
8.48259366873
6.61231611294
2.20405983165e-11
8.62814152586e-12
8.11080758507e-12
1.52195143158e-11
7.6185842093e-11
11.5884338571
17.0469787054
18.211927289
22.7695653494
26.2407160526
28.5633368266
31.7433153719
35.6180631233
40.1696563147
44.4231290615
50.0390030024
55.577729558
61.860963734
69.1837704318
76.7231362877
83.9695363208
91.4597360975
99.9698985239
99.999999986
100
100
100
100
100
99.0972991406
7.69424228034e-12
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1.20589029421e-26
93.9735631317
89.8489943815
87.9820627287
85.8321055717
84.0365294477
82.2710401615
80.9635114154
79.869933458
79.0297179899
78.7232215589
78.0466815302
77.2590191423
77.5455456598
5.21077121563e-12
1.56648298707e-12
1.56802609686e-11
10.1216349586
10.7536464651
10.2825677912
9.39733840778
8.03657468197
6.21844564146
4.46403372e-11
4.72194740831e-12
4.24424242854e-12
8.55497230391e-12
1.95171345323
9.7895655594
14.4104763317
20.5372326672
23.6363465779
25.3544202918
29.4850856977
33.2010155729
36.2418966584
40.1057233096
45.7547631523
51.5920455737
56.6710968536
63.5527179771
71.5236186983
79.0836002024
86.641061391
96.9944465818
99.9999988536
100
100
100
100
100
100
1.38414979499e-18
7.11479689614e-20
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
97.5001871143
88.5438323765
89.6125745013
87.2259104616
85.5195847479
83.3560260467
81.3171186233
79.6942116395
78.2922071546
77.1135757042
76.1690596196
75.6546227301
75.3364928083
76.1756242179
1.50246161555e-11
9.83534458433e-13
1.03853504964e-12
10.6396671301
11.1846346766
10.4253498738
9.27717446024
7.60113600018
4.91574198469
4.87918432377e-12
3.07457886527e-12
2.77153055069e-12
4.42811415178e-12
3.20038024137
9.80343833144
13.8391025287
19.2064295552
23.5223170756
26.4034779409
30.292055562
31.9393663374
36.3438003092
42.0700996645
47.2474907407
51.4718942081
58.3517305316
65.8513644168
72.6743552863
80.8299794281
90.827363085
99.9887067038
99.9999999934
100
100
100
100
100
100
1.15319716146e-23
12.2486608287
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5.24276424906e-39
99.9999996579
96.1263385559
91.5346338765
87.9199424169
85.2120028503
82.8478026358
80.0825460933
78.0997768678
76.4801822876
75.1886603333
74.2051244735
73.7961028833
73.2260708535
73.7530308213
6.89408844301e-10
8.82273957605e-13
4.46235447415e-13
10.9343399806
11.4589760889
10.4926666012
9.10725196509
7.21891298348
4.58058378435
2.86986275703e-12
1.64242203493e-12
1.80044445266e-12
5.22262830503e-12
5.48306085298
10.3861074151
14.317353207
17.5993821372
22.1452344719
26.7824903431
29.3002492358
32.6934851049
37.7810105159
42.8634154998
46.2033876642
52.7490770711
59.9163532322
66.2269869839
74.022763899
83.4430669872
93.2112574843
99.9996167741
99.9999999999
100
100
100
100
100
100
2.71332210262e-28
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
95.6438908243
88.5019701759
95.6299388612
91.975731561
88.4682678104
85.1671083145
82.099762396
78.9755962269
76.6612659091
74.8551675103
73.4630051604
72.5359833883
72.1812056007
71.339736477
70.6245311871
2.30399428017e-12
9.14310949081e-10
2.84559845408e-13
10.2316824743
11.5317940101
10.3867999197
8.63311497288
5.50162888971
1.60846471834e-12
7.24449066752e-13
5.95268754131e-13
7.07593783777e-13
1.41672638181e-12
5.93932040431
11.8719942644
15.3190104631
17.7507555392
20.2672682477
24.4229757492
28.9908185855
32.7898652714
37.2977010913
41.1565405873
46.4608260309
54.0298246841
60.4252417728
66.2672332083
74.4934766206
84.2914161834
95.7073594735
99.9999874775
100
100
100
100
100
100
100
7.19904900283e-28
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
100
99.9999999998
99.9746672397
94.6452970908
90.0131050317
85.4738630068
81.4775898972
78.1938798315
75.6011730703
73.6042326345
72.0648838676
71.1257523225
70.5227079876
69.6097344481
68.8968440075
1.47249040079e-12
5.0816762977
1.73419337941e-13
9.27545966821
11.5975049855
10.214921676
8.28108513743
6.77217050058
4.59484830193
2.38078815132e-11
3.81890959184e-12
2.95285464105e-12
8.43306136153e-12
6.73605674027
12.2638471948
15.5135642381
18.0833669292
20.5220932576
22.7681858355
25.4845380897
30.4387743021
35.5507960807
40.1766952708
46.495606324
53.6541793809
59.7379080926
66.404935811
75.5028329204
85.9322091543
95.9934049545
99.9999907776
100
100
100
100
100
100
100
9.33473257425e-22
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1.22274325488e-13
83.5931159162
99.9999998693
99.9981411835
96.8000884405
90.9794802618
86.3819527184
81.4135440088
77.8080821797
74.8982974116
72.6992820251
71.1333975699
70.4266497392
69.092497655
68.1260814555
67.522148736
3.05287508617e-13
5.69131432396
1.00547998916e-13
9.72400477861
10.9613393397
8.56059973461
5.60125054399
2.72705566528
1.27282997142e-13
7.32148436477e-14
6.64731588721e-14
8.42898682928e-14
1.81387935931e-13
4.44713170816
12.7965075349
16.5639195333
18.1125897262
19.4744668766
21.4174171421
24.3557447718
27.8845627698
32.1659106389
38.0094313011
45.7544583329
53.094017902
59.7817640151
65.7181700181
74.4403123153
84.7924068694
96.737270749
99.999999303
100
100
100
100
100
100
100
1.18597110626e-20
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
100
100
100
99.9999998239
99.6733866479
93.010154659
86.8256520743
81.7715149618
77.523845369
74.1216390431
71.6160215878
69.9209368519
68.8696238022
67.3953110597
66.5895631819
66.6961207688
4.18198459959e-13
1.95483147638
5.86923028276e-14
9.34343389424
8.34660728889
6.08580608067
4.41323729924
2.96085469989
3.48670658865e-14
3.74604983423e-14
5.44243310097e-14
1.16527384396e-13
1.65650890715e-12
6.02493134307
12.3849387723
14.9279169764
16.1045190801
17.0185024305
19.0753838886
22.9198786651
26.651718055
31.1816927966
36.7632691993
43.5686232198
50.3869587893
56.4452045756
63.5858548293
73.6490827638
84.8480948465
97.6472581762
99.9999997054
100
100
100
100
100
100
100
1.75722881253e-19
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1.06219445838e-39
99.9999999999
100
100
99.9999999999
99.9981825405
94.9745191133
87.618971767
81.7882706531
76.8769907983
72.8284343575
69.8294590102
67.8827614581
66.2189497342
64.8979226885
63.9754559774
64.6759741948
3.77161266954
3.90520860754e-14
3.5788076974e-14
10.8164731599
9.34905884172
6.26354322442
4.41048152582
2.95489988078
2.4995939605e-14
2.35960549435e-14
2.48486580136e-14
2.99639341432e-14
5.5705776954e-14
0.018228050463
12.811871641
15.5542784848
16.1035843349
16.2638473234
17.0025376093
19.2062798894
23.423952538
29.0974380339
35.2664198056
41.8359196121
47.7063775386
53.7990322479
61.7005679657
71.8942155956
84.0042726965
96.6337261876
99.9999971974
100
100
100
100
100
100
100
7.03160677046e-19
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
79.8071339512
100
100
100
100
99.9999991905
96.2887674781
88.2363321418
81.3761922824
75.7283525346
71.0865381554
67.4451488316
64.830859336
62.6057311647
61.1701980921
60.1164715047
61.0816524613
8.38344901505
1.1526836429e-12
3.31650068723e-14
11.427718802
10.6598581349
6.11883024965
4.8593168995
3.41638563379
1.63277048686e-14
1.92578050063e-14
3.8428579445e-14
9.23157692722e-14
1.05944627088e-13
2.53044562746e-07
11.4281914872
15.2858145445
15.3588171469
14.1163868219
13.0066344352
14.8995419712
19.9885261234
26.2243168625
32.6552281349
39.1794968805
45.7826065358
51.9001453489
60.2831459136
70.114486888
81.0543146093
93.4373724807
99.9999358451
100
100
100
100
100
100
100
3.00183191007e-17
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
100
100
100
100
100
99.9999999999
99.6170683543
89.2972490732
80.8735641304
74.3385319786
69.0751733086
64.0883242628
60.5332811871
58.0275364556
56.6257292826
55.6015802452
56.4004569284
9.69553056411
0.00573806166488
4.29687540936e-14
0.614682499151
6.48967535568
6.89703123818
6.06192290715
5.55391164587
6.21599506709
1.16107987732e-13
3.68628015198e-14
2.7313463083e-14
2.74619774202e-14
5.4948453417e-14
9.68870066894
15.520098213
15.2946960381
11.8849136331
5.25896826558
7.02643435939
14.7443396637
23.5751444181
30.7205926609
36.6721743042
42.496028788
49.2017520132
57.6348039058
67.5126929102
78.401661804
89.9849941422
99.9685133095
99.9999999974
100
100
100
100
100
100
1.18858735385e-16
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5.28973061215e-39
100
100
100
100
100
100
99.9999591766
91.5892630535
80.9202915055
72.6483136363
66.3533959798
61.2222477608
57.1574551655
53.6505102531
51.3993312005
50.8528890722
50.7803320295
7.44424623229
3.99237444631
1.23301127976e-13
2.50837021741e-11
7.18520098184
9.58034637035
10.4834338755
8.85057994482
6.04010136053
1.39927395607e-13
3.28613593863e-14
2.11111449702e-14
1.75419182177e-14
2.16564592082e-14
6.89653867346
15.7745917584
16.5458526844
12.4522902631
4.10282580632
3.049753893e-08
9.66978537393
19.8765118653
27.0345212082
32.8401282243
38.7209851208
45.6542706162
54.3288328639
64.2795646652
74.2849328972
84.077330273
95.802476132
99.9999996371
100
100
100
100
100
100
0.197505835443
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
95.7852029823
100
100
100
100
100
100
99.9999999913
94.7985176414
81.8210381742
71.4180551633
63.589896971
57.3087648431
52.6803760921
49.1784237917
45.5779712218
45.4166800953
44.5724371213
4.86852923714
5.46382502144
5.2328724602e-13
9.99515725827e-13
9.4260931805
11.2523832761
10.6517992647
9.86600758842
8.61407881847
0.931925035085
7.51193961694e-14
2.08825479605e-14
1.42769257188e-14
1.42459415412e-14
9.59812883318e-08
18.0083387161
20.5291009917
9.5253633714
6.56426131609e-13
3.41747712273e-14
3.7080786698e-14
6.47648932754
22.3381142652
28.6640362231
33.9842648003
40.8471469899
49.6619679056
60.0554532101
68.8563462133
76.4516203791
87.0518227839
99.9649588599
99.9999999719
100
100
100
100
100
3.4068412943e-10
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
100
100
100
100
100
100
100
100
98.7017993289
83.9471950747
71.3133887806
61.8596637305
54.059952019
47.9537955392
43.8135239473
39.7572983803
38.9497222044
39.4924317622
4.53288581401
7.56693604142
1.88436491979e-11
3.07283396353e-13
11.3280475907
11.7827821677
11.7194819505
11.3473284189
10.7702812543
8.40712231485
5.24914566303e-08
3.08539840201e-14
1.15381554379e-14
9.53642236694e-15
10.4051296608
23.1541634365
17.174735755
1.53498580679e-10
3.14337870979e-12
9.09532534441e-15
2.2055485621e-15
6.52369475347e-07
11.2984305123
20.7853546562
24.6843400394
33.5830289456
43.0273566962
55.7641561212
63.3314457288
66.5781876216
74.2016461755
87.9896921779
99.2179036842
99.9999999517
100
100
100
100
99.9999999965
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1.22689813682e-39
100
100
100
100
100
100
100
100
99.9995307143
86.7107734981
72.0806449202
60.7160079567
52.2454922224
44.6935524297
38.4948310209
33.7210440782
33.3496394105
37.2624584678
0.246984986611
6.9676349732e-05
1.16412206002e-11
6.93595482018e-06
13.027065165
13.4913080524
13.7471151253
13.5786214267
13.4012870106
12.8206136067
4.17263320045
4.11818746095e-11
2.03769150709e-14
6.08956023993e-15
3.93612509735e-15
24.9362464786
8.454323335e-08
1.70375945594e-10
3.64023979961e-09
0.424826978638
7.3648032985e-16
1.76298840097e-16
1.2552397454e-07
13.4164369213
23.1764986637
23.6740406212
28.4161850513
46.8935826901
60.2522702174
54.3109497994
55.8331993489
65.943058235
77.7022583357
94.4493366963
99.999999972
100
100
100
100
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
100
100
100
100
100
100
100
100
100
99.9999992544
89.0533776167
73.2799526437
60.4886501171
50.6290266782
42.8563887507
36.4420101282
31.601824025
31.1194444816
29.8308590512
1.49228620319
2.37114187282e-11
3.74171292552e-09
1.43715632672e-13
13.8041264572
15.8092170855
16.7551612955
16.6374868206
16.8096975294
15.6152803802
13.77566309
0.00871448609871
1.21266376543e-13
4.63691516286e-15
3.21317887747e-15
4.41731361485e-14
3.43464574139e-11
0.278433213611
22.7415825725
13.9294490636
1.62012919884e-16
3.16859384621e-17
7.24808697268e-18
5.51404284949e-18
5.59279260601e-18
2.98561811927e-11
2.55574844346
2.49488317796e-15
35.7133198588
42.0050959183
39.4969413861
60.5753472878
64.4424170443
81.9109772674
94.5642871676
99.9999972938
99.9999999856
100
100
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1.98636809388e-41
97.3813465163
100
100
100
100
100
100
100
100
99.9999999583
90.5889420415
74.866916116
61.5067344555
50.6997473039
42.4007232698
35.5292104991
29.6166509053
25.8591023634
19.2394253547
1.12415342956
6.27372448485
0.259121587919
2.84814618321e-13
3.66736856933e-15
1.01921847927e-14
1.14659725523e-11
7.41599689917e-14
5.23186539242e-14
2.77514991782e-14
1.47931157316e-14
7.42712999487e-15
3.21932525033e-15
1.09574149954e-15
4.04290508251e-16
1.13588711258e-16
5.68430664461e-17
5.32807422414e-17
3.88014317492e-17
2.43860249143e-17
1.60315352536e-17
9.54690448385e-18
4.75223579481e-18
2.56975066428e-18
2.07811759969e-18
1.3216467239e-18
6.38766284649e-19
2.66609015142e-19
1.88843235253e-19
6.85055076479e-20
6.18719842116e-20
3.33048284692e-21
8.33209209871e-19
6.07898853328e-24
8.9872458686e-19
4.32048541107e-27
7.31473209448e-18
9.39906340849e-33
5.94188211329e-32
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3.30451659572e-41
100
1.45936156318e-20
100
100
100
100
100
100
100
99.9999999534
90.1268661088
74.5911619145
61.3307618923
49.9257626805
40.6063209946
33.0261784039
27.0112223673
22.9177819592
12.9507535599
)
;
boundaryField
{
frontAndBack
{
type empty;
}
upperWall
{
type calculated;
value uniform 0;
}
lowerWall
{
type calculated;
value uniform 0;
}
inlet
{
type calculated;
value uniform 1.18103084448e-38;
}
outlet
{
type calculated;
value nonuniform List<scalar>
20
(
6.80125607649e-41
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5.83225108388e-42
1.32198017838e-40
)
;
}
}
// ************************************************************************* //
| [
"as998@snu.edu.in"
] | as998@snu.edu.in | |
e7342592750078f287a06478992b6a6752c6282d | e6317162fd2ac60acf13090eec30c6e577f5bcb1 | /leetCode/121.Best Time to Buy and Sell Stock.hpp | 0d78057765d324f4154eed7a85aac6f555b88991 | [
"Apache-2.0"
] | permissive | CainHsu/ProgramStudy-leetcode | 024a9fb093a0ce9cdaab6b8ece82ba94ede5b5c2 | 23653e8927902aed64ba13a23a1d6c983b7ea5d5 | refs/heads/master | 2021-06-26T10:35:34.447660 | 2021-05-16T12:47:04 | 2021-05-16T12:47:04 | 226,617,577 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 614 | hpp | //
// Created by xuche on 2020/7/18.
//
#ifndef PROGRAMSTUDY_LEETCODE_121_BEST_TIME_TO_BUY_AND_SELL_STOCK_HPP
#define PROGRAMSTUDY_LEETCODE_121_BEST_TIME_TO_BUY_AND_SELL_STOCK_HPP
#include "vector"
#include "algorithm"
using namespace std;
int maxProfit(vector<int>& prices) {
if(prices.empty()) return 0;
int minPrice = prices[0], profit = 0;
for(int index = 0; index < prices.size(); ++index){
minPrice = min(prices[index], minPrice);
profit = max(prices[index]-minPrice, profit);
}
return profit;
}
#endif //PROGRAMSTUDY_LEETCODE_121_BEST_TIME_TO_BUY_AND_SELL_STOCK_HPP
| [
"xu.chen28@qq.com"
] | xu.chen28@qq.com |
c6ce1704a6ec39943be3ef5c527b4b5e9e717b72 | 5581e60b6de66a24c150003e36382f2ae8afd1e0 | /CvGameCoreDLL_Expansion2/CvProjectClasses.cpp | 2afacd027b9b2e64c51642017a8b3725645f91eb | [] | no_license | HungryForFood/Community-Patch-DLL | bf86b3809cd11eda8aa44c1b05af67fff8f56548 | 6411822d8f0976317ad8ac2a936df46c76d34251 | refs/heads/master | 2021-12-08T12:47:12.557952 | 2021-08-13T15:36:24 | 2021-08-13T15:36:24 | 113,146,758 | 0 | 0 | null | 2017-12-05T07:13:30 | 2017-12-05T07:13:30 | null | WINDOWS-1252 | C++ | false | false | 11,709 | cpp | /* -------------------------------------------------------------------------------------------------------
© 1991-2012 Take-Two Interactive Software and its subsidiaries. Developed by Firaxis Games.
Sid Meier's Civilization V, Civ, Civilization, 2K Games, Firaxis Games, Take-Two Interactive Software
and their respective logos are all trademarks of Take-Two interactive Software, Inc.
All other marks and trademarks are the property of their respective owners.
All rights reserved.
------------------------------------------------------------------------------------------------------- */
#include "CvGameCoreDLLPCH.h"
#include "ICvDLLUserInterface.h"
#include "CvGameCoreUtils.h"
// include this after all other headers!
#include "LintFree.h"
CvProjectEntry::CvProjectEntry(void):
m_piResourceQuantityRequirements(NULL),
m_piVictoryThreshold(NULL),
m_piVictoryMinThreshold(NULL),
m_piProjectsNeeded(NULL),
#if defined(MOD_BALANCE_CORE)
m_piHappinessNeedModifier(NULL),
m_eFreeBuilding(NO_BUILDINGCLASS),
m_eFreePolicy(NO_POLICY),
#endif
m_piFlavorValue(NULL)
{
}
//------------------------------------------------------------------------------
CvProjectEntry::~CvProjectEntry(void)
{
SAFE_DELETE_ARRAY(m_piHappinessNeedModifier);
SAFE_DELETE_ARRAY(m_piResourceQuantityRequirements);
SAFE_DELETE_ARRAY(m_piVictoryThreshold);
SAFE_DELETE_ARRAY(m_piVictoryMinThreshold);
SAFE_DELETE_ARRAY(m_piProjectsNeeded);
SAFE_DELETE_ARRAY(m_piFlavorValue);
}
//------------------------------------------------------------------------------
bool CvProjectEntry::CacheResults(Database::Results& kResults, CvDatabaseUtility& kUtility)
{
if(!CvBaseInfo::CacheResults(kResults, kUtility))
return false;
m_iMaxGlobalInstances = kResults.GetInt("MaxGlobalInstances");
m_iMaxTeamInstances = kResults.GetInt("MaxTeamInstances");
m_iProductionCost = kResults.GetInt("Cost");
m_iNukeInterception = kResults.GetInt("NukeInterception");
m_iCultureBranchesRequired = kResults.GetInt("CultureBranchesRequired");
m_iTechShare = kResults.GetInt("TechShare");
m_iVictoryDelayPercent = kResults.GetInt("VictoryDelayPercent");
m_bSpaceship = kResults.GetBool("Spaceship");
m_bAllowsNukes = kResults.GetBool("AllowsNukes");
#if defined(MOD_BALANCE_CORE)
m_iGoldMaintenance = kResults.GetInt("Maintenance");
m_iCostScalerEra = kResults.GetInt("CostScalerEra");
m_iCostScalerNumRepeats = kResults.GetInt("CostScalerNumRepeats");
m_bIsRepeatable = kResults.GetBool("IsRepeatable");
m_iNumRequiredTier3Tenets = kResults.GetInt("NumRequiredTier3Tenets");
m_bInfluenceAllRequired = kResults.GetBool("InfluenceAllRequired");
m_bIdeologyRequired = kResults.GetBool("IdeologyRequired");
m_iHappiness = kResults.GetInt("Happiness");
m_iEmpireMod = kResults.GetInt("EmpireMod");
m_iEspionageMod = kResults.GetInt("EspionageMod");
const char* szFreeBuilding = kResults.GetText("FreeBuildingClassIfFirst");
if(szFreeBuilding)
{
m_eFreeBuilding = (BuildingClassTypes)GC.getInfoTypeForString(szFreeBuilding, true);
}
const char* szFreePolicy = kResults.GetText("FreePolicyIfFirst");
if(szFreePolicy)
{
m_eFreePolicy = (PolicyTypes)GC.getInfoTypeForString(szFreePolicy, true);
}
#endif
m_strMovieArtDef = kResults.GetText("MovieDefineTag");
const char* szVictoryPrereq = kResults.GetText("VictoryPrereq");
m_iVictoryPrereq = GC.getInfoTypeForString(szVictoryPrereq, true);
const char* szTechPrereq = kResults.GetText("TechPrereq");
m_iTechPrereq = GC.getInfoTypeForString(szTechPrereq, true);
const char* szEveryoneSpecialUnit = kResults.GetText("EveryoneSpecialUnit");
m_iEveryoneSpecialUnit = GC.getInfoTypeForString(szEveryoneSpecialUnit, true);
const char* szCreateSound = kResults.GetText("CreateSound");
SetCreateSound(szCreateSound);
const char* szAnyonePrereqProject = kResults.GetText("AnyonePrereqProject");
m_iAnyoneProjectPrereq = GC.getInfoTypeForString(szAnyonePrereqProject, true);
//Arrays
const char* szProjectType = GetType();
kUtility.PopulateArrayByValue(m_piResourceQuantityRequirements, "Resources", "Project_ResourceQuantityRequirements", "ResourceType", "ProjectType", szProjectType, "Quantity");
kUtility.SetYields(m_piHappinessNeedModifier, "Project_NeedsModifierYield", "ProjectType", szProjectType);
//Victory Thresholds
{
const int iNumVictories = kUtility.MaxRows("Victories");
kUtility.InitializeArray(m_piVictoryThreshold, iNumVictories);
kUtility.InitializeArray(m_piVictoryMinThreshold, iNumVictories);
Database::Results kDBResults;
char szQuery[512] = {0};
sprintf_s(szQuery, "select VictoryType, Threshold, MinThreshold from Project_VictoryThresholds where ProjectType = '%s';", szProjectType);
if(DB.Execute(kDBResults, szQuery))
{
while(kDBResults.Step())
{
const char* szVictoryType = kDBResults.GetText("VictoryType");
const int idx = GC.getInfoTypeForString(szVictoryType, true);
const int iThreshold = kDBResults.GetInt("Threshold");
const int iMinThreshold = kDBResults.GetInt("MinThreshold");
m_piVictoryThreshold[idx] = iThreshold;
m_piVictoryMinThreshold[idx] = iMinThreshold;
}
}
}
kUtility.SetFlavors(m_piFlavorValue, "Project_Flavors", "ProjectType", szProjectType);
kUtility.PopulateArrayByValue(m_piProjectsNeeded, "Projects", "Project_Prereqs", "PrereqProjectType", "ProjectType", szProjectType, "AmountNeeded");
return true;
}
//------------------------------------------------------------------------------
/// What victory does this contribute to?
int CvProjectEntry::GetVictoryPrereq() const
{
return m_iVictoryPrereq;
}
/// Technology prerequisite
int CvProjectEntry::GetTechPrereq() const
{
return m_iTechPrereq;
}
/// Is there a project someone must have completed?
int CvProjectEntry::GetAnyoneProjectPrereq() const
{
return m_iAnyoneProjectPrereq;
}
/// Set whether or not there a project someone must have completed
void CvProjectEntry::SetAnyoneProjectPrereq(int i)
{
m_iAnyoneProjectPrereq = i;
}
/// Is there a maximum number of these in the world?
int CvProjectEntry::GetMaxGlobalInstances() const
{
return m_iMaxGlobalInstances;
}
/// Is there a maximum number of these for one team?
int CvProjectEntry::GetMaxTeamInstances() const
{
return m_iMaxTeamInstances;
}
/// Shields to construct the building
int CvProjectEntry::GetProductionCost() const
{
return m_iProductionCost;
}
/// Percent chance of intercepting nukes
int CvProjectEntry::GetNukeInterception() const
{
return m_iNukeInterception;
}
/// Number of Policy branches required to build this project
int CvProjectEntry::GetCultureBranchesRequired() const
{
return m_iCultureBranchesRequired;
}
/// Does it grant all techs known by X civs? (X is value returned)
int CvProjectEntry::GetTechShare() const
{
return m_iTechShare;
}
/// Special unit enabled by this wonder
int CvProjectEntry::GetEveryoneSpecialUnit() const
{
return m_iEveryoneSpecialUnit;
}
/// Percent delay in declaring victory
int CvProjectEntry::GetVictoryDelayPercent() const
{
return m_iVictoryDelayPercent;
}
/// Find value of flavors associated with this building
int CvProjectEntry::GetFlavorValue(int i) const
{
CvAssertMsg(i < GC.getNumFlavorTypes(), "Index out of bounds");
CvAssertMsg(i > -1, "Index out of bounds");
if(i > -1 && i < GC.getNumFlavorTypes() && m_piFlavorValue)
{
return m_piFlavorValue[i];
}
return 0;
}
/// Is this a spaceship part?
bool CvProjectEntry::IsSpaceship() const
{
return m_bSpaceship;
}
/// Does this allow you to build nukes?
bool CvProjectEntry::IsAllowsNukes() const
{
return m_bAllowsNukes;
}
#if defined(MOD_BALANCE_CORE)
int CvProjectEntry::CostScalerEra() const
{
return m_iCostScalerEra;
}
int CvProjectEntry::GetGoldMaintenance() const
{
return m_iGoldMaintenance;
}
int CvProjectEntry::CostScalerNumberOfRepeats() const
{
return m_iCostScalerNumRepeats;
}
/// Free building if first
BuildingClassTypes CvProjectEntry::GetFreeBuilding() const
{
return m_eFreeBuilding;
}
PolicyTypes CvProjectEntry::GetFreePolicy() const
{
return m_eFreePolicy;
}
int CvProjectEntry::GetNumRequiredTier3Tenets() const
{
return m_iNumRequiredTier3Tenets;
}
bool CvProjectEntry::InfluenceAllRequired() const
{
return m_bInfluenceAllRequired;
}
bool CvProjectEntry::IdeologyRequired() const
{
return m_bIdeologyRequired;
}
bool CvProjectEntry::IsRepeatable() const
{
return m_bIsRepeatable;
}
int CvProjectEntry::GetHappinessNeedModifier(int i) const
{
CvAssertMsg(i < NUM_YIELD_TYPES, "Index out of bounds");
CvAssertMsg(i > -1, "Index out of bounds");
if (i > -1 && i < NUM_YIELD_TYPES && m_piHappinessNeedModifier)
{
return m_piHappinessNeedModifier[i];
}
return 0;
}
int CvProjectEntry::GetHappiness() const
{
return m_iHappiness;
}
int CvProjectEntry::GetEmpireMod() const
{
return m_iEmpireMod;
}
int CvProjectEntry::GetEspionageMod() const
{
return m_iEspionageMod;
}
#endif
/// Retrieve movie file name
const char* CvProjectEntry::GetMovieArtDef() const
{
return m_strMovieArtDef;
}
/// Retrieve sound to play on creation
const char* CvProjectEntry::GetCreateSound() const
{
return m_strCreateSound;
}
/// Set sound to play on creation
void CvProjectEntry::SetCreateSound(const char* szVal)
{
m_strCreateSound = szVal;
}
// ARRAYS
/// Resources consumed to construct
int CvProjectEntry::GetResourceQuantityRequirement(int i) const
{
CvAssertMsg(i < GC.getNumResourceInfos(), "Index out of bounds");
CvAssertMsg(i > -1, "Index out of bounds");
if(i > -1 && i < GC.getNumResourceInfos() && m_piResourceQuantityRequirements)
{
return m_piResourceQuantityRequirements[i];
}
return -1;
}
/// Maximum number of these needed for victory condition
int CvProjectEntry::GetVictoryThreshold(int i) const
{
CvAssertMsg(i < GC.getNumVictoryInfos(), "Index out of bounds");
CvAssertMsg(i > -1, "Index out of bounds");
if(i > -1 && i < GC.getNumVictoryInfos() && m_piVictoryThreshold)
{
return m_piVictoryThreshold[i];
}
return -1;
}
/// Minimum number of these needed for victory condition
int CvProjectEntry::GetVictoryMinThreshold(int i) const
{
CvAssertMsg(i < GC.getNumVictoryInfos(), "Index out of bounds");
CvAssertMsg(i > -1, "Index out of bounds");
if(i > -1 && i < GC.getNumVictoryInfos())
{
if(m_piVictoryMinThreshold && m_piVictoryMinThreshold[i] != 0)
{
return m_piVictoryMinThreshold[i];
}
return GetVictoryThreshold(i);
}
return 0;
}
/// Other projects required before this one can be built
int CvProjectEntry::GetProjectsNeeded(int i) const
{
CvAssertMsg(i < GC.getNumProjectInfos(), "Index out of bounds");
CvAssertMsg(i > -1, "Index out of bounds");
if(i > -1 && i < GC.getNumProjectInfos() && m_piProjectsNeeded)
{
return m_piProjectsNeeded[i];
}
return 0;
}
//=====================================
// CvProjectXMLEntries
//=====================================
/// Constructor
CvProjectXMLEntries::CvProjectXMLEntries(void)
{
}
/// Destructor
CvProjectXMLEntries::~CvProjectXMLEntries(void)
{
DeleteArray();
}
/// Returns vector of project entries
std::vector<CvProjectEntry*>& CvProjectXMLEntries::GetProjectEntries()
{
return m_paProjectEntries;
}
/// Number of defined projects
int CvProjectXMLEntries::GetNumProjects()
{
return m_paProjectEntries.size();
}
/// Clear project entries
void CvProjectXMLEntries::DeleteArray()
{
for(std::vector<CvProjectEntry*>::iterator it = m_paProjectEntries.begin(); it != m_paProjectEntries.end(); ++it)
{
SAFE_DELETE(*it);
}
m_paProjectEntries.clear();
}
/// Get a specific entry
CvProjectEntry* CvProjectXMLEntries::GetEntry(int index)
{
#if defined(MOD_BALANCE_CORE)
return (index!=NO_PROJECT) ? m_paProjectEntries[index] : NULL;
#else
return m_paProjectEntries[index];
#endif
}
| [
"thewizardofwas@gmail.com"
] | thewizardofwas@gmail.com |
b5c04f5fd3d18f36667194c576ca80647427ac9c | 53b62066493bbfb0a8492f4f065af7abbc0314be | /_engine/src/engine/render/camera.h | 25af7cdfc48e784edc4e0084b6a962a0b36d2945 | [] | no_license | mevoroth/meet-minecraft-bots | 5d39892c27322bbb1837845d1fdefa961eb45e96 | 8e699f797eaad7f2751e5c9bdacf3e697f11f3b9 | refs/heads/master | 2020-03-25T17:24:21.352175 | 2014-08-23T23:54:45 | 2014-08-23T23:54:45 | null | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 3,611 | h | #ifndef __SIMPLE_CAM_H__
#define __SIMPLE_CAM_H__
#include "external/gl/glew.h"
#include "external/gl/freeglut.h"
#include "engine/utils/types_3d.h"
#include "engine/utils/ny_utils.h"
class NYCamera
{
public:
NYVert3Df _Position; ///< Position de la camera
NYVert3Df _LookAt; ///< Point regarde par la camera
NYVert3Df _Direction; ///< Direction de la camera
NYVert3Df _UpVec; ///< Vecteur up de la camera
NYVert3Df _NormVec; ///< Si on se place dans la camera, indique la droite
NYVert3Df _UpRef; ///< Ce qu'on considère comme le "haut" dans notre monde (et pas le up de la cam)
NYFloatMatrix _InvertViewMatrix; ///< Pour les shaders, pour repasser de la modelview a la model
NYCamera()
{
_Position = NYVert3Df(0,-1,0);
_LookAt = NYVert3Df(0,0,0);
_UpRef = NYVert3Df(0,0,1);
_UpVec = _UpRef;
updateVecs();
}
/**
* Mise a jour de la camera
*/
virtual void update(float elapsed)
{
}
/**
* Definition du point regarde
*/
void setLookAt(NYVert3Df lookat)
{
_LookAt = lookat;
updateVecs();
}
/**
* Definition de la position de la camera
*/
void setPosition(NYVert3Df pos)
{
_Position = pos;
updateVecs();
}
/**
* Definition du haut de notre monde
*/
void setUpRef(NYVert3Df upRef)
{
_UpRef = upRef;
updateVecs();
}
/**
* Deplacement de la camera d'un delta donné
*/
void move(NYVert3Df delta)
{
_Position += delta;
_LookAt += delta;
updateVecs();
}
/**
* Deplacement de la camera d'un delta donné
*/
void moveTo(NYVert3Df & target)
{
this->move(target-_Position);
}
/**
* On recalcule les vecteurs utiles au déplacement de la camera (_Direction, _NormVec, _UpVec)
* on part du principe que sont connus :
* - la position de la camera
* - le point regarde par la camera
* - la vecteur up de notre monde
*/
void updateVecs(void)
{
_Direction = _LookAt;
_Direction -= _Position;
_Direction.normalize();
_UpVec = _UpRef;
_NormVec = _Direction.vecProd(_UpVec);
_NormVec.normalize();
_UpVec = _NormVec.vecProd(_Direction);
_UpVec.normalize();
}
/**
* Rotation droite gauche en subjectif
*/
void rotate(float angle)
{
_LookAt -= _Position;
_LookAt.rotate(_UpRef,angle);
_LookAt += _Position;
updateVecs();
}
/**
* Rotation haut bas en subjectif
*/
void rotateUp(float angle)
{
_LookAt -= _Position;
_LookAt.rotate(_NormVec,angle);
_LookAt += _Position;
updateVecs();
}
/**
* Rotation droite gauche en troisième personne
*/
void rotateAround(float angle)
{
_Position -= _LookAt;
_Position.rotate(_UpRef,angle);
_Position += _LookAt;
updateVecs();
}
/**
* Rotation haut bas en troisième personne
*/
void rotateUpAround(float angle)
{
_Position -= _LookAt;
//On ne monte pas trop haut pour ne pas passer de l'autre coté
NYVert3Df previousPos = _Position;
_Position.rotate(_NormVec,angle);
NYVert3Df normPos = _Position;
normPos.normalize();
float newAngle = normPos.scalProd(_UpRef);
if(newAngle > 0.99 || newAngle < -0.99)
_Position = previousPos;
_Position += _LookAt;
updateVecs();
}
/**
* Calcul du bon repère de départ pour la matrice monde
*/
void look(void)
{
gluLookAt(_Position.X, _Position.Y,_Position.Z,_LookAt.X,_LookAt.Y,_LookAt.Z,_UpVec.X,_UpVec.Y,_UpVec.Z);
_InvertViewMatrix.createViewMatrix(_Position,_LookAt,_UpVec);
_InvertViewMatrix.invert();
}
};
#endif | [
"mevoroth@gmail.com"
] | mevoroth@gmail.com |
4dc53ae0cd68ee3d431c04825f2c98e794ff552d | a5edb9bc455f8e1e4cb7e20842ab0eeb8f602049 | /source/net/udp/udpclient.cpp | 5ba44f1e834a749c1bb26e70b7a9a1e12be3ba7a | [
"Apache-2.0"
] | permissive | lwIoT/lwiot-core | 32d148b4527c9ca9f4b9716bd89ae10d4a99030e | 07d2a3ba962aef508911e453268427b006c57701 | refs/heads/master | 2020-03-13T06:47:44.493308 | 2019-08-30T15:15:21 | 2019-08-30T15:15:21 | 131,012,032 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,169 | cpp | /*
* UDP client implementation.
*
* @author Michel Megens
* @email dev@bietje.net
*/
#include <stdlib.h>
#include <stdio.h>
#include <lwiot.h>
#include <lwiot/types.h>
#include <lwiot/log.h>
#include <lwiot/stl/string.h>
#include <lwiot/error.h>
#include <lwiot/network/stdnet.h>
#include <lwiot/network/udpclient.h>
#include <lwiot/network/ipaddress.h>
#include <lwiot/stl/move.h>
namespace lwiot
{
UdpClient::UdpClient() : _remote(IPAddress::fromBindAddress(BIND_ADDR_ANY)), _port(0)
{
}
UdpClient::UdpClient(const lwiot::IPAddress &addr, uint16_t port) : _remote(addr), _port(to_netorders(port))
{
}
UdpClient::UdpClient(const lwiot::String &host, uint16_t port) : _remote((uint32_t)0), _port(to_netorders(port)), _host(host)
{
this->resolve();
}
const IPAddress& lwiot::UdpClient::address() const
{
return this->_remote;
}
uint16_t UdpClient::port() const
{
return this->_port;
}
void UdpClient::resolve()
{
remote_addr_t remote;
if(this->_host.length() <= 0)
return;
remote.version = 4;
if(dns_resolve_host(this->_host.c_str(), &remote) != -EOK) {
this->_remote = stl::move(IPAddress(0,0,0,0));
} else {
this->_remote = stl::move(IPAddress(remote));
}
}
uint8_t UdpClient::read()
{
uint8_t tmp;
auto rc = this->read(&tmp, sizeof(tmp));
if(rc < 0)
return 0;
return tmp;
}
bool UdpClient::write(uint8_t byte)
{
return this->write(&byte, sizeof(byte)) == sizeof(byte);
}
Stream& UdpClient::operator<<(char x)
{
this->write((uint8_t)x);
return *this;
}
Stream& UdpClient::operator<<(short x)
{
this->write((uint8_t*)&x, sizeof(x));
return *this;
}
Stream& UdpClient::operator<<(int x)
{
this->write((uint8_t*)&x, sizeof(x));
return *this;
}
Stream& UdpClient::operator<<(const long & x)
{
this->write((uint8_t*)&x, sizeof(x));
return *this;
}
Stream& UdpClient::operator<<(const long long& x)
{
this->write((uint8_t*)&x, sizeof(x));
return *this;
}
Stream& UdpClient::operator<<(unsigned char x)
{
this->write((uint8_t)x);
return *this;
}
Stream& UdpClient::operator<<(unsigned short x)
{
this->write((uint8_t*)&x, sizeof(x));
return *this;
}
Stream& UdpClient::operator<<(unsigned int x)
{
this->write((uint8_t*)&x, sizeof(x));
return *this;
}
Stream& UdpClient::operator<<(unsigned const long & x)
{
this->write((uint8_t*)&x, sizeof(x));
return *this;
}
Stream& UdpClient::operator<<(const unsigned long long& x)
{
this->write((uint8_t*)&x, sizeof(x));
return *this;
}
Stream& UdpClient::operator<<(const float &x)
{
this->write((uint8_t*)&x, sizeof(x));
return *this;
}
Stream& UdpClient::operator<<(const double &x)
{
this->write((uint8_t*)&x, sizeof(x));
return *this;
}
Stream& UdpClient::operator<<(const lwiot::String &str)
{
*this << str.c_str();
return *this;
}
Stream& UdpClient::operator<<(const char *cstr)
{
this->write(reinterpret_cast<const uint8_t *>(cstr), strlen(cstr));
return *this;
}
}
| [
"dev@bietje.net"
] | dev@bietje.net |
ce7a4864c0d3b9423648a7e7e3cea7f986aa7c2c | 0840e722dd777fc8f2235d9828cc1294eda7fc73 | /static_router.h | a84dc2b9ba067f75769f46c781b9c88a87115d91 | [] | no_license | vincenscotti/convsim | 34793eed9f17b44c7ac1306e9c0d14484baa143d | 8d9638381b75e670b1d43e710026c9fca64b3a68 | refs/heads/master | 2020-09-05T09:31:47.468881 | 2020-01-09T14:50:35 | 2020-01-09T14:50:35 | 220,057,880 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,045 | h | #pragma once
#include <systemc>
#include <array>
namespace convsim {
using namespace std;
using namespace sc_core;
template <size_t Srcs, size_t Dsts>
struct mcast_config {
typedef array<array<bool, Dsts>, Srcs> routing_matrix;
mcast_config() {
for (auto &row : m) { row.fill(false); }
}
inline bool path(size_t src, size_t dst) {
return m[src][dst];
}
void groupEnable(size_t src, initializer_list<size_t> dsts) {
for (auto dst : dsts) {
assert(dst < Dsts);
m[src][dst] = true;
}
}
void print(ostream &os = cout) {
for (size_t src = 0; src < Srcs; src++) {
os << "source " << src << ": ";
for (size_t dst = 0; dst < Dsts; dst++) {
os << m[src][dst] << " ";
}
os << endl;
}
}
bool valid() {
for (size_t dst = 0; dst < Dsts; dst++) {
size_t routes_for_dst = 0;
for (size_t src = 0; src < Srcs; src++) {
if (m[src][dst]) routes_for_dst++;
}
if (routes_for_dst > 1) return false;
}
return true;
}
private:
routing_matrix m;
};
typedef enum {
N, E, S, W, GLB, PE, N_DIRECTIONS
} direction;
template <typename DataType>
SC_MODULE(router) {
// configuration matrix: a row for each src port, a col for each dst port
typedef mcast_config<N_DIRECTIONS, N_DIRECTIONS> config;
typedef DataType data_type;
// router interface
// a clk signal to know the propagation delay to model
sc_in<bool> clk;
// N input fifos, one for each source port
array<sc_fifo_in<DataType>, N_DIRECTIONS> in;
// N output fifos, one for each output port
array<sc_fifo_out<DataType>, N_DIRECTIONS> out;
SC_CTOR(router) : clk("clk") {
// each source port has its own control flow (so a stall on one port doesn't stall the whole router)
for (size_t i = 0; i < N_DIRECTIONS; i++) {
sc_spawn_options opts;
opts.set_sensitivity(&clk.pos());
direction dir = static_cast<direction>(i);
sc_spawn(bind(&router::port_thread, this, dir), 0, &opts);
}
}
void set_config(config new_cfg) {
cfg = new_cfg;
// first we validate the new configuration
if (!cfg.valid()) throw runtime_error(string(name()) + " invalid router configuration");
cerr << "Router " << name() << endl;
cerr << "Setting new circuit configuration" << endl;
cfg.print(cerr);
}
private:
// the route configuration
config cfg;
void port_thread(direction src) {
DataType data_in;
while (true) {
in[src].read(data_in);
wait(1);
for (size_t dst = 0; dst < N_DIRECTIONS; dst++) {
// for each dst port, check if we should send there
if (cfg.path(src, dst)) {
out[dst].write(data_in);
}
}
}
}
};
}
| [
"vscotti@gap.upv.es"
] | vscotti@gap.upv.es |
c964695b3dedcc8f631ea26d8979a20f9aa431bc | 6a3a50538c544c9f8d65bcb8f96d4e3b68a4e848 | /Sources/Bomberman/Header/InputComponent.hh | 1f6984a0922f86a604ca7a41430dfef308b1012d | [] | no_license | lejard-h/cpp_bomberman | 8f2d7eabebc1b872e189f066caeee78bc2550569 | 3ba7dcbc77ac87fb47be006446c537da7055b2dc | refs/heads/master | 2016-09-06T08:57:09.230787 | 2014-07-11T08:55:12 | 2014-07-11T08:55:12 | 21,691,750 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 931 | hh | /*
** InputComponent.hh for Bomberman in /home/lejard_h/rendu/cpp_bomberman/Bomberman/Header
**
** Made by hadrien lejard
** Login <lejard_h@epitech.net>
**
** Started on jeu. mai 29 14:19:36 2014 hadrien lejard
// Last update Sat Jun 14 10:59:46 2014 Marc Le Labourier
*/
#ifndef __INPUTCOMPONENT_HH__
# define __INPUTCOMPONENT_HH__
#include <queue>
#include "SysGame.hh"
#include "Component.hh"
#include "EventDispatcher.hh"
#include "Settings.hpp"
#include "PositionComponent.hh"
#include "PhysicComponent.hh"
#include "KeyboardManager.hh"
#include "LeapManager.hh"
namespace Bomb
{
class InputComponent : public BaseComponent
{
public:
InputComponent();
void Destroy();
void OnEvent(Event::Event *);
protected:
std::list<Event::Event *> _events;
std::map<std::string, double> _rMap;
void Move(std::string const &) const;
void Move(int) const;
void PutBomb() const;
};
}
#endif
| [
"lejard_h@epitech.eu"
] | lejard_h@epitech.eu |
7014f929550b76df086512657799abaefcc381fd | 2aa13805fefde015f78a9007210749f7b02ddd17 | /OpenGL/OpenGL/header/Assets/FBXProgram.h | d30ba60e207af535f5a34565c71946216621e8fe | [] | no_license | Brandon-Bruce/AIE-Projects | 7df184007193dca7effbbd2f0e5de95047fb4a9c | 95105eb46b257bb8130893c7a35d0e2185e1406e | refs/heads/master | 2021-01-19T09:10:18.264070 | 2016-03-30T06:52:22 | 2016-03-30T06:52:22 | 50,803,740 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 495 | h | #ifndef FBXPROGRAM_H
#define FBXPROGRAM_H
#include "Program.h"
#include "glm\mat4x4.hpp"
class FBXFile;
class Camera;
class SphereCollider;
class FBXProgram : public Program
{
public:
void Startup(const char* fileName, glm::mat4 position,
char* name, float scale);
void CreateOpenGLBuffers();
void CleanUpOpenGLBuffers();
void Draw(glm::mat4 projectionView, Camera* camera);
private:
FBXFile* fbx;
glm::mat4 position;
char* name;
SphereCollider* collider;
float scale;
};
#endif | [
"brandon.bruce@ad.aie.edu"
] | brandon.bruce@ad.aie.edu |
45468650fa734cd7d4edc688475a605a5ec91a53 | 0ec75f71699b7abbff707ac11907cd01312a66e8 | /NewSplittingPlacement.cpp | 58212cea97b749e679e5e437fd8081e8a0cdce44 | [] | no_license | stonetree/NewSplittingPlacement | 84b490d66919c4223f1b326d1a4d0f2513d87d26 | 7c0433a866d9c8e69cbc10bcb98be62621479172 | refs/heads/master | 2020-05-20T06:41:18.617043 | 2014-11-26T01:47:40 | 2014-11-26T01:47:40 | 26,755,539 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,358 | cpp | // NewSplittingPlacement.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "common.h"
#include "cVMRequest.h"
#include "cServer.h"
uint total_num_profile_55 = 100;
uint total_num_profile_70 = 0;
uint total_num_servers = 50;
double total_server_capacity = 100;
double splitable_percentage = 1;
double total_used = 0;
uint request_index = 0;
map<double,MappingFunction> resourceRequirement;
map<ID,cServer*> usedServers;
map<ID,cServer*> unusedServers;
double lambda_low_55 = 0.7;
double lambda_high_55 = 1.4;
double lambda_low_70 = 0.5;
double lambda_high_70 = 1.2;
double lambda_low_80 = 0.4;
double lambda_high_80 = 1;
double lambda_low_90 = 0.2;
double lambda_high_90 = 0.8;
double lambda_low_100 = 0.1;
double lambda_high_100 = 0.6;
int _tmain(int argc, _TCHAR* argv[])
{
//store the resource required by the original vm or its svms
vector<vector<double>> resource_request_vec;
//input the info about resource requests
if (initializeInputFile(resource_request_vec))
{
cout<<"Can not locate the input file"<<endl;
exit(0);
}
vector<vector<double>>::iterator input_iterator = resource_request_vec.begin();
for (;input_iterator != resource_request_vec.end();input_iterator++)
{
unusedServers.clear();
usedServers.clear();
//initialize parameters
initializeInputParameters((*input_iterator));
//servers
vector<cServer> server_vec;
//Initialize servers
initializeServers(server_vec);
//vm requests
vector<cVMRequest> vmrequests_vec;
initializeVMRequests(vmrequests_vec);
//resource requirement
map<pair<double,uint>,double> resource_request;
//initialize the resource request
//initializeResourceRequest(*input_iterator,resource_request);
initializeResourceRequest();
vector<cVMRequest>::iterator iter_vm_request;
//allocate vm requests
request_index = 1;
//allocateGlobalVMRequest(vmrequests_vec,server_vec,resource_request);
for (iter_vm_request = vmrequests_vec.begin();iter_vm_request != vmrequests_vec.end();iter_vm_request++)
{
cout<<"The "<<request_index<<"th request"<<endl;
allocateVMRequest(*iter_vm_request,server_vec,resource_request);
//allocateVMRequestGreedy(*iter_vm_request,server_vec,resource_request);
request_index++;
}
//collect output data
outputResults((*input_iterator)[0],server_vec);
}
return 0;
}
| [
"liuliu.sky@gmail.com"
] | liuliu.sky@gmail.com |
081f2bedd9ac5ff707c6004025f032b8a58bdb69 | bb82a5f977bef455714c16e24e2d8254e2d0faa5 | /src/vendor/cget/cget/pkg/chriskohlhoff__asio/install/include/asio/detail/reactive_socket_service.hpp | 309fd8db13235be842c690d847a22671d33a5923 | [
"Unlicense"
] | permissive | pqrs-org/Karabiner-Elements | 4ae307d82f8b67547c161c7d46d2083a0fd07630 | d05057d7c769e2ff35638282e888a6d5eca566be | refs/heads/main | 2023-09-01T03:11:08.474417 | 2023-09-01T00:44:19 | 2023-09-01T00:44:19 | 63,037,806 | 8,197 | 389 | Unlicense | 2023-09-01T00:11:00 | 2016-07-11T04:57:55 | C++ | UTF-8 | C++ | false | false | 21,440 | hpp | //
// detail/reactive_socket_service.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef ASIO_DETAIL_REACTIVE_SOCKET_SERVICE_HPP
#define ASIO_DETAIL_REACTIVE_SOCKET_SERVICE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/config.hpp"
#if !defined(ASIO_HAS_IOCP) \
&& !defined(ASIO_HAS_IO_URING_AS_DEFAULT)
#include "asio/buffer.hpp"
#include "asio/error.hpp"
#include "asio/execution_context.hpp"
#include "asio/socket_base.hpp"
#include "asio/detail/buffer_sequence_adapter.hpp"
#include "asio/detail/memory.hpp"
#include "asio/detail/noncopyable.hpp"
#include "asio/detail/reactive_null_buffers_op.hpp"
#include "asio/detail/reactive_socket_accept_op.hpp"
#include "asio/detail/reactive_socket_connect_op.hpp"
#include "asio/detail/reactive_socket_recvfrom_op.hpp"
#include "asio/detail/reactive_socket_sendto_op.hpp"
#include "asio/detail/reactive_socket_service_base.hpp"
#include "asio/detail/reactor.hpp"
#include "asio/detail/reactor_op.hpp"
#include "asio/detail/socket_holder.hpp"
#include "asio/detail/socket_ops.hpp"
#include "asio/detail/socket_types.hpp"
#include "asio/detail/push_options.hpp"
namespace asio {
namespace detail {
template <typename Protocol>
class reactive_socket_service :
public execution_context_service_base<reactive_socket_service<Protocol> >,
public reactive_socket_service_base
{
public:
// The protocol type.
typedef Protocol protocol_type;
// The endpoint type.
typedef typename Protocol::endpoint endpoint_type;
// The native type of a socket.
typedef socket_type native_handle_type;
// The implementation type of the socket.
struct implementation_type :
reactive_socket_service_base::base_implementation_type
{
// Default constructor.
implementation_type()
: protocol_(endpoint_type().protocol())
{
}
// The protocol associated with the socket.
protocol_type protocol_;
};
// Constructor.
reactive_socket_service(execution_context& context)
: execution_context_service_base<
reactive_socket_service<Protocol> >(context),
reactive_socket_service_base(context)
{
}
// Destroy all user-defined handler objects owned by the service.
void shutdown()
{
this->base_shutdown();
}
// Move-construct a new socket implementation.
void move_construct(implementation_type& impl,
implementation_type& other_impl) ASIO_NOEXCEPT
{
this->base_move_construct(impl, other_impl);
impl.protocol_ = other_impl.protocol_;
other_impl.protocol_ = endpoint_type().protocol();
}
// Move-assign from another socket implementation.
void move_assign(implementation_type& impl,
reactive_socket_service_base& other_service,
implementation_type& other_impl)
{
this->base_move_assign(impl, other_service, other_impl);
impl.protocol_ = other_impl.protocol_;
other_impl.protocol_ = endpoint_type().protocol();
}
// Move-construct a new socket implementation from another protocol type.
template <typename Protocol1>
void converting_move_construct(implementation_type& impl,
reactive_socket_service<Protocol1>&,
typename reactive_socket_service<
Protocol1>::implementation_type& other_impl)
{
this->base_move_construct(impl, other_impl);
impl.protocol_ = protocol_type(other_impl.protocol_);
other_impl.protocol_ = typename Protocol1::endpoint().protocol();
}
// Open a new socket implementation.
asio::error_code open(implementation_type& impl,
const protocol_type& protocol, asio::error_code& ec)
{
if (!do_open(impl, protocol.family(),
protocol.type(), protocol.protocol(), ec))
impl.protocol_ = protocol;
ASIO_ERROR_LOCATION(ec);
return ec;
}
// Assign a native socket to a socket implementation.
asio::error_code assign(implementation_type& impl,
const protocol_type& protocol, const native_handle_type& native_socket,
asio::error_code& ec)
{
if (!do_assign(impl, protocol.type(), native_socket, ec))
impl.protocol_ = protocol;
ASIO_ERROR_LOCATION(ec);
return ec;
}
// Get the native socket representation.
native_handle_type native_handle(implementation_type& impl)
{
return impl.socket_;
}
// Bind the socket to the specified local endpoint.
asio::error_code bind(implementation_type& impl,
const endpoint_type& endpoint, asio::error_code& ec)
{
socket_ops::bind(impl.socket_, endpoint.data(), endpoint.size(), ec);
ASIO_ERROR_LOCATION(ec);
return ec;
}
// Set a socket option.
template <typename Option>
asio::error_code set_option(implementation_type& impl,
const Option& option, asio::error_code& ec)
{
socket_ops::setsockopt(impl.socket_, impl.state_,
option.level(impl.protocol_), option.name(impl.protocol_),
option.data(impl.protocol_), option.size(impl.protocol_), ec);
ASIO_ERROR_LOCATION(ec);
return ec;
}
// Set a socket option.
template <typename Option>
asio::error_code get_option(const implementation_type& impl,
Option& option, asio::error_code& ec) const
{
std::size_t size = option.size(impl.protocol_);
socket_ops::getsockopt(impl.socket_, impl.state_,
option.level(impl.protocol_), option.name(impl.protocol_),
option.data(impl.protocol_), &size, ec);
if (!ec)
option.resize(impl.protocol_, size);
ASIO_ERROR_LOCATION(ec);
return ec;
}
// Get the local endpoint.
endpoint_type local_endpoint(const implementation_type& impl,
asio::error_code& ec) const
{
endpoint_type endpoint;
std::size_t addr_len = endpoint.capacity();
if (socket_ops::getsockname(impl.socket_, endpoint.data(), &addr_len, ec))
{
ASIO_ERROR_LOCATION(ec);
return endpoint_type();
}
endpoint.resize(addr_len);
return endpoint;
}
// Get the remote endpoint.
endpoint_type remote_endpoint(const implementation_type& impl,
asio::error_code& ec) const
{
endpoint_type endpoint;
std::size_t addr_len = endpoint.capacity();
if (socket_ops::getpeername(impl.socket_,
endpoint.data(), &addr_len, false, ec))
{
ASIO_ERROR_LOCATION(ec);
return endpoint_type();
}
endpoint.resize(addr_len);
return endpoint;
}
// Disable sends or receives on the socket.
asio::error_code shutdown(base_implementation_type& impl,
socket_base::shutdown_type what, asio::error_code& ec)
{
socket_ops::shutdown(impl.socket_, what, ec);
ASIO_ERROR_LOCATION(ec);
return ec;
}
// Send a datagram to the specified endpoint. Returns the number of bytes
// sent.
template <typename ConstBufferSequence>
size_t send_to(implementation_type& impl, const ConstBufferSequence& buffers,
const endpoint_type& destination, socket_base::message_flags flags,
asio::error_code& ec)
{
typedef buffer_sequence_adapter<asio::const_buffer,
ConstBufferSequence> bufs_type;
size_t n;
if (bufs_type::is_single_buffer)
{
n = socket_ops::sync_sendto1(impl.socket_, impl.state_,
bufs_type::first(buffers).data(),
bufs_type::first(buffers).size(), flags,
destination.data(), destination.size(), ec);
}
else
{
bufs_type bufs(buffers);
n = socket_ops::sync_sendto(impl.socket_, impl.state_,
bufs.buffers(), bufs.count(), flags,
destination.data(), destination.size(), ec);
}
ASIO_ERROR_LOCATION(ec);
return n;
}
// Wait until data can be sent without blocking.
size_t send_to(implementation_type& impl, const null_buffers&,
const endpoint_type&, socket_base::message_flags,
asio::error_code& ec)
{
// Wait for socket to become ready.
socket_ops::poll_write(impl.socket_, impl.state_, -1, ec);
ASIO_ERROR_LOCATION(ec);
return 0;
}
// Start an asynchronous send. The data being sent must be valid for the
// lifetime of the asynchronous operation.
template <typename ConstBufferSequence, typename Handler, typename IoExecutor>
void async_send_to(implementation_type& impl,
const ConstBufferSequence& buffers,
const endpoint_type& destination, socket_base::message_flags flags,
Handler& handler, const IoExecutor& io_ex)
{
bool is_continuation =
asio_handler_cont_helpers::is_continuation(handler);
typename associated_cancellation_slot<Handler>::type slot
= asio::get_associated_cancellation_slot(handler);
// Allocate and construct an operation to wrap the handler.
typedef reactive_socket_sendto_op<ConstBufferSequence,
endpoint_type, Handler, IoExecutor> op;
typename op::ptr p = { asio::detail::addressof(handler),
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(success_ec_, impl.socket_,
buffers, destination, flags, handler, io_ex);
// Optionally register for per-operation cancellation.
if (slot.is_connected())
{
p.p->cancellation_key_ =
&slot.template emplace<reactor_op_cancellation>(
&reactor_, &impl.reactor_data_, impl.socket_, reactor::write_op);
}
ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
&impl, impl.socket_, "async_send_to"));
start_op(impl, reactor::write_op, p.p,
is_continuation, true, false, &io_ex, 0);
p.v = p.p = 0;
}
// Start an asynchronous wait until data can be sent without blocking.
template <typename Handler, typename IoExecutor>
void async_send_to(implementation_type& impl, const null_buffers&,
const endpoint_type&, socket_base::message_flags,
Handler& handler, const IoExecutor& io_ex)
{
bool is_continuation =
asio_handler_cont_helpers::is_continuation(handler);
typename associated_cancellation_slot<Handler>::type slot
= asio::get_associated_cancellation_slot(handler);
// Allocate and construct an operation to wrap the handler.
typedef reactive_null_buffers_op<Handler, IoExecutor> op;
typename op::ptr p = { asio::detail::addressof(handler),
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(success_ec_, handler, io_ex);
// Optionally register for per-operation cancellation.
if (slot.is_connected())
{
p.p->cancellation_key_ =
&slot.template emplace<reactor_op_cancellation>(
&reactor_, &impl.reactor_data_, impl.socket_, reactor::write_op);
}
ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
&impl, impl.socket_, "async_send_to(null_buffers)"));
start_op(impl, reactor::write_op, p.p,
is_continuation, false, false, &io_ex, 0);
p.v = p.p = 0;
}
// Receive a datagram with the endpoint of the sender. Returns the number of
// bytes received.
template <typename MutableBufferSequence>
size_t receive_from(implementation_type& impl,
const MutableBufferSequence& buffers,
endpoint_type& sender_endpoint, socket_base::message_flags flags,
asio::error_code& ec)
{
typedef buffer_sequence_adapter<asio::mutable_buffer,
MutableBufferSequence> bufs_type;
std::size_t addr_len = sender_endpoint.capacity();
std::size_t n;
if (bufs_type::is_single_buffer)
{
n = socket_ops::sync_recvfrom1(impl.socket_, impl.state_,
bufs_type::first(buffers).data(), bufs_type::first(buffers).size(),
flags, sender_endpoint.data(), &addr_len, ec);
}
else
{
bufs_type bufs(buffers);
n = socket_ops::sync_recvfrom(impl.socket_, impl.state_, bufs.buffers(),
bufs.count(), flags, sender_endpoint.data(), &addr_len, ec);
}
if (!ec)
sender_endpoint.resize(addr_len);
ASIO_ERROR_LOCATION(ec);
return n;
}
// Wait until data can be received without blocking.
size_t receive_from(implementation_type& impl, const null_buffers&,
endpoint_type& sender_endpoint, socket_base::message_flags,
asio::error_code& ec)
{
// Wait for socket to become ready.
socket_ops::poll_read(impl.socket_, impl.state_, -1, ec);
// Reset endpoint since it can be given no sensible value at this time.
sender_endpoint = endpoint_type();
ASIO_ERROR_LOCATION(ec);
return 0;
}
// Start an asynchronous receive. The buffer for the data being received and
// the sender_endpoint object must both be valid for the lifetime of the
// asynchronous operation.
template <typename MutableBufferSequence,
typename Handler, typename IoExecutor>
void async_receive_from(implementation_type& impl,
const MutableBufferSequence& buffers, endpoint_type& sender_endpoint,
socket_base::message_flags flags, Handler& handler,
const IoExecutor& io_ex)
{
bool is_continuation =
asio_handler_cont_helpers::is_continuation(handler);
typename associated_cancellation_slot<Handler>::type slot
= asio::get_associated_cancellation_slot(handler);
// Allocate and construct an operation to wrap the handler.
typedef reactive_socket_recvfrom_op<MutableBufferSequence,
endpoint_type, Handler, IoExecutor> op;
typename op::ptr p = { asio::detail::addressof(handler),
op::ptr::allocate(handler), 0 };
int protocol = impl.protocol_.type();
p.p = new (p.v) op(success_ec_, impl.socket_, protocol,
buffers, sender_endpoint, flags, handler, io_ex);
// Optionally register for per-operation cancellation.
if (slot.is_connected())
{
p.p->cancellation_key_ =
&slot.template emplace<reactor_op_cancellation>(
&reactor_, &impl.reactor_data_, impl.socket_, reactor::read_op);
}
ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
&impl, impl.socket_, "async_receive_from"));
start_op(impl,
(flags & socket_base::message_out_of_band)
? reactor::except_op : reactor::read_op,
p.p, is_continuation, true, false, &io_ex, 0);
p.v = p.p = 0;
}
// Wait until data can be received without blocking.
template <typename Handler, typename IoExecutor>
void async_receive_from(implementation_type& impl, const null_buffers&,
endpoint_type& sender_endpoint, socket_base::message_flags flags,
Handler& handler, const IoExecutor& io_ex)
{
bool is_continuation =
asio_handler_cont_helpers::is_continuation(handler);
typename associated_cancellation_slot<Handler>::type slot
= asio::get_associated_cancellation_slot(handler);
// Allocate and construct an operation to wrap the handler.
typedef reactive_null_buffers_op<Handler, IoExecutor> op;
typename op::ptr p = { asio::detail::addressof(handler),
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(success_ec_, handler, io_ex);
// Optionally register for per-operation cancellation.
if (slot.is_connected())
{
p.p->cancellation_key_ =
&slot.template emplace<reactor_op_cancellation>(
&reactor_, &impl.reactor_data_, impl.socket_, reactor::read_op);
}
ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
&impl, impl.socket_, "async_receive_from(null_buffers)"));
// Reset endpoint since it can be given no sensible value at this time.
sender_endpoint = endpoint_type();
start_op(impl,
(flags & socket_base::message_out_of_band)
? reactor::except_op : reactor::read_op,
p.p, is_continuation, false, false, &io_ex, 0);
p.v = p.p = 0;
}
// Accept a new connection.
template <typename Socket>
asio::error_code accept(implementation_type& impl,
Socket& peer, endpoint_type* peer_endpoint, asio::error_code& ec)
{
// We cannot accept a socket that is already open.
if (peer.is_open())
{
ec = asio::error::already_open;
ASIO_ERROR_LOCATION(ec);
return ec;
}
std::size_t addr_len = peer_endpoint ? peer_endpoint->capacity() : 0;
socket_holder new_socket(socket_ops::sync_accept(impl.socket_,
impl.state_, peer_endpoint ? peer_endpoint->data() : 0,
peer_endpoint ? &addr_len : 0, ec));
// On success, assign new connection to peer socket object.
if (new_socket.get() != invalid_socket)
{
if (peer_endpoint)
peer_endpoint->resize(addr_len);
peer.assign(impl.protocol_, new_socket.get(), ec);
if (!ec)
new_socket.release();
}
ASIO_ERROR_LOCATION(ec);
return ec;
}
// Start an asynchronous accept. The peer and peer_endpoint objects must be
// valid until the accept's handler is invoked.
template <typename Socket, typename Handler, typename IoExecutor>
void async_accept(implementation_type& impl, Socket& peer,
endpoint_type* peer_endpoint, Handler& handler, const IoExecutor& io_ex)
{
bool is_continuation =
asio_handler_cont_helpers::is_continuation(handler);
typename associated_cancellation_slot<Handler>::type slot
= asio::get_associated_cancellation_slot(handler);
// Allocate and construct an operation to wrap the handler.
typedef reactive_socket_accept_op<Socket, Protocol, Handler, IoExecutor> op;
typename op::ptr p = { asio::detail::addressof(handler),
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(success_ec_, impl.socket_, impl.state_,
peer, impl.protocol_, peer_endpoint, handler, io_ex);
// Optionally register for per-operation cancellation.
if (slot.is_connected() && !peer.is_open())
{
p.p->cancellation_key_ =
&slot.template emplace<reactor_op_cancellation>(
&reactor_, &impl.reactor_data_, impl.socket_, reactor::read_op);
}
ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
&impl, impl.socket_, "async_accept"));
start_accept_op(impl, p.p, is_continuation, peer.is_open(), &io_ex, 0);
p.v = p.p = 0;
}
#if defined(ASIO_HAS_MOVE)
// Start an asynchronous accept. The peer_endpoint object must be valid until
// the accept's handler is invoked.
template <typename PeerIoExecutor, typename Handler, typename IoExecutor>
void async_move_accept(implementation_type& impl,
const PeerIoExecutor& peer_io_ex, endpoint_type* peer_endpoint,
Handler& handler, const IoExecutor& io_ex)
{
bool is_continuation =
asio_handler_cont_helpers::is_continuation(handler);
typename associated_cancellation_slot<Handler>::type slot
= asio::get_associated_cancellation_slot(handler);
// Allocate and construct an operation to wrap the handler.
typedef reactive_socket_move_accept_op<Protocol,
PeerIoExecutor, Handler, IoExecutor> op;
typename op::ptr p = { asio::detail::addressof(handler),
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(success_ec_, peer_io_ex, impl.socket_,
impl.state_, impl.protocol_, peer_endpoint, handler, io_ex);
// Optionally register for per-operation cancellation.
if (slot.is_connected())
{
p.p->cancellation_key_ =
&slot.template emplace<reactor_op_cancellation>(
&reactor_, &impl.reactor_data_, impl.socket_, reactor::read_op);
}
ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
&impl, impl.socket_, "async_accept"));
start_accept_op(impl, p.p, is_continuation, false, &io_ex, 0);
p.v = p.p = 0;
}
#endif // defined(ASIO_HAS_MOVE)
// Connect the socket to the specified endpoint.
asio::error_code connect(implementation_type& impl,
const endpoint_type& peer_endpoint, asio::error_code& ec)
{
socket_ops::sync_connect(impl.socket_,
peer_endpoint.data(), peer_endpoint.size(), ec);
ASIO_ERROR_LOCATION(ec);
return ec;
}
// Start an asynchronous connect.
template <typename Handler, typename IoExecutor>
void async_connect(implementation_type& impl,
const endpoint_type& peer_endpoint,
Handler& handler, const IoExecutor& io_ex)
{
bool is_continuation =
asio_handler_cont_helpers::is_continuation(handler);
typename associated_cancellation_slot<Handler>::type slot
= asio::get_associated_cancellation_slot(handler);
// Allocate and construct an operation to wrap the handler.
typedef reactive_socket_connect_op<Handler, IoExecutor> op;
typename op::ptr p = { asio::detail::addressof(handler),
op::ptr::allocate(handler), 0 };
p.p = new (p.v) op(success_ec_, impl.socket_, handler, io_ex);
// Optionally register for per-operation cancellation.
if (slot.is_connected())
{
p.p->cancellation_key_ =
&slot.template emplace<reactor_op_cancellation>(
&reactor_, &impl.reactor_data_, impl.socket_, reactor::connect_op);
}
ASIO_HANDLER_CREATION((reactor_.context(), *p.p, "socket",
&impl, impl.socket_, "async_connect"));
start_connect_op(impl, p.p, is_continuation,
peer_endpoint.data(), peer_endpoint.size(), &io_ex, 0);
p.v = p.p = 0;
}
};
} // namespace detail
} // namespace asio
#include "asio/detail/pop_options.hpp"
#endif // !defined(ASIO_HAS_IOCP)
// && !defined(ASIO_HAS_IO_URING_AS_DEFAULT)
#endif // ASIO_DETAIL_REACTIVE_SOCKET_SERVICE_HPP
| [
"tekezo@pqrs.org"
] | tekezo@pqrs.org |
c5d7b9e727f41812cb8cf9d4650c8fd7807e0729 | f7ea25dec016933bea8599fde12e448ec668c1a2 | /src/http/verbs.cpp | 978138c366839c33b4391b7133157d40aac385f7 | [
"Apache-2.0"
] | permissive | NeuralNoise/poseidon | 3629b73e0f67b7194727b84733f92ab15dab12a8 | 27c8145641a171a1a239391f84248b7b55730f4c | refs/heads/master | 2021-07-01T10:33:40.343882 | 2017-09-22T09:52:54 | 2017-09-22T09:52:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,067 | cpp | // 这个文件是 Poseidon 服务器应用程序框架的一部分。
// Copyleft 2014 - 2017, LH_Mouse. All wrongs reserved.
#include "../precompiled.hpp"
#include "verbs.hpp"
namespace Poseidon {
namespace {
CONSTEXPR const char VERB_TABLE[][16] = {
"INVALID_VERB",
"GET",
"POST",
"HEAD",
"PUT",
"DELETE",
"TRACE",
"CONNECT",
"OPTIONS",
};
}
namespace Http {
Verb get_verb_from_string(const char *str){
const unsigned len = std::strlen(str);
if(len == 0){
return V_INVALID_VERB;
}
const char *const begin = VERB_TABLE[0];
const AUTO(pos, static_cast<const char *>(::memmem(begin, sizeof(VERB_TABLE), str, len + 1)));
if(!pos){
return V_INVALID_VERB;
}
const unsigned i = (unsigned)(pos - begin) / sizeof(VERB_TABLE[0]);
if(pos != VERB_TABLE[i]){
return V_INVALID_VERB;
}
return static_cast<Verb>(i);
}
const char *get_string_from_verb(Verb verb){
unsigned i = static_cast<unsigned>(verb);
if(i >= COUNT_OF(VERB_TABLE)){
i = static_cast<unsigned>(V_INVALID_VERB);
}
return VERB_TABLE[i];
}
}
}
| [
"lh_mouse@126.com"
] | lh_mouse@126.com |
1b732abc79c81b5afe02c4c9aa0a8fca7e305013 | 7dd209afc5217ece1f71c1d7875d5e237d1a6c95 | /Test/1.cpp | e86a00af0463172def005c92b388750797a72c06 | [] | no_license | hieudt183739/Aglorithm | 9a9ef6b01f46a67ba7d19f857be796765dadb55d | 3377789e97cd8af0522d44b85c9767b771263c04 | refs/heads/master | 2023-07-05T22:51:04.662621 | 2021-08-04T08:37:19 | 2021-08-04T08:37:19 | 346,371,022 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 985 | cpp |
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int N = 1e5 + 10;
int num[N];
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
int n;
cin >> n;
for(int i = 0; i < n; i++){
cin >> num[i];
}
int res = 0;
int sum = 0;
for(int i = 0; i < n; i++){
res += num[i] * i;
sum += num[i];
}
int tmp = res;
for(int i = n -1; i >= 1; i--){
tmp = tmp - num[i] * (n - 1) + sum - num[i];
res = max(res, tmp);
}
cout << res << endl;
return 0;
}
// https://leetcode.com/problems/rotate-function
// f(0) = num[0] x 0 + num[1] x 1 + num[2] x 2 + num[3] x 3
// f(1) = num[3] x 0 + num[0] x 1 + num[1] x 2 + num[2] x 3 = f(0) - num[3] x 3 + num[0] + num[1] + num[2]
// = f(0) - num[3] x 3 + sum -num[3]
// f(2) = num[2] x 0 + num[3] x 1 + num[0] x 2 + num[1] x 3 = f(1) - num[2] x 3 + num[3] + num[0] + num[1]
// = f(1) - num[2] x 3 + sum - num[2];
| [
"video06072000@gmail.com"
] | video06072000@gmail.com |
b948103f90ff958ce1b0c2ad60591dd03de12b05 | 5100674f94aca3f0a0e9c4f3bcb16006d11e5c6b | /classic_interview_questions/lru_cplusplus.cpp | 704f2e2bd93205e240309d9d33b06cc0b1bdbff2 | [] | no_license | erikliu123/algorithm_problems | 0702655ed61d60702395390e377d4e480aae75dc | 7cab9006dc37a745ac9a5f96a9d4265508b712af | refs/heads/master | 2023-08-11T13:01:07.235840 | 2021-09-27T03:28:41 | 2021-09-27T03:28:41 | 357,453,683 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,889 | cpp | #include <unordered_map>
#include <list>
#include <vector>
using namespace std;
struct Node
{
Node(int k = 0, int v = 0) : key(k), val(v) {}
int key;
int val;
};
class LRUCache
{
public:
/**
* lru design
* @param operators int整型vector<vector<>> the ops
* @param k int整型 the k
* @return int整型vector
*/
vector<int> LRU(vector<vector<int>> &operators, int k)
{
// write code here
cap = k;
vector<int> ans;
for (auto &input : operators)
{
if (input[0] == 1)
{
put(input[1], input[2]);
}
else
{
ans.push_back(get(input[1]));
}
}
return ans;
}
LRUCache(int capacity)
{
cap = capacity;
}
//删除
int remove(std::list<Node>::iterator &ite)
{
int key = ite->key;
int val = ite->val;
L.erase(ite);
H.erase(key);
return val;
}
// 添加
void add(int key, int val)
{
L.push_front(Node(key, val));
H[key] = L.begin();
if (L.size() > cap)
{
auto last = L.end();
--last;
remove(last);
}
}
void put(int x, int y)
{
auto ite = H.find(x);
//已经存在,删除了再添加到头部
if (ite != H.end())
{
remove(ite->second);
}
add(x, y);
}
int get(int x)
{
int val = 0;
//已经存在,删除了再添加到头部
auto ite = H.find(x);
if (ite != H.end())
{
val = remove(ite->second);
add(x, val);
return val;
}
return -1;
}
private:
std::list<Node> L;
std::unordered_map<int, std::list<Node>::iterator> H;
int cap;
};
| [
"1171045702@qq.com"
] | 1171045702@qq.com |
cf624a66c5af950f27a35bfedb672dc2d598b0ff | d4a154e192e790d8607a5f3de9c1f95109599b20 | /project4/proj4B/PNMwriter.h | 97116e7794d225e495cd57a2201dfae7aba41d1f | [] | no_license | fabiancaraballo/CS330-C-CPP-UNIX | 80b5baa018bd4b01902ec31ab1c7e36c6726a0fa | 2992348a0a7ff4d1924e9db2b75f0a4ec793efdd | refs/heads/master | 2020-06-11T02:58:25.686134 | 2019-06-26T05:01:11 | 2019-06-26T05:01:11 | 193,832,508 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 155 | h | #ifndef PNMWRITER_H
#define PNMWRITER_H
#include <stdio.h>
#include "sink.h"
class PNMwriter: public Sink {
public:
void Write(char *file);
};
#endif
| [
"fabian.caraballo@gmail.com"
] | fabian.caraballo@gmail.com |
aafe10247283705be3e7cc3fb06cc7eac9f91d98 | 93427e5015233aea8284ab7dc37a4b59b9d6c500 | /tree/pruefer-code.hpp | 1b14c5676092d6e781dc240bf27962c3dda6b135 | [
"CC0-1.0"
] | permissive | zxc123qwe456asd789/library | fd978a387c8dd805ef1a7ffc1118272c6878b64a | 13c01442cc5082da181acdaa414554ace30b6ae3 | refs/heads/master | 2023-05-28T22:50:47.466753 | 2021-06-12T04:10:24 | 2021-06-12T04:10:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,035 | hpp | #pragma once
#include "../misc/rng.hpp"
// input: [c \in [0, n)] * (n-2), n>=3
vector<vector<int>> pruefer_code(const vector<int>& code) {
int n = code.size() + 2;
assert(n > 2);
vector<vector<int>> g(n);
vector<int> deg(n, 1);
int e = 0;
for (auto& x : code) deg[x]++;
for (auto& i : code) {
for (int j = 0; j < n; j++) {
if (deg[j] == 1) {
g[i].push_back(j);
g[j].push_back(i);
deg[i]--, deg[j]--;
e++;
break;
}
}
}
int u = -1, v = -1;
for (int i = 0; i < n; i++) {
if (deg[i] == 1) (u == -1 ? u : v) = i;
}
assert(u != -1 and v != -1);
g[u].push_back(v);
g[v].push_back(u);
e++;
assert(e == n - 1);
return g;
}
vector<vector<int>> random_tree(int n) {
if (n <= 2) {
vector<vector<int>> g(n);
if (n == 2) {
g[0].push_back(1);
g[1].push_back(0);
}
return g;
}
vector<int> pruefer(n - 2);
for (auto& x : pruefer) x = randint(0, n);
return pruefer_code(pruefer);
}
/**
* @brief Pruefer Code
*/
| [
"suteakadapyon3@gmail.com"
] | suteakadapyon3@gmail.com |
883b9d3d5ca995b9d32e2f5e3fbaa243e098a4d5 | a92b18defb50c5d1118a11bc364f17b148312028 | /src/prod/src/Management/ClusterManager/ClearComposeDeploymentUpgradeContextAsyncOperation.h | 132b02c32eff3728827733371aab24939fff577e | [
"MIT"
] | permissive | KDSBest/service-fabric | 34694e150fde662286e25f048fb763c97606382e | fe61c45b15a30fb089ad891c68c893b3a976e404 | refs/heads/master | 2023-01-28T23:19:25.040275 | 2020-11-30T11:11:58 | 2020-11-30T11:11:58 | 301,365,601 | 1 | 0 | MIT | 2020-11-30T11:11:59 | 2020-10-05T10:05:53 | null | UTF-8 | C++ | false | false | 1,080 | h | // ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information.
// ------------------------------------------------------------
#pragma once
namespace Management
{
namespace ClusterManager
{
class ClearComposeDeploymentUpgradeContextAsyncOperation :
public ProcessRolloutContextAsyncOperationBase
{
public:
ClearComposeDeploymentUpgradeContextAsyncOperation(
__in RolloutManager &,
__in ComposeDeploymentUpgradeContext &,
Common::TimeSpan const,
Common::AsyncCallback const &,
Common::AsyncOperationSPtr const &);
void OnStart(Common::AsyncOperationSPtr const &);
private:
void OnCommitComplete(Common::AsyncOperationSPtr const &, bool expectedCompletedSynchronously);
ComposeDeploymentUpgradeContext & context_;
};
}
}
| [
"noreply-sfteam@microsoft.com"
] | noreply-sfteam@microsoft.com |
8df28c62b9aa8b98ea3391fb16a4caf4b94fe6d2 | 861c0b2803e37f2cb2be97de0c40613a65c62e0b | /build-MultipurposeApplication-Desktop_Qt_5_6_3_MinGW_32bit-Debug/ui_mainwindow.h | 463c3afbd188d15c0549fd70ff40fc49d3cef13a | [] | no_license | KavinduTheekshana/Multipurpose-Application | 6e9c16e4beab307e772254c381c6848c7fe2822c | 52856b7999161b97152127f0c0b8cc04a5e2eadc | refs/heads/master | 2020-12-04T10:00:09.337929 | 2020-01-13T13:28:10 | 2020-01-13T13:28:10 | 231,720,341 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,566 | h | /********************************************************************************
** Form generated from reading UI file 'mainwindow.ui'
**
** Created by: Qt User Interface Compiler version 5.6.3
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_MAINWINDOW_H
#define UI_MAINWINDOW_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_MainWindow
{
public:
QWidget *centralWidget;
QPushButton *btnCalculator;
QPushButton *pushButton_2;
QPushButton *pushButton_3;
QPushButton *pushButton_4;
QLabel *DigitalClock;
QLabel *label;
void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QStringLiteral("MainWindow"));
MainWindow->resize(537, 437);
QIcon icon;
icon.addFile(QStringLiteral(":/img/img/software_3k5_icon.ico"), QSize(), QIcon::Normal, QIcon::Off);
MainWindow->setWindowIcon(icon);
centralWidget = new QWidget(MainWindow);
centralWidget->setObjectName(QStringLiteral("centralWidget"));
btnCalculator = new QPushButton(centralWidget);
btnCalculator->setObjectName(QStringLiteral("btnCalculator"));
btnCalculator->setGeometry(QRect(10, 170, 251, 121));
btnCalculator->setStyleSheet(QLatin1String("QPushButton {\n"
" background-color: rgb(255, 151, 57);\n"
" color: white; \n"
" border: 1px solid gray;\n"
" border-radius: 30px;\n"
"}\n"
"\n"
"QPushButton:pressed {\n"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
" stop: 0 #FF7832, stop: 1 #FF9739);\n"
"}"));
pushButton_2 = new QPushButton(centralWidget);
pushButton_2->setObjectName(QStringLiteral("pushButton_2"));
pushButton_2->setGeometry(QRect(270, 170, 251, 121));
pushButton_2->setStyleSheet(QLatin1String("QPushButton {\n"
" background-color: #5cb85c;\n"
" color: white; \n"
" border: 1px solid gray;\n"
" border-radius: 30px;\n"
"}\n"
"\n"
"QPushButton:pressed {\n"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
" stop: 0 #428c42, stop: 1 #12e312);\n"
"}\n"
"\n"
""));
pushButton_3 = new QPushButton(centralWidget);
pushButton_3->setObjectName(QStringLiteral("pushButton_3"));
pushButton_3->setGeometry(QRect(270, 300, 251, 121));
pushButton_3->setStyleSheet(QLatin1String("QPushButton {\n"
" background-color: #d9534f;\n"
" color: white; \n"
" border: 1px solid gray;\n"
" border-radius: 30px;\n"
"}\n"
"\n"
"QPushButton:pressed {\n"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
" stop: 0 #bd1f1a, stop: 1 #f50800);\n"
"}\n"
"\n"
""));
pushButton_4 = new QPushButton(centralWidget);
pushButton_4->setObjectName(QStringLiteral("pushButton_4"));
pushButton_4->setGeometry(QRect(10, 300, 251, 121));
pushButton_4->setStyleSheet(QLatin1String("QPushButton {\n"
" background-color: #337ab7;\n"
" color: white; \n"
" border: 1px solid gray;\n"
" border-radius: 30px;\n"
"}\n"
"\n"
"QPushButton:pressed {\n"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
" stop: 0 #29689e, stop: 1 #0084f5);\n"
"}\n"
"\n"
""));
DigitalClock = new QLabel(centralWidget);
DigitalClock->setObjectName(QStringLiteral("DigitalClock"));
DigitalClock->setGeometry(QRect(10, 100, 511, 51));
QFont font;
font.setFamily(QStringLiteral("Nexa Bold"));
font.setPointSize(36);
DigitalClock->setFont(font);
DigitalClock->setStyleSheet(QStringLiteral("color : #181f1b;"));
DigitalClock->setAlignment(Qt::AlignCenter);
label = new QLabel(centralWidget);
label->setObjectName(QStringLiteral("label"));
label->setGeometry(QRect(10, 19, 511, 51));
QFont font1;
font1.setFamily(QStringLiteral("Montserrat ExtraBold"));
font1.setPointSize(20);
label->setFont(font1);
label->setAlignment(Qt::AlignCenter);
MainWindow->setCentralWidget(centralWidget);
retranslateUi(MainWindow);
QMetaObject::connectSlotsByName(MainWindow);
} // setupUi
void retranslateUi(QMainWindow *MainWindow)
{
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "Multi Purpose Application", Q_NULLPTR));
btnCalculator->setText(QApplication::translate("MainWindow", "Calculator", Q_NULLPTR));
pushButton_2->setText(QApplication::translate("MainWindow", "Encrypted Text Editor", Q_NULLPTR));
pushButton_3->setText(QApplication::translate("MainWindow", "Convertor", Q_NULLPTR));
pushButton_4->setText(QApplication::translate("MainWindow", "Audio Player", Q_NULLPTR));
DigitalClock->setText(QApplication::translate("MainWindow", "TextLabel", Q_NULLPTR));
label->setText(QApplication::translate("MainWindow", "Multi Purpose Application", Q_NULLPTR));
} // retranslateUi
};
namespace Ui {
class MainWindow: public Ui_MainWindow {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_MAINWINDOW_H
| [
"kavindutheekshana@gmail.com"
] | kavindutheekshana@gmail.com |
cad13824c7090334fa8047497629e7a821ba5fb6 | ad295aa0208a892bedad00918d02c227c00e1b90 | /ComparatorSyntacticSugarProject/ComparatorSyntacticSugarProject.cpp | eb61c30013a40a419e32e217c17352f9c54bf0f8 | [] | no_license | michallub/ComparatorSyntacticSugarRepo | 3a4243516c775b8423caad44a05df478f3478d0c | e3c5aaf8ac933dcda9b1af7faf8b114fddf37276 | refs/heads/master | 2023-08-14T06:35:05.953930 | 2021-09-14T02:30:26 | 2021-09-14T02:30:26 | 406,183,347 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 227 | cpp | // ComparatorSyntacticSugarProject.cpp : Defines the functions for the static library.
//
#include "pch.h"
#include "framework.h"
// TODO: This is an example of a library function
void fnComparatorSyntacticSugarProject()
{
}
| [
"michallub@outlook.com"
] | michallub@outlook.com |
501ea5736b5be5f5fe1d428708faf715991e82ed | 1bf8b46afad5402fe6fa74293b464e1ca5ee5fd7 | /SDK/BPF_Clipper_parameters.h | 7d551adaae71f6d48b1151b5c506aa2a96e513af | [] | no_license | LemonHaze420/ShenmueIIISDK | a4857eebefc7e66dba9f667efa43301c5efcdb62 | 47a433b5e94f171bbf5256e3ff4471dcec2c7d7e | refs/heads/master | 2021-06-30T17:33:06.034662 | 2021-01-19T20:33:33 | 2021-01-19T20:33:33 | 214,824,713 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 819 | h | #pragma once
#include "../SDK.h"
// Name: Shenmue3SDK, Version: 1.4.1
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
namespace SDK
{
//---------------------------------------------------------------------------
// Parameters
//---------------------------------------------------------------------------
// Function BPF_Clipper.BPF_Clipper_C.getS3ClipperManager
struct UBPF_Clipper_C_getS3ClipperManager_Params
{
class UObject* __WorldContext; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData)
class ABP_Clipper_C* AsBP_Clipper; // (Parm, OutParm, ZeroConstructor, IsPlainOldData)
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"35783139+LemonHaze420@users.noreply.github.com"
] | 35783139+LemonHaze420@users.noreply.github.com |
5b06f21dc372f55d01016625c6053de945a43bd8 | 3a7215dc6b8ec2ca51af991c0625eca3230b94cf | /c++/reconstruct_itenerary.cpp | 460dc818c2b9bb612b15c58c7219547f44607853 | [] | no_license | ajayt6/AlgoPractice | 55fd60dc5ac3df28680eedb0d3776b7dfabe0823 | 6ab6c65a11ddd47be2e3b8de904a46af7da77868 | refs/heads/master | 2020-12-24T11:37:01.050541 | 2018-02-23T04:11:49 | 2018-02-23T04:11:49 | 73,027,996 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,939 | cpp | /*
https://leetcode.com/problems/reconstruct-itinerary/
This is colution only for the base case
*/
#include<vector>
#include<iostream>
#include<unordered_map>
#include<string>
using namespace std;
class Node
{
public:
string value;
Node * next;
Node()
{
value = "";
next = NULL;
}
};
vector<pair<string, string>> tickets;// = ("MUC", "LHR"), ("JFK", "MUC"), ("SFO", "SJC"), ("LHR", "SFO") };
vector<string> findItinerary(vector<pair<string, string>> tickets) {
unordered_map<string, pair<Node*, int>> airportMap;
string a;
vector<string> resultVector;
Node *temp = NULL,*begin = NULL;
for (auto i = tickets.begin(); i != tickets.end(); i++)
{
//cout << i->first << " " << i->second << endl;
//First check if the airport is already there in the map
if (airportMap.find(i->first) == airportMap.end())
{
temp = new Node;
temp->value = i->first;
airportMap[i->first].first = temp;
airportMap[i->first].second = 0;
}
else
{
temp = airportMap[i->first].first;
}
if (airportMap.find(i->second) == airportMap.end())
{
temp->next = new Node;
temp->next->value = i->second;
airportMap[i->second].first = temp->next;
airportMap[i->second].second = 1;
}
else
{
temp->next= airportMap[i->second].first;
}
if (i->first.compare("JFK") == 0)
begin = temp;
}
if (begin != NULL)
{
temp = begin;
while (temp != NULL)
{
resultVector.push_back(temp->value);
temp = temp->next;
}
return resultVector;
}
else
return{ "Invalid" };
}
int main()
{
vector<string> result;
tickets.push_back(pair<string,string>("MUC", "LHR"));
tickets.push_back(pair<string, string>("JFK", "MUC"));
tickets.push_back(pair<string, string>("SFO", "SJC"));
tickets.push_back(pair<string, string>("LHR", "SFO"));
result = findItinerary(tickets);
cout << "The result is: " << endl;
for (auto i : result)
{
cout << i << " ";
}
getchar();
return 0;
} | [
"ajayt6@gmail.com"
] | ajayt6@gmail.com |
5dbe044817981a43cf7abbe1bdf154dfe5251619 | 8217aa42cc20e705f6793fa30cbab28ed93eb262 | /LeetCode/036 Valid Sudoku/solution.h | 4b6dec1d537312be8e62aca07226232fd91ba370 | [] | no_license | AverJing/LeetCode | 53634d30aec1f36e15fb25b88f4f0c49c7e4830f | b1e31c7f18fc42e59d5dadf38c7e0a63dcef127f | refs/heads/master | 2020-03-24T16:17:20.886107 | 2019-03-17T05:56:32 | 2019-03-17T05:56:32 | 116,369,838 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,793 | h | /*
*
*
*@author: Aver Jing
*@description:
*@date:
*
*
*/
/*
Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:
Each row must contain the digits 1-9 without repetition.
Each column must contain the digits 1-9 without repetition.
Each of the 9 3x3 sub-boxes of the grid must contain the digits 1-9 without repetition.
The Sudoku board could be partially filled, where empty cells are filled with the character '.'.
Example 1:
Input:
[
["5","3",".",".","7",".",".",".","."],
["6",".",".","1","9","5",".",".","."],
[".","9","8",".",".",".",".","6","."],
["8",".",".",".","6",".",".",".","3"],
["4",".",".","8",".","3",".",".","1"],
["7",".",".",".","2",".",".",".","6"],
[".","6",".",".",".",".","2","8","."],
[".",".",".","4","1","9",".",".","5"],
[".",".",".",".","8",".",".","7","9"]
]
Output: true
Example 2:
Input:
[
["8","3",".",".","7",".",".",".","."],
["6",".",".","1","9","5",".",".","."],
[".","9","8",".",".",".",".","6","."],
["8",".",".",".","6",".",".",".","3"],
["4",".",".","8",".","3",".",".","1"],
["7",".",".",".","2",".",".",".","6"],
[".","6",".",".",".",".","2","8","."],
[".",".",".","4","1","9",".",".","5"],
[".",".",".",".","8",".",".","7","9"]
]
Output: false
Explanation: Same as Example 1, except with the 5 in the top left corner being
modified to 8. Since there are two 8's in the top left 3x3 sub-box, it is invalid.
Note:
A Sudoku board (partially filled) could be valid but is not necessarily solvable.
Only the filled cells need to be validated according to the mentioned rules.
The given board contain only digits 1-9 and the character '.'.
The given board size is always 9x9.
*/
#pragma once
#include <vector>
#include <unordered_map>
#include <unordered_set>
using std::vector;
class Solution {
public:
/*
bool isValidSudoku(vector<vector<char> > &board) {
std::unordered_map<size_t, std::unordered_set<char>> row_map, col_map, cel_map;
for (size_t i = 0; i < board.size(); ++i)
for (size_t j = 0; j < board[0].size(); ++j) {
if (board[i][j] == '.') continue;
if (!row_map[i].insert(board[i][j]).second) return false;
if (!col_map[j].insert(board[i][j]).second) return false;
if (!cel_map[i / 3 * 10 + j / 3].insert(board[i][j]).second) return false;
}
return true;
}*/
bool isValidSudoku(vector<vector<char>>& board) {
vector<std::unordered_set<char>> row(9), col(9), box(9);
for (int i = 0; i < 9; ++i) {
for (int j = 0; j < 9; ++j) {
if (board[i][j] == '.')
continue;
int boxNum = i / 3 + j / 3 * 3;
if (!(row[i].insert(board[i][j]).second) || !(col[j].insert(board[i][j]).second) || !(box[boxNum].insert(board[i][j]).second))
return false;
}
}
return true;
}
}; | [
"panda12396@163.com"
] | panda12396@163.com |
e3a4b75644d9f4c2862cae627f85e0bd24d4873a | 0674e81a160161996251fb4b063c801330ccd1e2 | /codeforces/Gym/2009-ACMICPC-SouthEast_USA_regional/F.cpp | 1666e7a85e238a962015ced150f1466acbf72ad1 | [] | no_license | joshuabezaleel/cp | 8a2c9b44605810da4367efeb981f822ae5e1e9a2 | 57f365458cca38c3c0fb1f5af1c6b44b74f3b53e | refs/heads/master | 2022-07-19T00:39:34.395495 | 2020-05-23T20:37:20 | 2020-05-23T20:37:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,946 | cpp | #include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
using namespace std;
#ifdef DEBUG
#define debug(...) printf(__VA_ARGS__)
#define GetTime() fprintf(stderr,"Running time: %.3lf second\n",((double)clock())/CLOCKS_PER_SEC)
#else
#define debug(...)
#define GetTime()
#endif
//type definitions
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
//abbreviations
#define A first
#define B second
#define MP make_pair
#define PB push_back
#define LLD "%I64d"
//macros
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n)-1; 0 <= i; --i)
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for (int i = (a); (b) <= i; --i)
#define FORIT(it,c) for (__typeof ((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define RESET(a,x) memset(a,x,sizeof(a))
#define EXIST(a,s) ((s).find(a) != (s).end())
#define MX(a,b) a = max((a),(b));
#define MN(a,b) a = min((a),(b));
/* -------------- end of azaky's template -------------- */
int n, d, a[1111];
int main(){
scanf("%d%d",&n,&d);
if (n + d == 0) return 0;
priority_queue <pii> pq;
map<int,int> pos;
FOR(i,1,n){
scanf("%d",&a[i]);
pos[a[i]] = i;
pq.push(MP(-a[i],i));
}
bool left = pos[*max_element(a+1,a+n+1)] < pos[*min_element(a+1,a+n+1)];
int lastpos = pq.top().B; pq.pop();
int ans = 0;
FOR(i,2,n){
int nowpos = pq.top().B; pq.pop();
if ((nowpos < lastpos && !left) || (nowpos > lastpos && left)) ans += d;
lastpos = nowpos;
}
printf("%d\n",ans);
main();
return 0;
}
| [
"ahmadzaky003@gmail.com"
] | ahmadzaky003@gmail.com |
ad3ddd9ca0d56abf0c41cbccdf6ca84d57bc0271 | d11be72d86ffb16a89e89c84e387c04329b28d2f | /SampleLib/samplelib.cpp | 71aee070b161ff3ae3100847227206e4dcc8059d | [] | no_license | PlumpMath/InteropTest | 734cce3c8a9a0f9624652ea853a9a9147303b9be | d58a75207497d69c9220a57b805f324e8a235e2e | refs/heads/master | 2021-01-19T23:12:06.453327 | 2013-09-09T05:27:31 | 2013-09-09T05:27:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 301 | cpp | #include <iostream>
#include "samplelib.h"
#include "time.h"
int Test()
{
std::cout << "Calling Add(2, 3)" << std::endl;
int res = Add(2, 3);
std::cout << "Calling Sub(5, 1)" << std::endl;
return Sub(res, 1);
}
int Add(int a, int b)
{
return a + b;
}
int Sub(int a, int b)
{
return a - b;
}
| [
"klein.yang@outlook.com"
] | klein.yang@outlook.com |
95d9bcd967b81a7e3982c9bce70bf1e6cd2832ba | e895750cb2172867a2a049e2f404314085827b05 | /FKCore/FKMessage.cpp | d0357113c2177d20197ed143d9b5f34aecdd3d9f | [
"MIT"
] | permissive | FajraKatviro/FKFramework2 | 32e18621a7ef5bfe7bf61a010932d00dc59de4f9 | 0b55b402c255b50fe07ee568bbf46acd6617a6e4 | refs/heads/master | 2021-01-17T10:07:36.601902 | 2016-04-07T14:50:22 | 2016-04-07T14:50:22 | 21,795,178 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,123 | cpp | #include "FKMessage.h"
#include "FKLogger.h"
/*!
\class FKMessage
\brief Class provides simple message container to deliver into another infrastructure
*/
/*!
* \brief Default constructor. Create empty message object
*/
FKMessage::FKMessage():FKSystemObject(),_subject(){
FK_CBEGIN
FK_CEND
}
/*!
* \brief Create message containing \i subject
*/
FKMessage::FKMessage(const QString& subject):FKSystemObject(),_subject(subject){
FK_CBEGIN
FK_CEND
}
/*!
* \brief Destructs message object
*/
FKMessage::~FKMessage(){
FK_CBEGIN
FK_CEND
}
/*!
* \fn QString FKMessage::subject()const
* \brief Returns message text
*/
/*!
* \brief This is reimplemented function. Pack subject to stream.
*/
bool FKMessage::packObject(QDataStream &stream) const{
stream<<_subject;
return true;
}
/*!
* \brief This is reimplemented function. Read subject from stream.
*/
bool FKMessage::loadObject(QDataStream &stream){
stream>>_subject;
return true;
}
/*!
* \brief This is reimplemented function.
*/
FKSystemObject* FKMessage::clone() const{
return new FKMessage(_subject);
}
| [
"pahaa7@mail.ru"
] | pahaa7@mail.ru |
b9b9d848a05d3b1f2c57526390e471f9c211a80b | 45e0fbd9a9dbcdd4fbe6aaa2fdb2aed296f81e33 | /FindSecret/Classes/Native/UnityEngine_UnityEngine_VRTextureUsage3142149582.h | 7eaa3d518be681b895afa360dc594964f9b500db | [
"MIT"
] | permissive | GodIsWord/NewFindSecret | d4a5d2d810ee1f9d6b3bc91168895cc808bac817 | 4f98f316d29936380f9665d6a6d89962d9ee5478 | refs/heads/master | 2020-03-24T09:54:50.239014 | 2018-10-27T05:22:11 | 2018-10-27T05:22:11 | 142,641,511 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 986 | h | #pragma once
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
#include "mscorlib_System_Enum4135868527.h"
#include "UnityEngine_UnityEngine_VRTextureUsage3142149582.h"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.VRTextureUsage
struct VRTextureUsage_t3142149582
{
public:
// System.Int32 UnityEngine.VRTextureUsage::value__
int32_t ___value___1;
public:
inline static int32_t get_offset_of_value___1() { return static_cast<int32_t>(offsetof(VRTextureUsage_t3142149582, ___value___1)); }
inline int32_t get_value___1() const { return ___value___1; }
inline int32_t* get_address_of_value___1() { return &___value___1; }
inline void set_value___1(int32_t value)
{
___value___1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
| [
"zhangyide@9fbank.cc"
] | zhangyide@9fbank.cc |
920463f2b25bad80e58550336be1ac71cdeb5a69 | f69400af4e10d7a02e00088e79685050dfaae646 | /pir&ir.ino | 199e3b78749707015cfb55be437797d527b0688e | [] | no_license | BushraKhushi/Sensors | 85af2e97b4ea457e00a2540277be6ecbe9460482 | f222bc332866836c6ac54bf2ee2ca73606a72aa5 | refs/heads/master | 2020-09-11T15:18:59.610196 | 2019-11-16T14:18:46 | 2019-11-16T14:18:46 | 222,108,850 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 244 | ino | int ir =0;
int s_Pin;
void setup() {
Serial.begin(9600);
pinMode(ir,INPUT);
}
void loop() {
s_Pin=digitalRead(ir);
if(s_Pin==HIGH){
Serial.println("Detected");
delay(1000);
}
else
Serial.println("N");
}
| [
"noreply@github.com"
] | BushraKhushi.noreply@github.com |
4872dea847c551be2a6ae77e1bcb3603583578d0 | fd4681cefece4c3efd7a0ec4105d1a8f909165ac | /src/codes/rlnc_example.cpp | 3fc4cc1e139834ade507baf91cd69cd977eb810b | [] | no_license | kishori82/COLAS | 05b0a6a0fadb2626769d2319c7b1056d5e502e33 | eb6c2b441f23ce321b1e978a8adfdd50b57d1455 | refs/heads/master | 2020-04-16T02:08:19.815374 | 2017-09-20T14:58:59 | 2017-09-20T14:58:59 | 65,014,280 | 5 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 3,835 | cpp | // Copyright Steinwurf ApS 2016.
// Distributed under the "STEINWURF RESEARCH LICENSE 1.0".
// See accompanying file LICENSE.rst or
// http://www.steinwurf.com/licensing
#include <cstdint>
#include <algorithm>
#include <iostream>
#include <vector>
#include <kodocpp/kodocpp.hpp>
// Prints out the elements of a vector to the
// screen for debugging purposes
// vector<uint8_t> vector the vector to be printed
void printVectorBytes(std::vector<uint8_t> vector){
for (std::vector<uint8_t>::const_iterator i = vector.begin(); i != vector.end(); ++i){
printf("%.2x ", unsigned(*i));
}
std::cout << std::endl;
}
void printVectorChars(std::vector<uint8_t> vector){
for (std::vector<uint8_t>::const_iterator i = vector.begin(); i != vector.end(); ++i){
printf("%c", *i);
}
std::cout << std::endl;
}
void printVectorCharsN(std::vector<uint8_t> vector, int N){
int j=0;
for (std::vector<uint8_t>::const_iterator i = vector.begin(); i != vector.end(); ++i){
if( j++ >= N )
printf("%c", *i);
}
std::cout << std::endl;
}
int main()
{
//! [0]
// Set the number of symbols (i.e. the generation size in RLNC
// terminology) and the size of a symbol in bytes
uint32_t max_symbols = 6;
uint32_t max_symbol_size = 10;
//! [1]
// In the following we will make an encoder/decoder factory.
// The factories are used to build actual encoders/decoders
kodocpp::encoder_factory encoder_factory(
kodocpp::codec::full_vector,
kodocpp::field::binary8,
max_symbols,
max_symbol_size);
kodocpp::encoder encoder = encoder_factory.build();
kodocpp::decoder_factory decoder_factory(
kodocpp::codec::full_vector,
kodocpp::field::binary8,
max_symbols,
max_symbol_size);
//! [2]
std::vector<uint8_t> payload(encoder.payload_size());
std::vector<uint8_t> data_in(encoder.block_size());
char a[] = "My name is Mary! I am a member of the local choir at the St Bishop's church";
char *b;
b = a;
std::generate(data_in.begin(), data_in.end(), [&b]{ return *b++; });
printVectorChars(data_in);
kodocpp::decoder decoder = decoder_factory.build();
//! [3]
// Assign the data buffer to the encoder so that we may start
// to produce encoded symbols from it
encoder.set_const_symbols(data_in.data(), encoder.block_size());
//! [4]
// Create a buffer which will contain the decoded data, and we assign
// that buffer to the decoder
std::vector<uint8_t> data_out(decoder.block_size());
decoder.set_mutable_symbols(data_out.data(), decoder.block_size());
//! [5]
bool DEBUG_MODE = true;
uint32_t lost_payloads = 0;
uint32_t encoded_count = 0;
while (!decoder.is_complete())
{
// Encode a packet into the payload buffer
uint32_t bytes_used = encoder.write_payload(payload.data());
std::cout << "Bytes used = " << bytes_used << std::endl;
++encoded_count;
if(DEBUG_MODE){
// printf("%.2d: ", j);
printVectorBytes(payload);
printVectorChars(payload);
printVectorCharsN(payload, 7);
if ( (rand() % 2) == 0)
{
lost_payloads++;
continue;
}
}
// Pass that packet to the decoder
decoder.read_payload(payload.data());
}
std::cout << "Number of lost payloads: " << lost_payloads << std::endl;
std::cout << "Encoded count = " << encoded_count << std::endl;
//! [6]
// Check if we properly decoded the data
if (data_in == data_out)
{
printVectorChars(data_in);
std::cout << "Data decoded correctly" << std::endl;
printVectorChars(data_out);
}
//! [7]
return 0;
}
| [
"kishori82@gmail.com"
] | kishori82@gmail.com |
db29bbc3b0e11197476522d03de4aee074862eb8 | 5debc2cb3b9a0c7650ab5bfcb6bf3b04d7cf8998 | /Sort/Merge_Sort.cpp | 8f20f7f3481dfbe4cd2145353a6efafe6a34f762 | [] | no_license | thientoan0101/DataStructures-and-Algorithms | 8d84a727b45c89776173b14e9f9dc3e1d2ef5442 | bba62dc79795f0de910594a1174ea02502a8f2fc | refs/heads/main | 2023-01-23T06:15:52.573090 | 2020-11-30T13:44:54 | 2020-11-30T13:44:54 | 309,021,042 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,630 | cpp | // Idea:
// - Partition the original array into two sub arrays.Repeat partitioning on
// the sub array until the array has 1 element. (top - down)
// - Merge each pair of sub arrays into an array in order and repeat for its
// two parent arrays, until the original array size is reached. (bottom - up)
//
// Steps :
// - S1 : mid = (l + r) / 2;
// - S2: Split array a into 2 subarrays b, c
// - S3 : If the subarray b, c has more than 2 elements, then repeat S2.
// - S4 : Merge two child arrays to get an ordered parent array.
// Repeat until the array is full of elements
#include <iostream>
#include <algorithm>
using namespace std;
void print(int a[], int n)
{
for (int i = 0; i < n; i++)
{
cout << a[i] << " ";
}
cout << endl;
}
void merge(int a[], int l, int m, int r)
{
int n1 = m - l + 1;
int n2 = r - m;
int* L = new int[n1];
int* R = new int[n2];
for (int i = 0; i < n1; i++)
L[i] = a[l + i];
for (int i = 0; i < n2; i++)
R[i] = a[m + 1 + i];
int i = 0, j = 0;
for (int k = l; k <= r; k++)
{
if (i < n1 && (j >= n2 || L[i] < R[j]))
{
a[k] = L[i];
i++;
}
else {
a[k] = R[j];
j++;
}
}
delete[] L;
delete[] R;
}
void MergeSort(int a[], int l, int r)
{
if (l >= r) return;
int mid = l + (r - l) / 2;
MergeSort(a, l, mid);
MergeSort(a, mid + 1, r);
merge(a, l, mid, r);
}
int main()
{
int a[] = { 7,3,9,10,1,5,2,4,8 };
for (int i = 0; i < 9; i++)
cout << a[i] << " ";
cout << endl;
mergeSort(a, 0, 8);
for (int i = 0; i < 9; i++)
cout << a[i] << " ";
} | [
"66426299+thientoan0101@users.noreply.github.com"
] | 66426299+thientoan0101@users.noreply.github.com |
b7c424b0d213f38f3888321d9c176a1a4fb2bdd7 | f3a853e4b0854aef4e8b968c730fce717c16d105 | /ScreenElements.h | 10cb57617b5b0e1ce06e6ee66a3f701274a23bc7 | [] | no_license | scanti/Oblivion-Graphics-Extender-v2 | e5990287aae968c3f9b4be8f3788d63593ef5d3c | a25c5fffc5ad252454d11bada92bd05abc3a35da | refs/heads/master | 2021-01-25T05:34:28.361134 | 2010-03-20T02:14:09 | 2010-03-20T02:14:09 | 469,766 | 6 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,583 | h | #pragma once
#include <d3d9.h>
#include <d3dx9.h>
#include <vector>
class ScreenElement
{
public:
bool enabled;
D3DXVECTOR3 pos;
D3DXVECTOR2 scale;
float rot;
D3DXMATRIX transform;
DWORD color;
void SetPosition(float x, float y, float z);
void SetScale(float x, float y);
void SetRotation(float rotation);
void UpdateTransform(void);
void SetColor(float red, float green, float blue);
void SetAlpha(float alpha);
virtual void Render(ID3DXSprite *sprite)=0;
};
class Sprite : public ScreenElement
{
public:
int tex;
bool SetTexture(int texture);
int GetTexture(void);
virtual void Render(ID3DXSprite *sprite);
};
/*
class AnimatedSprite : public Sprite
{
public:
float fps;
float time;
int CurrentFrame;
int Width;
int Height;
void SetFramesPerSecond(float speed);
void SetCurrentFrame(int index);
void SetFilmStripDimensions(int width,int height);
void Render(ID3DXSprite *sprite);
};
*/
class HUDManager
{
public:
static HUDManager* Singleton;
::std::vector<Sprite*> ScreenElementList;
int NextElementIndex;
LPD3DXSPRITE sprite;
private:
HUDManager(); // Declare as private. Use GetSingleton to initialise HUDManager.
// This is so we can't init multiple HUD managers.
public:
static HUDManager *GetSingleton(void);
int AddScreenElement(Sprite *data);
Sprite *index(int ind);
void PurgeTexture(int TextureIndex);
void Render(void);
void DeviceLost(void);
void DeviceReset(void);
void NewGame(void);
void LoadGame(void);
void SaveGame(void);
}; | [
"scanti@bulldoghome.com"
] | scanti@bulldoghome.com |
1f9032dea2539747238aabc906df53027f987265 | 73cfd700522885a3fec41127e1f87e1b78acd4d3 | /_Include/boost/preprocessor/repetition/enum_binary_params.hpp | 401144b4590a3306ecfd7465c723704a4eb8f1b3 | [] | no_license | pu2oqa/muServerDeps | 88e8e92fa2053960671f9f57f4c85e062c188319 | 92fcbe082556e11587887ab9d2abc93ec40c41e4 | refs/heads/master | 2023-03-15T12:37:13.995934 | 2019-02-04T10:07:14 | 2019-02-04T10:07:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,141 | hpp | ////////////////////////////////////////////////////////////////////////////////
// enum_binary_params.hpp
# /* **************************************************************************
# * *
# * (C) Copyright Paul Mensonides 2002.
# * Distributed under the Boost Software License, Version 1.0. (See
# * accompanying file LICENSE_1_0.txt or copy at
# * http://www.boost.org/LICENSE_1_0.txt)
# * *
# ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# ifndef BOOST_PREPROCESSOR_REPETITION_ENUM_BINARY_PARAMS_HPP
# define BOOST_PREPROCESSOR_REPETITION_ENUM_BINARY_PARAMS_HPP
#
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/config/config.hpp>
# include <boost/preprocessor/punctuation/comma_if.hpp>
# include <boost/preprocessor/repetition/repeat.hpp>
# include <boost/preprocessor/tuple/elem.hpp>
# include <boost/preprocessor/tuple/rem.hpp>
#
# /* BOOST_PP_ENUM_BINARY_PARAMS */
#
# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
# define BOOST_PP_ENUM_BINARY_PARAMS(count, p1, p2) BOOST_PP_REPEAT(count, BOOST_PP_ENUM_BINARY_PARAMS_M, (p1, p2))
# else
# define BOOST_PP_ENUM_BINARY_PARAMS(count, p1, p2) BOOST_PP_ENUM_BINARY_PARAMS_I(count, p1, p2)
# define BOOST_PP_ENUM_BINARY_PARAMS_I(count, p1, p2) BOOST_PP_REPEAT(count, BOOST_PP_ENUM_BINARY_PARAMS_M, (p1, p2))
# endif
#
# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()
# define BOOST_PP_ENUM_BINARY_PARAMS_M(z, n, pp) BOOST_PP_ENUM_BINARY_PARAMS_M_IM(z, n, BOOST_PP_TUPLE_REM_2 pp)
# define BOOST_PP_ENUM_BINARY_PARAMS_M_IM(z, n, im) BOOST_PP_ENUM_BINARY_PARAMS_M_I(z, n, im)
# else
# define BOOST_PP_ENUM_BINARY_PARAMS_M(z, n, pp) BOOST_PP_ENUM_BINARY_PARAMS_M_I(z, n, BOOST_PP_TUPLE_ELEM(2, 0, pp), BOOST_PP_TUPLE_ELEM(2, 1, pp))
# endif
#
# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC()
# define BOOST_PP_ENUM_BINARY_PARAMS_M_I(z, n, p1, p2) BOOST_PP_ENUM_BINARY_PARAMS_M_II(z, n, p1, p2)
# define BOOST_PP_ENUM_BINARY_PARAMS_M_II(z, n, p1, p2) BOOST_PP_COMMA_IF(n) p1 ## n p2 ## n
# else
# define BOOST_PP_ENUM_BINARY_PARAMS_M_I(z, n, p1, p2) BOOST_PP_COMMA_IF(n) BOOST_PP_CAT(p1, n) BOOST_PP_CAT(p2, n)
# endif
#
# /* BOOST_PP_ENUM_BINARY_PARAMS_Z */
#
# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
# define BOOST_PP_ENUM_BINARY_PARAMS_Z(z, count, p1, p2) BOOST_PP_REPEAT_ ## z(count, BOOST_PP_ENUM_BINARY_PARAMS_M, (p1, p2))
# else
# define BOOST_PP_ENUM_BINARY_PARAMS_Z(z, count, p1, p2) BOOST_PP_ENUM_BINARY_PARAMS_Z_I(z, count, p1, p2)
# define BOOST_PP_ENUM_BINARY_PARAMS_Z_I(z, count, p1, p2) BOOST_PP_REPEAT_ ## z(count, BOOST_PP_ENUM_BINARY_PARAMS_M, (p1, p2))
# endif
#
# endif
/////////////////////////////////////////////////
// vnDev.Games - Trong.LIVE - DAO VAN TRONG //
////////////////////////////////////////////////////////////////////////////////
| [
"langley.joshua@gmail.com"
] | langley.joshua@gmail.com |
4188ba3193321ac02dc007b08c8a0ac7a599c107 | 1f5f7a63cb9badc5a953e3ee4d7feb96f8feed8c | /Cell.cpp | 129298ddec0ee37eb6355588392641ce2d833209 | [] | no_license | Chimitov931bae/Shashki | aa506ab7c9dd47a3ce243f61a30756c361567bd6 | 6028a0c26ee3ff10ac23ef505c1020ae2cea3b73 | refs/heads/master | 2022-04-21T16:47:43.869744 | 2020-04-25T07:10:03 | 2020-04-25T07:10:03 | 258,705,352 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 145 | cpp | #include "Cell.h"
Cell::Cell(/*const pos & position,*/ State state) : /* mPosition(position),*/ mState(state)
{
}
Cell::~Cell()
{
}
| [
"noreply@github.com"
] | Chimitov931bae.noreply@github.com |
dc4cee70a88315d4cc33b61d12163600211b7e5b | cefd6c17774b5c94240d57adccef57d9bba4a2e9 | /WebKit/Source/JavaScriptCore/ftl/FTLAbstractHeapRepository.h | f3e2bdd7c6e5eb763bb7b75acc6585b1d04015cb | [
"BSL-1.0"
] | permissive | adzhou/oragle | 9c054c25b24ff0a65cb9639bafd02aac2bcdce8b | 5442d418b87d0da161429ffa5cb83777e9b38e4d | refs/heads/master | 2022-11-01T05:04:59.368831 | 2014-03-12T15:50:08 | 2014-03-12T15:50:08 | 17,238,063 | 0 | 1 | BSL-1.0 | 2022-10-18T04:23:53 | 2014-02-27T05:39:44 | C++ | UTF-8 | C++ | false | false | 6,948 | h | /*
* Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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.
*/
#ifndef FTLAbstractHeapRepository_h
#define FTLAbstractHeapRepository_h
#if ENABLE(FTL_JIT)
#include "DFGArrayMode.h"
#include "FTLAbstractHeap.h"
#include "IndexingType.h"
namespace JSC { namespace FTL {
#define FOR_EACH_ABSTRACT_HEAP(macro) \
macro(length) \
macro(typedArrayProperties) \
macro(WriteBarrierBuffer_bufferContents)
#define FOR_EACH_ABSTRACT_FIELD(macro) \
macro(ArrayBuffer_data, ArrayBuffer::offsetOfData()) \
macro(Butterfly_arrayBuffer, Butterfly::offsetOfArrayBuffer()) \
macro(Butterfly_publicLength, Butterfly::offsetOfPublicLength()) \
macro(Butterfly_vectorLength, Butterfly::offsetOfVectorLength()) \
macro(CallFrame_callerFrame, CallFrame::callerFrameOffset()) \
macro(JSArrayBufferView_length, JSArrayBufferView::offsetOfLength()) \
macro(JSArrayBufferView_mode, JSArrayBufferView::offsetOfMode()) \
macro(JSArrayBufferView_vector, JSArrayBufferView::offsetOfVector()) \
macro(JSCell_structureID, JSCell::structureIDOffset()) \
macro(JSCell_typeInfoFlags, JSCell::typeInfoFlagsOffset()) \
macro(JSCell_typeInfoType, JSCell::typeInfoTypeOffset()) \
macro(JSCell_indexingType, JSCell::indexingTypeOffset()) \
macro(JSCell_gcData, JSCell::gcDataOffset()) \
macro(JSFunction_executable, JSFunction::offsetOfExecutable()) \
macro(JSFunction_scope, JSFunction::offsetOfScopeChain()) \
macro(JSObject_butterfly, JSObject::butterflyOffset()) \
macro(JSScope_next, JSScope::offsetOfNext()) \
macro(JSString_flags, JSString::offsetOfFlags()) \
macro(JSString_length, JSString::offsetOfLength()) \
macro(JSString_value, JSString::offsetOfValue()) \
macro(JSVariableObject_registers, JSVariableObject::offsetOfRegisters()) \
macro(JSWrapperObject_internalValue, JSWrapperObject::internalValueOffset()) \
macro(MarkedAllocator_freeListHead, MarkedAllocator::offsetOfFreeListHead()) \
macro(MarkedBlock_markBits, MarkedBlock::offsetOfMarks()) \
macro(StringImpl_data, StringImpl::dataOffset()) \
macro(StringImpl_hashAndFlags, StringImpl::flagsOffset()) \
macro(Structure_structureID, Structure::structureIDOffset()) \
macro(Structure_classInfo, Structure::classInfoOffset()) \
macro(Structure_globalObject, Structure::globalObjectOffset()) \
#define FOR_EACH_INDEXED_ABSTRACT_HEAP(macro) \
macro(JSRopeString_fibers, JSRopeString::offsetOfFibers(), sizeof(WriteBarrier<JSString>)) \
macro(characters8, 0, sizeof(LChar)) \
macro(characters16, 0, sizeof(UChar)) \
macro(indexedInt32Properties, 0, sizeof(EncodedJSValue)) \
macro(indexedDoubleProperties, 0, sizeof(double)) \
macro(indexedContiguousProperties, 0, sizeof(EncodedJSValue)) \
macro(indexedArrayStorageProperties, 0, sizeof(EncodedJSValue)) \
macro(singleCharacterStrings, 0, sizeof(JSString*)) \
macro(variables, 0, sizeof(Register))
#define FOR_EACH_NUMBERED_ABSTRACT_HEAP(macro) \
macro(properties)
// This class is meant to be cacheable between compilations, but it doesn't have to be.
// Doing so saves on creation of nodes. But clearing it will save memory.
class AbstractHeapRepository {
WTF_MAKE_NONCOPYABLE(AbstractHeapRepository);
public:
AbstractHeapRepository(LContext);
~AbstractHeapRepository();
AbstractHeap root;
#define ABSTRACT_HEAP_DECLARATION(name) AbstractHeap name;
FOR_EACH_ABSTRACT_HEAP(ABSTRACT_HEAP_DECLARATION)
#undef ABSTRACT_HEAP_DECLARATION
#define ABSTRACT_FIELD_DECLARATION(name, offset) AbstractField name;
FOR_EACH_ABSTRACT_FIELD(ABSTRACT_FIELD_DECLARATION)
#undef ABSTRACT_FIELD_DECLARATION
AbstractField& JSCell_freeListNext;
#define INDEXED_ABSTRACT_HEAP_DECLARATION(name, offset, size) IndexedAbstractHeap name;
FOR_EACH_INDEXED_ABSTRACT_HEAP(INDEXED_ABSTRACT_HEAP_DECLARATION)
#undef INDEXED_ABSTRACT_HEAP_DECLARATION
#define NUMBERED_ABSTRACT_HEAP_DECLARATION(name) NumberedAbstractHeap name;
FOR_EACH_NUMBERED_ABSTRACT_HEAP(NUMBERED_ABSTRACT_HEAP_DECLARATION)
#undef NUMBERED_ABSTRACT_HEAP_DECLARATION
AbsoluteAbstractHeap absolute;
IndexedAbstractHeap* forIndexingType(IndexingType indexingType)
{
switch (indexingType) {
case ALL_BLANK_INDEXING_TYPES:
case ALL_UNDECIDED_INDEXING_TYPES:
return 0;
case ALL_INT32_INDEXING_TYPES:
return &indexedInt32Properties;
case ALL_DOUBLE_INDEXING_TYPES:
return &indexedDoubleProperties;
case ALL_CONTIGUOUS_INDEXING_TYPES:
return &indexedContiguousProperties;
case ALL_ARRAY_STORAGE_INDEXING_TYPES:
return &indexedArrayStorageProperties;
default:
RELEASE_ASSERT_NOT_REACHED();
return 0;
}
}
IndexedAbstractHeap& forArrayType(DFG::Array::Type type)
{
switch (type) {
case DFG::Array::Int32:
return indexedInt32Properties;
case DFG::Array::Double:
return indexedDoubleProperties;
case DFG::Array::Contiguous:
return indexedContiguousProperties;
case DFG::Array::ArrayStorage:
case DFG::Array::SlowPutArrayStorage:
return indexedArrayStorageProperties;
default:
RELEASE_ASSERT_NOT_REACHED();
return indexedInt32Properties;
}
}
private:
friend class AbstractHeap;
LContext m_context;
unsigned m_tbaaKind;
};
} } // namespace JSC::FTL
#endif // ENABLE(FTL_JIT)
#endif // FTLAbstractHeapRepository_h
| [
"adzhou@hp.com"
] | adzhou@hp.com |
b49e05c27b542a6ea6572262c63cec0e4aac3a9d | 2b9e3c3a7cf48650157e9e860148f16597078ff3 | /TextServiceFile.h | fc634a39f6580d80ff7a335b8bd337cedd372201 | [] | no_license | zhaojidabao/MGCode | 2a7fa089aaed9c2f99a2fd55cd4743fd1ae3d59e | c742915c8170869d5b2fbf791f339a1c28350334 | refs/heads/master | 2020-03-31T20:35:23.596990 | 2018-10-11T07:05:00 | 2018-10-11T07:05:00 | 152,546,612 | 0 | 6 | null | null | null | null | GB18030 | C++ | false | false | 1,091 | h | #pragma once
#include"cpp11_std_files.h"
#include"TextService.h"
using namespace std;
class text_service_file{
private:
wfstream fs;
text_service_file(){};
public:
wstring file_name;
public:
void read_frm_file(wstring& content,ios:: ios_base::openmode mode){
try
{
fs.open(file_name,ios_base::in|mode);
if(fs.is_open()){
if(mode&ios_base::binary){
//暂时没实现二进制输入
}else{
locale loc("");
fs.imbue(loc);
wostringstream wos;
wos<<fs.rdbuf();
wstring rlt=wos.str();
content+=rlt;
textLsReplae(content,L"\n",L"\r\n");
//another way,but with bad efficiency,just comment it for now
//wstring temp;
//while(fs){
// getline(fs,temp);
// content+=std::move(temp);
// temp.clear();
//}
}
}
fs.close();
}catch(const exception& e){
fs.close();
auto ms=e.what();
}
}
void write_to_file(wstring& contenet,ios_base::openmode mode){
//no implemention now
}
static text_service_file& Instance()
{
static text_service_file singleton;
return singleton;
}
};
| [
"42225836+zhaojidabao@users.noreply.github.com"
] | 42225836+zhaojidabao@users.noreply.github.com |
77cb76261a4f1524597a2f19d572752306687d0f | 572580660d475027fa349e47a078479222066726 | /Server/kennel/Ecc_Common/opens/snmp++/snmp++/Snmp++/include/snmp_pp/usertimeout.h | b101c4f7829310e3843dba5029587b51401dbda8 | [] | no_license | SiteView/ecc82Server | 30bae118932435e226ade01bfbb05b662742e6dd | 084b06af3a7ca6c5abf5064e0d1f3f8069856d25 | refs/heads/master | 2021-01-10T21:11:37.487455 | 2013-01-16T09:22:02 | 2013-01-16T09:22:02 | 7,639,874 | 6 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 6,796 | h | /*_############################################################################
_##
_## usertimeout.h
_##
_## SNMP++v3.2.15
_## -----------------------------------------------
_## Copyright (c) 2001-2004 Jochen Katz, Frank Fock
_##
_## This software is based on SNMP++2.6 from Hewlett Packard:
_##
_## Copyright (c) 1996
_## Hewlett-Packard Company
_##
_## ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
_## Permission to use, copy, modify, distribute and/or sell this software
_## and/or its documentation is hereby granted without fee. User agrees
_## to display the above copyright notice and this license notice in all
_## copies of the software and any documentation of the software. User
_## agrees to assume all liability for the use of the software;
_## Hewlett-Packard and Jochen Katz make no representations about the
_## suitability of this software for any purpose. It is provided
_## "AS-IS" without warranty of any kind, either express or implied. User
_## hereby grants a royalty-free license to any and all derivatives based
_## upon this software code base.
_##
_## Stuttgart, Germany, Tue Jan 4 21:42:42 CET 2005
_##
_##########################################################################*/
/*===================================================================
Copyright (c) 1999
Hewlett-Packard Company
ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
Permission to use, copy, modify, distribute and/or sell this software
and/or its documentation is hereby granted without fee. User agrees
to display the above copyright notice and this license notice in all
copies of the software and any documentation of the software. User
agrees to assume all liability for the use of the software; Hewlett-Packard
makes no representations about the suitability of this software for any
purpose. It is provided "AS-IS without warranty of any kind,either express
or implied. User hereby grants a royalty-free license to any and all
derivatives based upon this software code base.
U S E R T I M E O U T . H
CUTEventQueue CLASS DEFINITION
COPYRIGHT HEWLETT PACKARD COMPANY 1999
INFORMATION NETWORKS DIVISION
NETWORK MANAGEMENT SECTION
DESIGN + AUTHOR:
Tom Murray
LANGUAGE:
ANSI C++
DESCRIPTION:
Queue for holding callback associated with user defined
timeouts
=====================================================================*/
// $Id: usertimeout.h,v 1.6 2004/03/03 23:11:21 katz Exp $
#ifndef _USERTIMEOUT
#define _USERTIMEOUT
//----[ includes ]-----------------------------------------------------
#ifndef WIN32
#include <sys/types.h> // NOTE: due to 10.10 bug, order is important
// in that all routines must include types.h
// and time.h in same order otherwise you
// will get conflicting definitions of
// "fd_set" resulting in link time errors.
#include <sys/time.h> // time stuff and fd_set
#endif
//----[ snmp++ includes ]----------------------------------------------
#include "snmp_pp/msec.h"
#include "snmp_pp/eventlist.h"
#ifdef SNMP_PP_NAMESPACE
namespace Snmp_pp {
#endif
//----[ defines ]------------------------------------------------------
typedef unsigned long UtId;
/* User-defined callback */
typedef void (*ut_callback)(void * callData, UtId id);
class EventListHolder;
//----[ CUTEvent class ]-------------------------------------------
/*-----------------------------------------------------------*/
/* CUTEvent */
/* a description of a single MIB access operation. */
/*-----------------------------------------------------------*/
class DLLOPT CUTEvent
{
public:
CUTEvent(const UtId uniqueId, const msec &timeout,
const ut_callback callBack, const void * callData);
~CUTEvent() {};
UtId GetId() { return m_uniqueId ; };
void GetTimeout(msec &timeout) { timeout = m_timeout; };
int Callback();
protected:
UtId m_uniqueId;
msec m_timeout;
ut_callback m_callBack;
void * m_callData;
};
/*-----------------------------------------------------------*/
/* CUTEventQueue */
/* class describing a collection of outstanding SNMP msgs. */
/*-----------------------------------------------------------*/
class DLLOPT CUTEventQueue: public CEvents
{
public:
CUTEventQueue(EventListHolder *holder)
: m_head(0, 0, 0), m_msgCount(0), m_id(1), my_holder(holder) {};
~CUTEventQueue();
UtId AddEntry(const msec &timeout,
const ut_callback callBack,
const void * callData);
CUTEvent *GetEntry(const UtId uniqueId);
void DeleteEntry(const UtId uniqueId);
UtId MakeId();
// find the next msg that will timeout
CUTEvent *GetNextTimeoutEntry();
// find the next timeout
int GetNextTimeout(msec &timeout);
// set up parameters for select
void GetFdSets(int &/*maxfds*/, fd_set &/*readfds*/, fd_set &/*writefds*/,
fd_set &/*exceptfds*/) {} // we never have any event sources
// return number of outstanding messages
int GetCount() { return m_msgCount; };
int HandleEvents(const int /*maxfds*/,
const fd_set &/*readfds*/,
const fd_set &/*writefds*/,
const fd_set &/*exceptfds*/)
{ msec now; return DoRetries(now); };
int DoRetries(const msec &sendtime);
int Done() { return 0; }; // we are never done
protected:
/*-----------------------------------------------------------*/
/* CUTEventQueueElt */
/* a container for a single item on a linked lists of */
/* CUTEvents. */
/*-----------------------------------------------------------*/
class DLLOPT CUTEventQueueElt
{
public:
CUTEventQueueElt(CUTEvent *utevent,
CUTEventQueueElt *next,
CUTEventQueueElt *previous);
~CUTEventQueueElt();
CUTEventQueueElt *GetNext() { return m_next; };
CUTEvent *GetUTEvent() { return m_utevent; };
CUTEvent *TestId(const UtId uniqueId);
private:
CUTEvent *m_utevent;
class CUTEventQueueElt *m_next;
class CUTEventQueueElt *m_previous;
};
CUTEventQueueElt m_head;
int m_msgCount;
UtId m_id;
EventListHolder *my_holder;
};
#ifdef SNMP_PP_NAMESPACE
}; // end of namespace Snmp_pp
#endif
#endif
| [
"xingyu.cheng@dragonflow.com"
] | xingyu.cheng@dragonflow.com |
e26ae8c1cc51fe52b87f603f0d82f73519a339b1 | 4158d1aff880a2949ab032e5107773f4736d46f3 | /Zappin' Kraken v1.0.6/src/main/include/Auto/Actions/ResetPosition.h | f8c0c55729f632c57d0e8cd6d6a381949a073b91 | [] | no_license | FRC1410/infiniterecharge2020 | 37023c2af913ed1c6ecc9fa1c76310b589de35a2 | 00e0bf970debda2e1e232ff2261f6b489ba3a51c | refs/heads/master | 2021-01-02T13:08:01.256723 | 2020-03-11T06:02:14 | 2020-03-11T06:02:14 | 239,635,589 | 5 | 4 | null | 2020-02-17T17:27:54 | 2020-02-10T23:32:11 | C++ | UTF-8 | C++ | false | false | 357 | h | #pragma once
#include "Util/Libraries.h"
class ResetPosition : public frc::Command {
private:
double x, z, angle;
public:
ResetPosition(double x_input, double z_input, double angle_input);
void Initialize() override;
void Execute() override;
bool IsFinished() override;
void End() override;
void Interrupted() override;
}; | [
"35178937+RandyNgo02@users.noreply.github.com"
] | 35178937+RandyNgo02@users.noreply.github.com |
dff5ffa1d7e1c2e1d4cd8ea049dd72b5f6f2f04a | 55dcd3f3f19438f27a86a291e14b9521a2504e23 | /UnrealEngine-4.14-substance_plugin/Engine/Source/Runtime/Engine/Classes/Engine/HairWorksInstance.h | 1c421e1d85a74523cbcefd9d849a64f2ce46c62e | [] | no_license | wangganggreat/UE4NVIDIAHairWorks-Substance | 539faf7eadd131decfe8d2ba04bacd5bee25ed53 | 64ca06a501618ee42189ebf630144e87b8b899e4 | refs/heads/master | 2021-01-19T09:24:55.914028 | 2017-02-28T17:12:47 | 2017-02-28T17:12:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 743 | h | // @third party code - BEGIN HairWorks
#pragma once
#include "HairWorksInstance.generated.h"
class UHairWorksMaterial;
class UHairWorksAsset;
USTRUCT(BlueprintType)
struct ENGINE_API FHairWorksInstance
{
GENERATED_USTRUCT_BODY()
/** Assign HairWorks asset here. */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Asset)
UHairWorksAsset* Hair;
/** Whether override Hair Material of the HairWorks asset. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Asset)
bool bOverride = false;
/** A Hair Material to override the Hair Material of the HairWorks asset. */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Instanced, Category = Hair)
UHairWorksMaterial* HairMaterial;
};
// @third party code - END HairWorks
| [
"smagnani@emblazongames.com"
] | smagnani@emblazongames.com |
e17e57fbd004def3bc2ab8507b76163e07134d15 | 7a7c2f632ee2c78b3402d8e857a42eb5c9cf3909 | /03shader/src/ofApp.h | 6afb40b831294a541445aa614d0a8f8ea74e1e69 | [
"MIT"
] | permissive | micuat/GRAND2014WorkshopKinectPCL | 25ff5eabafa9f13b864760bdc5fb9aba8004799b | 6ac5f6243b7bebd203d135224b53987f4cf7313f | refs/heads/master | 2021-01-01T15:31:18.702171 | 2014-05-27T16:41:42 | 2014-05-27T16:41:42 | 19,116,592 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 599 | h | #pragma once
#include "ofMain.h"
#include "ofxPCL.h"
#include "ofxKinect.h"
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void exit();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
ofxKinect kinect;
ofEasyCam easyCam;
bool toggleWireframe;
ofShader shader;
};
| [
"micuat@aim.com"
] | micuat@aim.com |
788d381c441db05532a901cd7e6bb74b93d0c21f | 7ac3f2b7d12c082b5c2d3a4641d7bc25108238b7 | /bboard1 | c1003153acdffd17f2cfb6d8164150417abfc5c1 | [] | no_license | ryanly36/projects | b8763924a58f8deb8a500ae5fd2e2aa1f3ff3099 | d7bfa4e3bca02bb8cb2a56d179924a51a4ca35ba | refs/heads/master | 2021-05-17T06:44:08.386772 | 2020-07-06T00:56:29 | 2020-07-06T00:56:29 | 250,679,995 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 718 | #ifndef __BBOARD_H__
#define __BBOARD_H__
#include <string>
#include <vector>
using namespace std;
#include "Message.h"
#include "User.h"
class BBoard {
private:
string title;
vector<User> user_list;
const User* current_user;
vector<Message *> message_list;
public:
BBoard();
BBoard(const string &);
~BBoard();
bool loadUsers(const string &);
bool loadMessages(const string &);
bool saveMessages(const string &);
void login();
void run();
private:
void addUser(const string &name, const string &pass);
const User* getUser(const string &name, const string &pw) const;
void display() const;
void addTopic();
void addReply();
};
#endif
| [
"noreply@github.com"
] | ryanly36.noreply@github.com | |
b01bde5d01381c10f886608af61a24fcca71bf39 | 29ed8cdb18e199c6f78f49b9a82fdea099dd03ad | /Firmware/Panel/Button.cpp | e1d1acb4da3854e6f6631e68c304dc783f6d5782 | [] | no_license | kurrosetra/RCWS | a1a63e928d4c3be894d5a015227dc716584f3d6c | dca746c2e56fc7f3f74dfd68fdbe2fdabfca725f | refs/heads/master | 2021-04-27T05:18:28.801598 | 2018-04-27T10:32:03 | 2018-04-27T10:32:03 | 117,524,029 | 1 | 0 | null | 2018-01-17T10:07:01 | 2018-01-15T09:22:11 | Arduino | UTF-8 | C++ | false | false | 2,556 | cpp | //
//
//
#include "Button.h"
byte ButtonClass::asci2byte(String s)
{
char lsb = '0', msb = '0';
byte ret = 0;
if (s.length() > 1) {
msb = s.charAt(0);
lsb = s.charAt(1);
}
else lsb = s.charAt(0);
ret = char2byte(msb) << 4 | (char2byte(lsb) & 0xF);
return ret;
}
byte ButtonClass::char2byte(char c)
{
byte i = 0;
if (c >= '0' && c <= '9') i = c - '0';
else if (c >= 'a' && c <= 'f') i = (c - 'a') + 10;
else if (c >= 'A' && c <= 'F') i = (c - 'A') + 10;
return i;
}
ButtonClass::ButtonClass(HardwareSerial & uart, uint32_t baud) :_uart(&uart)
{
_baud = baud;
_header = "$BUT";
}
ButtonClass::ButtonClass(HardwareSerial & uart, uint32_t baud, String header) :_uart(&uart)
{
_baud = baud;
_header = header;
}
void ButtonClass::init()
{
_uart->begin(_baud);
in.reserve(BUT_MAX_BUFSIZE);
}
bool ButtonClass::read()
{
static byte _prevDataIn = 0;
static uint16_t _prevVolVal = 0;
bool ret = 0;
char c;
byte awal, akhir, b;
uint16_t _v = 0;
String s;
if (_uart->available()) {
c = _uart->read();
if (c == _header.charAt(0)) {
in = "";
inCompleted = 0;
}
else if (c == BUT_CHAR_TERMINATOR) inCompleted = 1;
in += c;
}
if (inCompleted) {
//Serial.println(in);
if (in.indexOf(_header) == 0) {
akhir = in.indexOf(BUT_CHAR_SEPARATOR);
//button command value
awal = akhir + 1;
akhir = in.indexOf(BUT_CHAR_SEPARATOR, awal);
s = in.substring(awal, akhir);
b = asci2byte(s);
//dataIn = asci2byte(s);
if (_prevDataIn != dataIn) {
dataIn = _prevDataIn;
}
else {
if (_prevDataIn != b) {
_prevDataIn = b;
}
}
//voltage value
awal = akhir + 1;
akhir = in.indexOf(BUT_CHAR_TERMINATOR, awal);
s = in.substring(awal, akhir);
_v = s.toInt();
//volValue = s.toInt();
if (_prevVolVal != volValue) {
volValue = _prevVolVal;
}
else {
if (_prevVolVal != _v) {
_prevVolVal = _v;
}
}
ret = 1;
}
}
return ret;
}
byte ButtonClass::getCamera()
{
byte i = CAMERA_NONE;
if (bitRead(dataIn, BUT_POS_SONY)) i = CAMERA_SONY;
else if (bitRead(dataIn, BUT_POS_FLIR)) i = CAMERA_THERMAL;
return i;
}
byte ButtonClass::getMovementMode()
{
byte i = MOVE_MANUAL;
if (bitRead(dataIn, BUT_POS_TRACK)) i = MOVE_TRACK;
else if (bitRead(dataIn, BUT_POS_STAB)) i = MOVE_STAB;
return i;
}
bool ButtonClass::getLrfPower()
{
return bitRead(dataIn, BUT_POS_LRF_PWR);
}
bool ButtonClass::getTriggerEnable()
{
return bitRead(dataIn, BUT_POS_TRIGGER_EN);
}
uint16_t ButtonClass::getVoltage()
{
return volValue;
}
| [
"kurrosetra@gmail.com"
] | kurrosetra@gmail.com |
e4fc0cf98c9e812e5a31effc52fdbb06244c2d4c | 0b51715dec7831108d53b40bfb7dc083a3fd3432 | /src/DeviceEventCallbackInvoker.cc | 4a69211907594bf106384742de06a599b79c3588 | [
"MIT"
] | permissive | spuun/node-jontelldus | d8f65faa754724b5ab73d63333aaf07973dedabc | 002c503da2604551e74f00d0c0a0543af113749a | refs/heads/master | 2021-01-10T03:44:28.249390 | 2017-03-04T20:27:12 | 2017-03-04T20:27:12 | 47,183,600 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 619 | cc | #include "DeviceEventCallbackInvoker.h"
namespace JonTelldus {
DeviceEventCallbackInvoker::DeviceEventCallbackInvoker(
Nan::Callback *callback, int deviceId_, int method_, const char* data_)
: CallbackInvoker(callback), deviceId(deviceId_), method(method_), data(data_) { }
void DeviceEventCallbackInvoker::Execute() {
v8::Local<v8::Object> eventObj = Nan::New<v8::Object>();
Set(eventObj, "deviceId", deviceId);
Set(eventObj, "method", method);
Set(eventObj, "data", data.c_str());
v8::Local<v8::Value> argv[] = {
eventObj
};
callback->Call(1, argv);
}
}
| [
"jon@spuun.se"
] | jon@spuun.se |
8891a1aa802b46e40806bd2418a7dba9854505a2 | 44dc6efc21e4a86cfc07d08dcc1e94aa6094d75f | /MATE71/IOManager.h | a317ecf487f3be3a38639f898db625993accf381 | [] | no_license | KareshiKraise/Prototype3DModelling | 3b36f92b38c95f41a9d568778b22b8be2382d681 | dca57b05b77b3cd3c12c733decac602f2448613e | refs/heads/main | 2023-03-29T02:18:43.490724 | 2021-04-02T11:35:52 | 2021-04-02T11:35:52 | 354,000,137 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 280 | h | #ifndef _LOADER_
#define _LOADER_
#include <vector>
#include <string>
class IOManager
{
public:
static bool readFileToBuffer(std::string filePath, std::vector<unsigned char>& buffer);
static bool readFileToBuffer(std::string filePath, std::string& buffer);
};
#endif | [
"vitormoraesaranha@gmail.com"
] | vitormoraesaranha@gmail.com |
67dfa6b95c256a5556b72138915bce0541690d74 | b01299f1d8972949863b3862ac6b83da580d443f | /lib/tlucene/test/utf8.cc | c64d0cc3df4c4b85818508ece2091d75e4b74d33 | [] | no_license | neophytos-sk/phigita-star | daf170f29212f601270c8182ffb1835163485efe | dd48dc5f5768acb199c3ee2866d01efb4ef98f8a | refs/heads/master | 2021-01-25T10:21:12.039782 | 2016-02-24T09:50:28 | 2016-02-24T09:50:28 | 35,161,947 | 3 | 2 | null | 2023-03-20T11:47:34 | 2015-05-06T14:01:52 | HTML | UTF-8 | C++ | false | false | 13 | cc | ../cc/utf8.cc | [
"neophytos@gmail.com"
] | neophytos@gmail.com |
eda1615a6395dc0cbfedce96eff9fb4595f469a2 | 744c38647f9ad6ef13da1c1be711491cfdc4effe | /aula5.cpp | f63b3add508c5d9acfa22a7ad27c519876233361 | [] | no_license | pauloatavila/estrutura_dados_II | e041a29431d8ba03bbc9c2f6804d508663fa4856 | 97f79548618120cf062343425f65a1b94c19b15c | refs/heads/master | 2019-05-16T13:48:55.304533 | 2016-06-16T00:44:20 | 2016-06-16T00:44:20 | 55,104,997 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 876 | cpp | #include <iostream>
#include "pessoa.hpp"
using namespace std;
int main(int argc, char **argv){
string nome;
int idade;
int i;
Pessoa *raiz = NULL;
for (i=0; i<1; i++){
Pessoa *novo;
cout << "Insira nome" << endl;
cin >> nome;
cout << "Insira idade" << endl;
cin >> idade;
novo = new Pessoa(nome,idade);
if (raiz == NULL){
raiz = novo;
novo->setPai();
} else {
raiz->inserirFilho(novo);
}
}
raiz->caminhoPreOrdem();
cout << endl;
// raiz->caminhoOrdem();
// cout << endl;
// raiz->caminhoPosOrdem();
// cout << endl;
cout << "Insira idade do elemento para apagar" << endl;
cin >> idade;
Pessoa *b = raiz->buscar(idade);
if (b != NULL)
b->deleteEscolhido(&b,&raiz);
else
cout << "Não Encontrado" << endl;
if (raiz != NULL){
raiz->caminhoPreOrdem();
cout << endl;
}
return 0;
}
| [
"psjunior_atavila@hotmail.com"
] | psjunior_atavila@hotmail.com |
fa636e79152f25cf5fddca53b0338a6d5e222afe | 400bcebcf07282b1817b9ffed654914605d463fd | /examples/00Style/main.h | 8fbc92df56c1a13e117e92782a984c2d2f7a2d4f | [] | no_license | c4181/csce240 | c367f092a523168402c39c33cd38ce9f00d34af8 | 4f78a602b06ac764532b3349f58818331ae6bc3b | refs/heads/master | 2021-06-11T22:59:53.097351 | 2021-05-12T02:55:21 | 2021-05-12T02:55:21 | 151,420,442 | 0 | 0 | null | 2018-12-04T17:06:30 | 2018-10-03T13:51:45 | C++ | UTF-8 | C++ | false | false | 531 | h | /******************************************************************************
*3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
* This is a program to test 'cpplint' in catching problems.
*
* Author/copyright: Duncan A. Buell. All rights reserved.
* Used with permission and modified by: Jane Random Hacker
* Date: 14 August 2018
**/
#ifndef MAIN_H
#define MAIN_H
#include <iostream>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using std::string;
#endif // MAIN_H
| [
"cm4181@gmail.com"
] | cm4181@gmail.com |
fed2f2887fc82f40f5b45bacce54337c08c3ef83 | 62a94e72253ab1d830d0ceadee094192b23922f1 | /UAlbertaBot/Source/Micro.cpp | 4d1abcd256acffde9c7d7d1056bdafe189156a67 | [] | no_license | machinsk/CMPUT350_UAlberrtaBot_ProtossKing | 6edba135da8a4016ee05740abd3dffe0f4f95575 | 17cbe5fe0d220bd07533b7262209cf515dfa8a11 | refs/heads/master | 2021-01-10T07:46:48.281113 | 2015-11-19T04:38:38 | 2015-11-19T04:38:38 | 46,467,031 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,944 | cpp | #include "Micro.h"
using namespace UAlbertaBot;
size_t TotalCommands = 0;
const int dotRadius = 2;
void Micro::drawAPM(int x, int y)
{
int bwapiAPM = BWAPI::Broodwar->getAPM();
int myAPM = (int)(TotalCommands / ((double)BWAPI::Broodwar->getFrameCount() / (24*60)));
BWAPI::Broodwar->drawTextScreen(x, y, "%d %d", bwapiAPM, myAPM);
}
void Micro::SmartAttackUnit(BWAPI::UnitInterface* attacker, BWAPI::UnitInterface* target)
{
UAB_ASSERT(attacker, "SmartAttackUnit: Attacker not valid");
UAB_ASSERT(target, "SmartAttackUnit: Target not valid");
if (!attacker || !target)
{
return;
}
// if we have issued a command to this unit already this frame, ignore this one
if (attacker->getLastCommandFrame() >= BWAPI::Broodwar->getFrameCount() || attacker->isAttackFrame())
{
return;
}
// get the unit's current command
BWAPI::UnitCommand currentCommand(attacker->getLastCommand());
// if we've already told this unit to attack this target, ignore this command
if (currentCommand.getType() == BWAPI::UnitCommandTypes::Attack_Unit && currentCommand.getTarget() == target)
{
return;
}
// if nothing prevents it, attack the target
attacker->attack(target);
TotalCommands++;
if (Config::Debug::DrawUnitTargetInfo)
{
BWAPI::Broodwar->drawCircleMap(attacker->getPosition(), dotRadius, BWAPI::Colors::Red, true);
BWAPI::Broodwar->drawCircleMap(target->getPosition(), dotRadius, BWAPI::Colors::Red, true);
BWAPI::Broodwar->drawLineMap( attacker->getPosition(), target->getPosition(), BWAPI::Colors::Red );
}
}
void Micro::SmartAttackMove(BWAPI::UnitInterface* attacker, const BWAPI::Position & targetPosition)
{
UAB_ASSERT(attacker, "SmartAttackMove: Attacker not valid");
UAB_ASSERT(targetPosition.isValid(), "SmartAttackMove: targetPosition not valid");
if (!attacker || !targetPosition.isValid())
{
return;
}
// if we have issued a command to this unit already this frame, ignore this one
if (attacker->getLastCommandFrame() >= BWAPI::Broodwar->getFrameCount() || attacker->isAttackFrame())
{
return;
}
// get the unit's current command
BWAPI::UnitCommand currentCommand(attacker->getLastCommand());
// if we've already told this unit to attack this target, ignore this command
if (currentCommand.getType() == BWAPI::UnitCommandTypes::Attack_Move && currentCommand.getTargetPosition() == targetPosition)
{
return;
}
// if nothing prevents it, attack the target
attacker->attack(targetPosition);
TotalCommands++;
if (Config::Debug::DrawUnitTargetInfo)
{
BWAPI::Broodwar->drawCircleMap(attacker->getPosition(), dotRadius, BWAPI::Colors::Orange, true);
BWAPI::Broodwar->drawCircleMap(targetPosition, dotRadius, BWAPI::Colors::Orange, true);
BWAPI::Broodwar->drawLineMap(attacker->getPosition(), targetPosition, BWAPI::Colors::Orange);
}
}
void Micro::SmartMove(BWAPI::UnitInterface* attacker, const BWAPI::Position & targetPosition)
{
UAB_ASSERT(attacker, "SmartAttackMove: Attacker not valid");
UAB_ASSERT(targetPosition.isValid(), "SmartAttackMove: targetPosition not valid");
if (!attacker || !targetPosition.isValid())
{
return;
}
// if we have issued a command to this unit already this frame, ignore this one
if (attacker->getLastCommandFrame() >= BWAPI::Broodwar->getFrameCount() || attacker->isAttackFrame())
{
return;
}
// get the unit's current command
BWAPI::UnitCommand currentCommand(attacker->getLastCommand());
// if we've already told this unit to move to this position, ignore this command
if ((currentCommand.getType() == BWAPI::UnitCommandTypes::Move) && (currentCommand.getTargetPosition() == targetPosition) && attacker->isMoving())
{
return;
}
// if nothing prevents it, attack the target
attacker->move(targetPosition);
TotalCommands++;
if (Config::Debug::DrawUnitTargetInfo)
{
BWAPI::Broodwar->drawCircleMap(attacker->getPosition(), dotRadius, BWAPI::Colors::White, true);
BWAPI::Broodwar->drawCircleMap(targetPosition, dotRadius, BWAPI::Colors::White, true);
BWAPI::Broodwar->drawLineMap(attacker->getPosition(), targetPosition, BWAPI::Colors::White);
}
}
void Micro::SmartRightClick(BWAPI::UnitInterface * unit, BWAPI::UnitInterface * target)
{
UAB_ASSERT(unit, "SmartRightClick: Unit not valid");
UAB_ASSERT(target, "SmartRightClick: Target not valid");
if (!unit || !target)
{
return;
}
// if we have issued a command to this unit already this frame, ignore this one
if (unit->getLastCommandFrame() >= BWAPI::Broodwar->getFrameCount() || unit->isAttackFrame())
{
return;
}
// get the unit's current command
BWAPI::UnitCommand currentCommand(unit->getLastCommand());
// if we've already told this unit to move to this position, ignore this command
if ((currentCommand.getType() == BWAPI::UnitCommandTypes::Right_Click_Unit) && (currentCommand.getTargetPosition() == target->getPosition()))
{
return;
}
// if nothing prevents it, attack the target
unit->rightClick(target);
TotalCommands++;
if (Config::Debug::DrawUnitTargetInfo)
{
BWAPI::Broodwar->drawCircleMap(unit->getPosition(), dotRadius, BWAPI::Colors::Cyan, true);
BWAPI::Broodwar->drawCircleMap(target->getPosition(), dotRadius, BWAPI::Colors::Cyan, true);
BWAPI::Broodwar->drawLineMap(unit->getPosition(), target->getPosition(), BWAPI::Colors::Cyan);
}
}
void Micro::SmartRepair(BWAPI::UnitInterface * unit, BWAPI::UnitInterface * target)
{
UAB_ASSERT(unit, "SmartRightClick: Unit not valid");
UAB_ASSERT(target, "SmartRightClick: Target not valid");
if (!unit || !target)
{
return;
}
// if we have issued a command to this unit already this frame, ignore this one
if (unit->getLastCommandFrame() >= BWAPI::Broodwar->getFrameCount() || unit->isAttackFrame())
{
return;
}
// get the unit's current command
BWAPI::UnitCommand currentCommand(unit->getLastCommand());
// if we've already told this unit to move to this position, ignore this command
if ((currentCommand.getType() == BWAPI::UnitCommandTypes::Repair) && (currentCommand.getTarget() == target))
{
return;
}
// if nothing prevents it, attack the target
unit->repair(target);
TotalCommands++;
if (Config::Debug::DrawUnitTargetInfo)
{
BWAPI::Broodwar->drawCircleMap(unit->getPosition(), dotRadius, BWAPI::Colors::Cyan, true);
BWAPI::Broodwar->drawCircleMap(target->getPosition(), dotRadius, BWAPI::Colors::Cyan, true);
BWAPI::Broodwar->drawLineMap(unit->getPosition(), target->getPosition(), BWAPI::Colors::Cyan);
}
} | [
"dave.churchill@gmail.com"
] | dave.churchill@gmail.com |
4fcf392ce97fcd4c6de96738bd87a762d8ed8848 | 5145d166dbb699a8f75c4b9d9614002607ae0597 | /algos_semina/1st_semina/seminar_1/D_2075/whaeun25_2075.cpp | 0ca05c787da85f1da9f5297e3b07addd54ea93d6 | [] | no_license | Sookmyung-Algos/2021algos | 8cedfb92d8efaf4f6241dece5bc9b820fc5dc277 | be152912517558f0fc8685574064090e6c175065 | refs/heads/master | 2022-07-21T03:47:38.926142 | 2021-12-02T01:35:13 | 2021-12-02T01:35:13 | 341,102,594 | 11 | 46 | null | 2021-12-02T01:35:14 | 2021-02-22T06:32:53 | C++ | UTF-8 | C++ | false | false | 554 | cpp | #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int>num;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
int check = 0;
cin >> n;
num.resize(n * n + 1);
for (int i = 0; i < n * n; i++) {
cin >> num[i];
}
sort(num.begin(), num.end());
int pos;
for (int i = 0; i <= n * n; i++) {
if (num[i] == 0) {
pos = i;
}
//cout << "i: " << i << " : " << num[i] << "\n";
}
if (pos >= n * n - n + 1) {
check = 1;
}
cout << num[n * n - n + 1 - check];
}
| [
"noreply@github.com"
] | Sookmyung-Algos.noreply@github.com |
af651417e0492d39479cfc6dde8c75b12c46e641 | 656a5c2c0ec1820dcc07a5c76282cd49f31d793f | /backend/third_party/xviz/include/xviz/third_party/asio/detail/reactive_socket_sendto_op.hpp | da970b76a66c15e4d9370f81873bd00b72a8c749 | [
"MIT"
] | permissive | sdhanush13/carlaviz | 9386c0843d5e507782ef070eeee15311db329c7d | bb0071c197a33e402fa749e087f57797f672d979 | refs/heads/main | 2023-01-20T00:21:55.469396 | 2020-11-15T16:19:14 | 2020-11-15T16:19:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,399 | hpp | //
// detail/reactive_socket_sendto_op.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef ASIO_DETAIL_REACTIVE_SOCKET_SENDTO_OP_HPP
#define ASIO_DETAIL_REACTIVE_SOCKET_SENDTO_OP_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "xviz/third_party/asio/detail/config.hpp"
#include "xviz/third_party/asio/detail/bind_handler.hpp"
#include "xviz/third_party/asio/detail/buffer_sequence_adapter.hpp"
#include "xviz/third_party/asio/detail/fenced_block.hpp"
#include "xviz/third_party/asio/detail/memory.hpp"
#include "xviz/third_party/asio/detail/reactor_op.hpp"
#include "xviz/third_party/asio/detail/socket_ops.hpp"
#include "xviz/third_party/asio/detail/push_options.hpp"
namespace asio {
namespace detail {
template <typename ConstBufferSequence, typename Endpoint>
class reactive_socket_sendto_op_base : public reactor_op
{
public:
reactive_socket_sendto_op_base(socket_type socket,
const ConstBufferSequence& buffers, const Endpoint& endpoint,
socket_base::message_flags flags, func_type complete_func)
: reactor_op(&reactive_socket_sendto_op_base::do_perform, complete_func),
socket_(socket),
buffers_(buffers),
destination_(endpoint),
flags_(flags)
{
}
static status do_perform(reactor_op* base)
{
reactive_socket_sendto_op_base* o(
static_cast<reactive_socket_sendto_op_base*>(base));
buffer_sequence_adapter<asio::const_buffer,
ConstBufferSequence> bufs(o->buffers_);
status result = socket_ops::non_blocking_sendto(o->socket_,
bufs.buffers(), bufs.count(), o->flags_,
o->destination_.data(), o->destination_.size(),
o->ec_, o->bytes_transferred_) ? done : not_done;
ASIO_HANDLER_REACTOR_OPERATION((*o, "non_blocking_sendto",
o->ec_, o->bytes_transferred_));
return result;
}
private:
socket_type socket_;
ConstBufferSequence buffers_;
Endpoint destination_;
socket_base::message_flags flags_;
};
template <typename ConstBufferSequence, typename Endpoint, typename Handler>
class reactive_socket_sendto_op :
public reactive_socket_sendto_op_base<ConstBufferSequence, Endpoint>
{
public:
ASIO_DEFINE_HANDLER_PTR(reactive_socket_sendto_op);
reactive_socket_sendto_op(socket_type socket,
const ConstBufferSequence& buffers, const Endpoint& endpoint,
socket_base::message_flags flags, Handler& handler)
: reactive_socket_sendto_op_base<ConstBufferSequence, Endpoint>(socket,
buffers, endpoint, flags, &reactive_socket_sendto_op::do_complete),
handler_(ASIO_MOVE_CAST(Handler)(handler))
{
handler_work<Handler>::start(handler_);
}
static void do_complete(void* owner, operation* base,
const asio::error_code& /*ec*/,
std::size_t /*bytes_transferred*/)
{
// Take ownership of the handler object.
reactive_socket_sendto_op* o(static_cast<reactive_socket_sendto_op*>(base));
ptr p = { asio::detail::addressof(o->handler_), o, o };
handler_work<Handler> w(o->handler_);
ASIO_HANDLER_COMPLETION((*o));
// Make a copy of the handler so that the memory can be deallocated before
// the upcall is made. Even if we're not about to make an upcall, a
// sub-object of the handler may be the true owner of the memory associated
// with the handler. Consequently, a local copy of the handler is required
// to ensure that any owning sub-object remains valid until after we have
// deallocated the memory here.
detail::binder2<Handler, asio::error_code, std::size_t>
handler(o->handler_, o->ec_, o->bytes_transferred_);
p.h = asio::detail::addressof(handler.handler_);
p.reset();
// Make the upcall if required.
if (owner)
{
fenced_block b(fenced_block::half);
ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_, handler.arg2_));
w.complete(handler, handler.handler_);
ASIO_HANDLER_INVOCATION_END;
}
}
private:
Handler handler_;
};
} // namespace detail
} // namespace asio
#include "xviz/third_party/asio/detail/pop_options.hpp"
#endif // ASIO_DETAIL_REACTIVE_SOCKET_SENDTO_OP_HPP
| [
"harish.jartarghar@gmail.com"
] | harish.jartarghar@gmail.com |
4cb4153f784afae611c5fd510b1d49c7d76e9547 | 92e67b30497ffd29d3400e88aa553bbd12518fe9 | /assignment2/part6/Re=110/23.9/uniform/time | 6e1acd7b0bfcb399017db1164011bc586a386b3a | [] | no_license | henryrossiter/OpenFOAM | 8b89de8feb4d4c7f9ad4894b2ef550508792ce5c | c54b80dbf0548b34760b4fdc0dc4fb2facfdf657 | refs/heads/master | 2022-11-18T10:05:15.963117 | 2020-06-28T15:24:54 | 2020-06-28T15:24:54 | 241,991,470 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 823 | /*--------------------------------*- 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 dictionary;
location "23.9/uniform";
object time;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
value 23.9000000000002046;
name "23.9";
index 478;
deltaT 0.05;
deltaT0 0.05;
// ************************************************************************* //
| [
"henry.rossiter@utexas.edu"
] | henry.rossiter@utexas.edu | |
1642d58fc4798f55735703eb4a2440d83e11a12d | bc034b187c9058c30bbac0a20aebba581ab1e510 | /source/0_3242733_27494_10274_784/t0_3242733_27494_10274_784_1_4.cpp | 4cc02fcf46a0d6b4d310624b2aa60ac19a9d1d5b | [] | no_license | ToolTech/GeneticMNIST | 2d1d3af68b17c1d6c3440246f335e184ce2086e9 | 1e9c2c1dd9dc0cc8451ec543fafe1e3100141b0b | refs/heads/master | 2020-12-19T04:14:05.092882 | 2020-02-17T10:56:16 | 2020-02-17T10:56:16 | 235,614,718 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,192 | cpp | // Cpp file for ctxVirtualMachineProgram : 0_3242733_27494_10274_784 Pass:1 Thread:4
#include "t0_3242733_27494_10274_784_1_4.h"
gzBool t0_3242733_27494_10274_784_1_4(ctxVirtualMachineProgram *program)
{
if(!m0_3242733_27494_10274_784_1_4_371(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_372(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_373(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_374(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_375(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_376(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_377(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_378(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_379(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_380(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_381(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_382(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_383(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_384(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_385(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_386(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_387(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_388(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_389(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_390(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_391(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_392(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_393(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_394(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_395(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_396(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_397(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_398(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_399(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_400(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_401(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_402(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_403(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_404(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_405(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_406(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_407(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_408(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_409(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_410(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_411(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_412(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_413(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_414(program))
return FALSE;
if(!m0_3242733_27494_10274_784_1_4_415(program))
return FALSE;
return TRUE;
}
| [
"anders.moden@saabgroup.com"
] | anders.moden@saabgroup.com |
8451f1131a96db8fb803aa19de15f0682b2c5e59 | bbb70fe8bc76c63e6b77e88606657e6f04a4cf69 | /ArrayAsArgument/stdafx.cpp | 5ac311f81fa50f7b056133b94cf610bda3b48629 | [] | no_license | Ravindrakumarg/C-Programs | e724087aefe36773c90ab40302671e9c90305bb5 | 5a4ed4e0d8806449ab69a9b6f9e1463e1cedb4c4 | refs/heads/master | 2021-07-11T20:00:05.767778 | 2020-03-30T16:39:51 | 2020-03-30T16:39:51 | 123,067,511 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 302 | cpp | // stdafx.cpp : source file that includes just the standard includes
// ArrayAsArgument.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| [
"ravindra.gupta@tallysolutions.com"
] | ravindra.gupta@tallysolutions.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.