blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 2 247 | content_id stringlengths 40 40 | detected_licenses listlengths 0 57 | license_type stringclasses 2 values | repo_name stringlengths 4 111 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 58 | visit_date timestamp[ns]date 2015-07-25 18:16:41 2023-09-06 10:45:08 | revision_date timestamp[ns]date 1970-01-14 14:03:36 2023-09-06 06:22:19 | committer_date timestamp[ns]date 1970-01-14 14:03:36 2023-09-06 06:22:19 | github_id int64 3.89k 689M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 25 values | gha_event_created_at timestamp[ns]date 2012-06-07 00:51:45 2023-09-14 21:58:52 ⌀ | gha_created_at timestamp[ns]date 2008-03-27 23:40:48 2023-08-24 19:49:39 ⌀ | gha_language stringclasses 159 values | src_encoding stringclasses 34 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 7 10.5M | extension stringclasses 111 values | filename stringlengths 1 195 | text stringlengths 7 10.5M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
beb43c7d4cb141736f83db0060e0601a9dcc7450 | f4826410ade98a911cb40751eba28c48ab7d75ab | /source/driver.cc | 74e8ca320b30a94d002969eef1da89afff5011cd | [] | no_license | andreamola/WaveBEM | 7489b62231e680974c2a3e35c9de083369a82772 | f81b0606ac676431845e98000f93c7cb0376b1ae | refs/heads/master | 2021-01-17T23:13:56.806512 | 2015-12-28T10:22:52 | 2015-12-28T10:22:52 | 57,984,239 | 0 | 1 | null | 2016-05-03T16:30:29 | 2016-05-03T16:30:29 | null | UTF-8 | C++ | false | false | 2,816 | cc | driver.cc | #include "../include/driver.h"
template <int dim>
Driver<dim>::Driver(int argc, char **argv) :
computational_domain(1,1),
fma(computational_domain),
bem_problem(computational_domain, fma),
free_surface(computational_domain, bem_problem),
dae_time_int(free_surface),
prm()
{
// Declare the parameter entries..
DeclareParameters();
deallog.depth_console(3);
std::list<std::string> args;
for (int i=0; i<argc; ++i)
args.push_back (argv[i]);
std::string default_prm;
// The default parameter file is the name of the application plus prm
default_prm = args.back() + ".prm";
prm.read_input(default_prm, false, true);
// Now that we have the final version of the parameters, parse them.
ParseParameters();
// And write the used ones.
default_prm = args.front() + "_used.prm";
ofstream outprm(default_prm.c_str());
prm.print_parameters(outprm, ParameterHandler::ShortText);
}
template <int dim>
Driver<dim>::~Driver()
{}
template <int dim>
void Driver<dim>::run()
{
computational_domain.read_domain();
Vector<double> y, yp, res, diff_compos,sys_comp;
if(free_surface.initial_condition_from_dump)
{
free_surface.restore_solution(y, yp,
free_surface.restore_filename);
bem_problem.reinit();
free_surface.reinit();
}
else
{
computational_domain.refine_and_resize();
bem_problem.reinit();
free_surface.reinit();
y.reinit(free_surface.n_dofs());
diff_compos.reinit(free_surface.n_dofs());
diff_compos = free_surface.differential_components();
sys_comp = free_surface.sys_comp;
free_surface.initial_conditions(y);
yp.reinit(free_surface.n_dofs());
res.reinit(free_surface.n_dofs());
}
free_surface.prepare_restart(0, y, yp);
//computational_domain.generate_octree_blocking();
dae_time_int.start_ode(y, yp, maxNumSteps);
cout<<"Number of rhs evaluations is "<<free_surface.Rhs_evaluations_counter()<<endl; //*/
}
template <int dim>
void Driver<dim>::DeclareParameters()
{
prm.declare_entry("Maximum number of steps", "1", Patterns::Integer());
computational_domain.declare_parameters(prm);
free_surface.declare_parameters(prm);
dae_time_int.declare_parameters(prm);
bem_problem.declare_parameters(prm);
fma.declare_parameters(prm);
}
template <int dim>
void Driver<dim>::ParseParameters()
{
maxNumSteps = prm.get_integer("Maximum number of steps");
computational_domain.parse_parameters(prm);
free_surface.parse_parameters(prm);
dae_time_int.parse_parameters(prm);
bem_problem.parse_parameters(prm);
fma.parse_parameters(prm);
}
template class Driver<3>;
|
2bd01eec9fff6b15b4d1df07950bb6967d82852e | cab02fadcc30a4ca1385d2025c345783a706100a | /01.slides/Buoi 1 - Overview/Labs/helloworld/hello.cpp | c0e64ee4bcbc9a3bcd469ed282504311475da53c | [] | no_license | ToanTran201217/hi-tech | b1aeecfdc0f100c5cc0c1618e9ec9351031db6bf | 2c7717601fab1eca904c0d8b17e6bf5c0de95591 | refs/heads/master | 2023-08-06T03:13:41.995654 | 2021-10-03T14:27:29 | 2021-10-03T14:27:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 102 | cpp | hello.cpp |
const char* welcome_str = "hello world";
const char* get_welcome_string()
{
return welcome_str;
}
|
2d025646d934e6c31562075aea2ab5bee2ed414f | 1baf465b456e7455c97eff7da5c7d37e64146142 | /Enemy.hpp | 3cbe1da81bea283d2fc8788ea7da0f14950a0785 | [] | no_license | marsakov/piw_piw | 333dd367812ac4a0ce8345726e0b802c1ce764de | 7989789851e30898022ff41e0f809d5d2fc34529 | refs/heads/master | 2020-04-03T03:25:39.552686 | 2018-11-03T14:16:07 | 2018-11-03T14:16:07 | 154,985,521 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,584 | hpp | Enemy.hpp | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Enemy.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: oevtushe <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/10/06 18:29:54 by oevtushe #+# #+# */
/* Updated: 2018/10/07 20:43:54 by oevtushe ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ENEMY_HPP
# define ENEMY_HPP
#include "GameEntity.hpp"
#include "Bullet.hpp"
class Enemy : public GameEntity
{
public:
Enemy(void);
Enemy(int x, int y, int damage);
Enemy(Enemy const &enemy);
~Enemy(void);
int move(int rightX, int rigthY);
void setRightChap();
void setLeftChap();
void shoot(void);
void drawEntity();
void clear(void) const;
int isRightChap(void) const;
int isLeftChap(void) const;
int addToWarriorPool(Enemy *entity);
static const unsigned int warriorPoolSize;
static Enemy *warriorPool[];
Enemy &operator=(Enemy const &enemy);
private:
//int _index;
int _damage;
int _rightChap;
int _leftChap;
};
#endif
|
508127534ae7097013f3aba03e35806e9aa5844b | cdbde43eb95e630502b1aefe575f5a25ed1627df | /CarNd-Laser-Measurements/kalman_filter.hpp | 9b282d2920d265376271685f6e0ec19edff68aa4 | [] | no_license | chapola/CarND-Lasar-Measurements | e47a9eadd0cbbefe0d6323abf49faee7fb1a4fdd | d1fa68a0790719f71151fbf976193ac97d457592 | refs/heads/master | 2020-03-26T21:07:06.459606 | 2018-08-20T04:46:55 | 2018-08-20T04:46:55 | 145,367,144 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,038 | hpp | kalman_filter.hpp | //
// kalman_filter.hpp
// CarNd-Laser-Measurements
//
// Created by Bajrang Chapola on 19/08/18.
// Copyright © 2018 Bajrang Chapola. All rights reserved.
//
#ifndef kalman_filter_hpp
#define kalman_filter_hpp
#include "Eigen/Dense"
#include <stdio.h>
using Eigen::MatrixXd;
using Eigen::VectorXd;
class Kalmanfilter{
public:
///*state vector
VectorXd x_;
// State Covariance matrix
MatrixXd P_;
// State Transition Matrix
MatrixXd F_;
// Process Covariance matrix
MatrixXd Q_;
// measurement matrix
MatrixXd H_;
// measurement Covariance matrix
MatrixXd R_;
//Constructor
Kalmanfilter();
//Distructor
virtual ~Kalmanfilter();
/**
*Predict, Pridict the state and state covariance
*using process model
*/
void Predict();
/**
*Update the state
*@params z The measurement at k+1
*/
void Update(const VectorXd &z);
};
#endif /* kalman_filter_hpp */
|
a881ac89e5fc798277059cf1b9062804cdc40d3d | 531a5b576546b5e71802bea4d82102615265a19a | /Ghost.cpp | c7bf591057ccb5b8c93e76a48248f2b16fb2c5ad | [] | no_license | MaksymKapelianovych/2DEngine | 3881bea45784b36cb3f40862a546122e7a96e30b | 418afa7666dd32ba0322474b72c3c7f2d0060ec6 | refs/heads/master | 2023-04-16T14:28:45.834918 | 2021-04-29T17:13:40 | 2021-04-29T17:13:40 | 362,893,285 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,283 | cpp | Ghost.cpp | //
// Created by zephyrus on 28.03.21.
//
#include <iostream>
#include "Ghost.h"
#include "Engine/game_object.h"
#include "Map.h"
#include "Cell.h"
#include "Components/image.h"
#include "Components/sprite.h"
#include "Path.h"
Ghost::Ghost(const std::weak_ptr<GameObject>& owner, std::weak_ptr<Cell> cell)
: Component(owner), cell_(std::move(cell))
{
}
void Ghost::tryDfs(const std::weak_ptr<Cell>& target)
{
auto map = owner_.lock()->getParent().lock()->getParent().lock()->getComponent<Map>();
}
void Ghost::update(float dt)
{
if(Path::food_.expired()){
auto cell = getOwner()->getParent().lock()->getComponent<Cell>();
auto map = owner_.lock()->getParent().lock()->getParent().lock()->getComponent<Map>();
if(auto food = map->getNearestFood(cell).lock()){
}else{
return;
}
}
static float time = 0;
time += dt;
if (time > 0.2)
{
if (auto nextCell = Path::findGhost().lock())
{
auto owner = getOwner();
owner->getParent().lock()->getComponent<Cell>()->removeObject();
auto map = owner_.lock()->getParent().lock()->getParent().lock()->getComponent<Map>();
if (map->getPacMan().lock() == nextCell)
{
std::cout << "Pacman is eaten\n";
}
nextCell->setObject(owner);
cell_ = nextCell;
time = 0;
}
}
}
|
307f08ff54446c491ce5238016c93302954f8d3e | 6e665dcd74541d40647ebb64e30aa60bc71e610c | /800/VPBX_Support/include/util/transport/ConnectionBrokenException.hxx | 3e098f1bf8ebe565c9b66da44663971907902d91 | [] | no_license | jacklee032016/pbx | b27871251a6d49285eaade2d0a9ec02032c3ec62 | 554149c134e50db8ea27de6a092934a51e156eb6 | refs/heads/master | 2020-03-24T21:52:18.653518 | 2018-08-04T20:01:15 | 2018-08-04T20:01:15 | 143,054,776 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,424 | hxx | ConnectionBrokenException.hxx | #if !defined(CONNECTION_BROKEN_EXCEPTION_DOT_H)
#define CONNECTION_BROKEN_EXCEPTION_DOT_H
/*
* $Id: ConnectionBrokenException.hxx,v 1.1.1.1 2006/11/30 16:27:09 lizhijie Exp $
*/
#include "SystemException.hxx"
/** Infrastructure common to ASSIST.
*/
namespace Assist
{
/** Infrastructure in ASSIST related to making network transport layer
* connections.<br><br>
*/
namespace Transport
{
/** Exception thrown when a TCP connection is broken.<br><br>
*
* @see Assist::SystemException
*/
class ConnectionBrokenException : public Assist::SystemException
{
public:
/** Create the exception.
*
* @param msg Message to be logged. It's usually a strerror.
* @param file File name where exception was created.
* @param line Line number of the file where the exception was
* created.
* @param error Usually an errno.
* @param warn If set, will cause a LOG_WARN to be generated.
*/
ConnectionBrokenException(
const string & msg,
const string & file,
const int line,
const int error = 0,
bool warning = true);
/** Name of this class of exception, "ConnectionBrokenException".
*/
string getName() const;
};
} // namespace Transport
} // namespace Assist
#endif // !defined(CONNECTION_BROKEN_EXCEPTION_DOT_H)
|
e14a33a0b76e99c7e4b894018cf62b08d3e3fda6 | 93309e93d1d000bd672099d1e251e668fd9eac5e | /main.cpp | 5c82db678acdb77b7e65298f19d12e4513328693 | [] | no_license | G4GUO/datvexpressSink | 9f9bc40ed9078d5099db1393c930da3b882a989c | f3d917aff6542c590cdafc88ebcdab31acebb5a3 | refs/heads/master | 2020-05-19T09:12:53.017016 | 2019-05-14T21:11:49 | 2019-05-14T21:11:49 | 184,941,776 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,268 | cpp | main.cpp | #include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <pthread.h>
#include <stdarg.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include "datvexpressSink.h"
bool m_running;
DVBS2 m_dvbs2;
#define TSPLEN 188
#define TP_SYNC 0x47
//
// Signal handler
//
void my_handler(int s){
m_running = false;
express_receive();
express_deinit();
printf("Caught signal %d\n",s);
exit(0);
}
//
// Common print routine
//
void printcon( const char *fmt, ... )
{
va_list ap;
va_start(ap,fmt);
vprintf(fmt,ap);
va_end(ap);
}
static unsigned char m_null[TP_SIZE];
void null_fmt( void )
{
m_null[0] = 0x47;
m_null[1] = 0;
// Add the 13 bit pid
m_null[1] = 0x1F;
m_null[2] = 0xFF;
m_null[3] = 0x10;
for( int i = 4; i < TP_SIZE; i++ ) m_null[i] = 0xFF;
}
//
// increment the counter in a transport packet
//
void inc_seq_count(uint8_t *b){
uint8_t c = b[3]&0x0F;
c = (c+1)&0x0F;
b[3] = (b[3]&0xF0)|c;
}
//
// This processes the transport stream from the UDP socket
//
void *udp_thread( void *arg )
{
// This blocks
uint8_t *b;
while( m_running )
{
b = alloc_buff();
get_udp_buffer( b, TSPLEN );
if( b[0] != TP_SYNC ){ // Try to achieve sync
for( int i = 0; i < TSPLEN-1; i++ ){
get_udp_buffer( b, 1 );
if( b[0] == TP_SYNC ){
get_udp_buffer( b, TSPLEN - 1 );
}
}
}
// Queue
post_buff( b );
}
return arg;
}
//
// This processes the transport stream from STDIN
//
void *stdin_thread( void *arg )
{
// This blocks
uint8_t *b;
while( m_running )
{
b = alloc_buff();
int len = fread(b, 1, TSPLEN, stdin);
if( b[0] == TP_SYNC )
{
// Aligned to TP (probably)
post_buff( b );
}
else
{
// Slip bytes until TP alignment
printcon("STDIN Invalid sync byte %.2X %d\n",b[0],len);
len = fread(b, 1, 1, stdin);
rel_buff( b );
}
}
return arg;
}
//
// Feed modulator with transport packets
//
void ts_loop(void){
uint8_t *b;
while( m_running == true){
if((b=get_buff())!= NULL)
m_dvbs2.s2_add_ts_frame( b );
else
{
// Underrun
m_dvbs2.s2_add_ts_frame( m_null );
}
}
}
static pthread_t m_thread;
void std_loop(void){
// Start the std input loop thread
if(pthread_create( &m_thread, NULL, stdin_thread, NULL ) != 0 )
{
printcon("Unable to start stdin thread\n");
m_running = false;
return;
}
ts_loop();
}
void udp_loop(void){
// Start the udp loop thread
if(pthread_create( &m_thread, NULL, udp_thread, NULL ) != 0 )
{
printcon("Unable to start udp thread\n");
m_running = false;
return;
}
ts_loop();
}
void null_loop(void){
// Just send NULL packets
while( m_running == true){
inc_seq_count( m_null);
m_dvbs2.s2_add_ts_frame( m_null );
}
}
int main( int c, char *argv[]){
struct sigaction sigIntHandler;
SinkConfig cfg;
DVB2FrameFormat fmt;
sigIntHandler.sa_handler = my_handler;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
buf_init();
process_command_line( c, argv, &fmt, &cfg);
if( express_init( "datvexpress16.ihx", "datvexpressraw16.rbf" ) == EXP_OK){
express_set_freq( cfg.express_frequency );
express_set_sr( cfg.express_symbolrate );
express_set_level( cfg.express_level );
if(m_dvbs2.s2_set_configure( &fmt ) == 0){
m_dvbs2.s2_register_tx(express_write_16_bit_samples);
printcon("Channel bitrate %d\n",(int)(m_dvbs2.s2_get_efficiency()*cfg.express_symbolrate));
express_transmit();
m_running = true;
null_fmt();
if(cfg.input == STD_INPUT ) std_loop();
if(cfg.input == UDP_INPUT ) udp_loop();
if(cfg.input == NULL_INPUT ) null_loop();
}else{
printcon( "Error: unable to configure S2 invalid parameter" );
}
}else{
printcon( "Error: unable to init Express" );
}
return 0;
}
|
cf2d3db116f9afe628ca94aa14a1c67f89b0639b | e45adb4daabea0d0a2b96d5eccae52a236f0d265 | /src/scripts/luabridge/object_functions/quest_functions.cpp | 6c3dabf30d0aa9db078a8e4e414415d8265fa2d3 | [] | no_license | Refuge89/WoW-1 | 790a72d7a27b4fd19783bc032309ef7d02437521 | d18b293f5548dae7b09ac5b56398a23c604a728d | refs/heads/master | 2020-04-12T22:37:26.167417 | 2018-12-21T23:49:25 | 2018-12-21T23:49:25 | 162,793,929 | 1 | 0 | null | 2018-12-22T08:15:07 | 2018-12-22T08:15:06 | null | UTF-8 | C++ | false | false | 5,704 | cpp | quest_functions.cpp |
#include "../interpreter/LUAEngine.h"
LuaQuest::LuaQuest(uint32 id) : entry(id), QuestScript() {}
LuaQuest::~LuaQuest()
{
PLUA_INSTANCE li_ = lua_instance.get();
for(std::pair<li::QuestInterfaceMap::iterator, li::QuestInterfaceMap::iterator> interfaces = li_->m_questInterfaceMap.equal_range(entry); interfaces.first != interfaces.second; ++interfaces.first)
{
if(interfaces.first->second == this)
{
li_->m_questInterfaceMap.erase(interfaces.first);
break;
}
}
li::ObjectFRefMap::iterator it;
for(std::pair<li::ObjectFRefMap::iterator, li::ObjectFRefMap::iterator> frefs = li_->m_questFRefs.equal_range(entry); frefs.first != frefs.second;)
{
it = frefs.first++;
cleanup_varparam(it->second, li_->lu);
li_->m_questFRefs.erase(it);
}
}
void LuaQuest::OnQuestStart(Player* mTarget, QuestLogEntry* qLogEntry)
{
NULL_BINDING_CHECK
lua_engine::BeginLuaFunctionCall(m_binding->refs[QUEST_EVENT_ON_ACCEPT]);
push_player(mTarget);
push_int(qLogEntry->GetQuest()->id);
lua_engine::ExecuteLuaFunction(2);
RELEASE_LOCK
}
void LuaQuest::OnQuestComplete(Player* mTarget, QuestLogEntry* qLogEntry)
{
NULL_BINDING_CHECK
lua_engine::BeginLuaFunctionCall(m_binding->refs[QUEST_EVENT_ON_COMPLETE]);
push_player(mTarget);
push_int(qLogEntry->GetQuest()->id);
lua_engine::ExecuteLuaFunction(2);
RELEASE_LOCK
}
void LuaQuest::OnQuestCancel(Player* mTarget)
{
NULL_BINDING_CHECK
lua_engine::BeginLuaFunctionCall(m_binding->refs[QUEST_EVENT_ON_CANCEL]);
push_player(mTarget);
lua_engine::ExecuteLuaFunction(1);
RELEASE_LOCK
}
void LuaQuest::OnGameObjectActivate(uint32 entry, Player* mTarget, QuestLogEntry* qLogEntry)
{
NULL_BINDING_CHECK
lua_engine::BeginLuaFunctionCall(m_binding->refs[QUEST_EVENT_GAMEOBJECT_ACTIVATE]);
push_int(entry);
push_player(mTarget);
push_int(qLogEntry->GetQuest()->id);
lua_engine::ExecuteLuaFunction(3);
RELEASE_LOCK
}
void LuaQuest::OnCreatureKill(uint32 entry, Player* mTarget, QuestLogEntry* qLogEntry)
{
NULL_BINDING_CHECK
lua_engine::BeginLuaFunctionCall(m_binding->refs[QUEST_EVENT_ON_CREATURE_KILL]);
push_int(entry);
push_player(mTarget);
push_int(qLogEntry->GetQuest()->id);
lua_engine::ExecuteLuaFunction(3);
RELEASE_LOCK
}
void LuaQuest::OnExploreArea(uint32 areaId, Player* mTarget, QuestLogEntry* qLogEntry)
{
NULL_BINDING_CHECK
lua_engine::BeginLuaFunctionCall(m_binding->refs[QUEST_EVENT_ON_EXPLORE_AREA]);
push_int(areaId);
push_player(mTarget);
push_int(qLogEntry->GetQuest()->id);
lua_engine::ExecuteLuaFunction(3);
RELEASE_LOCK
}
void LuaQuest::OnPlayerItemPickup(uint32 itemId, uint32 totalCount, Player* mTarget, QuestLogEntry* qLogEntry)
{
NULL_BINDING_CHECK
lua_engine::BeginLuaFunctionCall(m_binding->refs[QUEST_EVENT_ON_PLAYER_ITEMPICKUP]);
push_int(itemId);
push_int(totalCount);
push_player(mTarget);
push_int(qLogEntry->GetQuest()->id);
lua_engine::ExecuteLuaFunction(4);
RELEASE_LOCK
}
namespace lua_engine
{
QuestScript* createluaquest(uint32 id)
{
LuaQuest* pLua = NULL;
PLUA_INSTANCE ref = lua_instance.get();
li::ObjectBindingMap::iterator itr = ref->m_questBinding.find(id);
PObjectBinding pBinding = (itr != ref->m_questBinding.end()) ? itr->second : NULL;
if(pBinding != NULL)
{
pLua = new LuaQuest(id);
pLua->m_binding = pBinding;
ref->m_questInterfaceMap.insert(make_pair(id, pLua));
}
return pLua;
}
void bindQuestMethods(luabridge::module & m)
{
m .class_<QuestLogEntry>("QuestLogEntry")
.method(&QuestLogEntry::CanBeFinished, "CanBeFinished", "canBeFinished", "canbefinished", NULL)
.method(&QuestLogEntry::Complete, "Complete", "complete", NULL)
.method(&QuestLogEntry::UpdatePlayerFields, "UpdatePlayerFields", "updatePlayerFields", "updateplayerfields", NULL)
.method(&QuestLogEntry::SetTrigger, "SetTrigger", "setTrigger", "settrigger", NULL)
.method(&QuestLogEntry::SetMobCount, "SetMobCount", "setMobCount", "setmobcount", NULL)
.method(&QuestLogEntry::IncrementMobCount, "IncrementMobCount", "incrementMobCount", "incrementmobcount", NULL)
.method(&QuestLogEntry::IsUnitAffected, "IsUnitAffected", "isUnitAffected", "isunitaffected", NULL)
.method(&QuestLogEntry::IsCastQuest, "IsCastQuest", "isCastQuest", "iscastquest", NULL)
.method(&QuestLogEntry::IsEmoteQuest, "IsEmoteQuest", "isEmoteQuest", "isemotequest", NULL)
.method(&QuestLogEntry::AddAffectedUnit, "AddAffectedUnit", "addAffectedUnit", "addaffectedunit", NULL)
.method(&QuestLogEntry::ClearAffectedUnits, "ClearAffectedUnits", "clearAffectedUnits", "clearaffectedunits", NULL)
.method(&QuestLogEntry::SetSlot, "SetSlot", "setSlot", "setslot", NULL)
.method(&QuestLogEntry::Finish, "Finish", "finish", NULL)
.method(&QuestLogEntry::SendQuestComplete, "SendQuestComplete", "sendQuestComplete", "sendquestcomplete", NULL)
.method(&QuestLogEntry::SendUpdateAddKill, "SendUpdateAddKill", "sendUpdateAddKill", "sendupdateaddkill", NULL)
.method(&QuestLogEntry::GetMobCount, "GetMobCount", "getMobCount", "getmobcount", NULL)
.method(&QuestLogEntry::GetExploredAreas, "GetExploredAreas", "getExploredAreas", "getexploredareas", NULL)
.method(&QuestLogEntry::GetBaseField, "GetBaseField", "getBaseField", "getbasefield", NULL)
.method(&QuestLogEntry::GetSlot, "GetSlot", "getSlot", "getslot", NULL);
}
}
|
2ed5ea2e551f681654b812d194de767aca5da7ea | e57f89e12ab60e725c19d247e23216f09fd05ff4 | /Src/C++/EasyPlayerPro/xmlConfig.cpp | eb5714e39e5d592cf7268e49da3aed4d063a448b | [] | no_license | QQ1112880/EasyPlayerPro-Win | bb21649d2d7eee26b0b5ea505023b06518811b1c | f65925a425e3d2f0ee6910bcecfb3d36b48e83d6 | refs/heads/master | 2023-05-07T22:05:47.417182 | 2021-06-04T06:22:10 | 2021-06-04T06:22:10 | 392,160,068 | 1 | 0 | null | 2021-08-03T02:22:54 | 2021-08-03T02:22:53 | null | GB18030 | C++ | false | false | 6,085 | cpp | xmlConfig.cpp | #include "xmlConfig.h"
#include "tinyxml/tinystr.h"
#include "tinyxml/tinyxml.h"
XMLConfig::XMLConfig(void)
{
memset(&proConfig, 0x00, sizeof(PRO_CONFIG_T));
}
XMLConfig::~XMLConfig(void)
{
}
int XMLConfig::LoadConfig(char *filename, PRO_CONFIG_T *pConfig)
{
if (NULL == filename) return -1;
int ret = -1;
TiXmlDocument m_DocR;
if (! m_DocR.LoadFile(filename))
{
memset(&proConfig, 0x00, sizeof(PRO_CONFIG_T));
proConfig.splitWindow = 4;
//proConfig.renderFormat = 24;
proConfig.scale = 0;
proConfig.multiple = 1;
proConfig.fullScreen = 0;
proConfig.recordingFileSize = 512;
int channel_num = sizeof(proConfig.channel)/sizeof(proConfig.channel[0]);
for (int i=0; i<channel_num; i++)
{
proConfig.channel[i].cache = 3;
proConfig.channel[i].protocol = 1;
proConfig.channel[i].showOSD = 1;
proConfig.channel[i].showToolbar = 1;
proConfig.channel[i].autoPlay = 0;
}
SaveConfig(filename, &proConfig); //不存在配置文件, 生成一个新的配置文件
if (NULL != pConfig) memcpy(pConfig, &proConfig, sizeof(PRO_CONFIG_T));
return ret;
}
TiXmlHandle hDoc(&m_DocR);
TiXmlHandle hRoot(0);
TiXmlElement *pConfigXML = hDoc.FirstChild("XMLConfig").ToElement();
if (NULL != pConfigXML)
{
TiXmlElement *pE;
pE = pConfigXML->FirstChildElement("SplitWindow");
if (pE && pE->GetText()) proConfig.splitWindow = atoi(pE->GetText());
/*
pE = pConfigXML->FirstChildElement("RenderFormat");
if (pE && pE->GetText()) proConfig.renderFormat = atoi(pE->GetText());
*/
pE = pConfigXML->FirstChildElement("Scale");
if (pE && pE->GetText()) proConfig.scale = atoi(pE->GetText());
pE = pConfigXML->FirstChildElement("Multiple");
if (pE && pE->GetText()) proConfig.multiple = atoi(pE->GetText());
pE = pConfigXML->FirstChildElement("FullScreen");
if (pE && pE->GetText()) proConfig.fullScreen = atoi(pE->GetText());
pE = pConfigXML->FirstChildElement("RecordingFileSize");
if (pE && pE->GetText()) proConfig.recordingFileSize = atoi(pE->GetText());
pE = pConfigXML->FirstChildElement("RecordingDuration");
if (pE && pE->GetText()) proConfig.recordingDuration = atoi(pE->GetText());
pE = pConfigXML->FirstChildElement("AutoSegmentation");
if (pE && pE->GetText()) proConfig.recordingFileAutoSegmentation = atoi(pE->GetText());
TiXmlNode *pNode = pConfigXML->FirstChild("Channel");
if (NULL != pNode)
{
TiXmlElement *pChannel = pNode->ToElement();
if (NULL != pChannel)
{
int chIdx = 0;
TiXmlElement *pCh = pChannel->FirstChild("CH")->ToElement();
while (NULL != pCh)
{
TiXmlAttribute *pAttr = pCh->FirstAttribute();
while (NULL != pAttr)
{
if (0 == strcmp(pAttr->Name(), "URL")) strcpy(proConfig.channel[chIdx].url, pAttr->Value());
else if (0 == strcmp(pAttr->Name(), "OSD")) proConfig.channel[chIdx].showOSD = atoi(pAttr->Value());
else if (0 == strcmp(pAttr->Name(), "Protocol")) proConfig.channel[chIdx].protocol = atoi(pAttr->Value());
else if (0 == strcmp(pAttr->Name(), "Cache")) proConfig.channel[chIdx].cache = atoi(pAttr->Value());
else if (0 == strcmp(pAttr->Name(), "ShowToolbar")) proConfig.channel[chIdx].showToolbar = atoi(pAttr->Value());
else if (0 == strcmp(pAttr->Name(), "AutoPlay")) proConfig.channel[chIdx].autoPlay = atoi(pAttr->Value());
pAttr = pAttr->Next();
}
chIdx ++;
pCh = pCh->NextSiblingElement();
}
//pChannel = pChannel->NextSiblingElement();
}
}
if (NULL != pConfig) memcpy(pConfig, &proConfig, sizeof(PRO_CONFIG_T));
ret = 0;
}
return ret;
}
int AddElement(char *propertyName, char *propertyValue, TiXmlElement *pParent)
{
TiXmlElement *pProperty = new TiXmlElement(propertyName);
TiXmlText* pValue = new TiXmlText(propertyValue);
pProperty->InsertEndChild(*pValue);
pParent->InsertEndChild(*pProperty);
delete pValue;
delete pProperty;
return 0;
}
int AddElement(char *propertyName, int value, TiXmlElement *pParent)
{
char sztmp[16] = {0};
sprintf(sztmp, "%d", value);
TiXmlElement *pProperty = new TiXmlElement(propertyName);
TiXmlText* pValue = new TiXmlText(sztmp);
pProperty->InsertEndChild(*pValue);
pParent->InsertEndChild(*pProperty);
delete pValue;
delete pProperty;
return 0;
}
void XMLConfig::SaveConfig(char *filename, PRO_CONFIG_T *pConfig)
{
if (NULL == filename) return;
if (NULL != pConfig)
{
memcpy(&proConfig, pConfig, sizeof(PRO_CONFIG_T));
}
TiXmlDocument xmlDoc( filename );
TiXmlDeclaration Declaration( "1.0", "UTF-8", "yes" );
xmlDoc.InsertEndChild( Declaration );
TiXmlElement* pRootElm = NULL;
pRootElm = new TiXmlElement( "XMLConfig" );
AddElement("SplitWindow", proConfig.splitWindow, pRootElm);
//AddElement("RenderFormat", proConfig.renderFormat, pRootElm);
AddElement("Scale", proConfig.scale, pRootElm);
AddElement("Multiple", proConfig.multiple, pRootElm);
AddElement("FullScreen", proConfig.fullScreen, pRootElm);
AddElement("RecordingFileSize", proConfig.recordingFileSize,pRootElm);
AddElement("RecordingDuration", proConfig.recordingDuration,pRootElm);
AddElement("AutoSegmentation", proConfig.recordingFileAutoSegmentation,pRootElm);
TiXmlElement* pChannel = NULL;
pChannel = new TiXmlElement( "Channel" );
int channel_num = sizeof(proConfig.channel)/sizeof(proConfig.channel[0]);
for (int i=0; i<channel_num; i++)
{
TiXmlElement *pCh = new TiXmlElement("CH");
pChannel->LinkEndChild(pCh);
pCh->SetAttribute("No", i+1);
pCh->SetAttribute("URL", proConfig.channel[i].url);
pCh->SetAttribute("OSD", proConfig.channel[i].showOSD);
pCh->SetAttribute("Protocol", proConfig.channel[i].protocol);
pCh->SetAttribute("Cache", proConfig.channel[i].cache);
pCh->SetAttribute("ShowToolbar", proConfig.channel[i].showToolbar);
pCh->SetAttribute("AutoPlay", proConfig.channel[i].autoPlay);
}
pRootElm->LinkEndChild(pChannel); //链接到节点RootLv1下
xmlDoc.InsertEndChild(*pRootElm) ;
//xmlDoc.Print() ;
if (xmlDoc.SaveFile())
{
}
delete pRootElm;
}
|
99c5f93c467f0d36fb4b1a1d56a315dbd60ff7e5 | 7af45082f4d819cb43e443d3f7bdd1d559cd11d8 | /encoder_demo/encoder_demo.ino | 3f3dfe6e5cb508834e26ce2c83018e3bf3b2ec0a | [] | no_license | cgil/rocket-launcher | f15e64fc97587a0dfed5e1d9305fd223632286c0 | 2849edac307105cc4dddbfe50f1a27af139808fb | refs/heads/master | 2021-01-25T08:48:59.826641 | 2013-10-23T04:45:19 | 2013-10-23T04:45:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,774 | ino | encoder_demo.ino | // for encoder 0
#define encoder0PinA 2
#define encoder0PinB 3
volatile int encoder0Count = 0;
volatile float angle0 = 0;
volatile float velocity0 = 0;
volatile float angle0_previous = 0;
volatile float angle0_post = 0;
// for encoder 1
#define encoder1PinA 21
#define encoder1PinB 20
volatile int encoder1Count = 0;
volatile float angle1 = 0;
volatile float velocity1 = 0;
volatile float angle1_previous = 0;
volatile float angle1_post = 0;
// for Timer2
volatile int tcnt2 = 131;
volatile int t = 0;
void setup() {
Serial.print("STARTED");
// for encoder 0
pinMode(encoder0PinA, INPUT);
pinMode(encoder0PinB, INPUT);
attachInterrupt(0, doEncoder0A, CHANGE);
attachInterrupt(1, doEncoder0B, CHANGE);
// for encoder 1
pinMode(encoder1PinA, INPUT);
pinMode(encoder1PinB, INPUT);
attachInterrupt(2, doEncoder1A, CHANGE);
attachInterrupt(3, doEncoder1B, CHANGE);
// setup for Timer2: interrupts every 1 ms
TIMSK2 &= ~(1<<TOIE2);
TCCR2A &= ~((1<<WGM21) | (1<<WGM20));
TCCR2B &= ~(1<<WGM22);
ASSR &= ~(1<<AS2);
TIMSK2 &= ~(1<<OCIE2A);
TCCR2B |= (1<<CS22) | (1<<CS20);
TCCR2B &= ~(1<<CS21);
TCNT2 = tcnt2;
TIMSK2 |= (1<<TOIE2);
Serial.begin (9600); // for debugging
}
void loop() {
// for encoder 0
Serial.print("cnt0: ");
Serial.print(encoder0Count, DEC);
Serial.print("; ");
Serial.print("agl0: ");
Serial.print(angle0, 4);
Serial.print("; ");
Serial.print("vel0: ");
Serial.print(velocity0, 4);
Serial.print("; ");
// for encoder 1
Serial.print("cnt1: ");
Serial.print(encoder1Count, DEC);
Serial.print("; ");
Serial.print("agl1: ");
Serial.print(angle1, 4);
Serial.print("; ");
Serial.print("Vel1: ");
Serial.print(velocity1, 4);
Serial.println(".");
}
|
3e90294a5cfc2cdcb2b881bef2220ef4b9feb479 | b1a24c76de06576818a21c70ec411de66564125c | /Maximum Product Subarray.cpp | 32a3c9d770879bee675078642aa629651aad5c41 | [] | no_license | Cyitao/leetcode | 0388dae30c190eaaf2bc337145a6b4073eaf13d5 | aed9c96671aa203a273eb00f700f44b84f7a9346 | refs/heads/master | 2020-04-06T07:19:40.156495 | 2017-12-16T08:12:17 | 2017-12-16T08:12:17 | 63,563,300 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 531 | cpp | Maximum Product Subarray.cpp | /*/**
* Author: 常奕涛
* Date: 2016/07
* Github: https://github.com/Cyitao
* Declaration: All Rights Reserved !!!
**/
class Solution {
public:
int maxProduct(vector<int>& nums)
{
if(nums.empty())
return 0;
int local_min=nums[0],local_max=nums[0];
int res=local_max;
for(int i=1;i<nums.size();i++)
{
int temp=max(max(nums[i],nums[i]*local_min),nums[i]*local_max);
local_min=min(min(nums[i],nums[i]*local_min),nums[i]*local_max);
local_max=temp;
res=max(local_max,res);
}
return res;
}
}; |
bce4eabd3ef4e1fd327f1e9567ccf50e30dea6da | 90d49d65583146cb13a382afac69ff693da0f132 | /validate_maze_dp.cpp | 485fbf5a108586f61c4f3b1dcb5061fcfb2ce878 | [] | no_license | srkprasad1995/files | 82768b538a9e180cc4908bff6174743a0f93a1c8 | 00983aa8439eec6158ab17d0bcbd29bf2a3239c3 | refs/heads/master | 2021-01-15T19:45:10.585486 | 2015-03-22T10:25:43 | 2015-03-22T10:25:43 | 32,670,902 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,414 | cpp | validate_maze_dp.cpp | #include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
int n,m;
char str[21][21];
int visited[21][21];
int di[] = {0,0,-1,1};
int dj[] = {1,-1,0,0};
void dfs(int su,int sv)
{
visited[su][sv] = true;
for(int i=0;i<4;i++)
{
int X=su+di[i];
int Y = sv+dj[i];
if(X<n && X>=0 && Y>=0 && Y<m)
if(!visited[X][Y] && str[X][Y] != '#')
dfs(X,Y);
}
return ;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d %d",&n,&m);
int su,sv,eu,ev;
for(int i=0;i<n;i++)
scanf("%s",str[i]);
int cnt = 0;
memset(visited,0,sizeof(visited));
bool vis[21][21] = {{0}};
for(int i=0;i<n;i++)
{
if(str[i][m-1] =='.' && !vis[i][m-1])
{
if(cnt == 1) eu = i,ev=m-1;
else su=i,sv=m-1;
cnt++;
}
vis[i][m-1] = true;
if(str[i][0] == '.' && !vis[i][0])
{
if(cnt == 1) eu = i,ev=0;
else su=i,sv=0;
cnt++;
}
vis[i][0] = true;
}
for(int i=0;i<m;i++)
{
if(str[0][i] =='.' && !vis[0][i])
{
if(cnt == 1) eu = 0,ev=i;
else su=0,sv=i;
cnt++;
}
vis[0][i] = true;
if(str[n-1][i] =='.' && !vis[n-1][i])
{
if(cnt == 1) eu = n-1,ev=i;
else su=n-1,sv=i;
cnt++;
}
vis[n-1][i] = true;
}
if(cnt != 2)
{
printf("invalid\n");
continue;
}
dfs(su,sv);
if(visited[eu][ev]) printf("valid\n");
else printf("invalid\n");
}
return 0;
}
|
5a063e8cf6783c7774f12c8d2c55d8cfd8283e38 | 97c90eda1035a4f5e13228abb088292e0123938a | /Sources/simple_json_writer.hpp | 12b270021e18373da93b110eb7c43c126cbc6ed4 | [
"MIT"
] | permissive | klassen-software-solutions/kssio | 05127077f685edd117ba3b9c15f84e56c9415dad | b70eb7b0b95d2e78e40edd8d074062cc850c5846 | refs/heads/master | 2020-04-03T17:15:42.430768 | 2020-01-10T23:47:03 | 2020-01-10T23:47:03 | 155,438,127 | 0 | 0 | MIT | 2020-01-10T23:47:05 | 2018-10-30T18:40:17 | C++ | UTF-8 | C++ | false | false | 6,463 | hpp | simple_json_writer.hpp | //
// simple_json_writer.hpp
// kssio
//
// Created by Steven W. Klassen on 2018-04-14.
// Copyright © 2018 Klassen Software Solutions. All rights reserved.
// Licensing follows the MIT License.
//
#ifndef kssio_simple_json_writer_h
#define kssio_simple_json_writer_h
#include <algorithm>
#include <cassert>
#include <functional>
#include <iomanip>
#include <initializer_list>
#include <map>
#include <ostream>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
namespace kss { namespace io { namespace stream { namespace json {
/*!
This namespace provides methods for efficiently creating JSON output. The
requirements for this project were as follows:
1. Single-file header-only implementation suitable for embedding into other projects.
2. No dependancies other than a modern C++ compiler (i.e. no third-party libraries).
3. Ability to stream JSON data without having to have the entire thing in memory.
4. Keys can be assumed to be strings.
5. Values will be assumed to be numbers if they "look like" a number.
6. Children will always be in arrays.
The intention is not a full-grown JSON package (i.e. it is not the equivalent
of kss::util::json::Document), but rather to be able to create JSON output
efficiently.
*/
namespace simple_writer {
using namespace std;
struct Node;
/*!
A JSON child is represented by a key and a node generator function. The function
should return a node* with each call. The pointer must remain valid until the
next call. When there are no more children, it should return nullptr.
Note that the generator can be a lambda, or it could be a generator class that
has a method "node* operator()() { ... }". In either case it will need to maintain
its own state so that it will know what to return on each call.
*/
using node_generator_fn = function<Node*(void)>;
using array_child_t = pair<string, node_generator_fn>;
/*!
A JSON node is represented by a key/value pair mapping combined with an optional
child generator. In the mapping values that appear to be numeric will not be
quoted, all others will assumed to be strings and will be escaped and quoted.
*/
struct Node {
map<string, string> attributes;
mutable vector<array_child_t> arrays;
/*!
Convenience access for setting attributes.
*/
string& operator[](const string& key) {
assert(!key.empty());
return attributes[key];
}
/*!
Reset the node to an empty one.
*/
void clear() noexcept {
attributes.clear();
arrays.clear();
// postconditions
assert(attributes.empty());
assert(arrays.empty());
}
};
// Don't call anything in this "namespace" manually.
struct _private {
// This is based on code found at
// https://stackoverflow.com/questions/4654636/how-to-determine-if-a-string-is-a-number-with-c?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
static inline bool isNumber(const string& s) {
return !s.empty() && std::find_if(s.begin(), s.end(), [](char c) { return !(isdigit(c) || c == '.'); }) == s.end();
}
// The following is based on code found at
// https://stackoverflow.com/questions/7724448/simple-json-string-escape-for-c/33799784#33799784
static string encodeJson(const string &s) {
// If it is a number we need to escapes or quotes.
if (isNumber(s)) {
return s;
}
// Otherwise we must escape it and quote it.
ostringstream o;
o << '"';
for (auto c = s.cbegin(); c != s.cend(); c++) {
switch (*c) {
case '"': o << "\\\""; break;
case '\\': o << "\\\\"; break;
case '\b': o << "\\b"; break;
case '\f': o << "\\f"; break;
case '\n': o << "\\n"; break;
case '\r': o << "\\r"; break;
case '\t': o << "\\t"; break;
default:
if ('\x00' <= *c && *c <= '\x1f') {
o << "\\u"
<< std::hex << std::setw(4) << std::setfill('0') << (int)*c;
} else {
o << *c;
}
}
}
o << '"';
return o.str();
}
static ostream& indent(ostream& strm, int indentLevel, int extraSpaces = 0) {
assert(indentLevel >= 0);
for (auto i = 0; i < (indentLevel*4)+extraSpaces; ++i) {
strm << ' ';
}
return strm;
}
static ostream& writeWithIndent(ostream& strm,
const Node& json,
int indentLevel,
bool needTrailingComma)
{
// preconditions
assert(indentLevel >= 0);
indent(strm, indentLevel);
strm << '{' << endl;
auto lastIt = --json.attributes.end();
for (auto it = json.attributes.begin(); it != json.attributes.end(); ++it) {
indent(strm, indentLevel, 2);
strm << '"' << it->first << "\": " << encodeJson(it->second);
if (it != lastIt || json.arrays.size() > 0) strm << ',';
strm << endl;
}
const auto last = --json.arrays.end();
for (auto it = json.arrays.begin(); it != json.arrays.end(); ++it) {
writeChildInArray(strm, indentLevel, *it, it == last);
}
indent(strm, indentLevel);
strm << '}';
if (needTrailingComma) strm << ',';
strm << endl;
return strm;
}
static ostream& writeChildInArray(ostream& strm,
int indentLevel,
array_child_t& child,
bool isLastChild)
{
// preconditions
assert(indentLevel >= 0);
indent(strm, indentLevel, 2);
strm << '"' << child.first << "\": [" << endl;
Node* json = child.second();
while (json) {
Node tmp = *json;
Node* next = child.second();
writeWithIndent(strm, tmp, indentLevel+1, (next != nullptr));
json = next;
}
indent(strm, indentLevel, 2);
strm << "]";
if (!isLastChild) { strm << ','; }
strm << endl;
return strm;
}
};
/*!
Write a JSON object to a stream.
@returns the stream
@throws any exceptions that the stream writing may throw.
*/
inline ostream& write(ostream& strm, const Node& json) {
return _private::writeWithIndent(strm, json, 0, false);
}
}
} } } }
#endif
|
1ef0d5dea7faad9ecbdba41f5adf78e5cb4d711e | c54b831f63f0da08d13e3626f85c27dbf8347f4a | /zrs233-TestLife.c++ | 99fc88bb81eece2111f29bb942cece025e9c3152 | [] | no_license | cs371p-spring-2013/cs371p-life-tests | 34f9b6261c1ec11f3d0239067cf2ea6cb8249f41 | 0b8da0fce0272fec58d7dec88ef684e8f733282d | refs/heads/master | 2021-01-19T07:12:39.631110 | 2013-04-29T01:48:16 | 2013-04-29T01:48:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,073 | zrs233-TestLife.c++ | /* Faisal Ejaz (UTEID: fe2333 CSID: faisalej, 10AM section)
/ Zachary Sais (UTEID: zrs233 CSID: zrs233, 1PM section)
/ CS371P - Downing
/ Project Life
/ April 24 2013
*/
/*
To test the program:
% ls /usr/include/cppunit/
...
TestFixture.h
...
% locate libcppunit.a
/usr/lib/libcppunit.a
% g++ -pedantic -std=c++0x -Wall Darwin.c++ TestDarwin.c++ -o TestDarwin.c++.app -lcppunit -ldl
% valgrind TestDarwin.c++.app >& TestDarwin.c++.out
*/
// --------
// includes
// --------
#include <iostream> // cout, endl
#include <sstream> // istringtstream, ostringstream
#include <string> // ==
#include <vector>
#include <utility>
#include "cppunit/extensions/HelperMacros.h" // CPPUNIT_TEST, CPPUNIT_TEST_SUITE, CPPUNIT_TEST_SUITE_END
#include "cppunit/TestFixture.h" // TestFixture
#include "cppunit/TextTestRunner.h" // TextTestRunner
#define private public
#define protected public
#define class struct
#include "Cell.h"
#include "ConwayCell.h"
#include "FredkinCell.h"
#include "Life.h"
// -----------
// TestDarwin
// -----------
struct TestLife: CppUnit::TestFixture {
// Testing Constructors
void test_ConwayCell_1(){
ConwayCell cell('.');
CPPUNIT_ASSERT(cell._type =='.');
}
void test_ConwayCell_2(){
ConwayCell cell('*');
CPPUNIT_ASSERT(cell._type =='*');
CPPUNIT_ASSERT(cell._alive == true);
CPPUNIT_ASSERT(cell._will_mutate == false);
}
void test_ConwayCell_3(){
ConwayCell cell('*');
CPPUNIT_ASSERT(cell._type =='*');
CPPUNIT_ASSERT(cell._type == '*');
CPPUNIT_ASSERT(cell._alive = true);
CPPUNIT_ASSERT(cell._will_mutate == false);
}
// Testing willInvert
void test_ConwayCell_4(){
ConwayCell cell('.');
CPPUNIT_ASSERT(cell._type =='.');
CPPUNIT_ASSERT(cell._will_invert == false);
cell.willInvert(3);
CPPUNIT_ASSERT(cell._will_invert == true);
}
void test_ConwayCell_5(){
ConwayCell cell('*');
CPPUNIT_ASSERT(cell._type =='*');
CPPUNIT_ASSERT(cell._will_invert == false);
cell.willInvert(1);
CPPUNIT_ASSERT(cell._will_invert == true);
}
void test_ConwayCell_6(){
ConwayCell cell('*');
CPPUNIT_ASSERT(cell._type =='*');
CPPUNIT_ASSERT(cell._will_invert == false);
cell.willInvert(3);
CPPUNIT_ASSERT(cell._will_invert == false);
}
// Testing move
void test_ConwayCell_7(){
ConwayCell cell('.');
CPPUNIT_ASSERT(cell.move() == 0);
}
void test_ConwayCell_8(){
ConwayCell cell('.');
cell.willInvert(3);
CPPUNIT_ASSERT(cell.move() == 1);
CPPUNIT_ASSERT(cell._type == '*');
}
void test_ConwayCell_9(){
ConwayCell cell('*');
cell.willInvert(1);
CPPUNIT_ASSERT(cell.move() == -1);
CPPUNIT_ASSERT(cell._type == '.');
}
// Testing FredkinCell Constructors
void test_FredkinCell_1(){
FredkinCell cell('0');
CPPUNIT_ASSERT(cell._type =='0');
CPPUNIT_ASSERT(cell._age == 0);
CPPUNIT_ASSERT(cell._alive == true);
}
void test_FredkinCell_2(){
FredkinCell cell('-');
CPPUNIT_ASSERT(cell._type =='-');
CPPUNIT_ASSERT(cell._alive == false);
CPPUNIT_ASSERT(cell._will_mutate == false);
}
void test_FredkinCell_3(){
FredkinCell cell('0');
CPPUNIT_ASSERT(cell._type =='0');
CPPUNIT_ASSERT(cell._alive = true);
CPPUNIT_ASSERT(cell._will_mutate == false);
}
// Testing willInvert
void test_FredkinCell_4(){
FredkinCell cell('-');
CPPUNIT_ASSERT(cell._type =='-');
CPPUNIT_ASSERT(cell._will_invert == false);
cell.willInvert(1);
CPPUNIT_ASSERT(cell._will_invert == true);
}
void test_FredkinCell_5(){
FredkinCell cell('0');
CPPUNIT_ASSERT(cell._will_invert == false);
cell.willInvert(0);
CPPUNIT_ASSERT(cell._will_invert == true);
}
void test_FredkinCell_6(){
FredkinCell cell('0');
CPPUNIT_ASSERT(cell._type =='0');
CPPUNIT_ASSERT(cell._will_invert == false);
cell.willInvert(3);
CPPUNIT_ASSERT(cell._will_invert == false);
}
// Testing move
void test_FredkinCell_7(){
FredkinCell cell('.');
CPPUNIT_ASSERT(cell.move() == 0);
}
void test_FredkinCell_8(){
FredkinCell cell('0');
cell.willInvert(0);
CPPUNIT_ASSERT(cell.move() == -1);
CPPUNIT_ASSERT(cell._age == 0);
CPPUNIT_ASSERT(cell._type == '-');
}
void test_FredkinCell_9(){
FredkinCell cell('-');
cell.willInvert(1);
CPPUNIT_ASSERT(cell.move() == 1);
CPPUNIT_ASSERT(cell._type == '0');
}
// Testing Cell Constructors
void test_Cell_1(){
Cell cell = new ConwayCell('.');
CPPUNIT_ASSERT(cell.get()->_type =='.');
CPPUNIT_ASSERT(cell.get()->_alive == false);
}
void test_Cell_2(){
Cell cell = new ConwayCell('*');
CPPUNIT_ASSERT(cell.get()->_type =='*');
CPPUNIT_ASSERT(cell.get()->_alive == true);
}
void test_Cell_3(){
Cell cell = new FredkinCell('0');
CPPUNIT_ASSERT(cell.get()->_type =='0');
CPPUNIT_ASSERT(cell.get()->_alive == true);
}
void test_Cell_4(){
Cell cell = new FredkinCell('-');
CPPUNIT_ASSERT(cell.get()->_type =='-');
CPPUNIT_ASSERT(cell.get()->_alive == false);
}
// Testing isAlive()
void test_Cell_5(){
Cell cell = new ConwayCell('.');
CPPUNIT_ASSERT(cell.isAlive() == false);
}
void test_Cell_6(){
Cell cell = new FredkinCell('0');
CPPUNIT_ASSERT(cell.isAlive() == true);
}
void test_Cell_7(){
Cell cell = new FredkinCell('-');
CPPUNIT_ASSERT(cell.isAlive() == false);
}
// Testing printStatus()
void test_Cell_8(){
Cell cell = new ConwayCell('.');
CPPUNIT_ASSERT(cell.printStatus() == '.');
}
void test_Cell_9(){
Cell cell = new FredkinCell('0');
CPPUNIT_ASSERT(cell.printStatus() == '0');
}
void test_Cell_10(){
Cell cell = new FredkinCell('-');
CPPUNIT_ASSERT(cell.printStatus() == '-');
}
// Testing willInvert()
void test_Cell_11(){
Cell cell = new ConwayCell('*');
cell.willInvert(1);
CPPUNIT_ASSERT(cell.get()->_will_invert == true);
}
void test_Cell_12(){
Cell cell = new FredkinCell('0');
cell.willInvert(2);
CPPUNIT_ASSERT(cell.get()->_will_invert == true);
}
void test_Cell_13(){
Cell cell = new FredkinCell('-');
cell.willInvert(1);
CPPUNIT_ASSERT(cell.get()->_will_invert == true);
}
// Test move
void test_Cell_14(){
Cell cell = new ConwayCell('.');
CPPUNIT_ASSERT(cell.move() == 0);
}
void test_Cell_15(){
Cell cell = new ConwayCell('*');
cell.willInvert(1);
CPPUNIT_ASSERT(cell.move() == -1);
CPPUNIT_ASSERT(cell.get()->_type == '.');
}
void test_Cell_16(){
Cell cell = new FredkinCell('-');
cell.willInvert(1);
CPPUNIT_ASSERT(cell.move() == 1);
CPPUNIT_ASSERT(cell.get()->_type == '0');
}
// Test mutate
void test_Cell_17(){
Cell cell = new FredkinCell('-');
cell.mutate();
CPPUNIT_ASSERT(cell.get()->_type == '*');
}
void test_Cell_18(){
Cell cell = new FredkinCell('0');
cell.willInvert(1);
cell.move();
CPPUNIT_ASSERT(cell.get()->_type == '1');
cell.mutate();
CPPUNIT_ASSERT(cell.get()->_type == '*');
}
void test_Cell_19(){
Cell cell = new FredkinCell('0');
cell.willInvert(2);
cell.move();
CPPUNIT_ASSERT(cell.get()->_type == '-');
cell.mutate();
CPPUNIT_ASSERT(cell.get()->_type == '*');
}
// Test Constructor
void test_Life_1(){
Life<ConwayCell> life;
CPPUNIT_ASSERT(life._population == 0);
}
void test_Life_2(){
Life<ConwayCell> life;
CPPUNIT_ASSERT(life._generation == 0);
}
// Test read with filename
void test_Life_3(){
Life<ConwayCell> life;
life.read("RunLifeConway.in");
CPPUNIT_ASSERT(life._height == 109);
CPPUNIT_ASSERT(life._width == 69);
}
void test_Life_4(){
Life<FredkinCell> life;
life.read("RunLifeFredkin.in");
CPPUNIT_ASSERT(life._population == 4);
}
void test_Life_5(){
Life<Cell> life;
life.read("RunLifeCell.in");
CPPUNIT_ASSERT(life._population == 6);
}
void test_Life_6(){
Life<ConwayCell> life;
life.read("RunLifeConway.in");
CPPUNIT_ASSERT(life._height == 109);
CPPUNIT_ASSERT(life._width == 69);
CPPUNIT_ASSERT(life._population == 35);
}
// testing read with stringstream
void test_Life_7(){
Life <FredkinCell> life;
string grid = "9\n9\n0-------0\n-0-----0-\n--0---0--\n---0-0---\n----0----\n---0-0---\n--0---0--\n-0-----0-\n0-------0\n";
stringstream s_stream;
s_stream << grid;
life.read(s_stream);
CPPUNIT_ASSERT(life._height == 9);
CPPUNIT_ASSERT(life._width == 9);
CPPUNIT_ASSERT(life._population == 17);
}
void test_Life_8(){
Life <Cell> life;
string grid = "2\n2\n00\n-0\n";
stringstream s_stream;
s_stream << grid;
life.read(s_stream);
CPPUNIT_ASSERT(life._height == 2);
CPPUNIT_ASSERT(life._width == 2);
CPPUNIT_ASSERT(life._population == 3);
}
void test_Life_9(){
Life<FredkinCell> life;
string grid = "20\n20\n--------------------\n-000000000000000000-\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n-000000000000000000-\n--------------------\n";
stringstream s_stream;
s_stream << grid;
life.read(s_stream);
CPPUNIT_ASSERT(life._height == 20);
CPPUNIT_ASSERT(life._width == 20);
CPPUNIT_ASSERT(life._population == 36);
}
// testing do_turn()
void test_Life_10(){
Life<Cell> life;
string grid = "2\n2\n00\n-0\n";
stringstream s_stream;
s_stream << grid;
life.read(s_stream);
life.doTurn();
CPPUNIT_ASSERT(life._population == 2);
}
void test_Life_11(){
Life<Cell> life;
string grid = "8\n10\n----------\n-00000000-\n-00-00-00-\n-00-00-00-\n-00000000-\n-0--0-0-0-\n-0--0-0-0-\n----------\n";
stringstream s_stream;
s_stream << grid;
life.read(s_stream);
CPPUNIT_ASSERT(life._population == 36);
CPPUNIT_ASSERT(life._generation == 0);
life.doTurn();
life.doTurn();
CPPUNIT_ASSERT(life._population == 38);
}
void test_Life_12(){
Life<Cell> life;
string grid = "20\n20\n--------------------\n-000000000000000000-\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n--------------------\n-000000000000000000-\n--------------------\n";
stringstream s_stream;
s_stream << grid;
life.read(s_stream);
CPPUNIT_ASSERT(life._population == 36);
CPPUNIT_ASSERT(life._generation == 0);
life.doTurn();
life.doTurn();
life.doTurn();
life.doTurn();
life.doTurn();
CPPUNIT_ASSERT(life._generation == 5);
CPPUNIT_ASSERT(life._population == 152);
}
// Testing findNeighbors()
void test_Life_13(){
Life<Cell> life;
string grid = "8\n10\n----------\n-00000000-\n-00-00-00-\n-00-00-00-\n-00000000-\n-0--0-0-0-\n-0--0-0-0-\n----------\n";
stringstream s_stream;
s_stream << grid;
life.read(s_stream);
CPPUNIT_ASSERT(life.findNeighbors(0,0) == 0);
}
void test_Life_14(){
Life<Cell> life;
string grid = "2\n2\n00\n-0\n";
stringstream s_stream;
s_stream << grid;
life.read(s_stream);
life.doTurn();
CPPUNIT_ASSERT(life.findNeighbors(1,1) == 0);
}
void test_Life_15(){
Life<ConwayCell> life;
string grid = "6\n4\n....\n....\n***.\n.***\n....\n....\n";
stringstream s_stream;
s_stream << grid;
life.read(s_stream);
life.doTurn();
life.doTurn();
life.doTurn();
life.doTurn();
CPPUNIT_ASSERT(life._generation == 4);
CPPUNIT_ASSERT(life.findNeighbors(1,2) == 4);
}
// testing addCell()
void test_Life_16(){
Life<ConwayCell> life;
string grid = "2\n2\n..\n..\n";
stringstream s_stream;
s_stream << grid;
life.read(s_stream);
CPPUNIT_ASSERT(life.addCell(0,0, ConwayCell('*')) == true);
CPPUNIT_ASSERT(life._grid[0][0]._type == '*');
}
void test_Life_17(){
Life<FredkinCell> life;
string grid = "2\n2\n--\n--\n";
stringstream s_stream;
s_stream << grid;
life.read(s_stream);
CPPUNIT_ASSERT(life.addCell(0,0, FredkinCell('0')) == true);
CPPUNIT_ASSERT(life.addCell(1,1, FredkinCell('-')) == false);
CPPUNIT_ASSERT(life._grid[0][0]._type == '0');
CPPUNIT_ASSERT(life._grid[1][1]._type == '-');
CPPUNIT_ASSERT(life._grid[1][0]._type == '-');
}
void test_Life_18(){
Life<Cell> life;
string grid = "8\n10\n----------\n-00000000-\n-00-00-00-\n-00-00-00-\n-00000000-\n-0--0-0-0-\n-0--0-0-0-\n----------\n";
stringstream s_stream;
s_stream << grid;
life.read(s_stream);
CPPUNIT_ASSERT(life.addCell(0,5, new FredkinCell('0')) == true);
CPPUNIT_ASSERT(life._grid[0][5].printStatus() == '0');
}
// -----
// suite
// -----
CPPUNIT_TEST_SUITE(TestLife);
CPPUNIT_TEST(test_ConwayCell_1);
CPPUNIT_TEST(test_ConwayCell_2);
CPPUNIT_TEST(test_ConwayCell_3);
CPPUNIT_TEST(test_ConwayCell_4);
CPPUNIT_TEST(test_ConwayCell_5);
CPPUNIT_TEST(test_ConwayCell_6);
CPPUNIT_TEST(test_ConwayCell_7);
CPPUNIT_TEST(test_ConwayCell_8);
CPPUNIT_TEST(test_ConwayCell_9);
CPPUNIT_TEST(test_FredkinCell_1);
CPPUNIT_TEST(test_FredkinCell_2);
CPPUNIT_TEST(test_FredkinCell_3);
CPPUNIT_TEST(test_FredkinCell_4);
CPPUNIT_TEST(test_FredkinCell_5);
CPPUNIT_TEST(test_FredkinCell_6);
CPPUNIT_TEST(test_FredkinCell_7);
CPPUNIT_TEST(test_FredkinCell_8);
CPPUNIT_TEST(test_FredkinCell_9);
CPPUNIT_TEST(test_Cell_1);
CPPUNIT_TEST(test_Cell_2);
CPPUNIT_TEST(test_Cell_3);
CPPUNIT_TEST(test_Cell_4);
CPPUNIT_TEST(test_Cell_5);
CPPUNIT_TEST(test_Cell_6);
CPPUNIT_TEST(test_Cell_7);
CPPUNIT_TEST(test_Cell_8);
CPPUNIT_TEST(test_Cell_9);
CPPUNIT_TEST(test_Cell_10);
CPPUNIT_TEST(test_Cell_11);
CPPUNIT_TEST(test_Cell_12);
CPPUNIT_TEST(test_Cell_13);
CPPUNIT_TEST(test_Cell_14);
CPPUNIT_TEST(test_Cell_15);
CPPUNIT_TEST(test_Cell_16);
CPPUNIT_TEST(test_Cell_17);
CPPUNIT_TEST(test_Cell_18);
CPPUNIT_TEST(test_Cell_19);
CPPUNIT_TEST(test_Life_1);
CPPUNIT_TEST(test_Life_2);
CPPUNIT_TEST(test_Life_3);
CPPUNIT_TEST(test_Life_4);
CPPUNIT_TEST(test_Life_5);
CPPUNIT_TEST(test_Life_6);
CPPUNIT_TEST(test_Life_7);
CPPUNIT_TEST(test_Life_8);
CPPUNIT_TEST(test_Life_9);
CPPUNIT_TEST(test_Life_10);
CPPUNIT_TEST(test_Life_11);
CPPUNIT_TEST(test_Life_12);
CPPUNIT_TEST(test_Life_13);
CPPUNIT_TEST(test_Life_14);
CPPUNIT_TEST(test_Life_15);
CPPUNIT_TEST(test_Life_16);
CPPUNIT_TEST(test_Life_17);
CPPUNIT_TEST(test_Life_18);
CPPUNIT_TEST_SUITE_END();
};
// ----
// main
// ----
int main () {
using namespace std;
ios_base::sync_with_stdio(false); // turn off synchronization with C I/O
cout << "TestLife.c++" << endl;
CppUnit::TextTestRunner tr;
tr.addTest(TestLife::suite());
tr.run();
cout << "Done." << endl;
return 0;} | |
11a6b557af06b4c6a3f9f0bdc1eb76a4378ebbc4 | c98bffce9b9201b8c7b0f0a7bde3ea0171bb3efa | /课程/基础算法/分治/取余运算.cpp | 710f9c6ab7d859000150ec4bb6fc7e388bc64e7d | [] | no_license | iOranges/KoalaWY | 4edc87eaeb9d5f54a96f3689a3cb7d3c63a5ebc9 | b99383d5484ed3e61ed935b0ff47971e3a448e2b | refs/heads/master | 2020-12-14T09:40:51.195501 | 2020-01-18T08:20:59 | 2020-01-18T08:20:59 | 234,699,509 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 310 | cpp | 取余运算.cpp | #include<iostream>
using namespace std;
long long b,p,k;
long long f(int i)
{
if(i == 0) return 1;
int b2 = f(i/2) % k;
b2 = (b2*b2) % k;
if(i%2 == 1) b2 = (b2 * b) % k;
return b2;
}
int main()
{
cin >> b >> p >> k;
int b2=b;
b%=k;
cout << b2 << "^" << p << " mod " << k << "=" << f(p);
return 0;
}
|
1f37cec03fb344b18dd7cd929eb4f877187bf7e4 | 5ff0d8043518bb312a38403617c7eb70ebecf1b8 | /C++/World.cpp | 965eeb4aae6401317fbb3158a9fcd778fbb222ef | [] | no_license | emenychtas/uni-projects | ef39f27826534f260579434690aaecdc519e8191 | d8681044bb04a1ed843b3f854cc5a9f4229b62fc | refs/heads/main | 2023-04-03T00:41:56.171351 | 2021-04-09T07:13:46 | 2021-04-09T07:13:46 | 330,410,099 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,009 | cpp | World.cpp | #include "World.h"
#include <cstdlib>
#include <iostream>
using std::cout;
using std::endl;
extern int baseX, baseY;
World::World(int config[])
{
dimX = config[0];
dimY = config[1];
baseX = config[2];
baseY = config[3];
explorersCount = config[4];
analyzersCount = config[5];
rescuersCount = config[6];
targetPalladium = config[7];
targetIridium = config[8];
targetPlatinum = config[9];
InitializeGrid();
InitializeVehicles();
}
void World::WorkVehicles()
{
for(int i=0; i<vehicles.size(); i++)
{
if(vehicles[i] != NULL && !vehicles[i]->getDamaged())
{
vehicles[i]->V_Work(grid);
}
}
cout << endl;
}
void World::MoveVehicles()
{
for(int i=0; i<vehicles.size(); i++)
{
if(vehicles[i] != NULL)
{
if(!vehicles[i]->getDamaged())
{
vehicles[i]->V_Move(grid);
}
else
{
if(vehicles[i]->getRoundsD() < 10)
{
vehicles[i]->setRoundsD(vehicles[i]->getRoundsD() + 1);
}
else
{
cout << vehicles[i]->getSymbol() << vehicles[i]->getIndex() << ": removed from the simulation" << endl;
grid[vehicles[i]->getPositionX()][vehicles[i]->getPositionY()].setCurVehicle(NULL);
vehicles[i] = NULL;
}
}
}
}
cout << endl;
}
void World::PrintState()
{
cout << " ";
for(int j=0; j<grid[0].size(); j++)
{
j<10 ? (cout << "0" << j) : (cout << j);
cout << " ";
}
cout << endl << endl;
for(int i=0; i<grid.size(); i++)
{
i<10 ? (cout << "0" << i) : (cout << i);
cout << " ";
for(int j=0; j<grid[0].size(); j++)
{
if(i==baseX && j==baseY) { cout << 'X'; }
else if(!grid[i][j].getOccupied()) { cout << '-'; }
else { cout << grid[i][j].getCurVehicle()->getSymbol(); }
cout << " ";
}
cout << endl << endl;
}
}
void World::PrintBaseInfo()
{
cout << "Base Info:" << endl << endl;
cout << "Palladium Resources: " << grid[baseX][baseY].getPalladium() << "/" << targetPalladium << endl;
cout << "Iridium Resources: " << grid[baseX][baseY].getIridium() << "/" << targetIridium << endl;
cout << "Platinum Resources: " << grid[baseX][baseY].getPlatinum() << "/" << targetPlatinum << endl << endl;
}
void World::PrintMapStats()
{
int pallTotal = 0, iridTotal = 0, platTotal = 0;
int accessibleCount = 0;
float diffSum = 0.0;
for(int i=0; i<grid.size(); i++)
{
for(int j=0; j<grid[0].size(); j++)
{
pallTotal += grid[i][j].getPalladium();
iridTotal += grid[i][j].getIridium();
platTotal += grid[i][j].getPlatinum();
if(!grid[i][j].getAvoid())
{
diffSum += grid[i][j].getDifficulty();
accessibleCount++;
}
}
}
pallTotal -= grid[baseX][baseY].getPalladium();
iridTotal -= grid[baseX][baseY].getIridium();
platTotal -= grid[baseX][baseY].getPlatinum();
float meanDiff = diffSum/accessibleCount;
cout << "Mean Difficulty: " << meanDiff << endl;
cout << "Total Palladium: " << pallTotal << endl;
cout << "Total Iridium: " << iridTotal << endl;
cout << "Total Platinum: " << platTotal << endl << endl;
}
void World::PrintBlockInfo(int x, int y)
{
cout << "Block [" << x << "," << y << "] Info:" << endl << endl;
cout << "Palladium Resources: " << grid[x][y].getPalladium() << endl;
cout << "Iridium Resources: " << grid[x][y].getIridium() << endl;
cout << "Platinum Resources: " << grid[x][y].getPlatinum() << endl;
cout << "Difficulty: " << grid[x][y].getDifficulty() << endl;
cout << "Flagged: " << grid[x][y].getAvoid() << endl;
cout << "Occupied by: ";
if(!grid[x][y].getOccupied()) { cout << "N/A" << endl << endl; }
else { cout << grid[x][y].getCurVehicle()->getSymbol() << grid[x][y].getCurVehicle()->getIndex() << endl << endl; }
}
void World::EditBlock(int x, int y, int pa, int ir, int pl)
{
grid[x][y].setPalladium(pa);
grid[x][y].setIridium(ir);
grid[x][y].setPlatinum(pl);
cout << "Block [" << x << "," << y << "] resources edited." << endl << endl;
}
void World::PrintVehicles()
{
cout << "Vehicle Indices: " << endl << endl;
for(int i=0; i<vehicles.size(); i++)
{
if(vehicles[i] != NULL)
{
cout << i << ". " << vehicles[i]->getSymbol() << vehicles[i]->getIndex() << endl;
}
}
cout << endl;
}
void World::PrintVehicleStats()
{
cout << "Total Moves: " << Vehicle::movesTotal << endl;
cout << "Total Breakdowns: " << Vehicle::breakdownsTotal << endl;
cout << "Total Flags Placed: " << Vehicle_Explorer::flagsTotal << endl;
cout << "Total Resources Extracted: " << Vehicle_Analyzer::extractedResTotal << endl;
cout << "Total vehicles Fixed: " << Vehicle_Rescuer::rescuesTotal << endl;
cout << "Currently Damaged vehicles: " << Vehicle::damagedVehicles << endl << endl;
}
void World::PrintVehicleInfo(int i)
{
cout << vehicles[i]->getSymbol() << vehicles[i]->getIndex() << " Info:" << endl << endl;
cout << "Position: " << vehicles[i]->getPositionX() << "," << vehicles[i]->getPositionY() << endl;
cout << "Moves: " << vehicles[i]->getMoves() << endl;
cout << "Breakdowns: " << vehicles[i]->getBreakdowns() << endl;
cout << "Durability: " << vehicles[i]->getDurability() << endl;
cout << "Damaged: " << vehicles[i]->getDamaged() << endl;
cout << "Rounds Damaged: " << vehicles[i]->getRoundsD() << endl;
if(vehicles[i]->getSymbol() == 'E')
{
cout << "Flags Placed: " << ((Vehicle_Explorer*)vehicles[i])->getFlags() << endl;
}
else if(vehicles[i]->getSymbol() == 'A')
{
cout << "Resources Extracted: " << ((Vehicle_Analyzer*)vehicles[i])->getExtractedRes() << endl;
cout << "Palladium Load: " << ((Vehicle_Analyzer*)vehicles[i])->getPalladium() << endl;
cout << "Iridium Load: " << ((Vehicle_Analyzer*)vehicles[i])->getIridium() << endl;
cout << "Platinum Load: " << ((Vehicle_Analyzer*)vehicles[i])->getPlatinum() << endl;
}
else if(vehicles[i]->getSymbol() == 'R')
{
cout << "vehicles Fixed: " << ((Vehicle_Rescuer*)vehicles[i])->getRescues() << endl;
}
cout << endl;
}
void World::ToggleVehicleStatus(int i)
{
if(vehicles[i]->getDamaged())
{
vehicles[i]->setDamaged(false);
Vehicle::damagedVehicles--;
}
else
{
vehicles[i]->setDamaged(true);
Vehicle::damagedVehicles++;
}
cout << vehicles[i]->getSymbol() << vehicles[i]->getIndex() << " status toggled." << endl << endl;
}
void World::AddNewVehicle(int x, int y, char type)
{
if(grid[x][y].getOccupied())
{
cout << "The specified block is currently occupied." << endl << endl;
}
else
{
Vehicle* newVehicle = NULL;
if(type == 'E' || type == 'e')
{
newVehicle = new Vehicle_Explorer(x, y, explorersCount);
explorersCount++;
}
else if(type == 'A' || type == 'a')
{
newVehicle = new Vehicle_Analyzer(x, y, analyzersCount);
analyzersCount++;
}
else if(type == 'R' || type == 'r')
{
newVehicle = new Vehicle_Rescuer(x, y, rescuersCount);
rescuersCount++;
}
if(newVehicle != NULL)
{
grid[x][y].setCurVehicle(newVehicle);
vehicles.push_back(newVehicle);
cout << "New vehicle added at block [" << x << "," << y << "]." << endl << endl;
}
else
{
cout << "Invalid vehicle type." << endl << endl;
}
}
}
int World::GameState()
{
int state = 0;
if(grid[baseX][baseY].getPalladium() >= targetPalladium)
{
if(grid[baseX][baseY].getIridium() >= targetIridium)
{
if(grid[baseX][baseY].getPlatinum() >= targetPlatinum)
{
state = 1;
}
}
}
if(state == 0 && Vehicle::damagedVehicles >= vehicles.size())
{
state = -1;
}
return state;
}
void World::InitializeGrid()
{
for(int i=0; i<dimX; i++)
{
vector<Block> Row;
for(int j=0; j<dimY; j++)
{
Row.push_back(Block());
}
grid.push_back(Row);
}
grid[baseX][baseY].setPalladium(0);
grid[baseX][baseY].setIridium(0);
grid[baseX][baseY].setPlatinum(0);
grid[baseX][baseY].setDifficulty(0.0);
grid[baseX][baseY].setAvoid(true);
grid[baseX][baseY].setCurVehicle(NULL);
}
void World::InitializeVehicles()
{
for(int i=0; i<(explorersCount + analyzersCount + rescuersCount); i++)
{
int tempX, tempY;
do{
tempX = rand() % dimX;
tempY = rand() % dimY;
}while((tempX==baseX && tempY==baseY) || grid[tempX][tempY].getOccupied());
Vehicle* newVehicle;
if(i < explorersCount)
{
newVehicle = new Vehicle_Explorer(tempX, tempY, i);
}
else if(i < (explorersCount + analyzersCount))
{
newVehicle = new Vehicle_Analyzer(tempX, tempY, i-explorersCount);
}
else
{
newVehicle = new Vehicle_Rescuer(tempX, tempY, i-explorersCount-analyzersCount);
}
grid[tempX][tempY].setCurVehicle(newVehicle);
vehicles.push_back(newVehicle);
}
} |
a0c035151a437539000fc571108e13a659732901 | 2bff77479b167f287c9d526af8b5de93580b9567 | /Src/ARcBridgeInput/InputRebarGagak.cpp | 6553b7b9df443a45ec9f81ad7fa87504b5e84f0b | [] | no_license | SamuelBacaner1112/ARcBridge | 84dd7291ebca4928ebbf5564ce4a7163a77fd621 | 370aea531455f6eb927d68c16a7c4f6ce969b727 | refs/heads/master | 2023-01-30T03:54:50.231730 | 2020-12-09T00:32:54 | 2020-12-09T00:32:54 | 319,797,260 | 0 | 1 | null | null | null | null | UHC | C++ | false | false | 10,841 | cpp | InputRebarGagak.cpp | // InputRebarGagak.cpp : implementation file
//
#include "stdafx.h"
#include "arcbridgeinput.h"
#include "../ARcBridgeDBDraw/ARcBridgeDBDraw.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CInputRebarGagak dialog
CInputRebarGagak::CInputRebarGagak(CWnd* pParent /*=NULL*/)
: CInputDialogBase(CInputRebarGagak::IDD, pParent)
{
//{{AFX_DATA_INIT(CInputRebarGagak)
m_nTab = 0;
m_nCross = -1;
//}}AFX_DATA_INIT
}
void CInputRebarGagak::DoDataExchange(CDataExchange* pDX)
{
CInputDialogBase::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CInputRebarGagak)
DDX_Control(pDX, IDC_COMBO_BRIDGE_NO, m_comboBridgeNo);
DDX_Control(pDX, IDC_COMBO_CTC, m_comboCTC);
DDX_Control(pDX, IDC_BUTTON_EXAMINE, m_btnExamine);
DDX_GridControl(pDX, IDC_GRID, m_Grid);
DDX_Control(pDX, IDC_TAB, m_Tab);
DDX_Radio(pDX, IDC_RADIO_CROSS, m_nCross);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CInputRebarGagak, CInputDialogBase)
//{{AFX_MSG_MAP(CInputRebarGagak)
ON_CBN_SELCHANGE(IDC_COMBO_BRIDGE_NO, OnSelchangeComboBridgeNo)
ON_BN_CLICKED(IDC_RADIO_CROSS, OnRadioCross)
ON_BN_CLICKED(IDC_RADIO_PLANE, OnRadioPlane)
//}}AFX_MSG_MAP
ON_NOTIFY(GVN_CELL_CHANGED_DATA, IDC_GRID, OnCellChangedData)
ON_NOTIFY(GVN_CELL_CHANGED_ROW, IDC_GRID, OnCellChangedRow)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInputRebarGagak message handlers
BOOL CInputRebarGagak::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
return CInputDialogBase::PreTranslateMessage(pMsg);
}
void CInputRebarGagak::SetDataSave()
{
m_Grid.UpdateData(TRUE);
m_pIn->m_pDoc->SetModifiedFlag();
}
void CInputRebarGagak::SetDataInit()
{
CRcBridgeRebar *pBri = m_pIn->GetRcBridgeRebar();
m_Grid.UpdateData(FALSE);
CHgBaseConcStd baseConc;
m_comboCTC.SetCurSel(baseConc.GetIdxByRebarCTC(pBri->m_dCTC_MainRebar));
}
void CInputRebarGagak::SetGridData()
{
// 그리드 초기화
m_Grid.SetGridDefault(2, 2, 1, 1);
CRcBridgeRebar *pBri = m_pIn->GetRcBridgeRebar();
if(!pBri) return;
UINT nFormat = DT_CENTER | DT_VCENTER;
UINT nLine = CELL_LINE_NO;
CStringArray sArr, sArrType;
CString str = _T("");
sArr.RemoveAll();
sArr.Add("주철근 기준 배치");
sArr.Add("배력철근 기준 배치");
sArrType.RemoveAll();
sArrType.Add("직선 철근");
sArrType.Add("곡선 철근");
long row(0), col(0);
m_Grid.AddCell(row, col, "위치");
m_Grid.AddCell(row, col+1, "가각부 주철근 배치 기준");
m_Grid.AddCell(row, col+2, "철근 연장 거리");
m_Grid.AddCell(row, col+3, "철근타입");
m_Grid.AddCell(row, col+4, "선형방향배치");
m_Grid.AddCell(row, col+5, "보강철근개수");
row++;
for(long stt = 0; stt < 2; stt++)
{
BOOL bStt = stt == iSTT;
for(long left = 0; left < 2; left++)
{
BOOL bLeft = left == iLEFT;
BOOL bReadOnly = pBri->m_nTypeRebarMainRebarOfExp[stt][left] == 1;
str.Format("%s %s(%s%s)", stt==iSTT ? "시점" : "종점", left==iLEFT ? "좌측" : "우측", bStt ? "S" : "E", bLeft ? "L" : "R");
m_Grid.AddCell(row, col, str);
m_Grid.AddCell(row, col+1, &pBri->m_nTypeOrgMainRebarOfExp[stt][left], nFormat, TRUE, bReadOnly ? CELL_READONLY : nLine, "", CELL_TYPE_COMBO, sArr);
m_Grid.AddCell(row, col+2, &pBri->m_dLenMainRebarOfExp[stt][left]);
m_Grid.AddCell(row, col+3, &pBri->m_nTypeRebarMainRebarOfExp[stt][left], nFormat, TRUE, nLine, "", CELL_TYPE_COMBO, sArrType);
m_Grid.AddCell(row, col+4, &pBri->m_bLineDirRebarOfExp[stt][left], nFormat, nLine, "", CELL_TYPE_CHECK);
m_Grid.AddCell(row, col+5, &pBri->m_nCountSupportRebarOfExpAtLineDirRebar[stt][left], nFormat, FALSE, pBri->m_bLineDirRebarOfExp[stt][left] ? nLine : CELL_READONLY, "");
row++;
}
}
long nRows(0), nCols(0);
m_Grid.GetCellCount(nRows, nCols);
m_Grid.SetRows(nRows);
m_Grid.SetCols(nCols);
m_Grid.SetColumnWidth(0, 100);
m_Grid.SetColumnWidth(1, 300);
m_Grid.SetColumnWidth(2, 150);
m_Grid.SetColumnWidth(3, 100);
}
void CInputRebarGagak::DrawInputDomyunView(BOOL bZoomAll)
{
CRcBridgeRebar *pBri = m_pIn->GetRcBridgeRebar();
CDomyun *pDom = m_pView->GetDomyun();
pDom->ClearEtt(TRUE, FALSE);
pDom->SetScaleDim(m_pIn->GetScaleInputDialog());
CARcBridgeDBStandard DBStd(m_pIn->GetRcBridgeRebar(), m_pIn->m_pARoadOptionStd, m_pIn->m_pARcBridgeDataStd);
BOOL bStt = IsStt();
BOOL bLeft = IsLeft();
BOOL bCross = m_nCross == 0;
CDomyun Dom(pDom);
CHgBaseDrawStd baseDraw;
if(bCross)
{
BOOL bInner = pBri->m_nTypeWallForRebarGen == 1;
DBStd.m_pDrawCrossSection->DrawCrossAllAtJijum(&Dom, bStt ? 0 : pBri->m_nQtyJigan, TRUE, FALSE, TRUE, FALSE);
if(bStt)
{
double dMid = pBri->GetMidCrossSection(FALSE);
Dom.Mirror(dMid, TRUE);
}
CTwinVectorArray tvArrRebarMainSide;
DBStd.m_pDrawCrossSection->DrawCrossSection_OutWall_Exp(&Dom, bStt, bInner, bInner, !bStt);
DBStd.m_pDrawCrossSection->DrawRebarMain_CrossSection_OutWallExp(&Dom, bStt, 0, bInner, bInner, 0, TRUE, TRUE, !bStt, tvArrRebarMainSide);
//DBStd.m_pDrawCrossSection->DrawRebarMain_CrossSection_OutWallExp(&Dom, bStt, FALSE, bInner, 0, TRUE, TRUE, !bStt);
}
else
{
DBStd.m_pDrawPlane->DrawPlaneGen(&Dom, 5000, TRUE, FALSE, TRUE, FALSE, FALSE);
CTwinVectorArray tvArrRebarOut;
pBri->GetTvRebarOut_Plane_UpperSlabStd(tvArrRebarOut, 0, TRUE);
m_pIn->m_pARoadOptionStd->SetEnvType(&Dom, HCAD_BARC);
baseDraw.DrawTvArray(&Dom, tvArrRebarOut);
DBStd.m_pDrawPlane->DrawRebarMain_Plane_Slab_Exp(&Dom, TRUE, TRUE, 0, FALSE, FALSE, -1, TRUE);
DBStd.m_pDrawPlane->DrawRebarMain_Plane_Slab_Exp(&Dom, TRUE, TRUE, 0, FALSE, FALSE, 1, TRUE);
// 철근 배치 기준선
DBStd.m_pDrawPlane->DrawMainRebarOrgLineOfExp(&Dom, bStt, bLeft);
#ifdef _DEBUG
//DBStd.RotateDomByBridgeSttEndXy(&Dom);
#else
DBStd.RotateDomByBridgeSttEndXy(&Dom);
#endif
}
*pDom << Dom;
CInputDialogBase::DrawInputDomyunView(bZoomAll);
}
void CInputRebarGagak::OnPreInitDialog()
{
// 시작하면서 pick box의 크기를 정해줌
if(m_pView)
{
CTwinVector tv;
tv.SetPickBoxSize(m_pView->GetSelectionRectSize()/m_pView->GetRatioWindow());
}
InitTabCtrl();
InitComboCtrl();
SetResize(IDC_BUTTON_EXAMINE, SZ_BOTTOM_LEFT, SZ_BOTTOM_LEFT);
SetResize(IDC_TAB, SZ_TOP_LEFT, SZ_BOTTOM_RIGHT);
SetResize(IDC_GRID, SZ_TOP_LEFT, SZ_BOTTOM_RIGHT);
SetResize(IDC_RADIO_CROSS, SZ_TOP_RIGHT, SZ_TOP_RIGHT);
SetResize(IDC_RADIO_PLANE, SZ_TOP_RIGHT, SZ_TOP_RIGHT);
SetResize(IDC_STATIC_VIEW, SZ_TOP_RIGHT, SZ_TOP_RIGHT);
SetHyperHelp(m_pIn->GetManualPath());
m_Grid.InitGrid(m_pIn->m_pARcBridgeDataStd->m_Fy);
SetGridData();
SetDataInit();
}
BOOL CInputRebarGagak::OnInitDialog()
{
CInputDialogBase::OnInitDialog();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CInputRebarGagak::InitTabCtrl()
{
m_Tab.RemoveAllTabs();
m_Tab.SendInitialUpdate(TRUE);
// Clip children of the tab control from paint routines to reduce flicker.
m_Tab.ModifyStyle(0L, WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
// 사이클 탭
CStringArray sArrTabName;
long nTab = 0;
sArrTabName.Add("가각부 주철근"); m_nTab = nTab++;
long i = 0; for(i = 0; i < sArrTabName.GetSize(); i++)
m_Tab.InsertItem(i, sArrTabName[i]);
m_Tab.SetCurSel(m_nTab);
}
void CInputRebarGagak::InitComboCtrl()
{
CARcBridgeDataStd* pStd = m_pIn->m_pARcBridgeDataStd;
CString str = _T("");
// 교량
long nSize = pStd->GetBridgeSize();
long i = 0; for(i = 0; i < nSize; i++)
{
CRcBridgeApp* pBri = pStd->GetBridge(i);
str = pStd->GetStringBridgeOrder(i) + _T(" : ") + pBri->m_strBridgeName
+ _T(" [") + pBri->GetStringBridgeType() + _T("]");
m_comboBridgeNo.AddString(str);
}
m_comboBridgeNo.SetCurSel(m_pIn->m_nCurrentBridge);
// CTC
for(long ctc = 0; ctc < MAX_REBAR_CTC; ctc++)
{
CHgBaseConcStd baseConcStd;
str.Format("CTC %.0f", baseConcStd.GetValueRebarCTC(ctc));
m_comboCTC.AddString(str);
}
SetControl();
}
void CInputRebarGagak::OnSelchangeComboBridgeNo()
{
// TODO: Add your control notification handler code here
SetDataSave();
m_pIn->m_nCurrentBridge = m_comboBridgeNo.GetCurSel();
InitTabCtrl();
SetControl();
SetGridData();
SetDataInit();
SetPaneTitle();
DrawInputDomyunView(TRUE);
m_comboBridgeNo.SetFocus();
}
void CInputRebarGagak::SetControl()
{
CRcBridgeRebar *pBri = m_pIn->GetRcBridgeRebar();
if(!pBri) return;
m_nCross = 1;
m_comboCTC.EnableWindow(FALSE);
UpdateData(FALSE);
}
void CInputRebarGagak::SetDataDefault()
{
for(long bri = 0; bri < m_pIn->m_pARcBridgeDataStd->GetBridgeSize(); bri++)
{
CRcBridgeRebar *pBri = m_pIn->m_pARcBridgeDataStd->GetBridgeRebar(bri);
if(!pBri) continue;
BOOL bFirst = IsFirst(bri);
pBri->SetDefaultedState(GetIDD(), 0x00000001);
if(!bFirst && !IsClickDefaultButton(bri)) continue;
for(long stt = 0; stt < 2; stt++)
{
for(long left = 0; left < 2; left++)
{
pBri->m_nTypeOrgMainRebarOfExp[stt][left] = 1;
pBri->m_dLenMainRebarOfExp[stt][left] = pBri->GetExtMainRebarLimitGagak(stt==iSTT, left ==iLEFT); // 1500;
pBri->m_bLineDirRebarOfExp[stt][left] = FALSE;
pBri->m_nCountSupportRebarOfExpAtLineDirRebar[stt][left] = 1;
}
}
}
DrawInputDomyunView(FALSE);
}
BOOL CInputRebarGagak::IsStt()
{
long nRow = m_Grid.GetFocusCell().row;
if(nRow == 1 || nRow == 2) return TRUE;
return FALSE;
}
BOOL CInputRebarGagak::IsLeft()
{
long nRow = m_Grid.GetFocusCell().row;
if(nRow == 1 || nRow == 3) return TRUE;
return FALSE;
}
void CInputRebarGagak::OnCellChangedRow(NMHDR* pNotifyStruct, LRESULT* result)
{
DrawInputDomyunView(FALSE);
CString str = _T("");
str.Format("%s%s", IsStt() ? "S" : "E", IsLeft() ? "L" : "R");
m_pView->GetDomyun()->STMakeCursor(str);
}
void CInputRebarGagak::OnCellChangedData(NMHDR* pNotifyStruct, LRESULT* result)
{
CInputDialogBase::OnCellChangedData(pNotifyStruct, result);
SetGridData();
SetDataInit();
}
void CInputRebarGagak::OnRadioCross()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
DrawInputDomyunView(FALSE);
}
void CInputRebarGagak::OnRadioPlane()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
DrawInputDomyunView(FALSE);
}
BOOL CInputRebarGagak::IsValid()
{
BOOL bIsExp = FALSE;
if(!m_pIn) return FALSE;
if(!m_pIn->m_pARcBridgeDataStd) return FALSE;
long nCountBri = m_pIn->m_pARcBridgeDataStd->GetBridgeSize();
for(long bri = 0; bri < nCountBri; bri++)
{
CRcBridgeRebar *pBri = m_pIn->m_pARcBridgeDataStd->GetBridgeRebar(bri);
if(pBri)
{
if(pBri->m_bIsExp)
{
bIsExp = TRUE;
break;
}
}
}
return bIsExp;
}
|
df1ceba6098c4aa8321c41b1288b0cbda1e824c6 | 67ba5b98e9d251da597e7cb818f181d899aba737 | /varsity/algo viva 5th sem final/1 floyed warshall.cpp | 86adc9230c74326c4420a252f70eb66bd9a73a45 | [] | no_license | amsaabesh/Laptop | 3d0a18a64b9760789e495321662a04ee7d37c6a3 | 991a220cbf53870f585509a574f5a13ae2c007d1 | refs/heads/main | 2023-03-10T10:09:10.651193 | 2021-02-11T07:41:09 | 2021-02-11T07:41:09 | 337,957,338 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,485 | cpp | 1 floyed warshall.cpp | #include<bits/stdc++.h>
using namespace std;
#define N 4
#define M INT_MAX
void path_howing(int durotto[][N], int v, int u)
{
if (durotto[v][u] == v)
return;
path_howing(durotto, v, durotto[v][u]);
cout << durotto[v][u] << " ";
}
void shortpath(int khoroch[N][N], int durotto[N][N])
{
for (int v = 0; v < N; v++)
{
for (int u = 0; u < N; u++)
{
if (u != v && durotto[v][u] != -1)
{
cout << "shobcheye choto" << v << " -> " << u << " is ("
<< v << " ";
path_howing(durotto, v, u);
cout << u << ")" << endl;
}
}
}
}
void all_path_shortest(int adjMatrix[][N])
{
int khoroch[N][N],durotto[N][N];
for (int v = 0; v < N; v++)
{
for (int u = 0; u < N; u++)
{
khoroch[v][u] = adjMatrix[v][u];
if (v == u)
durotto[v][u] = 0;
else if (khoroch[v][u] != INT_MAX)
durotto[v][u] = v;
else
durotto[v][u] = -1;
}
}
for (int k = 0; k < N; k++)
{
for (int v = 0; v < N; v++)
{
for (int u = 0; u < N; u++)
{
if (khoroch[v][k] != INT_MAX && khoroch[k][u] != INT_MAX
&& khoroch[v][k] + khoroch[k][u] < khoroch[v][u])
{
khoroch[v][u] = khoroch[v][k] + khoroch[k][u];
durotto[v][u] = durotto[k][u];
}
}
if (khoroch[v][v] < 0)
{
cout << "Eta negative, tai possible na";
return;
}
}
}
shortpath(khoroch, durotto);
}
int main()
{
int SA235[N][N] =
{
{ 0, M, -2, M },
{ 4, 0, 3, M },
{ M, M, 0, 2 },
{ M, -1, M, 0 }
};
all_path_shortest(SA235);
return 0;
}
|
a210e30ade866e637c1b6a780f38af8549011ee3 | 22f8ce70cc780eda7cb11f93803058831f43c7c5 | /Source/SomeTest/UseConfig/UseConfigObject.cpp | 3f424a45e65ed546252d1c0a8000c2a69e2e58c7 | [] | no_license | VegetableWithChicken/SomeTest | 4d26ebc44fbf8a387bec2ec9677d51485c7c9668 | 8659f9b99ec05f3e235ec9d7839671751c85cbf8 | refs/heads/dev | 2023-03-16T05:40:16.603350 | 2020-11-02T07:04:52 | 2020-11-02T07:04:52 | 508,117,547 | 1 | 0 | null | 2022-06-28T01:42:35 | 2022-06-28T01:42:34 | null | UTF-8 | C++ | false | false | 514 | cpp | UseConfigObject.cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "UseConfigObject.h"
UUseConfigObject::UUseConfigObject()
{
//if (!GConfig) return;
//FString ValueReceived;
//GConfig->GetString(
// TEXT("/Script/Engine.WorldInfo"),
// TEXT("GlobalDefaultGameType"),
// ValueReceived,
// GGameIni
//);
//if (!GConfig) return;
//GConfig->SetInt(
// TEXT("sectionname"),
// TEXT("key"),
// 100,
// GGameUserSettingsIni
//);
//GConfig->Flush(false, GGameUserSettingsIni);
}
|
a65789b12a41220dd5a82c07666f5130b62dcb66 | 32e4e3d77b1a5a309f8f721c61d4012429c2916a | /src/vidScheduler.cpp | db0c6ae9ce1783ba761fb1d3340f4b4b85f7cc44 | [] | no_license | tianxiejack/lib_crencOver422uart_040 | ea8b72cdede047dfe35072bc5be68626b306a1fa | 9f3e7ee95ca2a3c18d9408990f47efc3806f52b2 | refs/heads/master | 2020-04-12T15:24:43.212195 | 2018-12-17T11:47:15 | 2018-12-17T11:47:15 | 162,580,045 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,796 | cpp | vidScheduler.cpp | /**************************************************************************************************
* Copyright (C), 2011-2012, ChamRun Tech. Co., Ltd.
* WorkContext:
* FileName: snd_scheduler.c
* Author: wzk Version : Date:2015年9月7日
* Description: // 对2M/4M/8M H.264的码流做发送调度。
* // 1. H.264码流在编码的时候有一个周期为11帧的16ms抖动
* // 2. 422 2M 串口一个周期33ms 只能发送8.34K,需要让带宽利用率更高,
* // 通过调度可以使数据发送更均匀
* // 调度策略
* 1. 根据发送数据长度计算传输时间,每一短数据帧发送延迟时间t
* t = (两帧之间能发送字节数 - 当前等待发送字节) * 帧间隔时间 / 两帧之间能发送字节数
* 以30fps为例
* t = (8.34k - frameLen) * 33ms / 8.34k
* 2. 视频数据每次到达不直接启动数据发送,只负责放入发送队列
* 起一个以视频周期为单位的定时器,当定时器到达,查看缓存数据,启动发送,可去除编码抖动
*
* //注意:策略2 增加了一帧的延迟, 遇到大数据对应用程序无影响,会在驱动中积攒
* :不支持多个通道
* Version: // 版本信息
* History: // 历史修改记录
* <author> <time> <version > <description>
* wzk 2015年9月7日 V1.00 build this module
***************************************************************************************************/
#include <unistd.h>
#include <assert.h>
#include <osa.h>
#include <osa_tsk.h>
#include <vidScheduler.h>
#include <math.h>
#define MAX_FRAMES 9
#define FRAME_BUFLEN 0x040000 // 256KB
typedef struct
{
unsigned int tm_input;
unsigned int tm_output;
unsigned int tm_schedBegin;
unsigned int tm_schedEnd;
unsigned int tm_cap;
unsigned int tm_wait; //422发送调度等待时间
unsigned char *data; //数据指针
unsigned int lengh; //数据长度
}Sched_Frame;
typedef struct
{
int index;
int rdIndx;
int wrIndx;
int framewait;
OSA_SemHndl sem;
OSA_MutexHndl muxLock;
OSA_ThrHndl thread;
int taskLoop;
int thrd;
Sched_Frame frames[MAX_FRAMES];
int sendTime_isBuild;
unsigned int sendTime_sndBase;
unsigned int sendTime_capBase;
// FILE *cbFd;
// size_t (*write_cb)(const void *, size_t, size_t, FILE* );
long cbFd;
int (*write_cb)(long fd, unsigned char *buf, int len);
}
Sched_Chn;
//打开DM8168编码抖动去除,使能定时器驱动发送,不使用视频码流驱动发送
//#define SCHEDER_H264_ENC
#define TIME_DIFF(t0,t1) \
(( t1 - t0) > 0 )?(t1 - t0) : 0
//extern void memcpy_neon( void *, const void *, size_t );
#define CHAN_COUNT 2
static Sched_Chn schedChannel[CHAN_COUNT];
static int bInit = 0;
//static int last_snd_ts[2]={0,0};
//static int ch_snd_td[2]={33,33};
//static unsigned int g_cap_tm[2] = {0,0};
static OSA_ThrHndl thread_tm;
static int taskLoop_tm = 0;
static int g_chan_cout = 2;
static void* SchedTask(void *pPrm);
static void * SchedTimeTask(void *pPrm);
static unsigned int Sched_get_wait_time(Sched_Chn * sched, unsigned int capTs,unsigned int delayTs, unsigned int *pBegin, unsigned int *pEnd);
/*
* @Function: // Sched_h265_Init
* @Description: // 分配视频帧队列,启动调度发送任务
* @Return: // 成功失败
* @Others: // 队列为8帧,cache 帧为1帧
* @Others: // 外部接口函数
*/
int Sched_h26x_Init()
{
int i = 0, j=0;
int status;
Sched_Chn *pCh=NULL;
if(bInit)
return 0;
/* 分配缓存*/
memset(schedChannel, 0, sizeof(schedChannel));
for( j = 0;j < CHAN_COUNT; j++)
{
pCh = &schedChannel[j];
pCh->index = j;
for( i = 0; i < MAX_FRAMES; i++)
{
pCh->frames[i].data =(unsigned char*)malloc(FRAME_BUFLEN);
OSA_assert(pCh->frames[i].data!=NULL);
pCh->frames[i].lengh = 0;
}
pCh->framewait = 1000000/30; // default is 30fps
/* 创建同步信号量*/
status = OSA_semCreate(&pCh->sem , 1, 0);
OSA_assert(status == OSA_SOK);
/* 创建互斥锁*/
status = OSA_mutexCreate(&pCh->muxLock);
OSA_assert(status == OSA_SOK);
/* 创建调度发送任务*/
status = OSA_thrCreate(
&pCh->thread,
SchedTask,
OSA_THR_PRI_DEFAULT,
0,
pCh
);
OSA_assert(status==OSA_SOK);
}
/* 创建调度发送任务*/
taskLoop_tm = 0;
status = OSA_thrCreate(
&thread_tm,
SchedTimeTask,
OSA_THR_PRI_DEFAULT,
0,
NULL
);
OSA_assert(status==OSA_SOK);
bInit = 1;
return OSA_SOK;
}
/*
* @Function: // Sched_h265_unInit
* @Description: // 释放视频帧队列,注销调度发送任务
* @Others: // 外部接口函数
*/
int Sched_h26x_unInit()
{
int i = 0, j=0;
Sched_Chn *pCh=NULL;
if(!bInit)
return OSA_SOK;
taskLoop_tm = 1;
OSA_waitMsecs(100);
OSA_thrDelete(&thread_tm);
for( j = 0;j < CHAN_COUNT; j++)
{
pCh = &schedChannel[j];
pCh->taskLoop = 1;
OSA_semSignal(&pCh->sem);
OSA_waitMsecs(10);
OSA_thrDelete(&pCh->thread);
for(i = 0; i < MAX_FRAMES; i++)
{
free(pCh->frames[i].data);
}
OSA_mutexDelete(&pCh->muxLock);
OSA_semDelete(&pCh->sem);
}
bInit = 0;
return OSA_SOK;
}
/*
* @Function: // Sched_frame_output
* @Description: // 从缓存队列取出一帧,往外发送
* @Input: // Sched_Chn* sched 调度器句柄
* @Output: // 对输出参数的说明。
* @Return: // 发送数据长度
* @Others: // 内部函数
*/
static int Sched_frame_output(Sched_Chn* sched, int flag)
{
int iRet = 0;
int rd;
struct timeval timeout;
timeout.tv_sec = 0;
//int delay_tm = 17, currFrames;
OSA_mutexLock(&sched->muxLock);
rd = sched->rdIndx ;
/*有缓存数据启动发送*/
if(sched->wrIndx != sched->rdIndx )
{
int thrd = sched->thrd;
int tmp = 0;
int len = sched->frames[rd].lengh;
/* 计算422串口发送调度时间*/
if(len < thrd)
{
// formula_aloysa 1000*1000/30
tmp = (thrd - len) * sched->framewait / g_chan_cout / thrd;
tmp = (tmp > 0) ?tmp : 0;
sched->frames[rd].tm_wait = tmp;
}
else
{
//printf("len:%d Bytes, sync422:%d per %dms, send immediately\n", len , thrd, 1000/sched->framewait);
}
/*
OSA_printf("chid %d cur tm %05d wait %05d len %05d",
sched->index, OSA_getCurTimeInMsec(),sched->frames[rd].tm_wait,len);
*/
/*422发送调度延迟*/
if(sched->frames[rd].tm_wait!=0)
{
//OSA_waitMsecs(sched->frames[rd].tm_wait);
OSA_mutexUnlock(&sched->muxLock);
if (flag)
{
timeout.tv_usec = sched->frames[rd].tm_wait;
select(0,NULL,NULL,NULL,&timeout);
}
OSA_mutexLock(&sched->muxLock);
}
if(sched->write_cb!=NULL && sched->wrIndx != sched->rdIndx)
{
iRet = sched->write_cb(sched->cbFd,sched->frames[rd].data,sched->frames[rd].lengh);
}
rd = (rd+ 1)%MAX_FRAMES;
sched->rdIndx = rd;
}
OSA_mutexUnlock(&sched->muxLock);
return iRet;
}
/*
* @Function: // Sched_frame_input
* @Description: // 外部向调度器缓存队列存入一帧,立即返回
* @Input: // Sched_Chn* sched 调度器句柄
* // void * data 数据指针
* // int len 需要写入的数据长度
* @Output: // 对输出参数的说明。
* @Return: // 写入数据长度
* @Assumptions: // 不会有任何一帧数据超过256K
* @Others: // 内部函数
*/
static int Sched_frame_input(Sched_Chn* sched,void * data,int len,unsigned int ts)
{
int i = 0;
int wr = sched->wrIndx;
memcpy(sched->frames[wr].data, data, len);
sched->frames[wr].lengh = len;
sched->frames[wr].tm_input = OSA_getCurTimeInMsec();
sched->frames[wr].tm_cap = ts;
sched->frames[wr].tm_wait = 0;
OSA_mutexLock(&sched->muxLock);
wr = (wr + 1)%MAX_FRAMES;
sched->wrIndx = wr;
/* 调度器缓存满直接发送 */
if(sched->wrIndx == sched->rdIndx)
{
OSA_mutexUnlock(&sched->muxLock);
for(i = 0; i < MAX_FRAMES-1; i++)
{
Sched_frame_output(sched, 0);
}
OSA_printf("chId %d Sched_frame_input overflow!!!",sched->index);
}
else
{
OSA_mutexUnlock(&sched->muxLock);
}
#ifndef SCHEDER_H264_ENC
//OSA_semSignal(&sched->sem);
#endif
return len;
}
static void * SchedTimeTask(void *pPrm)
{
int pp = 0;
struct timeval timeout;
timeout.tv_sec = 0;
while(!taskLoop_tm)
{
if(taskLoop_tm)
break;
//timeout.tv_usec = (schedChannel[0].framewait-100) / g_chan_cout;
timeout.tv_usec = (33333-100) / 2;
select(0,NULL,NULL,NULL,&timeout);
OSA_semSignal(&schedChannel[pp].sem);
// pp^=1;
pp = (pp + 1)%CHAN_COUNT;
}
return NULL;
}
/*
* @Function: // SchedTask
* @Description: // 调度器发送任务
* @Input: // void *pPrm 调度器句柄
* @Output: // 无
* @Return: // 无
* @Others: // 内部函数
*/
static void* SchedTask(void *pPrm)
{
int iRet = 0;
unsigned int tmp = 0;
int rd = 0;
int last_ts = 0;
int curr_ts = 0;
int isDelay = 0;
Sched_Chn * sched = (Sched_Chn*)pPrm;
struct timeval timeout;
timeout.tv_sec = 0;
printf(" [DEBUG:] %s task entry !!! \r\n",__func__);
last_ts = OSA_getCurTimeInMsec();
while(!sched->taskLoop)
{
tmp = OSA_getCurTimeInMsec();
tmp = (tmp >= last_ts) ? (tmp-last_ts) : (last_ts);
#ifndef SCHEDER_H264_ENC
OSA_semWait(&sched->sem, OSA_TIMEOUT_FOREVER);
#else
if(isDelay)
{
tmp = 5000;//5ms
isDelay = 0;
}
timeout.tv_usec = tmp;
select(0,NULL,NULL,NULL,&timeout);
#endif
last_ts = OSA_getCurTimeInMsec();
//OSA_printf("tm %d", last_ts - curr_ts);
curr_ts = last_ts;
if(sched->taskLoop )
break;
if(sched->wrIndx!= sched->rdIndx )
{
tmp = 0;
rd = sched->rdIndx;
iRet = Sched_frame_output(sched, 1);
}
else
{
isDelay = 0x01;
//OSA_printf("chId %d Que is empty!!!",sched->index);
}
}
printf(" [DEBUG:] %s task exit!!! \r\n",__func__);
return NULL;
}
/*
* @Function: // Sched_h265_Scheder
* @Description: // 外部调用此函数向调度器缓存队列存入一帧,立即返回
* @Input: // iChn 编码通道 未使用
* // void * data 数据指针
* // int len 需要写入的数据长度
* // ts 时间戳未使用
* // int thrd 帧周期最大发送字节数
* // write_cb 发送回调函数
* // cbFd 发送回调函数串口FD
* @Output: // 对输出参数的说明。
* @Return: // 写入数据长度
* @Assumptions: // 不会有任何一帧数据超过80K
* @Others: // 外部接口函数
*/
int Sched_h26x_Scheder
(
int iChn,
void *data,
int len,
unsigned int ts,
int thrd,
int (*write_cb)(long, unsigned char *buf, int),
long cbFd
)
{
int iRet = 0;
Sched_Chn * sched=NULL;
if(!bInit)
{
Sched_h26x_Init();
}
if(len >= FRAME_BUFLEN)
return iRet;
OSA_assert(iChn < CHAN_COUNT);
sched = &schedChannel[iChn];
//sched = &schedChannel[0];
sched->write_cb = write_cb;
sched->cbFd = cbFd;
sched->thrd = thrd;
iRet = Sched_frame_input(sched,data,len,ts);
return iRet;
}
int Sched_config
(
int iChn,
int iChn_cout,
int framerate
)
{
Sched_Chn * sched=NULL;
if(!bInit)
return 0;
sched = &schedChannel[iChn];
if(framerate != 0)
{
sched->framewait = 1000000 / framerate;
}
g_chan_cout = iChn_cout; // = 1;
return 0;
}
static unsigned int Sched_get_wait_time(Sched_Chn * sched, unsigned int capTs,unsigned int delayTs, unsigned int *pBegin, unsigned int *pEnd)
{
unsigned int curTm = 0;
unsigned int capD = 0;
unsigned int uRet = 0;
OSA_assert(sched != NULL);
curTm = OSA_getCurTimeInMsec();
if( (!sched->sendTime_isBuild ) || (capTs < sched->sendTime_capBase) ||(curTm < sched->sendTime_sndBase))
{
sched->sendTime_sndBase = curTm ;
sched->sendTime_capBase = capTs;
sched->sendTime_isBuild = 1;
}
capD = capTs - sched->sendTime_capBase;
uRet = sched->sendTime_sndBase + capD + delayTs;
/* if(uRet <= curTm)
{
sched->sendTime_sndBase = curTm ;
sched->sendTime_capBase = capTs;
uRet = sched->sendTime_sndBase + delayTs;
}*/
if(pBegin != NULL)
*pBegin = curTm;
if(pEnd != NULL)
*pEnd = uRet;
return (uRet < curTm) ? 0 :(uRet - curTm)*1000;//us
}
/**********************************************end file****************************************/
|
a62859c936d2ba8945b546bf9dc89134c478110b | 877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a | /app/src/main/cpp/dir7941/dir22441/dir22442/dir22443/dir22444/dir22869/dir22870/dir22871/file22880.cpp | 6f4fed74b37387af63baf5a885b733d3f81a6596 | [] | no_license | tgeng/HugeProject | 829c3bdfb7cbaf57727c41263212d4a67e3eb93d | 4488d3b765e8827636ce5e878baacdf388710ef2 | refs/heads/master | 2022-08-21T16:58:54.161627 | 2020-05-28T01:54:03 | 2020-05-28T01:54:03 | 267,468,475 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 115 | cpp | file22880.cpp | #ifndef file22880
#error "macro file22880 must be defined"
#endif
static const char* file22880String = "file22880"; |
465c2c179cd0a5d34151f3f4d7a575b213e0e30b | 5f790869382ac6a2c7e0ae913ccbfdb60508c694 | /Level 3/Bit Manipulation/Single Number.cpp | 1c8cdbbbd98e9b21e1e590822f5fd09ebafcfcdd | [] | no_license | rohithmone27/InterviewBit | 4e702a62d4f8ff88ca89ebc3012ecbab86aacb03 | cbf65c69159d0a552b53b8e61bc94c76c85582e1 | refs/heads/master | 2022-11-28T23:22:30.520518 | 2020-08-09T16:45:08 | 2020-08-09T16:45:08 | 285,234,911 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 175 | cpp | Single Number.cpp | int Solution::singleNumber(const vector<int> &A) {
int temp = 0;
for (auto i=0; i<A.size(); ++i){
temp ^= A[i];
}
return temp;
} |
867069df23053080518d7adb92c3bc58554399b6 | 556a1b4de08e227601adb292e0628af9ff070c7c | /texture.cpp | 8497488f7afdbc339cf7e646486f2f8fb0422961 | [] | no_license | MekaGem/opengl-course-mipt | cc14b041a1cbce448770f61e86fbd432e8ba8430 | bf229fb6e84ebe3bdfe3fa99900f1bd746f69b8a | refs/heads/master | 2021-01-18T21:57:50.838078 | 2016-06-02T10:57:57 | 2016-06-02T10:57:57 | 51,753,336 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 890 | cpp | texture.cpp | #include <SOIL/SOIL.h>
#include "texture.hpp"
Texture::Texture(const std::string &textureName) : textureName(textureName) {
unsigned char *image = SOIL_load_image(textureName.c_str(), &width, &height, 0, SOIL_LOAD_RGBA);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
SOIL_free_image_data(image);
glBindTexture(GL_TEXTURE_2D, 0);
}
GLuint Texture::get() {
return texture;
}
int Texture::getWidth() {
return width;
}
int Texture::getHeight() {
return height;
}
|
79c181f01c602d0083019aa7b8af60c602fd8871 | 8a195ab4aaa7f1708eb164d80bded6f86aacdeca | /第07章 在线签名鉴定/应用实例/movement.cpp | 68d2b9301e208e232594c3a47d49df0320a293e9 | [] | no_license | zhe13/Pettern | 04a5ea24c1e628930f17ea9627a8d2f5357e6693 | b56bb196337e450df08dac80fe776d94d3e50014 | refs/heads/master | 2021-01-23T11:55:33.239002 | 2014-12-27T02:31:55 | 2014-12-27T02:31:55 | 28,526,471 | 19 | 8 | null | null | null | null | UTF-8 | C++ | false | false | 5,210 | cpp | movement.cpp | //movement.c
// date: 2001.9.22
#include "movement.h"
#define pi 3.1415926535
//////////////////////////////////////////////////////////////////////////////////////////////////
// compute_feature:
// x[],y[] represent the coordinate,length represent the array length
// featuretemp save the feagure computed
void compute_feagure(double x[],double y[],int length,PFEAGURE_MV feaguretemp)
{
double fg1,fg2,fg3,fg4,fg5,fg6,fg7,fg8;
int i;
double theta; //angle
double lm1,lm2;
double u00=0,u02=0,u20=0,u11=0;
double u03a=0,u03s=0,u03;//u03a>0,u03s<0
double u30a=0,u30s=0,u30;//u30a>0,u30s<0
double u12a=0,u12s=0,u12;//u12a>0,u12s<0
double u21a=0,u21s=0,u21;//u21a>0,u21s<0
double size;
double xmax=0,xmin=10000000.0,ymax=0,ymin=100000000.0;
double xav=0,yav=0;
//compute xav,yav;
for(i=0;i<length;i++){
xav+=x[i];
yav+=y[i];
}//end for
xav/=(double)length;
yav/=(double)length;
//compute the necessary parameter
for(i=0;i<length;i++){
//compute xmax,ymax,xmin,ymin
if(x[i]>xmax)
xmax=x[i];
if(x[i]<xmin)
xmin=x[i];
if(y[i]>ymax)
ymax=y[i];
if(y[i]<ymin)
ymin=y[i];
//add u02,u20......
u02+=(y[i]-yav)*(y[i]-yav);
u20+=(x[i]-xav)*(x[i]-xav);
u11+=(x[i]-xav)*(y[i]-yav);
u30=(x[i]-xav)*(x[i]-xav)*(x[i]-xav);
if(u30>0)
u30a+=u30;
else
u30s-=u30;
u03=(y[i]-yav)*(y[i]-yav)*(y[i]-yav);
if(u03>0)
u03a+=u03;
else
u03s-=u03;
u12=(x[i]-xav)*(y[i]-yav)*(y[i]-yav);
if(u12>0)
u12a+=u12;
else
u12s-=u12;
u21=(x[i]-xav)*(x[i]-xav)*(y[i]-yav);
if(u21>0)
u21a+=u21;
else
u21s-=u21;
}//end for
theta=atan((u02-u20+sqrt((u20-u02)*(u20-u02)+4*u11*u11))/(2*u11));
lm1=((u20+u02)+sqrt((u20-u02)*(u20-u02)+4*u11*u11))/2;
lm1=((u20+u02)-sqrt((u20-u02)*(u20-u02)+4*u11*u11))/2;
size=sqrt((xmax-xmin)*(ymax-ymin));
fg1=theta*2/pi;//orientation
fg2=(lm1-lm2)/(lm1+lm2);//inertial ratio
fg3=((u20-u02)/(u20+u02)+1)/2;//aspect ration
fg4=sqrt((u02+u20)/(double)length)*2/size;//spreadness
fg5=((u30a-u30s)/(u30a+u30s)+1)/2; //horizantal skewness
fg6=((u03a-u03s)/(u03a+u03s)+1)/2; //vertical skewness
fg7=((u21a-u21s)/(u21a+u21s)+1)/2; //banlance of horizontal extension
fg8=((u12a-u12s)/(u12a+u12s)+1)/2; //banlance of vertical extention
feaguretemp->f1=fg1;
feaguretemp->f2=fg2;
feaguretemp->f3=fg3;
feaguretemp->f4=fg4;
feaguretemp->f5=fg5;
feaguretemp->f6=fg6;
feaguretemp->f7=fg7;
feaguretemp->f8=fg8;
}//end feagure compute
void compute_feagure_ex(double x[],double y[],double pressure[],int length,PFEAGURE_MV feaguretemp)
{
double fg1,fg2,fg3,fg4,fg5,fg6,fg7,fg8;
double m00=0.0;
int i,j;
double theta; //angle
double lm1,lm2;
double u00=0,u02=0,u20=0,u11=0;
double u03a=0,u03s=0,u03;//u03a>0,u03s<0
double u30a=0,u30s=0,u30;//u30a>0,u30s<0
double u12a=0,u12s=0,u12;//u12a>0,u12s<0
double u21a=0,u21s=0,u21;//u21a>0,u21s<0
double size;
double xmax=0,xmin=10000000.0,ymax=0,ymin=100000000.0;
double xav=0,yav=0;
//compute xav,yav,m00;
for(i=0;i<length;i++){
xav+=x[i]*pressure[i];
yav+=y[i]*pressure[i];
m00+=pressure[i];
}//end for
xav/=m00;
yav/=m00;
//compute the necessary parameter
for(i=0;i<length;i++){
//compute xmax,ymax,xmin,ymin
if(x[i]>xmax)
xmax=x[i];
if(x[i]<xmin)
xmin=x[i];
if(y[i]>ymax)
ymax=y[i];
if(y[i]<ymin)
ymin=y[i];
//add u02,u20......
u02+=(y[i]-yav)*(y[i]-yav)*pressure[i];
u20+=(x[i]-xav)*(x[i]-xav)*pressure[i];
u11+=(x[i]-xav)*(y[i]-yav)*pressure[i];
u30=(x[i]-xav)*(x[i]-xav)*(x[i]-xav)*pressure[i];
if(u30>0)
u30a+=u30;
else
u30s-=u30;
u03=(y[i]-yav)*(y[i]-yav)*(y[i]-yav)*pressure[i];
if(u03>0)
u03a+=u03;
else
u03s-=u03;
u12=(x[i]-xav)*(y[i]-yav)*(y[i]-yav)*pressure[i];
if(u12>0)
u12a+=u12;
else
u12s-=u12;
u21=(x[i]-xav)*(x[i]-xav)*(y[i]-yav)*pressure[i];
if(u21>0)
u21a+=u21;
else
u21s-=u21;
}//end for
theta=atan((u02-u20+sqrt((u20-u02)*(u20-u02)+4*u11*u11))/(2*u11));
lm1=((u20+u02)+sqrt((u20-u02)*(u20-u02)+4*u11*u11))/2;
lm1=((u20+u02)-sqrt((u20-u02)*(u20-u02)+4*u11*u11))/2;
size=sqrt((xmax-xmin)*(ymax-ymin));
fg1=theta*2/pi;//orientation
fg2=(lm1-lm2)/(lm1+lm2);//inertial ratio
fg3=((u20-u02)/(u20+u02)+1)/2;//aspect ration
fg4=sqrt((u02+u20)/m00)*2/size;//spreadness
fg5=((u30a-u30s)/(u30a+u30s)+1)/2; //horizantal skewness
fg6=((u03a-u03s)/(u03a+u03s)+1)/2; //vertical skewness
fg7=((u21a-u21s)/(u21a+u21s)+1)/2; //banlance of horizontal extension
fg8=((u12a-u12s)/(u12a+u12s)+1)/2; //banlance of vertical extention
feaguretemp->f1=fg1;
feaguretemp->f2=fg2;
feaguretemp->f3=fg3;
feaguretemp->f4=fg4;
feaguretemp->f5=fg5;
feaguretemp->f6=fg6;
feaguretemp->f7=fg7;
feaguretemp->f8=fg8;
}//end feagure compute ex
double feagure_distance(PFEAGURE_MV feagure1,PFEAGURE_MV feagure2)
{
double dist=0.0;
double rx;
dist+=fabs(feagure1->f3-feagure2->f3);
dist+=fabs(feagure1->f4-feagure2->f4);
dist+=fabs(feagure1->f5-feagure2->f5);
dist+=fabs(feagure1->f6-feagure2->f6);
dist+=fabs(feagure1->f7-feagure2->f7);
dist+=fabs(feagure1->f8-feagure2->f8);
rx=fabs(feagure1->f1-feagure2->f1);
if(rx>1)
rx=2-rx;
dist+=rx*(feagure1->f2+feagure2->f2);
return dist;
}
|
249a2b688836882fa5e5a68748d5498b186d5050 | 57e9e105290aa0854fe9a394a1c67d9aa85ec48a | /GeekBrains_Learning/mylib.cpp | fb09d0a1c9a7dd6ba5bb36b59cb39dc98b9e8267 | [] | no_license | ell-pancho/GeekBrains_Learning | 77a31c0ea4a091d6f326f186b533b4757a034d8d | 2ecdd35901f12eb97876ce9cd42a29530a988b70 | refs/heads/master | 2023-07-13T07:42:38.436028 | 2021-08-29T12:23:15 | 2021-08-29T12:23:15 | 381,488,986 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 987 | cpp | mylib.cpp | #include <iostream>
using namespace std;
namespace MyLib
{
int getInputInteger()
{
int size;
while (true)
{
cout << "Enter an integer value: ";
cin >> size;
if (cin.fail())
{
cout << "Please enter an integer number!" << endl;
cin.clear();
cin.ignore(32767, '\n');
}
else
return size;
}
}
int* initArray(int size)
{
int* ptrArray;
ptrArray = new (nothrow) int[size];
for (size_t i = 0; i < size; i++)
ptrArray[i] = (rand() % 2101) - 100;
return ptrArray;
}
void printMyArray(int* array, int size)
{
for (size_t i = 0; i < size; i++)
cout << array[i] << " ";;
cout << endl;
}
void countElements(int* array, int size)
{
int positiveCount = 0, negativeCount = 0;
for (size_t i = 0; i < size; i++)
if (array[i] > 0)
positiveCount += 1;
else
negativeCount += 1;
cout << "Cout positive elements: " << positiveCount << endl;
cout << "Cout negative elements: " << negativeCount << endl;
}
}
|
44ad1ca1d2ed9f040aca87232e3b8fe503e94c67 | 7d260d31ede56e567590dc5910e8ca858e08ed61 | /altlightning/altlightning.ino | 19ca66ccf32467b6af9ba0c0d6e3ec183bf5b2e0 | [] | no_license | bradganley/bweeno | 2872fec512c0744f755b34627a7faf913eed7ad6 | 4d741299dfa9814be213094253fad73226f8a7ec | refs/heads/master | 2021-09-18T08:09:03.747235 | 2018-07-11T22:00:24 | 2018-07-11T22:00:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 639 | ino | altlightning.ino | #define BETWEEN 2579
#define DURATION 43
#define TIMES 7
#define LEDPIN 13
unsigned long lastTime = 0;
int waitTime = 0;
void setup()
{
Serial.begin(115200);
Serial.println("lightning 0.0");
pinMode(LEDPIN, OUTPUT);
}
void loop()
{
if (millis() - waitTime > lastTime) // time for a new flash
{
// adjust timing params
lastTime += waitTime;
waitTime = random(BETWEEN);
for (int i=0; i< random(TIMES); i++)
{
Serial.println(millis());
digitalWrite(LEDPIN, HIGH);
delay(20 + random(DURATION));
digitalWrite(LEDPIN, LOW);
delay(10);
}
}
// do other stuff here
}
|
cffc3660079af1f4498701de1f09f0042c36ec3c | fac9f801844d8759a195f5f6c83f29a371f0ba89 | /src/envoy/utils/token_subscriber_factory_impl.h | f73887fba6fdc3b58cc3652acedf0ad86a8773ec | [
"Apache-2.0"
] | permissive | bbamsch/esp-v2 | e75e594a3d98cfbbd59065ec01968e1003a500e5 | 1be738bc58b2e491bd7d2372347dd3e8fa61ee90 | refs/heads/master | 2020-11-26T03:25:17.118147 | 2019-12-18T17:19:24 | 2019-12-18T17:19:24 | 228,952,668 | 1 | 0 | Apache-2.0 | 2019-12-19T01:42:53 | 2019-12-19T01:42:52 | null | UTF-8 | C++ | false | false | 1,900 | h | token_subscriber_factory_impl.h | // Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include "src/envoy/utils/token_subscriber_factory.h"
namespace Envoy {
namespace Extensions {
namespace Utils {
class TokenSubscriberFactoryImpl : public TokenSubscriberFactory {
public:
TokenSubscriberFactoryImpl(Server::Configuration::FactoryContext& context)
: context_(context) {}
TokenSubscriberPtr createTokenSubscriber(
const std::string& token_cluster, const std::string& token_url,
const bool json_response,
TokenSubscriber::TokenUpdateFunc callback) const override {
return std::make_unique<TokenSubscriber>(context_, token_cluster, token_url,
json_response, callback);
}
IamTokenSubscriberPtr createIamTokenSubscriber(
IamTokenSubscriber::TokenGetFunc access_token_fn,
const std::string& iam_service_cluster,
const std::string& iam_service_uri,
IamTokenSubscriber::TokenUpdateFunc callback) const override {
return std::make_unique<IamTokenSubscriber>(context_, access_token_fn,
iam_service_cluster,
iam_service_uri, callback);
}
private:
Envoy::Server::Configuration::FactoryContext& context_;
};
} // namespace Utils
} // namespace Extensions
} // namespace Envoy
|
2110d2fdf005a3f0bd208d881fab2f5efe603767 | fca4ddc410c43aeaffdaa736f28c95c1761884de | /solution_minimum_scalar_product.h | d250e0b2e1ee351303a4857f75a451a89fb7de45 | [
"Apache-2.0"
] | permissive | AnubhavBharadwaaj/Solution-of-Google-Code-Jam-Minimum-Scalar-Product | 61c56005f50d4a445e06bd0a5ce992bd302722d1 | 9be2bc23923866efc4b79d62bcabe53d3d837f38 | refs/heads/master | 2020-06-11T09:18:17.573693 | 2016-12-06T06:25:21 | 2016-12-06T06:25:21 | 75,701,369 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,592 | h | solution_minimum_scalar_product.h | #include<iostream>
#include <vector>
#include <algorithm>
using namespace std;
int fac(int a)
{
int mul=1;
for(int i=a;i>=1;i--)
{
mul=mul*i;
}
return mul;
}
int main()
{
int n,i,j,k=0;
cin>>n;
vector<int> v1[n+1],v2[n+1];
int *num=new int[n+1];
for(i=0;i<n;i++)
{
cin>>num[k];
if(num[k]>8||num[k]<1)
{
exit(0);
}
for(j=0;j<num[k];j++)
{
int c;
cin>>c;
if(c>1000||c<-1000)
{
exit(0);
}
(v1[i]).push_back(c);
}
for(j=0;j<num[k];j++)
{
int c;
cin>>c;
if(c>1000||c<-1000)
{
exit(0);
}
(v2[i]).push_back(c);
}
k++;
}
int *repeat=new int[k];
for(j=0;j<k;j++)
{
repeat[j]=(fac(num[j]))*(fac(num[j]));
}
vector<int> result[5];
for(i=0;i<n;i++)
{
int p=0,sum=0;
while(p<=repeat[i])
{
sum=0;
random_shuffle((v1[i]).begin(),(v1[i]).end());
for(j=0;j<num[i];j++)
{
int pro=1;
pro=((v1[i])[j])*((v2[i])[j]);
sum=sum+pro;
}
//cout<<sum<<endl;
(result[i]).push_back(sum);
p++;
}
//sort((result[i]).begin(),(result[i]).end());
}
for(i=0;i<n;i++)
{
sort((result[i]).begin(),(result[i]).end());
}
for(i=0;i<n;i++)
{
cout<<"Case #"<<(i+1)<<": "<<((result[i])[0])<<endl;
}
return 0;
} |
948783171c7d4d0de7ae0fa30c4ad927ef779535 | c21398f10cdeaeb827e050d9556c36ab0e08489d | /lib/imap/IMAPCommandParser.src.h | 28fbffdd4a4edc4999273fd175c06be1098a245d | [
"Apache-2.0"
] | permissive | skywa04885/fsmtp-v2 | 9a318ca82a6a6f2b5063d871d619ea9b85c3149b | a8023ff92e00e1df12f097f50c9bb3bf05d22d0e | refs/heads/master | 2023-02-16T07:35:29.050033 | 2021-01-11T11:35:47 | 2021-01-11T11:35:47 | 275,809,400 | 2 | 1 | Apache-2.0 | 2020-07-19T21:23:04 | 2020-06-29T12:32:27 | C++ | UTF-8 | C++ | false | false | 6,721 | h | IMAPCommandParser.src.h | /*
Copyright [2020] [Luke A.C.A. Rieff]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#pragma once
#include "IMAP.src.h"
namespace FSMTP::IMAP::CommandParser
{
typedef enum : uint8_t
{
TT_LPAREN = 0,
TT_RPAREN,
TT_QUOTE,
TT_OTHER,
TT_SPACE,
TT_LBRACKET,
TT_RBRACKET,
TT_NUMBER,
TT_WSP,
TT_COLON
} TokenType;
class SyntaxException
{
public:
SyntaxException(const std::size_t i, const std::string &e_Message):
e_Message("ERR [token: " + std::to_string(i) + "]: " + e_Message)
{}
const char *what(void) const throw()
{
return this->e_Message.c_str();
}
private:
std::string e_Message;
};
/**
* Gets the name of an token type
*
* @Param {const TokenType} type
* @Return {const char *}
*/
const char *tokenTypeString(const TokenType type);
class Token
{
public:
/**
* The default empty constructor
*
* @Param {void}
* @Return {void}
*/
explicit Token(void);
/**
* The default empty constructor
*
* @Param {const char *} t_String
* @Param {const TokenType} t_Type
* @Return {void}
*/
Token(const char *t_String, const TokenType t_Type);
/**
* The default empty constructor
*
* @Param {const char} t_Char
* @Param {const TokenType} t_Type
* @Return {void}
*/
Token(const char t_Char, const TokenType t_Type);
/**
* The default empty constructor
*
* @Param {const int32_t} t_Int32
* @Param {const TokenType} t_Type
* @Return {void}
*/
Token(const int32_t t_Int32, const TokenType t_Type);
/**
* The default empty constructor
*
* @Param {const TokenType} t_Type
* @Return {void}
*/
Token(const TokenType t_Type);
/**
* Frees the memory, if string
*
* @Param {void}
* @Return {void}
*/
void free(void);
/**
* Turns the token into an string, for debug
*
* @param {void}
* @Return {std::string}
*/
std::string toString(void) const;
union
{
char *t_String;
int32_t t_Int32;
char t_Char;
};
TokenType t_Type;
};
class Lexer
{
public:
Lexer(const std::string &l_Text);
void advance(void);
/**
* Starts making the tokens
*
* @Param {void}
* @Return {void}
*/
void makeTokens(void);
/**
* Makes an number of a set of tokens
*
* @Param {void}
* @Return {void}
*/
void makeNumber(void);
/**
* Makes an string of characters
*
* @Param {void}
* @Return {void}
*/
void makeOther(void);
/**
* Default destructor, which free's the memory
*
* @Param {void}
* @Return {void}
*/
~Lexer(void);
std::vector<Token> l_Tokens;
private:
std::string l_Text;
std::size_t l_Pos;
char l_CurrentChar;
};
typedef enum : uint8_t
{
A_TYPE_STRING = 0,
A_TYPE_INT32,
A_TYPE_INT64,
A_TYPE_CHAR,
A_TYPE_ATOM,
A_TYPE_SECTION,
A_TYPE_LIST,
A_TYPE_RANGE
} ArgumentType;
typedef struct
{
int32_t r_From;
int32_t r_To;
} Range;
class Argument
{
public:
/**
* Default empty constructor
*
* @Param {void}
* @Return {void}
*/
explicit Argument(void);
/**
* Integer argument
*
* @Param {const int32_t} a_Int32
* @Param {const ArgumentType} a_Type
* @Return {void}
*/
Argument(const int32_t a_Int32, const ArgumentType a_Type);
/**
* Integer argument
*
* @Param {const int32_t} a_Int32
* @Param {const ArgumentType}
* @Return {void}
*/
Argument(const char a_Char, const ArgumentType a_Type);
/**
* Integer argument
*
* @Param {const Range} a_Range
* @Param {const ArgumentType}
* @Return {void}
*/
Argument(const Range a_Range, const ArgumentType a_Type);
/**
* Integer argument
*
* @Param {const char *} a_String
* @Param {const ArgumentType}
* @Return {void}
*/
Argument(const char *a_String, const ArgumentType a_Type);
/**
* Deletes the string if it is there
*
* @Param {void}
* @Return {void}
*/
void free(void);
union
{
int32_t a_Int32;
char *a_String;
char a_Char;
Range a_Range;
};
std::vector<Argument> a_Children;
ArgumentType a_Type;
};
class Parser
{
public:
/**
* Default constructor for the parser
*
* @Param {const std::vector<Token> &} p_Tokens
* @Return {void}
*/
Parser(const std::vector<Token> &p_Tokens);
/**
* Starts the parsing, and pushes the result to
* - the target
*
* @Param {std::vector<Argument> &} target
* @Return {void}
*/
void parse(std::vector<Argument> &target);
/**
* Analyzes and selects which action to start based
* - on the then current token
*
* @Param {std::vector<std::unique_ptr<Node>> &} target
* @Param {const bool} head
* @Return {void}
*/
void analyze(std::vector<Argument> &target, const bool head);
/**
* Goes to the next token, and sets the pointer to nullptr
* - if EOF
*
* @Param {void}
* @Return {void}
*/
void advance(void);
/**
* Parses an number and pushes it to the target
*
* @Param {std::vector<std::unique_ptr<Node>> &} target
* @Return {bool}
*/
bool number(std::vector<Argument> &target);
/**
* Parses an string and pushes it to the target
*
* @Param {std::vector<std::unique_ptr<Node>> &} target
* @Return {bool}
*/
bool string(std::vector<Argument> &target);
/**
* Parses an atom and pushes it to the target
*
* @Param {std::vector<std::unique_ptr<Node>> &} target
* @Return {bool}
*/
bool other(std::vector<Argument> &target);
/**
* Builds an list node in the recursive manner
*
* @Param {std::vector<std::unique_ptr<Node>> &} target
* @Return {bool}
*/
bool list(std::vector<Argument> &target);
/**
* Builds an section node in the recursive manner
*
* @Param {std::vector<std::unique_ptr<Node>> &} target
* @Return {bool}
*/
bool section(std::vector<Argument> &target);
/**
* Builds an section node in the recursive manner
*
* @Param {std::vector<std::unique_ptr<Node>> &} target
* @Return {bool}
*/
bool range(std::vector<Argument> &target);
private:
const Token *p_CurrentToken;
char p_CurrentChar;
std::size_t p_TokenIndex;
const std::vector<Token> &p_Tokens;
};
} |
abdf25a36b267b16a4acb7b4ebed704dda70bca6 | 38b9daafe39f937b39eefc30501939fd47f7e668 | /tutorials/2WayCouplingOceanWave3D/EvalResults180628-Eta/16.4/alpha.water | 1305166e2b2574709c2d9d1919168a948a19c2b8 | [] | no_license | rubynuaa/2-way-coupling | 3a292840d9f56255f38c5e31c6b30fcb52d9e1cf | a820b57dd2cac1170b937f8411bc861392d8fbaa | refs/heads/master | 2020-04-08T18:49:53.047796 | 2018-08-29T14:22:18 | 2018-08-29T14:22:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 126,676 | water | alpha.water | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 3.0.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "16.4";
object alpha.water;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 0 0 0 0];
internalField nonuniform List<scalar>
21420
(
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999999
0.999999
1
1
1
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999999
0.999999
0.999998
0.999998
0.999997
0.999996
0.999997
0.999996
0.999994
0.999994
0.999994
0.999994
0.999995
0.999997
0.999998
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999999
0.999998
0.999998
0.999998
0.999997
0.999996
0.999996
0.999998
0.999997
0.999998
0.999998
0.999998
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999999
0.999999
0.999998
0.999998
0.999997
0.999996
0.999995
0.999994
0.999994
0.999994
0.999994
0.999995
0.999996
0.999997
0.999998
0.999999
0.999999
0.999999
0.999999
0.999999
0.999998
0.999998
0.999998
0.999999
0.999999
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999997
0.999992
0.999985
0.999983
0.999982
0.999985
0.999989
0.999986
0.999984
0.999985
0.999985
0.999984
0.999983
0.999982
0.999983
0.999986
0.99999
0.999992
0.999993
0.999996
0.999997
0.999998
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999997
0.999994
0.99999
0.999986
0.999981
0.999973
0.999963
0.999951
0.999927
0.999917
0.999925
0.999878
0.999842
0.999833
0.999814
0.999849
0.999919
0.999963
0.999967
0.999961
0.999961
0.999965
0.999972
0.999978
0.999978
0.999977
0.999978
0.999982
0.999987
0.999991
0.999992
0.999994
0.999996
0.999997
0.999998
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999997
0.999995
0.99999
0.999982
0.99997
0.999958
0.999944
0.999925
0.9999
0.999874
0.999873
0.999899
0.99989
0.999942
0.999961
0.999973
0.999983
0.999981
0.999979
0.999981
0.999984
0.999988
0.99999
0.999991
0.999991
0.999991
0.999992
0.999993
0.999994
0.999995
0.999996
0.999996
0.999996
0.999998
0.999998
0.999998
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999998
0.999997
0.999994
0.999992
0.999988
0.999984
0.999977
0.999967
0.999955
0.999946
0.999943
0.999915
0.999869
0.999851
0.999837
0.999832
0.999845
0.999896
0.999937
0.999963
0.999963
0.999956
0.999955
0.99996
0.999968
0.999972
0.99997
0.999971
0.999976
0.999984
0.999989
0.999991
0.999994
0.999997
0.999998
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999998
0.999987
0.999937
0.999754
0.999202
0.99777
0.994544
0.988771
0.983404
0.979584
0.977688
0.978396
0.982107
0.988024
0.994581
0.999333
0.999639
0.999664
0.999673
0.999725
0.999804
0.999872
0.999899
0.999924
0.999955
0.999972
0.999981
0.99999
0.999995
0.999997
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999998
0.999993
0.999978
0.999936
0.999835
0.999608
0.999147
0.998307
0.996953
0.994909
0.991705
0.98645
0.978668
0.968394
0.955488
0.940558
0.92589
0.912176
0.898874
0.887887
0.881583
0.881968
0.889417
0.902623
0.919314
0.937793
0.956678
0.973734
0.987278
0.996135
0.999525
0.999548
0.999611
0.999705
0.999805
0.999875
0.9999
0.999929
0.999958
0.999973
0.999982
0.999991
0.999995
0.999997
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999997
0.999989
0.999966
0.999899
0.999726
0.999307
0.998371
0.996401
0.992535
0.98572
0.975315
0.960857
0.942215
0.920835
0.900873
0.885961
0.879436
0.882084
0.88989
0.900902
0.912095
0.924824
0.940419
0.956672
0.972352
0.984874
0.993627
0.998649
0.999737
0.999761
0.999789
0.999817
0.99985
0.999889
0.999921
0.999932
0.99994
0.999954
0.99997
0.999979
0.999984
0.99999
0.999994
0.999997
0.999998
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999998
0.999994
0.999983
0.999957
0.999896
0.999767
0.999514
0.999047
0.998236
0.996931
0.994969
0.991979
0.987352
0.980635
0.971656
0.960574
0.948136
0.934886
0.920646
0.906523
0.895335
0.887073
0.883816
0.88831
0.897998
0.910928
0.926537
0.943801
0.961544
0.978134
0.991165
0.998496
0.999445
0.999516
0.999634
0.99977
0.999856
0.999891
0.999931
0.999963
0.999976
0.999986
0.999993
0.999996
0.999998
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999999
0.999999
0.999998
0.999997
0.999996
0.999993
0.999991
0.999985
0.999975
0.999966
0.999954
0.999965
0.999989
0.999986
0.999981
0.999975
0.999969
0.999964
0.999961
0.999963
0.999969
0.99998
0.999984
0.999989
0.999992
0.999993
0.999995
0.999998
0.999998
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999984
0.999524
0.993528
0.949509
0.833773
0.719181
0.618444
0.531788
0.458383
0.397458
0.348521
0.311132
0.28531
0.271466
0.269692
0.281825
0.304879
0.337978
0.380106
0.431165
0.491526
0.56159
0.639227
0.728103
0.816583
0.88344
0.918929
0.950496
0.979281
0.997383
0.998794
0.999161
0.999539
0.999724
0.999828
0.999914
0.999954
0.999978
0.99999
0.999996
0.999998
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999995
0.999984
0.999948
0.999842
0.999531
0.998702
0.9966
0.991306
0.979147
0.955432
0.916487
0.859521
0.78087
0.694725
0.612578
0.537061
0.471348
0.419254
0.379603
0.34633
0.320843
0.304034
0.296482
0.298178
0.313658
0.343129
0.383813
0.434824
0.496652
0.565521
0.639284
0.714954
0.786035
0.845767
0.898158
0.943408
0.977221
0.996209
0.998766
0.999184
0.99955
0.99973
0.99983
0.999915
0.999953
0.999977
0.999989
0.999995
0.999998
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999998
0.999992
0.999975
0.999918
0.999744
0.999242
0.997768
0.993412
0.980926
0.950556
0.88918
0.786792
0.673578
0.571804
0.483114
0.40845
0.35046
0.3118
0.292163
0.287805
0.296607
0.31498
0.339863
0.368742
0.400654
0.44228
0.496659
0.560102
0.624892
0.687933
0.749887
0.807416
0.852416
0.890988
0.924521
0.95406
0.978201
0.993908
0.998991
0.999181
0.999421
0.999651
0.999774
0.99984
0.99991
0.999949
0.999971
0.999986
0.999993
0.999997
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999997
0.999988
0.999958
0.999872
0.999653
0.999144
0.997979
0.995388
0.989734
0.97816
0.956712
0.921583
0.869047
0.795154
0.712163
0.632916
0.560998
0.498989
0.447457
0.406558
0.373813
0.345968
0.323596
0.308159
0.303323
0.31296
0.33382
0.36358
0.403557
0.4535
0.514118
0.586329
0.667671
0.750759
0.82639
0.885649
0.937629
0.976972
0.996794
0.998729
0.999243
0.999616
0.999763
0.999868
0.999937
0.999966
0.999985
0.999993
0.999997
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999997
0.999992
0.999981
0.999959
0.999912
0.999814
0.999612
0.999193
0.998348
0.996767
0.993967
0.989271
0.981615
0.969101
0.948479
0.917856
0.891568
0.873507
0.863453
0.860457
0.866195
0.882191
0.908654
0.935035
0.948219
0.955384
0.963555
0.971189
0.980122
0.989134
0.99757
0.999672
0.999797
0.999846
0.999876
0.999919
0.999962
0.999977
0.999985
0.999992
0.999995
0.999999
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999997
0.998246
0.949946
0.747142
0.535622
0.34384
0.171964
0.0568082
0.032709
0.0238969
0.0171439
0.0116908
0.00745575
0.00434051
0.00224422
0.00100535
0.000401856
0.000153162
2.53861e-05
8.39869e-06
2.75589e-05
9.50302e-05
0.000290225
0.000753056
0.00185956
0.00447456
0.0102098
0.0237954
0.0542712
0.122319
0.244012
0.384014
0.538975
0.712215
0.85748
0.930205
0.979994
0.997402
0.998463
0.999264
0.999618
0.999824
0.999921
0.999966
0.999987
0.999995
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999995
0.999979
0.999926
0.999746
0.999151
0.997146
0.98969
0.964288
0.896063
0.756681
0.595597
0.447777
0.327168
0.235092
0.170392
0.124099
0.0887606
0.0624533
0.043899
0.0314502
0.0232711
0.0170598
0.0131094
0.0109828
0.0102182
0.0103255
0.0113358
0.0134191
0.0167847
0.0220725
0.0306096
0.0435349
0.063586
0.0952115
0.143667
0.219539
0.320849
0.441902
0.578103
0.722212
0.84291
0.922489
0.976273
0.997359
0.998419
0.999245
0.999601
0.999807
0.999914
0.99996
0.999984
0.999994
0.999998
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999997
0.999989
0.999961
0.999869
0.999574
0.998534
0.994654
0.979287
0.928
0.793561
0.603011
0.420699
0.268667
0.169602
0.111062
0.0715879
0.0450863
0.0278886
0.017691
0.012639
0.0105659
0.0100382
0.0103877
0.0116374
0.0134708
0.0159284
0.0187926
0.0230726
0.0308969
0.0431717
0.0603515
0.0839581
0.118174
0.168623
0.236804
0.31198
0.392869
0.483688
0.585793
0.694142
0.798449
0.874869
0.935594
0.978705
0.997638
0.998437
0.999164
0.999556
0.999754
0.999888
0.999944
0.999977
0.99999
0.999997
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999996
0.999985
0.999946
0.999818
0.99938
0.998
0.993533
0.980151
0.945561
0.869156
0.737729
0.594962
0.4605
0.344198
0.249517
0.180765
0.13304
0.096498
0.0698592
0.0507361
0.0370579
0.0277519
0.0212692
0.0166739
0.0133471
0.0113012
0.0106876
0.0113529
0.0127666
0.0149991
0.0186346
0.0242613
0.0330597
0.0478014
0.0731252
0.115006
0.186164
0.29185
0.422635
0.575898
0.735453
0.859522
0.939962
0.987295
0.997735
0.998791
0.99945
0.999703
0.999871
0.999941
0.999975
0.99999
0.999996
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999997
0.999991
0.999973
0.999918
0.999754
0.999265
0.997721
0.992851
0.979031
0.944122
0.865161
0.737544
0.610482
0.491845
0.382037
0.281053
0.191292
0.120707
0.0712244
0.0451421
0.0276304
0.0143135
0.00624844
0.00406836
0.00636849
0.0102618
0.0187303
0.0379742
0.0825466
0.146285
0.222515
0.313118
0.416055
0.529502
0.659332
0.798207
0.920042
0.961809
0.977294
0.991695
0.999416
0.999677
0.999795
0.999885
0.99994
0.99998
0.999985
0.999993
0.999998
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
0.997622
0.883969
0.580644
0.293309
0.0690663
0.0243614
0.0117593
0.00197553
0.000364341
0.000124374
7.46929e-05
5.71948e-05
3.32278e-05
1.77297e-05
8.36121e-06
3.21816e-06
8.96343e-07
1.90848e-07
5.19819e-08
2.22827e-08
1.59367e-09
4.87675e-09
2.55753e-08
4.56571e-08
2.23143e-07
7.76732e-07
1.82233e-06
6.96726e-06
1.7052e-05
5.83647e-05
0.00017882
0.000447956
0.00151339
0.00460466
0.0141611
0.0452613
0.136365
0.329253
0.554889
0.787043
0.918439
0.982047
0.996926
0.998623
0.999392
0.999739
0.999899
0.999961
0.999987
0.999996
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999995
0.999979
0.999918
0.999683
0.998771
0.994772
0.975583
0.900804
0.704756
0.474182
0.270863
0.1453
0.0742182
0.0313524
0.00972491
0.00145251
0.000499061
0.000309076
0.000183673
0.000108547
6.87622e-05
0.000150874
0.000202749
0.000230529
0.000242991
0.000252677
0.000270064
0.000284076
0.000314393
0.000374387
0.000465014
0.000599262
0.000816991
0.00113083
0.00162198
0.00242759
0.00374748
0.00610981
0.0108733
0.0210303
0.0433425
0.0934038
0.204972
0.373622
0.571913
0.773122
0.901679
0.975447
0.996692
0.998437
0.999329
0.999692
0.99988
0.999952
0.999984
0.999995
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999996
0.999986
0.999951
0.999828
0.999379
0.997619
0.98949
0.951444
0.813815
0.574688
0.336366
0.165038
0.0755071
0.0251827
0.00365916
0.000809215
0.000431137
0.000220626
0.000108482
7.48445e-05
0.000161877
0.00021121
0.000242585
0.00027094
0.000300109
0.00033803
0.000395112
0.000464315
0.000538728
0.000640105
0.000842583
0.00117755
0.00164212
0.0022805
0.00323212
0.00477806
0.00725731
0.0110838
0.017202
0.0277482
0.0468845
0.0826579
0.150728
0.266979
0.414514
0.585974
0.76342
0.886117
0.962982
0.996234
0.99799
0.999127
0.99957
0.999825
0.999927
0.999975
0.999992
0.999998
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999996
0.999985
0.999942
0.999781
0.999198
0.996826
0.985451
0.936977
0.796263
0.594091
0.397323
0.235046
0.137562
0.0752543
0.0350717
0.0123745
0.00218456
0.000478936
0.000298157
0.000176018
0.000105694
7.02573e-05
0.000162112
0.00021696
0.000262854
0.000290106
0.000292337
0.000285837
0.000292435
0.000311191
0.000349236
0.0004069
0.000500501
0.000641542
0.000844109
0.00118085
0.00179255
0.00284423
0.00483247
0.00901108
0.0186622
0.0420209
0.0986496
0.231195
0.423821
0.641749
0.832061
0.935954
0.990206
0.997521
0.998945
0.999521
0.999797
0.999919
0.999968
0.999989
0.999996
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999998
0.999993
0.999978
0.999924
0.999735
0.999084
0.996557
0.985824
0.946171
0.826053
0.630901
0.438369
0.263292
0.137744
0.0829415
0.0471454
0.0225732
0.00746394
0.000596908
0.000149603
7.59819e-05
3.45557e-05
1.29834e-05
6.72882e-06
3.32379e-06
1.6092e-06
7.37625e-07
8.59378e-07
1.07109e-06
1.4133e-06
2.44109e-06
3.79795e-06
8.38909e-06
1.85758e-05
4.46183e-05
0.000146459
0.000477656
0.00212599
0.00977296
0.0502037
0.186619
0.359809
0.547913
0.759209
0.931245
0.9743
0.991217
0.999245
0.999746
0.999818
0.999911
0.999977
0.999986
0.999993
0.999998
0.999999
1
1
1
1
1
1
1
0.999934
0.96565
0.649218
0.277732
0.0358672
0.0116786
0.00110627
0.000395899
0.000203887
0.000105867
5.58513e-05
2.10735e-05
5.99299e-06
3.30503e-06
2.41043e-06
1.23945e-06
5.64416e-07
2.17446e-07
6.36314e-08
1.2043e-08
1.53692e-09
2.60647e-10
3.90488e-11
1.41347e-12
1.23234e-11
7.3028e-11
1.30904e-10
1.02098e-09
3.07167e-09
8.68151e-09
4.02639e-08
9.04989e-08
3.45955e-07
1.1572e-06
2.38861e-06
9.27858e-06
2.98084e-05
7.61358e-05
0.000301691
0.00108168
0.00478293
0.0210435
0.0874673
0.30347
0.579153
0.845009
0.958072
0.995465
0.998062
0.99925
0.999703
0.999899
0.999965
0.99999
0.999997
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999995
0.999981
0.999922
0.999675
0.998643
0.993332
0.961473
0.813056
0.534963
0.269524
0.114567
0.0368719
0.00466904
0.00120937
0.00060023
0.000271917
0.000118696
5.18943e-05
2.61031e-05
1.43424e-05
7.49624e-06
4.04756e-06
4.35481e-06
5.01885e-06
6.92635e-06
7.51256e-06
6.91415e-06
6.89254e-06
6.97565e-06
7.59985e-06
8.55431e-06
1.03536e-05
1.33477e-05
1.73937e-05
2.43212e-05
3.45111e-05
4.98654e-05
7.44999e-05
0.000113993
0.000178931
0.0002938
0.000523129
0.00101562
0.00215516
0.00514824
0.0137943
0.039994
0.119316
0.312267
0.565216
0.813746
0.94056
0.993792
0.997672
0.999106
0.999635
0.999875
0.999956
0.999987
0.999996
0.999999
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999998
0.999995
0.999984
0.999945
0.999797
0.999251
0.996989
0.984582
0.916977
0.690837
0.404515
0.174761
0.0645538
0.0119205
0.00182317
0.000839148
0.00035414
0.000133023
5.39379e-05
2.45305e-05
1.0705e-05
4.60839e-06
5.12276e-06
6.37499e-06
6.65125e-06
6.94992e-06
7.70851e-06
8.21954e-06
9.54197e-06
1.12964e-05
1.33875e-05
1.64087e-05
1.96044e-05
2.50697e-05
3.58735e-05
5.23272e-05
7.42482e-05
0.000105179
0.000154162
0.000227048
0.000329582
0.000484902
0.000742891
0.00119394
0.00204758
0.00380407
0.00778566
0.0177523
0.0437166
0.113425
0.280126
0.506712
0.752416
0.909277
0.9849
0.996817
0.998733
0.99947
0.999814
0.999936
0.999981
0.999995
0.999999
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999997
0.999988
0.999951
0.999791
0.999135
0.9961
0.97905
0.890451
0.639733
0.358883
0.165604
0.0720638
0.0210999
0.00227267
0.000962838
0.0004973
0.000236061
0.000109495
4.87078e-05
2.37649e-05
1.29911e-05
6.74959e-06
3.63965e-06
3.72292e-06
5.84986e-06
6.92942e-06
6.92709e-06
7.9908e-06
8.78755e-06
8.21352e-06
7.87645e-06
8.48164e-06
9.61293e-06
1.1184e-05
1.38103e-05
1.82296e-05
2.5309e-05
3.54909e-05
5.33001e-05
8.37091e-05
0.00013877
0.000242736
0.000457368
0.000944235
0.0021749
0.00584374
0.0179628
0.0574063
0.178888
0.405896
0.668936
0.871145
0.96867
0.996235
0.998403
0.999366
0.999742
0.999909
0.999967
0.99999
0.999997
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999997
0.999989
0.999961
0.999858
0.99947
0.997892
0.989979
0.95224
0.807823
0.561007
0.315176
0.140022
0.0641552
0.0195888
0.00133195
0.000619995
0.000324065
0.00015961
6.66013e-05
2.52578e-05
1.04144e-05
4.1641e-06
1.8807e-06
7.36179e-07
2.15995e-07
9.90594e-08
4.42591e-08
2.02704e-08
1.29049e-09
1.72113e-09
1.67956e-09
1.70891e-09
2.67673e-09
2.62348e-09
4.3287e-09
7.6633e-09
9.4848e-09
2.47548e-08
4.77957e-08
1.38215e-07
4.40542e-07
1.3848e-06
9.87973e-06
5.29498e-05
0.000481372
0.00572489
0.0598925
0.263481
0.505511
0.757938
0.956821
0.985173
0.997729
0.999717
0.99983
0.99992
0.999979
0.999992
0.999997
0.999999
1
1
1
0.999926
0.919615
0.508677
0.105573
0.0114395
0.00118003
0.000446499
0.00022675
0.000104845
3.40986e-05
1.54087e-05
7.30251e-06
3.69554e-06
1.22406e-06
2.97048e-07
1.49449e-07
1.01626e-07
4.64158e-08
1.80951e-08
5.72358e-09
1.28943e-09
1.71285e-10
1.44468e-11
1.38703e-12
2.29318e-13
1.40135e-13
7.64809e-14
4.43959e-13
5.55741e-13
7.86745e-12
2.09688e-11
6.70506e-11
3.96103e-10
5.7927e-10
3.43986e-09
1.32045e-08
2.21553e-08
1.26629e-07
3.74155e-07
7.75545e-07
3.6033e-06
1.09036e-05
4.6089e-05
0.000181981
0.000839554
0.00506196
0.0270854
0.145964
0.4541
0.775909
0.940954
0.994615
0.997807
0.999243
0.999722
0.999915
0.999974
0.999994
0.999999
1
1
1
1
1
1
1
1
0.999999
0.999998
0.999995
0.999982
0.999931
0.999712
0.998727
0.992912
0.955077
0.767653
0.444405
0.172582
0.0522163
0.00585258
0.00172529
0.000712109
0.00026657
0.000107533
4.88355e-05
2.02244e-05
7.99427e-06
3.05284e-06
1.32626e-06
6.42887e-07
2.9413e-07
2.15505e-07
2.38287e-07
1.78334e-07
1.93555e-07
2.40814e-07
2.12365e-07
2.03626e-07
2.06448e-07
2.28271e-07
2.64343e-07
3.19438e-07
4.17956e-07
5.34671e-07
7.25724e-07
1.049e-06
1.52287e-06
2.20875e-06
3.43631e-06
5.66728e-06
9.18111e-06
1.6273e-05
3.20463e-05
6.7689e-05
0.00014996
0.00035071
0.000896686
0.0025851
0.00888195
0.0356662
0.148607
0.419193
0.728167
0.914739
0.989105
0.997315
0.99907
0.999652
0.99989
0.999966
0.999991
0.999998
1
1
1
1
1
1
1
0.999999
0.999999
0.999997
0.999992
0.999977
0.99993
0.999774
0.999157
0.996278
0.980111
0.892386
0.622505
0.301721
0.107455
0.0228221
0.0028249
0.00116368
0.00049306
0.000188182
7.88257e-05
3.08536e-05
1.03523e-05
3.50051e-06
1.36013e-06
5.06684e-07
3.40246e-07
2.57529e-07
2.24635e-07
1.98497e-07
1.89085e-07
2.19583e-07
2.22174e-07
2.59687e-07
3.15817e-07
3.76812e-07
4.90319e-07
6.09493e-07
7.54955e-07
1.03662e-06
1.52953e-06
2.24614e-06
3.15036e-06
4.63036e-06
6.90818e-06
1.01101e-05
1.50167e-05
2.36407e-05
3.88829e-05
6.58585e-05
0.000118041
0.000222124
0.000452825
0.00100561
0.00252563
0.00751787
0.0265206
0.101465
0.328032
0.633036
0.873991
0.977005
0.99627
0.99869
0.999533
0.999858
0.999959
0.99999
0.999998
1
1
1
1
1
1
1
1
0.999999
0.999997
0.99999
0.999962
0.999842
0.999287
0.996245
0.975746
0.858838
0.562502
0.254044
0.0877178
0.015764
0.00231066
0.000983416
0.000433356
0.000169262
7.8415e-05
3.73272e-05
1.61661e-05
6.82652e-06
2.70634e-06
1.12805e-06
5.40719e-07
2.49765e-07
1.77226e-07
1.52851e-07
1.71394e-07
2.13103e-07
2.08002e-07
2.04049e-07
2.56439e-07
2.66454e-07
2.42799e-07
2.63536e-07
2.97737e-07
3.38852e-07
4.23048e-07
5.37909e-07
7.77677e-07
1.1064e-06
1.62954e-06
2.56247e-06
4.29429e-06
7.64034e-06
1.46729e-05
3.01822e-05
6.71338e-05
0.00016326
0.000433334
0.00124774
0.00406092
0.0152414
0.062771
0.24236
0.532484
0.811747
0.945137
0.995098
0.99799
0.99928
0.999727
0.999915
0.999974
0.999993
0.999998
1
1
1
1
1
1
1
0.999999
0.999999
0.999998
0.999994
0.999982
0.999941
0.999792
0.99921
0.996479
0.980742
0.898464
0.649678
0.357984
0.140976
0.0490874
0.00628847
0.00141793
0.000626188
0.000250327
9.85608e-05
3.95472e-05
1.831e-05
8.04119e-06
2.90125e-06
9.64187e-07
3.48107e-07
1.17009e-07
4.6541e-08
1.55869e-08
3.63589e-09
1.43458e-09
5.59579e-10
1.95531e-10
6.04831e-12
7.50347e-12
6.36813e-12
5.29945e-12
6.87658e-12
5.39216e-12
8.02714e-12
1.15561e-11
1.01379e-11
2.17729e-11
3.18835e-11
6.25388e-11
1.60193e-10
3.30539e-10
1.53575e-09
4.93982e-09
1.335e-08
1.17464e-07
6.76867e-07
8.44923e-06
0.000191803
0.00423434
0.0900107
0.346407
0.629105
0.908956
0.986354
0.99669
0.999747
0.999901
0.999963
0.999991
0.999999
0.999997
0.916865
0.46368
0.055742
0.00425047
0.000640757
0.000322103
0.000137606
4.79287e-05
2.2336e-05
9.89174e-06
2.95395e-06
1.1818e-06
5.11158e-07
2.44244e-07
7.15397e-08
1.50817e-08
6.88051e-09
4.2965e-09
1.74617e-09
5.84583e-10
1.52724e-10
2.70018e-11
2.77525e-12
3.29873e-13
1.39546e-13
9.87018e-14
1.10319e-15
1.34035e-15
7.59456e-15
4.54999e-15
1.50649e-13
3.75363e-13
9.626e-13
5.90153e-12
2.37395e-12
4.72965e-11
1.88628e-10
1.81469e-10
2.16388e-09
6.64697e-09
1.1754e-08
6.82487e-08
1.86576e-07
8.1469e-07
2.86525e-06
1.08604e-05
6.9536e-05
0.000306809
0.00190359
0.0141189
0.0911038
0.391024
0.742416
0.9304
0.994096
0.997862
0.999308
0.999771
0.999937
0.999985
0.999996
0.999999
0.999999
0.999999
0.999999
0.999999
0.999998
0.999996
0.999992
0.999978
0.999928
0.999733
0.998846
0.993725
0.956178
0.748021
0.405347
0.142852
0.0313166
0.00376247
0.00150656
0.000527137
0.000201154
7.85715e-05
2.69866e-05
9.45612e-06
3.91163e-06
1.48063e-06
5.31285e-07
1.78313e-07
6.72048e-08
2.86699e-08
1.14314e-08
8.08665e-09
8.69153e-09
5.77545e-09
4.95555e-09
6.67878e-09
5.9729e-09
5.94346e-09
5.90126e-09
6.40532e-09
7.59717e-09
9.10305e-09
1.20041e-08
1.50096e-08
1.93585e-08
2.86255e-08
4.25467e-08
5.92264e-08
9.24684e-08
1.61913e-07
2.66117e-07
4.66619e-07
9.207e-07
1.97495e-06
4.38839e-06
1.03379e-05
2.68971e-05
7.51204e-05
0.000224602
0.00074029
0.0029691
0.0153003
0.0849124
0.341919
0.681945
0.904008
0.987468
0.997351
0.999118
0.999702
0.999916
0.99998
0.999994
0.999996
0.999997
0.999997
0.999997
0.999997
0.999994
0.999991
0.999983
0.999961
0.999892
0.999669
0.998885
0.995499
0.975115
0.861914
0.566459
0.253327
0.0805219
0.0103953
0.00244315
0.000961281
0.000356454
0.000136996
5.69339e-05
1.91221e-05
7.24646e-06
2.63245e-06
7.92609e-07
2.2732e-07
7.53521e-08
2.39211e-08
1.64281e-08
1.06567e-08
7.58176e-09
5.96721e-09
4.97093e-09
5.84566e-09
5.48055e-09
6.42096e-09
8.2267e-09
1.01629e-08
1.34595e-08
1.71155e-08
2.0918e-08
2.76741e-08
4.01359e-08
6.02319e-08
8.41629e-08
1.2298e-07
1.86119e-07
2.74492e-07
4.10333e-07
6.69473e-07
1.1337e-06
1.90545e-06
3.39266e-06
6.38122e-06
1.32503e-05
2.98219e-05
7.34761e-05
0.000194752
0.000569613
0.00197521
0.00905233
0.0493858
0.245547
0.585408
0.867726
0.979171
0.996688
0.998957
0.99967
0.999916
0.99998
0.999996
0.999999
0.999999
0.999999
0.999999
0.999999
0.999998
0.999995
0.999988
0.999963
0.999865
0.999437
0.997238
0.980206
0.856724
0.524388
0.206707
0.0603852
0.00633209
0.00206176
0.000755866
0.000272187
0.000104365
4.40291e-05
1.53784e-05
6.29379e-06
2.7565e-06
1.09122e-06
4.16888e-07
1.47523e-07
5.32801e-08
2.23032e-08
9.15974e-09
6.45547e-09
4.6643e-09
4.34748e-09
5.68242e-09
5.766e-09
5.23103e-09
6.85699e-09
7.89815e-09
6.98661e-09
7.84674e-09
8.87639e-09
9.69164e-09
1.19722e-08
1.41633e-08
2.14145e-08
3.19992e-08
4.49305e-08
7.10764e-08
1.23007e-07
2.24978e-07
4.44238e-07
9.13721e-07
1.98344e-06
4.85736e-06
1.29828e-05
3.77214e-05
0.000115512
0.000361718
0.00125443
0.0054952
0.0289031
0.14539
0.436776
0.751758
0.924272
0.990621
0.997779
0.999269
0.999752
0.999924
0.999981
0.999993
0.999995
0.999996
0.999996
0.999997
0.999996
0.999995
0.999992
0.999983
0.999962
0.999897
0.999681
0.998864
0.994912
0.971033
0.841484
0.539239
0.234664
0.0789861
0.0126681
0.00222866
0.000891812
0.000340376
0.000136128
5.3958e-05
2.00352e-05
7.22898e-06
2.52822e-06
1.03761e-06
4.05373e-07
1.2689e-07
3.7069e-08
1.16595e-08
3.31706e-09
1.15319e-09
3.28991e-10
6.2066e-11
2.08385e-11
7.03153e-12
1.57685e-12
1.35111e-13
7.77726e-14
5.43336e-14
4.95294e-14
4.56652e-14
3.84207e-14
4.96031e-14
4.17579e-14
3.39744e-14
6.87127e-14
6.11819e-14
8.04268e-14
1.33474e-13
1.96062e-13
6.56095e-13
1.55565e-12
2.71237e-12
1.89311e-11
7.3248e-11
3.7814e-10
3.17029e-09
1.71429e-08
3.50539e-07
8.55787e-06
0.000396279
0.0267693
0.251997
0.551128
0.853719
0.991353
0.997569
0.99988
0.999986
0.489299
0.0536974
0.00175859
0.000374492
0.000234382
8.38811e-05
3.90819e-05
1.60058e-05
5.17035e-06
2.21883e-06
9.31395e-07
2.57205e-07
9.18042e-08
3.62431e-08
1.61531e-08
4.21175e-09
7.816e-10
3.21808e-10
1.8263e-10
6.61328e-11
1.92263e-11
4.32523e-12
7.72182e-13
1.74777e-13
1.03762e-13
1.42995e-14
6.15977e-16
4.4078e-18
4.93569e-17
2.30731e-16
4.45783e-17
5.52349e-15
1.53874e-14
4.13546e-14
2.26597e-13
7.8817e-14
1.37951e-12
3.01573e-12
2.06967e-12
3.97828e-11
1.0822e-10
2.49424e-10
1.47895e-09
4.10049e-09
1.90343e-08
5.84976e-08
2.24344e-07
1.50652e-06
5.20244e-06
3.09716e-05
0.000218006
0.00120316
0.0099563
0.0745835
0.357981
0.729016
0.922266
0.990429
0.998021
0.999395
0.99983
0.999938
0.999972
0.999986
0.999987
0.999985
0.999981
0.999972
0.999946
0.999875
0.999646
0.998749
0.994123
0.961164
0.765494
0.407362
0.132807
0.0250475
0.00401616
0.00156611
0.000550643
0.000210312
6.82933e-05
2.35721e-05
8.61516e-06
2.6858e-06
8.30601e-07
3.12846e-07
1.07895e-07
3.51887e-08
1.04354e-08
3.43255e-09
1.29945e-09
4.77615e-10
2.70878e-10
3.08329e-10
1.83499e-10
1.51935e-10
2.05568e-10
1.91337e-10
2.16022e-10
2.07212e-10
2.16075e-10
2.55808e-10
3.00903e-10
3.8263e-10
4.46501e-10
5.16094e-10
7.57487e-10
1.11571e-09
1.49614e-09
2.36495e-09
4.25469e-09
6.99893e-09
1.21102e-08
2.40047e-08
5.33545e-08
1.20167e-07
2.85946e-07
7.571e-07
2.11914e-06
6.35204e-06
2.1336e-05
8.22983e-05
0.000341192
0.00157791
0.00952712
0.0648793
0.316493
0.668677
0.894929
0.981976
0.997477
0.999206
0.999768
0.999887
0.999926
0.999955
0.999962
0.999962
0.999952
0.999926
0.99988
0.999758
0.999373
0.998133
0.992915
0.964374
0.824724
0.519495
0.213979
0.0630738
0.0074461
0.00262068
0.00095424
0.000346431
0.000132704
4.50773e-05
1.6076e-05
6.41138e-06
1.93201e-06
6.62924e-07
2.22247e-07
6.02957e-08
1.48556e-08
4.20903e-09
1.14352e-09
7.23252e-10
4.36914e-10
2.75393e-10
1.93625e-10
1.67856e-10
1.97835e-10
1.79845e-10
2.0316e-10
2.53453e-10
3.14244e-10
3.93258e-10
4.89705e-10
5.81307e-10
7.3323e-10
1.05292e-09
1.53061e-09
1.96821e-09
2.74629e-09
4.36167e-09
6.65596e-09
1.00652e-08
1.69438e-08
2.96459e-08
5.02971e-08
9.00498e-08
1.71471e-07
3.61278e-07
8.08539e-07
1.97811e-06
5.23968e-06
1.5718e-05
5.46661e-05
0.00021291
0.000925427
0.00514664
0.036453
0.233411
0.606443
0.885921
0.984921
0.997461
0.999293
0.999809
0.999948
0.999979
0.999985
0.999986
0.999986
0.999983
0.999969
0.999935
0.999825
0.999402
0.997507
0.984595
0.888602
0.558977
0.20697
0.0506297
0.00553789
0.00217289
0.000757125
0.000287733
0.000100774
3.22687e-05
1.11375e-05
4.41001e-06
1.38511e-06
5.04039e-07
2.03048e-07
7.37194e-08
2.53332e-08
8.01027e-09
2.53992e-09
9.36731e-10
3.62538e-10
2.03656e-10
1.34998e-10
1.1075e-10
1.64676e-10
1.78878e-10
1.64024e-10
2.18804e-10
2.62296e-10
2.27756e-10
2.67904e-10
2.97125e-10
3.1402e-10
3.74404e-10
3.94703e-10
5.8015e-10
8.7218e-10
1.2103e-09
1.93407e-09
3.26372e-09
6.03694e-09
1.21903e-08
2.55757e-08
5.64549e-08
1.38892e-07
3.71204e-07
1.08518e-06
3.35495e-06
1.05679e-05
3.68229e-05
0.000145737
0.000605182
0.0028591
0.0169031
0.09989
0.370707
0.696141
0.899068
0.98149
0.997721
0.999214
0.9997
0.999863
0.999911
0.999938
0.999949
0.99995
0.999945
0.999924
0.999869
0.999731
0.999339
0.997968
0.991772
0.957429
0.787204
0.468622
0.175926
0.0491603
0.00444378
0.00187821
0.000719949
0.000270161
0.000100241
3.62459e-05
1.30789e-05
4.66373e-06
1.60321e-06
5.27161e-07
1.62029e-07
5.89826e-08
2.04661e-08
5.57526e-09
1.43413e-09
3.92243e-10
9.50807e-11
2.90446e-11
7.25159e-12
1.35346e-12
5.5869e-13
2.99008e-13
1.49548e-13
4.42808e-15
1.41419e-15
8.98682e-16
7.34536e-16
5.20922e-16
4.79386e-16
5.71236e-16
3.74915e-16
3.54154e-16
4.63695e-16
3.84048e-16
5.08327e-16
5.13472e-16
6.46295e-16
1.27565e-15
1.38407e-15
2.20013e-15
7.30133e-15
1.12711e-14
3.88611e-14
1.66566e-13
6.21728e-13
5.69424e-12
4.5889e-11
8.32592e-13
2.85011e-09
3.63487e-07
4.80023e-06
0.00479464
0.169501
0.462004
0.746031
0.974458
0.000325121
0.000151953
0.000141427
5.07952e-05
3.15916e-05
1.09273e-05
4.7565e-06
1.85806e-06
5.59972e-07
2.21926e-07
8.76472e-08
2.2503e-08
7.21234e-09
2.59898e-09
1.07054e-09
2.49922e-10
4.13966e-11
1.54121e-11
7.99547e-12
2.71426e-12
8.15561e-13
2.85655e-13
1.31418e-13
5.52076e-14
3.13339e-15
1.66471e-16
4.16649e-18
3.28335e-20
2.39359e-18
9.27198e-18
2.44625e-18
3.3049e-16
7.80061e-16
3.00621e-15
1.34898e-14
2.36746e-14
1.32883e-13
1.71211e-13
2.85936e-13
1.4418e-12
1.9081e-12
6.09188e-12
3.18575e-11
9.69789e-11
4.83132e-10
1.16304e-09
6.11837e-09
3.72045e-08
9.97558e-08
7.53968e-07
4.97673e-06
2.40942e-05
0.000179988
0.00101804
0.00799881
0.0729115
0.339858
0.683394
0.896793
0.977406
0.998167
0.999195
0.999439
0.99968
0.99976
0.99974
0.999682
0.999512
0.999045
0.997627
0.9917
0.959049
0.783306
0.434483
0.14476
0.0273389
0.00440627
0.00171853
0.000656448
0.000250843
8.19819e-05
2.94438e-05
8.77755e-06
2.76277e-06
9.40838e-07
2.65614e-07
7.32329e-08
2.5113e-08
7.86877e-09
2.3347e-09
6.17436e-10
1.82638e-10
7.25213e-11
5.18575e-11
5.85102e-11
6.79612e-11
8.14978e-11
7.78905e-11
7.49461e-11
7.48449e-11
7.49651e-11
7.60867e-11
7.73058e-11
8.01956e-11
8.31512e-11
8.73917e-11
9.02231e-11
9.22122e-11
1.01754e-10
1.12314e-10
1.22156e-10
1.44343e-10
1.94333e-10
2.68079e-10
4.04638e-10
7.24978e-10
1.50767e-09
3.18656e-09
7.61392e-09
2.09983e-08
6.04737e-08
1.8139e-07
5.98058e-07
2.31314e-06
9.8485e-06
4.54758e-05
0.000226325
0.00121346
0.008297
0.0614034
0.298073
0.626808
0.862885
0.962928
0.9965
0.998749
0.998825
0.999198
0.999383
0.999372
0.999205
0.998832
0.997935
0.994889
0.984035
0.938403
0.758479
0.459064
0.184315
0.0516205
0.00561308
0.00247868
0.000984487
0.000421776
0.000148015
4.97379e-05
1.82109e-05
5.6671e-06
1.88117e-06
7.11647e-07
1.95071e-07
6.06828e-08
1.86889e-08
4.57737e-09
9.80109e-10
2.41142e-10
6.3541e-11
4.43053e-11
3.10234e-11
4.16855e-11
6.43477e-11
6.43064e-11
6.92958e-11
7.43379e-11
7.71375e-11
8.03458e-11
8.51331e-11
8.84064e-11
9.32102e-11
9.81224e-11
1.05144e-10
1.17967e-10
1.32612e-10
1.40639e-10
1.56684e-10
1.99492e-10
2.58299e-10
3.45823e-10
5.33769e-10
8.79341e-10
1.4112e-09
2.41579e-09
4.55072e-09
9.72348e-09
2.22593e-08
5.4694e-08
1.43421e-07
4.26976e-07
1.48065e-06
5.89698e-06
2.64004e-05
0.000127803
0.000675598
0.0046611
0.0414373
0.274524
0.651007
0.896881
0.984676
0.998188
0.999147
0.999624
0.999753
0.999792
0.999786
0.999726
0.999528
0.998926
0.996637
0.984033
0.904518
0.609163
0.248833
0.0625625
0.00671072
0.00262259
0.000924616
0.000347787
0.00011417
4.06365e-05
1.3332e-05
3.81313e-06
1.19463e-06
4.3874e-07
1.24718e-07
4.05561e-08
1.5003e-08
5.00022e-09
1.54527e-09
4.41406e-10
1.29952e-10
5.13158e-11
3.95904e-11
4.70275e-11
6.04511e-11
7.49862e-11
7.0653e-11
6.80415e-11
6.79428e-11
6.79996e-11
7.13496e-11
7.23292e-11
7.4369e-11
7.6395e-11
7.72619e-11
8.0296e-11
8.17439e-11
8.73652e-11
9.59183e-11
1.05697e-10
1.25884e-10
1.59493e-10
2.39708e-10
4.28814e-10
8.43787e-10
1.76279e-09
4.0797e-09
1.05344e-08
3.10263e-08
9.78248e-08
3.03138e-07
1.04314e-06
4.23281e-06
1.81103e-05
8.19669e-05
0.000380556
0.00186512
0.0113455
0.0715369
0.30824
0.620008
0.848951
0.949648
0.991915
0.998532
0.998523
0.998849
0.999104
0.999164
0.999053
0.998634
0.997449
0.993822
0.980268
0.920841
0.711535
0.40402
0.148135
0.0359232
0.00419729
0.00180007
0.000644429
0.000260772
9.63982e-05
3.29603e-05
1.13489e-05
3.83077e-06
1.25575e-06
4.03956e-07
1.28214e-07
3.82911e-08
1.04113e-08
3.36336e-09
1.03553e-09
2.46582e-10
5.61123e-11
1.36917e-11
3.06716e-12
1.04851e-12
4.28633e-13
1.93947e-13
1.50226e-13
1.55999e-13
5.55526e-15
7.85662e-17
3.53238e-17
1.9633e-17
1.72726e-17
8.55576e-18
7.77839e-18
7.75073e-18
3.35052e-18
4.28663e-18
4.12693e-18
2.49098e-18
3.83799e-18
2.06375e-18
2.10909e-18
4.0032e-18
2.47966e-18
4.08675e-18
8.52206e-18
5.91682e-18
1.79822e-17
2.44182e-17
3.83945e-17
1.98525e-16
3.5857e-16
8.08842e-16
1.23627e-14
3.26975e-14
8.20124e-16
1.44044e-11
3.80111e-14
1.69613e-14
3.34104e-05
0.0434869
1.53902e-05
1.87812e-05
1.96926e-05
6.85454e-06
4.21804e-06
1.41483e-06
5.79543e-07
2.1535e-07
6.08522e-08
2.23213e-08
8.25339e-09
1.97763e-09
5.7213e-10
1.88218e-10
7.1251e-11
1.50549e-11
2.39323e-12
9.13565e-13
5.10841e-13
2.67213e-13
1.49255e-13
9.21944e-14
1.99711e-14
1.17992e-15
5.08087e-17
1.9769e-18
3.30439e-20
1.08483e-21
1.71629e-19
3.22631e-19
4.59743e-19
2.71652e-17
3.42296e-17
2.81994e-16
9.64251e-16
3.86273e-15
1.51389e-14
1.44098e-14
5.91173e-14
1.79257e-13
1.57933e-13
5.41038e-13
1.39313e-12
3.08134e-12
1.31242e-11
2.15023e-11
1.4711e-10
8.67535e-10
1.77667e-09
1.81944e-08
1.16526e-07
5.31259e-07
4.39588e-06
2.09564e-05
0.000141885
0.00115339
0.00756349
0.0575603
0.28145
0.578166
0.814786
0.916617
0.965752
0.987113
0.993031
0.993451
0.992012
0.986582
0.969781
0.913795
0.729309
0.431744
0.161036
0.0347328
0.00487883
0.00198548
0.000781703
0.000303252
0.000110138
4.03399e-05
1.22418e-05
4.10461e-06
1.12189e-06
3.24622e-07
1.02595e-07
2.62351e-08
6.49319e-09
2.02772e-09
5.77175e-10
1.57671e-10
4.12203e-11
1.56047e-11
1.62293e-11
3.4519e-11
5.1866e-11
6.50619e-11
8.07166e-11
9.28704e-11
9.82665e-11
1.07144e-10
1.10603e-10
1.15458e-10
1.19253e-10
1.20689e-10
1.24126e-10
1.259e-10
1.27692e-10
1.28862e-10
1.27756e-10
1.27099e-10
1.26846e-10
1.27639e-10
1.28214e-10
1.28747e-10
1.29598e-10
1.30559e-10
1.40271e-10
1.80292e-10
2.98055e-10
6.79336e-10
1.82095e-09
5.28566e-09
1.67627e-08
6.57999e-08
2.86761e-07
1.33211e-06
6.74795e-06
3.65975e-05
0.000209551
0.0011939
0.00762114
0.0497716
0.240915
0.529778
0.765585
0.88499
0.944539
0.972521
0.98332
0.984709
0.981296
0.969049
0.93354
0.826741
0.622401
0.364325
0.148988
0.0396409
0.00470496
0.00217074
0.000939219
0.000421219
0.000164582
6.87486e-05
2.28979e-05
7.12891e-06
2.47651e-06
7.10714e-07
2.20208e-07
7.83502e-08
1.97112e-08
5.56789e-09
1.57053e-09
3.4841e-10
6.85233e-11
1.7944e-11
1.14418e-11
1.28081e-11
1.83185e-11
4.08047e-11
6.52381e-11
9.21343e-11
1.09192e-10
1.27606e-10
1.32415e-10
1.33123e-10
1.34214e-10
1.35669e-10
1.37226e-10
1.3981e-10
1.42151e-10
1.42327e-10
1.42678e-10
1.43193e-10
1.44196e-10
1.45417e-10
1.46687e-10
1.48117e-10
1.49942e-10
1.52067e-10
1.66602e-10
1.94506e-10
2.49967e-10
3.8781e-10
7.36767e-10
1.63299e-09
4.05637e-09
1.16675e-08
4.00766e-08
1.64004e-07
7.47519e-07
3.56294e-06
1.89019e-05
0.000114632
0.000758734
0.0061667
0.0550315
0.306744
0.650059
0.870245
0.960982
0.992403
0.995404
0.995884
0.995837
0.99424
0.988715
0.968735
0.879847
0.616474
0.281683
0.0821884
0.0103521
0.00321979
0.0012373
0.000478153
0.000159124
5.63719e-05
1.72897e-05
5.73152e-06
1.74927e-06
4.50591e-07
1.28963e-07
4.35682e-08
1.12653e-08
3.28937e-09
1.11657e-09
3.42783e-10
9.827e-11
3.01132e-11
1.37095e-11
1.37587e-11
2.71832e-11
4.24054e-11
5.88271e-11
7.43898e-11
7.8547e-11
8.89176e-11
9.41027e-11
9.42845e-11
9.65531e-11
1.00212e-10
1.01038e-10
1.03012e-10
1.07035e-10
1.09271e-10
1.10433e-10
1.0979e-10
1.09828e-10
1.09892e-10
1.10123e-10
1.10588e-10
1.11219e-10
1.1202e-10
1.1312e-10
1.38875e-10
2.02306e-10
3.84791e-10
1.00059e-09
3.0672e-09
9.14878e-09
3.08858e-08
1.31095e-07
5.76627e-07
2.6332e-06
1.20887e-05
5.54165e-05
0.000267822
0.00138199
0.00821167
0.0484336
0.213712
0.47063
0.696956
0.841596
0.912373
0.952106
0.972687
0.976405
0.972084
0.95587
0.908301
0.777898
0.561854
0.30212
0.115695
0.0257654
0.00361845
0.00165486
0.000657511
0.000281902
9.53013e-05
3.66156e-05
1.28304e-05
4.02014e-06
1.28786e-06
4.02457e-07
1.20431e-07
3.50608e-08
1.0249e-08
2.77434e-09
6.71204e-10
1.92868e-10
5.28105e-11
1.14603e-11
2.54188e-12
7.80913e-13
3.27254e-13
2.03563e-13
1.49422e-13
4.99331e-14
1.32751e-14
2.86661e-15
5.73193e-17
2.06414e-18
9.31008e-19
3.82412e-19
3.29137e-19
1.24805e-19
1.32671e-19
9.63234e-20
2.72823e-20
3.7468e-20
1.87686e-20
7.1341e-21
8.11675e-21
3.61691e-21
2.89216e-21
4.16078e-21
1.39084e-21
1.60508e-21
1.54346e-21
5.40018e-22
1.01111e-21
5.91476e-22
3.59493e-22
7.13594e-22
3.02711e-22
2.78006e-22
3.52956e-22
1.60826e-22
2.68358e-22
3.50833e-22
2.36201e-22
4.92848e-23
3.09615e-23
8.32428e-26
1.63707e-06
2.29584e-06
2.6769e-06
9.17458e-07
5.57912e-07
1.82088e-07
7.06046e-08
2.49281e-08
6.63175e-09
2.25598e-09
7.78273e-10
1.74434e-10
4.58461e-11
1.38208e-11
4.88524e-12
1.05189e-12
2.94811e-13
1.69682e-13
1.24906e-13
1.61112e-13
3.66495e-14
6.67327e-15
5.957e-16
2.59563e-17
8.60764e-19
2.41348e-20
3.47043e-22
1.78403e-22
1.03427e-20
1.28285e-20
1.17073e-19
1.74537e-18
1.6537e-18
2.63288e-17
8.56771e-17
2.83469e-16
1.74611e-15
2.02203e-15
9.81327e-15
2.54075e-14
2.90917e-14
1.07415e-13
2.62444e-13
4.871e-13
1.21623e-12
1.42685e-12
3.97392e-12
1.74499e-11
2.7288e-11
3.25477e-10
1.98565e-09
8.62089e-09
8.34687e-08
3.65056e-07
2.87049e-06
2.39882e-05
0.000121704
0.000828214
0.00565675
0.0326109
0.142239
0.345639
0.529601
0.666887
0.739841
0.752042
0.724293
0.637647
0.490723
0.300065
0.133739
0.0358263
0.00442237
0.00237038
0.000920553
0.000372283
0.000143493
5.40358e-05
1.86061e-05
6.46351e-06
1.82548e-06
5.70753e-07
1.43166e-07
3.82649e-08
1.11882e-08
2.59613e-09
5.80402e-10
1.66913e-10
4.4788e-11
1.25748e-11
7.20905e-12
6.9339e-12
1.3082e-11
3.3903e-11
5.51092e-11
7.12103e-11
9.00622e-11
1.05023e-10
1.12042e-10
1.19594e-10
1.23663e-10
1.26165e-10
1.30279e-10
1.31728e-10
1.37957e-10
1.42734e-10
1.47356e-10
1.48617e-10
1.48512e-10
1.47744e-10
1.4695e-10
1.45853e-10
1.46651e-10
1.48987e-10
1.50879e-10
1.50932e-10
1.50569e-10
1.51708e-10
1.52876e-10
1.5399e-10
1.60405e-10
2.52127e-10
5.62106e-10
2.17883e-09
8.89342e-09
3.94121e-08
1.98827e-07
1.09371e-06
6.49295e-06
3.74799e-05
0.000207845
0.00109455
0.00606885
0.0325451
0.130241
0.319403
0.494671
0.608403
0.651995
0.650182
0.621148
0.518461
0.36331
0.197372
0.0885659
0.0219678
0.0033844
0.00227349
0.000865829
0.000374808
0.000163577
7.28446e-05
2.76553e-05
1.11693e-05
3.51885e-06
1.01836e-06
3.34862e-07
8.90907e-08
2.58225e-08
8.58873e-09
1.99473e-09
5.13729e-10
1.34281e-10
2.81919e-11
8.1723e-12
5.34292e-12
7.03655e-12
9.53652e-12
1.5281e-11
3.89066e-11
6.94873e-11
1.00563e-10
1.23308e-10
1.43291e-10
1.48928e-10
1.4898e-10
1.51759e-10
1.55235e-10
1.60479e-10
1.67242e-10
1.75794e-10
1.81824e-10
1.92059e-10
1.94543e-10
1.94259e-10
1.93431e-10
1.92886e-10
1.95996e-10
1.97536e-10
1.98225e-10
1.97533e-10
1.9836e-10
2.00241e-10
2.02159e-10
2.04548e-10
2.06493e-10
2.56915e-10
4.53587e-10
1.25457e-09
4.95147e-09
2.20678e-08
1.0109e-07
5.20071e-07
3.16659e-06
2.14781e-05
0.000150537
0.00104796
0.00800466
0.0579116
0.262651
0.530119
0.733383
0.840201
0.87555
0.873312
0.826882
0.697187
0.49828
0.253761
0.0892074
0.0139835
0.00332827
0.00169022
0.00062292
0.000237778
8.83691e-05
2.76033e-05
9.1424e-06
2.61831e-06
8.0661e-07
2.28562e-07
5.33616e-08
1.40149e-08
4.33026e-09
1.02381e-09
2.70257e-10
8.70791e-11
2.6331e-11
9.27458e-12
7.63574e-12
8.04708e-12
1.04654e-11
2.48037e-11
4.33116e-11
6.20487e-11
8.07172e-11
8.77543e-11
1.03371e-10
1.03123e-10
1.02964e-10
1.07469e-10
1.09103e-10
1.11762e-10
1.14712e-10
1.19934e-10
1.24428e-10
1.2479e-10
1.24939e-10
1.25271e-10
1.2547e-10
1.25719e-10
1.27555e-10
1.29154e-10
1.29806e-10
1.29513e-10
1.30001e-10
1.31121e-10
1.32291e-10
1.33716e-10
1.85743e-10
3.66324e-10
1.06836e-09
4.69214e-09
1.99756e-08
8.89118e-08
4.00729e-07
1.77471e-06
8.66366e-06
4.53417e-05
0.000230382
0.00110143
0.0051742
0.0231129
0.0819989
0.21049
0.355358
0.46171
0.524988
0.537507
0.505511
0.417923
0.284304
0.153874
0.0646218
0.0122395
0.00254047
0.00152666
0.000573389
0.000273206
0.00010579
4.4423e-05
1.41208e-05
5.14507e-06
1.69471e-06
4.89522e-07
1.46207e-07
4.20991e-08
1.15383e-08
3.04952e-09
8.19475e-10
2.01269e-10
4.42172e-11
1.1669e-11
3.0644e-12
9.55206e-13
3.58279e-13
2.04735e-13
1.80624e-13
4.87679e-14
1.09259e-14
1.83569e-15
3.54945e-16
4.60717e-17
7.10194e-19
8.64438e-20
3.78378e-20
1.36129e-20
9.05795e-21
3.2132e-21
2.54099e-21
1.18414e-21
3.22864e-22
3.17508e-22
1.21336e-22
3.51397e-23
2.78102e-23
8.18557e-24
3.36889e-24
1.76675e-24
4.40839e-25
2.52123e-25
6.42207e-26
4.81882e-26
5.51622e-26
6.05167e-27
9.82002e-27
9.87362e-27
1.8211e-27
9.63193e-28
1.17184e-28
2.46445e-28
1.18809e-28
7.89003e-29
7.59864e-29
2.99429e-30
1.8182e-32
2.44896e-35
1.7427e-07
2.77912e-07
3.56345e-07
1.21709e-07
7.31371e-08
2.33001e-08
8.59606e-09
2.88367e-09
7.24324e-10
2.28812e-10
7.35156e-11
1.55319e-11
3.80369e-12
1.15557e-12
4.55144e-13
1.64028e-13
1.03608e-13
7.47767e-14
3.07572e-14
9.69254e-15
1.84892e-15
2.56587e-16
1.75888e-17
5.88094e-19
1.51305e-20
3.06185e-22
5.22366e-24
2.9738e-23
4.9309e-22
1.63904e-21
1.38128e-20
1.40685e-19
4.97393e-19
3.56862e-18
1.72843e-17
5.70392e-17
3.02745e-16
8.23255e-16
2.69223e-15
7.54529e-15
1.51967e-14
4.31205e-14
1.0154e-13
2.12007e-13
5.39171e-13
8.62673e-13
1.2138e-12
2.2884e-12
3.71502e-12
7.98884e-12
2.72274e-11
1.01824e-10
9.28664e-10
3.54556e-09
2.62794e-08
2.1092e-07
1.20196e-06
9.53171e-06
6.45509e-05
0.000339699
0.00162818
0.00694259
0.022773
0.0536302
0.0920628
0.116626
0.115482
0.0894427
0.0454237
0.0113612
0.00312359
0.0023727
0.000924921
0.00036495
0.000165508
7.09772e-05
2.65718e-05
9.61498e-06
3.14179e-06
1.03097e-06
2.71977e-07
7.93055e-08
1.82868e-08
4.5277e-09
1.2224e-09
2.59665e-10
5.46614e-11
1.49095e-11
6.06759e-12
3.02256e-12
3.32641e-12
4.71315e-12
8.77728e-12
2.1648e-11
3.98403e-11
5.62883e-11
6.8818e-11
8.10996e-11
8.60593e-11
8.9857e-11
9.41722e-11
9.13289e-11
9.57041e-11
9.72333e-11
1.07932e-10
1.16545e-10
1.23376e-10
1.33297e-10
1.44823e-10
1.42413e-10
1.3956e-10
1.38602e-10
1.46921e-10
1.55016e-10
1.62199e-10
1.65061e-10
1.67397e-10
1.68792e-10
1.68549e-10
1.6666e-10
1.67208e-10
1.68798e-10
1.70962e-10
2.1111e-10
4.7904e-10
1.58261e-09
6.78108e-09
3.33914e-08
1.89399e-07
1.07442e-06
6.26375e-06
3.47561e-05
0.000177476
0.000838257
0.00357743
0.0136523
0.0373358
0.0721925
0.0961834
0.0980501
0.0883248
0.0558693
0.0212319
0.00427794
0.00288702
0.00169875
0.000624905
0.000278058
0.000132866
6.6286e-05
2.87791e-05
1.26001e-05
4.63383e-06
1.79989e-06
5.37686e-07
1.45264e-07
4.514e-08
1.11796e-08
3.03586e-09
9.41474e-10
2.0596e-10
4.99971e-11
1.30206e-11
4.1441e-12
2.24817e-12
2.92028e-12
5.28633e-12
7.04158e-12
9.99657e-12
2.22676e-11
4.04985e-11
6.17386e-11
8.70879e-11
1.0506e-10
1.23288e-10
1.17548e-10
1.20684e-10
1.24707e-10
1.36972e-10
1.5202e-10
1.65876e-10
1.77381e-10
1.92812e-10
1.98944e-10
2.00178e-10
2.01464e-10
2.03237e-10
2.12275e-10
2.196e-10
2.28696e-10
2.33241e-10
2.36314e-10
2.36287e-10
2.34398e-10
2.32272e-10
2.30749e-10
2.33756e-10
2.3571e-10
2.37991e-10
3.37104e-10
1.09518e-09
4.07821e-09
1.83003e-08
1.00676e-07
6.5185e-07
4.56723e-06
3.19e-05
0.000204595
0.00120058
0.00670819
0.0322173
0.100295
0.195288
0.249727
0.248431
0.202852
0.125527
0.0529022
0.0107741
0.00436743
0.00236492
0.00069054
0.000280151
0.000124018
4.61302e-05
1.63019e-05
4.7889e-06
1.47905e-06
3.96508e-07
1.13435e-07
2.98244e-08
6.33917e-09
1.53471e-09
4.32586e-10
9.69975e-11
2.4241e-11
1.04018e-11
5.07053e-12
3.04876e-12
4.13677e-12
5.73077e-12
7.78101e-12
1.53672e-11
2.9547e-11
4.24019e-11
5.78573e-11
6.38984e-11
8.08505e-11
8.11063e-11
7.24123e-11
7.82718e-11
7.71402e-11
8.14044e-11
8.64941e-11
9.61159e-11
1.04457e-10
1.12808e-10
1.16783e-10
1.15262e-10
1.19551e-10
1.20235e-10
1.28576e-10
1.34165e-10
1.38833e-10
1.42411e-10
1.45178e-10
1.46739e-10
1.47665e-10
1.47271e-10
1.48268e-10
1.49222e-10
1.50294e-10
2.93058e-10
8.7933e-10
3.4389e-09
1.45986e-08
5.88873e-08
2.74675e-07
1.41517e-06
7.49916e-06
3.86879e-05
0.000177175
0.000707693
0.00242617
0.00697828
0.0164451
0.0303656
0.0443681
0.0503717
0.0438023
0.0263612
0.00758588
0.00242475
0.00211583
0.00104546
0.000386396
0.000204376
9.36733e-05
4.55618e-05
1.70901e-05
6.96448e-06
2.08573e-06
7.21165e-07
2.22347e-07
5.94989e-08
1.65957e-08
4.39129e-09
1.10557e-09
2.66379e-10
6.6577e-11
1.53077e-11
3.67637e-12
1.30462e-12
4.59161e-13
2.74185e-13
2.10941e-13
5.29783e-14
1.07854e-14
2.44446e-15
4.16715e-16
6.09287e-17
8.4718e-18
7.44436e-19
3.61251e-20
1.58171e-20
6.78321e-21
2.45502e-21
1.22935e-21
4.51477e-22
2.28639e-22
1.01537e-22
3.29559e-23
2.48551e-23
9.85464e-24
3.12807e-24
1.94725e-24
5.02595e-25
2.21779e-25
8.78044e-26
2.55478e-26
2.02481e-26
4.49397e-27
3.14422e-27
3.28667e-27
3.6624e-28
2.67784e-28
2.59156e-28
5.52742e-29
2.58339e-29
5.09365e-30
5.85279e-30
1.70162e-30
5.42432e-31
2.09829e-31
6.52509e-33
3.34773e-35
3.82195e-38
1.85545e-08
3.33384e-08
4.65722e-08
1.60008e-08
9.51147e-09
2.96649e-09
1.04558e-09
3.33196e-10
7.91817e-11
2.3317e-11
7.00305e-12
1.4859e-12
4.22687e-13
1.97148e-13
1.13383e-13
7.64766e-14
1.71542e-14
6.32799e-15
2.23273e-15
5.68422e-16
9.04773e-17
9.71885e-18
5.18941e-19
1.37125e-20
2.75255e-22
4.09703e-24
5.03069e-25
6.99284e-24
1.01696e-22
7.35046e-22
5.32377e-21
4.72255e-20
2.33253e-19
1.49736e-18
8.08258e-18
3.04032e-17
1.35736e-16
4.53624e-16
1.45262e-15
4.08764e-15
9.37856e-15
2.62081e-14
6.25354e-14
1.38572e-13
3.61571e-13
6.47263e-13
9.72896e-13
1.86773e-12
3.79927e-12
6.32958e-12
1.05721e-11
1.61019e-11
3.80329e-11
8.88893e-11
4.06709e-10
2.5832e-09
1.52623e-08
1.0998e-07
4.33305e-07
8.89878e-07
1.43834e-06
1.40547e-06
2.0348e-06
2.96459e-06
2.88253e-06
2.64516e-06
7.24631e-05
0.000380792
0.000773085
0.000685857
0.000411674
0.000237998
0.00012199
6.73303e-05
3.15911e-05
1.3528e-05
4.91325e-06
1.70304e-06
5.29257e-07
1.63942e-07
4.05063e-08
1.10316e-08
2.34228e-09
5.39772e-10
1.37723e-10
2.74992e-11
8.29684e-12
2.84031e-12
1.06535e-12
1.41731e-12
2.28506e-12
3.36465e-12
5.79802e-12
8.79471e-12
1.55829e-11
2.31221e-11
2.72105e-11
3.5368e-11
3.84341e-11
4.09186e-11
4.43507e-11
4.04458e-11
4.29067e-11
4.53601e-11
5.27689e-11
5.93557e-11
6.48729e-11
7.3312e-11
9.72972e-11
9.52175e-11
9.2341e-11
8.9825e-11
1.0422e-10
1.22685e-10
1.42723e-10
1.56386e-10
1.67178e-10
1.73606e-10
1.77895e-10
1.79862e-10
1.83402e-10
1.84111e-10
1.80541e-10
1.76661e-10
1.78929e-10
2.76365e-10
6.59039e-10
2.27888e-09
1.02927e-08
4.07841e-08
1.84234e-07
6.94745e-07
1.89448e-06
6.49833e-06
1.57037e-05
1.90669e-05
1.86741e-05
2.07825e-05
9.53197e-05
2.96175e-05
0.000137641
0.00102984
0.000905451
0.00055545
0.000289724
0.00015965
7.72539e-05
4.74538e-05
2.33171e-05
1.1752e-05
5.05414e-06
2.16625e-06
7.72698e-07
2.87862e-07
8.18461e-08
2.07212e-08
6.08007e-09
1.40903e-09
3.60048e-10
1.07293e-10
2.32714e-11
8.15772e-12
2.36642e-12
8.05797e-13
1.22999e-12
2.00413e-12
3.4223e-12
4.42783e-12
5.46115e-12
8.31809e-12
1.24208e-11
1.94226e-11
3.36383e-11
4.47753e-11
5.8961e-11
6.02072e-11
6.12437e-11
6.29459e-11
7.39177e-11
8.69576e-11
9.91783e-11
1.11125e-10
1.27797e-10
1.53805e-10
1.54584e-10
1.56664e-10
1.6098e-10
1.81957e-10
2.03583e-10
2.25085e-10
2.36227e-10
2.45133e-10
2.51624e-10
2.54554e-10
2.57386e-10
2.60459e-10
2.59655e-10
2.5357e-10
2.50115e-10
2.53598e-10
2.67033e-10
4.92535e-10
1.5087e-09
5.97347e-09
2.96155e-08
1.70794e-07
1.05736e-06
6.33314e-06
3.46561e-05
0.000141719
0.0003352
0.000466972
0.000590765
0.000620808
0.000253619
0.00100429
0.00270172
0.00283603
0.00148975
0.000647511
0.000289663
0.000119723
5.6534e-05
2.47784e-05
8.92231e-06
2.98766e-06
8.29268e-07
2.38773e-07
6.00798e-08
1.59613e-08
3.89718e-09
7.57633e-10
1.74273e-10
4.57379e-11
1.28324e-11
4.41257e-12
1.76427e-12
1.22466e-12
1.90179e-12
3.12572e-12
3.93094e-12
4.87403e-12
7.979e-12
1.10121e-11
1.49404e-11
2.1795e-11
2.45315e-11
3.44586e-11
3.42295e-11
3.01406e-11
3.26125e-11
3.2262e-11
3.59786e-11
3.93539e-11
4.65723e-11
5.13977e-11
5.9928e-11
6.80741e-11
6.64466e-11
7.34802e-11
7.55036e-11
8.93104e-11
1.03615e-10
1.23063e-10
1.38817e-10
1.47911e-10
1.54024e-10
1.59642e-10
1.62847e-10
1.62957e-10
1.61288e-10
1.59283e-10
1.56424e-10
1.79949e-10
3.65533e-10
1.03796e-09
3.24563e-09
1.25306e-08
4.29976e-08
1.40467e-07
4.91056e-07
1.72308e-06
4.4257e-06
1.32755e-05
2.64401e-05
2.79276e-05
1.83338e-05
1.28056e-05
1.21977e-05
0.000147943
0.000324021
0.000358988
0.000245506
0.000161326
9.35125e-05
5.7905e-05
3.34413e-05
1.5548e-05
7.58755e-06
2.75149e-06
1.08337e-06
3.06803e-07
1.00743e-07
2.9019e-08
7.22312e-09
1.88361e-09
4.58098e-10
1.08104e-10
2.43469e-11
6.52906e-12
1.94858e-12
6.04174e-13
2.74666e-13
3.11399e-13
7.42888e-14
1.76674e-14
3.95557e-15
6.16965e-16
1.14749e-16
1.56616e-17
1.99155e-18
2.40674e-19
3.50852e-20
9.14055e-21
4.31165e-21
1.8458e-21
6.27414e-22
2.71482e-22
9.61992e-23
4.0041e-23
1.63524e-23
5.31031e-24
3.4912e-24
1.25831e-24
3.58586e-25
1.76001e-25
4.69912e-26
1.68323e-26
6.94749e-27
1.57985e-27
9.13581e-28
2.97588e-28
9.97611e-29
8.92007e-29
1.17868e-29
3.61451e-30
3.23183e-30
7.52503e-31
3.53141e-31
7.70988e-32
6.50638e-32
1.9947e-32
3.13534e-33
6.47003e-34
1.60949e-35
6.99771e-38
6.72387e-41
1.97403e-09
3.96614e-09
5.99326e-09
2.08615e-09
1.22855e-09
3.75708e-10
1.26877e-10
3.84492e-11
8.72322e-12
2.45252e-12
7.62797e-13
2.42133e-13
1.07233e-13
1.17901e-13
3.41318e-14
6.27428e-15
1.49665e-15
5.09644e-16
1.55285e-16
3.25636e-17
4.31507e-18
3.64218e-19
1.53832e-20
3.28457e-22
5.18186e-24
6.57594e-26
1.72016e-25
2.48211e-24
3.58003e-23
2.95992e-22
2.25352e-21
1.87535e-20
1.02783e-19
6.51344e-19
3.58105e-18
1.46044e-17
6.33782e-17
2.1811e-16
7.11935e-16
2.08625e-15
5.03506e-15
1.44511e-14
3.47552e-14
7.8199e-14
2.04236e-13
3.7228e-13
6.522e-13
1.28114e-12
2.68799e-12
5.58009e-12
1.20269e-11
1.77415e-11
2.54533e-11
4.59287e-11
9.94801e-11
3.91812e-10
2.34184e-09
1.76258e-08
9.07287e-08
2.50907e-07
5.16966e-07
7.53422e-07
1.65793e-06
3.99846e-06
4.41387e-06
2.6643e-06
2.6488e-06
2.3343e-05
4.63167e-05
4.98199e-05
4.31729e-05
3.40933e-05
2.10943e-05
1.25168e-05
6.02406e-06
2.56271e-06
9.04331e-07
3.00263e-07
8.89516e-08
2.60298e-08
6.0342e-09
1.53988e-09
3.06003e-10
6.87429e-11
2.0142e-11
5.13285e-12
1.33365e-12
6.07303e-13
6.66004e-13
8.64398e-13
1.36306e-12
2.06636e-12
3.31798e-12
4.57699e-12
5.62634e-12
6.85713e-12
8.50997e-12
1.20151e-11
1.34053e-11
1.5194e-11
1.64386e-11
1.43445e-11
1.51866e-11
1.63853e-11
1.8495e-11
2.22045e-11
2.6116e-11
2.76227e-11
3.60059e-11
3.70043e-11
4.16833e-11
4.57551e-11
5.57478e-11
6.8595e-11
8.58101e-11
1.01473e-10
1.17233e-10
1.32874e-10
1.5034e-10
1.64403e-10
1.84943e-10
1.87684e-10
1.87694e-10
1.7806e-10
1.88262e-10
2.10029e-10
2.64873e-10
4.90385e-10
1.63051e-09
5.91543e-09
3.05241e-08
1.35786e-07
3.6874e-07
1.21945e-06
4.0654e-06
7.41223e-06
1.02663e-05
1.68285e-05
2.9246e-05
2.13166e-05
8.05183e-06
5.27748e-05
4.5842e-05
3.60489e-05
2.5859e-05
1.92963e-05
1.24693e-05
8.1706e-06
4.09929e-06
2.07304e-06
8.82834e-07
3.69627e-07
1.28307e-07
4.57748e-08
1.24414e-08
2.96021e-09
8.22209e-10
1.85693e-10
4.59789e-11
1.69227e-11
4.7105e-12
1.27569e-12
4.9287e-13
6.42246e-13
6.5007e-13
1.1425e-12
2.02017e-12
2.56588e-12
2.98075e-12
4.24222e-12
5.76741e-12
8.17687e-12
1.22264e-11
1.60605e-11
1.92512e-11
2.44619e-11
2.39113e-11
2.45722e-11
3.11229e-11
3.83563e-11
4.62384e-11
5.36445e-11
6.1823e-11
7.58715e-11
8.22236e-11
8.77409e-11
9.3066e-11
1.09895e-10
1.29283e-10
1.53355e-10
1.71442e-10
1.91396e-10
2.12381e-10
2.32488e-10
2.51299e-10
2.6663e-10
2.6734e-10
2.67332e-10
2.65914e-10
2.60232e-10
2.60025e-10
2.83612e-10
4.1858e-10
9.80843e-10
3.56928e-09
1.64739e-08
8.75312e-08
4.36696e-07
1.93576e-06
7.72378e-06
2.10478e-05
2.90455e-05
3.05751e-05
4.53135e-05
2.95038e-05
8.63382e-05
0.000217422
0.000217347
0.000139245
7.17616e-05
4.30016e-05
2.37816e-05
1.14378e-05
4.91778e-06
1.71454e-06
5.43897e-07
1.43326e-07
3.8496e-08
9.1224e-09
2.24941e-09
5.11691e-10
9.5134e-11
2.46347e-11
8.18536e-12
2.22411e-12
8.02933e-13
6.92121e-13
9.90721e-13
1.1024e-12
1.87931e-12
2.40023e-12
2.79978e-12
3.92489e-12
4.78795e-12
5.6264e-12
7.47138e-12
8.4144e-12
1.09654e-11
1.12635e-11
1.09634e-11
1.12358e-11
1.11772e-11
1.26126e-11
1.32619e-11
1.52964e-11
1.66846e-11
1.85655e-11
2.3329e-11
2.51823e-11
3.08392e-11
3.45883e-11
4.34191e-11
5.44664e-11
7.11362e-11
8.86425e-11
1.04583e-10
1.22024e-10
1.40724e-10
1.5731e-10
1.6505e-10
1.64941e-10
1.65024e-10
1.57449e-10
1.65375e-10
1.94442e-10
2.75624e-10
5.55332e-10
1.80541e-09
6.44946e-09
2.42085e-08
8.6651e-08
2.83655e-07
7.4758e-07
1.77847e-06
3.62263e-06
5.9692e-06
9.83101e-06
1.10878e-05
1.02634e-05
1.23246e-05
1.80509e-05
2.12422e-05
1.9281e-05
1.78137e-05
1.29351e-05
9.08262e-06
5.47509e-06
2.58171e-06
1.25239e-06
4.40232e-07
1.67242e-07
4.49547e-08
1.40339e-08
3.77505e-09
8.78007e-10
2.15978e-10
4.97272e-11
1.22794e-11
3.66036e-12
1.06853e-12
3.64032e-13
2.69521e-13
1.22505e-13
3.26335e-14
6.76438e-15
1.40822e-15
2.70826e-16
3.41261e-17
5.26179e-18
6.62908e-19
1.05506e-19
2.27279e-20
7.13017e-21
2.2308e-21
9.60215e-22
3.9372e-22
1.27774e-22
4.85462e-23
1.62907e-23
5.7161e-24
2.22907e-24
7.11738e-25
3.84807e-25
1.37385e-25
3.54516e-26
1.41902e-26
3.99696e-27
1.17535e-27
5.14992e-28
1.00691e-28
3.75535e-29
1.3558e-29
2.82045e-30
1.93383e-30
3.70206e-31
1.08932e-31
6.44318e-32
1.34798e-32
4.49505e-33
1.69932e-33
1.06175e-33
2.57245e-34
4.05812e-35
6.15424e-36
8.72118e-38
3.13901e-40
2.53593e-43
2.09809e-10
4.68482e-10
7.61463e-10
2.69724e-10
1.57533e-10
4.73151e-11
1.53787e-11
4.48248e-12
1.02848e-12
3.33657e-13
1.43186e-13
8.1161e-14
3.96705e-14
1.27152e-14
3.19575e-15
5.24273e-16
1.28829e-16
3.96653e-17
1.04296e-17
1.82577e-18
2.01414e-19
1.35472e-20
4.59478e-22
8.06221e-24
1.01065e-25
3.41668e-27
5.31702e-26
7.7065e-25
1.08174e-23
1.01622e-22
8.43867e-22
6.66977e-21
3.96008e-20
2.5009e-19
1.41306e-18
6.25759e-18
2.68422e-17
9.57042e-17
3.21568e-16
9.82305e-16
2.4981e-15
7.12196e-15
1.7432e-14
3.97276e-14
9.51937e-14
1.77293e-13
3.58551e-13
6.60167e-13
1.1133e-12
2.16349e-12
4.75373e-12
1.08102e-11
1.91625e-11
3.73291e-11
6.24385e-11
1.19161e-10
3.82121e-10
1.77104e-09
8.41954e-09
2.50849e-08
6.06699e-08
2.22185e-07
5.58869e-07
1.41842e-06
2.35886e-06
2.52855e-06
2.62038e-06
3.45738e-06
4.63963e-06
5.54659e-06
5.71381e-06
5.48173e-06
3.7131e-06
2.32154e-06
1.14167e-06
4.81998e-07
1.65615e-07
5.27591e-08
1.49357e-08
4.14038e-09
9.0342e-10
2.22742e-10
4.22159e-11
1.45297e-11
3.81213e-12
9.10097e-13
5.20858e-13
4.38198e-13
2.44657e-13
4.03942e-13
7.73508e-13
1.2131e-12
1.87285e-12
2.58676e-12
3.41044e-12
4.00743e-12
4.85203e-12
6.00104e-12
6.14935e-12
6.35293e-12
6.63766e-12
6.044e-12
6.30749e-12
6.75244e-12
7.33253e-12
8.17305e-12
9.16659e-12
8.93607e-12
1.04748e-11
1.07685e-11
1.36732e-11
1.75886e-11
2.36457e-11
3.14304e-11
4.3162e-11
5.54565e-11
6.83492e-11
8.22707e-11
9.83598e-11
1.15181e-10
1.38302e-10
1.73597e-10
1.72934e-10
1.59102e-10
1.71662e-10
1.87705e-10
2.08296e-10
2.53971e-10
4.11721e-10
9.72397e-10
4.03097e-09
1.55602e-08
5.09826e-08
1.58473e-07
3.655e-07
7.6485e-07
1.41011e-06
2.80966e-06
4.15666e-06
3.47317e-06
2.77868e-06
4.20268e-06
3.98357e-06
3.48589e-06
3.56083e-06
2.9457e-06
2.04447e-06
1.40306e-06
7.17678e-07
3.62986e-07
1.53362e-07
6.26683e-08
2.12556e-08
7.25147e-09
1.89655e-09
4.30218e-10
1.18097e-10
3.22863e-11
1.08141e-11
2.89083e-12
8.43635e-13
4.75446e-13
3.34488e-13
1.79641e-13
2.9801e-13
6.38591e-13
1.13754e-12
1.45923e-12
1.69868e-12
2.34139e-12
3.13409e-12
4.31128e-12
5.80051e-12
7.07536e-12
7.81333e-12
9.19123e-12
9.12277e-12
9.45228e-12
1.0684e-11
1.24782e-11
1.62485e-11
2.00894e-11
2.38383e-11
2.81512e-11
3.49692e-11
4.01308e-11
4.44667e-11
5.56642e-11
6.7722e-11
8.47025e-11
9.8734e-11
1.16089e-10
1.35776e-10
1.57053e-10
1.79952e-10
2.08395e-10
2.58942e-10
2.60394e-10
2.48309e-10
2.52374e-10
2.60235e-10
2.76807e-10
3.09834e-10
4.23886e-10
8.89841e-10
3.23587e-09
1.70942e-08
8.05825e-08
3.11278e-07
9.5126e-07
2.49982e-06
4.78392e-06
8.24378e-06
1.25761e-05
1.13325e-05
1.00807e-05
1.60478e-05
1.72339e-05
1.44031e-05
1.14699e-05
8.18159e-06
4.72973e-06
2.30054e-06
9.67141e-07
3.27284e-07
9.84676e-08
2.4741e-08
6.20584e-09
1.39273e-09
3.23803e-10
7.11797e-11
1.73924e-11
4.94245e-12
1.37823e-12
6.52665e-13
6.45897e-13
3.70499e-13
3.99648e-13
5.82425e-13
1.10081e-12
1.41395e-12
1.5959e-12
2.08061e-12
2.63123e-12
3.213e-12
4.16344e-12
4.44709e-12
5.02863e-12
5.0041e-12
5.00721e-12
4.93764e-12
4.99078e-12
5.43259e-12
5.51483e-12
6.2784e-12
6.47087e-12
6.51109e-12
7.34215e-12
7.34436e-12
9.29433e-12
1.09877e-11
1.55405e-11
2.18045e-11
3.05425e-11
4.15929e-11
5.32097e-11
6.80537e-11
8.46114e-11
1.04122e-10
1.38224e-10
1.54572e-10
1.41479e-10
1.39594e-10
1.52169e-10
1.65381e-10
1.82881e-10
2.27195e-10
3.8089e-10
1.00766e-09
3.72248e-09
1.30206e-08
4.01072e-08
9.90265e-08
2.3116e-07
5.09823e-07
9.40187e-07
1.66446e-06
1.934e-06
1.9918e-06
2.07299e-06
2.18981e-06
2.28497e-06
2.25921e-06
2.3458e-06
1.88487e-06
1.42482e-06
8.90342e-07
4.2659e-07
2.04761e-07
6.9956e-08
2.56487e-08
6.56944e-09
1.95141e-09
4.91245e-10
1.11192e-10
2.61051e-11
8.11382e-12
2.00882e-12
6.07038e-13
3.07998e-13
2.17765e-13
6.28234e-14
1.53242e-14
3.30267e-15
5.87033e-16
1.07163e-16
1.75839e-17
1.92272e-18
2.79693e-19
5.32156e-20
1.66092e-20
5.17363e-21
1.69198e-21
4.93414e-22
1.91388e-22
7.47337e-23
2.36865e-23
7.76942e-24
2.40626e-24
7.35124e-25
2.59367e-25
7.71748e-26
3.54935e-26
1.24166e-26
2.97456e-27
9.95216e-28
2.70282e-28
7.39642e-29
2.96553e-29
5.40453e-30
1.81322e-30
6.00487e-31
1.15372e-31
5.98976e-32
1.30108e-32
4.74889e-33
2.29852e-33
3.66945e-34
9.57894e-35
3.52691e-35
1.49248e-35
3.82715e-36
9.20714e-37
9.99195e-38
1.05019e-39
3.1852e-42
2.1694e-45
2.22564e-11
5.49387e-11
9.56062e-11
3.45726e-11
2.00674e-11
5.95414e-12
1.89942e-12
5.80418e-13
1.88757e-13
8.7009e-14
7.97694e-14
1.94372e-14
4.53052e-15
1.34183e-15
2.97475e-16
4.43942e-17
1.08945e-17
3.00423e-18
6.80646e-19
1.00365e-19
9.233e-21
5.01192e-22
1.38411e-23
2.02161e-25
2.06157e-27
6.95635e-28
1.44303e-26
2.21966e-25
3.07182e-24
3.20351e-23
2.93018e-22
2.29571e-21
1.43711e-20
9.25604e-20
5.42818e-19
2.57993e-18
1.13025e-17
4.25764e-17
1.48663e-16
4.70047e-16
1.26788e-15
3.58583e-15
9.03424e-15
2.13061e-14
4.89706e-14
1.01096e-13
2.11105e-13
3.94039e-13
6.82489e-13
1.23932e-12
2.08659e-12
4.50762e-12
1.01142e-11
1.78088e-11
3.18956e-11
5.52279e-11
1.14078e-10
3.19573e-10
1.11509e-09
3.51788e-09
8.70571e-09
2.67568e-08
7.14503e-08
1.82029e-07
3.64908e-07
4.23976e-07
5.0013e-07
5.78741e-07
6.74166e-07
7.78661e-07
8.4463e-07
8.84019e-07
6.53394e-07
4.27839e-07
2.148e-07
9.00743e-08
3.02021e-08
9.26472e-09
2.51149e-09
6.63068e-10
1.44131e-10
3.95895e-11
1.00443e-11
2.35186e-12
7.57024e-13
4.851e-13
2.44322e-13
1.15194e-13
8.02377e-14
1.97936e-13
4.24192e-13
6.85236e-13
1.0657e-12
1.47122e-12
1.91761e-12
2.21954e-12
2.65544e-12
3.05333e-12
3.02188e-12
3.00921e-12
3.12942e-12
2.88028e-12
3.03607e-12
3.24058e-12
3.45224e-12
3.79309e-12
4.18642e-12
4.25053e-12
4.62205e-12
4.49391e-12
5.11575e-12
5.39002e-12
7.03431e-12
1.00332e-11
1.63282e-11
2.34831e-11
3.25608e-11
4.30201e-11
5.61093e-11
7.09357e-11
8.71844e-11
1.10779e-10
1.18115e-10
1.2926e-10
1.38239e-10
1.53585e-10
1.73255e-10
1.95384e-10
2.31985e-10
3.26409e-10
7.85811e-10
2.60184e-09
8.15329e-09
2.34112e-08
4.77332e-08
1.0595e-07
2.13708e-07
4.53497e-07
5.89015e-07
4.92232e-07
4.93889e-07
5.22132e-07
4.85892e-07
4.43642e-07
4.93334e-07
4.50118e-07
3.34767e-07
2.39541e-07
1.24938e-07
6.31466e-08
2.65346e-08
1.05877e-08
3.52468e-09
1.15235e-09
3.03042e-10
6.7464e-11
2.57803e-11
6.77236e-12
1.80229e-12
6.34878e-13
4.63033e-13
2.24452e-13
8.27358e-14
5.81684e-14
1.39607e-13
3.37433e-13
6.17613e-13
8.23547e-13
9.86693e-13
1.34602e-12
1.80086e-12
2.37118e-12
2.94029e-12
3.47329e-12
3.80308e-12
4.08722e-12
4.13193e-12
4.30846e-12
4.71366e-12
5.28334e-12
6.0391e-12
6.81822e-12
7.50301e-12
8.30518e-12
1.03591e-11
1.21694e-11
1.41625e-11
2.04826e-11
2.70495e-11
3.77436e-11
4.71625e-11
5.95485e-11
7.39363e-11
9.08147e-11
1.09449e-10
1.31594e-10
1.75359e-10
1.96314e-10
1.89138e-10
1.97076e-10
2.21632e-10
2.48066e-10
2.72065e-10
3.1117e-10
4.168e-10
8.79764e-10
3.66658e-09
1.52333e-08
4.93717e-08
1.30513e-07
3.71194e-07
8.93982e-07
1.92214e-06
2.31707e-06
1.96213e-06
1.86246e-06
2.10786e-06
2.1785e-06
2.03915e-06
1.9917e-06
1.55785e-06
9.34592e-07
4.5898e-07
1.88499e-07
6.21208e-08
1.77635e-08
4.27712e-09
1.00508e-09
2.24028e-10
4.99735e-11
1.55585e-11
2.96021e-12
9.32511e-13
5.36239e-13
4.03898e-13
1.76411e-13
1.19313e-13
1.74131e-13
3.11264e-13
6.16769e-13
8.10744e-13
9.15146e-13
1.17751e-12
1.46974e-12
1.79974e-12
2.27678e-12
2.40756e-12
2.61487e-12
2.60165e-12
2.57641e-12
2.5479e-12
2.59114e-12
2.75907e-12
2.76239e-12
3.06743e-12
3.12074e-12
3.20363e-12
3.55463e-12
3.55989e-12
4.14924e-12
4.33473e-12
4.89503e-12
6.38958e-12
9.06696e-12
1.42628e-11
2.03574e-11
2.96678e-11
4.18313e-11
5.70456e-11
7.57492e-11
9.53277e-11
9.86961e-11
1.08323e-10
1.19615e-10
1.35831e-10
1.51706e-10
1.70011e-10
2.00262e-10
2.97684e-10
6.84837e-10
2.03044e-09
5.79714e-09
1.40424e-08
3.19689e-08
7.04306e-08
1.29099e-07
2.33443e-07
2.73914e-07
2.81808e-07
2.93388e-07
2.92523e-07
2.92435e-07
2.91175e-07
3.09715e-07
2.74437e-07
2.2247e-07
1.43687e-07
7.00815e-08
3.31925e-08
1.10565e-08
3.91795e-09
9.61924e-10
2.76e-10
6.74136e-11
1.94747e-11
5.64634e-12
1.219e-12
4.21696e-13
2.72127e-13
1.34236e-13
3.49252e-14
8.51066e-15
1.77756e-15
3.21652e-16
4.91487e-17
7.86577e-18
1.14066e-18
1.32749e-19
2.66352e-20
9.73002e-21
4.04388e-21
1.30953e-21
4.09353e-22
1.18071e-22
4.15065e-23
1.52731e-23
4.8165e-24
1.442e-24
4.1252e-25
1.19378e-25
3.692e-26
9.89295e-27
3.65477e-27
1.23929e-27
3.01083e-28
8.81417e-29
2.38441e-29
6.24709e-30
2.00919e-30
4.18686e-31
1.308e-31
3.87384e-32
8.68099e-33
3.82859e-33
1.05626e-33
3.36097e-34
1.35834e-34
3.01736e-35
7.66654e-36
1.88457e-36
5.94362e-37
1.45332e-37
3.19669e-38
3.8103e-39
4.66445e-41
1.24007e-43
7.12189e-47
2.3558e-12
6.40156e-12
1.18826e-11
4.41148e-12
2.56864e-12
7.87488e-13
2.85515e-13
1.21619e-13
6.08287e-14
3.439e-14
9.26278e-15
2.25047e-15
5.06869e-16
1.38882e-16
2.75258e-17
3.79199e-18
9.04408e-19
2.2226e-19
4.33556e-20
5.41786e-21
4.16765e-22
1.84644e-23
4.20249e-25
5.15904e-27
4.8849e-29
1.73986e-28
3.82798e-27
6.27155e-26
8.89258e-25
1.02401e-23
9.85944e-23
7.91494e-22
5.27604e-21
3.4417e-20
2.09255e-19
1.05318e-18
4.75502e-18
1.91279e-17
6.9513e-17
2.26827e-16
6.44559e-16
1.85548e-15
4.7794e-15
1.1659e-14
2.71197e-14
5.85313e-14
1.24425e-13
2.40574e-13
4.09078e-13
7.24806e-13
1.34782e-12
2.41869e-12
5.85071e-12
1.1296e-11
2.01934e-11
3.37568e-11
5.80437e-11
1.17164e-10
2.50833e-10
6.21386e-10
1.36479e-09
3.76703e-09
1.01021e-08
2.61117e-08
5.46862e-08
6.42975e-08
7.61922e-08
8.83348e-08
1.02748e-07
1.17678e-07
1.28814e-07
1.42389e-07
1.1464e-07
7.83212e-08
4.01466e-08
1.67773e-08
5.49942e-09
1.6344e-09
4.35854e-10
1.14743e-10
3.45901e-11
9.24426e-12
1.70987e-12
5.68646e-13
4.06847e-13
1.79266e-13
5.95266e-14
3.14218e-14
3.04818e-14
9.49435e-14
2.19611e-13
3.70914e-13
5.99207e-13
8.44862e-13
1.09149e-12
1.25429e-12
1.47411e-12
1.57943e-12
1.54516e-12
1.49689e-12
1.56221e-12
1.4403e-12
1.53366e-12
1.62032e-12
1.69344e-12
1.87511e-12
2.06431e-12
2.13482e-12
2.31981e-12
2.24652e-12
2.51807e-12
2.7083e-12
3.09778e-12
3.61242e-12
4.24904e-12
6.01069e-12
9.03202e-12
1.40996e-11
2.19076e-11
3.19159e-11
4.43729e-11
5.78656e-11
7.22323e-11
8.64129e-11
1.0091e-10
1.22257e-10
1.46126e-10
1.69527e-10
1.9009e-10
2.18258e-10
3.0044e-10
6.03012e-10
1.50134e-09
3.80032e-09
6.90374e-09
1.50889e-08
3.19763e-08
6.59226e-08
8.43007e-08
7.16106e-08
7.11943e-08
7.20675e-08
6.6106e-08
6.16056e-08
6.85295e-08
6.86441e-08
5.46387e-08
4.06688e-08
2.16714e-08
1.09559e-08
4.59393e-09
1.79639e-09
5.99313e-10
1.96333e-10
6.1533e-11
1.89471e-11
5.12701e-12
1.26789e-12
5.10939e-13
4.81869e-13
1.69367e-13
5.29647e-14
2.10142e-14
2.11328e-14
6.30361e-14
1.65885e-13
3.20199e-13
4.4999e-13
5.5894e-13
7.63611e-13
1.02478e-12
1.26614e-12
1.476e-12
1.68633e-12
1.86138e-12
1.94657e-12
1.94528e-12
2.05541e-12
2.23931e-12
2.46259e-12
2.72885e-12
3.07111e-12
3.40011e-12
3.68226e-12
4.02156e-12
4.24335e-12
4.58978e-12
5.21335e-12
6.81592e-12
9.98358e-12
1.37486e-11
2.0134e-11
2.84272e-11
3.94264e-11
5.32601e-11
6.95832e-11
9.21815e-11
1.16208e-10
1.30328e-10
1.48082e-10
1.77995e-10
2.09326e-10
2.3907e-10
2.61529e-10
2.95693e-10
4.02757e-10
9.62342e-10
3.05288e-09
8.65605e-09
2.12104e-08
6.45949e-08
1.67021e-07
3.59418e-07
3.90552e-07
3.30403e-07
3.34571e-07
3.523e-07
3.50855e-07
3.43387e-07
3.53295e-07
2.95149e-07
1.83074e-07
9.08848e-08
3.64852e-08
1.17599e-08
3.20266e-09
7.4383e-10
1.73081e-10
4.80826e-11
1.32325e-11
2.64865e-12
6.78392e-13
5.32278e-13
2.73345e-13
1.07203e-13
4.88249e-14
4.08239e-14
7.76327e-14
1.59468e-13
3.27365e-13
4.48431e-13
5.16377e-13
6.71767e-13
8.39858e-13
1.01791e-12
1.26842e-12
1.35393e-12
1.43902e-12
1.41626e-12
1.38908e-12
1.39524e-12
1.39229e-12
1.47058e-12
1.46052e-12
1.56708e-12
1.56656e-12
1.64468e-12
1.79571e-12
1.83909e-12
2.14211e-12
2.24402e-12
2.50203e-12
2.85857e-12
3.3369e-12
3.86469e-12
5.30407e-12
8.07687e-12
1.3718e-11
2.22903e-11
3.49223e-11
4.74609e-11
5.79562e-11
7.03802e-11
8.55999e-11
1.07171e-10
1.27906e-10
1.47686e-10
1.62633e-10
1.84602e-10
2.47026e-10
4.5122e-10
9.98292e-10
2.25129e-09
4.58132e-09
9.56627e-09
1.74061e-08
3.13718e-08
3.91312e-08
3.7802e-08
3.9236e-08
3.94839e-08
3.95956e-08
3.99605e-08
4.204e-08
3.98888e-08
3.45813e-08
2.30601e-08
1.14608e-08
5.34868e-09
1.74714e-09
5.99264e-10
1.49275e-10
4.26214e-11
1.44515e-11
3.47911e-12
9.47029e-13
3.35482e-13
2.77533e-13
8.46286e-14
2.27761e-14
5.30738e-15
1.10158e-15
1.95083e-16
3.01811e-17
3.99898e-18
5.72366e-19
8.41793e-20
1.52412e-20
4.9098e-21
2.33699e-21
1.04716e-21
3.43465e-22
1.07235e-22
3.27357e-23
1.08951e-23
3.75657e-24
1.1836e-24
3.48533e-25
9.89103e-26
2.7658e-26
7.98573e-27
2.1018e-27
6.64007e-28
2.23912e-28
5.9164e-29
1.58809e-29
4.47404e-30
1.116e-30
3.08784e-31
7.22851e-32
1.97385e-32
5.55269e-33
1.2895e-33
5.0284e-34
1.61662e-34
4.15726e-35
1.26807e-35
3.03656e-36
7.24354e-37
1.64696e-37
3.36983e-38
6.98629e-39
1.12831e-39
1.1806e-40
1.49352e-42
3.43725e-45
1.65611e-48
2.51044e-13
7.47301e-13
1.46862e-12
5.8439e-13
3.61087e-13
1.40732e-13
7.1987e-14
4.06517e-14
1.72144e-14
4.42635e-15
1.07761e-15
2.58115e-16
5.57438e-17
1.41249e-17
2.53111e-18
3.25277e-19
7.37371e-20
1.6099e-20
2.7041e-21
2.87587e-22
1.85581e-23
6.77576e-25
1.2837e-26
1.33404e-28
2.45237e-30
4.33711e-29
1.00501e-27
1.76897e-26
2.58757e-25
3.21726e-24
3.24688e-23
2.67666e-22
1.89137e-21
1.24753e-20
7.74292e-20
4.07921e-19
1.90738e-18
8.11971e-18
3.05659e-17
1.02636e-16
3.05702e-16
8.9738e-16
2.38613e-15
6.01538e-15
1.42359e-14
3.20151e-14
6.74547e-14
1.33146e-13
2.26673e-13
3.86641e-13
7.17097e-13
1.26371e-12
2.318e-12
6.05352e-12
1.24071e-11
2.20158e-11
3.61003e-11
6.00167e-11
1.02645e-10
1.82668e-10
3.07912e-10
6.04644e-10
1.47159e-09
3.65396e-09
8.21696e-09
1.03549e-08
1.14294e-08
1.32811e-08
1.57535e-08
1.82183e-08
2.01616e-08
2.29575e-08
2.00886e-08
1.42939e-08
7.47937e-09
3.13079e-09
1.00871e-09
3.06491e-10
8.48751e-11
3.19233e-11
7.30044e-12
1.69123e-12
4.97839e-13
4.18805e-13
1.53633e-13
4.31531e-14
1.42246e-14
9.02058e-15
1.23885e-14
4.30075e-14
1.05857e-13
1.89854e-13
3.23214e-13
4.70326e-13
6.07594e-13
6.97946e-13
8.10963e-13
8.13682e-13
7.73607e-13
7.55178e-13
7.76662e-13
7.21896e-13
7.61639e-13
8.02816e-13
8.35203e-13
9.22953e-13
1.0228e-12
1.05947e-12
1.13788e-12
1.11922e-12
1.25155e-12
1.37677e-12
1.55725e-12
1.80273e-12
2.11914e-12
2.52682e-12
2.90262e-12
3.44417e-12
5.18443e-12
8.2732e-12
1.37119e-11
2.05542e-11
2.93079e-11
4.17426e-11
5.71013e-11
8.01182e-11
1.07776e-10
1.3683e-10
1.62431e-10
1.82151e-10
2.04022e-10
2.67857e-10
4.27241e-10
7.94249e-10
1.20466e-09
2.28685e-09
4.77729e-09
9.51177e-09
1.26798e-08
1.0442e-08
1.04088e-08
1.04305e-08
9.62933e-09
9.15004e-09
9.98858e-09
1.05144e-08
8.93384e-09
6.90473e-09
3.77674e-09
1.91988e-09
8.07853e-10
3.26602e-10
1.12591e-10
5.06993e-11
1.62342e-11
3.47607e-12
1.09611e-12
5.02815e-13
3.50763e-13
1.30458e-13
4.14484e-14
1.21602e-14
5.56737e-15
8.03327e-15
2.65926e-14
7.49774e-14
1.5556e-13
2.31248e-13
2.99507e-13
4.12515e-13
5.59442e-13
6.5819e-13
7.3678e-13
8.16468e-13
8.93684e-13
9.3587e-13
9.19432e-13
9.84711e-13
1.06596e-12
1.15299e-12
1.28434e-12
1.41378e-12
1.59154e-12
1.70741e-12
1.84193e-12
1.98756e-12
2.13766e-12
2.46787e-12
2.78902e-12
3.27724e-12
3.75084e-12
4.58864e-12
6.46889e-12
9.64637e-12
1.51936e-11
2.2994e-11
3.64227e-11
5.15455e-11
6.84065e-11
9.10774e-11
1.23351e-10
1.60183e-10
1.99039e-10
2.28997e-10
2.54845e-10
2.87273e-10
4.16676e-10
8.14965e-10
1.79545e-09
3.82109e-09
1.14424e-08
3.0763e-08
6.22078e-08
6.91564e-08
5.73178e-08
5.87261e-08
6.15261e-08
6.14083e-08
6.10213e-08
6.33727e-08
5.56001e-08
3.55803e-08
1.79186e-08
7.03792e-09
2.22876e-09
5.87562e-10
1.39728e-10
4.31647e-11
1.14448e-11
2.22864e-12
6.54832e-13
5.27712e-13
2.11698e-13
7.18151e-14
2.74571e-14
1.36477e-14
1.46889e-14
3.37739e-14
7.60986e-14
1.62653e-13
2.3509e-13
2.783e-13
3.69318e-13
4.6657e-13
5.59615e-13
6.99047e-13
7.54924e-13
7.85266e-13
7.59185e-13
7.54141e-13
7.53471e-13
7.5509e-13
7.91215e-13
7.71378e-13
8.07827e-13
7.9069e-13
8.30716e-13
9.22527e-13
9.69949e-13
1.12981e-12
1.21185e-12
1.30381e-12
1.49827e-12
1.7572e-12
2.02797e-12
2.36613e-12
2.71713e-12
3.31953e-12
5.06674e-12
8.68761e-12
1.43137e-11
2.07497e-11
3.06128e-11
4.47665e-11
6.6145e-11
8.97964e-11
1.15401e-10
1.35963e-10
1.49989e-10
1.65056e-10
2.06715e-10
2.94855e-10
4.85173e-10
7.82783e-10
1.37744e-09
2.41076e-09
4.29294e-09
5.6778e-09
5.41104e-09
5.2622e-09
5.38505e-09
5.47963e-09
5.59973e-09
5.79435e-09
5.82702e-09
5.37377e-09
3.701e-09
1.88159e-09
8.65514e-10
2.90029e-10
9.86608e-11
3.44299e-11
1.09586e-11
2.37721e-12
7.10925e-13
3.28281e-13
1.93078e-13
5.90332e-14
1.56992e-14
3.67786e-15
7.65171e-16
1.36294e-16
2.04887e-17
2.73627e-18
3.196e-19
4.42326e-20
8.9388e-21
2.88024e-21
1.18395e-21
6.07336e-22
2.85512e-22
9.71681e-23
3.19632e-23
1.03569e-23
3.38485e-24
1.12078e-24
3.51273e-25
1.04273e-25
2.97612e-26
8.04077e-27
2.23488e-27
5.90107e-28
1.75798e-28
5.79262e-29
1.51803e-29
3.82547e-30
1.08415e-30
2.63559e-31
6.84845e-32
1.56671e-32
3.68535e-33
1.00589e-33
2.24292e-34
7.41135e-35
2.30014e-35
5.84015e-36
1.67873e-36
3.29927e-37
7.01379e-38
1.30647e-38
2.07283e-39
3.19419e-40
3.48062e-41
3.14508e-42
3.99343e-44
7.8568e-47
3.14618e-50
3.08135e-14
9.95175e-14
2.02762e-13
1.00963e-13
7.74858e-14
4.22569e-14
3.3292e-14
9.47534e-15
2.27608e-15
5.66163e-16
1.25423e-16
2.9326e-17
6.04063e-18
1.4138e-18
2.31162e-19
2.79046e-20
5.90891e-21
1.14352e-21
1.65508e-22
1.50261e-23
8.16093e-25
2.47525e-26
3.93325e-28
3.48293e-30
3.95827e-31
1.10641e-29
2.70133e-28
5.05966e-27
7.6137e-26
9.97934e-25
1.04211e-23
8.73312e-23
6.40174e-22
4.24975e-21
2.66221e-20
1.45245e-19
6.99018e-19
3.11691e-18
1.21315e-17
4.18151e-17
1.29625e-16
3.89667e-16
1.07303e-15
2.80136e-15
6.80114e-15
1.5835e-14
3.27087e-14
6.51222e-14
1.14406e-13
2.02269e-13
3.7239e-13
6.92464e-13
1.25723e-12
2.29925e-12
6.21397e-12
1.32131e-11
2.36201e-11
3.7606e-11
5.87038e-11
9.03741e-11
1.29599e-10
1.72817e-10
2.91474e-10
5.86169e-10
1.31053e-09
1.7481e-09
1.7962e-09
2.10289e-09
2.5292e-09
2.96732e-09
3.31677e-09
3.78385e-09
3.56972e-09
2.64153e-09
1.4115e-09
6.09479e-10
2.02673e-10
7.69618e-11
2.6409e-11
6.67473e-12
1.4579e-12
5.00264e-13
3.47817e-13
1.21086e-13
3.90029e-14
1.01487e-14
3.37078e-15
2.70036e-15
4.97924e-15
1.80642e-14
4.70193e-14
9.06126e-14
1.63432e-13
2.4623e-13
3.20595e-13
3.69293e-13
4.26594e-13
3.98807e-13
3.65144e-13
3.61267e-13
3.64514e-13
3.41416e-13
3.60847e-13
3.75619e-13
3.94732e-13
4.40034e-13
4.83691e-13
5.05919e-13
5.42198e-13
5.40259e-13
6.06414e-13
6.68894e-13
7.56963e-13
8.81124e-13
1.06513e-12
1.23096e-12
1.43426e-12
1.67342e-12
2.0465e-12
2.44474e-12
3.1212e-12
4.52918e-12
6.78699e-12
1.20318e-11
2.09259e-11
3.7528e-11
6.14349e-11
9.12771e-11
1.23055e-10
1.49535e-10
1.69257e-10
1.8818e-10
2.28845e-10
3.06393e-10
3.70565e-10
4.74941e-10
8.13081e-10
1.49145e-09
2.04091e-09
1.72672e-09
1.60924e-09
1.61862e-09
1.51931e-09
1.4597e-09
1.59669e-09
1.70598e-09
1.52338e-09
1.21055e-09
6.96202e-10
3.71245e-10
1.62111e-10
8.39336e-11
3.86314e-11
1.22475e-11
3.08936e-12
8.49356e-13
4.55445e-13
2.98392e-13
1.02687e-13
3.39671e-14
9.77868e-15
2.74812e-15
1.5303e-15
2.9787e-15
1.03204e-14
3.08658e-14
6.97262e-14
1.09495e-13
1.48939e-13
2.06529e-13
2.8411e-13
3.20627e-13
3.44028e-13
3.76255e-13
4.09524e-13
4.25722e-13
4.17861e-13
4.45355e-13
4.84491e-13
5.24577e-13
5.84026e-13
6.44724e-13
7.28375e-13
7.89366e-13
8.51816e-13
9.0305e-13
9.92976e-13
1.13738e-12
1.31344e-12
1.5291e-12
1.76314e-12
1.99058e-12
2.35192e-12
2.71822e-12
3.38588e-12
4.85641e-12
7.6911e-12
1.22579e-11
2.16898e-11
3.84344e-11
6.45171e-11
9.8606e-11
1.41014e-10
1.82159e-10
2.19578e-10
2.4548e-10
2.80538e-10
3.79231e-10
5.71482e-10
8.85793e-10
2.16292e-09
5.55332e-09
1.09697e-08
1.26519e-08
1.01833e-08
1.04355e-08
1.09264e-08
1.10229e-08
1.1006e-08
1.14184e-08
1.04763e-08
6.90259e-09
3.54133e-09
1.368e-09
4.42358e-10
1.15654e-10
4.12096e-11
9.85887e-12
2.12526e-12
6.02107e-13
5.06715e-13
1.50206e-13
5.74827e-14
1.82075e-14
6.8422e-15
3.86134e-15
5.33389e-15
1.38473e-14
3.33069e-14
7.47628e-14
1.14999e-13
1.39909e-13
1.9056e-13
2.4444e-13
2.90193e-13
3.69223e-13
4.00655e-13
4.07621e-13
3.92516e-13
3.89531e-13
3.88789e-13
3.91303e-13
4.09798e-13
3.89283e-13
3.95782e-13
3.85063e-13
4.06202e-13
4.63693e-13
4.98506e-13
5.86889e-13
6.38088e-13
6.75229e-13
7.89475e-13
8.97149e-13
1.0481e-12
1.20812e-12
1.42876e-12
1.70623e-12
1.98685e-12
2.44542e-12
3.21748e-12
4.52684e-12
7.36183e-12
1.3607e-11
2.64223e-11
4.53585e-11
7.03142e-11
9.66854e-11
1.18998e-10
1.33604e-10
1.49399e-10
1.71101e-10
2.07129e-10
2.4117e-10
2.84005e-10
4.01099e-10
6.59003e-10
8.92442e-10
8.78421e-10
7.82083e-10
8.03966e-10
8.25769e-10
8.53709e-10
8.78228e-10
9.04164e-10
8.64452e-10
6.20368e-10
3.33018e-10
1.54502e-10
6.43019e-11
2.68684e-11
7.36802e-12
1.91025e-12
5.85032e-13
3.57032e-13
1.72705e-13
4.47987e-14
1.20768e-14
2.81415e-15
5.71552e-16
1.05223e-16
1.61743e-17
2.07329e-18
2.40565e-19
2.56488e-20
4.15172e-21
1.49902e-21
6.91844e-22
3.18366e-22
1.72428e-22
8.5162e-23
3.02485e-23
1.0808e-23
3.60124e-24
1.1646e-24
3.75204e-25
1.15895e-25
3.43265e-26
9.61255e-27
2.51665e-27
6.68024e-28
1.71847e-28
4.85157e-29
1.53186e-29
3.94332e-30
9.58395e-31
2.57287e-31
6.0862e-32
1.48963e-32
3.43798e-33
7.2789e-34
1.84772e-34
3.80587e-35
9.92163e-36
3.3648e-36
7.95667e-37
2.02493e-37
3.98192e-38
6.68988e-39
1.04113e-39
1.39237e-40
1.72133e-41
1.17953e-42
7.80007e-44
9.88892e-46
1.64235e-48
5.38617e-52
6.43201e-15
2.10943e-14
4.10999e-14
2.92352e-14
2.52585e-14
1.39288e-14
4.6679e-15
1.26193e-15
2.99487e-16
7.19002e-17
1.45828e-17
3.30123e-18
6.46029e-19
1.3944e-19
2.09521e-20
2.38519e-21
4.65722e-22
7.97436e-23
9.95581e-24
7.73292e-25
3.54538e-26
8.98862e-28
1.20403e-29
9.29228e-32
9.61095e-32
2.87766e-30
7.2568e-29
1.41709e-27
2.16061e-26
2.94517e-25
3.15055e-24
2.6511e-23
1.97844e-22
1.3053e-21
8.2057e-21
4.58122e-20
2.25158e-19
1.04665e-18
4.18504e-18
1.47731e-17
4.7355e-17
1.45767e-16
4.18537e-16
1.13475e-15
2.84802e-15
6.85958e-15
1.38975e-14
2.78001e-14
5.03532e-14
9.38297e-14
1.73766e-13
3.42283e-13
6.25915e-13
1.14121e-12
1.92481e-12
5.13272e-12
1.21626e-11
2.24107e-11
3.82641e-11
5.95493e-11
8.52479e-11
1.10442e-10
1.40409e-10
1.88944e-10
2.94776e-10
3.6419e-10
3.63289e-10
4.2218e-10
5.03972e-10
5.89398e-10
6.55082e-10
7.24633e-10
7.05487e-10
5.43133e-10
3.01498e-10
1.38997e-10
6.50961e-11
2.1804e-11
5.50697e-12
1.46367e-12
5.70113e-13
3.73907e-13
1.05386e-13
3.34277e-14
9.58784e-15
2.31993e-15
7.96001e-16
8.20539e-16
1.88487e-15
6.96783e-15
1.91168e-14
3.99059e-14
7.61793e-14
1.18569e-13
1.56198e-13
1.80564e-13
2.07517e-13
1.77135e-13
1.57215e-13
1.55998e-13
1.53946e-13
1.45177e-13
1.54817e-13
1.58572e-13
1.6927e-13
1.89185e-13
2.07708e-13
2.20031e-13
2.3758e-13
2.41162e-13
2.73577e-13
3.02425e-13
3.39964e-13
3.98949e-13
4.8638e-13
5.75573e-13
6.62256e-13
8.11217e-13
9.84323e-13
1.16519e-12
1.38913e-12
1.7203e-12
2.02805e-12
2.61729e-12
4.35637e-12
9.59967e-12
2.17065e-11
4.25649e-11
7.03443e-11
9.95764e-11
1.27903e-10
1.48769e-10
1.71132e-10
2.03545e-10
2.37112e-10
2.50541e-10
2.81504e-10
3.62438e-10
4.20523e-10
3.43884e-10
3.2549e-10
3.4071e-10
3.4136e-10
3.49254e-10
3.78383e-10
3.88712e-10
3.38713e-10
2.65337e-10
1.66592e-10
1.11026e-10
5.96912e-11
2.44469e-11
8.46264e-12
2.34166e-12
8.48261e-13
4.87573e-13
2.76126e-13
9.24479e-14
2.82335e-14
8.4719e-15
2.22404e-15
6.1372e-16
4.25881e-16
1.03209e-15
3.65334e-15
1.15054e-14
2.85407e-14
4.70808e-14
6.75363e-14
9.3665e-14
1.30794e-13
1.4235e-13
1.45294e-13
1.55783e-13
1.70363e-13
1.75422e-13
1.72241e-13
1.84409e-13
2.01131e-13
2.18372e-13
2.42279e-13
2.67763e-13
3.04173e-13
3.39472e-13
3.67856e-13
3.88244e-13
4.37407e-13
4.871e-13
5.84886e-13
6.86179e-13
7.92638e-13
9.26323e-13
1.10474e-12
1.26763e-12
1.4926e-12
1.71764e-12
2.11998e-12
2.50936e-12
4.22018e-12
8.81966e-12
2.00894e-11
4.08098e-11
7.40312e-11
1.14362e-10
1.59764e-10
1.99826e-10
2.27788e-10
2.66274e-10
3.26913e-10
3.8763e-10
5.60769e-10
1.1129e-09
2.06143e-09
2.44425e-09
1.92953e-09
1.97688e-09
2.08002e-09
2.09743e-09
2.0963e-09
2.15594e-09
2.04176e-09
1.37462e-09
7.33741e-10
2.91897e-10
1.07469e-10
3.69895e-11
9.56774e-12
1.92606e-12
6.12853e-13
4.56327e-13
1.53282e-13
4.15743e-14
1.5108e-14
4.47039e-15
1.66539e-15
1.0993e-15
1.87469e-15
5.23913e-15
1.32566e-14
3.15235e-14
5.19126e-14
6.44968e-14
9.05348e-14
1.17618e-13
1.3837e-13
1.80157e-13
1.9604e-13
1.95039e-13
1.8647e-13
1.85501e-13
1.83265e-13
1.86068e-13
1.93842e-13
1.80605e-13
1.76666e-13
1.72688e-13
1.8364e-13
2.13409e-13
2.34956e-13
2.83407e-13
3.12489e-13
3.2637e-13
3.85761e-13
4.31467e-13
5.09703e-13
5.90138e-13
7.21053e-13
8.54417e-13
1.03538e-12
1.29524e-12
1.52733e-12
1.80369e-12
2.07691e-12
3.01734e-12
5.71915e-12
1.23435e-11
2.62502e-11
4.67421e-11
7.02524e-11
9.12269e-11
1.12451e-10
1.30746e-10
1.49609e-10
1.62789e-10
1.59893e-10
1.55698e-10
1.78384e-10
1.98203e-10
1.95394e-10
1.72646e-10
1.83475e-10
1.95368e-10
2.07688e-10
2.14096e-10
2.05386e-10
1.80388e-10
1.27538e-10
8.85154e-11
4.68425e-11
1.79454e-11
5.32242e-12
1.34404e-12
5.48452e-13
4.43328e-13
1.47917e-13
4.3042e-14
9.91598e-15
2.36971e-15
4.8524e-16
8.57268e-17
1.3874e-17
1.8482e-18
2.03017e-19
2.06031e-20
2.15662e-21
5.30044e-22
3.21679e-22
1.77311e-22
8.95355e-23
5.22743e-23
2.73618e-23
9.94498e-24
3.84531e-24
1.30311e-24
4.17591e-25
1.30703e-25
3.97294e-26
1.16691e-26
3.17798e-27
8.04929e-28
2.02419e-28
4.91507e-29
1.28068e-29
3.85547e-30
9.9163e-31
2.33934e-31
6.03587e-32
1.36665e-32
3.19951e-33
7.0865e-34
1.39096e-34
3.28615e-35
6.13045e-36
1.2666e-36
4.4426e-37
9.87486e-38
2.3208e-38
4.61738e-39
6.20225e-40
8.52939e-41
9.70118e-42
1.00005e-42
4.99439e-44
1.9044e-45
2.29824e-47
3.15506e-50
8.27151e-54
2.84147e-15
1.05131e-14
2.35216e-14
9.96405e-15
6.21531e-15
1.94489e-15
6.49914e-16
1.67274e-16
3.91926e-17
9.06071e-18
1.69134e-18
3.6827e-19
6.82592e-20
1.3564e-20
1.8831e-21
2.02501e-22
3.61204e-23
5.46391e-24
5.89097e-25
3.92075e-26
1.52108e-27
3.23732e-29
3.66392e-31
2.95154e-33
2.46001e-32
7.35447e-31
1.86694e-29
3.72841e-28
5.69872e-27
7.96959e-26
8.71749e-25
7.32668e-24
5.50507e-23
3.5621e-22
2.23129e-21
1.26125e-20
6.28644e-20
3.02265e-19
1.22745e-18
4.41136e-18
1.4507e-17
4.54786e-17
1.37327e-16
3.88209e-16
1.01229e-15
2.52749e-15
5.18272e-15
1.04452e-14
1.97086e-14
3.79563e-14
7.51334e-14
1.55341e-13
2.93339e-13
5.65536e-13
9.77119e-13
1.55383e-12
3.33424e-12
8.45878e-12
1.8815e-11
3.52895e-11
5.83022e-11
8.87158e-11
1.18076e-10
1.48056e-10
1.78591e-10
2.09045e-10
2.23614e-10
2.37303e-10
2.45529e-10
2.48012e-10
2.53308e-10
2.47141e-10
2.19645e-10
1.72692e-10
1.08956e-10
5.2106e-11
1.716e-11
4.66557e-12
1.33536e-12
5.71476e-13
3.83519e-13
1.22847e-13
3.04743e-14
8.82324e-15
2.28182e-15
5.15244e-16
1.87611e-16
2.45617e-16
6.57143e-16
2.45399e-15
7.08082e-15
1.60878e-14
3.23085e-14
5.15336e-14
6.86046e-14
7.93948e-14
9.0054e-14
6.8968e-14
5.95559e-14
5.82665e-14
5.63414e-14
5.31998e-14
5.75836e-14
5.78881e-14
6.25382e-14
6.98653e-14
7.72365e-14
8.29346e-14
9.04453e-14
9.40147e-14
1.08325e-13
1.20291e-13
1.33177e-13
1.56643e-13
1.91972e-13
2.34007e-13
2.81895e-13
3.48005e-13
4.16755e-13
5.32219e-13
6.42569e-13
8.06546e-13
9.50379e-13
1.18635e-12
1.46929e-12
1.95914e-12
4.12528e-12
1.02979e-11
2.37755e-11
4.39361e-11
6.99811e-11
9.72443e-11
1.25504e-10
1.57012e-10
1.90703e-10
2.22414e-10
2.45829e-10
2.71545e-10
2.81443e-10
2.75125e-10
2.6644e-10
2.67978e-10
2.65327e-10
2.56789e-10
2.30648e-10
2.03028e-10
1.62104e-10
1.19182e-10
7.20117e-11
3.58823e-11
1.50451e-11
5.09036e-12
1.81847e-12
7.23486e-13
5.07648e-13
2.37223e-13
9.18934e-14
2.71247e-14
7.39516e-15
2.02797e-15
4.88529e-16
1.35578e-16
1.16629e-16
3.27855e-16
1.17306e-15
3.86981e-15
1.05909e-14
1.8174e-14
2.74133e-14
3.75088e-14
5.2848e-14
5.55013e-14
5.32703e-14
5.57296e-14
6.16104e-14
6.21245e-14
6.11739e-14
6.6767e-14
7.25065e-14
7.85603e-14
8.61886e-14
9.76183e-14
1.1111e-13
1.27227e-13
1.39775e-13
1.44895e-13
1.67766e-13
1.88439e-13
2.33587e-13
2.80406e-13
3.24128e-13
3.8348e-13
4.5526e-13
5.52659e-13
6.63344e-13
7.94587e-13
9.47081e-13
1.07336e-12
1.32679e-12
1.75786e-12
3.58957e-12
8.58748e-12
2.16329e-11
4.61317e-11
8.28923e-11
1.2781e-10
1.74045e-10
2.14431e-10
2.55461e-10
3.01258e-10
3.29635e-10
3.93714e-10
5.33426e-10
5.84791e-10
4.51893e-10
4.68572e-10
5.05776e-10
5.21444e-10
5.28921e-10
5.2996e-10
4.89486e-10
3.29045e-10
1.83954e-10
9.51344e-11
3.53394e-11
8.53636e-12
1.96231e-12
6.28814e-13
5.05918e-13
1.45747e-13
4.50801e-14
1.11152e-14
3.8379e-15
1.0632e-15
3.97009e-16
3.10526e-16
6.20165e-16
1.81067e-15
4.77621e-15
1.21144e-14
2.14299e-14
2.69277e-14
3.89746e-14
5.06778e-14
5.89671e-14
7.83445e-14
8.49867e-14
8.27188e-14
7.81297e-14
7.76331e-14
7.61752e-14
7.73922e-14
8.06234e-14
7.31217e-14
6.92078e-14
6.74376e-14
7.24454e-14
8.57275e-14
9.68212e-14
1.21253e-13
1.35956e-13
1.40031e-13
1.65506e-13
1.86093e-13
2.18314e-13
2.6144e-13
3.20147e-13
3.95307e-13
4.76959e-13
6.09665e-13
7.54756e-13
9.05721e-13
1.10504e-12
1.4298e-12
1.81319e-12
2.61984e-12
5.26053e-12
1.14788e-11
2.31374e-11
3.83041e-11
5.89873e-11
8.09765e-11
1.07831e-10
1.35838e-10
1.55513e-10
1.52764e-10
1.53604e-10
1.61372e-10
1.64162e-10
1.62369e-10
1.6555e-10
1.66774e-10
1.60476e-10
1.41768e-10
1.1643e-10
8.60037e-11
5.45893e-11
2.77015e-11
1.09616e-11
3.36685e-12
1.13939e-12
4.52933e-13
4.0515e-13
1.29211e-13
3.90052e-14
1.01882e-14
2.10529e-15
4.46935e-16
8.05151e-17
1.24266e-17
1.76172e-18
2.0407e-19
1.92956e-20
1.72995e-21
2.0162e-22
8.53366e-23
7.06478e-23
4.3247e-23
2.40622e-23
1.53834e-23
8.64165e-24
3.18088e-24
1.30578e-24
4.47741e-25
1.42133e-25
4.31351e-26
1.29036e-26
3.75394e-27
1.00694e-27
2.50502e-28
6.02099e-29
1.36446e-29
3.24385e-30
9.24635e-31
2.38444e-31
5.51214e-32
1.36537e-32
2.96855e-33
6.68268e-34
1.39953e-34
2.59657e-35
5.65906e-36
9.60137e-37
1.64797e-37
5.37673e-38
1.11421e-38
2.57916e-39
5.03153e-40
5.59596e-41
7.15964e-42
6.87602e-43
5.8557e-44
2.58768e-45
5.03518e-47
5.04233e-49
5.52458e-52
1.10865e-55
3.06322e-16
1.27631e-15
3.03535e-15
1.35464e-15
8.51961e-16
2.70185e-16
8.98709e-17
2.20647e-17
5.0985e-18
1.13255e-18
1.95409e-19
4.0717e-20
7.12984e-21
1.30222e-21
1.67675e-22
1.70318e-23
2.75738e-24
3.68037e-25
3.43028e-26
1.95812e-27
6.43777e-29
1.15261e-30
1.10155e-32
2.09398e-34
6.06364e-33
1.7815e-31
4.4805e-30
9.01838e-29
1.37759e-27
1.93909e-26
2.17448e-25
1.83066e-24
1.37963e-23
8.74012e-23
5.43211e-22
3.08359e-21
1.54998e-20
7.54232e-20
3.06245e-19
1.11362e-18
3.7021e-18
1.1689e-17
3.7296e-17
1.09893e-16
2.96747e-16
7.66209e-16
1.65632e-15
3.44193e-15
6.77082e-15
1.34625e-14
2.80511e-14
6.13011e-14
1.23239e-13
2.57155e-13
4.78453e-13
8.13521e-13
1.29016e-12
2.05637e-12
4.69624e-12
1.17659e-11
2.37899e-11
4.25119e-11
6.38554e-11
8.59338e-11
1.04239e-10
1.23875e-10
1.42411e-10
1.5772e-10
1.71975e-10
1.83055e-10
1.7804e-10
1.53259e-10
1.12178e-10
7.05901e-11
3.44418e-11
1.31508e-11
3.59799e-12
1.20723e-12
5.66769e-13
4.0451e-13
1.2987e-13
3.82704e-14
8.44999e-15
2.2361e-15
5.25697e-16
1.11243e-16
4.40203e-17
7.08013e-17
2.09539e-16
7.87746e-16
2.38407e-15
5.88924e-15
1.23062e-14
1.98373e-14
2.65523e-14
3.04417e-14
3.36288e-14
2.26441e-14
1.89111e-14
1.78858e-14
1.70776e-14
1.59095e-14
1.75148e-14
1.73414e-14
1.86912e-14
2.10849e-14
2.33983e-14
2.55597e-14
2.81981e-14
3.02103e-14
3.52939e-14
3.92852e-14
4.33507e-14
5.1146e-14
6.27822e-14
7.88294e-14
9.99528e-14
1.23873e-13
1.48913e-13
2.05364e-13
2.51112e-13
3.17309e-13
4.08364e-13
5.07538e-13
6.63264e-13
8.75257e-13
1.23374e-12
1.89086e-12
4.21955e-12
9.71645e-12
2.08205e-11
3.93022e-11
6.49967e-11
9.50938e-11
1.08335e-10
1.29284e-10
1.51794e-10
1.70408e-10
1.71971e-10
1.72966e-10
1.63838e-10
1.57158e-10
1.4507e-10
1.31566e-10
1.15445e-10
9.08272e-11
6.10807e-11
3.78462e-11
1.88975e-11
7.99518e-12
3.05544e-12
1.29223e-12
6.78719e-13
5.79521e-13
2.54384e-13
8.0188e-14
2.88127e-14
7.60355e-15
1.85868e-15
4.67364e-16
1.03841e-16
2.95795e-17
3.07511e-17
9.49999e-17
3.40935e-16
1.17367e-15
3.53709e-15
6.2203e-15
9.73848e-15
1.28527e-14
1.79953e-14
1.81546e-14
1.60877e-14
1.63887e-14
1.8193e-14
1.79049e-14
1.76755e-14
1.9709e-14
2.1309e-14
2.29556e-14
2.5142e-14
2.931e-14
3.33767e-14
3.84801e-14
4.29793e-14
4.46136e-14
5.34668e-14
6.08575e-14
7.63214e-14
9.4493e-14
1.08115e-13
1.35963e-13
1.59401e-13
1.95911e-13
2.43068e-13
3.02641e-13
3.6742e-13
4.45826e-13
5.6827e-13
7.72929e-13
1.05126e-12
1.4865e-12
3.43687e-12
8.89108e-12
2.22079e-11
5.00355e-11
9.69618e-11
1.4749e-10
1.90312e-10
2.54722e-10
3.03081e-10
3.3053e-10
3.50254e-10
3.59836e-10
3.50578e-10
3.54224e-10
3.51759e-10
3.32479e-10
3.08833e-10
2.69246e-10
2.19349e-10
1.4494e-10
7.87035e-11
2.85931e-11
8.28028e-12
1.85421e-12
6.33957e-13
4.83831e-13
1.76442e-13
4.49285e-14
1.27899e-14
2.8707e-15
9.42857e-16
2.44871e-16
9.27675e-17
8.56311e-17
1.90576e-16
5.703e-16
1.5577e-15
4.22647e-15
8.01557e-15
1.00678e-14
1.49268e-14
1.90616e-14
2.18052e-14
2.9235e-14
3.12739e-14
2.96074e-14
2.73699e-14
2.70168e-14
2.64489e-14
2.68231e-14
2.80332e-14
2.45751e-14
2.25144e-14
2.17048e-14
2.35786e-14
2.84248e-14
3.30522e-14
4.3509e-14
4.97286e-14
5.00248e-14
5.95093e-14
6.69843e-14
7.94933e-14
9.7278e-14
1.20254e-13
1.53693e-13
1.87168e-13
2.46626e-13
3.1965e-13
3.97464e-13
5.21291e-13
7.3431e-13
9.2713e-13
1.22495e-12
1.5932e-12
2.30349e-12
4.41051e-12
8.29216e-12
1.54106e-11
2.64559e-11
4.33034e-11
6.37229e-11
8.0326e-11
8.27479e-11
8.58839e-11
9.08019e-11
9.51319e-11
9.48788e-11
8.83706e-11
7.79132e-11
6.41481e-11
5.38342e-11
3.8875e-11
2.46319e-11
1.29184e-11
5.55924e-12
2.13602e-12
8.80083e-13
4.62647e-13
3.1293e-13
1.27759e-13
3.64997e-14
9.93549e-15
2.31719e-15
4.30288e-16
8.12117e-17
1.28784e-17
1.7424e-18
2.1611e-19
2.18276e-20
1.78352e-21
1.43691e-22
2.1749e-23
1.46193e-23
1.4304e-23
9.48919e-24
5.86129e-24
4.12375e-24
2.48097e-24
9.21509e-25
3.95674e-25
1.37083e-25
4.31659e-26
1.27305e-26
3.76403e-27
1.08378e-27
2.87828e-28
7.08093e-29
1.64774e-29
3.5347e-30
7.70091e-31
2.07179e-31
5.38053e-32
1.22863e-32
2.9292e-33
6.17287e-34
1.33819e-34
2.66596e-35
4.74839e-36
9.54624e-37
1.49545e-37
2.26406e-38
6.27495e-39
1.17719e-39
2.78296e-40
5.26889e-41
4.95623e-42
6.07262e-43
4.91714e-44
3.38612e-45
1.49026e-46
1.62978e-48
1.06985e-50
8.81569e-54
1.24019e-57
3.29898e-17
1.54645e-16
3.90218e-16
1.83646e-16
1.16389e-16
3.73593e-17
1.23457e-17
2.89574e-18
6.5904e-19
1.40372e-19
2.24609e-20
4.4618e-21
7.36453e-22
1.23437e-22
1.47774e-23
1.41594e-24
2.07168e-25
2.43718e-26
1.9652e-27
9.62396e-29
2.68217e-30
4.03831e-32
3.25091e-34
3.49679e-35
1.34636e-33
3.86148e-32
9.5525e-31
1.92601e-29
2.94838e-28
4.08715e-27
4.69472e-26
3.98396e-25
3.01852e-24
1.90931e-23
1.17871e-22
6.71055e-22
3.39281e-21
1.62825e-20
6.53457e-20
2.39747e-19
7.93828e-19
2.49658e-18
8.31144e-18
2.51577e-17
6.96281e-17
1.83868e-16
4.31659e-16
9.35765e-16
1.89345e-15
3.98504e-15
8.74537e-15
1.99666e-14
4.34566e-14
9.83285e-14
2.00985e-13
3.76908e-13
6.52979e-13
1.08281e-12
1.66089e-12
2.89499e-12
6.39305e-12
1.42178e-11
2.54543e-11
3.89124e-11
5.26847e-11
6.67522e-11
8.21388e-11
9.23594e-11
9.56782e-11
9.00007e-11
7.2974e-11
5.57126e-11
3.56928e-11
1.93015e-11
8.17361e-12
2.88066e-12
1.03352e-12
5.45966e-13
3.96753e-13
1.47372e-13
4.19652e-14
1.14035e-14
2.25413e-15
5.45965e-16
1.17227e-16
2.33647e-17
1.02285e-17
1.93887e-17
6.10922e-17
2.30473e-16
7.2863e-16
1.94218e-15
4.1589e-15
6.63038e-15
8.8202e-15
9.82396e-15
1.03472e-14
5.97188e-15
4.74226e-15
4.21724e-15
3.95715e-15
3.6042e-15
4.01441e-15
3.98079e-15
4.17926e-15
4.74619e-15
5.34378e-15
5.97601e-15
6.66085e-15
7.42498e-15
8.75476e-15
9.76146e-15
1.06254e-14
1.28921e-14
1.55772e-14
2.00976e-14
2.66774e-14
3.3221e-14
4.13488e-14
5.90556e-14
7.39179e-14
9.81277e-14
1.31381e-13
1.77625e-13
2.26132e-13
3.35302e-13
4.62263e-13
7.37948e-13
1.12817e-12
1.60597e-12
3.3285e-12
7.30376e-12
1.67325e-11
3.53609e-11
4.81318e-11
5.90141e-11
7.32977e-11
8.93134e-11
9.21775e-11
8.8327e-11
8.32117e-11
7.90972e-11
6.93559e-11
5.58386e-11
3.92352e-11
2.5815e-11
1.54239e-11
8.85622e-12
4.0493e-12
1.91161e-12
9.84976e-13
6.20164e-13
5.28747e-13
2.2777e-13
9.07385e-14
2.59739e-14
8.59677e-15
2.04375e-15
4.49639e-16
1.03903e-16
2.13826e-17
6.35202e-18
7.7087e-18
2.5146e-17
8.9737e-17
3.20548e-16
1.05282e-15
1.85885e-15
2.94356e-15
3.63451e-15
4.8997e-15
4.68288e-15
3.72261e-15
3.64364e-15
4.04491e-15
3.95849e-15
3.86092e-15
4.44113e-15
4.66831e-15
5.08581e-15
5.4882e-15
6.57676e-15
7.48011e-15
8.73823e-15
9.99269e-15
1.03698e-14
1.29191e-14
1.45705e-14
1.88107e-14
2.39746e-14
2.73582e-14
3.66144e-14
4.12834e-14
5.21083e-14
7.06969e-14
9.2209e-14
1.06645e-13
1.4083e-13
1.83756e-13
2.53377e-13
3.98238e-13
5.73214e-13
8.3459e-13
1.28029e-12
3.10819e-12
8.63616e-12
2.58924e-11
6.13931e-11
9.79178e-11
1.44841e-10
1.94581e-10
2.27767e-10
2.40163e-10
2.33e-10
2.39188e-10
2.34066e-10
2.21614e-10
2.04055e-10
1.81402e-10
1.45378e-10
9.89e-11
5.06302e-11
2.17974e-11
6.7018e-12
1.85484e-12
6.67955e-13
5.30728e-13
1.76333e-13
5.84642e-14
1.33189e-14
3.49761e-15
7.16681e-16
2.24156e-16
5.46156e-17
2.12461e-17
2.27492e-17
5.41747e-17
1.63917e-16
4.60558e-16
1.33501e-15
2.68992e-15
3.32926e-15
4.97763e-15
6.09628e-15
6.76935e-15
8.9234e-15
9.25303e-15
8.40551e-15
7.49439e-15
7.29395e-15
7.11073e-15
7.218e-15
7.57394e-15
6.4018e-15
5.62075e-15
5.33965e-15
5.86534e-15
7.24713e-15
8.70627e-15
1.21496e-14
1.4234e-14
1.38816e-14
1.65591e-14
1.85692e-14
2.26782e-14
2.79999e-14
3.52605e-14
4.60205e-14
5.74883e-14
7.85986e-14
1.04708e-13
1.4138e-13
1.96387e-13
3.04207e-13
3.86533e-13
5.06393e-13
7.29107e-13
9.42803e-13
1.27134e-12
1.78076e-12
3.27878e-12
5.97209e-12
1.13693e-11
1.93516e-11
2.74312e-11
2.7866e-11
3.01075e-11
3.39208e-11
3.59971e-11
3.6726e-11
3.24812e-11
2.63882e-11
1.87277e-11
1.26206e-11
8.14742e-12
4.66166e-12
2.58951e-12
1.33321e-12
7.08518e-13
5.32443e-13
3.01789e-13
1.06208e-13
3.83137e-14
9.92499e-15
2.43704e-15
5.08435e-16
8.48558e-17
1.42471e-17
1.98988e-18
2.36578e-19
2.56715e-20
2.26578e-21
1.60539e-22
1.19541e-23
2.63424e-24
2.40026e-24
2.58591e-24
1.84099e-24
1.26007e-24
9.61885e-25
6.07645e-25
2.25601e-25
9.94692e-26
3.46514e-26
1.08306e-26
3.11598e-27
9.15048e-28
2.61316e-28
6.89686e-29
1.68285e-29
3.83422e-30
7.9582e-31
1.61843e-31
4.1386e-32
1.08541e-32
2.4566e-33
5.70421e-34
1.17656e-34
2.47385e-35
4.74932e-36
8.21649e-37
1.55002e-37
2.285e-38
3.226e-39
7.32378e-40
1.20326e-40
2.90787e-41
5.40572e-42
4.38726e-43
5.15739e-44
3.54989e-45
1.94166e-46
8.96249e-48
6.64376e-50
2.26196e-52
1.24158e-55
1.03815e-59
3.55101e-18
1.87104e-17
5.00203e-17
2.48373e-17
1.58531e-17
5.14292e-18
1.68496e-18
3.77919e-19
8.45916e-20
1.72409e-20
2.56421e-21
4.8439e-22
7.52078e-23
1.15529e-23
1.28779e-24
1.16154e-25
1.53166e-26
1.58659e-27
1.10713e-28
4.64846e-30
1.09652e-31
1.38293e-33
9.3859e-36
6.26797e-36
2.41505e-34
6.61308e-33
1.58382e-31
3.15561e-30
4.83634e-29
6.54643e-28
7.66458e-27
6.5683e-26
4.99984e-25
3.21743e-24
1.97762e-23
1.13248e-22
5.77472e-22
2.73132e-21
1.09189e-20
4.06397e-20
1.34379e-19
4.2517e-19
1.4285e-18
4.36158e-18
1.22306e-17
3.26087e-17
8.45712e-17
1.91786e-16
4.03627e-16
9.02161e-16
2.09744e-15
4.90258e-15
1.15285e-14
2.79388e-14
6.23908e-14
1.2919e-13
2.51174e-13
4.5127e-13
7.77761e-13
1.17856e-12
1.78932e-12
3.03285e-12
5.96191e-12
1.0138e-11
1.47916e-11
2.06409e-11
2.90064e-11
3.24447e-11
3.06575e-11
2.52644e-11
1.78057e-11
1.1231e-11
6.56645e-12
3.79171e-12
1.74519e-12
9.35903e-13
6.46415e-13
3.82538e-13
1.52741e-13
5.1328e-14
1.3031e-14
3.26644e-15
5.79963e-16
1.28842e-16
2.53361e-17
4.78281e-18
2.33777e-18
5.01073e-18
1.63447e-17
6.15859e-17
2.01878e-16
5.71852e-16
1.23075e-15
1.88794e-15
2.44152e-15
2.55807e-15
2.47523e-15
1.17669e-15
8.55174e-16
6.89969e-16
6.13425e-16
5.34782e-16
6.06785e-16
6.17778e-16
6.10335e-16
7.02702e-16
8.00714e-16
9.17666e-16
1.02615e-15
1.20632e-15
1.42897e-15
1.58811e-15
1.7336e-15
2.18063e-15
2.47311e-15
3.37723e-15
4.56706e-15
5.83688e-15
7.32865e-15
1.07815e-14
1.45118e-14
1.99005e-14
2.81591e-14
4.02039e-14
5.28147e-14
8.29226e-14
1.24542e-13
2.06962e-13
3.32119e-13
5.14137e-13
7.55174e-13
1.09459e-12
2.2585e-12
5.80105e-12
1.06483e-11
1.6487e-11
2.28338e-11
3.10322e-11
3.23278e-11
2.84794e-11
2.46159e-11
2.33179e-11
1.83558e-11
1.22243e-11
6.57e-12
4.45529e-12
2.8964e-12
1.92945e-12
1.25979e-12
8.25304e-13
8.43248e-13
4.32726e-13
2.21925e-13
8.48049e-14
3.09928e-14
8.06528e-15
2.45723e-15
5.29066e-16
1.05099e-16
2.23508e-17
4.27471e-18
1.33757e-18
1.82648e-18
6.10643e-18
2.14636e-17
7.87535e-17
2.7565e-16
4.75425e-16
7.30636e-16
8.12734e-16
9.96813e-16
8.66251e-16
5.88704e-16
5.36905e-16
5.91044e-16
5.89601e-16
5.62899e-16
6.76709e-16
6.63456e-16
7.3987e-16
7.766e-16
9.55733e-16
1.06722e-15
1.28935e-15
1.51839e-15
1.56529e-15
2.06171e-15
2.22414e-15
3.02629e-15
3.877e-15
4.48252e-15
6.22201e-15
6.5829e-15
9.06575e-15
1.27495e-14
1.72977e-14
2.03262e-14
2.93801e-14
3.93777e-14
5.58181e-14
9.30491e-14
1.25512e-13
2.25527e-13
3.86815e-13
5.51151e-13
8.5772e-13
2.70402e-12
8.83467e-12
2.42871e-11
5.19321e-11
9.10873e-11
1.27212e-10
1.51891e-10
1.41788e-10
1.40638e-10
1.36914e-10
1.27084e-10
1.03793e-10
7.43038e-11
4.03389e-11
2.30675e-11
1.07927e-11
4.6607e-12
1.6524e-12
6.72315e-13
5.25939e-13
2.06532e-13
6.14563e-14
1.8562e-14
3.8095e-15
9.24685e-16
1.73408e-16
5.16475e-17
1.18093e-17
4.76381e-18
5.77134e-18
1.4259e-17
4.3171e-17
1.23885e-16
3.80683e-16
8.01036e-16
9.60239e-16
1.41197e-15
1.61377e-15
1.69459e-15
2.10169e-15
2.04681e-15
1.73371e-15
1.43998e-15
1.36097e-15
1.30641e-15
1.32794e-15
1.40144e-15
1.14311e-15
9.54406e-16
8.77326e-16
9.74281e-16
1.25947e-15
1.56724e-15
2.31659e-15
2.80345e-15
2.65881e-15
3.11462e-15
3.5113e-15
4.35231e-15
5.49369e-15
6.85384e-15
9.29353e-15
1.1645e-14
1.64109e-14
2.35568e-14
3.36602e-14
5.21964e-14
8.7944e-14
1.16199e-13
1.51796e-13
2.18371e-13
3.20242e-13
4.719e-13
6.85947e-13
1.05026e-12
1.47805e-12
2.22626e-12
3.82417e-12
5.49501e-12
5.13941e-12
4.57789e-12
4.39915e-12
4.59205e-12
5.40701e-12
4.75652e-12
3.43885e-12
2.44085e-12
1.9855e-12
1.68271e-12
1.23104e-12
8.75438e-13
6.96026e-13
5.68956e-13
2.73444e-13
1.06081e-13
3.40961e-14
1.1047e-14
2.60034e-15
5.76573e-16
1.0793e-16
1.61884e-17
2.41918e-18
2.97826e-19
3.11665e-20
2.96075e-21
2.28745e-22
1.41008e-23
1.01194e-24
3.34851e-25
3.63171e-25
4.15439e-25
3.13336e-25
2.31805e-25
1.84459e-25
1.17429e-25
4.23498e-26
1.85562e-26
6.3964e-27
1.97927e-27
5.58204e-28
1.63458e-28
4.6434e-29
1.22253e-29
2.96968e-30
6.69087e-31
1.36845e-31
2.66436e-32
6.57115e-33
1.74086e-33
3.91845e-34
8.99577e-35
1.83391e-35
3.7887e-36
7.1161e-37
1.20968e-37
2.20316e-38
3.11934e-39
4.28311e-40
8.23471e-41
1.17246e-41
2.84515e-42
5.2985e-43
3.81933e-44
4.27353e-45
2.53957e-46
1.09624e-47
5.4134e-49
3.01409e-51
4.79495e-54
1.49653e-57
4.61693e-62
3.82243e-19
2.26173e-18
6.39941e-18
3.35324e-18
2.15411e-18
7.05253e-19
2.28589e-19
4.90555e-20
1.07825e-20
2.09868e-21
2.90586e-22
5.21071e-23
7.5951e-24
1.06792e-24
1.10925e-25
9.39345e-27
1.11429e-27
1.01543e-28
6.13249e-30
2.20527e-31
4.39267e-33
4.61605e-35
2.75249e-37
8.62258e-37
2.99328e-35
7.28359e-34
1.57195e-32
2.90469e-31
4.28742e-30
5.69062e-29
6.73002e-28
5.8093e-27
4.4338e-26
2.89269e-25
1.78105e-24
1.02651e-23
5.3009e-23
2.51971e-22
1.03196e-21
3.90266e-21
1.32083e-20
4.33291e-20
1.50409e-19
4.73662e-19
1.35e-18
3.68905e-18
9.89509e-18
2.3725e-17
5.25923e-17
1.24081e-16
3.09477e-16
7.39949e-16
1.80711e-15
4.52983e-15
1.06043e-14
2.30961e-14
5.00256e-14
1.03544e-13
2.07384e-13
3.75362e-13
6.49101e-13
1.05226e-12
1.01326e-12
1.90378e-12
3.26714e-12
4.49317e-12
5.59265e-12
6.72339e-12
7.92289e-12
6.78705e-12
5.16993e-12
3.58788e-12
2.28425e-12
1.34515e-12
8.8446e-13
5.98828e-13
3.71771e-13
1.56359e-13
5.5803e-14
1.71793e-14
3.89738e-15
9.01511e-16
1.43887e-16
2.93981e-17
5.29994e-18
9.53164e-19
5.22065e-19
1.22015e-18
4.03259e-18
1.50803e-17
5.07183e-17
1.49337e-16
3.15126e-16
4.50633e-16
5.46456e-16
5.1324e-16
4.29106e-16
1.57846e-16
9.59736e-17
6.27295e-17
4.84655e-17
3.84741e-17
4.49758e-17
4.76049e-17
4.25549e-17
5.05147e-17
5.90328e-17
6.65688e-17
7.32549e-17
9.29257e-17
1.1442e-16
1.25043e-16
1.35291e-16
1.78314e-16
1.89264e-16
2.58178e-16
3.4816e-16
5.0343e-16
5.69779e-16
8.59599e-16
1.29667e-15
1.81025e-15
2.71346e-15
4.14987e-15
5.33824e-15
8.97521e-15
1.49455e-14
2.4043e-14
3.71174e-14
6.04434e-14
9.7442e-14
1.55461e-13
2.42752e-13
3.81771e-13
6.45233e-13
1.13497e-12
2.69154e-12
4.57985e-12
6.32145e-12
6.53758e-12
6.43038e-12
5.58809e-12
4.5364e-12
3.54544e-12
2.78856e-12
2.0772e-12
1.54578e-12
1.19404e-12
9.18799e-13
6.66501e-13
3.94423e-13
1.85337e-13
8.76257e-14
3.00057e-14
1.01601e-14
2.40115e-15
6.74433e-16
1.31856e-16
2.37118e-17
4.64836e-18
8.28309e-19
2.74806e-19
4.08706e-19
1.36878e-18
4.68806e-18
1.74114e-17
6.2868e-17
1.02024e-16
1.43286e-16
1.35947e-16
1.37058e-16
9.80039e-17
5.01641e-17
3.86818e-17
4.14087e-17
4.25564e-17
3.88802e-17
5.01138e-17
4.27707e-17
4.96219e-17
4.98998e-17
6.51846e-17
6.13609e-17
8.30913e-17
1.00678e-16
1.00171e-16
1.47822e-16
1.56455e-16
2.10687e-16
2.96675e-16
2.97703e-16
4.29405e-16
4.38001e-16
6.35616e-16
9.16832e-16
1.26926e-15
1.71558e-15
2.28269e-15
3.07091e-15
4.62608e-15
8.19203e-15
1.03912e-14
1.9687e-14
3.62123e-14
6.60611e-14
8.05543e-14
1.53967e-13
3.14075e-13
5.50895e-13
2.64988e-12
1.04313e-11
2.71648e-11
4.50108e-11
4.43431e-11
4.45826e-11
4.17111e-11
3.55838e-11
2.45819e-11
1.52739e-11
9.90377e-12
5.4239e-12
2.70889e-12
1.24958e-12
7.03929e-13
5.65385e-13
2.11727e-13
7.63056e-14
2.052e-14
5.66039e-15
1.04967e-15
2.36177e-16
4.05631e-17
1.15247e-17
2.47189e-18
1.04311e-18
1.39239e-18
3.4879e-18
1.04726e-17
3.04425e-17
9.7911e-17
2.10007e-16
2.38524e-16
3.33379e-16
3.44175e-16
3.26591e-16
3.5626e-16
3.03786e-16
2.2172e-16
1.57168e-16
1.34244e-16
1.2323e-16
1.25503e-16
1.32191e-16
1.05082e-16
8.27385e-17
7.14886e-17
8.08679e-17
1.11302e-16
1.4353e-16
2.26928e-16
2.8668e-16
2.62077e-16
2.98344e-16
3.36318e-16
4.08064e-16
5.42726e-16
6.57581e-16
8.86977e-16
1.16391e-15
1.70542e-15
2.69995e-15
4.10769e-15
6.88064e-15
1.35494e-14
1.71189e-14
2.33869e-14
3.16501e-14
4.83258e-14
7.74783e-14
1.42458e-13
2.21149e-13
3.90686e-13
6.39079e-13
8.86858e-13
1.57146e-12
1.92837e-12
2.38317e-12
2.77063e-12
3.14321e-12
2.51795e-12
2.17488e-12
1.9436e-12
1.71016e-12
1.43845e-12
1.18568e-12
1.08891e-12
7.35811e-13
4.64395e-13
2.38476e-13
1.00486e-13
3.55822e-14
1.04784e-14
3.07739e-15
6.57933e-16
1.31871e-16
2.22047e-17
2.99266e-18
3.9831e-19
4.32642e-20
3.98961e-21
3.32132e-22
2.24927e-23
1.21071e-24
8.84336e-26
4.21757e-26
5.01425e-26
5.93524e-26
4.60378e-26
3.46684e-26
2.65957e-26
1.56793e-26
5.06449e-27
2.02331e-27
6.50302e-28
1.95773e-28
5.43645e-29
1.59155e-29
4.50854e-30
1.18775e-30
2.88284e-31
6.46815e-32
1.3176e-32
2.51128e-33
6.08151e-34
1.62933e-34
3.66863e-35
8.44649e-36
1.72206e-36
3.55388e-37
6.64072e-38
1.12582e-38
2.0374e-39
2.83642e-40
3.90753e-41
6.83189e-42
8.74908e-43
2.11474e-43
4.03227e-44
2.72673e-45
2.92736e-46
1.56509e-47
5.53147e-49
2.95004e-50
1.29076e-52
8.66587e-56
9.52644e-60
8.93598e-72
)
;
boundaryField
{
inlet
{
type zeroGradient;
}
bottom
{
type zeroGradient;
}
outlet
{
type zeroGradient;
}
atmosphere
{
type inletOutlet;
inletValue uniform 0;
value nonuniform List<scalar>
357
(
3.82243e-19
2.26173e-18
6.39941e-18
3.35324e-18
2.15411e-18
7.05253e-19
2.28589e-19
4.90555e-20
1.07825e-20
2.09868e-21
2.90586e-22
5.21071e-23
7.5951e-24
1.06792e-24
1.10925e-25
9.39345e-27
1.11429e-27
1.01543e-28
6.13249e-30
2.20527e-31
4.39267e-33
4.61605e-35
2.75249e-37
8.62258e-37
2.99328e-35
7.28359e-34
1.57195e-32
2.90469e-31
4.28742e-30
0
0
0
0
0
0
0
0
0
0
0
0
0
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.59265e-12
6.72339e-12
7.92289e-12
6.78705e-12
5.16993e-12
3.58788e-12
2.28425e-12
1.34515e-12
8.8446e-13
5.98828e-13
3.71771e-13
1.56359e-13
5.5803e-14
1.71793e-14
3.89738e-15
9.01511e-16
1.43887e-16
2.93981e-17
5.29994e-18
9.53164e-19
5.22065e-19
1.22015e-18
4.03259e-18
1.50803e-17
5.07183e-17
1.49337e-16
3.15126e-16
4.50633e-16
5.46456e-16
5.1324e-16
4.29106e-16
1.57846e-16
9.59736e-17
6.27295e-17
4.84655e-17
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
6.53758e-12
6.43038e-12
5.58809e-12
4.5364e-12
3.54544e-12
2.78856e-12
2.0772e-12
1.54578e-12
1.19404e-12
9.18799e-13
6.66501e-13
3.94423e-13
1.85337e-13
8.76257e-14
3.00057e-14
1.01601e-14
2.40115e-15
6.74433e-16
1.31856e-16
2.37118e-17
4.64836e-18
8.28309e-19
2.74806e-19
4.08706e-19
1.36878e-18
4.68806e-18
1.74114e-17
6.2868e-17
1.02024e-16
1.43286e-16
1.35947e-16
1.37058e-16
9.80039e-17
5.01641e-17
3.86818e-17
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4.45826e-11
4.17111e-11
3.55838e-11
2.45819e-11
1.52739e-11
9.90377e-12
5.4239e-12
2.70889e-12
1.24958e-12
7.03929e-13
5.65385e-13
2.11727e-13
7.63056e-14
2.052e-14
5.66039e-15
1.04967e-15
2.36177e-16
4.05631e-17
1.15247e-17
2.47189e-18
1.04311e-18
1.39239e-18
3.4879e-18
1.04726e-17
3.04425e-17
9.7911e-17
2.10007e-16
2.38524e-16
3.33379e-16
3.44175e-16
3.26591e-16
3.5626e-16
3.03786e-16
2.2172e-16
1.57168e-16
1.34244e-16
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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.14321e-12
2.51795e-12
2.17488e-12
1.9436e-12
1.71016e-12
1.43845e-12
1.18568e-12
1.08891e-12
7.35811e-13
4.64395e-13
2.38476e-13
1.00486e-13
3.55822e-14
1.04784e-14
3.07739e-15
6.57933e-16
1.31871e-16
2.22047e-17
2.99266e-18
3.9831e-19
4.32642e-20
3.98961e-21
3.32132e-22
2.24927e-23
1.21071e-24
8.84336e-26
4.21757e-26
5.01425e-26
5.93524e-26
4.60378e-26
3.46684e-26
2.65957e-26
1.56793e-26
5.06449e-27
2.02331e-27
6.50302e-28
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
)
;
}
frontBack
{
type empty;
}
}
// ************************************************************************* //
|
2f8988d97f1745e40ff94c50ef0ed869656aa109 | 0fb77d6a6b49cb32502c641c3d95f2cfbb703958 | /1.cpp | 862ee02254966b362eb5b70130941b2233c19018 | [] | no_license | Marzx11/c- | 3a67106195d6566f1d9f7db71d3a202b51d22e96 | 22ffbfd4f96c220ec449cc86814048be0df37319 | refs/heads/main | 2023-08-23T08:47:43.364007 | 2021-11-01T05:27:11 | 2021-11-01T05:27:11 | 413,715,179 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 586 | cpp | 1.cpp | #include <iostream>
#include <string.h>
#include <iomanip>
#include<time.h>
using namespace std;
int main()
{
int a[5][2];
int scoretest[10][10];
srand(time(NULL));
int n;
cout << "Enter : ";
cin >> n;
for(int i=0;i<n;i++)
{
for(int j=0;j<2;j++)
{
cout << ". Enter Score Test " << j+1 << " : " ;
cin >> scoretest[i][j];
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<2;j++)
{
cout <<"\t" << scoretest[i][j] ;
}
cout << endl;
}
return(0);
} |
0be4f4c1f970e1e67d1d9ee5c13bd07e3d545b3e | aabdbcf0c25f677d18fc9d9530af72a3797ef146 | /OSGCh05/OSGCh05Ex14/OSGCh05Ex14/main.cpp | 70ce78d61f05e7994813a90628fa97a87dca4a13 | [] | no_license | XiaBingGame/OSGGuideTutorial | 7f2d3d38a658ee4bd03f6cf478d9c84d182c061b | 3f3fd6b44d3c86734edc26ff868a13a9b701afb0 | refs/heads/master | 2023-08-17T13:58:19.032520 | 2023-08-15T14:32:04 | 2023-08-15T14:32:04 | 156,837,457 | 3 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,874 | cpp | main.cpp | #include <Windows.h>
#include <iostream>
#include <osg/Notify>
#include <osg/MatrixTransform>
#include <osg/PositionAttitudeTransform>
#include <osg/Geometry>
#include <osg/Geode>
#include <osg/Material>
#include <osg/CullFace>
#include <osgUtil/Optimizer>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
#include <osgSim/OverlayNode>
#include <osgText/Font>
#include <osgText/Text>
#include <osgViewer/Viewer>
#include <iostream>
//创建一个四边形节点
osg::ref_ptr<osg::Node> createNode()
{
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry();
//设置顶点
osg::ref_ptr<osg::Vec3Array> vc = new osg::Vec3Array();
vc->push_back(osg::Vec3(0.0f, 0.0f, 0.0f));
vc->push_back(osg::Vec3(1.0f, 0.0f, 0.0f));
vc->push_back(osg::Vec3(1.0f, 0.0f, 1.0f));
vc->push_back(osg::Vec3(0.0f, 0.0f, 1.0f));
geom->setVertexArray(vc.get());
//设置纹理坐标
osg::ref_ptr<osg::Vec2Array> vt = new osg::Vec2Array();
vt->push_back(osg::Vec2(0.0f, 0.0f));
vt->push_back(osg::Vec2(1.0f, 0.0f));
vt->push_back(osg::Vec2(1.0f, 1.0f));
vt->push_back(osg::Vec2(0.0f, 1.0f));
geom->setTexCoordArray(0, vt.get());
//设置法线
osg::ref_ptr<osg::Vec3Array> nc = new osg::Vec3Array();
nc->push_back(osg::Vec3(0.0f, -1.0f, 0.0f));
geom->setNormalArray(nc.get());
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
//添加图元
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS, 0, 4));
//绘制
geode->addDrawable(geom.get());
return geode.get();
}
int main()
{
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
osg::ref_ptr<osg::Group> root = new osg::Group();
osg::ref_ptr<osg::Node> node = createNode();
//得到状态属性
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet();
stateset = node->getOrCreateStateSet();
//创建材质对象
osg::ref_ptr<osg::Material> mat = new osg::Material();
//设置正面散射颜色
mat->setDiffuse(osg::Material::FRONT, osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f));
//设置正面镜面颜色
mat->setSpecular(osg::Material::FRONT, osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f));
//设置正面指数
mat->setShininess(osg::Material::FRONT, 90.0f);
stateset->setAttribute(mat.get());
//设置背面剔除
osg::ref_ptr<osg::CullFace> cullface = new osg::CullFace(osg::CullFace::BACK);
stateset->setAttribute(cullface.get());
stateset->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
// stateset->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
root->addChild(node.get());
viewer->setUpViewInWindow(100, 100, 800, 600);
//优化场景数据
osgUtil::Optimizer optimizer;
optimizer.optimize(root.get());
viewer->setSceneData(root.get());
viewer->realize();
viewer->run();
return 0;
} |
1a7d206869cd3e4753195baab8d2bd06d25be7e3 | 0412573aa478f60cd9123e6a9715f503a1dd6bd7 | /DLL/KeyBind.h | 567a8a3b099d4c2908d18684e8411a355e9de2d3 | [] | no_license | Abin-Liu/Pindlebot_Sig | 7d28f4d4a5cdeeed69f9676f4b1349d2664a3775 | ff5269c5148c80662283ca1b646b191484b30592 | refs/heads/master | 2020-03-20T19:29:17.621445 | 2018-06-10T09:12:54 | 2018-06-10T09:12:54 | 137,639,835 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,232 | h | KeyBind.h | //////////////////////////////////////////////////////////////////////
// KeyBind.h
//
// CKeyBind, a helper class used for bind.d2h. It captures in-game
// key strokes and maintains command lists those are binded to captured
// key strokes.
//
// Written by Abin (abinn32@yahoo.com)
// June 26, 2004
//
//////////////////////////////////////////////////////////////////////
#ifndef __KEYBIND_H__
#define __KEYBIND_H__
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define BIND_ENTRY_COUNT 256
// Whenever an appropriate key-stroke is captured, this function will be called.
// iVKCode: The virtual key code of the captured key stroke
// lpszCommand: The command binded to the key code, if NULL, means the player wants to display the key code
typedef BOOL (CALLBACK *KEYBINDPROC)(BYTE iVkCode, LPCTSTR lpszCommand);
// A hotkey entry
class CKeyBindEntry
{
public:
CKeyBindEntry();
CKeyBindEntry(BYTE iVKCode, BYTE iRetCode, LPCTSTR lpszCommands);
CKeyBindEntry(const CKeyBindEntry& rhs);
virtual ~CKeyBindEntry();
const CKeyBindEntry& operator=(const CKeyBindEntry& rhs);
BOOL operator==(const CKeyBindEntry& rhs) const;
BOOL operator>(const CKeyBindEntry& rhs) const; // for search and sort
void SetVKCode(BYTE iVKCode);
BYTE GetVKCode() const;
BYTE GetRetCode() const;
void SetRetCode(BYTE iRetCode);
void SetCommands(LPCTSTR lpszCommands);
DWORD GetCommandStartPosition() const; // Get the first command
void GetNextCommand(DWORD& dwPosition, LPTSTR lpszBuffer, DWORD dwChars) const; // Get the next command after lpszPosition
BOOL GetDisplayStr(LPTSTR lpszBuffer) const;
static BOOL VerifyVKCode(LPCTSTR lpsz, DWORD dwLen, BYTE* pVKCode);
BOOL ParseLineStr(LPCTSTR lpszLineStr);
BOOL GetLineStr(LPTSTR lpszBuffer) const;
BOOL GetEntryNameStr(LPTSTR lpszBuffer) const;
static BOOL GetLineStr(BYTE iRetCode, LPCTSTR lpszCommands, LPTSTR lpszBuffer);
static BOOL GetEntryNameStr(BYTE iVKCode, LPTSTR lpszBuffer);
BOOL IsMapped() const;
protected:
void __FreeData();
protected:
BYTE m_iVKCode; // The virtual key code to capture
BYTE m_iRetCode; // The return key code
LPTSTR m_lpszCommands; // Command(s) binded to this key
};
// The CKeyBind class.
class CKeyBind
{
public:
static BOOL InstallKeyBind(); // Must be called before use, "OnClientStart" is a good place for this
static BOOL UninstallKeyBind(); // Should be called when no longer needed, "OnClientStop" is a good place for this
static void SetKeyBindProc(KEYBINDPROC lpfnProc); // Set the callback function pointer
static void SetShowCode(BOOL bSet = TRUE); // The player wants to display the virtual key code of the next key-stroke
static CKeyBindEntry* CKeyBind::GetEntry(BYTE iIndex); // Get info of a particular entry
static void ClearAll(); // Remove all entries from the list
static BOOL SetEntry(BYTE iVKCode, BYTE iRetCode, LPCTSTR lpszCommand); // Add or set an entry
static BOOL IsTyping(); // whether the player is typing some chat message
static void SetTargetWnd(HWND hWnd);
static BOOL IsAllCleared();
static BOOL Clear(BYTE iIndex);
protected:
static LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam); // The build in process function
};
#endif // __KEYBIND_H__
|
b5d511f3336bd2b23c82b6753a15f8d3a1eb42c0 | fa38edeaf042827ce381d3de56531d7f352ab261 | /cell.cc | b598387b10e3917ae9776262cc65b0bfe7a4b036 | [] | no_license | SeventhHelix/Conway-s-Game-of-Life | ba31ad19816179a5a5955852dca1354f31d298be | 6f939693417d641e81abaf0183a467fb5150318b | refs/heads/master | 2020-05-30T21:17:27.633476 | 2013-01-08T23:09:14 | 2013-01-08T23:09:14 | 3,228,698 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,055 | cc | cell.cc | /*
* =====================================================================================
*
* Filename: cell.cc
*
* Description: Methods used by each cell in Conway's Game of Life
*
* Author: Jeff Dyck
*
* =====================================================================================
*/
#include "cell.h"
/*
* Cell constructor
*/
Cell::Cell () {
this->isAlive = false;
this->numNeighbours = 0;
this->numAlive = 0;
for (int i=0; i<maxNeighbours; i++) {
this->neighbours[i] = NULL;
}
this->pw = NULL;
}
/*
* Cell destructor
*/
Cell::~Cell() {
// delete this->pw; // NOT SURE IF NEEDED
}
/*
* Sets the cell to living
*/
void Cell::setLiving() {
this->isAlive = true;
this->draw();
return;
}
void Cell::setDead() {
this->isAlive = false;
this->undraw();
return;
}
/*
* Adds a pointer to one of the cell's neighbours to the array
*/
void Cell::addNeighbour(Cell *neighbour) {
for (int i=0; i < maxNeighbours; i++) {
if (this->neighbours[i] == NULL) {
this->neighbours[i] = neighbour;
this->numNeighbours += 1;
return;
}
} // for
return;
}
/*
* If the cell is alive, tell all neighbours that the cell is alive
*/
void Cell::alertNeighbours() {
if (this->isAlive) {
for (int i=0; i < this->numNeighbours; i++) {
this->neighbours[i]->neighbourIsAlive();
}
} // if
return;
}
/*
* Will be called by the cell's neighbours to tell it theyre alive
*/
void Cell::neighbourIsAlive() {
this->numAlive += 1;
return;
}
/*
* Reassess the cell's living-or-dead status based on the number of living neighbours
*/
void Cell::recalculate() {
if (this->isAlive) {
if (!(this->numAlive == 2 || this->numAlive == 3)) {
this->isAlive = false;
this->undraw();
}
} else {
if (this->numAlive == 3) {
this->isAlive = true;
this->draw();
}
}
// Resets numAlive so it can be recalculated next time
this->numAlive = 0;
return;
}
/*
* Sets the coordinates for the cell and gives a pointer to the window
*/
void Cell::setCoords(int X, int Y, int W, int H, Xwindow *PW) {
this->x = X;
this->y = Y;
this->width = W;
this->height = H;
this->pw = PW;
}
/*
* Draws the cell's box on the window depending on it's coordinates
*/
void Cell::draw() {
(this->pw)->fillRectangle((this->x * this->width), (this->y * this->height),
this->width, this->height);
return;
}
/*
* Removes the cell's box drawn on the window by drawing a white box
*/
void Cell::undraw() {
(this->pw)->fillRectangle((this->x * this->width), (this->y * this->height),
this->width, this->height, 0);
return;
}
/*
* Overloads the << operator
* Prints X if the cell is alive, _ if it's dead
*/
std::ostream& operator<<(std::ostream &out, const Cell &c) {
if (c.isAlive) out << 'X';
else out << '_';
return out;
}
|
de2d32fc0e885c183e3187713647add1d2d68d18 | 7ac5538df2e1d8c7e9452a81ccb4dc8b6c2df20e | /Source/binvox-0.4/cc/math/Vector.cc | b79b671b175ccf484414496a8c06c0991dcb6080 | [] | no_license | icemansina/ambientocclusion | 0f72c2d45d16678681f78c78a64db9994741bc3d | 80ff256bfd373aa61de9802fc360939f083294d6 | refs/heads/master | 2020-03-10T04:49:59.461023 | 2018-04-12T14:53:46 | 2018-04-12T14:53:46 | 129,202,443 | 0 | 0 | null | 2018-04-12T06:15:52 | 2018-04-12T06:15:51 | null | UTF-8 | C++ | false | false | 8,941 | cc | Vector.cc | //
// binvox, a binary 3D mesh voxelizer
// Copyright (c) 2004-2007 by Patrick Min, patrick.n.min "at" gmail "dot" com
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//
// $Id: Vector.cc,v 1.3 2001/03/19 19:30:07 min Exp min $
//
#include <math.h>
#include <stdio.h>
#include "Vector.h"
#include "MyRandom.h"
using namespace std;
static const Float epsilon = 1e-6; // for ccw
Vector::Vector(Float a, Float b, Float c)
{
set(a, b, c);
} // Vector constructor
Vector::Vector(Float a, Float b, Float c, Float d)
{
set(a, b, c, d);
} // Vector constructor
void
Vector::set(Float a, Float b, Float c)
{
set(a, b, c, 1);
} // set with 3 parameters
void
Vector::set(Float a, Float b, Float c, Float d)
{
elm[X] = a;
elm[Y] = b;
elm[Z] = c;
elm[W] = d;
} // set with 4 parameters
Vector
Vector::operator +(const Vector& A)
{
Vector result;
for(int i = 0; i < VECTOR_SIZE; i++)
result[i] = elm[i] + A[i];
return result;
} // Vector operator +
Vector
Vector::operator -(Vector& A)
{
Vector result;
for(int i = 0; i < VECTOR_SIZE; i++)
result[i] = elm[i] - A[i];
return result;
} // Vector operator -
Vector
Vector::operator -()
{
Vector result;
for(int i = 0; i < VECTOR_SIZE; i++)
result[i] = -elm[i];
return result;
} // Vector operator - (unary)
int
Vector::operator ==(const Vector &B)
{
for(int i = 0; i < VECTOR_SIZE; i++)
if (elm[i] != B[i]) return 0;
return 1;
} // Vector::operator ==
int
Vector::operator !=(const Vector& B)
{
for(int i = 0; i < VECTOR_SIZE; i++)
if (elm[i] != B[i]) return 1;
return 0;
} // Vector::operator !=
Float
Vector::operator *(const Vector& A)
{
Float result = 0;
for(int i = 0; i < VECTOR_SIZE; i++)
result += elm[i] * A[i];
return result;
} // Vector operator * (in product)
ostream&
operator <<(ostream& out_stream, const Vector& T)
{
out_stream << "[";
for(int i = 0; i < MAX_SIZE; i++) {
out_stream << T[i];
if (i < (MAX_SIZE - 1)) out_stream << ", ";
}
out_stream << "]";
return out_stream;
} // Vector operator <<
istream&
operator>>(istream& in_stream, Vector& T)
{
cout << "Vector operator>>" << endl;
char k;
in_stream >> k;
cout << "read char " << k << endl;
for(int i=0; i < VECTOR_SIZE; i++) {
in_stream >> T[i];
cout << "read T[" << i << "]: " << T[i] << endl;
if (i < (VECTOR_SIZE - 1)) in_stream >> k;
}
in_stream >> k;
cout << "read char " << k << endl;
return in_stream;
} // Vector operator >>
Float
Vector::sum()
{
return(elm[X] + elm[Y] + elm[Z]);
} // Vector::sum
Float
Vector::squared_length()
{
Float squared_length = 0;
for(int i = 0; i < VECTOR_SIZE; i++)
squared_length += elm[i] * elm[i];
return squared_length;
} // Vector::squared_length
Float
Vector::length()
{
Float len = squared_length();
return sqrt(len);
} // Vector::length
Float
Vector::squared_distance(Vector& V)
{
Vector diff;
for(int i=0; i < VECTOR_SIZE; i++)
diff[i] = elm[i] - V[i];
return diff.squared_length();
} // Vector::squared_distance
Float
Vector::distance(Vector& V)
{
Vector diff;
for(int i=0; i < VECTOR_SIZE; i++)
diff[i] = elm[i] - V[i];
return diff.length();
} // Vector::distance
void
Vector::normalize()
{
Float my_length = length();
if (my_length) {
for(int i = 0; i < VECTOR_SIZE; i++)
elm[i] /= my_length;
}
} // normalize
Vector
operator *(const Vector& A, const Float scalar)
{
Vector result;
for(int i = 0; i < VECTOR_SIZE; i++)
result[i] = scalar * A[i];
return result;
} // mult. operator for scalar * Vector
Vector
operator *(const Float scalar, const Vector& A)
{
return (A * scalar);
} // multiply for Vector * scalar
Vector
operator /(const Vector& A, const Float scalar)
{
Vector result;
for(int i = 0; i < VECTOR_SIZE; i++)
result[i] = A[i] / scalar;
return result;
} // division operator for Vector / scalar
void
Vector::clamp(Float min, Float max)
{
for(int i=0; i < VECTOR_SIZE; i++) {
if (elm[i] > max) elm[i] = max;
else if (elm[i] < min) elm[i] = min;
}
} // Vector::clamp
Vector
Vector::vec_abs()
{
Vector result;
for(int i=0; i < VECTOR_SIZE; i++) {
result[i] = fabs(elm[i]);
}
return result;
} // Vector::vec_abs
Vector
Vector::round()
{
Vector result;
for(int i=0; i < VECTOR_SIZE; i++) {
result[i] = floor(elm[i] + 0.5);
}
return result;
} // Vector::round
Vector
Vector::operator ^(const Vector& A)
{
Vector result;
result[X] = elm[Y] * A[Z] - A[Y] * elm[Z];
result[Y] = A[X] * elm[Z] - elm[X] * A[Z];
result[Z] = elm[X] * A[Y] - A[X] * elm[Y];
return result;
} // cross product, operator ^
int
ccw(Vector& A, Vector& B, Vector& C)
{
if (A == B) {
if (A == C) return 0;
else return 2;
}
if ((A == C) || (B == C)) return 0;
Float ccw_value = (B[X] * C[Y] - C[X] * B[Y] -
A[X] * C[Y] + C[X] * A[Y] +
A[X] * B[Y] - B[X] * A[Y]);
if (ccw_value > epsilon) return 1;
else if (ccw_value < -epsilon) return -1;
Vector L = B - A;
Vector R = C - A;
if ((L * R) < 0) return -2;
L = A - B;
R = C - B;
if ((L * R) < 0) return 2;
return 0;
} // ccw
Matrix
Vector::star()
{
Matrix *M = new Matrix(0, -elm[X], elm[Y],
elm[Z], 0, -elm[X],
-elm[Y], elm[X], 0);
return *M;
} // Vector::star, create matrix to mult by matrix to create crossprod
Matrix
Vector::outer_product()
{
Matrix *M = new Matrix(elm[X] * elm[X], elm[X] * elm[Y], elm[X] * elm[Z],
elm[Y] * elm[X], elm[Y] * elm[Y], elm[Y] * elm[Z],
elm[Z] * elm[X], elm[Z] * elm[Y], elm[Z] * elm[Z]);
return *M;
} // Vector::outer_product
int
Vector::max_dimension()
{
if ((elm[X] > elm[Y]) && (elm[X] > elm[Z]))
return X;
else {
if ((elm[Y] > elm[X]) && (elm[Y] > elm[Z]))
return Y;
else
return Z;
}
} // Vector::max_dimension
int intersect(Vector& p1, Vector& p2, Vector& q1, Vector& q2)
//
// for each pair of ccw's (the first pair being ccw1 and ccw2, the
// second ccw3 and ccw4) it should be true that either:
// - at least one of them is zero (implying that the third or fourth
// point is inside the first line segment)
// - or their product is negative (implying that the first and second
// point of the other segment lie on opposite sides)
//
{
int ccw1 = ccw(p1, p2, q1);
int ccw2 = ccw(p1, p2, q2);
int ccw3 = ccw(q1, q2, p1);
int ccw4 = ccw(q1, q2, p2);
return (((ccw1 * ccw2) <= 0) || ((ccw3 * ccw4) <= 0));
} // intersect
void
Vector::random_in_sphere()
{
// get point on surface of 4D sphere and normalize...
Float temp[4];
Float length = 0;
for(int i=0; i < 4; i++) {
temp[i] = MyRandom::gaussian();
length += temp[i] * temp[i];
}
length = sqrt(length);
for(int i=0; i < 3; i++)
{ // 3!
temp[i] /= length;
elm[i] = temp[i];
}
elm[W] = 1.0;
} // Vector::random_in_sphere
void
Vector::random_on_sphere()
{
for(int i=0; i < VECTOR_SIZE; i++) {
elm[i] = MyRandom::gaussian();
} // for
normalize();
} // Vector::random_on_sphere
void
Vector::project(Vector normal)
{
Vector temp = (*this * normal) * normal;
*this = *this - temp;
} // Vector::project
void
Vector::uniform(Float min, Float max)
{
for(int i=0; i < VECTOR_SIZE; i++) {
elm[i] = MyRandom::uniform(min, max);
}
} // Vector::uniform
void
Vector::rotate(Vector& axis, Float angle)
{
//
// Rotate vector counterclockwise around axis (looking at axis end-on) (rz(xaxis) = yaxis)
// From Goldstein: v' = v cos t + a (v . a) [1 - cos t] - (v x a) sin t
//
Float cos_angle = cos(angle);
Float dot = *this * axis;
Vector cross = *this ^ axis;
Vector temp = *this;
*this = cos_angle * temp;
*this = *this + dot * (1.0 - cos_angle) * axis;
cross = sin(angle) * cross;
*this = *this - cross;
} // Vector::rotate
//
// scale by another vector, X by X, etc.
//
void
Vector::scale(Vector& scale)
{
elm[X] *= scale[X];
elm[Y] *= scale[Y];
elm[Z] *= scale[Z];
} // Vector::scale
void
Vector::flip_y_z()
{
Float temp = elm[Y];
elm[Y] = elm[Z];
elm[Z] = temp;
} // Vector::flip_y_z
|
47aaa3e09a6bd62d086cf38c5c667c85c648531f | 5e2729c110be2faed5b589b6369a6521522a78f6 | /src/gstochar.h | 96b508227eb92d9d31cce8186c83d9d7c69089d6 | [] | no_license | kananb/Console-Image-Display-OLD | 0cb188800bf1a865e64279733b3452c12b34a3aa | 72ec6e104029e1ab24dc122156c4e84353b24e22 | refs/heads/master | 2021-10-23T00:34:51.955713 | 2019-03-13T23:35:15 | 2019-03-13T23:35:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 634 | h | gstochar.h | #ifndef GUARD_GSTOCHAR_H
#define GUARD_GSTOCHAR_H
#pragma once
namespace gtc {
const char chGSRamp[] = {
' ', '.', '\'', '`', '^', '"', ',', ':', ';', 'I',
'l', '!', 'i', '>', '<', '~', '+', '_', '-', '?',
']', '[', '}', '{', '1', ')', '(', '|', '\\', '/',
't', 'f', 'j', 'r', 'x', 'n', 'u', 'v', 'c', 'z',
'X', 'Y', 'U', 'J', 'C', 'L', 'Q', '0', 'O', 'Z',
'm', 'w', 'q', 'p', 'd', 'b', 'k', 'h', 'a', 'o',
'*', '#', 'M', 'W', '&', '8', '%', 'B', '@', '$'
};
const int nRampLen = (int)strlen(chGSRamp);// 70;
const float fRampConversion = (float)(255. / (nRampLen - 1));// 3.64285714f;
}
#endif // GUARD_GSTOCHAR_H |
7dbf353788b1af9a5b84efcdfeb04774b2362143 | f1eb042365f987eaa759faa8b97811d66423628f | /HapticEvaluation/HapticThreadSingleHaptic.h | 99bc61288287e93fc358e80b5e1e481b4c773c1a | [] | no_license | cyhd/HaCoE | 72e3f89fb3284bf3cca557c370c129371f255ddf | 27b05d01a0f2ce3d4e6ab0ffeba774e65dbe8b1c | refs/heads/master | 2020-12-29T02:32:34.879438 | 2017-03-02T12:38:00 | 2017-03-02T12:38:00 | 43,976,216 | 1 | 0 | null | 2017-03-02T11:55:45 | 2015-10-09T19:35:19 | C | UTF-8 | C++ | false | false | 2,001 | h | HapticThreadSingleHaptic.h | /**********************************************************************************************************
HapticThreadSingleHaptic class
Created: May 2014
Author: Cedric Dumas
This class is used to control perform a single haptic force feedback experiment.
dominante hand device will be used: HaptDeviceA or HaptDeviceB
The thread will poll the GUI through haptlinksupervisor for the stop command while running. If a stop command
is detected, then the thread stops.
*************************************************************************************************************/
#pragma once
#include <qthread.h>
#include "HapticThread.h"
#include <QKeyEvent>
class HapticThreadSingleHaptic : public HapticThread
{
public:
HapticThreadSingleHaptic( void );
~HapticThreadSingleHaptic( void );
void run();
protected:
Vector3 outputForce;
Vector3 outputForceDirection; //a copy of the output force vector, but it is used only for its direction
Vector3 outputTorque;
Vector3 replicateForce; //the amount of force to output to resist movement on replicating device
Vector3 replicateTorque;
HapticDevice *outputDevice;
HapticDevice *replicateDevice;
double outputForceMagnitude; //used to computer unit vector
Vector3 outputForceUnitVector; //unit vector in direction of output force
Vector3 deviation; //absolute position w.r.t. home position
double dotProduct; //used to compute the projection of the deviation from home onto vector parallel to the output force
Vector3 trans; //position of the replicate device (translational)
Matrix3x3 rot; //position of the replicate device (rotational)
double t2;
double t5;
double t10;
static const double HR_GENERAL_DAMPING_TRANSLATION;
static const double HR_GENERAL_DAMPING_ROTATION;
static const double X_HOME;
static const double Y_HOME;
static const double Z_HOME;
static const int SWITCH_TIME = 5000;
double HR_K_FORCE;
double HR_K_TORQUE;
private:
//int count;
bool seqSwitch;
int timeStart;
int currentTime;
}; |
ccf94e6912ce7d14306e0d8208feb3c85628af37 | 520d630ab1a2c473b628109eb45107c06e12159a | /smartab/Arduino/smartlab/smartlab.ino | 554c98382179e31b46e017ee94e0411b06b92121 | [
"Apache-2.0"
] | permissive | jeanadrien/evrythng-cern-hackathon | dd9d4c04944d26fa9323b58938cd9fc96e38c305 | 929637fa8338960931609359a4b737958e365e9f | refs/heads/master | 2021-01-19T07:34:24.903275 | 2016-04-25T10:08:55 | 2016-04-25T10:08:55 | 57,032,357 | 0 | 0 | null | 2016-04-25T10:16:52 | 2016-04-25T10:16:52 | null | UTF-8 | C++ | false | false | 2,266 | ino | smartlab.ino |
// Libraries to connect the board to the EVT cloud
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
#define DEBUG 0 //1 to see debug code on the serial port
#define MQTT_HOST "mqtt.evrythng.com"
#define MQTT_HOST_PORT 1883
// EVRYTHNG thng id and api key for the connected radon detector
#define THNG_ID "UDP8Neb8GFQpDUDesSte5bff"
#define DEVICE_API_KEY "Lp1WoHwYKReONRIXO7e1LE4OEQYiohDczm46yDXRJck9fhTUP3tOoOrFSOmsXxxS5DY9U7crirz6HIwc"
#define CLIENT_ID "radondetector"
// Update these with values suitable for your network.
byte mac[] = {
0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
};
void callback(char* topic, byte* payload, unsigned int length) {
// handle message arrived
}
EthernetClient ethClient;
PubSubClient client(MQTT_HOST, MQTT_HOST_PORT, callback, ethClient);
void setup()
{
pinMode(A0, OUTPUT);
if (DEBUG) {
Serial.begin(9600);
delay(100);
// this check is only needed on the Leonardo:
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
}
if (Ethernet.begin(mac) == 0) {
if (DEBUG) {
Serial.println("Failed to configure Ethernet using DHCP");
}
// no point in carrying on, so do nothing forevermore:
for (;;)
;
}
if (DEBUG) {
// print your local IP address:
Serial.print("My IP address: ");
for (byte thisByte = 0; thisByte < 4; thisByte++) {
// print the value of each byte of the IP address:
Serial.print(Ethernet.localIP()[thisByte], DEC);
Serial.print(".");
}
}
if (DEBUG) {
Serial.println("Ready");
}
}
char payload[32];
volatile int current_level;
int previous_level = 0;
void loop()
{
if (!client.loop()) {
if (client.connect(CLIENT_ID, "authorization", DEVICE_API_KEY)) {
if (DEBUG) {
Serial.println("Successfully connected to the cloud");
}
} else {
if (DEBUG) {
Serial.println("Could not connected to the cloud");
for (;;)
;
}
}
}
delay(8000);
current_level = analogRead(A0);
if (previous_level != current_level) {
sprintf(payload, "[{\"value\":%d}]", current_level);
previous_level = current_level;
client.publish("/thngs/" THNG_ID "/properties/concentration", payload);
}
}
|
6be80028d48ca564d3be8343370ca1c30690a9db | 8f56e6e27dde1a2a5db8744f9bd4b40061648d67 | /src/util/pragma.cpp | 49bffe3d6413eddded52376d16c98ea6f763fdc7 | [] | no_license | anroysko/contestlib | a0231f91f947428ad8bead1fbc2090aa598bb3d7 | d2c494c1730b4141401c3510c13bf35277f71215 | refs/heads/master | 2022-02-01T17:02:32.099784 | 2022-01-31T02:47:11 | 2022-01-31T02:47:11 | 138,644,894 | 11 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 152 | cpp | pragma.cpp | #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
|
588a80999c14a16dc5d79adcc3bccafaaf92c5cd | 0d9f953352e3e628aafeefd4ed5afad2bdd22588 | /StreamSocketFsm.h | e07c29ca6bdb1a6a46f75ddb9a2b09369b7f16aa | [] | no_license | MartijnS1997/socket_interface | 1b9e1c2c99e2d885192a0db2e76157fae658f27f | ae3b664f2a347f1d11c1405099734da508af50e3 | refs/heads/master | 2020-03-28T11:08:43.329290 | 2018-09-10T17:28:41 | 2018-09-10T17:28:41 | 148,180,952 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,668 | h | StreamSocketFsm.h | #ifndef STREAMSOCKETFSM_H
#define STREAMSOCKETFSM_H
#include "SocketAddress.h"
#include "FdGuard.h"
namespace snl{
struct StrSoConnect {StrSoConnect() = default;};
struct StrSoSend { StrSoSend() = default; };
struct StrSoReceive { StrSoReceive() = default; };
struct StrSoUClose {StrSoUClose() = default;};
struct StrSoDClose {StrSoDClose() = default;};
struct StrSoClose {StrSoClose() = default; };
struct StrSoReset {StrSoReset() = default; };
struct StrSoReConnect {StrSoReConnect() = default; };
constexpr StrSoConnect connectAct{};
constexpr StrSoSend sendAct{};
constexpr StrSoReceive receiveAct{};
constexpr StrSoUClose upstrCloseAct{};
constexpr StrSoDClose downstrCloseAct{};
constexpr StrSoClose closeAct{};
constexpr StrSoReset resetAct{};
constexpr StrSoReConnect resetConnectAct{};
class StreamSocketFsm
{
public:
enum class StrSoFsmState:uint8_t {INIT = 0, CONNECTED = 1, UCLOSED = 2, DCLOSED = 3, CLOSED = 4};
StreamSocketFsm();
StreamSocketFsm(FdGuard&& fdGuard, SocketAddress address);
~StreamSocketFsm();
template<typename Action, typename ...Args>
void toNextState(Action& action, Args&&... args){
toNextStateImpl(action, std::forward<Args>(args)...);
}
void setNonBlock(bool nonBlockVal);
SocketAddress getSockAddress();
bool isNonBlock();
bool isConnected();
bool upstreamClosed();
bool downStreamClosed();
bool isClosed();
static constexpr int upstreamShutdown = 1;
static constexpr int downstreamShutdown = 0;
static constexpr bool defaultNonBlock = false;
private:
void toNextStateImpl(const StrSoConnect&, const SocketAddress& socketAddress);
void toNextStateImpl(const StrSoSend&, const void* buffer, std::size_t bufferSize, std::size_t& bytesSent, int flags); //sets the buffer size to the size of the unread portion
void toNextStateImpl(const StrSoReceive&, void* buffer, std::size_t bufferSize, std::size_t& bytesReceived, int flags);
void toNextStateImpl(const StrSoUClose&);
void toNextStateImpl(const StrSoDClose&);
void toNextStateImpl(const StrSoClose&);
void toNextStateImpl(const StrSoReset&);
void toNextStateImpl(const StrSoReConnect&);
static void connectCheck(StrSoFsmState current);
static void sendCheck(StrSoFsmState current);
static void receiveCheck(StrSoFsmState current);
static void upstreamCloseCheck(StrSoFsmState current);
static void downsreamCloseCheck(StrSoFsmState current);
static void closeCheck(StrSoFsmState current);
static void resetConnectCheck(StrSoFsmState current);
//creates a socket fd and connects it to the specified address
//common call for reset connection and connect, the non block val is to indicate if the socket is blocking or not
//-->saved blocking behavior will also be set here
static FdGuard createSockAndConnect(const SocketAddress& address, bool nonBlockVal);
//setter for the blocking behavior of the blocking call
//if nonBlockVal == true, the fd will be set to nonblock
static void setFdBlockingBehav(FdGuard& guard, bool nonBlockVal);
SocketAddress socketAddress;
FdGuard strSoFd;
bool nonBlock = defaultNonBlock;
StrSoFsmState fsmState;
};
}
#endif // STREAMSOCKETFSM_H
|
059644907d6700f65de74e948ae72651f1ae1063 | b9253a0b8cabf5bd9fc54e5916f11ad3f5c8ba18 | /Classes/GameData.cpp | 4a7ed57192c5c6a9c70e692e5474804d11077e41 | [] | no_license | Crasader/koudaixianxia_client | 982e58bea57581aad766230f3861e5da83b7f5d5 | a68c1c440a0a91b6dddd5177e5ccb6b352727bfb | refs/heads/master | 2020-12-07T08:21:19.450933 | 2014-11-30T00:47:24 | 2014-11-30T00:47:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,955 | cpp | GameData.cpp | //
// GameData.cpp
// TestGame
//
// Created by lh on 13-9-12.
// www.9miao.com
//
#include "GameData.h"
#include "stdlib.h"
static GameData *gamedata=NULL;
GameData::GameData(){
eneMoveFlag=false;
SkillBtnIsTouch= false;
fire_Flag=false;
roleDic= CCDictionary::create();
roleDic->retain();
eneDic=CCDictionary::create();
eneDic->retain();
roleArr=CCArray::create();
roleArr->retain();
enemyArr=CCArray::create();
enemyArr->retain();
posArr=CCArray::create();
posArr->retain();
msg_dic= CCDictionary::create();
msg_dic->retain();
}
GameData::~GameData(){
}
int GameData::getRandom(){
int random=arc4random()%1000+1;
// int send=1;
// srand(unsigned(time(NULL)));
// switch (random) {
// case 0:
// send=rand()%1000+1;
// break;
// case 1:
// send=rand()%1000+1;
// break;
// case 2:
// send=rand()%1000+1;
// break;
// case 3:
// send=rand()%1000+1;
// break;
// case 4:
// send=rand()%1000+1;
// break;
// case 5:
// send=rand()%1000+1;
// break;
// default:
// break;
// }
return random;
}
GameData * GameData::shareGameData(){
if(!gamedata)
gamedata = new GameData();
return gamedata;
}
void GameData::setTouchPoint(cocos2d::CCPoint pos){
point=pos;
}
CCPoint GameData::getTouchPoint(){
return point;
}
//inline const ::allPetInfo1101::PetFight& GameData::pfinfo(int index) const {
// return pfinfo_.Get(index);
//}
//inline const ::google::protobuf::RepeatedPtrField< ::allPetInfo1101::PetFight >&
//GameData::pfinfo() const {
// return pfinfo_;
//}
//void GameData::setPetFightArr(::google::protobuf::RepeatedPtrField< ::allPetInfo1101::PetFight > pfinfo){
// pfinfo_=pfinfo;
//}
//
//void GameData::setGroupList(::google::protobuf::RepeatedPtrField< ::instanceInfo1201::Group > grouplist){
// grouplist_=grouplist;
//}
//inline const ::google::protobuf::RepeatedPtrField< ::instanceInfo1201::Group >&
//GameData::grouplist() const{
// return grouplist_;
//}
//inline const ::instanceInfo1201::Group& GameData::grouplist(int index) const{
// return grouplist_.Get(index);
//}
//
//
//inline const ::MonsterInfo& GameData::mlist(int index) const {
// return mlist_.Get(index);
//}
//inline const ::google::protobuf::RepeatedPtrField< ::MonsterInfo >&
//GameData::mlist() const {
// return mlist_;
//}
//void GameData::setMonsterGroup(::google::protobuf::RepeatedPtrField< ::MonsterInfo> mlist){
// mlist_=mlist;
//}
attackInfo::attackInfo(){
charid=0;
attack_id=0;
countofAttack=0;
skillId=0;
attack_time="";
attackeds=CCArray::create();
attackeds->retain();
}
attackInfo::~attackInfo(){
}
attackedInfo::attackedInfo(){
}
attackedInfo::~attackedInfo(){
}
|
b8b05641557d133289eee1c6b7808c7f0f8ea8f1 | 4610baf9a7e81cad6e52fe49289a5f234861732b | /planner/aw_topology/include/aw_Graph.h | ff1f5a8de5f1bba82972113a3ee04708c03e1c35 | [] | no_license | kuasha/stanley | 07f924f6ff61413f5baabd5b6605d4289e93c68d | b6b6d3a9efd4611258b2a6337ef25007f406bd80 | refs/heads/master | 2021-01-19T00:57:09.752337 | 2016-08-15T02:36:18 | 2016-08-15T02:36:18 | 65,698,509 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,119 | h | aw_Graph.h | /********************************************************
Stanford Driving Software
Copyright (c) 2011 Stanford University
All rights reserved.
Redistribution and use in source and binary forms, with
or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* The names of the contributors may not be used to endorse
or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
********************************************************/
#ifndef AW_GRAPH_H
#define AW_GRAPH_H
#include <list>
#include <map>
#include <set>
#include <vector>
#include <assert.h>
#include <vlrException.h>
#include <aw_Counter.h>
namespace vlr {
namespace RoutePlanner {
class AnnotatedRouteEdge;
template<class EdgeT> class Vertex {
public:
typedef std::list<EdgeT *> EdgeList;
typedef typename EdgeList::const_iterator EdgeIterator;
typedef std::set<EdgeT*> TEdgeSet;
Vertex(int id = -1) : id(id) {}
virtual ~Vertex() {}
// deprecated interface
void addEdge(EdgeT* edge) { assert(edge); assert(edge > (EdgeT*)0x040000); edgeList.push_back(edge); }
void removeEdge(EdgeT* edge) { edgeList.remove(edge); }
typename EdgeList::iterator beginEdges() { return edgeList.begin(); }
typename EdgeList::iterator endEdges() { return edgeList.end(); }
EdgeIterator beginEdges() const { return edgeList.begin(); }
EdgeIterator endEdges() const { return edgeList.end(); }
int getNumberOfEdges() const { return edgeList.size(); }
// new interface
void addInEdge(EdgeT* edge) { assert(edge); assert(edge > (EdgeT *)0x040000); m_inEdges.insert(edge); }
void removeInEdge(EdgeT* edge) { assert(edge); m_inEdges.erase(edge); }
bool hasInEdge(EdgeT* edge) const { return m_inEdges.find(edge) != m_inEdges.end(); }
size_t numInEdges() const { return m_inEdges.size(); }
const TEdgeSet& inEdges() const { return m_inEdges; }
void addOutEdge(EdgeT* edge) { assert(edge); assert(edge > (EdgeT *)0x040000); m_outEdges.insert(edge); }
void removeOutEdge(EdgeT* edge) { assert(edge); m_outEdges.erase(edge); }
bool hasOutEdge(EdgeT* edge) const { return m_outEdges.find(edge) != m_outEdges.end(); }
size_t numOutEdges() const { return m_outEdges.size(); }
const TEdgeSet& outEdges() const { return m_outEdges; }
int getId() const { return id; }
protected:
EdgeList edgeList;
TEdgeSet m_outEdges;
TEdgeSet m_inEdges;
int id;
};
template<class VertexT> class Edge {
public:
Edge(VertexT * from, VertexT * to, double weight = 1., int id = -1)
: visited_( false ), from(from), to(to), id(id), weight(weight)/*, annotatedEdge(0)*/
{
assert(weight > 0.); // has to be greater than 0. otherwise the AStar Route Planner fails
}
virtual ~Edge() { }
void deleteVertices() {
delete to;
to = 0;
delete from;
from = 0;
}
virtual VertexT * fromVertex() {
return from;
}
virtual VertexT * toVertex() {
return to;
}
virtual VertexT const * fromVertex() const {
return from;
}
virtual VertexT const * toVertex() const {
return to;
}
int getId() const {
return id;
}
double getWeight() const {
return weight;
}
bool visited() const {return visited_;}
void setVisited(bool visited = true) {visited_ = visited;}
/* this is evil :) RndfEdge <-> AnnotetedRouteEdge is no 1:1 relation
// get link to annotation if available (if edge is in route graph)
AnnotatedRouteEdge* getAnnotatedEdge() {
return annotatedEdge;
}
const AnnotatedRouteEdge* getAnnotatedEdge() const {
return annotatedEdge;
}
void setAnnotatedEdge(AnnotatedRouteEdge* annoEdge) {
annotatedEdge=annoEdge;
}
*/
protected:
bool visited_;
VertexT* from;
VertexT* to;
int id;
double weight;
// AnnotatedRouteEdge* annotatedEdge;
};
template<class VertexT, class EdgeT> class Graph {
public:
typedef std::map<int, VertexT*> VertexMap;
typedef std::map<int, EdgeT*> EdgeMap;
typedef std::list<EdgeT*> EdgeList;
typedef std::set<EdgeT*> EdgeSet;
typedef std::vector<EdgeT*> EdgeId2EdgeMap;
typedef std::vector<VertexT*> VertexId2EdgeMap; // TODO: verify
Graph() {}
virtual ~Graph();
VertexT * addVertex();
VertexT * addVertex(int id);
EdgeT * connect(VertexT * v1, VertexT * v2, double weight = 1.);
EdgeT * connect(VertexT * v1, VertexT * v2, double weight, int edgeId);
void removeEdge(EdgeT * edge);
VertexT * getVertex(int id);
EdgeT * edge(int id);
EdgeT * findIncomingEdge(VertexT * to);
int countIncomingEdge(VertexT * to);
EdgeList * searchPath(VertexT * from, VertexT * to, bool ignore_blockades = false);
// returns a set of edges that are according to the graph
EdgeSet edges();
// const EdgeMap& edges() const {return edgeMap;}
protected:
virtual double searchHeuristic(const VertexT* /*vertex*/, const VertexT* /*goal*/) {
return 0.;
}
public:
EdgeMap edgeMap;
EdgeId2EdgeMap edges_;
protected:
VertexMap vertexMap;
VertexId2EdgeMap vertices_;
rndf::Counter vertex_id_count_, edge_id_count_;
};
template<class VertexT, class EdgeT>
VertexT * Graph<VertexT, EdgeT>::addVertex() {
return addVertex(vertex_id_count_.getNextId());
}
template<class VertexT, class EdgeT> VertexT * Graph<VertexT, EdgeT>::addVertex(int id) {
VertexT * v = new VertexT(id);
vertexMap.insert(make_pair(id, v));
return v;
}
template<class VertexT, class EdgeT>
EdgeT* Graph<VertexT, EdgeT>::connect(VertexT * v1, VertexT * v2, double weight) {
return connect(v1, v2, weight, edge_id_count_.getNextId());
}
template<class VertexT, class EdgeT>
EdgeT* Graph<VertexT, EdgeT>::connect(VertexT * v1, VertexT * v2, double weight, int edgeId)
{
assert( edgeMap.find(edgeId) == edgeMap.end() );
assert(v1 && v2);
EdgeT * edge = new EdgeT(v1, v2, weight, edgeId);
v1->addEdge(edge);
v1->addOutEdge(edge);
v2->addInEdge(edge);
edgeMap.insert(make_pair(edgeId, edge));
return edge;
}
template<class VertexT, class EdgeT> VertexT * Graph<VertexT, EdgeT>::getVertex(int id) {
typename VertexMap::iterator it = vertexMap.find(id);
if (it == vertexMap.end()) {
return NULL;
} else {
return it->second;
}
}
template<class VertexT, class EdgeT> EdgeT * Graph<VertexT, EdgeT>::edge(int id) {
typename EdgeMap::iterator it = edgeMap.find(id);
if (it == edgeMap.end()) {
return NULL;
} else {
return it->second;
}
}
template<class VertexT, class EdgeT> EdgeT * Graph<VertexT, EdgeT>::findIncomingEdge(VertexT * to) {
// #warning this looks sick. consider adapting vertex and edge types to allow backward traversal
for (typename EdgeMap::iterator it = edgeMap.begin(); it != edgeMap.end(); ++it) {
if (it->second->toVertex() == to) {
return it->second;
}
}
return NULL;
}
template<class VertexT, class EdgeT> int Graph<VertexT, EdgeT>::countIncomingEdge(VertexT * to) {
int count=0;
for (typename EdgeMap::iterator it = edgeMap.begin(); it != edgeMap.end(); ++it) {
if (it->second->toVertex() == to) {
++count;
}
}
return count;
}
template<class VertexT, class EdgeT> Graph<VertexT, EdgeT>::~Graph() {
for (typename VertexMap::iterator vit = vertexMap.begin(); vit != vertexMap.end(); ++vit) {
delete vit->second;
}
for (typename EdgeMap::iterator eit = edgeMap.begin(); eit != edgeMap.end(); ++eit) {
delete eit->second;
}
}
template<class VertexT, class EdgeT> void Graph<VertexT, EdgeT>::removeEdge(EdgeT * edge) {
assert(edge->fromVertex());
assert(edge->toVertex());
edge->fromVertex()->removeEdge(edge);
edge->fromVertex()->removeOutEdge(edge);
edge->toVertex()->removeInEdge(edge);
//typename EdgeMap::iterator it = find(edgeMap.begin(), edgeMap.end(), edge->getId());
typename EdgeMap::iterator it = edgeMap.find(edge->getId());
assert(it != edgeMap.end());
edgeMap.erase(it);
delete edge;
}
template<class VertexT, class EdgeT> typename Graph<VertexT, EdgeT>::EdgeSet Graph<VertexT, EdgeT>::edges() {
EdgeSet edges;
for (typename EdgeMap::iterator it = edgeMap.begin(); it != edgeMap.end(); ++it)
edges.insert(it->second);
return edges;
}
}
} // namespace vlr
#endif
|
8fdcc458624e0a857f69430a4af22fe80dfc9823 | 74837c92508b3190f8639564eaa7fa4388679f1d | /xic/src/main/pcell_params.cc | 051fd660030e8fe4b3ffde419f1200ce893a1098 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | frankhoff/xictools | 35d49a88433901cc9cb88b1cfd3e8bf16ddba71c | 9ff0aa58a5f5137f8a9e374a809a1cb84bab04fb | refs/heads/master | 2023-03-21T13:05:38.481014 | 2022-09-18T21:51:41 | 2022-09-18T21:51:41 | 197,598,973 | 1 | 0 | null | 2019-07-18T14:07:13 | 2019-07-18T14:07:13 | null | UTF-8 | C++ | false | false | 66,602 | cc | pcell_params.cc |
/*========================================================================*
* *
* Distributed by Whiteley Research Inc., Sunnyvale, California, USA *
* http://wrcad.com *
* Copyright (C) 2017 Whiteley Research Inc., all rights reserved. *
* Author: Stephen R. Whiteley, except as indicated. *
* *
* As fully as possible recognizing licensing terms and conditions *
* imposed by earlier work from which this work was derived, if any, *
* this work is released under the Apache License, Version 2.0 (the *
* "License"). You may not use this file except in compliance with *
* the License, and compliance with inherited licenses which are *
* specified in a sub-header below this one if applicable. A copy *
* of the License is provided with this distribution, or you may *
* obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* See the License for the specific language governing permissions *
* and limitations under the License. *
* *
* 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 NON- *
* INFRINGEMENT. IN NO EVENT SHALL WHITELEY RESEARCH INCORPORATED *
* OR STEPHEN R. WHITELEY 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. *
* *
*========================================================================*
* XicTools Integrated Circuit Design System *
* *
* Xic Integrated Circuit Layout and Schematic Editor *
* *
*========================================================================*
$Id:$
*========================================================================*/
#include "cd.h"
#include "pcell_params.h"
#include "si_parsenode.h"
#include "si_parser.h"
#include "si_interp.h"
#include "errorlog.h"
#include "spnumber/spnumber.h"
#include "miscutil/encode.h"
#include <algorithm>
// Equality operator for PCellParam lists. Lists are equal if there
// is a 1-1 correspondence between properties, and all values match.
//
bool PCellParam::matching(const PCellParam *p1, const PCellParam *p2)
{
int n1 = 0;
for (const PCellParam *p = p1; p; p = p->next())
n1++;
int n2 = 0;
for (const PCellParam *p = p2; p; p = p->next())
n2++;
if (n1 != n2)
return (false);
if (n1 == 0)
return (true);
const PCellParam *p2last = p2;
for (const PCellParam *p = p1; p; p = p->next()) {
if (!p2last || strcmp(p->name(), p2last->name())) {
for (p2last = p2; p2last; p2last = p2last->next()) {
if (!strcmp(p->name(), p2last->name()))
break;
}
if (!p2last)
return (false);
}
if (p->type() != p2last->type())
return (false);
switch (p->type()) {
case PCPbool:
if (p->boolVal() != p2last->boolVal())
return (false);
break;
case PCPint:
if (p->intVal() != p2last->intVal())
return (false);
break;
case PCPtime:
if (p->timeVal() != p2last->timeVal())
return (false);
break;
case PCPfloat:
if (p->floatVal() != p2last->floatVal())
return (false);
break;
case PCPdouble:
if (p->doubleVal() != p2last->doubleVal())
return (false);
break;
case PCPstring:
{
const char *s1 = p->stringVal();
if (!s1)
s1 = "";
const char *s2 = p2last->stringVal();
if (!s2)
s2 = "";
if (strcmp(s1, s2))
return (false);
}
break;
case PCPappType:
{
if (p->appValSize() != p2last->appValSize())
return (false);
unsigned int sz = p->appValSize();
if (sz && memcmp(p->appVal(), p2last->appVal(), sz))
return (false);
}
break;
}
p2last = p2last->next();
}
return (true);
}
namespace {
bool boolval(const char *str)
{
if (isdigit(*str))
return (atoi(str));
return (lstring::cieq(str, "true") || lstring::cieq(str, "on"));
}
long longval(const char *str)
{
return (strtol(str, 0, 10));
}
float floatval(const char *str)
{
return (strtof(str, 0));
}
double doubleval(const char *str)
{
return (strtod(str, 0));
}
}
PCellParam::PCellParam(char typ, const char *nam, const char *val,
const char *constr)
{
switch (typ) {
case 'b':
case 'B':
init(PCPbool, nam, constr);
u.ival = boolval(val);
break;
case 'i':
case 'I':
init(PCPint, nam, constr);
u.ival = longval(val);
break;
case 't':
case 'T':
init(PCPtime, nam, constr);
u.ival = longval(val);
break;
case 'f':
case 'F':
init(PCPfloat, nam, constr);
u.fval = floatval(val);
break;
case 'd':
case 'D':
init(PCPdouble, nam, constr);
u.dval = doubleval(val);
break;
case 'a':
case 'A':
init(PCPappType, nam, constr);
p_appsize = 0;
u.aval = 0;
break;
default:
init(PCPstring, nam, constr);
u.sval = lstring::copy(val);
break;
}
}
// Return a text token naming the type.
//
const char *
PCellParam::typestr()
{
switch (type()) {
case PCPbool:
return ("bool");
case PCPint:
return ("int");
case PCPtime:
return ("time");
case PCPfloat:
return ("float");
case PCPdouble:
return ("double");
case PCPstring:
return ("string");
case PCPappType:
return ("apptype");
break;
}
// not reached
return (0);
}
// Set a single parameter from p. Try to coerce a type if it seems
// reasonable. Only set the variable if the new value differs, to
// avoid unnecessarily setting the changed flag.
//
// Return true if the data types are compatible, false otherwise.
//
bool
PCellParam::set(const PCellParam *p)
{
const char *s;
switch (type()) {
case PCPbool:
{
bool bv;
switch (p->type()) {
case PCPbool:
if (boolVal() != p->boolVal())
setBoolVal(p->boolVal());
return (true);
case PCPint:
bv = (p->intVal() != 0);
if (boolVal() != bv)
setBoolVal(bv);
return (true);
case PCPtime:
bv = (p->timeVal() != 0);
if (boolVal() != bv)
setBoolVal(bv);
return (true);
case PCPfloat:
bv = (p->floatVal() != 0.0);
if (boolVal() != bv)
setBoolVal(bv);
return (true);
case PCPdouble:
bv = (p->doubleVal() != 0.0);
if (boolVal() != bv)
setBoolVal(bv);
return (true);
case PCPstring:
s = p->stringVal();
if (s) {
int v = -1;
if (!strcasecmp(s, "1") || !strcasecmp(s, "t") ||
!strcasecmp(s, "true") || !strcasecmp(s, "y") ||
!strcasecmp(s, "yes") || !strcasecmp(s, "on"))
v = 1;
else if (!strcasecmp(s, "0") || !strcasecmp(s, "n") ||
!strcasecmp(s, "no") || !strcasecmp(s, "nil") ||
!strcasecmp(s, "f") || !strcasecmp(s, "false") ||
!strcasecmp(s, "off"))
v = 0;
if (v >= 0) {
bv = v;
if (boolVal() != bv)
setBoolVal(bv);
return (true);
}
}
break;
case PCPappType:
break;
}
}
return (false);
case PCPint:
{
long iv;
switch (p->type()) {
case PCPbool:
iv = p->boolVal();
if (intVal() != iv)
setIntVal(iv);
return (true);
case PCPint:
if (intVal() != p->intVal())
setIntVal(p->intVal());
return (true);
case PCPtime:
iv = p->timeVal();
if (intVal() != iv)
setIntVal(iv);
return (true);
case PCPfloat:
iv = mmRndL(p->floatVal());
if (intVal() != iv)
setIntVal(iv);
return (true);
case PCPdouble:
iv = mmRndL(p->doubleVal());
if (intVal() != iv)
setIntVal(iv);
return (true);
case PCPstring:
s = p->stringVal();
if (s) {
double *d = SPnum.parse(&s, false);
if (d) {
iv = mmRndL(*d);
if (intVal() != iv)
setIntVal(iv);
return (true);
}
}
break;
case PCPappType:
break;
}
}
return (false);
case PCPtime:
{
long tv;
switch (p->type()) {
case PCPbool:
tv = p->boolVal();
if (timeVal() != tv)
setTimeVal(tv);
return (true);
case PCPint:
tv = p->intVal();
if (timeVal() != tv)
setTimeVal(tv);
return (true);
case PCPtime:
if (timeVal() != p->timeVal())
setTimeVal(p->timeVal());
return (true);
case PCPfloat:
tv = mmRndL(p->floatVal());
if (timeVal() != tv)
setTimeVal(tv);
return (true);
case PCPdouble:
tv = mmRndL(p->doubleVal());
if (timeVal() != tv)
setTimeVal(tv);
return (true);
case PCPstring:
s = p->stringVal();
if (s) {
double *d = SPnum.parse(&s, false);
if (d) {
tv = mmRndL(*d);
if (timeVal() != tv)
setTimeVal(tv);
return (true);
}
}
break;
case PCPappType:
break;
}
}
return (false);
case PCPfloat:
{
float fv;
switch (p->type()) {
case PCPbool:
fv = p->boolVal();
if (floatVal() != fv)
setFloatVal(fv);
return (true);
case PCPint:
fv = p->intVal();
if (floatVal() != fv)
setFloatVal(fv);
return (true);
case PCPtime:
fv = p->timeVal();
if (floatVal() != fv)
setFloatVal(fv);
return (true);
case PCPfloat:
if (floatVal() != p->floatVal())
setFloatVal(p->floatVal());
return (true);
case PCPdouble:
fv = p->doubleVal();
if (floatVal() != fv)
setFloatVal(fv);
return (true);
case PCPstring:
s = p->stringVal();
if (s) {
double *d = SPnum.parse(&s, false);
if (d) {
fv = *d;
if (floatVal() != fv)
setFloatVal(fv);
return (true);
}
}
break;
case PCPappType:
break;
}
}
return (false);
case PCPdouble:
{
double dv;
switch (p->type()) {
case PCPbool:
dv = p->boolVal();
if (doubleVal() != dv)
setDoubleVal(dv);
return (true);
case PCPint:
dv = p->intVal();
if (doubleVal() != dv)
setDoubleVal(dv);
return (true);
case PCPtime:
dv = p->timeVal();
if (doubleVal() != dv)
setDoubleVal(dv);
return (true);
case PCPfloat:
dv = p->floatVal();
if (doubleVal() != dv)
setDoubleVal(dv);
return (true);
case PCPdouble:
if (doubleVal() != p->doubleVal())
setDoubleVal(p->doubleVal());
return (true);
case PCPstring:
s = p->stringVal();
if (s) {
double *d = SPnum.parse(&s, false);
if (d) {
dv = *d;
if (doubleVal() != dv)
setDoubleVal(dv);
return (true);
}
}
break;
case PCPappType:
break;
}
}
return (false);
case PCPstring:
{
char buf[64];
switch (p->type()) {
case PCPbool:
sprintf(buf, "%d", p->boolVal());
if (!stringVal() || strcmp(stringVal(), buf))
setStringVal(buf);
return (true);
case PCPint:
sprintf(buf, "%ld", p->intVal());
if (!stringVal() || strcmp(stringVal(), buf))
setStringVal(buf);
return (true);
case PCPtime:
sprintf(buf, "%ld", (long)p->timeVal());
if (!stringVal() || strcmp(stringVal(), buf))
setStringVal(buf);
return (true);
case PCPfloat:
sprintf(buf, "%.9g", p->floatVal());
if (!stringVal() || strcmp(stringVal(), buf))
setStringVal(buf);
return (true);
case PCPdouble:
sprintf(buf, "%.15lg", p->doubleVal());
if (!stringVal() || strcmp(stringVal(), buf))
setStringVal(buf);
return (true);
case PCPstring:
if ((!stringVal() && p->stringVal()) ||
(stringVal() && !p->stringVal()) ||
(stringVal() && p->stringVal() &&
strcmp(stringVal(), p->stringVal())))
setStringVal(p->stringVal());
return (true);
case PCPappType:
break;
}
}
return (false);
case PCPappType:
{
switch (p->type()) {
case PCPbool:
break;
case PCPint:
break;
case PCPtime:
break;
case PCPfloat:
break;
case PCPdouble:
break;
case PCPstring:
break;
case PCPappType:
if ((appValSize() != p->appValSize()) ||
memcmp(appVal(), p->appVal(),
p->appValSize()))
setAppVal(p->appVal(), p->appValSize());
return (true);
}
}
break;
}
return (false);
}
// Static function.
// Duplicate a parameter list.
//
PCellParam *
PCellParam::dup(const PCellParam *thispc)
{
PCellParam *p0 = 0, *pe = 0;
for (const PCellParam *p = thispc; p; p = p->next()) {
PCellParam *pn = 0;
switch (p->type()) {
case PCPbool:
pn = new PCellParam(p->type(), p->name(), p->constraint_string(),
p->boolVal());
break;
case PCPint:
pn = new PCellParam(p->type(), p->name(), p->constraint_string(),
(long)p->intVal());
break;
case PCPtime:
pn = new PCellParam(p->type(), p->name(), p->constraint_string(),
(long)p->timeVal());
break;
case PCPfloat:
pn = new PCellParam(p->type(), p->name(), p->constraint_string(),
p->floatVal());
break;
case PCPdouble:
pn = new PCellParam(p->type(), p->name(), p->constraint_string(),
p->doubleVal());
break;
case PCPstring:
pn = new PCellParam(p->type(), p->name(), p->constraint_string(),
p->stringVal());
break;
case PCPappType:
pn = new PCellParam(p->type(), p->name(), p->constraint_string(),
p->appName(), p->appVal(), p->appValSize());
break;
}
if (!p0)
p0 = pe = pn;
else {
pe->setNext(pn);
pe = pn;
}
}
return (p0);
}
// Set the parameters in this from p0. The p0 should be a subset of
// the params in this, params in p0 and not this are ignored.
//
void
PCellParam::setup(const PCellParam *p0)
{
{
PCellParam *ppt = this;
if (!ppt)
return;
}
if (!p0)
return;
SymTab tab(false, false);
for (PCellParam *p = this; p; p = p->next())
tab.add(p->name(), p, false);
for (const PCellParam *q = p0; q; q = q->next()) {
PCellParam *p = (PCellParam*)SymTab::get(&tab, q->name());
if (p == (PCellParam*)ST_NIL)
continue;
p->set(q);
}
}
// All elements of this are set to corresponding p0 values, all
// changed flags are cleared.
//
void
PCellParam::reset(const PCellParam *p0)
{
{
PCellParam *ppt = this;
if (!ppt)
return;
}
if (!p0)
return;
SymTab tab(false, false);
for (PCellParam *p = this; p; p = p->next())
tab.add(p->name(), p, false);
for (const PCellParam *q = p0; q; q = q->next()) {
PCellParam *p = (PCellParam*)SymTab::get(&tab, q->name());
if (p == (PCellParam*)ST_NIL)
continue;
p->set(q);
p->p_changed = false;
}
}
// Update the single element that matches prm_name with the value
// given. It the constraint string is non-null, update the constraint
// as well. Return true if a change was made.
//
bool
PCellParam::setValue(const char *prm_name, double prm_value,
const char *constr)
{
PCellParam *p = find(this, prm_name);
if (!p)
return (false);
if (constr) {
while (isspace(*constr))
constr++;
if (*constr) {
PConstraint *pc = new PConstraint();
const char *c = constr;
if (!pc->parseConstraint(&c)) {
Log()->WarningLogV(mh::Initialization,
"Failed to parse new constraint string\n %s\n"
"for parameter %s. constraint unchanged.",
constr, p_name);
delete pc;
}
else {
delete [] p->p_constr_str;
p->p_constr_str = lstring::copy(constr);
delete p->p_constr;
p->p_constr = pc;
}
}
}
if (p->type() == PCPbool) {
bool b = (prm_value != 0.0);
if (b != p->boolVal()) {
p->setBoolVal(b);
return (true);
}
}
else if (p->type() == PCPint) {
long i = mmRndL(prm_value);
if (i != p->intVal()) {
p->setIntVal(i);
return (true);
}
}
else if (p->type() == PCPtime) {
long i = mmRndL(prm_value);
if (i != p->timeVal()) {
p->setTimeVal(i);
return (true);
}
}
else if (p->type() == PCPfloat) {
float f = prm_value;
if (f != p->floatVal()) {
p->setFloatVal(f);
return (true);
}
}
else if (p->type() == PCPdouble) {
if (prm_value != p->doubleVal()) {
p->setDoubleVal(prm_value);
return (true);
}
}
else if (p->type() == PCPstring) {
char buf[128];
sprintf(buf, "%.15g", prm_value);
if (strcmp(buf, p->stringVal() ? p->stringVal() : "")) {
p->setStringVal(buf);
return (true);
}
}
return (false);
}
// Update the single element that matches prm_name with the value
// given. It the constraint string is non-null, update the constraint
// as well. Return true if a change was made.
//
bool
PCellParam::setValue(const char *prm_name, const char *prm_value,
const char *constr)
{
PCellParam *p = find(this, prm_name);
if (!p)
return (false);
if (constr) {
while (isspace(*constr))
constr++;
if (*constr) {
PConstraint *pc = new PConstraint();
const char *c = constr;
if (!pc->parseConstraint(&c)) {
Log()->WarningLogV(mh::Initialization,
"Failed to parse new constraint string\n %s\n"
"for parameter %s. constraint unchanged.",
constr, p_name);
delete pc;
}
else {
delete [] p->p_constr_str;
p->p_constr_str = lstring::copy(constr);
delete p->p_constr;
p->p_constr = pc;
}
}
}
if (p->type() == PCPbool) {
bool b = boolval(prm_value);
if (b != p->boolVal()) {
p->setBoolVal(b);
return (true);
}
}
else if (p->type() == PCPint) {
long i = longval(prm_value);
if (i != p->intVal()) {
p->setIntVal(i);
return (true);
}
}
else if (p->type() == PCPtime) {
long i = longval(prm_value);
if (i != p->timeVal()) {
p->setTimeVal(i);
return (true);
}
}
else if (p->type() == PCPfloat) {
float f = floatval(prm_value);
if (f != p->floatVal()) {
p->setFloatVal(f);
return (true);
}
}
else if (p->type() == PCPdouble) {
double d = doubleval(prm_value);
if (d != p->doubleVal()) {
p->setDoubleVal(d);
return (true);
}
}
else if (p->type() == PCPstring) {
if (strcmp(prm_value, p->stringVal() ? p->stringVal() : "")) {
p->setStringVal(prm_value);
return (true);
}
}
return (false);
}
char *
PCellParam::getValue() const
{
if (type() == PCPstring)
return (lstring::copy(stringVal()));
char buf[64];
if (type() == PCPbool) {
sprintf(buf, "%s", boolVal() ? "1" : "0");
return (lstring::copy(buf));
}
if (type() == PCPint) {
sprintf(buf, "%ld", intVal());
return (lstring::copy(buf));
}
if (type() == PCPtime) {
sprintf(buf, "%ld", intVal());
return (lstring::copy(buf));
}
if (type() == PCPfloat) {
sprintf(buf, "%.9g", floatVal());
return (lstring::copy(buf));
}
if (type() == PCPdouble) {
sprintf(buf, "%.15lg", doubleVal());
return (lstring::copy(buf));
}
return (0);
}
char *
PCellParam::getValueByName(const char *prm_name) const
{
const PCellParam *p = find_c(this, prm_name);
if (p)
return (p->getValue());
return (0);
}
// Return an assignment string, which will be parsed by the Xic script
// interpreter for parameter initialization of native pcells.
//
char *
PCellParam::getAssignment() const
{
sLstr lstr;
lstr.add(name());
lstr.add(" = ");
char *v = getValue();
lstr.add(v);
delete [] v;
return (lstr.string_trim());
}
// Return a string containing a TCL parameter assignment in the form
// set name [expr "val"] (numeric values)
// set name "val" (pre-quoted strings)
//
// Note that any param names in the value string MUST have a $
// prepending, this is not added here.
//
char *
PCellParam::getTCLassignment() const
{
sLstr lstr;
lstr.add("set ");
lstr.add(name());
char *v = getValue();
if (!v)
v = lstring::copy("\"\"");
if (*v == '"') {
lstr.add_c(' ');
lstr.add(v);
}
else {
lstr.add(" [expr \"");
lstr.add(v);
lstr.add("\"]");
}
delete [] v;
return (lstr.string_trim());
}
// This will update the existing elements from the passed string,
// which is in the format described for the parse() function. No new
// elements are created, names not found and syntax errors are
// ignored. True is returned if a change was made.
//
bool
PCellParam::update(const char *str)
{
if (!str)
return (false);
bool chgd = false;
const char *s = str;
while (*s) {
char typ, *nam, *val, *cns;
if (!getPair(&s, &typ, &nam, &val, &cns))
break;
if (nam) {
if (setValue(nam, val, cns))
chgd = true;
}
delete [] nam;
delete [] val;
delete [] cns;
}
return (chgd);
}
namespace {
inline bool pccmp(const PCellParam *p1, const PCellParam *p2)
{
return (strcmp(p1->name(), p2->name()) > 0);
}
}
// Print the element to a string. The format is
//
// type:name=value:constraint
//
// type:
// Single character type specifier, for all but string type. In
// strings that are used with Xic native PCells, all parameters are
// "string" type, so the type character and following colon will not
// appear.
//
// name=value
// The parameter name and value.
//
// :constraint
// Optional colon-separated constraint string. This is skipped if
// noconstr is true.
//
char *
PCellParam::this_string(bool noconstr) const
{
sLstr lstr;
// New type prefix.
switch (type()) {
case PCPbool:
lstr.add_c('b');
lstr.add_c(PCP_TYPE_SEP);
break;
case PCPint:
lstr.add_c('i');
lstr.add_c(PCP_TYPE_SEP);
break;
case PCPtime:
lstr.add_c('t');
lstr.add_c(PCP_TYPE_SEP);
break;
case PCPfloat:
lstr.add_c('f');
lstr.add_c(PCP_TYPE_SEP);
break;
case PCPdouble:
lstr.add_c('d');
lstr.add_c(PCP_TYPE_SEP);
break;
case PCPstring:
// No prefix in this case.
break;
case PCPappType:
lstr.add_c('a');
lstr.add_c(PCP_TYPE_SEP);
break;
}
lstr.add(name());
lstr.add_c('=');
switch (type()) {
case PCPbool:
lstr.add(boolVal() ? "1" : "0");
break;
case PCPint:
lstr.add_i(intVal());
break;
case PCPtime:
lstr.add_i(timeVal());
break;
case PCPfloat:
lstr.add_d(floatVal(), 9, true);
break;
case PCPdouble:
lstr.add_d(doubleVal(), 9, true);
break;
case PCPstring:
{
const char *str = stringVal();
if (str) {
bool quotme = false;
if (*str != '\'' && *str != '"') {
for (const char *s = str; *s; s++) {
if (isspace(*s) || *s == PCP_WORD_SEP ||
*s == PCP_CONS_SEP) {
quotme = true;
break;
}
}
}
if (quotme)
lstr.add_c('"');
// If the string is already double-quoted, add a
// leading backslash which forces preservation of
// the quotes in the string.
else if (*str == '"')
lstr.add_c('\\');
lstr.add(str);
if (quotme)
lstr.add_c('"');
}
else {
lstr.add_c('"');
lstr.add_c('"');
}
}
break;
case PCPappType:
lstr.add("0");
break;
}
if (!noconstr) {
// Add the constraint if there is one.
const char *cns = constraint_string();
if (cns && *cns) {
lstr.add_c(PCP_CONS_SEP);
lstr.add(cns);
}
}
return (lstr.string_trim());
}
// Print the list to a string. The format is
//
// type:name=value:constraint,type:name=value,...
//
// Elements are separated by commas. There is no white space, except
// possibly enclosed in strings. If a string token contains commas,
// colons, or white space, it will be double quoted.
//
// If noconstr, the constraints will be skipped over and ignored.
//
char *
PCellParam::string(bool noconstr) const
{
sLstr lstr;
for (const PCellParam *p = this; p; p = p->next()) {
char *s = p->this_string(noconstr);
lstr.add(s);
delete [] s;
if (p->next())
lstr.add_c(PCP_WORD_SEP);
}
return (lstr.string_trim());
}
// Return a digest string that is unique for the parameter set and values
// independent of order.
//
char *
PCellParam::digest() const
{
int n = 0;
for (const PCellParam *p = this; p; p = p->next())
n++;
if (n == 0)
return (lstring::copy("noparams"));
const PCellParam **ary = new const PCellParam*[n];
n = 0;
for (const PCellParam *p = this; p; p = p->next())
ary[n++] = p;
if (n > 1)
std::sort(ary, ary + n, pccmp);
sLstr lstr;
for (int i = 0; i < n; i++) {
const PCellParam *p = ary[i];
if (p->type() == PCPappType) {
lstr.add_i(p->appValSize());
for (unsigned int k = 0; k < p->appValSize(); k++) {
char c = p->appVal()[k];
lstr.add_c(c ? c : '0');
}
}
else {
char *s = ary[i]->this_string(true);
lstr.add(s);
delete [] s;
}
}
delete [] ary;
// MD5 likes 4-byte boundaries.
while (lstr.length() % 4)
lstr.add_c('$');
n = lstr.length();
// Compute the MD5 digest.
MD5cx ctx;
ctx.update((unsigned char*)lstr.string(), n);
unsigned char *fstr = new unsigned char[17];
memset(fstr, 0, 17);
ctx.final(fstr);
// Remap the chars so that they are all valid in GDSII cell names.
// These are 0-9a-zA-Z?$_
const char *good =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$?_";
int mod = strlen(good);
for (n = 0; n < 16; n++)
fstr[n] = good[fstr[n] % mod];
return ((char*)fstr);
}
// Print the list (debugging).
//
void
PCellParam::print() const
{
for (const PCellParam *p = this; p; p = p->next()) {
char *s = p->this_string(false);
printf("%s\n", s);
delete [] s;
}
}
// Static function.
// Get one name = value pair and advance the pointer. The expected
// element syntax is
//
// [typechar:]name [=] value[:constraint] [,]
//
// Return false on a fatal syntax error, else return true. The
// pointers should be checked on a true return, a null name indicates
// end of data.
//
bool
PCellParam::getPair(const char **pstr, char *ptype, char **pname,
char **pvalue, char **pconstraint)
{
*ptype = 0;
*pname = 0;
*pvalue = 0;
if (pconstraint)
*pconstraint = 0;
char *nam = 0;
char *val = 0;
char *constr = 0;
// Skip leading space and word separation characters.
const char *s = *pstr;
while (*s == PCP_WORD_SEP || isspace(*s))
s++;
if (!*s) {
*pstr = s;
return (true);
}
// s now points to first char of [type:]name, parse this.
char typ = 0;
if (*(s+1) == PCP_TYPE_SEP) {
typ = *s;
s += 2;
}
*ptype = typ;
// Copy the parameter name, which is terminated by '=' or white
// space.
const char *eq = s;
while (*eq && *eq != '=' && !isspace(*eq))
eq++;
int len = eq - s;
nam = new char[len + 1];
strncpy(nam, s, len);
nam[len] = 0;
// Note that nam can be empty, which is not good, but we'll look
// at the rest of the token before dealing with it.
// Skip to start of value.
s = eq + 1;
while (*s == '=' || isspace(*s))
s++;
const char *sep = s;
if (*sep) {
// This is a little tricky. It the value starts out with a
// double quote character, read up to the matching quote
// verbatim, but strip the quotes. If the value starts with a
// single quote, also read in verbatim but retain the quotes
// (for Python) unless the second character is a double quote
// mark. In this case, strip the single quotes, the double
// quotes will remain. This is for backward compatibility
// with '"a string"' as a way to preserve the double quotes
// for native string assignments.
//
// If the value starts with backslash-double quote, strip the
// backslash and retain the double quotes. When copying and
// searching for the ending quote, if an ending quote
// character is preceded by a backslash, copy both characters
// verbatim and continue searching.
const char *q2 = 0;
if (*sep == '"' || *sep == '\'') {
char q = *sep++;
bool killit = false;
if (q == '"' || *sep == '"') {
s++; // Skip leading quote.
killit = true;
}
while (*sep && (*sep != q || *(sep-1) == '\\'))
sep++;
if (*sep && killit)
q2 = sep; // Location of ending quote.
}
else if (*sep == '\\' && *(sep+1) == '"') {
char q = *(sep+1);
sep++;
sep++;
s++; // Skip backslash, but retain quote.
while (*sep && (*sep != q || *(sep-1) == '\\'))
sep++;
}
while (*sep && *sep != PCP_WORD_SEP && *sep != PCP_CONS_SEP &&
!isspace(*sep))
sep++;
len = sep - s;
val = new char[len + 1];
if (q2) {
// Don't copy the ending quote char.
strncpy(val, s, q2 - s);
strncpy(val + (q2 - s), q2 + 1, sep - q2 - 1);
val[len - 1] = 0;
}
else {
strncpy(val, s, len);
val[len] = 0;
}
// Look for a constraint string.
if (*sep == PCP_CONS_SEP) {
sep++;
s = sep;
q2 = 0;
if (*sep == '"' || *sep == '\'') {
char q = *sep++;
s++; // will skip leading quote
while (*sep && (*sep != q || *(sep-1) == '\\'))
sep++;
if (*sep)
q2 = sep; // location of ending quote
while (*sep && *sep != PCP_WORD_SEP && !isspace(*sep))
sep++;
len = sep - s;
constr = new char[len + 1];
if (q2) {
// Don't copy the ending quote char.
strncpy(constr, s, q2 - s);
strncpy(constr + (q2 - s), q2 + 1, sep - q2 - 1);
constr[len - 1] = 0;
}
else {
strncpy(constr, s, len);
constr[len] = 0;
}
// Make sure that it is valid.
PConstraint pc;
s = constr;
if (!pc.parseConstraint(&s)) {
// Syntax error.
delete [] nam;
delete [] val;
Errs()->add_error(
"Syntax error in constraint %s.", constr);
delete [] constr;
return (false);
}
}
else {
// Not quoted, the constraint parser determines the
// length.
PConstraint pc;
if (!pc.parseConstraint(&sep)) {
// Syntax error.
delete [] val;
Errs()->add_error(
"Syntax error in parameter %s constraint.", nam);
delete [] nam;
return (false);
}
constr = new char[sep - s + 1];
strncpy(constr, s, sep - s);
constr[sep - s] = 0;
}
}
}
// Now see if what we saved is ok.
if (*nam && val) {
if (!*val && typ) {
// Empty value accepted for string type only.
delete [] val;
delete [] constr;
Errs()->add_error("Empty value in parameter %s string.", nam);
delete [] nam;
return (false);
}
*pname = nam;
*pvalue = val;
if (pconstraint)
*pconstraint = constr;
else
delete [] constr;
}
else {
if (!*nam && (!val || !*val)) {
// No name or value, ignore.
delete [] nam;
delete [] val;
delete [] constr;
}
else {
// Syntax error.
delete [] val;
delete [] constr;
Errs()->add_error("Syntax error in parameter %s string.",
nam ? nam : "");
delete [] nam;
return (false);
}
}
*pstr = sep;
return (true);
}
// Static function.
// Take the user-supplied input string and return in pret a PCellParam
// list. The input format is as described for the string() method.
// It is assumed to consist of pairs of name/value tokens, separated
// by white space, commas, or equal signs. It supports the
// [typechar:] prefixing on parameter names, and Ciranova-style
// constraint strings which can follow the value separated by a colon.
// I.e.,
//
// [typechar:]name [=] value[:constraint] [,]
//
// Note that white space is a delimiter and is otherwise ignored, and
// the '=' and ',' characters are optional. If the leading character
// of a value is a single or double quote, all characters up to the
// matching quote will be read verbatim, with the quotes stripped.
//
bool
PCellParam::parseParams(const char *str, PCellParam **pret)
{
*pret = 0;
if (!str)
return (true);
PCellParam *p0 = 0, *pe = 0;
const char *s = str;
while (*s) {
char typ, *nam, *val, *cns;
if (!getPair(&s, &typ, &nam, &val, &cns)) {
PCellParam::destroy(p0);
return (false);
}
if (!nam)
break;
PCellParam *px = new PCellParam(typ, nam, val, cns);
if (!p0)
p0 = pe = px;
else {
pe->setNext(px);
pe = px;
}
delete [] nam;
delete [] val;
delete [] cns;
}
*pret = p0;
return (true);
}
// Private function to initialize the constraint.
//
void
PCellParam::init_constraint()
{
p_constr = 0;
if (p_constr_str) {
p_constr = new PConstraint();
const char *c = p_constr_str;
if (!p_constr->parseConstraint(&c)) {
Log()->WarningLogV(mh::Initialization,
"Failed to parse constraint string\n %s\n"
"for parameter %s. constraint ignored.",
p_constr_str, p_name);
delete p_constr;
p_constr = 0;
delete [] p_constr_str;
p_constr_str = 0;
}
}
}
// End of PCellParam functions.
//
// Parse methods for Ciranova-style parameter constraint strings,
// which are in the form of Python function calls.
//
PConstraint::PConstraint()
{
pc_type = PCunknown;
pc_action = PCAreject;
pc_choice_list = 0;
pc_scale = lstring::copy("u"); // default value
pc_low = 0.0;
pc_high = 0.0;
pc_resol = 0.0;
pc_step = 0.0;
pc_start = 0.0;
pc_limit = 0.0;
pc_sfact = factor(pc_scale);
pc_low_none = true;
pc_high_none = true;
pc_resol_none = true;
pc_step_none = true;
pc_start_none = false; // defaults to 0
pc_limit_none = true;
}
namespace {
// Return true and set pd if the param is numeric, including a
// string value that can be parsed as a number.
//
bool numeric_val(const PCellParam *p, double *pd)
{
if (p->type() == PCPstring) {
const char *t = p->stringVal();
double *d = SPnum.parse(&t, false);
if (d) {
*pd = *d;
return (true);
}
return (false);
}
if (p->type() == PCPint) {
*pd = p->intVal();
return (true);
}
if (p->type() == PCPtime) {
*pd = p->timeVal();
return (true);
}
if (p->type() == PCPfloat) {
*pd = p->floatVal();
return (true);
}
if (p->type() == PCPdouble) {
*pd = p->doubleVal();
return (true);
}
return (false);
}
bool numeric_val(const char *str, double *pd)
{
double *d = SPnum.parse(&str, false);
if (d) {
*pd = *d;
return (true);
}
return (false);
}
}
// Return false if the constraint forbids the value in the argument,
// true if ok or doesn't apply.
//
bool
PConstraint::checkConstraint(const PCellParam *p) const
{
if (!p || p->type() == PCPbool || p->type() == PCPappType)
return (true);
if (pc_action == PCAaccept)
return (true);
if (pc_type == PCchoice) {
if (!pc_choice_list)
return (true);
if (p->type() == PCPstring) {
const char *str = p->stringVal();
if (!str)
str = "";
for (stringlist *sl = pc_choice_list; sl; sl = sl->next) {
if (lstring::cieq(str, sl->string))
return (true);
}
return (false);
}
double val = 0;
if (numeric_val(p, &val)) {
for (stringlist *sl = pc_choice_list; sl; sl = sl->next) {
const char *s = sl->string;
double *d = SPnum.parse(&s, false);
if (d) {
if (*d == val)
return (true);
if (fabs(val - *d) < 1e-9*(fabs(val) + fabs(*d)))
return (true);
}
}
return (false);
}
return (true);
}
if (pc_type == PCrange) {
double val;
if (numeric_val(p, &val)) {
if (!pc_low_none && val < pc_low)
return (false);
if (!pc_high_none && val > pc_high)
return (false);
}
return (true);
}
if (pc_type == PCstep || pc_type == PCnumStep) {
// PCnumStep is like PCstep except that
// 1. The SPICE number parser is used to convert the string
// value, allowing use of suffix multipliers (e.g., 1k = 1e3).
// 2. The start, step, and limit values are internally multiplied
// by the scaleFactor before use (when parsed).
double val;
if (numeric_val(p, &val)) {
if (pc_step == 0.0) {
// In this case, treat like range.
if (!pc_start_none && val < pc_start)
return (false);
if (!pc_limit_none && val > pc_limit)
return (false);
return (true);
}
int n = mmRnd((val - pc_start)/pc_step);
if (n < 0)
return (false);
if (!pc_limit_none) {
if (pc_step > 0.0 && val > pc_limit)
return (false);
if (pc_step < 0.0 && val < pc_limit)
return (false);
}
double d = pc_start + n*pc_step;
if (d == val)
return (true);
if (fabs(d - val) < 1e-9*(fabs(d) + fabs(val)))
return (true);
return (false);
}
return (true);
}
return (true);
}
// Return false if the constraint forbids the value in the argument,
// true if ok or doesn't apply.
//
bool
PConstraint::checkConstraint(double val) const
{
if (pc_action == PCAaccept)
return (true);
if (pc_type == PCchoice) {
if (!pc_choice_list)
return (true);
for (stringlist *sl = pc_choice_list; sl; sl = sl->next) {
const char *s = sl->string;
double *d = SPnum.parse(&s, false);
if (d) {
if (*d == val)
return (true);
if (fabs(val - *d) < 1e-9*(fabs(val) + fabs(*d)))
return (true);
}
}
return (false);
}
if (pc_type == PCrange) {
if (!pc_low_none && val < pc_low)
return (false);
if (!pc_high_none && val > pc_high)
return (false);
return (true);
}
if (pc_type == PCstep || pc_type == PCnumStep) {
// PCnumStep is like PCstep except that
// 1. The SPICE number parser is used to convert the string
// value, allowing use of suffix multipliers (e.g., 1k = 1e3).
// 2. The start, step, and limit values are internally multiplied
// by the scaleFactor before use (when parsed).
if (pc_step == 0.0) {
// In this case, treat like range.
if (!pc_start_none && val < pc_start)
return (false);
if (!pc_limit_none && val > pc_limit)
return (false);
return (true);
}
int n = mmRnd((val - pc_start)/pc_step);
if (n < 0)
return (false);
if (!pc_limit_none) {
if (pc_step > 0.0 && val > pc_limit)
return (false);
if (pc_step < 0.0 && val < pc_limit)
return (false);
}
double d = pc_start + n*pc_step;
if (d == val)
return (true);
if (fabs(d - val) < 1e-9*(fabs(d) + fabs(val)))
return (true);
return (false);
}
return (true);
}
// Return false if the constraint forbids the value in the argument,
// true if ok or doesn't apply.
//
bool
PConstraint::checkConstraint(const char *string) const
{
if (pc_action == PCAaccept)
return (true);
if (!string)
string = "";
if (pc_type == PCchoice) {
if (!pc_choice_list)
return (true);
double val = 0;
if (numeric_val(string, &val)) {
for (stringlist *sl = pc_choice_list; sl; sl = sl->next) {
const char *s = sl->string;
double *d = SPnum.parse(&s, false);
if (d) {
if (*d == val)
return (true);
if (fabs(val - *d) < 1e-9*(fabs(val) + fabs(*d)))
return (true);
}
}
}
else {
for (stringlist *sl = pc_choice_list; sl; sl = sl->next) {
if (lstring::cieq(string, sl->string))
return (true);
}
}
return (false);
}
if (pc_type == PCrange) {
double val;
if (numeric_val(string, &val)) {
if (!pc_low_none && val < pc_low)
return (false);
if (!pc_high_none && val > pc_high)
return (false);
}
return (true);
}
if (pc_type == PCstep || pc_type == PCnumStep) {
// PCnumStep is like PCstep except that
// 1. The SPICE number parser is used to convert the string
// value, allowing use of suffix multipliers (e.g., 1k = 1e3).
// 2. The start, step, and limit values are internally multiplied
// by the scaleFactor before use (when parsed).
double val;
if (numeric_val(string, &val)) {
if (pc_step == 0.0) {
// In this case, treat like range.
if (!pc_start_none && val < pc_start)
return (false);
if (!pc_limit_none && val > pc_limit)
return (false);
return (true);
}
int n = mmRnd((val - pc_start)/pc_step);
if (n < 0)
return (false);
if (!pc_limit_none) {
if (pc_step > 0.0 && val > pc_limit)
return (false);
if (pc_step < 0.0 && val < pc_limit)
return (false);
}
double d = pc_start + n*pc_step;
if (d == val)
return (true);
if (fabs(d - val) < 1e-9*(fabs(d) + fabs(val)))
return (true);
return (false);
}
return (true);
}
return (true);
}
// Parse a Python constraint specification, setting the appropriate
// fields in this. Returns true if success, false otherwise with a
// message fragment in the error system.
//
bool
PConstraint::parseConstraint(const char **pstr)
{
if (!pstr)
return (true);
const char *c = *pstr;
if (!c || !*c)
return (true);
char *cname = lstring::gettok(&c, "(");
if (!cname) {
Errs()->add_error("no constraint typename given");
return (false);
}
if (lstring::ciprefix("choice", cname)) {
// ChoiceConstraint(choices, action=REJECT)
// choices: ['string', Layer('string') ... ]
delete [] cname;
if (!parse_argument(&c, "choices"))
goto bad;
if (!parse_argument(&c, "action"))
goto bad;
pc_type = PCchoice;
}
else if (lstring::ciprefix("range", cname)) {
// RangeConstraint(low, high, resolution=None, action=REJECT)
delete [] cname;
if (!parse_argument(&c, "low"))
goto bad;
if (!parse_argument(&c, "high"))
goto bad;
if (!parse_argument(&c, "resolution"))
goto bad;
if (!parse_argument(&c, "action"))
goto bad;
if (!pc_low_none && !pc_high_none && pc_low > pc_high) {
double tmp = pc_low;
pc_low = pc_high;
pc_high = tmp;
}
pc_type = PCrange;
}
else if (lstring::ciprefix("step", cname)) {
// StepConstraint(step, start=0, limit=None, resolution=None,
// action=REJECT)
delete [] cname;
if (!parse_argument(&c, "step"))
goto bad;
if (!parse_argument(&c, "start"))
goto bad;
if (!parse_argument(&c, "limit"))
goto bad;
if (!parse_argument(&c, "resolution"))
goto bad;
if (!parse_argument(&c, "action"))
goto bad;
pc_type = PCstep;
}
else if (lstring::ciprefix("numericstep", cname)) {
// NumericStepConstraint(step, start=0, limit=None, resolution=None,
// scaleFactor='u', action=REJECT)
// This is like "step" except that
// 1. The SPICE number parser is used to convert the string
// value, allowing use of suffix multipliers (e.g., 1k = 1e3).
// 2. The start, step, and limit values are internally multiplied
// by the scaleFactor before use.
delete [] cname;
if (!parse_argument(&c, "step"))
goto bad;
if (!parse_argument(&c, "start"))
goto bad;
if (!parse_argument(&c, "limit"))
goto bad;
if (!parse_argument(&c, "resolution"))
goto bad;
if (!parse_argument(&c, "scaleFactor"))
goto bad;
if (!parse_argument(&c, "action"))
goto bad;
double f = factor(pc_scale);
if (f != 0.0) {
pc_start *= f;
pc_step *= f;
pc_limit *= f;
}
pc_type = PCnumStep;
}
else {
Errs()->add_error("unknown constraint name: %s", cname);
delete [] cname;
goto bad;
}
// Get past the trailing ')', we'll accept white space here for no
// particularly good reason.
while (isspace(*c))
c++;
if (*c == ')')
c++;
*pstr = c;
return (true);
bad:
// Skip to the end of the token, presumably terminated by ')'.
while (*c && *c != ')')
c++;
if (*c == ')')
c++;
*pstr = c;
return (false);
}
// Static function.
// Return the numerical scale factor implied by the suffix string,
// or 0 if not recognized.
//
double
PConstraint::factor(const char *s)
{
if (s && *s) {
char c = isupper(*s) ? tolower(*s) : *s;
switch (c) {
case 'a': return (1e-18);
case 'f': return (1e-15);
case 'p': return (1e-12);
case 'n':
{
if (lstring::ciprefix("none", s))
return (0.0);
return (1e-9);
}
case 'u': return (1e-6);
case 'm':
{
if (lstring::ciprefix("meg", s))
return (1e6);
if (lstring::ciprefix("mil", s))
return (1e-3/39.3700787402);
return (1e-3);
}
case 'k': return (1e3);
case 'g': return (1e9);
case 't': return (1e12);
default:
break;
}
}
return (0.0);
}
// Parse an argument. The argname is the positional name, which is
// ignored if a keyword is found with the argument.
//
bool
PConstraint::parse_argument(const char **pstr, const char *argname)
{
const char *s = *pstr;
while (isspace(*s) || *s == ',')
s++;
if (!*s || *s == ')')
return (true);
char *keyword = 0;
if (isalpha(*s)) {
const char *t = s;
while (*t && !isspace(*t) && *t != '=' && *t != ',' && *t != ')')
t++;
while (isspace(*t))
t++;
if (*t == '=') {
// a keyword=value argument
keyword = new char[t - s + 1];
char *se = keyword;
while (!isspace(*s) && *s != '=')
*se++ = *s++;
*se = 0;
s = t+1;
}
}
if (!keyword)
keyword = lstring::copy(argname);
bool ret = true;
if (lstring::cieq(keyword, "choices"))
ret = parse_list(&s);
else if (lstring::cieq(keyword, "action"))
ret = parse_action(&s);
else if (lstring::cieq(keyword, "low"))
ret = parse_number(&s, &pc_low, &pc_low_none);
else if (lstring::cieq(keyword, "high"))
ret = parse_number(&s, &pc_high, &pc_high_none);
else if (lstring::cieq(keyword, "resolution"))
ret = parse_number(&s, &pc_resol, &pc_resol_none);
else if (lstring::cieq(keyword, "step"))
ret = parse_number(&s, &pc_step, &pc_step_none);
else if (lstring::cieq(keyword, "start"))
ret = parse_number(&s, &pc_start, &pc_start_none);
else if (lstring::cieq(keyword, "limit"))
ret = parse_number(&s, &pc_limit, &pc_limit_none);
else if (lstring::cieq(keyword, "scaleFactor")) {
delete [] pc_scale;
if (*s == '\'' || *s == '"')
pc_scale = parse_quoted(&s);
else {
const char *t = s;
while (*t && !isspace(*t) && *t != ',' && *t != ')')
t++;
int len = t - s;
pc_scale = new char[len + 1];
strncpy(pc_scale, s, len);
pc_scale[len] = 0;
s = t;
}
pc_sfact = factor(pc_scale);
}
else {
ret = false;
Errs()->add_error("unknown argument: %s", keyword);
}
delete [] keyword;
*pstr = s;
return (ret);
}
// Parse the list that is proveded for the "choices" value. A list
// consists of comma-separated tokens inside of square brackets.
// Elements can be either single-quoted strings or forms like
// "Layer('name')". In the latter case, we simply strip the Layer( )
// part. If success, the pc_choice_list is set to a list of unquoted
// tokens, the plst is advanced, and true is returned.
//
bool
PConstraint::parse_list(const char **plst)
{
const char *terms = ",()]";
const char *s = *plst;
while (isspace(*s) || *s == ',')
s++;
if (*s != '[') {
// Can't be a list!
return (false);
}
s++;
stringlist *sle = 0;
for (;;) {
while (isspace(*s) || *s == ',' || *s == ')')
s++;
if (*s == ']')
break;
if (*s == '\'' || *s == '"') {
// 'foo' or "foo"
char *str = parse_quoted(&s);
stringlist *sl = new stringlist(str, 0);
if (!sle)
sle = pc_choice_list = sl;
else {
sle->next = sl;
sle = sl;
}
}
else {
const char *t = s;
while (*t && !isspace(*t) && !strchr(terms, *t))
t++;
const char *e = t;
while (isspace(*e))
e++;
if (*e == '(') {
// Weird Ciranova thing, form like Layer(something), we
// keep only the something.
s = e + 1;
continue;
}
else {
// Unquoted word, just grab it verbatim.
int len = t - s;
if (len) {
char *str = new char[len + 1];
strncpy(str, s, len);
str[len] = 0;
stringlist *sl = new stringlist(str, 0);
if (!sle)
sle = pc_choice_list = sl;
else {
sle->next = sl;
sle = sl;
}
}
s = t;
}
}
}
*plst = s + 1;
return (true);
}
// Check the value of the action token. Set the pc_action if the
// token is recognized, advance pstr, and return true.
//
bool
PConstraint::parse_action(const char **pstr)
{
// Look for REJECT, ACCEPT, USE_DEFAULT.
const char *s = *pstr;
while (isspace(*s) || *s == ',')
s++;
if (lstring::ciprefix("REJECT", s)) {
s += 6;
pc_action = PCAreject;
}
else if (lstring::ciprefix("ACCEPT", s)) {
s += 6;
pc_action = PCAaccept;
}
else if (lstring::ciprefix("USE_DEFAULT", s)) {
s += 11;
pc_action = PCAdefault;
}
else
return (false);
*pstr = s;
return (true);
}
// Parse a token known to start with a single or double quote
// character. This returns a copy of the token with the quotes
// stripped, and advances pstr. We skip over the initial quote,
// copying characters until the final quote or a null byte.
//
char *
PConstraint::parse_quoted(const char **pstr)
{
const char *s = *pstr;
char q = *s++;
if (q != '\'' && q != '"')
return (0); // error
const char *t = s;
while (*t && *t != q)
t++;
char *str = new char[t - s + 1];
char *se = str;
while (s < t)
*se++ = *s++;
*se = 0;
*pstr = *s ? s+1 : s;
return (str);
}
// Parse a number token, which can be a raw number or a single-quoted
// string. We use the SPICE parser to handle the scale factors. If
// the parse succeeds, true is returned, and the result is in res.
// The pstr is advanced past the number token.
//
// Giving a value "None" will instead set the flag.
//
bool
PConstraint::parse_number(const char **pstr, double *res, bool *none)
{
const char *s = *pstr;
while (isspace(*s) || *s == ',')
s++;
if (*s == '\'' || *s == '"') {
char *str = parse_quoted(&s);
if (lstring::ciprefix("str", s)) {
*none = true;
*pstr = s;
return (true);
}
const char *t = str;
double *dp = SPnum.parse(&t, false);
delete [] str;
if (!dp) {
Errs()->add_error("number parse failure");
return (false);
}
*res = *dp;
}
else {
if (lstring::ciprefix("None", s)) {
*none = true;
*pstr = s + 4;
return (true);
}
double *dp = SPnum.parse(&s, false);
if (!dp) {
Errs()->add_error("number parse failure");
return (false);
}
*res = *dp;
}
*pstr = s;
*none = false;
return (true);
}
// End of PConstraint functions.
// Originally, Xic pcell names were required to have the form
// "basenameXXX", but any name is now accepted. The XXX, if present,
// will be stripped.
//
#define OLD_PCELL_SUFFIX "XXX"
// Return a unique sub-master cell name, used to name the Xic cells
// for the sub-master.
//
// There is no clobber-testing here. The user can set the cellname
// with PCellItem::setCellname, otherwise a "suggested" name is
// generated here.
//
char *
PCellDesc::cellname(const char *basename, const PCellItem *pi) const
{
if (pi->cellname())
return (lstring::copy(pi->cellname()));
int len = strlen(basename);
char *cname = new char[len + 18];
strcpy(cname, basename);
char *s = cname + len - strlen(OLD_PCELL_SUFFIX);
if (!strcmp(s, OLD_PCELL_SUFFIX))
*s = 0;
else
s = cname + len;
#define use_digest 0
if (use_digest) {
// Using the digest will give a repeatably unique name
// for a given parameter set.
char *dgn = pi->params()->digest();
// The digest is 16 chars plus a null terminator, enforce
// this anyway.
if (strlen(dgn) > 16)
dgn[16] = 0;
*s++ = '$';
strcpy(s, dgn);
delete [] dgn;
}
else
sprintf(s, "$$%u", pi->index());
return (cname);
}
// Static function.
// Encode the names into a single "dbname" token.
// Warning: CDs::setPCellFlags assumes this format.
//
char *
PCellDesc::mk_dbname(const char *libname, const char *cellname,
const char *viewname)
{
int len = 0;
len += libname ? strlen(libname) : 0;
len += cellname ? strlen(cellname) : 0;
len += viewname ? strlen(viewname) : 0;
len += 7;
char *dbname = new char[len];
char *t = dbname;
*t++ = '<';
if (libname)
t = lstring::stpcpy(t, libname);
*t++ = '>';
*t++ = '<';
if (cellname)
t = lstring::stpcpy(t, cellname);
*t++ = '>';
*t++ = '<';
if (viewname)
t = lstring::stpcpy(t, viewname);
*t++ = '>';
*t = 0;
return (dbname);
}
// Static function.
// Encode the Xic cellname into a single "dbname" token.
//
char *
PCellDesc::mk_native_dbname(const char *cellname)
{
return (mk_dbname(XIC_NATIVE_LIBNAME, cellname, "layout"));
}
// Static function.
// Split a "dbname" string into its components.
//
bool
PCellDesc::split_dbname(const char *dbname, char **libname, char **cellname,
char **viewname)
{
if (libname)
*libname = 0;
if (cellname)
*cellname = 0;
if (viewname)
*viewname = 0;
const char *t = dbname;
if (!t || *t != '<')
return (false);
t++;
const char *e = strchr(t, '>');
if (!e)
return (false);
char *lname = new char[e - t + 1];
strncpy(lname, t, e - t);
lname[e - t] = 0;
t = e + 1;
if (*t != '<') {
delete [] lname;
return (false);
}
t++;
e = strchr(t, '>');
if (!e) {
delete [] lname;
return (false);
}
char *cname = new char[e - t + 1];
strncpy(cname, t, e - t);
cname[e - t] = 0;
t = e + 1;
if (*t != '<') {
delete [] lname;
delete [] cname;
return (false);
}
t++;
e = strchr(t, '>');
if (!e) {
delete [] lname;
delete [] cname;
return (false);
}
char *vname = new char[e - t + 1];
strncpy(vname, t, e - t);
vname[e - t] = 0;
if (libname)
*libname = lname;
else
delete [] lname;
if (cellname)
*cellname = cname;
else
delete [] cname;
if (viewname)
*viewname = vname;
else
delete [] vname;
return (true);
}
// End of PCellDesc functions.
|
e5275a6fc339e5ef9d378cf18b75719504df69f4 | 6829c0c298a75142f736f5de61b471e12bb619d1 | /include/hmc5883l.h | 6579d441187731b6f5ea1c9b36e776a9df2c5f56 | [
"MIT"
] | permissive | superjax/airbourne | 9d0c59a9ddd2bb5bc36638e19464cddb8d5085c8 | 0d49d4615a5deff607891cbdcd620f99e04e9017 | refs/heads/master | 2021-01-12T02:03:27.624639 | 2017-01-12T17:20:01 | 2017-01-12T17:20:01 | 78,461,197 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,786 | h | hmc5883l.h | #ifndef HMC5883L_H
#define HMC5883L_H
#include "vector3.h"
#include "i2c.h"
#include "gpio.h"
#define HMC58X3_ADDR 0x1E
#define HMC58X3_CRA 0x00
#define HMC58X3_CRB 0x01
#define HMC58X3_MODE 0x02
#define HMC58X3_DATA 0x03
#define HMC58X3_STATUS 0x0A
#define HMC58X3_ID1 0x0B
#define HMC58X3_ID2 0x0C
#define HMC58X3_ID3 0x0D
#define HMC58X3_CRA_NO_AVG 0x00
#define HMC58X3_CRA_AVG_2_MEAS 0x20
#define HMC58X3_CRA_AVG_4_MEAS 0x40
#define HMC58X3_CRA_AVG_8_MEAS 0x60
#define HMC58X3_CRA_DO_0_75 0x00
#define HMC58X3_CRA_DO_1_5 0x04
#define HMC58X3_CRA_DO_3 0x08
#define HMC58X3_CRA_DO_7_5 0x0C
#define HMC58X3_CRA_DO_15 0x10
#define HMC58X3_CRA_DO_30 0x14
#define HMC58X3_CRA_DO_75 0x18
#define HMC58X3_CRA_MEAS_MODE_NORMAL 0x00
#define HMC58X3_CRA_MEAS_MODE_POS_BIAS 0x01
#define HMC58X3_CRA_MEAS_MODE_NEG_BIAS 0x02
#define HMC58X3_CRB_GN_1370 0x00
#define HMC58X3_CRB_GN_1090 0x20
#define HMC58X3_CRB_GN_820 0x40
#define HMC58X3_CRB_GN_660 0x60
#define HMC58X3_CRB_GN_440 0x80
#define HMC58X3_CRB_GN_390 0xA0
#define HMC58X3_CRB_GN_330 0xC0
#define HMC58X3_CRB_GN_230 0xE0
#define HMC58X3_MODE_HS 0x80
#define HMC58X3_MODE_CONTINUOUS 0x00
#define HMC58X3_MODE_SINGLE 0x01
#define HMC58X3_MODE_IDLE 0x02
#define HMC58X3_SR_LOCK 0x02
#define HMC58X3_SR_RDY 0x01
#define HMC58X3_TIMEOUT 30000
#include "magnetometer.h"
class HMC5883L : public Magnetometer
{
public:
HMC5883L();
bool init(I2C *I2CDev);
void update();
void read(vector3 *mag);
bool new_data();
void data_read_CB();
private:
void configure_DRDY_interrupt();
I2C* i2c;
GPIO DRDY_;
void blocking_read(vector3 *data);
vector3 gain_;
bool new_data_;
int16_t raw_data_[3];
uint8_t data_buffer_[6];
};
extern HMC5883L* HMC5883LPtr;
#endif // HMC5883L_H
|
087b44556b40e79e7d5a495109ff40a75ddde873 | 858f9d99cdf6807d3c52174a5d755e6ee36b7e53 | /unused/MGC3130.cpp | 08b6c2c1f775414d5990999c9f6525139243ffa4 | [] | no_license | twoentartian/UoG-UESTC_RTCSA_GroupProject | 42c826452e21895bb9a57345fb0a10bb3d0a06b5 | b82dd7ed2a57a90410d2ebfa081cafe2eb39eb2a | refs/heads/master | 2021-08-19T08:43:48.293569 | 2017-11-25T15:06:43 | 2017-11-25T15:06:43 | 109,779,499 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,380 | cpp | MGC3130.cpp | #include "MGC3130.h"
MGC3130::MGC3130(PinName sda, PinName scl, PinName EI0, bool IS2)
:TS_Line(EI0), _i2c_bus(sda,scl), msg(), sensor()
{
TS_Line.output();
TS_Line.write(1);
_i2c_bus.frequency(FREQUENCY_FULL);
if (IS2)
_addr = 0x86;
else
_addr = 0x84;
}
GestICMsg * MGC3130::readMsg()
{
TS_Line.input();
if (TS_Line.read() == 0)
return NULL;
msg.rewind();
TS_Line.output();
TS_Line.write(0);
_i2c_bus.start();
_i2c_bus.write(_addr | 0x01);
int size = _i2c_bus.read(1);
msg.set(size);
for (int i = 1; i < size - 1; i++)
msg.set(_i2c_bus.read(1));
msg.set(_i2c_bus.read(0));
_i2c_bus.stop();
TS_Line.write(1);
wait_us(200);
return &msg;
}
SensorData * MGC3130::readSensorData()
{
if (readMsg() != NULL && sensor.convert(&msg))
return &sensor;
else return NULL;
}
int MGC3130::setRuntimeParameter(Parameter * para)
{
_i2c_bus.start();
_i2c_bus.write(_addr);
_i2c_bus.write(0x10);
_i2c_bus.write(0x00);
_i2c_bus.write(0x00);
_i2c_bus.write(0xA2);
for (int i =0; i < Parameter::Length; i++)
_i2c_bus.write(para->gets()[i]);
_i2c_bus.stop();
while (!(readMsg() != NULL || msg.getID() == GestICMsg::System_Status))
setRuntimeParameter(para);
return msg.get(6) | (msg.get(7) << 8);
} |
c9df45e71c8e9c068902ee4919d483d9529666ed | 62b5756ab4b9639278eca9c19be9d7f9d4d0dbb8 | /src/renderer/Font.cpp | 160ae94cd0e684cea8591e58782700c6af649de0 | [] | no_license | Jon0/audio | 149a34ab457c89538c8a17a1d039d87e585153de | 792a74250fe905d92fa4d11f98a6168bf99d8080 | refs/heads/master | 2016-09-05T22:33:02.283077 | 2016-01-02T08:03:24 | 2016-01-02T08:03:24 | 11,997,668 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,214 | cpp | Font.cpp | extern "C" {
#define FT_CONFIG_OPTION_SUBPIXEL_RENDERING
#include <ft2build.h>
#include FT_FREETYPE_H
}
#include "Font.h"
namespace renderer {
Font::Font(const std::string &file_path) {
FT_Library library = 0;
FT_Face face = 0;
FT_Init_FreeType(&library);
//FT_Library_SetLcdFilter(library, FT_LCD_FILTER_LIGHT);
FT_New_Face(library, file_path.c_str(), 0, &face);
FT_Set_Char_Size(face, 0, 24 * 64, 300, 300);
FT_ULong charcode = 0x003f;
FT_UInt glyph_index = 0;
glyph_index = FT_Get_Char_Index(face, charcode);
FT_Load_Glyph(face, glyph_index, FT_LOAD_TARGET_NORMAL);
FT_Render_Glyph(face->glyph, FT_RENDER_MODE_LCD);
FT_Bitmap bitmap = face->glyph->bitmap;
FT_Glyph_Metrics metrics = face->glyph->metrics;
int colStartPos = metrics.horiBearingX / 64;
int rowStartPos = metrics.horiBearingY / 64;
for (int y = 0; y < bitmap.rows; y++) {
int row = rowStartPos + y;
for (int x = 0; x < bitmap.width; x++) {
int col = colStartPos + x;
uint8_t r = bitmap.buffer[y * bitmap.pitch + x * 3];
uint8_t g = bitmap.buffer[y * bitmap.pitch + x * 3 + 1];
uint8_t b = bitmap.buffer[y * bitmap.pitch + x * 3 + 2];
//imgView(col, row) = boost::gil::rgba8_pixel_t{r, g, b, 255};
}
}
}
}
|
5e797e49fa68dee13f5b1203d37ec78d520c4f51 | 8590b7928fdcff351a6e347c4b04a085f29b7895 | /CropSyst/source/seeding_param.h | a4e5c8fb108e839385dd7a130f636061349016fd | [] | no_license | liao007/VIC-CropSyst-Package | 07fd0f29634cf28b96a299dc07156e4f98a63878 | 63a626250ccbf9020717b7e69b6c70e40a264bc2 | refs/heads/master | 2023-05-23T07:15:29.023973 | 2021-05-29T02:17:32 | 2021-05-29T02:17:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,314 | h | seeding_param.h | #ifndef seeding_paramH
#define seeding_paramH
#include "corn/primitive.h"
#include "corn/const.h"
//180326 #include "corn/validate/validtyp.h"
#include "corn/parameters/parameter.h"
namespace CORN
{
class Data_record; // forward declaration
}
//______________________________________________________________________________
class Seeding_parameters
{
public:
float32 rate_seeds_m2; // seeding rate seeds/m2
float32 emergence_rate_percent; // anticipated emergence percent (100% indicates all seeds emerge)
float32 sowing_depth_cm; //
public: // validators
CORN::Parameter_number p_rate_seeds; //180326
CORN::Parameter_number p_emergence_rate; //180326
CORN::Parameter_number p_sowing_depth; //180326
public: // constructors
Seeding_parameters();
Seeding_parameters(const Seeding_parameters &original);
inline virtual ~Seeding_parameters() {} //170217
public: // I/O
virtual void setup_parameters(CORN::Data_record &data_rec,bool for_write) modification_;
};
//_Seeding_parameters__________________________________________________________/
#endif
|
22f4e7a1fc2e509a6ecbc1021d5b46e896e7f534 | 0b14d5cfe1b86910b0d42dace139343fbbc5359b | /include/rellic/AST/TransformVisitor.h | 906f8fcd032ce509208f34e323801121f1da4be4 | [
"Apache-2.0"
] | permissive | lifting-bits/rellic | 8e01d39f1240429633699d4045bf8d954f30ba47 | 6226304d78a142f61fa2866533383f111f9e8913 | refs/heads/master | 2023-08-19T11:01:16.515039 | 2023-07-28T08:21:07 | 2023-07-28T08:21:07 | 161,553,342 | 344 | 31 | Apache-2.0 | 2023-07-28T08:21:09 | 2018-12-12T22:32:12 | C++ | UTF-8 | C++ | false | false | 2,282 | h | TransformVisitor.h | /*
* Copyright (c) 2021-present, Trail of Bits, Inc.
* All rights reserved.
*
* This source code is licensed in accordance with the terms specified in
* the LICENSE file found in the root directory of this source tree.
*/
#pragma once
#include <clang/AST/RecursiveASTVisitor.h>
#include <unordered_map>
#include "rellic/AST/ASTPass.h"
#include "rellic/AST/Util.h"
namespace rellic {
using StmtSubMap = std::unordered_map<clang::Stmt *, clang::Stmt *>;
template <typename Derived>
class TransformVisitor : public ASTPass,
public clang::RecursiveASTVisitor<Derived> {
protected:
StmtSubMap substitutions;
void CopyProvenance(clang::Stmt *from, clang::Stmt *to) {
::rellic::CopyProvenance(from, to, dec_ctx.stmt_provenance);
}
void CopyProvenance(clang::Expr *from, clang::Expr *to) {
::rellic::CopyProvenance(from, to, dec_ctx.use_provenance);
}
bool ReplaceChildren(clang::Stmt *stmt, StmtSubMap &repl_map) {
auto change = false;
for (auto c_it = stmt->child_begin(); c_it != stmt->child_end(); ++c_it) {
auto s_it = repl_map.find(*c_it);
if (s_it != repl_map.end()) {
*c_it = s_it->second;
CopyProvenance(s_it->first, s_it->second);
if (clang::isa<clang::Expr>(s_it->first) &&
clang::isa<clang::Expr>(s_it->second)) {
auto from_expr{clang::cast<clang::Expr>(s_it->first)};
auto to_expr{clang::cast<clang::Expr>(s_it->second)};
CopyProvenance(from_expr, to_expr);
}
change = true;
}
}
return change;
}
void RunImpl() override { substitutions.clear(); }
public:
TransformVisitor(DecompilationContext &dec_ctx) : ASTPass(dec_ctx) {}
virtual bool shouldTraversePostOrder() { return true; }
bool VisitFunctionDecl(clang::FunctionDecl *fdecl) {
// DLOG(INFO) << "VisitFunctionDecl";
if (auto body = fdecl->getBody()) {
auto iter = substitutions.find(body);
if (iter != substitutions.end()) {
fdecl->setBody(iter->second);
changed = true;
}
}
return !Stopped();
}
bool VisitStmt(clang::Stmt *stmt) {
// DLOG(INFO) << "VisitStmt";
changed |= ReplaceChildren(stmt, substitutions);
return !Stopped();
}
};
} // namespace rellic
|
0036a344f0f8a397cf7f408c261b03e216ead584 | 06a25ec850b89e034e627d482de5ab38712385b3 | /goa/Classes/mini_games/AlphaPhonics.h | b1875067719eb794416b0d3c7e9da89e8efa1add | [
"Apache-2.0",
"MIT"
] | permissive | maqsoftware/Simple-Class | 05e85186e13ec17a0ba92f5d82b5f035ecce2a02 | 758a4cc7963625c1dd415d1068bb1b454714718d | refs/heads/master | 2023-03-07T22:14:50.830371 | 2019-09-16T13:39:03 | 2019-09-16T13:39:03 | 187,072,035 | 0 | 0 | Apache-2.0 | 2019-09-16T13:39:04 | 2019-05-16T17:23:42 | C++ | UTF-8 | C++ | false | false | 1,629 | h | AlphaPhonics.h | //
// AlphaPhonics.h
// goa
//
// Created by Karim Mirazul on 13/04/17
//
//
#ifndef __ALPHAPHONICS_SCENE_H__
#define __ALPHAPHONICS_SCENE_H__
#include "cocos2d.h"
#include "../menu/MenuContext.h"
#include "../menu/StartMenuScene.h"
#include "editor-support/cocostudio/CocoStudio.h"
#include "ui/CocosGUI.h"
#include "../lang/LangUtil.h"
#include "../lang/TextGenerator.h"
#include "../effects/FShake.h"
#include "SimpleAudioEngine.h"
using namespace cocos2d;
using namespace std;
class AlphaPhonics : public cocos2d::Layer
{
protected:
MenuContext *_menuContext;
int liftOpenChoice = 0,currentOptionPosition = 0,_optionSelection = 0;
bool touchOption = true;
vector<int> _optionValue;
vector<Sprite*> _optionSprite;
vector<pair<string, string>> _optionsMap;
public:
std::string getConvertInUpperCase(string data);
~AlphaPhonics();
static cocos2d::Scene* createScene();
virtual bool init();
static AlphaPhonics* create();
void LiftAnimationPlay(string elevatorName,string animationName);
void LiftAnimationHandler(int elevatorNo);
bool DataCorrectOrNot(Sprite * option);
void OptionChangeAnimation(int optionNumber);
vector<int> getRandomValueRange(int min, int max, int getValue);
void RecreateOptions();
Sprite* createSprite(pair<string, string> data,int currentOptionPosition,Size size, Vec2 position);
void createOptions();
void onEnterTransitionDidFinish();
void update(float) override;
void OptionListner(Sprite *option);
string StringandIntConcat(string data, int number);
static const char* gameName() { return ALPHAPHONICS.c_str(); }
};
#endif // __ALPHAPHONICS_SCENE_H__
|
276afeba9dbc26eb4850845960bee119f244ca5b | 4b630e22db0216720e3097bdebe62a884e554012 | /cf/sgu11/e.cpp | b0a77b83eb01429278b0a5e919e2123100ea2483 | [] | no_license | nyanshell/Gestapolur-Code-Storage | 98da5662164cf4dac931a876200e595ae2b667df | 3bd949da41dc8d7cacfe1792a2b3acaaeaa38c66 | refs/heads/master | 2021-05-28T04:37:29.718337 | 2012-05-30T07:26:04 | 2012-05-30T07:26:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 405 | cpp | e.cpp | //#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;
ifstream cin("input.txt");
ofstream cout("output.txt");
int n , m , tot;
int main()
{
int i ;
cin>>n;
for( i = 1 ; i <= n ; ++ i )
{
cin>>m;
if( m % 2 == 0 ) cout<<"1\n";
else cout<<"0\n";
}
return 0;
}
|
39252c077916540861ea2315f69bd0312a03d7e5 | 7895353724d6bbc57e45eec7aa0db3d4220f84ca | /src/os/threadpool/threadpool_simple/test.cpp | 094330be248f69765c547d4df15d80a6c82f26d2 | [] | no_license | averyboy/skills | e8309ae835ad48d9f17c13b63047141589617f51 | a825feee50bc2b6faafe4580d543d8bb619a94d3 | refs/heads/master | 2020-04-23T16:04:41.494831 | 2019-03-27T13:45:29 | 2019-03-27T13:45:29 | 171,285,846 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 382 | cpp | test.cpp | #include"threadpool.h"
#include<bits/stdc++.h>
using namespace std;
void* func(void* args)
{
char* str=(char*)(args);
cout<<"thread_id"<<pthread_self()<<endl;
cout<<"Hello,"<<str<<endl;
return NULL;
}
int main()
{
threadpool* pool=threadpool_create(10,10);
threadpool_add_task(pool,func,(void*)"???");
sleep(1);
threadpool_free(pool);
return 0;
} |
e6f329729f2dcb3aa41c73216bb251851681671a | 05edc7d2d482d5f839c1abf8ab44b4bb50fd6911 | /Factorial.cpp | 8a757dc7f296f5eadce064b04aaf187fa5b6f0b0 | [] | no_license | Alomar79/C_Plus_Plus-programs | 33c8cda836e8072c1f4c4f6abf7e01758498aa1a | 2acb85f56d3a4824304d8c732829c60bf7eb9407 | refs/heads/master | 2023-03-23T20:10:35.871362 | 2021-03-08T21:14:00 | 2021-03-08T21:14:00 | 329,842,608 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 283 | cpp | Factorial.cpp | #include <iostream>
using namespace std;
int main()
{
unsigned int n;
int fact=1;
cout<<"enter integer n to calculate factorial :";
cin>>n;
for(int i=1; i<=n; i++)
fact = i*fact;
cout<<endl<<"factorial of the number is :"<<fact<<endl;
return 0;
}
|
afc349725a0f9f44438dc2a469fa006530fd5da8 | 1622d5a7f1a5e0e41836b9ce9beac3fdf3039248 | /Source/float4x4.h | 93b69486ef37f9509619aa1d4302231e33c2a240 | [] | no_license | JohanMes/JohanEngine | 26e99b9393052ecb8bd4cf521e1993ddf2b15aaa | 6de56418921ecd5073667a8ea0f24a10e035ac08 | refs/heads/master | 2020-06-02T15:25:01.191128 | 2015-03-24T00:09:32 | 2015-03-24T00:09:32 | 23,675,422 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 611 | h | float4x4.h | #ifndef FLOAT4X4_H
#define FLOAT4X4_H
#include <d3dx9math.h>
#if BUILDING_DLL
#define DLLIMPORT __declspec(dllexport)
#else
#define DLLIMPORT __declspec(dllimport)
#endif
class DLLIMPORT float4x4 : public D3DXMATRIX {
public:
float4x4();
float4x4(const D3DXMATRIX& rvalue);
float4x4 EulerRotation(const D3DXVECTOR3& angle);
float4x4 EulerRotationDeg(const D3DXVECTOR3& angle);
float4x4 Translation(const D3DXVECTOR3& translation);
float4x4 Scaling(const D3DXVECTOR3& scaling);
float4x4 Identity();
float4x4 Inverse(); // does not apply, only returns result
float Determinant();
};
#endif
|
3fffc2e51993c31cd6d03ccd85f7455ae34cc11a | ab3c1c4beb4addd017fce07e6dfffe4e1de87eb5 | /Source/StarWing/StarWingGameMode.h | 9a06b242f170970a1e36aed3a0d5abfd2b73eba0 | [] | no_license | randoro/StarWingGold | 70abdffb966b4796a49182e91fb055883292833c | c0826b8ddabf1b824e9632b1de57fe876c5d79ab | refs/heads/master | 2021-01-19T20:08:45.316979 | 2017-03-03T03:49:22 | 2017-03-03T03:49:22 | 83,738,092 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 981 | h | StarWingGameMode.h | // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "GameFramework/GameMode.h"
#include "StarWingGameMode.generated.h"
UCLASS(minimalapi)
class AStarWingGameMode : public AGameMode
{
GENERATED_BODY()
UPROPERTY(EditDefaultsOnly)
TSubclassOf<class UUserWidget> HUDWidgetClass;
UPROPERTY()
class UUserWidget* CurrentWidget;
UPROPERTY(VisibleAnywhere)
int32 Time = 2000;
UPROPERTY(VisibleAnywhere)
float Health = 1.0f;
UPROPERTY(VisibleAnywhere)
float Boost = 1.0f;
public:
AStarWingGameMode();
void BeginPlay();
void Tick(float DeltaTime);
UFUNCTION(BlueprintPure, Category = "Time")
int32 GetTime();
UFUNCTION(BlueprintPure, Category = "Time")
float GetHealth();
UFUNCTION(BlueprintPure, Category = "Time")
float GetBoost();
UFUNCTION(Category = "Time")
void SetTime(int32 NewTime);
UFUNCTION(Category = "Time")
void SetHealth(float NewHealth);
UFUNCTION(Category = "Time")
void SetBoost(float NewBoost);
};
|
af65757ecc8fdbc1a780e3ef02645081c68c4bfd | cbd7d9d15dedf7d35c983f51408e2b511f5ae32e | /UVAOJ/488/main.cpp | e0308bcad5574434b448080de6d6b29fab7f01ab | [] | no_license | VOID001/CodeTogetherNEU | 2a42ab1a9d3ee1307753309d6b128e85d45ba9af | d3c62292a1f5af38017764d98125dce24f5a3c60 | refs/heads/master | 2021-01-20T08:48:36.730818 | 2015-07-29T02:44:09 | 2015-07-29T02:44:09 | 18,906,322 | 0 | 0 | null | 2014-12-21T00:07:48 | 2014-04-18T07:37:31 | C++ | GB18030 | C++ | false | false | 816 | cpp | main.cpp | /**Triangle waves**/
#include<stdio.h>
#include<string.h>
#define MAX 1000
int main(void)
{
int waves,height;/**重复次数 以及最高处高度**/
int cases;
scanf("%d",&cases);
for(int i=1;i<=cases;i++)
{
scanf("%d\n%d",&height,&waves);
{
for(int toto=1;toto<=waves;toto++)
{
for(int cur=1;cur<=height;cur++)
{
for(int oo=1;oo<=cur;oo++)
printf("%d",cur);
printf("\n");
}
for(int cur=height-1;cur>=1;cur--)
{
for(int oo=1;oo<=cur;oo++)
printf("%d",cur);
printf("\n");
}
if(toto<waves) printf("\n");
}
}
if(i<cases) printf("\n");
}
}
/**tried 5 times Accepted 2013-12-30 12:10:26**/
|
a20af3d6737639ef5dfc4f06a7aa9b71f3e1d1c7 | b9c080483336a5c4b64d249c2f38cf28c3f52485 | /firmware/Servo_tests/Servo_tests.ino | fdbad6bd92a3c82e1632e4148c2cff34171e6108 | [
"MIT"
] | permissive | ad-march/stewart-platform | 981b2db21043e8c2692305d300ff21fb52b61a31 | de46608538948d121d8a083abd6b9d8f4c2fe459 | refs/heads/master | 2020-04-01T19:33:37.003760 | 2018-11-27T00:17:09 | 2018-11-27T00:17:09 | 153,560,046 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 874 | ino | Servo_tests.ino | #include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
//Servo calibration:
#define SERVOMIN 132
#define SERVOMAX 535
int servonum = 0;
int speed = 5;
int step_size = 1;
void setup() {
Serial.begin(9600);
Serial.println("8 channel Servo test!");
pwm.begin();
pwm.setPWMFreq(60); // Analog servos run at ~60 Hz updates
delay(10);
}
void loop() {
// Drive each servo one at a time
Serial.println(servonum);
for (double pulselen = SERVOMIN; pulselen < SERVOMAX; pulselen=pulselen+step_size) {
pwm.setPWM(servonum, 0, pulselen);
delay(speed);
}
delay(200);
for (double pulselen = SERVOMAX; pulselen > SERVOMIN; pulselen=pulselen-step_size) {
pwm.setPWM(servonum, 0, pulselen);
//delay(speed);
}
delay(200);
}
//servonum ++;
// if (servonum > 7) servonum = 0;
|
cb1a4b8118a7b09d8beb1adcaa4dc5e714832d0c | 93deffee902a42052d9f5fb01e516becafe45b34 | /cf/0987/B.cpp | 88bd2e10d31c3b71bd0ba74cdd3f53ebc02295ab | [] | no_license | kobortor/Competitive-Programming | 1aca670bc37ea6254eeabbe33e1ee016174551cc | 69197e664a71a492cb5b0311a9f7b00cf0b1ccba | refs/heads/master | 2023-06-25T05:04:42.492243 | 2023-06-16T18:28:42 | 2023-06-16T18:28:42 | 95,998,328 | 10 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 482 | cpp | B.cpp | #include<bits/stdc++.h>
using namespace std;
#define allof(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main(){
cin.tie(0);
cin.sync_with_stdio(0);
int X, Y;
cin >> X >> Y;
double v1 = Y * log(X);
double v2 = X * log(Y);
if(X == Y || (min(X, Y) == 2 && max(X, Y) == 4)){
cout << "=";
} else if (v1 < v2){
cout << "<";
} else {
cout << ">";
}
}
|
892a0b639da4c3d1f6da27ca786ea195a07a7886 | 7fb6c68e6bf7cd3224ce02aea55ea5b4cee607a3 | /facecat_cpp/source/log/LogService.cpp | 2ca62e8f61556500411f803a8f9d388f7a764278 | [
"BSD-2-Clause"
] | permissive | kknet/facecat | db02b26fd6ca1c472d156cc18e9a5d9c2b77e8ec | bd33eeda1e1b552a2296c833b89254a8e2a9724b | refs/heads/master | 2020-08-03T13:50:27.597696 | 2019-09-28T09:25:21 | 2019-09-28T09:25:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,820 | cpp | LogService.cpp | #include "..\\stdafx.h"
#include "..\\..\\include\\log\\LogService.h"
#include "..\\..\\include\\log\\RollingFileAppenderConfig.h"
#include "..\\..\\include\\log\\RollingFileAppender.h"
#include "..\\..\\include\\log\\SeparateDirAppender.h"
namespace FaceCat{
LogWorkDataInfo::LogWorkDataInfo(){
m_appender = 0;
m_id = 0;
m_pos = 0;
m_threadID = 0;
m_requestID = 0;
m_sessionID = 0;
m_logType = 0;
}
LogWorkDataInfo::~LogWorkDataInfo(){
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
LogReqDataInfo::LogReqDataInfo(){
m_requestID = 0;
m_sessionID = 0;
}
LogReqDataInfo::~LogReqDataInfo(){
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DWORD WINAPI pushDataStartWork(LPVOID lpParam){
LPVOID *parameters = (LPVOID*)lpParam;
LogService *pool = (LogService*)parameters[0];
int id = (int)(parameters[1]);
while(true){
pool->onWork(id);
::Sleep(1);
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
LogService::LogService(){
m_quitEvent = 0;
m_quitEventInvoke = 0;
m_recvEvent = 0;
m_recvEventInvoke = 0;
m_tick = 0;
m_workEvent = 0;
m_workEventInvoke = 0;
}
LogService::~LogService(){
m_lock.lock();
m_messages.clear();
m_lock.unLock();
m_quitEvent = 0;
m_quitEventInvoke = 0;
m_recvEvent = 0;
m_recvEventInvoke = 0;
m_lockStopPushDatas.lock();
m_stopPushDatas.clear();
m_lockStopPushDatas.unLock();
m_tick = 0;
m_workEvent = 0;
m_workEventInvoke = 0;
m_lockAppender.lock();
m_appenders.clear();
m_lockAppender.unLock();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void LogService::addAppender(BaseAppender* appender){
m_lockAppender.lock();
m_appenders[appender->getID()] = appender;
m_lockAppender.unLock();
}
void LogService::addRollingFileAppender(const String &filePath){
string strFilePath;
String wstrFilePaht;
strFilePath = FCStr::wstringTostring(filePath);
int index = (int)strFilePath.find_last_of("\\");
if (index < 0){
strFilePath = FCStr::getAppPath() + "\\log\\" + strFilePath;
}
wstrFilePaht = FCStr::stringTowstring(strFilePath);
RollingFileAppenderConfig* fileAppenderConfig = new RollingFileAppenderConfig();
fileAppenderConfig->m_logFile = wstrFilePaht;
fileAppenderConfig->m_name = L"RollingFileAppender";
fileAppenderConfig->m_type = L"RollingFileAppender";
fileAppenderConfig->m_datePattern = L"%d-%02d-%02d %02d:%02d:%02d:%03d";
fileAppenderConfig->m_logType = 1;
fileAppenderConfig->m_wstrMaxFileSize = L"500kb";
fileAppenderConfig->m_maxSizeRollBackups = 500;
RollingFileAppender* appender = new RollingFileAppender(fileAppenderConfig);
addAppender(appender);
}
void LogService::addSeparateDirAppender(const String &filePath){
string strFilePath;
String wstrFilePaht;
strFilePath = FCStr::wstringTostring(filePath);
int index = (int)strFilePath.find_last_of("\\");
if (index < 0){
string date;
String wDate = getNowDate(L"%d%02d%02d");
date = FCStr::wstringTostring(wDate);
strFilePath = FCStr::getAppPath() + "\\log\\" + date + "\\" + strFilePath;
}
wstrFilePaht = FCStr::stringTowstring(strFilePath);
RollingFileAppenderConfig* fileAppenderConfig = new RollingFileAppenderConfig();
fileAppenderConfig->m_logFile = wstrFilePaht;
fileAppenderConfig->m_name = L"SeparateDirAppender";
fileAppenderConfig->m_type = L"SeparateDirAppender";
fileAppenderConfig->m_datePattern = L"%d-%02d-%02d %02d:%02d:%02d:%03d";
fileAppenderConfig->m_logType = 1;
fileAppenderConfig->m_wstrMaxFileSize = L"500kb";
fileAppenderConfig->m_maxSizeRollBackups = 500;
SeparateDirAppender* appender = new SeparateDirAppender(fileAppenderConfig);
addAppender(appender);
}
String LogService::getNowDate(const String &datePattern){
SYSTEMTIME sysTime;
ZeroMemory(&sysTime, sizeof(sysTime));
GetLocalTime(&sysTime);
static wchar_t str[100] = {0};
_stprintf_s(str, 99, datePattern.c_str(), sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond, sysTime.wMilliseconds);
return str;
}
void LogService::log(LogType logType, const String &message){
String date = getNowDate(L"%d-%02d-%02d %02d:%02d:%02d:%03d");
String logContent/* = date*/;
logContent = logContent.append(L" ");
logContent = logContent.append(message);
map <int, BaseAppender*>::iterator iter = m_appenders.begin();
for(; iter != m_appenders.end(); ++iter){
LogWorkDataInfo *dataInfo = new LogWorkDataInfo();
dataInfo->m_logType = (int)logType;
dataInfo->m_logContent = logContent;
dataInfo->m_appender = iter->second;
startWork(dataInfo);
}
}
void LogService::log(LogType logType, const string &str){
String msg;
msg = FCStr::stringTowstring(str);
log(logType, msg);
}
void LogService::startWork(LogWorkDataInfo* dataInfo){
m_lock.lock();
m_messages.push_back(dataInfo);
m_lock.unLock();
}
void LogService::startWork(vector<LogWorkDataInfo*> &dataInfos){
m_lock.lock();
int count = (int)dataInfos.size();
if (count <= 0){
m_lock.unLock();
return;
}
for(int i = 0; i < count; ++i){
m_messages.push_back(dataInfos[i]);
}
m_lock.unLock();
}
void LogService::onWork(int id){
m_lock.lock();
int messagesSize = (int)m_messages.size();
for (int i = 0; i < messagesSize; i++){
m_dataInfos[id]->push_back(m_messages[i]);
}
m_messages.clear();
m_lock.unLock();
vector<LogWorkDataInfo*> *dataInfos = m_dataInfos[id];
int dataInfosSize = (int)dataInfos->size();
vector<LogReqDataInfo> stopPushDatas;
int stopPushDatasSize = (int)m_stopPushDatas.size();
if (stopPushDatasSize > 0){
m_lockStopPushDatas.lock();
stopPushDatasSize = (int)m_stopPushDatas.size();
for (int i = 0; i < stopPushDatasSize; i++){
stopPushDatas.push_back(m_stopPushDatas[i]);
}
m_lockStopPushDatas.unLock();
}
for (int i = 0; i < dataInfosSize; i++){
LogWorkDataInfo *pushDataInfo = (*dataInfos)[i];
int state = 0;
if (stopPushDatasSize > 0){
for (int j = 0; j < stopPushDatasSize; j++){
LogReqDataInfo reqDataInfo = stopPushDatas[j];
if (reqDataInfo.m_requestID == pushDataInfo->m_requestID
&& reqDataInfo.m_sessionID == pushDataInfo->m_sessionID){
m_lockStopPushDatas.lock();
int spdSize = (int)m_stopPushDatas.size();
for (int s = 0; s < spdSize; s++){
if (m_stopPushDatas[s].m_requestID == reqDataInfo.m_requestID
&& m_stopPushDatas[s].m_sessionID == reqDataInfo.m_sessionID){
m_stopPushDatas.erase(m_stopPushDatas.begin() + s);
break;
}
}
m_lockStopPushDatas.unLock();
state = -1;
}
}
}
if (state == 0){
state = onWorking(pushDataInfo);
}
if (state <= 0){
if (m_quitEvent){
m_quitEvent(pushDataInfo, m_quitEventInvoke);
}
delete (*dataInfos)[i];
dataInfos->erase(dataInfos->begin() + i);
i--;
dataInfosSize--;
}
}
}
int LogService::onWorking(LogWorkDataInfo* dataInfo){
if(!dataInfo->m_appender->m_initFinished){
return 1;
}
dataInfo->m_appender->log(dataInfo->m_logType, dataInfo->m_logContent);
return 0;
}
int LogService::quit(LogReqDataInfo *reqInfo){
m_lockStopPushDatas.lock();
m_stopPushDatas.push_back(*reqInfo);
m_lockStopPushDatas.unLock();
return 0;
}
void LogService::recv(LogWorkDataInfo *message){
LogWorkDataInfo *newMessage = new LogWorkDataInfo;
//newMessage->copy(message);
//char *body = new char[newMessage->m_bodyLength];
//for (int i = 0; i < newMessage->m_bodyLength; i++)
//{
// body[i] = message->m_body[i];
//}
//newMessage->m_body = body;
m_lock.lock();
m_messages.push_back(newMessage);
m_lock.unLock();
}
void LogService::registerQuitEvent(PushDataQuit quitEvent, void *pInvoke){
m_quitEvent = quitEvent;
m_quitEventInvoke = pInvoke;
}
void LogService::registerRecvEvent(PushDataRecv recvEvent, void *pInvoke){
m_recvEvent = recvEvent;
m_recvEventInvoke = pInvoke;
}
void LogService::registerWorkEvent(PushDataWork workEvent, void *pInvoke){
m_workEvent = workEvent;
m_workEventInvoke = pInvoke;
}
void LogService::start(){
map<int, BaseAppender*>::iterator iter = m_appenders.begin();
for(; iter != m_appenders.end(); ++iter){
vector<LogWorkDataInfo*> *datas = new vector<LogWorkDataInfo*>;
m_dataInfos[iter->first] = datas;
}
iter = m_appenders.begin();
for(; iter != m_appenders.end(); ++iter){
LPVOID *parameters = new LPVOID[2];
parameters[0] = this;
parameters[1] = (LPVOID)iter->first;
HANDLE hThread = ::CreateThread(0, 0, pushDataStartWork, (LPVOID)parameters, 0, 0);
::CloseHandle(hThread);
}
}
} |
7c8ba378b44ece74aad91eee19629e9a6d79d081 | 631f8cdc1924e2a87a71799ede8c9bd166ec605a | /dooked/include/utils/io_utils.hpp | 829b09e6993d5a66b209a551be2a2ff9f83eb45a | [] | no_license | iamOgunyinka/dooked | f4b6292df60fe3930a72897a011dab4a79b30196 | 2cb69017bd0ad0eaa7fcb2b2e8c6cb7b06bda2b0 | refs/heads/main | 2023-03-30T02:13:37.305007 | 2021-03-27T13:17:38 | 2021-03-27T13:17:38 | 324,373,307 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,170 | hpp | io_utils.hpp | #pragma once
#include "utils/containers.hpp"
#include "utils/probe_result.hpp"
#include <filesystem>
#include <fstream>
#include <iostream>
#include <nlohmann/json.hpp>
#include <optional>
#include <sstream>
namespace dooked {
using json = nlohmann::json;
template <typename T> using opt_list_t = std::optional<std::vector<T>>;
void to_json(json &j, probe_result_t const &record);
dns_record_type_e dns_str_to_record_type(std::string const &);
bool is_text_file(std::string const &file_extension);
bool is_json_file(std::string const &file_extension);
std::string get_file_type(std::filesystem::path const &file_path);
std::string get_filepath(std::string const &filename);
std::uint16_t uint16_value(unsigned char const *buff);
void trim(std::string &);
struct json_data_t {
std::string domain_name{};
std::string rdata{};
int ttl{};
int http_code{};
int content_length{};
dns_record_type_e type{};
static json_data_t serialize(std::string const &d, int const len,
int const http_code,
json::object_t &json_object) {
json_data_t data{};
data.domain_name = d;
data.type =
dns_str_to_record_type(json_object["type"].get<json::string_t>());
data.rdata = json_object["info"].get<json::string_t>();
data.ttl = json_object["ttl"].get<json::number_integer_t>();
data.content_length = len;
data.http_code = http_code;
return data;
}
};
struct jd_domain_comparator_t {
bool operator()(json_data_t const &a, json_data_t const &b) const {
return a.domain_name < b.domain_name;
}
};
namespace detail {
template <typename DnsType, typename RtType>
void write_json_result_impl(map_container_t<DnsType> const &result_map,
RtType const &rt_args) {
if (result_map.empty()) {
std::error_code ec{};
if (std::filesystem::exists(rt_args.output_filename) &&
!std::filesystem::remove(rt_args.output_filename, ec)) {
printf("unable to remove %s", rt_args.output_filename.c_str());
}
return;
}
json::array_t list;
for (auto const &result_pair : result_map.cresult()) {
json::object_t internal_object;
auto &http_result = result_pair.second.http_result_;
internal_object["dns_probe"] = result_pair.second.dns_result_list_;
internal_object["content_length"] = http_result.content_length_;
internal_object["http_code"] = http_result.http_status_;
internal_object["code_string"] = code_string(http_result.http_status_);
json::object_t object;
object[result_pair.first] = internal_object;
list.push_back(std::move(object));
}
json::object_t res_object;
res_object["program"] = "dooked";
res_object["result"] = std::move(list);
(*rt_args.output_file) << json(res_object).dump(2) << "\n";
rt_args.output_file->close();
}
template <typename T, typename Iterator>
std::optional<std::vector<T>> read_json_string(Iterator const begin,
Iterator const end) {
std::vector<T> result{};
try {
json json_content = json::parse(begin, end);
auto object_root = json_content.get<json::object_t>();
auto const result_list = object_root["result"].get<json::array_t>();
for (auto const &result_item : result_list) {
auto json_object = result_item.get<json::object_t>();
for (auto const json_item : json_object) {
std::string const domain_name = json_item.first;
auto internal_object = json_item.second.get<json::object_t>();
auto const domain_detail_list =
internal_object["dns_probe"].get<json::array_t>();
auto const content_length =
internal_object["content_length"].get<json::number_integer_t>();
auto const http_code =
internal_object["http_code"].get<json::number_integer_t>();
for (auto const &domain_detail : domain_detail_list) {
auto domain_object = domain_detail.get<json::object_t>();
result.push_back(T::serialize(domain_name, content_length, http_code,
domain_object));
}
}
}
} catch (std::runtime_error const &e) {
puts(e.what());
return std::nullopt;
}
return result;
}
template <typename T>
std::optional<std::vector<T>>
read_json_file(std::filesystem::path const &file_path) {
std::ifstream input_file(file_path);
if (!input_file) {
return std::nullopt;
}
auto const file_size = std::filesystem::file_size(file_path);
std::vector<char> file_buffer(file_size);
input_file.read(&file_buffer[0], file_size);
return read_json_string<T>(file_buffer.cbegin(), file_buffer.cend());
}
template <typename T>
opt_list_t<T> read_text_file(std::filesystem::path const &file_path) {
std::ifstream input_file(file_path);
if (!input_file) {
return std::nullopt;
}
std::vector<T> domain_names{};
std::string line{};
while (std::getline(input_file, line)) {
trim(line);
if (line.empty()) {
continue;
}
domain_names.push_back({line});
}
return domain_names;
}
} // namespace detail
template <typename T>
opt_list_t<T> get_names(std::string const &filename,
file_type_e const file_type = file_type_e::txt_type) {
bool const using_stdin = filename.empty();
// read line by line and send the result back as-is.
if (using_stdin && file_type == file_type_e::txt_type) { // use stdin
std::string domain_name{};
std::vector<T> domain_names;
while (std::getline(std::cin, domain_name)) {
domain_names.push_back({domain_name});
}
return domain_names;
// read line by line but parse the JSON result
} else if (using_stdin && file_type == file_type_e::json_type) {
std::ostringstream ss{};
std::string line{};
while (std::getline(std::cin, line)) {
ss << line;
}
auto const buffer{ss.str()};
if constexpr (!std::is_same_v<T, std::string>) {
return detail::read_json_string<T>(buffer.cbegin(), buffer.cend());
}
return std::nullopt;
} else if (using_stdin) {
return std::nullopt;
}
std::filesystem::path const file{filename};
if (!std::filesystem::exists(file)) {
return std::nullopt;
}
switch (file_type) {
case file_type_e::txt_type:
return detail::read_text_file<T>(file);
case file_type_e::json_type:
if constexpr (!std::is_same_v<T, std::string>) {
return detail::read_json_file<T>(file);
}
}
// if we are here, we were unable to determine the type
auto const file_extension{get_file_type(file)};
if (is_text_file(file_extension)) {
return detail::read_text_file<T>(file);
} else if (is_json_file(file_extension)) {
if constexpr (!std::is_same_v<T, std::string>) {
return detail::read_json_file<T>(file);
}
}
// if file extension/type cannot be determined, read as TXT file
return detail::read_text_file<T>(file);
}
template <typename DnsType, typename RtType>
void write_json_result(map_container_t<DnsType> const &result_map,
RtType const &rt_args) {
return detail::write_json_result_impl(result_map, rt_args);
}
} // namespace dooked
|
4efcf7125a0f323581d9ab6f7fced586d249f3e1 | 43cc9aaa77c5686e62688c5403b80fb9fe5d76d3 | /c++first/xiao_read.cpp | d5ff54b25a96c48bd174f8d69dcbafeae77fb3f7 | [] | no_license | jingyu323/cplus-study | 92cd6d893c7d86b047a332f5cd92afeb9380d18c | 7ee5b0cf591f88d5391cd79e6ee6f4a9f9eef96c | refs/heads/master | 2023-08-08T05:31:40.409966 | 2023-08-07T12:45:32 | 2023-08-07T12:45:32 | 147,777,268 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,401 | cpp | xiao_read.cpp |
// 请关闭中文输入法,用英文的字母和标点符号。
// 如果你想运行系统测试用例,请点击【执行代码】按钮,如果你想提交作答结果,请点击【提交】按钮,
// 注意:除答案外,请不要打印其他任何多余的字符,以免影响结果验证
// 本OJ系统是基于 OxCoder 技术开发,网址:www.oxcoder.com
// 模版代码提供基本的输入输出框架,可按个人代码习惯修改
#include <iostream>
#include <string>
#include <vector>
// 如果实在想用sizeof(array)/sizeof(array[0])算长度,请不要将数组作为参数,而是在main函数中算好length,再将传入函数中
int solution(int n, int pages[7],int length){
int result;
// TODO:
while(n>0){
int length1=sizeof(pages)/sizeof(pages[0]);
printf("%d ---", length1);//i=9
for(int i=0;i< length ;i++){
result = i+1;
n = n - pages[i];
if(n<=0){
break;
}
}
}
return result;
}
int main() {
int n;
int pages[7];
std::cin>>n;
for (int i = 0; i < 7; i++){
std::cin>>pages[i];
}
int length=sizeof(pages)/sizeof(pages[0]);
int result = solution(n, pages,length);
std::cout<<result<<std::endl;
return 0;
} |
ab5d4fda61762d1d0848296f09ad59052cd53204 | 04251e142abab46720229970dab4f7060456d361 | /lib/rosetta/source/external/boost_submod/boost/variant.hpp | a400cb2b1d87637a2334f52ccee9a2233a83e0f6 | [
"BSL-1.0"
] | permissive | sailfish009/binding_affinity_calculator | 216257449a627d196709f9743ca58d8764043f12 | 7af9ce221519e373aa823dadc2005de7a377670d | refs/heads/master | 2022-12-29T11:15:45.164881 | 2020-10-22T09:35:32 | 2020-10-22T09:35:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 36 | hpp | variant.hpp | ../variant/include/boost/variant.hpp |
77709278ff419ce43681042e6855969d31fb1e7e | 98f9f977a39843e5f7719062f43011ebfd169e42 | /Libs/PluginFramework/ctkBasicLocation_p.h | 18916c8679e85e7e517501ad55552d766bb20019 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | txdy077345/CTK | 71cab2d77193d09340afe7a50e5dddc3ea66a06d | 7cd253376139ea73f0450e1bad75bab41aa1b507 | refs/heads/master | 2023-05-27T19:20:21.825916 | 2023-04-29T16:35:03 | 2023-04-29T16:35:03 | 276,658,777 | 1 | 0 | Apache-2.0 | 2020-07-02T13:50:30 | 2020-07-02T13:50:29 | null | UTF-8 | C++ | false | false | 2,591 | h | ctkBasicLocation_p.h | /*=============================================================================
Library: CTK
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=============================================================================*/
#ifndef CTKBASICLOCATION_H
#define CTKBASICLOCATION_H
#include <service/datalocation/ctkLocation.h>
#include <QUrl>
#include <QString>
#include <QFileInfo>
#include <QReadWriteLock>
class ctkBasicLocation : public QObject, public ctkLocation
{
Q_OBJECT
Q_INTERFACES(ctkLocation)
public:
ctkBasicLocation(const QString& property, const QUrl& defaultValue,
bool isReadOnly, const QString& dataAreaPrefix);
~ctkBasicLocation();
bool allowsDefault() const;
QUrl getDefault() const;
ctkLocation* getParentLocation() const;
QUrl getUrl() const;
bool isSet() const;
bool isReadOnly() const;
bool set(const QUrl& value, bool lock);
bool set(const QUrl& value, bool lock, const QString& lockFilePath);
bool lock();
void release();
bool isLocked() const;
ctkLocation* createLocation(ctkLocation* parent, const QUrl& defaultValue, bool readonly);
QUrl getDataArea(const QString& path) const;
void setParent(ctkLocation* parent);
struct Locker;
private:
struct MockLocker;
class FileLocker;
bool m_isReadOnly;
QUrl m_location;
QScopedPointer<ctkLocation> m_parent;
QUrl m_defaultValue;
QString m_property;
QString m_dataAreaPrefix;
// locking related fields
QFileInfo m_lockFile;
Locker* m_locker;
mutable QReadWriteLock m_sync;
bool isSet_unlocked() const;
bool set_unlocked(const QUrl& value, bool lock);
bool set_unlocked(const QUrl& value, bool lock, const QString& lockFilePath);
bool lock_unlocked(const QFileInfo& lock, const QUrl& locationValue);
void setLocker_unlocked(const QFileInfo& lock);
Locker* createLocker_unlocked(const QFileInfo& lock, const QString& lockMode);
bool isLocked_unlocked(const QFileInfo& lock) const;
};
#endif // CTKBASICLOCATION_H
|
c6b7f77f43e82de480c91647fc617d719dbfa0ee | 046217dc86ca22477f27e31154b7ab4a50a38a23 | /findproduct.cpp | 7e3f4e08a4c0be0a97e11b0aa3a9f4843f1a98eb | [] | no_license | himanshu-lab/cp | ea16dae17c783cab948be791de10c0d6144398f5 | a8d78807d9e9134c8e96b9bb6a09f2e663e4290f | refs/heads/master | 2020-08-28T00:19:24.433686 | 2019-10-25T13:11:04 | 2019-10-25T13:11:04 | 217,532,949 | 1 | 2 | null | 2019-10-25T13:11:05 | 2019-10-25T12:51:53 | null | UTF-8 | C++ | false | false | 305 | cpp | findproduct.cpp |
// Sample code to perform I/O:
#include <iostream>
using namespace std;
int main()
{
int n;
long int ans=1;
cin >> n; // Reading input from STDIN
int arr[n],i;
for(i=0;i<n;i++)
{
cin>>arr[i];
ans=(ans*arr[i])%1000000007;
}
cout<<ans; // Writing output to STDOUT
}
|
dd650eb734ce38991fe02085440fd23bc6e5eb97 | a966ff5ada08aabe99caa6cc1bf605b3e1b5d2f6 | /algorithms-and-data-structures/utils.h | 1492e788b2a04acb550d34250fd6a568f4f29dac | [
"LicenseRef-scancode-public-domain",
"Unlicense"
] | permissive | bernardosulzbach/algorithms-and-data-structures | db43d5f43d9d40e37a6f7b3a503da7eb409af146 | a213590b9887bfcf9f23af1556969f4665061926 | refs/heads/master | 2021-06-01T21:20:57.759001 | 2015-12-01T18:10:00 | 2015-12-01T18:10:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,367 | h | utils.h | #pragma once
#include <algorithm>
#include <vector>
namespace AADS {
template <typename In, typename T>
bool in_range(In begin, In end, T element) {
return std::find(begin, end, element) != end;
}
template <typename T>
bool in_vector(const std::vector<T>& vector, T element) {
return in_range(vector.begin(), vector.end(), element);
}
/** Returns an iterator half between two iterators. */
template <typename In>
In middle(In begin, In end) {
return std::next(begin, std::distance(begin, end) / 2);
}
template <typename RandomAccessIterator>
/** Returns an iterator pointing to an element E such that E is bigger than or equal to its predecessor and its successor. */
RandomAccessIterator peak(RandomAccessIterator begin, RandomAccessIterator end) {
auto distance = std::distance(begin, end);
if (distance == 0 || distance == 1) return begin;
else {
if (begin[distance / 2] < begin[distance / 2 - 1]) {
return peak(begin, begin + distance / 2);
}
else if ((begin + distance / 2 + 1 != end) && begin[distance / 2] < begin[distance / 2 + 1]) {
return peak(begin + distance / 2 + 1, end);
}
else {
return begin + distance / 2;
}
}
}
} |
20931cce148287250a075140dd02b14ed8e7a46b | be2eff8da37e27c8ad0fcca96494d6b63ed1590c | /LabAssistant/editUser.cp | 26e201ae095f62fb180a08e805e8f302c1075959 | [] | no_license | daveklotz/LabAssistant | 1a3549ea78dbffc2e90148b58b97231b99475197 | 73a4dd743714c94ea04c48d0a0edb615210ac4f0 | refs/heads/master | 2022-04-16T00:27:40.401948 | 2020-04-13T23:00:32 | 2020-04-13T23:00:32 | 255,459,065 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,048 | cp | editUser.cp | #include "lab assistant.h"
#include "editUser.h"
#include "otherUser.h"
#include "userRecord.h"
#include "Menu.h"
void EditUser(userNodePtr theUser, userNodePtr userHead)
{
dialogRecordHdl dialogRecord;
dialogRecord = (dialogRecordHdl) NewHandle(sizeof(dialogRec));
HLock((Handle) dialogRecord);
(*dialogRecord)->theRecord = (long) theUser;
(*dialogRecord)->theEvent = kEventEditUser;
(*dialogRecord)->misc = (long) userHead;
(*dialogRecord)->callBack = EditUserCallBack;
HUnlock((Handle) dialogRecord);
EditUserBoxSetup(dialogRecord);
}
void EditUserCallBack(dialogRecordHdl dialogRecord)
{
userNode *theUser, *userHead;
short itemHit;
HLock((Handle) dialogRecord);
theUser = (userNode *) (*dialogRecord)->theRecord;
userHead = (userNode *) (*dialogRecord)->misc;
itemHit = (*dialogRecord)->itemHit;
HUnlock((Handle) dialogRecord);
switch(itemHit)
{
case ok:
WriteUserInfo(userHead);
DeleteUserList(userHead);
case cancel:
DisposeHandle((Handle) dialogRecord);
DisableMenus(false);
break;
}
} |
b4e3d91990d1a45599cf6dd1eb64f9e625eb0652 | 5699bcd221d7c168c2126aeb789451ec756fcb16 | /framework/CanInterface/Motor/Faulhaber.h | 755d8f73aec404a02a646dc4aedc83df3cb86923 | [] | no_license | andreas-koenig/kickermat | f12474785bee270941f0ccf1a715367305e4cb8d | 1f86ab5e774c5c4a6a4a14949787fc4e221fa6b9 | refs/heads/master | 2023-03-04T03:44:47.990729 | 2020-10-25T14:37:35 | 2020-10-25T14:37:35 | 336,041,128 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 667 | h | Faulhaber.h | #pragma once
#include "Motor.h"
// Umrechnungsfaktor für die Skalierung der Faulhaber Motoren in Winkel
#define FH_NUMBER_OF_STEPS 41375
namespace Motor {
class Faulhaber : public Motor::BaseMotor {
public:
Faulhaber(uint8_t motorId);
// Write PDOs
void RotateBar(uint32_t angle, PositioningMethod positioningMethod);
// Write SDOs
void SetScaleNumerator(uint16_t numerator);
void SetScaleFeedConstant(uint16_t constant);
void SetHomingOffset(uint16_t angle);
// Read SDOs
uint32_t GetScaleNumerator();
uint32_t GetScaleFeedConstant();
void Calibrate();
};
}
|
b8f9f283f020c784d06e2874297812733af0b19a | 287230b6695941701830dd513273d516c7235ba9 | /prebuilts/gcc/linux-x86/arm/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/6.3.1/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp | 809bf5f612fae78c07ffbf0210741d1054712649 | [] | no_license | haohlliang/rv1126 | 8279c08ada9e29d8973c4c5532ca4515bd021454 | d8455921b05c19b47a2d7c8b682cd03e61789ee9 | refs/heads/master | 2023-08-10T05:56:01.779701 | 2021-06-27T14:30:42 | 2021-06-27T14:30:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 129 | hpp | erase_fn_imps.hpp | version https://git-lfs.github.com/spec/v1
oid sha256:363f9b670f8be3fab887a0a9c9c6c679b360a78f9927ef56279a24ea2da76507
size 2889
|
064af21ef57a8d23a4f9b176c49c66bde3125c07 | 5a2497e0c96d8b04512b69f769f360e3fe872571 | /Linked_Lists/Stack_using_array.cpp | 96f6935bc8e681eebdcf03de074be91e6ea9f94a | [] | no_license | naman99lalit/Data-Structures-and-Algorithms | 10a5d7989cc8801bedca9139d57def8f862be0df | 4209c33f9319cd2eef610773a835ef01e5d62acd | refs/heads/master | 2021-06-28T14:41:07.792562 | 2020-10-29T16:42:18 | 2020-10-29T16:42:18 | 166,237,802 | 0 | 2 | null | 2020-10-29T16:42:19 | 2019-01-17T14:19:23 | C++ | UTF-8 | C++ | false | false | 1,458 | cpp | Stack_using_array.cpp | #include <bits/stdc++.h>
using namespace std;
int array[100], n=100, top=-1;
void push(int value)
{
if(top>=n-1)
cout<<"Stack Overflow"<<endl;
else
{
top++;
array[top]=value;
}
}
void pop()
{
if(top<=-1)
cout<<"Stack Underflow"<<endl;
else
{
cout<<"The Element popped from the stack is "<< array[top] <<endl;
top--;
}
}
void display()
{
if(top>=0)
{
cout<<"The elements in the stack are:";
for(int i=top; i>=0; i--)
cout<<array[i]<<" ";
cout<<endl;
}
else
cout<<"The Stack is empty";
}
int main()
{
int ch, val;
cout<<"Press 1 to Push element in the stack"<<endl;
cout<<"Press 2 to Pop element from the stack"<<endl;
cout<<"Press 3 to Display elements in the stack"<<endl;
cout<<"Press 4 to Exit from the stack"<<endl;
do {
cout<<"Enter the choice: "<<endl;
cin>>ch;
switch(ch)
{
case 1:
{
cout<<"Enter the value that you want to push:"<<endl;
cin>>val;
push(val);
break;
}
case 2:
{
pop();
break;
}
case 3:
{
display();
break;
}
case 4:
{
cout<<"Exit"<<endl;
break;
}
default:
{
cout<<"Invalid Choice"<<endl;
}
}
}while(ch!=4);
return 0;
}
|
45293b48d6a34055346bb852cae019a95a23e7de | 3b8ebd9a8720f1165bc68924b57eb5d3c7d27dbf | /src/HTBlobInterpreterMulti.cpp | e32dd7e8e6e0f2994aa21e04dc05d4c79069a6dc | [
"Apache-2.0"
] | permissive | cadet-salzburg/libHecato | b7c6a0d4682173d0f7e3a19278dd94728811cc8c | 1f4665d2cdfb35781d41ac3064ff07d5a9b79ab7 | refs/heads/master | 2021-05-27T01:11:39.998229 | 2013-06-21T09:55:51 | 2013-06-21T09:55:51 | 6,887,374 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,206 | cpp | HTBlobInterpreterMulti.cpp | #ifndef WIN32
#include <sys/time.h>
#else
#include <time.h>
#endif
#include "HTBlobInterpreterMulti.h"
HTBlobInterpreterMulti::HTBlobInterpreterMulti() : HTBlobInterpreter(),
numInstances(0),
curInstances(0),
corrRadiusW(0.08f),
corrRadiusH(0.25f),
corrPerson(0.25f)
{
for (unsigned i = 0; i < MAX_GENERATORS; i++)
{
generators[i] = false;
}
}
HTBlobInterpreterMulti::~HTBlobInterpreterMulti()
{
}
void HTBlobInterpreterMulti::registerGenerator(HTIBlobGenerator* kt, int id)
{
numInstances++;
stepWidth = 1.f / numInstances;
}
void HTBlobInterpreterMulti::setCorrelationRadiusW(float newDist)
{
corrRadiusW = newDist;
}
void HTBlobInterpreterMulti::setCorrelationRadiusH(float newDist)
{
corrRadiusH = newDist;
}
int HTBlobInterpreterMulti::getNumGenerators()
{
return numInstances;
}
void HTBlobInterpreterMulti::setCorrelationPerson(float newDist)
{
corrPerson = newDist;
}
void HTBlobInterpreterMulti::handleBlobResult(std::vector<HTIBlobResultTarget::SBlobResult>& points, int id)
{
mutti.lock();
if (id < 0 || id >= MAX_GENERATORS)
{
printf("HTBLOBINTERPRETERMULTI: Generator ID out of bounds (%i)!\n", id);
mutti.unlock();
return;
}
if (generators[id])
{
printf("Generator %i has already dumped data!\n", id);
mutti.unlock();
return;
}
generators[id] = true;
const unsigned len = points.size();
for (unsigned i = 0; i < len; i++)
{
//for the virtual global space, project the x coord into global space
globalPoints.push_back(BlobHandled(points[i].type, points[i].point.x*stepWidth + id * stepWidth, points[i].point.y, points[i].point.z, id));
}
curInstances++;
if (curInstances == numInstances)
{
// printf("Global points: %lu\n", globalPoints.size());
std::vector<HTIBlobResultTarget::SBlobResult> corrBlobs;
correlateBlobs(corrBlobs);
globalPoints.clear();
HTBlobInterpreter::handleBlobResult(corrBlobs, 0xBEEF);
curInstances = 0;
for (unsigned i = 0; i < MAX_GENERATORS; i++)
{
generators[i] = false;
}
}
mutti.unlock();
}
void HTBlobInterpreterMulti::correlateBlobs(std::vector<HTIBlobResultTarget::SBlobResult>& corrBlobs)
{
const unsigned len = globalPoints.size();
BlobHandled *compare, *compareTo;
for (unsigned i = 0; i < len; i++)
{
compare = &(globalPoints[i]);
if (compare->handled)
continue;
float meanX = compare->x, meanY = compare->y, nBlobs = 1.f, meanZ = 10100.f;
switch (compare->type)
{
case HTIBlobResultTarget::BRT_HAND:
for (unsigned j = i+1; j < len; j++)
{
compareTo = &(globalPoints[j]);
if (compareTo->type != compare->type || compareTo == compare || compareTo->handled || compare->originId == compareTo->originId)
continue;
//this here is executed when two neighboring blobs are to be correlated
float dX = compare->x - compareTo->x;
if (dX < 0.f)
dX = -dX;
float dY = compare->y - compareTo->y;
if (dY < 0.f)
dY = -dY;
if(dX < corrRadiusW && dY < corrRadiusH)
{
//calc mean
meanX += compareTo->x;
meanY += compareTo->y;
nBlobs++;
compareTo->handled = true;
}
}
corrBlobs.push_back(HTIBlobResultTarget::SBlobResult(compare->type, meanX / nBlobs, meanY / nBlobs));
compare->handled = true;
break;
case HTIBlobResultTarget::BRT_PERSON:
meanX = compare->x;
meanY = compare->y;
meanZ = compare->z;
for (unsigned j = i+1; j < len; j++)
{
compareTo = &(globalPoints[j]);
if (compareTo->type != compare->type || compareTo == compare || compareTo->handled || compare->originId == compareTo->originId)
continue;
//this here is executed when two neighboring blobs are to be correlated
float dX = compare->x - compareTo->x;
if (dX < 0.f)
dX = -dX;
// float dY = compare->y - compareTo->y;
// if (dY < 0.f)
// dY = -dY;
if(dX < corrPerson)
{
if (meanZ > compareTo->z)
{
meanX = compareTo->x;
meanY = compareTo->y;
meanZ = compareTo->z;
}
compareTo->handled = true;
}
}
corrBlobs.push_back(HTIBlobResultTarget::SBlobResult(compare->type, meanX, meanY, meanZ));
compare->handled = true;
break;
}
}
}
|
642307068dbf2e7bbe6c7663a0dd429e52d468bc | 10be7432c1f478f1297df394234000d60ccbcb63 | /WindyNote/MainWindow.cpp | 1c72dc12dfa85749dae9f97cf8474e93abe7bb74 | [] | no_license | zb872676223/WindyNote | 92759aee8dcba0df876e032f960d715f7201b532 | ba96c83b8732394eece012bac95dfd26e3599cc6 | refs/heads/master | 2020-03-22T23:45:40.927742 | 2015-04-26T15:00:45 | 2015-04-26T15:00:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,165 | cpp | MainWindow.cpp | #include "MainWindow.h"
#include <QWebPage>
#include <QWebFrame>
#include <QMessageBox>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QCoreApplication>
#include <QGuiApplication>
#include <QMessageBox>
#include <QCursor>
#include <QDebug>
#include <QScreen>
#include "NoteItemWidget.h"
#include "DatabaseService.h"
#include "AddNoteFolderDialog.h"
#include "DragProxy.h"
const int NOTE_FOLDER_ID_ROLE = Qt::UserRole + 1;
const int NOTE_ITEM_HEIGHT = 80;
MainWindow::MainWindow(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
DragProxy* dragProxy = new DragProxy(this);
dragProxy->SetBorderWidth(3, 3, 3, 3);
InitContextMenus();
ui.m_noteFolderTree->setContextMenuPolicy(Qt::CustomContextMenu);
ui.m_noteList->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui.m_minButton, &QPushButton::clicked, this, &MainWindow::OnMinButtonClicked);
connect(ui.m_maxButton, &QPushButton::clicked, this, &MainWindow::OnMaxButtonClicked);
connect(ui.m_restoreButton, &QPushButton::clicked, this, &MainWindow::OnRestoreButtonClicked);
connect(ui.m_closeButton, &QPushButton::clicked, this, &MainWindow::OnCloseButtonClicked);
ui.m_restoreButton->hide();
connect(ui.m_createNoteButton, &QPushButton::clicked, this, &MainWindow::OnCreateNoteButtonClicked);
connect(ui.m_noteFolderTree, &QTreeWidget::currentItemChanged,
this, &MainWindow::OnNoteFolderItemChanged);
connect(ui.m_noteList, &QListWidget::currentItemChanged,
this, &MainWindow::OnNoteItemChanged);
connect(ui.m_noteFolderTree, &QTreeWidget::customContextMenuRequested,
this, &MainWindow::OnFolderTreeContext);
connect(ui.m_noteList, &QListWidget::customContextMenuRequested,
this, &MainWindow::OnNoteListContext);
QWebPage* page = ui.m_noteContent->page();
QWebFrame* mainFrame = page->mainFrame();
connect(mainFrame, &QWebFrame::loadFinished, this, &MainWindow::OnNoteContentViewLoaded);
QString localEditor = QCoreApplication::applicationDirPath() + "/ckeditor/editor.html";
ui.m_noteContent->load(QUrl::fromLocalFile(localEditor));
LoadNoteFolders();
}
MainWindow::~MainWindow()
{
}
void MainWindow::InitContextMenus()
{
m_noteFolderTreeContextMenu = new QMenu(this);
m_addNoteFolderAction = m_noteFolderTreeContextMenu->addAction(tr("add note folder"));
m_removeNoteFolderAction = m_noteFolderTreeContextMenu->addAction(tr("remove note folder"));
m_noteListContextMenu = new QMenu(this);
m_addNoteAction = m_noteListContextMenu->addAction(tr("add note"));
m_removeNoteAction = m_noteListContextMenu->addAction(tr("remove note"));
connect(m_addNoteFolderAction, &QAction::triggered,
this, &MainWindow::OnAddNoteFolderActionTriggered);
connect(m_removeNoteFolderAction, &QAction::triggered,
this, &MainWindow::OnRemoveNoteFolderActionTriggered);
connect(m_addNoteAction, &QAction::triggered,
this, &MainWindow::OnAddNoteActionTriggered);
connect(m_removeNoteAction, &QAction::triggered,
this, &MainWindow::OnRemoveNoteActionTriggered);
}
void MainWindow::LoadNoteFolders()
{
QVector<NoteFolder> noteFolders = DatabaseService::Instance().GetNoteFolders();
for (int i = 0; i < noteFolders.size(); i++)
{
const NoteFolder& noteFolderData = noteFolders[i];
QTreeWidgetItem* folderItem = new QTreeWidgetItem(QStringList() << noteFolderData.folderName);
folderItem->setData(0, NOTE_FOLDER_ID_ROLE, noteFolderData.folderId);
ui.m_noteFolderTree->addTopLevelItem(folderItem);
}
}
void MainWindow::OnNoteContentViewLoaded(bool ok)
{
}
void MainWindow::OnCreateNoteButtonClicked()
{
QTreeWidgetItem* curItem = ui.m_noteFolderTree->currentItem();
if (!curItem)
{
return;
}
int curNoteFolderId = curItem->data(0, NOTE_FOLDER_ID_ROLE).toInt();
AddNote("new note", "", curNoteFolderId);
}
QString MainWindow::GetEditorContent()
{
return ui.m_noteContent->page()->mainFrame()->evaluateJavaScript("getEditorContent()").toString();
}
void MainWindow::SetEditorContent(const QString& content)
{
QString processedContent = content;
processedContent.replace("\n", "");
ui.m_noteContent->page()->mainFrame()->evaluateJavaScript("setEditorContent('" + processedContent + "')");
}
void MainWindow::OnNoteFolderItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous)
{
ui.m_noteList->clear();
int curNoteFolderId = current->data(0, NOTE_FOLDER_ID_ROLE).toInt();
QVector<Note> notes = DatabaseService::Instance().GetNotes(curNoteFolderId);
for (int i = 0; i < notes.size(); i++)
{
const Note& noteData = notes[i];
QListWidgetItem* item = new QListWidgetItem(ui.m_noteList);
item->setSizeHint(QSize(100, NOTE_ITEM_HEIGHT));
NoteItemWidget* itemWidget = new NoteItemWidget(ui.m_noteList);
itemWidget->UpdateFromNote(noteData);
ui.m_noteList->setItemWidget(item, itemWidget);
}
}
void MainWindow::OnNoteItemChanged(QListWidgetItem* current, QListWidgetItem* previous)
{
if (previous)
{
NoteItemWidget* preItemWidget = static_cast<NoteItemWidget*>(ui.m_noteList->itemWidget(previous));
if (preItemWidget)
{
Note oldNoteData = preItemWidget->GetNote();
UpdateNote(oldNoteData.noteId);
Note newNoteData = DatabaseService::Instance().GetNoteById(oldNoteData.noteId);
preItemWidget->UpdateFromNote(newNoteData);
}
}
if (!current)
{
return;
}
NoteItemWidget* curItemWidget = static_cast<NoteItemWidget*>(ui.m_noteList->itemWidget(current));
if (curItemWidget)
{
Note noteData = curItemWidget->GetNote();
ui.m_subjectEdit->setText(noteData.subject);
SetEditorContent(noteData.content);
}
}
void MainWindow::OnFolderTreeContext(const QPoint& pos)
{
QTreeWidgetItem* item = ui.m_noteFolderTree->itemAt(pos);
if (!item)
return;
m_noteFolderTreeContextMenu->popup(QCursor::pos());
}
void MainWindow::OnNoteListContext(const QPoint& pos)
{
QListWidgetItem* item = ui.m_noteList->itemAt(pos);
if (!item)
return;
m_noteListContextMenu->popup(QCursor::pos());
}
void MainWindow::OnAddNoteFolderActionTriggered()
{
AddNoteFolder();
}
void MainWindow::OnRemoveNoteFolderActionTriggered()
{
QTreeWidgetItem* curItem = ui.m_noteFolderTree->currentItem();
if (!curItem)
{
return;
}
int curNoteFolderId = curItem->data(0, NOTE_FOLDER_ID_ROLE).toInt();
RemoveNoteFolderById(curNoteFolderId);
}
void MainWindow::OnAddNoteActionTriggered()
{
OnCreateNoteButtonClicked();
}
void MainWindow::OnRemoveNoteActionTriggered()
{
QListWidgetItem* curItem = ui.m_noteList->currentItem();
if (!curItem)
return;
NoteItemWidget* itemWidget = static_cast<NoteItemWidget*>(ui.m_noteList->itemWidget(curItem));
DatabaseService::Instance().RemoveNote(itemWidget->GetNote().noteId);
int index = ui.m_noteList->row(curItem);
ui.m_noteList->takeItem(index);
}
void MainWindow::AddNoteFolder()
{
AddNoteFolderDialog dlg(this);
if (dlg.exec() == QDialog::Accepted)
{
QString newFolderName = dlg.GetNewFolderName();
int newFolderId = 0;
if (DatabaseService::Instance().CreateNoteFolder(newFolderName, -1, &newFolderId))
{
QTreeWidgetItem* folderItem = new QTreeWidgetItem(QStringList() << newFolderName);
folderItem->setData(0, NOTE_FOLDER_ID_ROLE, newFolderId);
ui.m_noteFolderTree->addTopLevelItem(folderItem);
}
}
}
void MainWindow::RemoveNoteFolderById(int noteFolderId)
{
DatabaseService::Instance().RemoveNoteFolder(noteFolderId);
int noteFolderItemCount = ui.m_noteFolderTree->topLevelItemCount();
for (int i = 0; i < noteFolderItemCount; i++)
{
QTreeWidgetItem* item = ui.m_noteFolderTree->topLevelItem(i);
int id = item->data(0, NOTE_FOLDER_ID_ROLE).toInt();
if (id == noteFolderId)
{
ui.m_noteFolderTree->takeTopLevelItem(i);
return;
}
}
}
void MainWindow::AddNote(const QString& subject, const QString& content, int noteFolderId)
{
int newNoteId = 0;
DatabaseService::Instance().CreateNote(subject, content, noteFolderId, &newNoteId);
QTreeWidgetItem* curItem = ui.m_noteFolderTree->currentItem();
if (!curItem)
{
return;
}
int curNoteFolderId = curItem->data(0, NOTE_FOLDER_ID_ROLE).toInt();
if (curNoteFolderId == noteFolderId)
{
Note noteData = DatabaseService::Instance().GetNoteById(newNoteId);
QListWidgetItem* item = new QListWidgetItem;
item->setSizeHint(QSize(100, NOTE_ITEM_HEIGHT));
NoteItemWidget* itemWidget = new NoteItemWidget(ui.m_noteList);
ui.m_noteList->insertItem(0, item);
itemWidget->UpdateFromNote(noteData);
ui.m_noteList->setItemWidget(item, itemWidget);
ui.m_noteList->setCurrentItem(ui.m_noteList->item(0));
}
}
void MainWindow::UpdateNote(int noteId)
{
QString subject = ui.m_subjectEdit->text();
QString content = GetEditorContent();
DatabaseService::Instance().ModifyNote(noteId, subject, content);
}
void MainWindow::OnMinButtonClicked()
{
showMinimized();
}
void MainWindow::OnMaxButtonClicked()
{
ui.m_maxButton->hide();
ui.m_restoreButton->show();
m_normalRect = geometry();
QRect availableRect = QGuiApplication::primaryScreen()->availableGeometry();
setGeometry(availableRect);
}
void MainWindow::OnRestoreButtonClicked()
{
ui.m_maxButton->show();
ui.m_restoreButton->hide();
setGeometry(m_normalRect);
}
void MainWindow::OnCloseButtonClicked()
{
close();
}
|
656ef4d0d9d259f88214ceafcb2da2af3f74c72e | 473088ef221c1ef526b0125d3c73ae80587e7d19 | /Basic-Raytracing/src/renderSpheres.cpp | c2a5b4251c130e899dbc1e05164323b6caf7db57 | [] | no_license | harrisjacob/3D-Renderer | 7866410569a561293a936b7dc83399174107cdc2 | cf2ddd1f4257ddbb13fe270a545c1bd8665dd7d6 | refs/heads/main | 2023-09-01T07:55:05.481622 | 2021-10-27T17:44:41 | 2021-10-27T17:44:41 | 413,991,837 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,174 | cpp | renderSpheres.cpp | #include <vector>
#include <fstream>
#include "Sphere.h"
#if defined __linux__ || defined __APPLE__
#else
#define M_PI 3.141592653589793
#define INFINITY 1e8
#endif
#define MAX_RAY_DEPTH 5
//Used by the fresnelEffect caluclation to mix the reflective and refractive values
float mix(const float &a, const float &b, const float &mix){
return b*mix + a * (1-mix);
}
//Returns a color for a given pixel and can be called recursively to the maximum depth
Vec3f trace(const Vec3f &rayOrigin, const Vec3f &rayDirection, const std::vector<Sphere> &spheres, const int &depth){
//Define closest elements and distance
float closestIntersect = INFINITY;
const Sphere* closestSphere = NULL;
//Iterate through spheres to find the closest intersection
for(const Sphere& oneSphere : spheres){
float nearIntersect = INFINITY;
float farIntersect = INFINITY;
//If there is an intersection with the current sphere
if(oneSphere.intersect(rayOrigin, rayDirection, nearIntersect, farIntersect)){
if(nearIntersect < 0 ) nearIntersect = farIntersect; // If the nearIntersect is behind
//Check and update closest sphere
if(nearIntersect < closestIntersect){
closestIntersect = nearIntersect;
closestSphere = &oneSphere;
}
}
}
if(!closestSphere) return Vec3f(2); //No intersection occured, set as background color
Vec3f surfaceColor = 0; //Color of the ray/surface of the object intersected by the ray
Vec3f pointOfIntersect = rayOrigin + rayDirection*closestIntersect; //rayDirection should be passed normalized
Vec3f normalOfIntersect = pointOfIntersect - closestSphere->center; //normal at intersection point
normalOfIntersect.normalize(); //Normalize normal vector
float bias = 1e-4; //Bias added to the point being traced
bool inside = false; //Is view inside a sphere
if(rayDirection.dot(normalOfIntersect) > 0){ //Test for inside
//If ray direction and normal vector are pointing in the same direction (relatively)
//then the view must be from inside a sphere
normalOfIntersect = -normalOfIntersect; //Flip normal
inside = true;
}
if((closestSphere->transparency > 0 || closestSphere->reflection > 0) && depth < MAX_RAY_DEPTH){
//Only make recursive calls if they are needed and max depth has not been reached
float facingRatio = -rayDirection.dot(normalOfIntersect); //Ray direction and normal vector should be pointing in opposite directions
//Gives the effect of the reflection becoming less defined the further the subject is from the point of reflection
//Change the last argument (mix value) to tweak the effect
float fresnelEffect = mix(pow(1-facingRatio, 3), 1, 0.1);
//Compute reflection direction, rayDirection and normal vector should already be normalized
Vec3f reflectDirection = rayDirection - normalOfIntersect * 2 * rayDirection.dot(normalOfIntersect);
reflectDirection.normalize();
Vec3f reflection = trace(pointOfIntersect+normalOfIntersect*bias, reflectDirection, spheres, depth+1);
//Recursively call trace function to get a reflection value
Vec3f refraction = 0;
//If sphere is transparent, a refraction ray (trasmission) needs to be calculated
if(closestSphere->transparency){
float ior = 1.1; //Chosen index of refraction value
//The following is an implementation of refractive equations desribed in a paper written by Bram de Greve
//Source: https://graphics.stanford.edu/courses/cs148-10-summer/docs/2006--degreve--reflection_refraction.pdf
float eta = (inside) ? ior : 1/ior; //Greek symbol eta is the ratio of IORs: (IOR_prev_material/IOR_new_material)
//If already in the sphere, the ratio is flipped
float cosI = -normalOfIntersect.dot(rayDirection); //cosine of angle of incidence
//See conclusion of above source
Vec3f refractDirection = rayDirection*eta + normalOfIntersect*(eta*cosI - sqrt(1-(eta*eta*(1-cosI*cosI))));
refractDirection.normalize();
//Recursively call trace function to get refraction color influence
refraction = trace(pointOfIntersect - normalOfIntersect*bias, refractDirection, spheres, depth+1);
}
//The result is a mix of reflection and refraction (if the sphere is transparent)
surfaceColor = (reflection*fresnelEffect + refraction * (1-fresnelEffect) * closestSphere->transparency) * closestSphere->surfaceColor;
}else{
//If max ray depth has been reached or its a diffuse object (no transparency or reflection), theres no need to raytrace any further
for(const Sphere& firstSphere: spheres){ //Check for light being emitted from other spheres
if(firstSphere.emissionColor.x > 0){
//Its a light source
Vec3f transmission = 1;
Vec3f lightDirection = firstSphere.center - pointOfIntersect;
lightDirection.normalize();
for(const Sphere& intersectSphere: spheres){
if(&intersectSphere == &firstSphere) continue;
float t0, t1; //Don't need these values, just need to fill function intersect parameters
if(intersectSphere.intersect(pointOfIntersect + normalOfIntersect*bias, lightDirection, t0, t1)){
transmission = 0;
break;
}
}
//Add emission color contributions from each of the spheres that emit light
surfaceColor += closestSphere->surfaceColor * transmission * std::max(float(0), normalOfIntersect.dot(lightDirection)) * firstSphere.emissionColor;
}
}
}
return surfaceColor + closestSphere->emissionColor;
}
void render(const std::vector<Sphere>& spheres){
unsigned width = 640, height = 480;
Vec3f *image = new Vec3f[width*height], *pixel = image;
//Image is a dynamically allocate array of RGB values, pixel and image points to the first vector in array
//The following is an implementation of a camera ray generation provided by scratchapixel.com
//Source: https://www.scratchapixel.com/lessons/3d-basic-rendering/ray-tracing-generating-camera-rays/generating-camera-rays
float invWidth = 1/float(width), invHeight = 1/float(height);
float fov = 30, aspectRatio = width / float(height);
float angle = tan(M_PI * 0.5 * fov / 180);
//tan is evaulated in radians hence the pi/180, the FOV must be split in half because it is centered at the middle of the screen
//Generate rayDirection for each pixel in image
for(unsigned y=0; y<height; y++){
for(unsigned x=0; x<width; x++, pixel++){ //Iterate to the next pixel each time
float xComponent = (2*((x+0.5)*invWidth) - 1) * angle * aspectRatio;
float yComponent = (1 - 2*((y+0.5)*invHeight)) * angle;
//For each pixel x, 0.5 is added to center the value horizontally on the pixel
//Dividing by the width (multiplying by invWidth) gives the percentage of horizontal placement, far left being 0 and far right being 1
//This value is in the range [0,1], but the canvas should be in the range [-1,1] so multiply by two and shift left
//Multiplying by aspectRation unsquashes the pixels making them square relative to the pixel height
//Multiplying by the angle stretches or squashes the images based on input angle
//The yComponent is (1 - 2 * ...) ... because pixels above the camera should have positive values, and those below should have negative values
Vec3f rayDirection(xComponent, yComponent, -1);
//The image canvas is 1 unit away from the camera in camera space, and the camera is align along the negative z-axis
rayDirection.normalize();
*pixel = trace(Vec3f(0), rayDirection, spheres, 0);
}
}
//Save result to PPM image
std::ofstream ofs("./sphereRender.ppm", std::ios::out | std::ios::binary);
//std::ios::out specfied that the file is open for writing, std::ios::binary means operations are performed in binary mode rather than text
//P6 is a binary encoding (see P6 below)
//P6 is a magic number used by PPM files, followed by whitespace separated width height, followed by the maximum color value
ofs << "P6\n" << width << " " << height << "\n255\n";
for(unsigned i=0; i< width*height; i++){
ofs << (unsigned char)(std::min(float(1), image[i].x) * 255) <<
(unsigned char)(std::min(float(1), image[i].y) * 255) <<
(unsigned char)(std::min(float(1), image[i].z) * 255);
//Each sample is represented in 1 byte pur binary, hence unsigned char
}
ofs.close();
delete[] image;
}
int main(int argc, char **argv){
std::vector<Sphere> spheres;
//position, radius, surface color, reflection =0, transparency =0, emission color =0
spheres.push_back(Sphere(Vec3f(0.0,-10004, -20), 10000, Vec3f(0.2,0.2,0.2), 0, 0.0));
spheres.push_back(Sphere(Vec3f(0.0,0, -20), 4, Vec3f(1.0,0.32,0.36), 1, 0.5));
spheres.push_back(Sphere(Vec3f(5,-1, -15), 2, Vec3f(0.9,0.76,0.46), 1, 0.0));
spheres.push_back(Sphere(Vec3f(5,0, -25), 3, Vec3f(0.65,0.77,0.97), 1, 0.0));
spheres.push_back(Sphere(Vec3f(-5.5,0, -15), 3, Vec3f(0.9,0.9,0.9), 1, 0.0));
//Light source
spheres.push_back(Sphere(Vec3f(0.0,20, -30), 3, Vec3f(0.0,0.0,0.0), 0, 0.0, Vec3f(3)));
render(spheres);
return 0;
} |
77648ac06260d551cf101d5a3107ae68d28b06c2 | fa27e64f55d35f7b70c59171fc38d264c10b47bb | /RatingLess1300/hungrySequence.cpp | cee9463c2a376ee2cc127bdf3aaa82da5db99813 | [] | no_license | papi656/a2ojLadder | 8abee33da89d805d581ec28ba5738618569f05f4 | d2597743e76dae53cb9944768a1a51ae87cfed7f | refs/heads/master | 2023-05-27T07:29:49.223189 | 2021-06-10T07:59:27 | 2021-06-10T07:59:27 | 363,168,394 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 204 | cpp | hungrySequence.cpp | #include <iostream>
#define lld long long int
using namespace std;
int main(){
lld n;
cin >> n;
for(lld i = 0; i < n; i++){
if(i == n-1)
cout << 3*n + i;
else
cout << 3*n + i << " ";
}
}
|
51f0b9004fd73042632ad9f1049bde0a2c1e0bfa | 2a8b952a1202300015b2a0ecc51437703e72628f | /src/mem/freelist.h | c8766c8cd1f13e129ddc6de898da99fafa94f859 | [
"MIT",
"LicenseRef-scancode-generic-cla"
] | permissive | devnexen/snmalloc | 07a144f8fcbe90c3cb71c23e3538ea9a25b7bd0e | 6e638742e3c66549174d4c264bd05c9435938ac1 | refs/heads/master | 2023-08-18T12:15:03.177622 | 2021-08-07T10:34:30 | 2021-08-13T08:04:24 | 199,717,935 | 0 | 0 | MIT | 2019-07-30T19:52:48 | 2019-07-30T19:52:47 | null | UTF-8 | C++ | false | false | 13,292 | h | freelist.h | #pragma once
/**
* This file encapsulates the in disused object free lists
* that are used per slab of small objects.
*/
#include "../ds/address.h"
#include "../ds/cdllist.h"
#include "../ds/dllist.h"
#include "../ds/helpers.h"
#include "allocconfig.h"
#include "entropy.h"
#include <cstdint>
namespace snmalloc
{
#ifdef CHECK_CLIENT
static constexpr std::size_t PRESERVE_BOTTOM_BITS = 16;
#endif
/**
* Used to turn a location into a key. This is currently
* just the slab address truncated to 16bits and offset by 1.
*/
template<typename T, capptr_bounds B>
inline static address_t initial_key(CapPtr<T, B> slab)
{
#ifdef CHECK_CLIENT
/**
* This file assumes that SLAB_BITS is smaller than 16. In multiple
* places it uses uint16_t to represent the offset into a slab.
*/
static_assert(
SLAB_BITS <= 16,
"Encoding requires slab offset representable in 16bits.");
return (address_cast(slab) & SLAB_MASK) + 1;
#else
UNUSED(slab);
return 0;
#endif
}
static inline bool different_slab(address_t p1, address_t p2)
{
return ((p1 ^ p2) >= SLAB_SIZE);
}
template<typename T>
static inline bool different_slab(address_t p1, CapPtr<T, CBAlloc> p2)
{
return different_slab(p1, address_cast(p2));
}
template<typename T, typename U>
static inline bool
different_slab(CapPtr<T, CBAlloc> p1, CapPtr<U, CBAlloc> p2)
{
return different_slab(address_cast(p1), address_cast(p2));
}
class FreeObject;
class EncodeFreeObjectReference
{
CapPtr<FreeObject, CBAlloc> reference;
/**
* On architectures which use IntegerPointers, we can obfuscate our free
* lists and use this to drive some probabilistic checks for integrity.
*
* There are two definitions of encode() below, which use std::enable_if_t
* to gate on do_encode.
*/
#ifndef CHECK_CLIENT
static constexpr bool do_encode = false;
#else
static constexpr bool do_encode = aal_supports<IntegerPointers, Aal>;
#endif
public:
#ifdef CHECK_CLIENT
template<typename T = FreeObject>
static std::enable_if_t<do_encode, CapPtr<T, CBAlloc>> encode(
uint16_t local_key, CapPtr<T, CBAlloc> next_object, LocalEntropy& entropy)
{
// Simple involutional encoding. The bottom half of each word is
// multiplied by a function of both global and local keys (the latter,
// in practice, being the address of the previous list entry) and the
// resulting word's top part is XORed into the pointer value before it
// is stored.
auto next = address_cast(next_object);
constexpr address_t MASK = bits::one_at_bit(PRESERVE_BOTTOM_BITS) - 1;
// Mix in local_key
address_t key = (local_key + 1) * entropy.get_constant_key();
next ^= (((next & MASK) + 1) * key) &
~(bits::one_at_bit(PRESERVE_BOTTOM_BITS) - 1);
return CapPtr<T, CBAlloc>(reinterpret_cast<T*>(next));
}
#endif
template<typename T = FreeObject>
static std::enable_if_t<!do_encode, CapPtr<T, CBAlloc>> encode(
uint16_t local_key, CapPtr<T, CBAlloc> next_object, LocalEntropy& entropy)
{
UNUSED(local_key);
UNUSED(entropy);
return next_object;
}
void store(
CapPtr<FreeObject, CBAlloc> value,
uint16_t local_key,
LocalEntropy& entropy)
{
reference = encode(local_key, value, entropy);
}
CapPtr<FreeObject, CBAlloc> read(uint16_t local_key, LocalEntropy& entropy)
{
return encode(local_key, reference, entropy);
}
};
struct Remote;
/**
* Free objects within each slab point directly to the next.
* The next_object pointer can be encoded to detect
* corruption caused by writes in a UAF or a double free.
*/
class FreeObject
{
public:
EncodeFreeObjectReference next_object;
static CapPtr<FreeObject, CBAlloc> make(CapPtr<void, CBAlloc> p)
{
return p.template as_static<FreeObject>();
}
/**
* Construct a FreeObject for local slabs from a Remote message.
*/
static CapPtr<FreeObject, CBAlloc> make(CapPtr<Remote, CBAlloc> p)
{
// TODO: Zero the difference between a FreeObject and a Remote
return p.template as_reinterpret<FreeObject>();
}
/**
* Read the next pointer handling any required decoding of the pointer
*/
CapPtr<FreeObject, CBAlloc> read_next(uint16_t key, LocalEntropy& entropy)
{
return next_object.read(key, entropy);
}
};
/**
* Used to iterate a free list in object space.
*
* Checks signing of pointers
*/
class FreeListIter
{
CapPtr<FreeObject, CBAlloc> curr = nullptr;
#ifdef CHECK_CLIENT
address_t prev = 0;
#endif
uint16_t get_prev()
{
#ifdef CHECK_CLIENT
return prev & 0xffff;
#else
return 0;
#endif
}
/**
* Updates the cursor to the new value,
* importantly this updates the key being used.
* Currently this is just the value of current before this call.
* Other schemes could be used.
*/
void update_cursor(CapPtr<FreeObject, CBAlloc> next)
{
#ifdef CHECK_CLIENT
# ifndef NDEBUG
if (next != nullptr)
{
check_client(
!different_slab(prev, next),
"Heap corruption - free list corrupted!");
}
# endif
prev = address_cast(curr);
#endif
curr = next;
}
public:
FreeListIter(CapPtr<FreeObject, CBAlloc> head)
: curr(head)
#ifdef CHECK_CLIENT
,
prev(initial_key(head))
#endif
{
SNMALLOC_ASSERT(head != nullptr);
}
FreeListIter() = default;
/**
* Checks if there are any more values to iterate.
*/
bool empty()
{
return curr == nullptr;
}
/**
* Returns current head without affecting the iterator.
*/
CapPtr<FreeObject, CBAlloc> peek()
{
return curr;
}
/**
* Moves the iterator on, and returns the current value.
*/
CapPtr<FreeObject, CBAlloc> take(LocalEntropy& entropy)
{
#ifdef CHECK_CLIENT
check_client(
!different_slab(prev, curr), "Heap corruption - free list corrupted!");
#endif
auto c = curr;
update_cursor(curr->read_next(get_prev(), entropy));
return c;
}
};
/**
* Used to build a free list in object space.
*
* Adds signing of pointers
*
* On 64bit ptr architectures this data structure has
* 44 bytes of data
* and has an alignment of
* 8 bytes
* This unfortunately means its sizeof is 48bytes. We
* use the template parameter, so that an enclosing
* class can make use of the remaining four bytes.
*
* The builder uses two queues, and "randomly" decides to
* add to one of the two queues. This means that we will
* maintain a randomisation of the order between
* allocations.
*
* The fields are paired up to give better codegen as then they are offset
* by a power of 2, and the bit extract from the interleaving seed can
* be shifted to calculate the relevant offset to index the fields.
*
* If RANDOM is set to false, then the code does not perform any
* randomisation.
*/
template<bool RANDOM = true, typename S = uint32_t>
class FreeListBuilder
{
static constexpr size_t LENGTH = RANDOM ? 2 : 1;
// Pointer to the first element.
EncodeFreeObjectReference head[LENGTH];
// Pointer to the reference to the last element.
// In the empty case end[i] == &head[i]
// This enables branch free enqueuing.
EncodeFreeObjectReference* end[LENGTH];
#ifdef CHECK_CLIENT
// The bottom 16 bits of the previous pointer
uint16_t prev[LENGTH];
// The bottom 16 bits of the current pointer
// This needs to be stored for the empty case
// where it is `initial_key()` for the slab.
uint16_t curr[LENGTH];
#endif
public:
S s;
uint16_t get_prev(uint32_t index)
{
#ifdef CHECK_CLIENT
return prev[index];
#else
UNUSED(index);
return 0;
#endif
}
uint16_t get_curr(uint32_t index)
{
#ifdef CHECK_CLIENT
return curr[index];
#else
UNUSED(index);
return 0;
#endif
}
static constexpr uint16_t HEAD_KEY = 1;
public:
FreeListBuilder()
{
init();
}
/**
* Start building a new free list.
* Provide pointer to the slab to initialise the system.
*/
void open(CapPtr<void, CBChunk> p)
{
SNMALLOC_ASSERT(empty());
for (size_t i = 0; i < LENGTH; i++)
{
#ifdef CHECK_CLIENT
prev[i] = HEAD_KEY;
curr[i] = initial_key(p) & 0xffff;
#else
UNUSED(p);
#endif
end[i] = &head[i];
}
}
/**
* Checks if the builder contains any elements.
*/
bool empty()
{
for (size_t i = 0; i < LENGTH; i++)
{
if (address_cast(end[i]) != address_cast(&head[i]))
return false;
}
return true;
}
bool debug_different_slab(CapPtr<FreeObject, CBAlloc> n)
{
for (size_t i = 0; i < LENGTH; i++)
{
if (!different_slab(address_cast(end[i]), n))
return false;
}
return true;
}
/**
* Adds an element to the builder
*/
void add(CapPtr<FreeObject, CBAlloc> n, LocalEntropy& entropy)
{
SNMALLOC_ASSERT(!debug_different_slab(n) || empty());
auto index = RANDOM ? entropy.next_bit() : 0;
end[index]->store(n, get_prev(index), entropy);
end[index] = &(n->next_object);
#ifdef CHECK_CLIENT
prev[index] = curr[index];
curr[index] = address_cast(n) & 0xffff;
#endif
}
/**
* Calculates the length of the queue.
* This is O(n) as it walks the queue.
* If this is needed in a non-debug setting then
* we should look at redesigning the queue.
*/
size_t debug_length(LocalEntropy& entropy)
{
size_t count = 0;
for (size_t i = 0; i < LENGTH; i++)
{
uint16_t local_prev = HEAD_KEY;
EncodeFreeObjectReference* iter = &head[i];
CapPtr<FreeObject, CBAlloc> prev_obj = iter->read(local_prev, entropy);
uint16_t local_curr = initial_key(prev_obj) & 0xffff;
while (end[i] != iter)
{
CapPtr<FreeObject, CBAlloc> next = iter->read(local_prev, entropy);
check_client(!different_slab(next, prev_obj), "Heap corruption");
local_prev = local_curr;
local_curr = address_cast(next) & 0xffff;
count++;
iter = &next->next_object;
}
}
return count;
}
/**
* Adds a terminator at the end of a free list,
* but does not close the builder. Thus new elements
* can still be added. It returns a new iterator to the
* list.
*
* This also collapses the two queues into one, so that it can
* be iterated easily.
*
* This is used to iterate an list that is being constructed.
*
* It is used with preserve_queue enabled to check
* invariants in Debug builds.
*
* It is used with preserve_queue disabled by close.
*/
FreeListIter terminate(LocalEntropy& entropy, bool preserve_queue = true)
{
if constexpr (RANDOM)
{
SNMALLOC_ASSERT(end[1] != &head[0]);
SNMALLOC_ASSERT(end[0] != &head[1]);
// If second list is non-empty, perform append.
if (end[1] != &head[1])
{
end[1]->store(nullptr, get_prev(1), entropy);
// Append 1 to 0
auto mid = head[1].read(HEAD_KEY, entropy);
end[0]->store(mid, get_prev(0), entropy);
// Re-code first link in second list (if there is one).
// The first link in the second list will be encoded with initial_key,
// But that needs to be changed to the curr of the first list.
if (mid != nullptr)
{
auto mid_next = mid->read_next(initial_key(mid) & 0xffff, entropy);
mid->next_object.store(mid_next, get_curr(0), entropy);
}
auto h = head[0].read(HEAD_KEY, entropy);
// If we need to continue adding to the builder
// Set up the second list as empty,
// and extend the first list to cover all of the second.
if (preserve_queue && h != nullptr)
{
#ifdef CHECK_CLIENT
prev[0] = prev[1];
curr[0] = curr[1];
#endif
end[0] = end[1];
#ifdef CHECK_CLIENT
prev[1] = HEAD_KEY;
curr[1] = initial_key(h) & 0xffff;
#endif
end[1] = &(head[1]);
}
SNMALLOC_ASSERT(end[1] != &head[0]);
SNMALLOC_ASSERT(end[0] != &head[1]);
return {h};
}
}
else
{
UNUSED(preserve_queue);
}
end[0]->store(nullptr, get_prev(0), entropy);
return {head[0].read(HEAD_KEY, entropy)};
}
/**
* Close a free list, and set the iterator parameter
* to iterate it.
*/
void close(FreeListIter& dst, LocalEntropy& entropy)
{
dst = terminate(entropy, false);
init();
}
/**
* Set the builder to a not building state.
*/
void init()
{
for (size_t i = 0; i < LENGTH; i++)
{
end[i] = &head[i];
}
}
};
} // namespace snmalloc
|
f2f6e3e55eefde220432b6d02841ffcdc7d8b6a1 | 84efc01eee34b35e695331dd46fc61b82d0825bc | /include/Application.h | c3f91d9bb6ca59e2df58543c5aa8bc3b81f3201e | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | eantcal/httpsrv | 9e4dd8fe6dccacceaa92d063a267c7297b07d14c | e4d2d476d793a857e25da86e288634af86ab4183 | refs/heads/master | 2023-02-18T01:09:00.916154 | 2021-01-17T11:31:55 | 2021-01-17T11:31:55 | 231,215,675 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,251 | h | Application.h | //
// This file is part of httpsrv
// Copyright (c) Antonino Calderone (antonino.calderone@gmail.com)
// All rights reserved.
// Licensed under the MIT License.
// See COPYING file in the project root for full license information.
//
/* -------------------------------------------------------------------------- */
#ifndef __APPLICATION_H__
#define __APPLICATION_H__
/* -------------------------------------------------------------------------- */
#include "HttpServer.h"
#include "FileRepository.h"
#include "FileUtils.h"
#include "SysUtils.h"
#include "StrUtils.h"
#include "TcpSocket.h"
#include <memory>
#include <string>
#include <iostream>
#include <sstream>
#include "config.h"
/* -------------------------------------------------------------------------- */
//! Helper class to manage the application configuration and server startup
class Application
{
public:
enum class ErrCode
{
success,
commandLineError,
showVersionUsage,
fileRepositoryInitError,
commLibError,
httpSrvBindError,
httpSrvListenError,
httpSrvStartError,
};
//! Initializes the application based on input paramters
Application(int argc, char *argv[], std::ostream &logger);
//! Applies a given configuration and runs HTTP Server
ErrCode run();
//! Gets any specific error message based on run() return-value
const std::string &getError() const noexcept
{
return _errMessage;
}
private:
Application(const Application &) = delete;
Application &operator=(const Application &) = delete;
bool showUsage(std::stringstream &os) const;
std::ostream &_logger;
std::string _progName;
std::string _commandLine;
std::string _localRepositoryPath = HTTPSRV_LOCAL_REPOSITORY_PATH;
TcpSocket::TranspPort _httpServerPort = HTTPSRV_PORT;
bool _showHelp = false;
bool _showVer = false;
bool _error = false;
bool _verboseModeOn = false;
std::string _errMessage;
static const int _min_ver = HTTPSRV_MIN_V;
static const int _maj_ver = HTTPSRV_MAJ_V;
int _mrufilesN = MRUFILES_DEF_N;
FileRepository::Handle _FileRepository;
};
/* -------------------------------------------------------------------------- */
#endif //! __APPLICATION_H__
|
a0a66431df081cb9b00cbaccb66816cc7adedf56 | 3b93f86d6986a68ecd0f43f8832b4807a566c9ab | /Software/swirli/libs/libserial.cpp | 290e55fc4cdf7f3649db933b28a2acae1bad9c07 | [
"MIT"
] | permissive | martijnvandijk/th06 | 66fe94924359a96679f5af1ad75d74f6df93f179 | 873c63fbd232c3465f700f5ecee945b2f2ecd8f2 | refs/heads/master | 2021-01-21T23:58:11.699661 | 2016-04-13T11:56:53 | 2016-04-13T11:56:53 | 45,834,385 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,403 | cpp | libserial.cpp | /*!
\file libserial.cpp
\brief Class to manage the serial port on Linux systems
\version 1.0
\date 26 november 2014
*/
#include "libserial.h"
/*! \brief Constructor of class LibSerial
*/
LibSerial::LibSerial (void) { }
/*! \brief Destructor of class LibSerial. It closes the connection
*/
LibSerial::~LibSerial (void) {
close();
}
// Configuration and initialization
/*! \brief Open the serial port
\param device : Port name /dev/ttyS0, /dev/ttyAMA0, /dev/ttyUSB0 ...
\param bauds : Baud rate of the serial port.
\n Supported baud rate for Linux :\n
- 110
- 300
- 600
- 1200
- 2400
- 4800
- 9600
- 19200
- 38400
- 57600
- 115200
\n The device is configured 8N1: 8 bits, no parity, 1 stop bit
\return 1 success
\return -1 error while opening the device
\return -2 unable to set non-blocking mode
\return -3 speed (bauds) not recognized
\return -4 unable to set baud rate
\return -5 unable to set flags
*/
int LibSerial::open (const char * device, unsigned int bauds) {
// Open device
fd = ::open (device, O_RDWR | O_NOCTTY | O_NDELAY); // Open port
if (fd == -1) return -1; // If the device is not open, return -1
if (fcntl (fd, F_SETFL, FNDELAY) == 11) // Open the device in nonblocking mode
return -2;
// Set parameters
struct termios options; // Structure with the device's options
bzero (&options, sizeof (options)); // Clear all the options
speed_t speed;
switch (bauds) { // Set the speed (bauds)
case 110 : speed = B110; break;
case 300 : speed = B300; break;
case 600 : speed = B600; break;
case 1200 : speed = B1200; break;
case 2400 : speed = B2400; break;
case 4800 : speed = B4800; break;
case 9600 : speed = B9600; break;
case 19200 : speed = B19200; break;
case 38400 : speed = B38400; break;
case 57600 : speed = B57600; break;
case 115200 : speed = B115200; break;
default : return -3;
}
if (cfsetispeed (&options, speed) == -1 || // Set the baud rate at selected bauds
cfsetospeed (&options, speed) == -1)
return -4;
options.c_cflag |= ( CLOCAL | CREAD | CS8); // Configure the device to 8N1: 8 bits, no parity, 1 stop bit
options.c_cflag &= ~(PARENB | PARODD);
options.c_cflag &= ~(CSTOPB) ;
options.c_iflag |= ( IGNPAR | IGNBRK ); // No control
options.c_cflag &= ~(CRTSCTS) ;
options.c_cc[VTIME] = 0; // Timer unused
options.c_cc[VMIN] = 2; // Return if two characters available for reading
if (tcsetattr (fd, TCSANOW, &options) == -1) // Activate the settings
return -5;
return 1; // Success
}
/*! \brief Close the connection with the current device
*/
void LibSerial::close (void) {
::close (fd);
}
// Read/Write operation on characters
/*! \brief Wait for a char from the serial device and return the data read
\param pChar : char read on the serial device
\return 1 success
\return -1 error while reading the char
*/
int LibSerial::readChar (char * pChar) {
if (::read (fd, pChar, 1) != 1) // Try to read a char from the device
return -1; // Error while reading
return 1; // Read successfull
}
/*! \brief Write a char on the current serial port
\param Char : char to send on the port
\return 1 success
\return -1 error while writting data
*/
int LibSerial::writeChar (char Char) {
if (::write (fd, &Char, 1) != 1) // Write the char
return -1; // Error while writting
return 1; // Write operation successfull
}
// Read/Write operation on strings
/*! \brief Read a string from the serial device
\param string : string read on the serial device
\param finalChar : final char of the string
\param maxChars : maximum allowed number of chars read
\return >0 success, return the number of chars read
\return -1 error while reading the char
\return -2 maxChars is reached
*/
int LibSerial::readString (char * string, char finalChar, unsigned int maxChars) {
unsigned int nbChars = 0; // Number of chars read
int ret; // Returned value from read
while (nbChars < maxChars) { // While the buffer is not full
ret = readChar (&string[nbChars]); // Read a char with the restant time
if (ret == 1) { // If a char has been read
if (string[nbChars] == finalChar) { // Check if it is the final char
string [++nbChars] = '\0'; // Yes : add the end character '\0'
return nbChars; // Return the number of chars read
}
nbChars++; // If not, just increase the number of chars read
}
if (ret < 0) return ret; // Error while reading : return the error number
}
return -2; // Buffer is full : return -3
}
/*! \brief Write a string on the current serial port
\param string : string to send on the port (must be terminated by '\0')
\return 1 success
\return -1 error while writting data
*/
int LibSerial::writeString (const char * string) {
int lenght = strlen (string); // Lenght of the string
if (::write(fd, string, lenght) != lenght) // Write the string
return -1; // Error while writing
return 1; // Write operation successfull
}
// Read/Write operation on bytes
/*! \brief Write an array of data on the current serial port
\param buffer : array of bytes to send on the port
\param nbBytes : number of bytes to send
\return 1 success
\return -1 error while writting data
*/
int LibSerial::write (const void * buffer, unsigned int nbBytes) {
if (::write (fd, buffer, nbBytes) != (ssize_t) nbBytes) // Write data
return -1; // Error while writing
return 1; // Write operation successfull
}
/*! \brief Read an array of bytes from the serial device
\param buffer : array of bytes read from the serial device
\param maxBytes : maximum allowed number of bytes to read
\return 1 success, return the number of bytes read
\return -1 error while reading the bytes
*/
int LibSerial::read (void * buffer, unsigned int maxBytes) {
unsigned int nbBytesRead = 0;
while (nbBytesRead < maxBytes) { // While not all bytes read
unsigned char * ptr =(unsigned char *) buffer + nbBytesRead; // Compute the position of the current byte
int ret = ::read (fd,(void *) ptr, maxBytes - nbBytesRead); // Try to read some bytes on the device
if (ret == -1) return -1; // Error while reading
if (ret > 0) // One or several byte(s) has been read on the device
nbBytesRead += ret; // Increase the number of read bytes
}
return 1; // Success : bytes has been read
}
// Special operation
/*! \brief Empty send and receive buffers
*/
void LibSerial::flush (void) {
tcflush (fd, TCIOFLUSH);
}
/*! \brief Return the number of bytes in the receive buffer
\return The number of bytes in the receive buffer
*/
int LibSerial::peek (void) {
int nbBytes = 0;
ioctl (fd, FIONREAD, &nbBytes);
return nbBytes;
}
|
f2e4af7a96e6fd665ca9f0054fe40d31a9c8c8d6 | 69ea41e3ca39ae0da17e60cf141e8015845d4f18 | /src/Simulator.cpp | ae347d91a079b7ce3fb8cffbc4c19c0cda1ba397 | [] | no_license | surajj1234/gun_hunt | aa47e6db7bf33a75184349a66ad8a327a4f1a94e | 1dca83556ca9dc35ce4c8b14bf959991dc61980c | refs/heads/master | 2021-07-15T21:26:28.198236 | 2017-10-23T22:09:35 | 2017-10-23T22:09:35 | 107,276,168 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,826 | cpp | Simulator.cpp | /***************************************************************************
* Author : Suraj Joseph
* Available for public use (but not misuse !)
****************************************************************************/
#include "Simulator.h"
#include <ncurses.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <unistd.h>
Simulator::Simulator(AudioDetector& ad, CommClient& comms, FakeSerial& ser,
GpsDriver& gd) :
audio_detector(ad), communications(comms), serial(ser), gps(gd)
{
}
void Simulator::InitGraphics()
{
// Refer to ncurses docs for initialization details
initscr();
timeout(0);
raw();
curs_set(0);
keypad(stdscr, true);
noecho();
mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL);
mouseinterval(75); // In ms
if (has_colors())
{
start_color();
init_pair(RED_ON_WHITE, COLOR_RED, COLOR_WHITE);
init_pair(YELLOW_ON_BLACK, COLOR_YELLOW, COLOR_BLACK);
init_pair(RED_ON_BLACK, COLOR_RED, COLOR_BLACK);
init_pair(GREEN_ON_BLACK, COLOR_GREEN, COLOR_BLACK);
}
// Ugly hack to get terminal emulators to report mouse movement
// Bypassing the terminfo database via the 1003 escape sequence
printf("\033[?1003h\n");
drawScreen();
}
void Simulator::drawScreen()
{
clear();
turnOnColor(RED_ON_WHITE);
mvprintw(0, 0, "Move mouse inside battlefield to change Lat/Long");
mvprintw(2, 0, "Mouse Left Click inside battlefield to fire a gunshot");
mvprintw(4, 0, "Press q to exit\n");
turnOffColor(RED_ON_WHITE);
// Figure out scaled co-ordinates and draw box for battlefield, with
// dynamic spacing from the window borders
getmaxyx(stdscr, rows, cols);
getyx(stdscr, start_y, start_x);
spacing_y = (10 * (rows - start_y)) / 100;
spacing_x = (10 * (cols - start_x)) / 100;
// (y1, x1)..............(y3, x3)
// . .
// . .
// . .
// (y2, x2).................
box_y1 = start_y + spacing_y;
box_x1 = start_x + spacing_x;
box_y2 = rows - spacing_y;
box_x2 = box_x1;
box_y3 = box_y1;
box_x3 = cols - spacing_x;
turnOnColor(YELLOW_ON_BLACK);
mvhline(box_y1, box_x1, '*', cols - (2 * spacing_x));
mvhline(box_y2, box_x2, '*', cols - (2 * spacing_x));
mvvline(box_y3, box_x3, '*', (rows - start_y) - (2 * spacing_y));
mvvline(box_y1, box_x1, '*', (rows - start_y) - (2 * spacing_y));
turnOffColor(YELLOW_ON_BLACK);
// Set window positions for status fields
latitude_y = box_y1 - 1;
latitude_x = box_x1;
longitude_y = latitude_y;
longitude_x = box_x1 + 15;
timestamp_y = latitude_y;
timestamp_x = box_x1 + 30;
server_y = latitude_y;
server_x = box_x1 + 50;
updatePositionData(box_y1, box_x1);
refresh();
}
Simulator::~Simulator()
{
printf("\033[?1003l\n"); // Disable mouse movement events
endwin();
}
void Simulator::Run()
{
int ch;
while ((ch = getch()) != 'q')
{
if (ch == KEY_MOUSE)
{
handleMouseEvent();
}
updateEvents_1Hz();
checkForScreenResize();
}
}
void Simulator::handleMouseEvent()
{
MEVENT event;
if(getmouse(&event) == OK)
{
int mouse_y = (uint8_t)event.y;
int mouse_x = (uint8_t)event.x;
if (pointInBox(mouse_y, mouse_x))
{
if (event.bstate & REPORT_MOUSE_POSITION)
{
updatePositionData(mouse_y, mouse_x);
}
else if (event.bstate & BUTTON1_PRESSED)
{
mvprintw(mouse_y, mouse_x, "BOOM!");
audio_detector.setDetected(true);
}
}
}
}
bool Simulator::pointInBox(int y, int x)
{
return ((y > box_y1) && (y < box_y2)) &&
((x > box_x1) && (x < box_x3));
}
void Simulator::updatePositionData(int mouse_y, int mouse_x)
{
gps_latitude = mouse_y - box_y1;
gps_longitude = mouse_x - box_x1;
mvprintw(latitude_y, latitude_x, "Lat: %03dS", gps_latitude);
mvprintw(longitude_y, longitude_x, "Long: %03dE", gps_longitude);
}
void Simulator::updateEvents_1Hz()
{
static struct timespec prev = {0,0};;
if (timeSinceMs(prev) > 1000) // 1 Hz
{
// Update timestamp
clock_gettime(CLOCK_REALTIME, &prev);
mvprintw(timestamp_y, timestamp_x, "Time: %ld", prev.tv_sec);
// Update server status
mvprintw(server_y, server_x, "Server: ");
bool connected = communications.IsConnected();
if (connected)
{
turnOnColor(GREEN_ON_BLACK);
printw("CONNECTED ");
turnOffColor(GREEN_ON_BLACK);
}
else
{
turnOnColor(RED_ON_BLACK);
printw("DISCONNECTED");
turnOffColor(RED_ON_BLACK);
}
double gps_time = prev.tv_sec + (double)prev.tv_nsec / 1.0e9;
gps.PulseInterruptHandler();
// Send simulated GPS input to the serial stream
std::string gps_output = std::string("$GPXXX") +
std::string(",") +
std::to_string(gps_latitude) +
std::string(",") +
std::string("S") +
std::string(",") +
std::to_string(gps_longitude) +
std::string(",") +
std::string("E") +
std::string(",") +
std::to_string(gps_time) +
"\n";
// Add a 50 ms delay to simulate system delays in receiving serial
// data from the gps receiver
usleep(50 * 1000);
serial.AddData(gps_output);
}
}
double Simulator::timeSinceMs(struct timespec start)
{
struct timespec end;
clock_gettime(CLOCK_REALTIME, &end);
double diff = (double)(end.tv_sec - start.tv_sec) * 1.0e9 +
(double)(end.tv_nsec - start.tv_nsec);
return diff / 1.0e6;
}
void Simulator::checkForScreenResize()
{
int current_rows, current_cols;
getmaxyx(stdscr, current_rows, current_cols);
if ((current_rows != rows) || (current_cols != cols))
{
drawScreen();
}
}
void Simulator::turnOnColor(int color_pair_index)
{
if (has_colors())
{
attron(COLOR_PAIR(color_pair_index));
}
}
void Simulator::turnOffColor(int color_pair_index)
{
if (has_colors())
{
attroff(COLOR_PAIR(color_pair_index));
}
}
|
cac2c522fd4812d428a642f1e2e67b87fc42f1a3 | e162982fa4a413d89f96edd6dd07a3ec44432ba0 | /Baekjoon/2000/2623-음악프로그램.cpp | 0de6bd0192dfdf76fbd77cc0d2ad24ea0114a14a | [] | no_license | Bucoco/Baekjoon | 3a70b867a8577de62a1486187bda2b6e5ce77a9b | 055ff80540c8da3c8c395f72461c061f6d676969 | refs/heads/master | 2023-06-19T21:21:16.420591 | 2021-07-21T06:44:12 | 2021-07-21T06:44:12 | 349,312,541 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 866 | cpp | 2623-음악프로그램.cpp | #include <iostream>
#include <vector>
#include <queue>
using namespace std;
vector<vector<int>> v;
vector<int> indegree;
int main() {
cin.tie(0); cout.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
v.resize(n + 1);
indegree.resize(n + 1);
for (int i = 0; i < m; i++) {
int num;
cin >> num;
vector<int> temp(num);
for (auto &j:temp) {
cin >> j;
}
for (int j = 0; j < num - 1; j++) {
v[temp[j]].push_back(temp[j + 1]);
indegree[temp[j + 1]]++;
}
}
queue<int> q;
vector<int> ans;
for (int i = 1; i <= n; i++) {
if (!indegree[i])
q.push(i);
}
while (!q.empty()) {
int root = q.front();
q.pop();
for (int i : v[root]) {
indegree[i]--;
if (!indegree[i])
q.push(i);
}
ans.push_back(root);
}
if (ans.size() < n)
cout << 0;
else
for (int i : ans)
cout << i << '\n';
return 0;
} |
b78eb6d49f1a2f50d424c3d03eae1f8caca53313 | 9bc5d0818cd3b3f4faa2a3e26295bd277401434d | /Source/InversionFPS/References.h | 7f3c525a10f97a084267d86e4327f7aa6eb7fc98 | [] | no_license | VLauren/InversionFPS | cfdcf22babc73565b0f8234d1f4edd1d3c8ca2c0 | 5b291643e8476551ebc25539b2271eac7a56d595 | refs/heads/master | 2020-03-23T00:38:37.058091 | 2018-07-17T18:04:36 | 2018-07-17T18:04:36 | 140,875,998 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 711 | h | References.h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Runtime/Engine/Classes/Materials/Material.h"
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "References.generated.h"
UCLASS()
class INVERSIONFPS_API AReferences : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AReferences();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
static AReferences* Instance;
UPROPERTY(EditAnywhere)
UMaterial* MatWhite;
UPROPERTY(EditAnywhere)
UMaterial* MatBlack;
};
|
fe718c07a7fec45fcf2874e7f81a13cdb59140b2 | f40a9ea8fcc5cf34e132181aed9076978161dc45 | /mba/cpp/src/tms/ltms.cpp | 401fa9711874e3d1da4661e7a20f881d0ca133e6 | [] | no_license | azeroman/Livingstone-2 | 7cb7373e58457ab09f979a966eed2ae043285dee | c422a8264900860ff6255c676e254004766486ec | refs/heads/master | 2022-04-12T20:35:36.050943 | 2020-04-08T14:58:50 | 2020-04-08T14:58:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 30,126 | cpp | ltms.cpp | /***
*** See the file "mba/disclaimers-and-notices-L2.txt" for
*** information on usage and redistribution of this file,
*** and for a DISCLAIMER OF ALL WARRANTIES.
***/
// Implementation of an LTMS
// $Id: ltms.cpp,v 1.83 2004/01/28 23:31:54 lbrown Exp $
#include <tms/ltms.h>
// For testing timing
#include <time.h>
/***************************************************************************
Implementing the fringe.
We have two fringes, which is why we ferret it off to an inner class to
do this work.
***************************************************************************/
/**
* The fringe.
* We used to use a list, but removing an arbitrary element from the
* list was prohibitively expensive. The problem is that STL iterators
* become undefined when anything happens. We need the behaviour to be
* defined.
* This defines an almost-stack. Removing an arbitrary element is defined to
* pop the top element, and replace the arbitrary element with the former top
* one; thus the order is not necessarily LIFO.
*
* The macro INITIAL_FRINGE_SIZE is 10 by default; but can be set elsewhere
* (i.e. as a -D flag) to change it. It must be greater than zero.
*
* The macro DISABLE_DYNAMIC_MEMORY is not currently handled.
*/
#ifndef INITIAL_FRINGE_SIZE
# define INITIAL_FRINGE_SIZE 16
#endif
LTMS::Fringe::Fringe() : super(INITIAL_FRINGE_SIZE) { }
// Remove an arbitrary fringe Clause. The final element is a special case.
// Called by LTMS::Fringe::remove_destroying()
void LTMS::Fringe::remove(Clause *pClause) {
unsigned fringeIndex = pClause->get_fringe_index();
if (fringeIndex == size() - 1) {
pop();
} else {
super::remove(fringeIndex);
pClause->take_from_fringe();
// set the replacement's index
operator[] (fringeIndex)->set_in_fringe(fringeIndex);
}
}
// Remove all Clauses in the Fringe such that Clause::is_destroying() is true
// Called by LTMS::finish_destroying()
void LTMS::Fringe::remove_destroying() {
for (unsigned i = 0; i < size(); /* iterate only if we don't remove */) {
Clause* pClause = operator[](i);
if (pClause->is_destroying()) {
// Remove the Clause, not the index -- otherwise indices don't map
// correctly anymore
remove(pClause);
} else {
++i;
}
}
}
/***************************************************************************
Operations on the fringe.
***************************************************************************/
// If the Clause is not already in the Fringe, put it in
// Called by LTMS::add(), Ptheory::initialize(), LTMS::assign(),
// LTMS::unassign()
void LTMS::insert_into_fringe(Clause& clause) {
if (!clause.is_in_fringe()) {
if (clause.is_volatile()) { volatile_fringe.push(&clause); }
else { fringe.push(&clause); }
}
}
// If the Clause is in the Fringe, take it out
// Called by LTMS::remove(), LTMS::assign()
void LTMS::remove_from_fringe(Clause& clause) {
if (clause.is_in_fringe()) {
if (clause.is_volatile()) { volatile_fringe.remove(&clause); }
else { fringe.remove(&clause); }
}
}
// Get any Clause from the Fringe, trying non-volatile first
// Called ty LTMS::partial_propagate(), LTMS::propagate()
Clause* LTMS::get_fringe_clause() {
if (!fringe.empty()) { return fringe.pop(); }
else if (!volatile_fringe.empty()) { return volatile_fringe.pop(); }
else { return 0; }
}
/***************************************************************************
Operations on the list of unsatisfied clauses.
***************************************************************************/
// If clause is marked satisfied, mark it and put it into the unsatisfied set
// Called by LTMS::add(), LTMS::assign()
void
LTMS::insert_into_unsat(Clause& clause) {
if (!clause.is_unsatisfied()) {
unsatisfied.push(&clause);
clause.set_unsatisfied(true);
}
}
// If clause is marked unsatisfied, unmark it and take it out of the
// unsatisfied set
// Called by LTMS::remove(), LTMS::unassign()
void
LTMS::remove_from_unsat(Clause& clause) {
if (clause.is_unsatisfied()) {
for (UnsatType::iterator it = unsatisfied.begin();
it != unsatisfied.end(); ++it) {
Clause *pClause = *it;
if (pClause == &clause) {
unsatisfied.erase(it);
clause.set_unsatisfied(false);
return;
}
}
L2_throw(L2_not_found_error, ("clause not found in unsat list"));
}
}
/***************************************************************************
Add/remove a clause.
***************************************************************************/
// Undelete a deleted Clause
// Called by client
void
LTMS::add(Clause& clause) {
// Only a currently deleted Clause can be added. If it isn't already
// deleted, it is already in the theory, and nothing need be done.
if (clause.is_deleted()) {
// Put the Clause back into the theory. This sets Clause::is_deleted(),
// Clause::satisfying_prop, and Clause::num_unassigned
Ptheory::add(clause);
// It supports nothing yet
clause.set_supports(NULL);
// Not yet known to be unsatisfied
clause.set_unsatisfied(false);
// It should not be in the fringe at this point
L2_assert(!clause.is_in_fringe(),
L2_fatal_error,
("found deleted clause that was already in the fringe"));
// Put it in the fringe or unsatisfied set if applicable
if (clause.get_satisfying_prop() == NULL) {
// If it is a unit Clause, add it to the fringe
if (clause.get_unassigned_count() == 1) {
insert_into_fringe(clause);
// If it is completely assigned but there's no satisfying Proposition,
// then it's unsatisfied.
} else if (clause.get_unassigned_count() == 0) {
insert_into_unsat(clause);
}
}
}
}
// Delete an undeleted Clause
void
LTMS::remove(Clause& clause) {
if (!clause.is_deleted()) {
Ptheory::remove(clause);
// Make sure the Clause isn't left behind in either the fringe or the set
// of unsatisfied Clauses
if (clause.is_in_fringe()) { remove_from_fringe(clause); }
else if (clause.is_unsatisfied()) { remove_from_unsat(clause); }
else { // It is satisfied
Proposition* pSupportedProposition = clause.get_supports();
if (pSupportedProposition != NULL) {
// undo any propagations from the Clause
enqueue_for_undo(pSupportedProposition);
// It no longer supports anything
clause.set_supports(NULL);
undo_propagations();
}
}
}
}
/***************************************************************************
Permanently remove marked clauses and propositions.
***************************************************************************/
// Helper to remove Clauses from the unsatisfied list. Filters the parameter.
// Called by LTMS::finish_destroying()
static void remove_marked_from_array(Array<Clause*, false>& list) {
for (Array<Clause*, false>::iterator it = list.begin(); it != list.end(); ) {
Clause *pClause = *it;
if (pClause->is_destroying()) { list.erase(it); }
else { ++it; }
}
}
// After Clauses are marked for destruction, deallocate them
// Called by client
void
LTMS::finish_destroying() {
// remove Clauses marked as destroying from the fringe and unsatisfied list
fringe.remove_destroying();
volatile_fringe.remove_destroying();
remove_marked_from_array(unsatisfied);
// foreach marked clause
// if it supports something that isn't marked
// remove our support
// This is done in two steps because we need to call
// Ptheory::finish_destroying to remove the effect of the Clauses we're
// destroying, but since it deallocates the Clauses, we need to figure out
// what to remove the support from first.
// First step of `foreach marked clause': collect Propositions to unassign
for (clause_list::iterator it = begin_clauses(); it != end_clauses(); ++it) {
Clause *pClause = *it;
if (pClause->is_destroying()) {
Proposition *pSupportedProposition = pClause->get_supports();
if (pSupportedProposition != NULL &&
!pSupportedProposition->is_destroying()) {
enqueue_for_undo(pSupportedProposition);
}
}
}
// Remove Clauses and Propositions from the theory
Ptheory::finish_destroying();
// Second step of `foreach marked clause': unassign Propositions on the list
undo_propagations();
// All that probably put stuff on the fringe; fix it
propagate();
}
// Propagate until done or iterations reached, whichever comes first
// Called by client
bool
LTMS::partial_propagate(size_t iterations, bool &consistent) {
for (size_t iteration = 0; unsatisfied.empty() && iteration < iterations;
iteration++) {
Clause *pFringeClause = get_fringe_clause();
if (pFringeClause != NULL) {
// These are here rather than at the top to make it clearer that the out
// loop is stateless (the state is held in the LTMS) and we can split it
bool is_positive;
Proposition *pProposition =
pFringeClause->get_unassigned_literal(is_positive);
assign(*pProposition, is_positive, *pFringeClause);
} else {
// We have propagated through all the fringe clauses and satisfied them.
consistent = true;
return true;
}
}
if (!unsatisfied.empty()) { // We have encountered an unsatisfied clause
consistent = false;
return true;
} else { // unsatisfied.empty() && (iteration >= iterations)
// The user should not be paying any attention to consistent
// since finished (the return value) is false. We won't set it here.
return false;
}
}
// Propagate until done
// Called by client
bool
LTMS::propagate() {
while (unsatisfied.empty()) {
Clause *pFringeClause = get_fringe_clause();
if (pFringeClause != NULL) {
bool is_positive;
Proposition *pProposition =
pFringeClause->get_unassigned_literal(is_positive);
assign(*pProposition, is_positive, *pFringeClause);
// Move this into assign.
pFringeClause->set_supports(pProposition);
} else {
// We have propagated through all of the fringe Clauses & satisfied them
return true;
}
}
// We have encountered an unsatisfied Clause
return false;
}
// Return all ancestor Clauses satisfying the predicate.
// Auxiliary to LTMS::last_conflict()
void
LTMS::get_clause_support(Clause& clause,
Clause::ListOfClause& result,
bool (*predicate)(const Clause&))
{
// Start at 16 since we often will need at least that many
Array<Clause*, false> stack(16);
// In case time_stamp is incremented until overflow, start from the beginning
if (time_stamp == Clause::MAX_TIME_STAMP) {
initialize_time_stamps();
}
// Starting a new cohort. No Clause should now have this time stamp.
++time_stamp;
// Initialize the stack with the input Clause
stack.push(&clause);
do {
// The next Clause to examine
Clause *pCurrentClause = stack.pop();
// For each Proposition in each Clause, collect its support
for (Clause::iterator it = pCurrentClause->begin();
it != pCurrentClause->end(); ++it) {
Proposition* pProposition = *it;
Clause* pParentClause = pProposition->get_supported_by();
#ifdef LTMS_DEBUG
if (pParentClause == NULL) {
_STD_ cerr << "PARENTLESS PROP IS " << *pProposition << _STD_ endl
<< "pCurrentClause is " << *pCurrentClause << _STD_ endl
<< "clause is " << clause << _STD_ endl
<< _STD_ flush;
}
#endif
L2_assert(pParentClause,
L2_fatal_error,
("unsupported clause was supporting something"));
// Don't add the Proposition's supporting Clause to the stack of Clauses
// to be processed if it is the Clause we are already processing or if
// the supporting Clause has already been visited because it supports
// another Proposition.
if ((pParentClause != pCurrentClause) &&
(pParentClause->get_time_stamp() != time_stamp)) {
// Mark it as having been visited in this cohort
pParentClause->set_time_stamp(time_stamp);
// Note that we keep tracing back until we hit a Clause for which the
// predicate holds. We do not add the support for the Clause that
// satisfied the predicate, nor do any Clauses that don't satisfy the
// predicate appear in the result.
#ifdef LTMS_DEBUG
_STD_ cerr << "Support clause is " << (*pParentClause) << _STD_ endl;
#endif
if (predicate(*pParentClause)) {
// It passes the filter; return it
result.push_front(pParentClause);
} else {
// It doesn't pass the filter; keep looking
stack.push(pParentClause);
}
} // end if
} // end for
} while (!stack.empty());
}
void LTMS::initialize() {
Ptheory::initialize();
// Clear containers
fringe.erase();
volatile_fringe.erase();
unsatisfied.erase();
undo_list.erase();
// Put all unit Clauses into the fringe
for (clause_list::iterator it = begin_clauses();
it != end_clauses(); it++) {
Clause* pClause = *it;
if (pClause->get_unassigned_count() == 1) {
insert_into_fringe(*pClause);
}
}
}
void LTMS::assignUpdateSameSense(const Proposition& proposition,
bool becomingTrue) {
Proposition::iterator it =
becomingTrue ? proposition.begin_positive() : proposition.begin_negative();
Proposition::iterator it_end =
becomingTrue ? proposition.end_positive() : proposition.end_negative();
for (; it != it_end; ++it) {
Clause *pClause = *it;
if (!pClause->is_deleted()) {
// One of its Propositions is being assigned
pClause->decr_num_unassigned();
// If it wasn't already satisfied, now it is
if (pClause->get_satisfying_prop() == NULL) {
pClause->set_satisfying_prop(&proposition);
// Now that it is satisfied, it can't be in the fringe
if (pClause->is_in_fringe()) {
remove_from_fringe(*pClause);
}
}
}
}
}
void LTMS::assignUpdateOppositeSense(const Proposition& proposition,
bool becomingTrue) {
Proposition::iterator it =
becomingTrue ? proposition.begin_negative() : proposition.begin_positive();
Proposition::iterator it_end =
becomingTrue ? proposition.end_negative() : proposition.end_positive();
for (; it != it_end; ++it) {
Clause *pClause = *it;
if (!pClause->is_deleted()) {
// One fewer unassigned Proposition
pClause->decr_num_unassigned();
if (pClause->get_satisfying_prop() == NULL) {
// The Clause was not satisfied
if (pClause->is_in_fringe()) {
// The number of unassigned literals was 1 but now must be 0
remove_from_fringe(*pClause);
// All its literals are assigned but it is not satisfied
insert_into_unsat(*pClause);
} else if (pClause->get_unassigned_count() == 1) {
// It has one unassigned literal and it is not satisfied: fringe
insert_into_fringe(*pClause);
}
}
}
}
}
// Now that Proposition has a truth assignment, we need to update all of the
// Clauses in which it appears. If the Clause contains the Proposition with
// the same truth value as becomingTrue, then Proposition is the satisfying
// Proposition for the Clause, if it doesn't already have one.
//
// If the Clause contains the Proposition with the opposite truth value, then
// the Proposition does not satisfy the Clause. In addition, if the Clause
// was in the fringe (that is, wasn't satisfied and had only one unassigned
// Proposition left, the one we just assigned to the wrong sign) it is now
// screwed. The Clause will be added to the unsatisfied Propositions of the
// theory.
// If becomingTrue is true, then the Positive Clauses are satisfied.
// Otherwise the negative Clauses are satisfied.
// Called by LTMS::move_support()
void
LTMS::assign(Proposition& proposition, bool becomingTrue, Clause& clause) {
proposition.set_value((becomingTrue ?
Proposition::PTRUE :
Proposition::PFALSE));
proposition.set_supported_by(&clause);
assignUpdateSameSense(proposition, becomingTrue);
assignUpdateOppositeSense(proposition, becomingTrue);
}
/***************************************************************************
Unassigning propositions.
***************************************************************************/
// Called by LTMS::remove(), LTMS::finish_destroying(), LTMS::unassign()
void
LTMS::enqueue_for_undo(Proposition *pProposition) {
undo_list.push(pProposition);
}
// Unassign each Proposition whose Clause had been removed
// Called by LTMS::remove(), LTMS::finish_destroying(), LTMS::move_support()
void
LTMS::undo_propagations() {
while (!undo_list.empty()) {
Proposition *pProposition = undo_list.pop();
unassign(*pProposition); // this may add more to undo_list
}
}
void LTMS::unassignUpdateSameSense(const Proposition& proposition,
bool wasTrue) {
Proposition::iterator it =
wasTrue ? proposition.begin_positive() : proposition.begin_negative();
Proposition::iterator it_end =
wasTrue ? proposition.end_positive() : proposition.end_negative();
for (; it != it_end; ++it) {
Clause *pClause = *it;
if (!pClause->is_deleted()) {
// One more literal is unassigned
pClause->incr_num_unassigned();
if (pClause->get_satisfying_prop() == &proposition) {
// The Proposition being unassigned used to satisfy it
const Proposition* pSatisfyingProposition =
pClause->find_satisfying_prop();
// Update the satisfying Proposition now that we know it
pClause->set_satisfying_prop(pSatisfyingProposition);
if (pSatisfyingProposition == NULL) {
// There is no other literal that satisfies the Clause
if (pClause->get_unassigned_count() == 1) {
// One unassigned literal and unsatisfied: fringe
insert_into_fringe(*pClause);
}
}
}
}
}
}
void LTMS::unassignUpdateOppositeSense(const Proposition& proposition,
bool wasTrue) {
Proposition::iterator it =
wasTrue ? proposition.begin_negative() : proposition.begin_positive();
Proposition::iterator it_end =
wasTrue ? proposition.end_negative() : proposition.end_positive();
for (; it != it_end; ++it) {
Clause *pClause = *it;
if (!pClause->is_deleted()) {
pClause->incr_num_unassigned();
if (pClause->is_unsatisfied()) {
// A hitherto unsatisfied Clause is no longer known to be unsatisfied
remove_from_unsat(*pClause);
insert_into_fringe(*pClause);
} else if (pClause->is_in_fringe()) {
// A hitherto fringe Clause is no longer fringe
remove_from_fringe(*pClause);
} else {
// A hitherto supported Clause is no longer supported
Proposition* pSupportedProposition = pClause->get_supports();
if (pSupportedProposition != NULL) {
enqueue_for_undo(pSupportedProposition);
pClause->set_supports(NULL);
}
}
}
}
}
// Unassigning a Proposition's truth value involves the following:
// o resetting the Proposition's truth value to UNKNOWN
// o updating the support and unassigned literal counts of all
// Clauses that it occurs in, and making sure that the update on the
// Clauses correctly updates the fringe and the unsatisfied Clauses
// o undoing the propagations from any Clauses that did unit propagations
// based on the truth value of this Proposition.
// Called by LTMS::undo_propagations(), LTMS::move_support()
void
LTMS::unassign(Proposition& proposition)
{
if (proposition.isUnknown()) {
// Integrity test
L2_assert(!proposition.get_supported_by(),
L2_fatal_error,
("prop has unknown value but is supported"));
// Nothing further to do
return;
} else {
bool wasTrue = proposition.isTrue();
proposition.initialize();
unassignUpdateSameSense(proposition, wasTrue);
unassignUpdateOppositeSense(proposition, wasTrue);
}
}
#ifdef LTMS_DEBUG
/**
* Send to _STD_ cerr the address of the chosen unsatisfied Clause and the
* pointers in the set of unsatisfied Clauses. The unsatisfield Clause should
* be the first element of the set.
* Debugging only
* Auxiliary to LTMS::last_conflict()
* \param pUnsatisfiedClause pointer the the first element of unsat
* \param unsatisfiedClauseSet
*/
static void
last_conflict_debug1(Clause *pUnsatisfiedClause,
Array<Clause *, false>& unsatisfiedClauseSet) {
_STD_ cout << "Unsatisfied clause is " << pUnsatisfiedClause << _STD_ endl;
_STD_ cout << _STD_ endl << " When checking conflict UNSAT is: "
<< _STD_ endl;
for (Array<Clause*, false>::iterator it = unsatisfiedClauseSet.begin();
it != unsatisfiedClauseSet.end(); ++it) {
Clause *pClause = *it;
_STD_ cout << " " << pClause << _STD_ endl;
}
_STD_ cout << _STD_ endl;
}
/**
* Send to _STD_ cerr the addresses of the elements of the Clause list.
* Debugging only
* Auxiliary to LTMS::last_conflict()
* \param conflict a list of Clauses
*/
static void last_conflict_debug2(Clause::ListOfClause& conflict) {
_STD_ cerr << "Conflict is " << _STD_ endl;
for (Clause::ListOfClause::iterator it = conflict.begin();
it != conflict.end(); ++it) {
Clause *pClause = *it;
_STD_ cerr << pClause << " ";
}
_STD_ cerr << _STD_ endl;
}
#endif
// Called by client
void
LTMS::last_conflict(Clause::ListOfClause& conflicts,
bool (*predicate)(const Clause&)) {
if (unsatisfied.empty()) {
// The theory is consistent, so there is no conflict; leave conflicts empty
return;
} else {
// The theory is inconsistent, so there is a conflict.
// If the model is well formed, all unsatisfied Clauses will be suitable.
// We will trace the inconsistency causing the first unsatisfied Clause.
Clause *pUnsatisfiedClause = unsatisfied[0];
#ifdef LTMS_DEBUG
last_conflict_debug1(pUnsatisfiedClause, unsatisfied);
#endif
// If the Clause is unsatisfied, that means that propagation attempted to
// propagate an Assignment to a Proposition through the Clause, and the
// Clause required a different value for that Proposition.
// Suppose we have the Clause (A or B) and we have propagated a false truth
// value for A. If we then attempt to propagate a false truth value to B,
// then the Clause is unsatisfied, and its support is left as Proposition B.
// We then want an explanation, in terms of Clauses that satisfy predicate,
// of what is supporting the conflicting truth values.
// If the unsatisfied Clause itself satisfies the predicate, then it is part
// of the explanation of the conflict, since it is placing one constraint
// on "B" (using the above example).
if (predicate(*pUnsatisfiedClause)) {
conflicts.push_front(pUnsatisfiedClause);
}
// The support for the unsatisfied Clause represents the propagation that
// had been done to deliver the conflicting "B" value into the unsatified
// Clause. That represents the remainder of the explaination.
get_clause_support(*pUnsatisfiedClause, conflicts, predicate);
#ifdef LTMS_DEBUG
last_conflict_debug2(conflicts);
#endif
}
}
#ifdef LTMS_DEBUG
// Debugging only
// Called by LTMS::move_support()
static void move_support_debug1(Proposition* pOldProposition,
Clause::ListOfClause& trans_clauses,
Proposition* pNewProposition) {
_STD_ cerr << "Moving support from "
<< *pOldProposition
<< " to " << *pNewProposition
<< _STD_ endl;
_STD_ cerr << "Clauses are " << _STD_ endl;
for (Clause::ListOfClause::iterator it = trans_clauses.begin();
it != trans_clauses.end(); ++it) {
Clause* pClause = *it;
_STD_ cerr << " " << pClause << _STD_ endl;
}
}
// Debugging only
// Called by LTMS::move_support()
static void move_support_debug2(Proposition* pOldProposition,
Clause::ListOfClause& trans_clauses,
Proposition* pNewProposition) {
_STD_ cerr << "Moved support from "
<< *pOldProposition
<< " to "
<< *pNewProposition
<< _STD_ endl;
_STD_ cerr << "Clauses are now" << _STD_ endl;
for (Clause::ListOfClause::iterator it = trans_clauses.begin();
it != trans_clauses.end(); ++it) {
Clause* pClause = *it;
_STD_ cerr << " " << pClause << _STD_ endl;
}
_STD_ cerr << _STD_ endl;
}
#endif
/**
* \TODO Since pOldProposition should appear in the Clause exactly once, it
* should be possible to stop iterating as soon as it is found. In fact, there
* can be only one loop, over all literals. When the literals match, it should
* be possible to determine from the index whether it is a positive or negative
* literal.
*/
void LTMS::transfer_clauses(Proposition* pOldProposition,
Proposition* pNewProposition,
Clause::ListOfClause& transferredClauses,
bool losing_assignment) {
// For each Clause in the list of Clauses
for (Clause::ListOfClause::iterator it = transferredClauses.begin();
it != transferredClauses.end(); ++it) {
Clause* pClause = *it;
// Move every occurrence of the Proposition in the Clause's positive
// literals. Let the Propositions know that the Clauses they appear in have
// changed.
// Contrary to appearances, positive_props is an array of Proposition*
Clause::iterator positive_props = pClause->begin_positive();
// For each positive literal of the Clause being transferred
for (int i = 0; i < pClause->number_of_positive_literals(); ++i) {
if (positive_props[i] == pOldProposition) {
positive_props[i] = pNewProposition;
pNewProposition->add_positive(pClause);
pOldProposition->remove_positive(pClause);
if (losing_assignment) { pClause->incr_num_unassigned(); }
}
}
// Move every occurrence of the Proposition in the Clause's negative
// literals. Let the Propositions know that the Clauses they appear in have
// changed.
// Contrary to appearances, negative_props is an array of Proposition*
Clause::iterator negative_props = pClause->begin_negative();
// For each negative literal of the Clause being transferred
for (int ii = 0; ii < pClause->number_of_negative_literals(); ++ii) {
if (negative_props[ii] == pOldProposition) {
negative_props[ii] = pNewProposition;
pNewProposition->add_negative(pClause);
pOldProposition->remove_negative(pClause);
if (losing_assignment) { pClause->incr_num_unassigned(); }
}
}
// If the moved Clause was satisfied by the old Propsition, now it is
// satisfied by the new Proposition.
if (pClause->get_satisfying_prop() == pOldProposition) {
pClause->set_satisfying_prop(pNewProposition);
}
}
}
/*
* There are 3 cases:
* (1) pOldProposition is not supported: simply transfer the Clauses
* (2) pOldProposition is supported by a Clause not in transferredClauses:
* transfer the Clauses but adjust the assignment count
* (3) pOldProposition is supported by a Clause in transferredClauses:
* assign newProposition, transfer the Clauses, unassign oldProposition,
* undo propagations
*/
void
LTMS::move_support(Proposition* pOldProposition,
Clause::ListOfClause& transferredClauses,
Proposition* pNewProposition) {
#ifdef LTMS_DEBUG
move_support_debug1(pOldProposition, transferredClauses, pNewProposition);
#endif
Clause *pSupportingClause = pOldProposition->get_supported_by();
if (pSupportingClause == NULL) {
// Just transfer the Clauses; no problem with support
transfer_clauses(pOldProposition, pNewProposition, transferredClauses,
false);
} else if (!transferredClauses.contains(pSupportingClause)) {
// If pOldProposition is supported by some other Clause than the ones we are
// moving, pNewProposition will not yet have support. In this case, the
// Clauses that swap pNewProposition for pOldProposition will lose one
// Assignment.
// If pOldProposition is supported but we cannot move that support to
// pNewProposition because it's not in the Clauses we are moving, we have
// lost the Assignment. We'll have to adjust the unassigned literal counts
// of all Clauses that swap pNewProposition for pOldProposition.
transfer_clauses(pOldProposition, pNewProposition, transferredClauses,
true);
} else {
#ifdef LTMS_DEBUG
_STD_ cerr << "Supporting transition clause moved " << _STD_ endl;
#endif
// If pOldProposition was constrained to a value by the transition Clauses,
// we want pNewProposition to take on its value and support. Otherwise,
// pNewProposition is not yet assigned. This will be important when we swap
// pNewProposition for pOldProposition.
// Assign pNewProposition while it is pointing only to Clauses in its time
// step (e.g., its domain constraints).
// For all of the Clauses across time steps, we will copy the support from
// pOldProposition to pNewProposition. We want to make this Assignment
// first so we do not mangle the existing support on the time step
// Clauses.
assign(*pNewProposition, !pOldProposition->isFalse(), *pSupportingClause);
transfer_clauses(pOldProposition, pNewProposition, transferredClauses,
false);
// We have now removed all of the time-step-related Clauses from
// pOldProposition and put them onto pNewProposition. If pOldProposition
// had a value and supporting Clause, then we'll want to unassign it. We can
// do that at the end so we do not disturb any of the propagations involving
// the time-step Clauses.
// As in the use of assign() above, do we want to put in the correct
// manipulations of the TMS here so we do not end up doing extra work?
unassign(*pOldProposition);
// We will have to call undo_propagations() before propagating to ensure we
// have undone all of the propagation that pOldProposition was supporting.
// Since we are going to call move_support() a great many times, we might
// want to call the undo_propagations() that cleans up after the unassigns
// just once. I haven't investigated whether it saves anything. JAK.
undo_propagations();
}
#ifdef LTMS_DEBUG
move_support_debug2(pOldProposition, transferredClauses, pNewProposition);
#endif
}
|
15626f6f56a3d898ef4370dba3559cdeef4cfedf | 1f902e98de99596e36ba017ce3907828b99a3c1f | /libs/hwui/SkiaCanvas.h | 715007cdcd3b161d44a39a131db5bbd91aa238e5 | [
"Apache-2.0",
"LicenseRef-scancode-unicode"
] | permissive | aosp-mirror/platform_frameworks_base | c98112233373c83586fb1bf4d7ac256e5521b11d | 942d47b019852409865ee53a189b09cc0743dff1 | refs/heads/main | 2023-08-29T10:34:14.756209 | 2023-08-29T07:02:44 | 2023-08-29T07:02:44 | 65,885 | 4,479 | 2,590 | NOASSERTION | 2023-08-08T07:25:50 | 2008-10-21T18:20:37 | Java | UTF-8 | C++ | false | false | 10,373 | h | SkiaCanvas.h | /*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "CanvasProperty.h"
#ifdef __ANDROID__ // Layoutlib does not support hardware acceleration
#include "DeferredLayerUpdater.h"
#endif
#include "RenderNode.h"
#include "VectorDrawable.h"
#include "hwui/Canvas.h"
#include "hwui/Paint.h"
#include "hwui/BlurDrawLooper.h"
#include <SkCanvas.h>
#include <SkDeque.h>
#include "pipeline/skia/AnimatedDrawables.h"
#include "src/core/SkArenaAlloc.h"
#include <cassert>
#include <optional>
namespace android {
// Holds an SkCanvas reference plus additional native data.
class SkiaCanvas : public Canvas {
public:
explicit SkiaCanvas(const SkBitmap& bitmap);
/**
* Create a new SkiaCanvas.
*
* @param canvas SkCanvas to handle calls made to this SkiaCanvas. Must
* not be NULL. This constructor does not take ownership, so the caller
* must guarantee that it remains valid while the SkiaCanvas is valid.
*/
explicit SkiaCanvas(SkCanvas* canvas);
virtual ~SkiaCanvas();
virtual void resetRecording(int width, int height,
uirenderer::RenderNode* renderNode) override {
LOG_ALWAYS_FATAL("SkiaCanvas cannot be reset as a recording canvas");
}
virtual void finishRecording(uirenderer::RenderNode*) override {
LOG_ALWAYS_FATAL("SkiaCanvas does not produce a DisplayList");
}
virtual void enableZ(bool enableZ) override {
LOG_ALWAYS_FATAL("SkiaCanvas does not support enableZ");
}
virtual void punchHole(const SkRRect& rect) override;
virtual void setBitmap(const SkBitmap& bitmap) override;
virtual bool isOpaque() override;
virtual int width() override;
virtual int height() override;
virtual int getSaveCount() const override;
virtual int save(SaveFlags::Flags flags) override;
virtual void restore() override;
virtual void restoreToCount(int saveCount) override;
virtual void restoreUnclippedLayer(int saveCount, const Paint& paint) override;
virtual int saveLayer(float left, float top, float right, float bottom, const SkPaint* paint) override;
virtual int saveLayerAlpha(float left, float top, float right, float bottom, int alpha) override;
virtual int saveUnclippedLayer(int left, int top, int right, int bottom) override;
virtual void getMatrix(SkMatrix* outMatrix) const override;
virtual void setMatrix(const SkMatrix& matrix) override;
virtual void concat(const SkMatrix& matrix) override;
virtual void rotate(float degrees) override;
virtual void scale(float sx, float sy) override;
virtual void skew(float sx, float sy) override;
virtual void translate(float dx, float dy) override;
virtual bool getClipBounds(SkRect* outRect) const override;
virtual bool quickRejectRect(float left, float top, float right, float bottom) const override;
virtual bool quickRejectPath(const SkPath& path) const override;
virtual bool clipRect(float left, float top, float right, float bottom, SkClipOp op) override;
virtual bool clipPath(const SkPath* path, SkClipOp op) override;
virtual bool replaceClipRect_deprecated(float left, float top, float right,
float bottom) override;
virtual bool replaceClipPath_deprecated(const SkPath* path) override;
virtual PaintFilter* getPaintFilter() override;
virtual void setPaintFilter(sk_sp<PaintFilter> paintFilter) override;
virtual SkCanvasState* captureCanvasState() const override;
virtual void drawColor(int color, SkBlendMode mode) override;
virtual void drawPaint(const Paint& paint) override;
virtual void drawPoint(float x, float y, const Paint& paint) override;
virtual void drawPoints(const float* points, int count, const Paint& paint) override;
virtual void drawLine(float startX, float startY, float stopX, float stopY,
const Paint& paint) override;
virtual void drawLines(const float* points, int count, const Paint& paint) override;
virtual void drawRect(float left, float top, float right, float bottom,
const Paint& paint) override;
virtual void drawRegion(const SkRegion& region, const Paint& paint) override;
virtual void drawRoundRect(float left, float top, float right, float bottom, float rx, float ry,
const Paint& paint) override;
virtual void drawDoubleRoundRect(const SkRRect& outer, const SkRRect& inner,
const Paint& paint) override;
virtual void drawCircle(float x, float y, float radius, const Paint& paint) override;
virtual void drawOval(float left, float top, float right, float bottom,
const Paint& paint) override;
virtual void drawArc(float left, float top, float right, float bottom, float startAngle,
float sweepAngle, bool useCenter, const Paint& paint) override;
virtual void drawPath(const SkPath& path, const Paint& paint) override;
virtual void drawVertices(const SkVertices*, SkBlendMode, const Paint& paint) override;
virtual void drawBitmap(Bitmap& bitmap, float left, float top, const Paint* paint) override;
virtual void drawBitmap(Bitmap& bitmap, const SkMatrix& matrix, const Paint* paint) override;
virtual void drawBitmap(Bitmap& bitmap, float srcLeft, float srcTop, float srcRight,
float srcBottom, float dstLeft, float dstTop, float dstRight,
float dstBottom, const Paint* paint) override;
virtual void drawBitmapMesh(Bitmap& bitmap, int meshWidth, int meshHeight,
const float* vertices, const int* colors,
const Paint* paint) override;
virtual void drawNinePatch(Bitmap& bitmap, const android::Res_png_9patch& chunk, float dstLeft,
float dstTop, float dstRight, float dstBottom,
const Paint* paint) override;
virtual double drawAnimatedImage(AnimatedImageDrawable* imgDrawable) override;
virtual void drawVectorDrawable(VectorDrawableRoot* vectorDrawable) override;
virtual void drawRoundRect(uirenderer::CanvasPropertyPrimitive* left,
uirenderer::CanvasPropertyPrimitive* top,
uirenderer::CanvasPropertyPrimitive* right,
uirenderer::CanvasPropertyPrimitive* bottom,
uirenderer::CanvasPropertyPrimitive* rx,
uirenderer::CanvasPropertyPrimitive* ry,
uirenderer::CanvasPropertyPaint* paint) override;
virtual void drawCircle(uirenderer::CanvasPropertyPrimitive* x,
uirenderer::CanvasPropertyPrimitive* y,
uirenderer::CanvasPropertyPrimitive* radius,
uirenderer::CanvasPropertyPaint* paint) override;
virtual void drawRipple(const uirenderer::skiapipeline::RippleDrawableParams& params) override;
virtual void drawLayer(uirenderer::DeferredLayerUpdater* layerHandle) override;
virtual void drawRenderNode(uirenderer::RenderNode* renderNode) override;
virtual void drawPicture(const SkPicture& picture) override;
protected:
SkiaCanvas();
SkCanvas* asSkCanvas() { return mCanvas; }
void reset(SkCanvas* skiaCanvas);
void drawDrawable(SkDrawable* drawable) { mCanvas->drawDrawable(drawable); }
virtual void drawGlyphs(ReadGlyphFunc glyphFunc, int count, const Paint& paint, float x,
float y, float totalAdvance) override;
virtual void drawLayoutOnPath(const minikin::Layout& layout, float hOffset, float vOffset,
const Paint& paint, const SkPath& path, size_t start,
size_t end) override;
void onFilterPaint(Paint& paint);
Paint filterPaint(const Paint& src) {
Paint dst(src);
this->onFilterPaint(dst);
return dst;
}
// proc(const SkPaint& modifiedPaint)
template <typename Proc>
void applyLooper(const Paint* paint, Proc proc, void (*preFilter)(SkPaint&) = nullptr) {
BlurDrawLooper* looper = paint ? paint->getLooper() : nullptr;
Paint pnt = paint ? *paint : Paint();
if (preFilter) {
preFilter(pnt);
}
this->onFilterPaint(pnt);
if (looper) {
looper->apply(pnt, [&](SkPoint offset, const Paint& modifiedPaint) {
mCanvas->save();
mCanvas->translate(offset.fX, offset.fY);
proc(modifiedPaint);
mCanvas->restore();
});
} else {
proc(pnt);
}
}
private:
struct SaveRec {
int saveCount;
SaveFlags::Flags saveFlags;
size_t clipIndex;
};
const SaveRec* currentSaveRec() const;
void recordPartialSave(SaveFlags::Flags flags);
template <typename T>
void recordClip(const T&, SkClipOp);
void applyPersistentClips(size_t clipStartIndex);
void drawPoints(const float* points, int count, const Paint& paint, SkCanvas::PointMode mode);
class Clip;
std::unique_ptr<SkCanvas> mCanvasOwned; // might own a canvas we allocated
SkCanvas* mCanvas; // we do NOT own this canvas, it must survive us
// unless it is the same as mCanvasOwned.get()
std::unique_ptr<SkDeque> mSaveStack; // lazily allocated, tracks partial saves.
std::vector<Clip> mClipStack; // tracks persistent clips.
sk_sp<PaintFilter> mPaintFilter;
};
} // namespace android
|
08e28e67c06d6c99ea159ea9d26553ace2fe4d3d | fafdf1e62cf622035ee82666ba6ae7108127d140 | /kynapse7/include/kypathdata/basesystem/coordsystem.inl | 9c8b13c006781d24f7b0fc5bf9eddffc5c75b4db | [] | no_license | saerich/RaiderZ-Evolved-SDK | 7f18942ddc6c566d47c3a6222c03fad7543738a4 | b576e6757b6a781a656be7ba31eb0cf5e8a23391 | refs/heads/master | 2023-02-12T03:21:26.442348 | 2020-08-30T15:39:54 | 2020-08-30T15:39:54 | 281,213,173 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 12,029 | inl | coordsystem.inl | /*
* Copyright 2010 Autodesk, Inc. All rights reserved.
* Use of this software is subject to the terms of the Autodesk license agreement provided at the time of installation or download,
* or which otherwise accompanies this software in either electronic or hard copy form.
*/
// primary contact: GUAL - secondary contact: MAMU
/*! \file
\ingroup kypathdata_basesystem */
namespace Kaim
{
namespace CoordSystem_Internal
{
inline void SetAxis(CoordSystem::ClientAxis axis, KyInt32& axisIdx, KyFloat32& axisSign)
{
axisIdx = axis / 2;
axisSign = (axis % 2) ? -1.0f : 1.0f;
}
inline CoordSystem::ClientAxis GetAxis(KyInt32 axisIdx, KyFloat32 axisSign)
{
if (axisSign > 0.0f) //axisSign is 1.f or -1.f
return (CoordSystem::ClientAxis)(axisIdx*2);
else
return (CoordSystem::ClientAxis)((axisIdx*2) + 1);
}
inline KyInt32 NearestInt(KyFloat32 x)
{
#if defined (KY_XBOX360) || defined (KY_PS3) || defined(KY_LINUX_ANY) || defined(__GCC__)
// JAPA - avoid aliasing issues. We still have a float->int here which is not ideal.
return (KyInt32)( x + Kaim::Fsel(x, 0.5f, -0.5f) );
#else
const KyFloat32 _0_5 = 0.5f;
KyInt32 offset = (0x80000000 & (KyUInt32&)x) | (KyUInt32&)_0_5;
return (KyInt32)(x + (KyFloat32&)offset);
#endif
}
}
void CoordSystem::Setup(
KyFloat32 oneMeterInClientUnits,
ClientAxis clientAxisForKynapseX,
ClientAxis clientAxisForKynapseY,
ClientAxis clientAxisForKynapseZ,
KyFloat32 integerPrecision)
{
SetOneMeterInClientUnits(oneMeterInClientUnits);
SetIntegerPrecision(integerPrecision);
SetClientAxisForKynapseX(clientAxisForKynapseX);
SetClientAxisForKynapseY(clientAxisForKynapseY);
SetClientAxisForKynapseZ(clientAxisForKynapseZ);
UpdateClientCoordMax();
}
void CoordSystem::Setup(const CoordSystemConfig& config)
{
Setup(
config.m_oneMeterInClientUnits,
(ClientAxis)config.m_clientAxisForKynapseX,
(ClientAxis)config.m_clientAxisForKynapseY,
(ClientAxis)config.m_clientAxisForKynapseZ,
config.m_integerPrecision);
}
void CoordSystem::SetOneMeterInClientUnits(KyFloat32 oneMeterInClientUnits)
{
m_oneMeter = oneMeterInClientUnits;
m_inv_oneMeter = 1.0f / oneMeterInClientUnits;
}
void CoordSystem::SetClientAxisForKynapseX(ClientAxis clientAxisForKynapseX) { CoordSystem_Internal::SetAxis(clientAxisForKynapseX, m_kynapseX_idx, m_kynapseX_sign); }
void CoordSystem::SetClientAxisForKynapseY(ClientAxis clientAxisForKynapseY) { CoordSystem_Internal::SetAxis(clientAxisForKynapseY, m_kynapseY_idx, m_kynapseY_sign); }
void CoordSystem::SetClientAxisForKynapseZ(ClientAxis clientAxisForKynapseZ) { CoordSystem_Internal::SetAxis(clientAxisForKynapseZ, m_kynapseZ_idx, m_kynapseZ_sign); }
CoordSystem::ClientAxis CoordSystem::GetClientAxisForKynapseX() { return CoordSystem_Internal::GetAxis(m_kynapseX_idx, m_kynapseX_sign); }
CoordSystem::ClientAxis CoordSystem::GetClientAxisForKynapseY() { return CoordSystem_Internal::GetAxis(m_kynapseY_idx, m_kynapseY_sign); }
CoordSystem::ClientAxis CoordSystem::GetClientAxisForKynapseZ() { return CoordSystem_Internal::GetAxis(m_kynapseZ_idx, m_kynapseZ_sign); }
void CoordSystem::SetIntegerPrecision(KyFloat32 precision)
{
m_integerPrecision = precision;
m_inv_integerPrecision = 1.0f / precision;
}
void CoordSystem::UpdateClientCoordMax()
{
m_clientCoordMax = IntToClient_Dist(KyInt32MAXVAL - 1); // inferior to 2**31;
}
// ------------------------------------ Client <-> Kynapse ------------------------------------
KyFloat32 CoordSystem::ClientToKynapse_Dist(KyFloat32 clientDist) const { return clientDist * m_inv_oneMeter; }
KyFloat32 CoordSystem::KynapseToClient_Dist(KyFloat32 kynapseDist) const { return kynapseDist * m_oneMeter; }
KyFloat32 CoordSystem::ClientToKynapse_SquareDist(KyFloat32 clientSquareDist) const { return clientSquareDist * m_inv_oneMeter * m_inv_oneMeter; }
KyFloat32 CoordSystem::KynapseToClient_SquareDist(KyFloat32 kynapseSquareDist) const { return kynapseSquareDist * m_oneMeter * m_oneMeter; }
void CoordSystem::ClientToKynapse_Pos(const Vec3f& clientPos, Vec3f& kynapsePos) const
{
kynapsePos.x = ClientToKynapse_Dist(m_kynapseX_sign * clientPos[m_kynapseX_idx]);
kynapsePos.y = ClientToKynapse_Dist(m_kynapseY_sign * clientPos[m_kynapseY_idx]);
kynapsePos.z = ClientToKynapse_Dist(m_kynapseZ_sign * clientPos[m_kynapseZ_idx]);
}
void CoordSystem::KynapseToClient_Pos(const Vec3f& kynapsePos, Vec3f& clientPos) const
{
clientPos[m_kynapseX_idx] = KynapseToClient_Dist(m_kynapseX_sign * kynapsePos.x);
clientPos[m_kynapseY_idx] = KynapseToClient_Dist(m_kynapseY_sign * kynapsePos.y);
clientPos[m_kynapseZ_idx] = KynapseToClient_Dist(m_kynapseZ_sign * kynapsePos.z);
}
Vec3f CoordSystem::ClientToKynapse_Pos(const Vec3f& clientPos) const
{
Vec3f kynapsePos;
ClientToKynapse_Pos(clientPos, kynapsePos);
return kynapsePos;
}
Vec3f CoordSystem::KynapseToClient_Pos(const Vec3f& kynapsePos) const
{
Vec3f clientPos;
KynapseToClient_Pos(kynapsePos, clientPos);
return clientPos;
}
void CoordSystem::ClientToKynapse_Normal(const Vec3f& clientNormal, Vec3f& kynapseNormal) const
{
kynapseNormal.x = m_kynapseX_sign * clientNormal[m_kynapseX_idx];
kynapseNormal.y = m_kynapseY_sign * clientNormal[m_kynapseY_idx];
kynapseNormal.z = m_kynapseZ_sign * clientNormal[m_kynapseZ_idx];
}
void CoordSystem::KynapseToClient_Normal(const Vec3f& kynapseNormal, Vec3f& clientNormal) const
{
clientNormal[m_kynapseX_idx] = m_kynapseX_sign * kynapseNormal.x;
clientNormal[m_kynapseY_idx] = m_kynapseY_sign * kynapseNormal.y;
clientNormal[m_kynapseZ_idx] = m_kynapseZ_sign * kynapseNormal.z;
}
Vec3f CoordSystem::ClientToKynapse_Normal(const Vec3f& clientNormal) const
{
Vec3f kynapseNormal;
ClientToKynapse_Normal(clientNormal, kynapseNormal);
return kynapseNormal;
}
Vec3f CoordSystem::KynapseToClient_Normal(const Vec3f& kynapseNormal) const
{
Vec3f clientNormal;
KynapseToClient_Normal(kynapseNormal, clientNormal);
return clientNormal;
}
void CoordSystem::ClientToKynapse_Box(const Vec3f& clientMin, const Vec3f& clientMax, Box3f& kyBox)
{
kyBox.Clear();
kyBox.ExpandByVec3(ClientToKynapse_Pos(clientMin));
kyBox.ExpandByVec3(ClientToKynapse_Pos(clientMax));
}
void CoordSystem::KynapseToClient_Box(const Box3f& kyBox, Vec3f& clientMin, Vec3f& clientMax)
{
Box3f clientBox;
clientBox.ExpandByVec3(KynapseToClient_Pos(kyBox.m_min));
clientBox.ExpandByVec3(KynapseToClient_Pos(kyBox.m_max));
clientMin = clientBox.m_min;
clientMax = clientBox.m_max;
}
// ------------------------------------ Client <-> Int ------------------------------------
KyInt32 CoordSystem::ClientToInt_Dist(KyFloat32 clientCoord) const { return CoordSystem_Internal::NearestInt(clientCoord * m_inv_oneMeter * m_inv_integerPrecision); }
KyFloat32 CoordSystem::IntToClient_Dist(KyInt32 intCoord) const { return intCoord * m_integerPrecision * m_oneMeter; }
void CoordSystem::ClientToInt_Pos(const Vec3f& clientPos, Vec3i& intPos) const
{
intPos.x = ClientToInt_Dist((KyInt32)m_kynapseX_sign * clientPos[m_kynapseX_idx]);
intPos.y = ClientToInt_Dist((KyInt32)m_kynapseY_sign * clientPos[m_kynapseY_idx]);
intPos.z = ClientToInt_Dist((KyInt32)m_kynapseZ_sign * clientPos[m_kynapseZ_idx]);
}
void CoordSystem::IntToClient_Pos(const Vec3i& intPos, Vec3f& clientPos) const
{
clientPos[m_kynapseX_idx] = IntToClient_Dist((KyInt32)m_kynapseX_sign * intPos.x);
clientPos[m_kynapseY_idx] = IntToClient_Dist((KyInt32)m_kynapseY_sign * intPos.y);
clientPos[m_kynapseZ_idx] = IntToClient_Dist((KyInt32)m_kynapseZ_sign * intPos.z);
}
// ------------------------------------ Kynapse <-> Int ------------------------------------
KyInt32 CoordSystem::KynapseToInt_Dist(KyFloat32 kynapseDist) const { return KynapseToInt_Dist(kynapseDist, m_inv_integerPrecision); }
KyFloat32 CoordSystem::IntToKynapse_Dist(KyInt32 intDist) const { return IntToKynapse_Dist(intDist, m_integerPrecision); }
void CoordSystem::KynapseToInt_Pos(const Vec3f& kynapsePos, Vec3i& intPos) const { return KynapseToInt_Pos(kynapsePos, intPos, m_inv_integerPrecision); }
void CoordSystem::IntToKynapse_Pos(const Vec3i& intPos, Vec3f& kynapsePos) const { return IntToKynapse_Pos(intPos, kynapsePos, m_integerPrecision); }
void CoordSystem::KynapseToInt_Pos(const Vec2f& kynapsePos, Vec2i& intPos) const { return KynapseToInt_Pos(kynapsePos, intPos, m_inv_integerPrecision); }
void CoordSystem::IntToKynapse_Pos(const Vec2i& intPos, Vec2f& kynapsePos) const { return IntToKynapse_Pos(intPos, kynapsePos, m_integerPrecision); }
// ----------------------- Kynapse <-> Int with custom integerPrecision --------------------------
KyInt32 CoordSystem::KynapseToInt_Dist(KyFloat32 kynapseDist, KyFloat32 inv_integerPrecision) { return CoordSystem_Internal::NearestInt(kynapseDist * inv_integerPrecision); }
KyFloat32 CoordSystem::IntToKynapse_Dist(KyInt32 intDist, KyFloat32 integerPrecision) { return intDist * integerPrecision; }
void CoordSystem::KynapseToInt_Pos(const Vec3f& kynapsePos, Vec3i& intPos, KyFloat32 inv_integerPrecision)
{
intPos.x = KynapseToInt_Dist(kynapsePos.x, inv_integerPrecision);
intPos.y = KynapseToInt_Dist(kynapsePos.y, inv_integerPrecision);
intPos.z = KynapseToInt_Dist(kynapsePos.z, inv_integerPrecision);
}
void CoordSystem::IntToKynapse_Pos(const Vec3i& intPos, Vec3f& kynapsePos, KyFloat32 integerPrecision)
{
kynapsePos.x = IntToKynapse_Dist(intPos.x, integerPrecision);
kynapsePos.y = IntToKynapse_Dist(intPos.y, integerPrecision);
kynapsePos.z = IntToKynapse_Dist(intPos.z, integerPrecision);
}
void CoordSystem::KynapseToInt_Pos(const Vec2f& kynapsePos, Vec2i& intPos, KyFloat32 inv_integerPrecision)
{
intPos.x = KynapseToInt_Dist(kynapsePos.x, inv_integerPrecision);
intPos.y = KynapseToInt_Dist(kynapsePos.y, inv_integerPrecision);
}
void CoordSystem::IntToKynapse_Pos(const Vec2i& intPos, Vec2f& kynapsePos, KyFloat32 integerPrecision )
{
kynapsePos.x = IntToKynapse_Dist(intPos.x, integerPrecision);
kynapsePos.y = IntToKynapse_Dist(intPos.y, integerPrecision);
}
void CoordSystem::Convert_Pos(Coordinates coordinates_in, const Vec3f& pos_in, Coordinates coordinates_out, Vec3f& pos_out)
{
KyUInt32 case_id = (KyUInt32)coordinates_in + (KyUInt32)coordinates_out * 2;
switch (case_id)
{
// in => out
case 0: pos_out = pos_in; break; // CLIENT => CLIENT
case 1: KynapseToClient_Pos(pos_in, pos_out); break; // KYNAPSE => CLIENT
case 2: ClientToKynapse_Pos(pos_in, pos_out); break; // CLIENT => KYNAPSE
case 3: pos_out = pos_in; break; // KYNAPSE => KYNAPSE
}
}
bool CoordSystem::IsInsideClientCoordBox(const Vec3f& clientPos) const
{
if (clientPos.x < m_clientCoordMax && clientPos.x > -m_clientCoordMax &&
clientPos.y < m_clientCoordMax && clientPos.y > -m_clientCoordMax &&
clientPos.z < m_clientCoordMax && clientPos.z > -m_clientCoordMax)
return true;
return false;
}
KyFloat32 CoordSystem::GetMaxEdgeLengthOfTriangle(const Vec3f& A, const Vec3f& B, const Vec3f& C) const
{
const Vec3f AB = B - A;
const Vec3f BC = C - B;
const Vec3f CA = A - C;
return Kaim::Max(AB.GetLength(), Kaim::Max(BC.GetLength(), CA.GetLength()));
}
bool CoordSystem::IsClientTriangleTooBig(const Vec3f& A, const Vec3f& B, const Vec3f& C) const
{
const KyFloat32 maxLength = IntToClient_Dist(KyInt32(sqrtf(KyFloat32(KyInt32MAXVAL))) - 1);
return GetMaxEdgeLengthOfTriangle(A, B, C) >= maxLength;
}
bool CoordSystem::operator==(const CoordSystem& other) const
{
return m_kynapseX_idx == other.m_kynapseX_idx && m_kynapseX_sign == other.m_kynapseX_sign
&& m_kynapseY_idx == other.m_kynapseY_idx && m_kynapseY_sign == other.m_kynapseY_sign
&& m_kynapseZ_idx == other.m_kynapseZ_idx && m_kynapseZ_sign == other.m_kynapseZ_sign
&& m_inv_integerPrecision == other.m_inv_integerPrecision
&& m_integerPrecision == other.m_integerPrecision
&& m_clientCoordMax == other.m_clientCoordMax
&& m_oneMeter == other.m_oneMeter;
}
bool CoordSystem::operator!=(const CoordSystem& other) const
{
return !operator==(other);
}
}
|
d504fd61fc865cc574668e6b17596a1e7744cf69 | 4afa229405961ea85fe18fdbdfa6700a141721bd | /vector.h | 0d958a00cc270c6e98b77b422b3f867e87732665 | [] | no_license | asuka1975/arms-model | b1b5fdada784e11bcc41a42f87c64a8e22264374 | a3749089bf9687c70c1d142e4422b8922d378ad0 | refs/heads/master | 2023-08-17T06:35:26.305012 | 2019-06-01T08:13:21 | 2019-06-01T08:13:21 | 189,688,006 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,037 | h | vector.h | #pragma once
#include <functional>
class vector {
public:
vector(unsigned int length);
vector(unsigned int lenght, double* arry);
vector(std::initializer_list<double> args);
vector(const vector& obj);
double& operator[](unsigned int idx);
const double operator[](unsigned int idx)const;
friend vector operator+(const vector& vec1, const vector& vec2);
friend vector operator-(const vector& vec1, const vector& vec2);
friend double operator*(const vector& vec1, const vector& vec2);
vector slice(unsigned int start, unsigned int len)const;
vector& operator=(const vector& obj);
friend std::ostream& operator<<(std::ostream& os, const vector& obj);
friend double summation(const vector& obj);
friend vector map(std::function<double(double)> func, const vector& obj);
friend vector map2(std::function<double(double, double)> func, const vector& left, const vector& right);
friend double foldr(std::function<double(double, double)> func, double g, const vector& obj);
private:
double* array;
const unsigned int length;
}; |
b7c74502c2368fc1712d654ba57cf5eddaaf4a1e | ceb020fee45a01645f0b2adc118483c6cf296226 | /ImageSmoother.cpp | 69fd267e30d8a98efbcb2211b9f1ea41a764864a | [] | no_license | anaypaul/LeetCode | 6423c4ca1b0d147206c06ebb86c9e558a85077f2 | 667825d32df2499301184d486e3a674291c0ca0b | refs/heads/master | 2021-09-28T06:05:21.256702 | 2020-10-12T04:01:46 | 2020-10-12T04:01:46 | 153,226,092 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 884 | cpp | ImageSmoother.cpp | class Solution {
public:
vector<vector<int>> imageSmoother(vector<vector<int>>& M) {
int n = M.size();
int m = M[0].size();
int dx[9] = {-1,-1,-1,0,0,0,1,1,1};
int dy[9] = {-1,0,1,-1,0,1,-1,0,1};
vector<vector<int>> res(M.size(), vector<int>(M[0].size(), 0));
for(int i = 0;i<M.size();i++){
for(int j = 0;j<M[0].size();j++){
int sum = 0;
int count = 0;
for(int idx = 0;idx<9;idx++){
int index_x = i + dx[idx];
int index_y = j + dy[idx];
if((index_x>=0 &&index_x<n) && (index_y>=0 && index_y<m)){
sum += M[index_x][index_y];
count++;
}
}
res[i][j] = sum/count;
}
}
return res;
}
}; |
1a061cbb9e6e77b6da7abf26dc2c1ac9ce222fc4 | ce3464c13488542b5d9142655e04365f386faaae | /Arduino Code/libraries/Ultrasonic/uninterruptedUltrasound.ino | e3daf50d7524a99cc5c0fea6d0c1eda4461aa29c | [] | no_license | hypermadman/UBRobotics | da1a923def8c0be25cfbf1de46fcdb87e3f947c1 | ee4ad9671cba29781eab89946c4a48c5d77d7a82 | refs/heads/master | 2021-01-11T14:37:05.070910 | 2017-01-12T21:01:51 | 2017-01-12T21:01:51 | 80,172,134 | 1 | 0 | null | 2017-01-27T01:23:34 | 2017-01-27T01:23:34 | null | UTF-8 | C++ | false | false | 1,196 | ino | uninterruptedUltrasound.ino | // Written by Ed Chamberlain for UBRobotics
// 01/04/16
const int trigPin = 4;
const int echoPin = 2; // must be inturrupt enabled
const int maxRange = 50; // (cm)
long unsigned int startTime;
void setup() {
// init serial
Serial.begin(9600);
// init pin modes
pinMode(echoPin, INPUT);
pinMode(trigPin, OUTPUT);
// Set ISR
attachInterrupt(digitalPinToInterrupt(echoPin), isr, FALLING);
}
void loop()
{
//send ping command
ping();
//delay for stability
delay(10);
}
void isr() { //ISR
//declare variables
double duration;
double distance;
// Calculate duration since pulse was emmited
duration = micros() - startTime;
// Convert the time into a distance (-10 for calibration)
distance = (duration / 29 / 2) - 10;
if (distance > maxRange) {
// outlier catching / out of range refusal
Serial.println("ERROR: OUT OF RANGE");
} else {
if (1 == 1) { // use this if for error catching
// result processing
Serial.println(distance);
}
}
}
void ping() {
//send activation pulse
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// record ping emmit time
startTime = micros();
}
|
2116ea7049ba363a9c9ba8430fbd5982a06cd98b | ca57d57bec37faeb57899a80df5b4d267a536ac5 | /test/script/name_mangler_test.cpp | 922bfad708083c97622f07852a9851050d9a54b2 | [
"BSD-3-Clause"
] | permissive | fuersten/sun_ray | ed875b2a5a2c0f9fd8bfb7321921b1b70c205a3a | b882d67cd9747f61b50def4c1414e7552ba917c0 | refs/heads/main | 2023-04-17T04:08:18.860499 | 2021-04-27T10:15:50 | 2021-04-27T10:15:50 | 335,270,596 | 2 | 0 | BSD-3-Clause | 2021-04-27T10:03:57 | 2021-02-02T11:46:17 | C++ | UTF-8 | C++ | false | false | 1,903 | cpp | name_mangler_test.cpp | //
// name_mangler_test.cpp
// sun_ray_test
//
// Created by Lars-Christian Fürstenberg on 04.02.20.
// Copyright © 2020 Lars-Christian Fürstenberg. All rights reserved.
//
#include <sun_ray/script/name_mangler.h>
#include <sstream>
#include <catch2/catch.hpp>
TEST_CASE("mangle", "[name mangler]")
{
SECTION("simple")
{
CHECK(sunray::script::NameMangler::mangle("println") == "_SR7println");
}
SECTION("function with parameter")
{
CHECK(sunray::script::NameMangler::mangle("other-func", 2) == "_SR10other-func2");
CHECK(sunray::script::NameMangler::mangle("my-func", 6) == "_SR7my-func6");
}
}
TEST_CASE("demangle", "[name mangler]")
{
SECTION("simple")
{
CHECK(sunray::script::NameMangler::demangle("_SR7println") == "println");
CHECK(sunray::script::NameMangler::demangle("_SR10other-func") == "other-func");
}
SECTION("function with parameter")
{
CHECK(sunray::script::NameMangler::demangle("_SR10other-func2") == "other-func");
CHECK(sunray::script::NameMangler::demangle("_SR7my-func6") == "my-func");
}
}
TEST_CASE("mangle error", "[name mangler]")
{
SECTION("empty name")
{
CHECK_THROWS_WITH(sunray::script::NameMangler::mangle(""), "cannot mangle empty name");
}
}
TEST_CASE("demangle error", "[name mangler]")
{
SECTION("unmangeled name")
{
CHECK_THROWS_WITH(sunray::script::NameMangler::demangle("println"), "'println' is not a mangeled name");
CHECK_THROWS_WITH(sunray::script::NameMangler::demangle("_EP7println"), "'_EP7println' is not a mangeled name");
CHECK_THROWS_WITH(sunray::script::NameMangler::demangle("_SR736"), "'_SR736' is not a mangeled name");
CHECK_THROWS_WITH(sunray::script::NameMangler::demangle("_SR0println"), "'_SR0println' is not a mangeled name");
CHECK_THROWS_WITH(sunray::script::NameMangler::demangle("_SRprintln"), "'_SRprintln' is not a mangeled name");
}
}
|
84970681cc714e6bc67f50b2bb766b6b1a85dc79 | 62baa5e499b90554cc142075179b612a4bf690ff | /HW5/AbstractBoard.h | eee981f46f0b326c2424f6aad787bcfcf0dcb6c2 | [] | no_license | vedatEllidokuzoglu/CSE241-Object-Oriented-Programming | a0c22a97aef2711284f068c59ca1494c549efde5 | f970d981332e40c247b7a14f9b992df5f69c7d4a | refs/heads/master | 2021-05-20T00:39:25.558628 | 2020-04-02T17:14:36 | 2020-04-02T17:14:36 | 252,111,033 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 991 | h | AbstractBoard.h | #ifndef ABSTRACTBOARD_H_
#define ABSTRACTBOARD_H_
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <vector>
using namespace std;
namespace HW5_161044098{
class AbstractBoard{
private:
char last_move;
int total_move;
public:
virtual void print(int flag)=0;
virtual void readFromFile(char file_name[20])=0;
virtual void writeToFile()=0;
virtual void reset(int flag,int size_i,int size_j)=0;
virtual void setsize(int &size_i,int &size_j)=0;
virtual int move(char move,int status,int flag_1)=0;
virtual int isSolved(int flag, int status)=0;
virtual int l(int i,int j)=0;
virtual int operator()(int i,int j)=0;
virtual bool operator==(const AbstractBoard &solution);
virtual int NumberOfBoards(int size)=0;
virtual char lastMove();
virtual int numberOfMoves();
void setter_last_move(char temp_last_move);
void setter_total_move(int temp_total_move);
virtual int get_size(int iORj)=0;
};
}
#endif |
4d6f5fddc59937fdfadd85a2acb384a5e0390843 | 41d2d32ef91e70759c36f646b6ac66bb61aa81aa | /CatalanNumber.cpp | f8a94c080430ec31333515e402d94616494d2c2b | [] | no_license | samoedo/Competition | 48e5625ebf42160e299d721471b6fd26c0036dab | 93287eb6b73f0728ec49f7684dc57fc06341e39e | refs/heads/master | 2021-06-06T19:12:52.351526 | 2016-10-03T12:20:22 | 2016-10-03T12:20:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,074 | cpp | CatalanNumber.cpp | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <numeric>
#include <bitset>
#include <complex>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define foreach(itr, x) for (typeof((x).begin()) itr = (x).begin(); itr != (x).end(); itr++)
#define EPS (1e-14)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;
ll C[1005][1005];
void combination(int size) {
for (int i = 0; i < size; i++) C[i][0] = 1LL;
for (int i = 1; i < size; i++) {
for (int j = 1; j <= i; j++) {
C[i][j] = (C[i-1][j-1] + C[i-1][j]) % (ll)(1e+9 + 7);
}
}
}
ll catalan_number(int n) {
return C[2 * n][n] - C[2 * n][n - 1];
}
int main() {
combination(1005);
for (int i = 1; i <= 10; i++) {
cout << catalan_number(i) << endl;
}
return 0;
}
|
d1d109f578f1f25b13c6fc4dd380a8173f774914 | 3dac77de59a3a7c9c0d02823115ff90ac0cb2548 | /TOTR.cpp | 31fc528dd693b2ebf31cad726b368b52f065c9da | [] | no_license | adhyay2000/codechef | 2cc28a40e882f055b479253d68ba00b060d8a310 | 8ea8d9c1720c13dc04d049ee6ecc77d6523ccf0e | refs/heads/master | 2023-02-09T20:37:13.763466 | 2021-01-05T17:21:23 | 2021-01-05T17:21:23 | 260,828,111 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 758 | cpp | TOTR.cpp | #include<iostream>
#include<string>
#include<unordered_map>
#include<ctype.h>
using namespace std;
int main(){
int t;
unordered_map<char,char> mp;
cin >> t;
string ret;
cin >> ret;
for(int i=0;i<ret.size();i++){
mp['a'+i]=ret[i];
}
for(int i=0;i<t;i++){
string ret;
cin >> ret;
for(int i=0;i<ret.size();i++){
if(ret[i]>='a' && ret[i] <='z'){
ret[i]=mp[ret[i]];
}
else if(ret[i]>='A' && ret[i]<='Z'){
ret[i]=toupper(mp[tolower(ret[i])]);
// cout << '1' << ret[i] << endl;
}
else if(ret[i]=='_') ret[i]=' ';
else continue;
}
printf("%s\n",ret.c_str());
}
} |
3dd5b37771e28fd8b4732eb2b70cf52596a87d9d | e236560ebc4a3e56cc60b215fa8e3096892a636b | /Physics.cpp | 3a2f68baab9fc4d79457b5573df9183dc6f9b5e7 | [] | no_license | arciel/QSim | 13a0ce0c30fbd819f6f91cb512a14a60f2e627c2 | 39b35d3f7f933ee2d97a5d02cd11c071ba1685c0 | refs/heads/master | 2021-01-17T05:44:26.999296 | 2018-12-17T19:07:29 | 2018-12-17T19:07:29 | 40,016,164 | 1 | 1 | null | 2015-08-30T06:32:07 | 2015-07-31T17:14:35 | C++ | UTF-8 | C++ | false | false | 3,539 | cpp | Physics.cpp | #include <cmath>
#include <array>
#include <vector>
#include "VParticle.h"
struct Physics
{
float delta = 1.f / 60.f;
std::array<std::vector<float>, 2> force(const ParticleSystem& ps)
{
std::vector<float> fx (ps.q.size());
std::vector<float> fy (ps.q.size());
for(int i = 0; i != ps.q.size(); i++)
{
for(int j = 0; j != ps.q.size(); j++)
{
if (i==j) continue;
float f = ps.q[i] * ps.q[j] / (std::pow(ps.px[i] - ps.px[j],2) + std::pow(ps.py[i] - ps.py[j], 2));
fx[i] += f * (ps.px[i] - ps.px[j]);
fy[i] += f * (ps.py[i] - ps.py[j]);
}
}
return {fx, fy};
}
void step(ParticleSystem& ps)
{
std::array<std::vector<float>, 2> fxy = force(ps);
for(int i = 0; i != ps.q.size(); i++)
{
ps.vx[i] += fxy[0][i] * delta;
ps.vy[i] += fxy[1][i] * delta;
ps.px[i] += ps.vx[i] * delta;
ps.py[i] += ps.vy[i] * delta;
}
}
};
#if 0
// Quick and Dirty RK4 implementation.
// Followed GoG's blog, Wikipedia, CodeFlow and Doswa.
// TODO : Refactor, refactor and refactor!
// Eventually, setup a physics manager class that
// can be initialized with a choice of integrator (RK4, RK4 Adaptive, Verlet, RK2, etc)
// and provides generic functions for the main simulation to call.
// As far as I understand,
// RK4 will require an acceleration function, something which returns the acceleration of
// of a particle slightly into the future, given its position, velocity and a time delta
// i.e. it wants the accn at t = t + dt. Obviously, impossible to do since accn in the
// future depends on positions of other particles in the future. To calculate those would require
// using RK4 itself, which leads to problems.
// So I cheat by assuming that in dt time the other particles haven't really moved.
// Yeah, it's a hack. Sue me.
// --arciel
struct PhysMan //RK4
{
double delta = 1.0 / 60.0;// Each frame advances the time by delta amount.
Vector2D rk4_accl(ParticleSystem& List,Vector2D r, Vector2D v, float dt, int id, float q)
{
VParticle vpf(id, q, r, v);
vpf.setR(vpf.getR() + vpf.getV()*dt); // x = x0 + vdt.
Vector2D netE(0, 0); // Initial electric field.
for (auto &it : List)
{
if (it->getID() == vpf.getID()) continue;
netE = netE + (vpf.getR() - it->getR()) * (it->getQ() / vpf.getR().distance2(it->getR()));
}
Vector2D f = netE * vpf.getQ();
return f; // mass = 1 => acc = force
}
void integrate(ParticleSystem& List)
{
for (auto &vp : List) //mad cpp11 features! Loop over every particle in the simulation...
{
if (vp->getFixed() == 1) continue; //this charge is fixed in space.
//Vector2D r1 = vp->getR();
Vector2D v1 = vp->getV();
Vector2D a1 = rk4_accl(List,r1, v1, delta, vp->getID(), vp->getQ());
//Vector2D r2 = r1 + v1*(float)(0.5*delta);
Vector2D v2 = v1 + a1*(float)(0.5*delta);
Vector2D a2 = rk4_accl(List,r2, v2, delta / 2, vp->getID(), vp->getQ());
//Vector2D r3 = r1 + v2*(float)(0.5*delta);
Vector2D v3 = v1 + a2*(float)(0.5*delta);
Vector2D a3 = rk4_accl(List,r3, v3, delta / 2, vp->getID(), vp->getQ());
//Vector2D r4 = r1 + v3*(float)delta;
Vector2D v4 = v1 + a3*(float)delta;
Vector2D a4 = rk4_accl(List, r4, v4, delta, vp->getID(), vp->getQ());
//Vector2D rf = r1 + (v1 + v2*2.0f + v3*2.0f + v4)*(float)(delta / 6.0f);
Vector2D vf = v1 + (a1 + a2*2.0f + a3*2.0f + a4)*(float)(delta / 6.0f);
vp->setR_(rf);
vp->setV_(vf);
}
for (auto &update : List)
{
update->setR(update->getR_());
update->setV(update->getV_());
}
}
};
#endif
|
db30985c3479eea2e0de2302899161a0ea71e626 | 8c5fd6d091a13637959939e880149c0927a27645 | /AndroidProjects/RunMusheeRun_Hulcy/jni/CoreEngine/Logging.h | f73ec156b3ecffcaee3bcafa32a7f95fb7102580 | [
"MIT"
] | permissive | hulcyp/GuildhallProjects | f1223f0f83a947b256fbfad02c3591083c93bdaa | 2c5c558992daa505867c4b37b73cec61e1c8d2d0 | refs/heads/master | 2021-01-17T17:06:31.480272 | 2014-03-13T16:00:21 | 2014-03-13T16:00:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 351 | h | Logging.h | #pragma once
//---------------------------------------------
// Author: Preston Hulcy
// Date: 9/4/2013
// Description:
//
//---------------------------------------------
#include <cstdarg>
namespace Monky
{
void Log( const char* format, ... );
void Log( const char* format, va_list args );
void vLog( const char* format, ... );
void Flush();
} |
fb3e5d7dda8d2f4376243212719a354513f0b478 | 118fed2d72ef5fa9c61c82febf10712215bf644d | /parallel_computing_semester_project/src/trace.h | 3a238fb76a051afe37edc4d47c5c859f48561ddd | [] | no_license | jwiggins/selected_schoolwork | 106be771ca2eece38ee79966ee14c557ad5caa7d | da15acce8db3e728343667c3cf9456a38329d9fd | refs/heads/master | 2020-06-03T13:24:49.972356 | 2017-06-12T19:12:35 | 2017-06-12T19:12:35 | 94,131,681 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,539 | h | trace.h | /*
trace.h
$Id: trace.h,v 1.3 2003/04/25 21:43:35 prok Exp $
$Log: trace.h,v $
Revision 1.3 2003/04/25 21:43:35 prok
Volume rendering is finally correct. Shading is turned off, because it's broken.
Two nasty bugs were squashed in transferfunction.h. Data distribution code in
read_data.cpp was modified to do a random distribution, rather than a modulo
distribution.
Revision 1.2 2003/04/20 08:14:49 prok
This is the initial working version. Output is mostly correct...
I Need to look at more transfer functions and datasets.
Revision 1.1.1.1 2003/04/19 05:18:21 prok
This is my parallel ray casting volume renderer. I'm writing it for CS377, but
if it turns out that this parallelization strategy is fast, I might develop it
further.
*/
#ifndef TRACE_H
#define TRACE_H
#include <vector>
#include <math.h>
#include <stdio.h>
#include "ray.h"
#include "veclib.h"
#include "color.h"
#include "light.h"
#include "volume.h"
using namespace std;
class Trace {
public:
Trace(Volume *v);
Trace(const Trace &t);
~Trace();
void AddLightToScene(Light *light);
color_t RayCast(const Ray &r) const;
private:
color_t compute_direct_illumination(color_t c, const Vector4 &P,
const Vector4 &V, const Vector4 &N) const;
color_t local_illumination(color_t c, const Vector4 &P, const Vector4 &N,
const Vector4 &L, const Vector4 &H) const;
vector<Light *> light_list;
Volume *vol;
};
#endif
|
b38e23b0ac9a39a6ce207e9a70b3b2645a0ea297 | 8d63a6398e9ef6e2554f2c57facaa5d3d73a6160 | /Packages/RendererManaged/Primitive.h | a8c4147e1277130e96843bc0a80ceac10de09b57 | [] | no_license | ElonGame/GodComplex | a0d8d9af6da0dd5f37031a00d230510d358b3b9b | 57ae11823009ba62b7be65f43237428604bf9f26 | refs/heads/master | 2021-01-01T17:49:20.558130 | 2017-06-27T15:10:51 | 2017-06-27T15:10:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 881 | h | Primitive.h | // Primitive.h
#pragma once
#include "Device.h"
#include "VertexFormats.h"
using namespace System;
namespace Renderer {
ref class Shader;
ref class ByteBuffer;
// Wraps a simple 3D primitive
//
public ref class Primitive {
public:
enum class TOPOLOGY {
POINT_LIST,
LINE_LIST,
TRIANGLE_LIST,
TRIANGLE_STRIP,
};
private:
::Primitive* m_pPrimitive;
public:
Primitive( Device^ _device, UInt32 _verticesCount, ByteBuffer^ _vertices, cli::array<UInt32>^ _indices, TOPOLOGY _topology, VERTEX_FORMAT _vertexFormat );
~Primitive() {
delete m_pPrimitive;
}
void Render( Shader^ _shader );
void RenderInstanced( Shader^ _shader, UInt32 _instancesCount );
void RenderInstanced( Shader^ _shader, UInt32 _instancesCount, UInt32 _startVertex, UInt32 _verticesCount, UInt32 _startIndex, UInt32 _indicesCount, UInt32 _baseVertexOffset );
};
}
|
85f69c41ed1a45ad47f59267ed1a637dbdf78a13 | d10f93fc85ea3b2e1faf81cededeb65b9f006d1b | /src/ObjectManager.cpp | 13fcf37e9641f190d20dfdfdb6ab8dc3a803455c | [] | no_license | carl2g/Raytracer | 0d45e36fc373d96ee4c617aa6269a4a303110072 | 8f7541251f6a7798964bf1906c90506c53ff79e0 | refs/heads/master | 2023-03-14T14:39:33.537095 | 2021-03-14T16:15:34 | 2021-03-14T16:15:34 | 135,750,579 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,962 | cpp | ObjectManager.cpp | #include "ObjectManager.hpp"
const Color ObjectManager::getColor(const Vec3<double> &origin, const Vec3<double> &rd, const Light &l, int z) {
auto &&tup = this->getClosestIntersection(origin, rd);
auto &&obj = std::get<0>(tup);
auto &&t = std::get<1>(tup);
if (t >= 0) {
auto &&hit_point = origin + rd * t;
auto &&coef = getLightCoef(hit_point, *obj, l);
auto &color = obj->getColor() * coef;
if (z > 5) {
return color;
}
auto &&obj_norm = obj->getNormalVect(hit_point);
auto &&adj = *obj_norm * rd.dot(*obj_norm);
auto &&ref_vect = rd - adj * 2;
auto &&ref_coef = obj->getReflection();
if (ref_coef > 0) {
return (color * (1.0 - ref_coef) + getColor(hit_point + *obj_norm * 0.0001, ref_vect, l, z+1) * ref_coef);
}
// std::cout << z << " " << tmp.getR() << " " << tmp.getG() << " " << tmp.getB() << " " << tmp.getA() << std::endl;
return (color);
}
return {0, 0, 0, 0};
}
std::tuple<Obj const *, double> ObjectManager::getClosestIntersection(const Vec3<double> &origin, const Vec3<double> &rd) {
double t = -1.0;
int f = 0;
for (int i = 0; i < _manager.size(); ++i) {
auto &&a = _manager[i];
auto &&tmp = a->intersect(origin, rd);
if ((tmp >= 0.0 && t > tmp) || (t < 0.0 && tmp >= 0.0)) {
t = tmp;
f = i;
}
}
return(std::make_tuple(_manager[f].get(), t));
};
double ObjectManager::getLightCoef(const Vec3<double> &origin, const Obj &obj, const Light &l) {
auto &&rd = l.getPos() - origin;
auto &&norm = obj.getNormalVect(origin);
auto &&angle = norm->getAngle(rd);
auto &&tup = this->getClosestIntersection(origin + *norm * 0.0001, rd);
auto &&t = std::get<1>(tup);
auto &&dist_to_light = rd.norm();
auto &&difuse = (1.0 - (1.75 * angle / M_PI));
auto &&intensity = l.getIntensity();
auto &&dist = intensity / (intensity + dist_to_light);
if (t >= 0 && dist_to_light > (rd * t).norm()) {
return (0.125 * dist);
}
auto &&coef = difuse * dist;
return (coef);
};
|
aea08bb7c5e894928827fab71bcd6fa973660af4 | a365df4d8460c5e397811d9dc16dabf21313a3ca | /king.cc | 5903351f992d073c8a5ab385b89f3bbc205b596d | [] | no_license | harvest-ltd/chess | d1080057511e54d68b8db222b84f23a4bc1bbfe3 | 55681666ce5b674ffef1b3437e1e039bd9a110af | refs/heads/master | 2021-01-23T05:45:13.694364 | 2013-07-15T17:57:17 | 2013-07-15T17:57:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,769 | cc | king.cc | #include "king.hh"
#include "board.hh"
#include "position.hh"
#include "move.hh"
#include "debug.hh"
#include <stdlib.h>
King::King(Board* board, ePieceColor color) :
Piece(board, color, king) {
}
King::~King() {
}
bool King::isFieldAttacked(Field* checkedField) {
Position checkedPosition = checkedField->getPosition();
Position position = field->getPosition();
if (checkedPosition == position) {
return false;
}
if (!checkedField->isEmpty()) {
if (checkedField->getPiece()->getColor() == color) {
return false;
}
}
if (abs(checkedPosition.col - position.col) <= 1 &&
abs(checkedPosition.row - position.row) <= 1) {
return true;
}
return false;
}
bool King::isMoveValid(Move* move) {
if (isFieldAttacked(move->getToField())) {
return true;
}
// check castling
DEBUGLINE("check castling move");
move->setCastling();
if (moved) {
DEBUGLINE("king already moved");
return false;
}
Position position = field->getPosition();
Position toPos = move->getToField()->getPosition();
char colDiff = toPos.col - position.col;
if (toPos.row != position.row || abs(colDiff) != 2) {
DEBUGLINE("not castling move");
return false;
}
char step = (colDiff == 2) ? 1 : -1;
unsigned char numberOfEmptyFields = (step == 1) ? 2 : 3;
for (unsigned char index = 1; index <= numberOfEmptyFields; ++index) {
Position emptyPosition(position);
emptyPosition.col = position.col + step * index;
Field* emptyField = board->getField(emptyPosition);
if (!emptyField->isEmpty()) {
DEBUGLINE("fields aren't empty between king and rook");
return false;
}
}
for (unsigned char index = 0; index <= numberOfEmptyFields; ++index) {
Position attackedPosition(position);
attackedPosition.col = position.col + step * index;
Field* attackedField = board->getField(attackedPosition);
if (board->isFieldAttacked(attackedField, this->getAttackColor())) {
DEBUGLINE("king is under attack");
return false;
}
}
Position rookPosition(position);
rookPosition.col = position.col + step * (numberOfEmptyFields + 1);
Field* rookFromField = board->getField(rookPosition);
if (rookFromField->isEmpty()) {
DEBUGLINE("rook field is empty");
return false;
}
Piece* rookPiece = rookFromField->getPiece();
if (rookPiece->getColor() != this->color || rookPiece->getType() != rook) {
DEBUGLINE("no proper rook");
return false;
}
if (rookPiece->isMoved()) {
DEBUGLINE("rook already moved");
return false;
}
rookPosition.col = position.col + step;
Field* rookToField = board->getField(rookPosition);
move->setRookFieldsDuringCastling(rookFromField, rookToField);
return true;
}
|
0a99e6fc120b378c8c6a048bab423f8f8ce2836c | 5401afea8de67b74b6edfd6fc038a9100319b3ee | /phast_gui/ui/widgetplotsettings.h | 82185005f190de9d6389e9c551130f2abcaf8d46 | [
"MIT"
] | permissive | stijnhinterding/phast | 9ca5b3c11b1127c4759749f41bc02bc09d593887 | dad4702eb6401c1eba03ad70eff3659292636d30 | refs/heads/master | 2023-03-28T06:14:20.548835 | 2021-03-15T09:56:18 | 2021-03-15T09:56:18 | 347,870,688 | 0 | 0 | MIT | 2021-03-15T07:09:03 | 2021-03-15T07:09:02 | null | UTF-8 | C++ | false | false | 2,252 | h | widgetplotsettings.h | /* Copyright (c) 2020 Stijn Hinterding, Utrecht University
* This sofware is licensed under the MIT license (see the LICENSE file)
*/
#ifndef WIDGETPLOTSETTINGS_H
#define WIDGETPLOTSETTINGS_H
#include <QDialog>
#include "../support/plotparams.h"
#include "../interfaces/ibinningclass.h"
#include <mutex>
class DataView;
class IDataPlot;
namespace Ui {
class WidgetPlotSettings;
}
class WidgetPlotSettings : public QDialog
{
Q_OBJECT
private:
IDataPlot* view;
IBinningClass* plot;
plot_params p;
QMetaObject::Connection cur_view_connection;
QMetaObject::Connection cur_plot_connection;
void use_new_params(plot_params p);
std::mutex view_mutex;
std::mutex plot_mutex;
signals:
void params_changed(plot_params new_value);
void bin_width_changed(uint64_t bin_width);
void clear_all_views();
public:
WidgetPlotSettings(const WidgetPlotSettings&) = delete;
WidgetPlotSettings& operator=(const WidgetPlotSettings&) = delete;
explicit WidgetPlotSettings(QWidget *parent = nullptr);
~WidgetPlotSettings();
public slots:
void new_view(IDataPlot *value);
void new_plot(IBinningClass* plot);
void view_deleted(IDataPlot *value);
void plot_deleted(IBinningClass* plot);
private slots:
void on_spb_xmin_valueChanged(double arg1);
void on_chk_xmax_auto_clicked(bool checked);
void on_spb_xmax_valueChanged(double arg1);
void on_spb_ymin_valueChanged(double arg1);
void on_chk_ymax_auto_toggled(bool checked);
void on_spb_ymax_valueChanged(double arg1);
void on_chk_ylog_toggled(bool checked);
void on_chk_x_const_size_toggled(bool checked);
void on_cnt_x_const_width_valueChanged(double value);
void on_chk_y_const_size_toggled(bool checked);
void on_cnt_y_const_width_valueChanged(double value);
void on_chk_auto_xmin_toggled(bool checked);
void on_cnt_bin_width_valueChanged(double value);
void on_chk_xlog_toggled(bool checked);
void on_btn_clear_all_views_clicked();
void on_chk_auto_ymin_toggled(bool checked);
private:
Ui::WidgetPlotSettings *ui;
};
#endif // WIDGETPLOTSETTINGS_H
|
d05a1211b05341fd53dea09fed2f86298a6baee1 | 579d78a971d30949f97c51d84ef10a7f7be5d1cd | /ft/hb_shaper.h | b1dc9b1edffdd5ed2c391fb4441089720ae5b4f0 | [
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | Gasparoken/laf | fe2a6367bb08509c37eb2c63acc4a8efa2f6dc3a | c550d2058adcb15a05fd98d35fdd37b7361231d3 | refs/heads/master | 2023-08-18T21:38:11.390738 | 2020-08-03T20:18:59 | 2020-08-03T20:18:59 | 164,723,739 | 4 | 0 | MIT | 2019-01-08T20:03:46 | 2019-01-08T20:03:46 | null | UTF-8 | C++ | false | false | 3,395 | h | hb_shaper.h | // LAF FreeType Wrapper
// Copyright (c) 2020 Igara Studio S.A.
// Copyright (c) 2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef FT_HB_SHAPER_H_INCLUDED
#define FT_HB_SHAPER_H_INCLUDED
#pragma once
#include "ft/hb_face.h"
#include <vector>
namespace ft {
template<typename HBFace>
class HBShaper {
public:
HBShaper(HBFace& face) : m_face(face) {
}
bool initialize(const base::utf8_const_iterator& begin,
const base::utf8_const_iterator& end) {
m_index = 0;
m_glyphCount = 0;
if (begin == end)
return false;
hb_buffer_t* buf = hb_buffer_create();
hb_buffer_t* chrBuf = hb_buffer_create();
hb_script_t script = HB_SCRIPT_UNKNOWN;
for (auto it=begin; it!=end; ++it) {
// Get the script of the next character in *it
hb_buffer_set_content_type(chrBuf, HB_BUFFER_CONTENT_TYPE_UNICODE);
hb_buffer_add(chrBuf, *it, 0);
hb_buffer_guess_segment_properties(chrBuf);
hb_script_t newScript = hb_buffer_get_script(chrBuf);
hb_buffer_reset(chrBuf);
if (newScript && script != newScript) {
addBuffer(buf, script);
hb_buffer_reset(buf);
script = newScript;
}
hb_buffer_add(buf, *it, it - begin);
}
addBuffer(buf, script);
hb_buffer_destroy(buf);
hb_buffer_destroy(chrBuf);
return (m_glyphCount > 0);
}
bool nextChar() {
++m_index;
return (m_index < m_glyphCount);
}
int unicodeChar() const {
return m_glyphInfo[m_index].codepoint;
}
int charIndex() {
return m_glyphInfo[m_index].cluster;
}
unsigned int glyphIndex() const {
return m_glyphInfo[m_index].codepoint;
}
void glyphOffsetXY(Glyph* glyph) {
glyph->x += m_glyphPos[m_index].x_offset / 64.0;
glyph->y += m_glyphPos[m_index].y_offset / 64.0;
}
void glyphAdvanceXY(const Glyph* glyph, double& x, double& y) {
x += m_glyphPos[m_index].x_advance / 64.0;
y += m_glyphPos[m_index].y_advance / 64.0;
}
private:
void addBuffer(hb_buffer_t* buf, hb_script_t script) {
if (hb_buffer_get_length(buf) == 0)
return;
// Just in case we're compiling with an old harfbuzz version
#ifdef HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS
hb_buffer_set_cluster_level(buf, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
#endif
hb_buffer_set_content_type(buf, HB_BUFFER_CONTENT_TYPE_UNICODE);
hb_buffer_set_script(buf, script);
hb_buffer_set_direction(buf, hb_script_get_horizontal_direction(script));
hb_shape(m_face.font(), buf, nullptr, 0);
unsigned int count;
auto info = hb_buffer_get_glyph_infos(buf, &count);
auto pos = hb_buffer_get_glyph_positions(buf, &count);
m_glyphCount += count;
const unsigned int start = m_glyphInfo.size();
m_glyphInfo.resize(m_glyphCount);
m_glyphPos.resize(m_glyphCount);
for (unsigned int i=0; i<count; ++i) {
m_glyphInfo[start+i] = info[i];
m_glyphPos[start+i] = pos[i];
}
}
HBFace& m_face;
std::vector<hb_glyph_info_t> m_glyphInfo;
std::vector<hb_glyph_position_t> m_glyphPos;
unsigned int m_glyphCount;
unsigned int m_index;
};
} // namespace ft
#endif
|
26fc8c86b611e51d399a99a784fffe58f8d0c122 | 68b9458411846822a74bd043094bd23d509cd1cd | /Project/IRFramework/IRFramework/Framework.h | 76b018749b0e898bb8f339ed4d9aa0449fdb6c03 | [] | no_license | Feross-Salameh/CPPIntro | 602035ab3eb534ac2e7cbea75e9ce1d99565b048 | 55b2f62f64daf746d883063cd370b5c7204d559f | refs/heads/master | 2018-11-04T13:06:00.051554 | 2018-09-17T01:44:11 | 2018-09-17T01:44:11 | 119,121,521 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 544 | h | Framework.h | #pragma once
#include "Header.h"
#include "IRCode.h"
#include "ArduinoInterface.h"
#include "DatabaseInterface.h"
class Framework
{
public:
Framework();
void StoreIRCode(std::string name);
void CreateSequence(std::vector<ICode *>& codes, std::string name);
void CallCode(std::string name);
void RunSequence(std::string name);
void GetCode(std::string name, ICode& code);
private:
ArduinoInterface myArdy;
DatabaseInterface myStorage;
// TODO: implement when there is more than 1 interface.
std::vector<IHardware*> interfaces;
};
|
f9d510fb82258d0472432498970d0ce128ed3cd8 | 28817c1d7c71718745fabbd7c8ff06b0444a16dd | /ThreadPool/ThreadPool.cpp | cc91484fd8d1a15302cba3c05316028b202a50d8 | [] | no_license | javiajinkal/Parallel-Dependency-Analysis | 5b56c90cf7611fb78e14f200b655ea048fb99564 | 352b63d13baed9d440e28e34ab90d03e791e6ec0 | refs/heads/master | 2020-06-27T13:08:10.159624 | 2017-07-12T22:43:43 | 2017-07-12T22:43:43 | 97,056,632 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,067 | cpp | ThreadPool.cpp | ///////////////////////////////////////////////////////////////////////////////
// ThreadPool.cpp - child thread processes enqueued work items //
// ver 1.0 //
// Language: C++, Visual Studio 2015 //
// Application: Project 3 , CSE687 - Object Oriented Design //
// Platform: Lenovo Yoga 3, Core-i5, Windows 10 //
// Author: Jinkal Arvind Javia, SUID: 425325424 //
// jjavia@syr.edu //
// Source: Jim Fawcett, Syracuse University, CST 4-187 //
// jfawcett@twcny.rr.com //
///////////////////////////////////////////////////////////////////////////////
#include "../Utilities/Utilities.h"
#include "ThreadPool.h"
#include <string>
#include <iostream>
#include <conio.h>
//----< demonstrate ThreadPool class >----------------------------
using Util = Utilities::StringHelper;
#ifdef TEST_THREADPOOL
int main()
{
std::cout << "\n--------Testing ThreadPool Package-------\n";
Util::Title("Enqueued Work Items");
std::cout << "\n main thread id = " << std::this_thread::get_id();
ThreadPool<bool, std::string> processor;
processor.start(2);
// define 1st work item
std::string s1 = "X";
std::function<bool(std::string)> w1 = [&](std::string file) {
return false;
};
workItem<bool, std::string> *wi1 = new workItem<bool, std::string>(&w1, &s1);
processor.doWork(wi1);
std::cout << "\n Processor Result: " << processor.result();
// define 2nd work item
std::string s2 = "Y";
std::function<bool(std::string)> w2 = [&](std::string file) {
return false;
};
workItem<bool, std::string> *wi2 = new workItem<bool, std::string>(&w2, &s2);
processor.doWork(wi2);
// the following calls to result() block until results are enqueued
std::cout << "\n Processor Result: " << processor.result();
processor.doWork(nullptr);
// wait for child thread to complete
processor.wait();
std::cout << "\n\n";
}
#endif |
2bb3da4e28e7617a22a00cb4781ec2ff042894db | 7cce0635a50e8d2db92b7b1bf4ad49fc218fb0b8 | /郭鑫程序交接/source.code.2012.06.11/source.code/portd/sockimpl.cpp | ab42750f81b11aa23bfb979d51219dfcc8f45783 | [] | no_license | liquanhai/cxm-hitech-matrix428 | dcebcacea58123aabcd9541704b42b3491444220 | d06042a3de79379a77b0e4e276de42de3c1c6d23 | refs/heads/master | 2021-01-20T12:06:23.622153 | 2013-01-24T01:05:10 | 2013-01-24T01:05:10 | 54,619,320 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 9,435 | cpp | sockimpl.cpp | #include <assert.h>
#include "../common/config.h"
#include "pcid.h"
#include "sockimpl.h"
#pragma comment(lib, "Ws2_32")
typedef struct __tagSOCKET_IMPL
{
SOCKET socket_;
SOCKET broadcast_socket_;
unsigned short listen_port_;
unsigned int recv_buffer_size_;
unsigned int send_buffer_size_;
SOCKADDR_IN remote_ip_;
unsigned short remote_port_;
}SOCKET_IMPL, *SOCKET_IMPL_PTR;
SOCKET_IMPL __socket_impl;
bool init_socket()
{
bool is_ok = TRUE;
WSADATA wsaData;
WORD wVersionRequested = MAKEWORD(2, 2);
int nResult = WSAStartup(wVersionRequested, &wsaData);
if (nResult != 0)
return false;
if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2){
WSACleanup();
WSASetLastError (WSAVERNOTSUPPORTED);
return false;
}
memset(&__socket_impl, 0x0, sizeof(__socket_impl));
return is_ok;
}
bool create_udp_socket(const char* listen_ip, unsigned short lisen_port, const char* remote_ip, unsigned short remote_port,
unsigned recv_buff_size, unsigned send_buff_size)
{
bool is_ok = true;
DWORD bytes_returned = 0;
BOOL new_behavior = FALSE;
unsigned long arg = 1;
BOOL is_broadcast = TRUE;
SOCKADDR_IN sockAddr;
memset(&sockAddr,0,sizeof(sockAddr));
//create a socket
assert(__socket_impl.socket_ == NULL);
__socket_impl.socket_ = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(__socket_impl.socket_ != NULL){
__socket_impl.listen_port_ = lisen_port;
sockAddr.sin_family = AF_INET;
sockAddr.sin_addr.s_addr = inet_addr(listen_ip);//htonl(INADDR_ANY);
sockAddr.sin_port = htons((u_short)__socket_impl.listen_port_);
//bind socket
bind(__socket_impl.socket_, (SOCKADDR*)&sockAddr, sizeof(sockAddr));
//set receive buff
__socket_impl.recv_buffer_size_ = recv_buff_size;
if(__socket_impl.recv_buffer_size_ != 0)
setsockopt(__socket_impl.socket_, SOL_SOCKET, SO_RCVBUF, (const char*)&__socket_impl.recv_buffer_size_,
sizeof(__socket_impl.recv_buffer_size_));
//set send buff
__socket_impl.send_buffer_size_ = send_buff_size;
if(__socket_impl.send_buffer_size_ != 0)
setsockopt(__socket_impl.socket_, SOL_SOCKET, SO_SNDBUF, (const char*)&__socket_impl.send_buffer_size_,
sizeof(__socket_impl.send_buffer_size_));
//set io control
ioctlsocket(__socket_impl.socket_, FIONBIO, &arg);
// disable new behavior using IOCTL: SIO_UDP_CONNRESET
WSAIoctl(__socket_impl.socket_, SIO_UDP_CONNRESET, &new_behavior, sizeof(new_behavior),
NULL, 0, &bytes_returned, NULL, NULL);
}
else{
OUTPUT_DEBUG_STRING(IDS_STRING142);
return false;
}
//create a broadcast socket
assert(__socket_impl.broadcast_socket_ == NULL);
__socket_impl.broadcast_socket_ = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(__socket_impl.broadcast_socket_ != NULL){
sockAddr.sin_family = AF_INET;
sockAddr.sin_addr.s_addr = inet_addr(listen_ip);//htonl(INADDR_ANY);
sockAddr.sin_port = htons(0);
setsockopt(__socket_impl.broadcast_socket_, SOL_SOCKET, SO_BROADCAST,
(char*)&is_broadcast, sizeof(BOOL));
//bind socket
bind(__socket_impl.broadcast_socket_, (SOCKADDR*)&sockAddr, sizeof(sockAddr));
}
//set remote ip
memset(&__socket_impl.remote_ip_, 0, sizeof(__socket_impl.remote_ip_));
__socket_impl.remote_ip_.sin_family = AF_INET;
if (remote_ip == NULL){
__socket_impl.remote_ip_.sin_addr.s_addr = htonl(INADDR_ANY);
}
else{
__socket_impl.remote_ip_.sin_addr.s_addr = inet_addr(remote_ip);
if (__socket_impl.remote_ip_.sin_addr.s_addr == INADDR_NONE){
LPHOSTENT lphost;
lphost = gethostbyname(remote_ip);
if (lphost != NULL){
__socket_impl.remote_ip_.sin_addr.s_addr = ((LPIN_ADDR)lphost->h_addr)->s_addr;
}
else{
WSASetLastError(WSAEINVAL);
return false;
}
}
}
__socket_impl.remote_ip_.sin_port = htons((u_short)remote_port);
__socket_impl.remote_port_ = remote_port;
return is_ok;
}
bool create_udp_socket(unsigned short lisen_port, const char* remote_ip, unsigned short remote_port,
unsigned recv_buff_size, unsigned send_buff_size)
{
bool is_ok = true;
DWORD bytes_returned = 0;
BOOL new_behavior = FALSE;
unsigned long arg = 1;
BOOL is_broadcast = TRUE;
SOCKADDR_IN sockAddr;
memset(&sockAddr,0,sizeof(sockAddr));
//create a socket
assert(__socket_impl.socket_ == NULL);
__socket_impl.socket_ = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(__socket_impl.socket_ != NULL){
__socket_impl.listen_port_ = lisen_port;
sockAddr.sin_family = AF_INET;
sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
sockAddr.sin_port = htons((u_short)__socket_impl.listen_port_);
//bind socket
bind(__socket_impl.socket_, (SOCKADDR*)&sockAddr, sizeof(sockAddr));
//set receive buff
__socket_impl.recv_buffer_size_ = recv_buff_size;
if(__socket_impl.recv_buffer_size_ != 0)
setsockopt(__socket_impl.socket_, SOL_SOCKET, SO_RCVBUF, (const char*)&__socket_impl.recv_buffer_size_,
sizeof(__socket_impl.recv_buffer_size_));
//set send buff
__socket_impl.send_buffer_size_ = send_buff_size;
if(__socket_impl.send_buffer_size_ != 0)
setsockopt(__socket_impl.socket_, SOL_SOCKET, SO_SNDBUF, (const char*)&__socket_impl.send_buffer_size_,
sizeof(__socket_impl.send_buffer_size_));
//set io control
ioctlsocket(__socket_impl.socket_, FIONBIO, &arg);
// disable new behavior using IOCTL: SIO_UDP_CONNRESET
WSAIoctl(__socket_impl.socket_, SIO_UDP_CONNRESET, &new_behavior, sizeof(new_behavior),
NULL, 0, &bytes_returned, NULL, NULL);
}
else{
OUTPUT_DEBUG_STRING(IDS_STRING142);
return false;
}
//create a broadcast socket
assert(__socket_impl.broadcast_socket_ == NULL);
__socket_impl.broadcast_socket_ = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(__socket_impl.broadcast_socket_ != NULL){
sockAddr.sin_family = AF_INET;
sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
sockAddr.sin_port = htons(0);
setsockopt(__socket_impl.broadcast_socket_, SOL_SOCKET, SO_BROADCAST,
(char*)&is_broadcast, sizeof(BOOL));
//bind socket
bind(__socket_impl.broadcast_socket_, (SOCKADDR*)&sockAddr, sizeof(sockAddr));
}
//set remote ip
memset(&__socket_impl.remote_ip_, 0, sizeof(__socket_impl.remote_ip_));
__socket_impl.remote_ip_.sin_family = AF_INET;
if (remote_ip == NULL){
__socket_impl.remote_ip_.sin_addr.s_addr = htonl(INADDR_ANY);
}
else{
__socket_impl.remote_ip_.sin_addr.s_addr = inet_addr(remote_ip);
if (__socket_impl.remote_ip_.sin_addr.s_addr == INADDR_NONE){
LPHOSTENT lphost;
lphost = gethostbyname(remote_ip);
if (lphost != NULL){
__socket_impl.remote_ip_.sin_addr.s_addr = ((LPIN_ADDR)lphost->h_addr)->s_addr;
}
else{
WSASetLastError(WSAEINVAL);
return false;
}
}
}
__socket_impl.remote_ip_.sin_port = htons((u_short)remote_port);
__socket_impl.remote_port_ = remote_port;
return is_ok;
}
int udp_recv(udp_recv_callback callback, void* args)
{
char recv_buf[MAX_PACK_NET_SIZE] = {0};
unsigned long ioctl_argp = 0L;
int recv_size = 0;
int count = 0;
while(true){
if(ioctlsocket(__socket_impl.socket_, FIONREAD, &ioctl_argp) == 0){
if(ioctl_argp > 0){
recv_size = recv(__socket_impl.socket_, recv_buf, sizeof(recv_buf), 0);
if(recv_size == SOCKET_ERROR){
OUTPUT_DEBUG_STRING(IDS_STRING143, recv_size);
break;
}
else if(recv_size == 0x0){
OUTPUT_DEBUG_STRING(IDS_STRING144);
break;
}
else if(recv_size > MAX_PACK_NET_SIZE){
OUTPUT_DEBUG_STRING(IDS_STRING145);
break;
}
else{
callback(args, recv_buf, recv_size);
count += recv_size;
}
}
else
break;
}
else{
break;
}
}
return count;
}
//int udp_send(const SOCKADDR* remote_ip, const char* send_buf, unsigned int send_buf_size, int flag)
//{
// int ret = 0;
// timeval time_val = {0};
// fd_set write_fds;
//
// FD_ZERO(&write_fds);
// FD_SET(__socket_impl.socket_, &write_fds);
// ret = select(NULL, NULL, &write_fds, NULL, &time_val);
//
// if(ret == 0) return 0;
// else if(ret == SOCKET_ERROR) return -1;
//
// return sendto(__socket_impl.socket_, send_buf, send_buf_size, flag, remote_ip, sizeof(sockaddr_in));
//}
int udp_send(const char* send_buf, unsigned int send_buf_size, const SOCKADDR* remote_ip, int flag)
{
int ret = 0;
timeval time_val = {0};
fd_set write_fds;
SOCKET s = NULL;
if(remote_ip == NULL) remote_ip = (SOCKADDR*)&__socket_impl.remote_ip_;
if(((SOCKADDR_IN*)remote_ip)->sin_addr.s_addr == htonl(INADDR_BROADCAST)){
s = __socket_impl.broadcast_socket_;
}
else{
FD_ZERO(&write_fds);
FD_SET(__socket_impl.socket_, &write_fds);
ret = select(NULL, NULL, &write_fds, NULL, &time_val);
if(ret == 0) return 0;
else if(ret == SOCKET_ERROR) return -1;
s = __socket_impl.socket_;
}
return sendto(s, send_buf, send_buf_size, flag, remote_ip, sizeof(SOCKADDR));
}
void release_socket()
{
WSACleanup();
}
void close_udp_socket()
{
if(__socket_impl.socket_){
closesocket(__socket_impl.socket_);
__socket_impl.socket_ = NULL;
}
if(__socket_impl.broadcast_socket_){
closesocket(__socket_impl.broadcast_socket_);
__socket_impl.broadcast_socket_ = NULL;
}
};
|
9254c17c0bdd02b84e4d086a07c0d6c7cedab846 | d915b8d0432189bc05021f1b8209fdc4a710f961 | /2019/24.2.cpp | 66f790604809d2227c10abc443ffdd5bc701c3a2 | [
"WTFPL"
] | permissive | wgevaert/AOC | cd77ed1848f73c78790bbfb6379b25832e1015e1 | 1f6cb2c2a134725bffbc6ce430899dcd9f03b8f7 | refs/heads/master | 2022-12-27T17:12:34.839336 | 2022-12-27T12:43:27 | 2022-12-27T12:43:27 | 225,715,331 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,420 | cpp | 24.2.cpp | #include <iostream>
#include <string>
#include <bitset>
const int size_x=5,size_y=5,mid_x=(size_x-1)/2,mid_y=(size_y-1)/2;
bool get_tile(int x,int y,uint32_t*boards,int index) {
if (x>=size_x)
return get_tile(mid_x+1,mid_y,boards,index-1);
if (y >=size_y)
return get_tile(mid_x,mid_y+1,boards,index-1);
if (x<0)
return get_tile(mid_x-1,mid_y,boards,index-1);
if (y<0)
return get_tile(mid_x,mid_y-1,boards,index-1);
if(x==mid_x&&y==mid_y)return 0;
return (boards[index] >> (size_x*y+x))%2;
}
void set_tile(int x,int y,uint32_t & board,bool value) {
if (value) {
board |= (1u<<(size_x*y+x));
} else {
board &= ~(1u<<(size_x*y+x));
}
}
uint32_t read() {
std::string line;
uint32_t rtr=0;
std::getline(std::cin,line);
int x,y=0;
while(line.size()) {
x=0;
for (char a : line) {
set_tile(x,y,rtr,a=='#');
x++;
}
y++;
std::getline(std::cin,line);
}
return rtr;
}
int main() {
const int board_offset = 150;
static uint32_t boards[2*board_offset];
boards[board_offset] = read();
static uint32_t new_boards[2*board_offset+1];
int steps = 0,max_depth=0,min_depth=0,new_max_depth,new_min_depth;
while (steps<200) {
new_max_depth = max_depth;
new_min_depth = min_depth;
for(int j=0;j<size_y;j++) {
for (int depth = min_depth-1;depth<=max_depth+1;depth++) {
bool lives = false;
for (int i=0;i<size_x;i++) {
int neighbours =
get_tile(i+1,j,boards,depth+board_offset) +
get_tile(i,j-1,boards,depth+board_offset) +
get_tile(i,j+1,boards,depth+board_offset) +
get_tile(i-1,j,boards,depth+board_offset);
if (i==mid_x) {
if (j==mid_y - 1) {
for (int k=0;k<size_y;k++)
neighbours += get_tile(k,0,boards,depth+1+board_offset);
} else if (j==mid_y+1) {
for (int k=0;k<size_y;k++)
neighbours += get_tile(k,size_y-1,boards,depth+1+board_offset);
} else if (j==mid_y)
continue;
}
else if (j==mid_y) {
if (i==mid_x - 1) {
for (int k=0;k<size_y;k++)
neighbours += get_tile(0,k,boards,depth+1+board_offset);
} else if (i==mid_x+1) {
for (int k=0;k<size_y;k++)
neighbours += get_tile(size_x-1,k,boards,depth+1+board_offset);
}
}
if (neighbours == 1 || (neighbours == 2 && !get_tile(i,j,boards,depth+board_offset))) {
set_tile(i,j,new_boards[depth+board_offset],true);
lives = true;
} else set_tile(i,j,new_boards[depth+board_offset],false);
}
if (depth==min_depth-1 && lives)
new_min_depth=min_depth-1;
else if(depth==max_depth+1 && lives)
new_max_depth=max_depth+1;
}
}
min_depth = new_min_depth;
max_depth = new_max_depth;
if (min_depth+board_offset <= 0 || max_depth >= board_offset) {
std::cout<<"BOARD BUFFER TOO SMALL"<<std::endl;return 1;
}
for (int d=min_depth;d<=max_depth;d++){
boards[d+board_offset] = new_boards[d+board_offset];
new_boards[d+board_offset]=0;
}
steps++;
}
long long unsigned total_bugs = 0;
std::cout<<"FINAL CONFIGURATION:"<<std::endl;
for (int d=min_depth;d<=max_depth;d++) {std::cout<<"\n\nDEPTH "<<d<<std::endl;
for (int j=0;j<size_y;j++){
for (int i=0;i<size_x;i++)
if(i==mid_x&&j==mid_y)std::cout<<'?';
else if(get_tile(i,j,boards,d+board_offset)) {
total_bugs++;
std::cout<<'#';
} else std::cout<<'.';
std::cout<<std::endl;
}
}
std::cout<<" TOTAL BUGS: "<<total_bugs<<std::endl;
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.