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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3c702c591e0d9b28b79cfbb0e53a8ba863d03cd3
|
021f65f3affeffaaff3d981e2e30177256cb988b
|
/Olympiad Programs/M3/Shaazzz/Contest 1 2013/3.1.cpp
|
cc4ed784643170960d4ee510126d94db3a8bb295
|
[
"MIT"
] |
permissive
|
mirtaba/ACMICPC-INOI_Archive
|
2d95bef1efdb26bbaabcf2993210b1562a3cc399
|
ea06e4e40e984f0807410e4f9b5f7042580da2e3
|
refs/heads/master
| 2021-04-09T15:17:47.532859
| 2018-03-16T09:11:48
| 2018-03-16T09:11:48
| 125,491,625
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,464
|
cpp
|
3.1.cpp
|
/*
ID: ghoolha1
PROG: greetings
LANG: C++
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <cmath>
#include <fstream>
#define MAX(a,b) (((a) > (b))? (a) : (b))
#define MIN(a,b) (((a) < (b))? (a) : (b))
#define MEM(a,b) (memset((a),(b),sizeof(a)))
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define f1 first
#define f2 second
#define X first
#define Y second
using namespace std;
typedef long long LL;
typedef pair <int, int> PII;
typedef pair <LL,LL> PLL;
const int Maxn = 500 + 25;
const int Mod = 100;
//ofstream fout ("greetings.out");
//ifstream fin ("greetings.in");
//#define cin fin
//#define cout fout
bool ma[Maxn][Maxn],d[Maxn][Maxn],flag,flag1,flag2;
int tmp1,tmp2,tp,Ans,tmp,N;
int main()
{
ios::sync_with_stdio(0);
FOR(i,1,501)
{
FOR(j,1,501)
{
(tp=(LL)(i*j)) %= Mod;
(tmp1=(LL)(2013*i)) %= Mod;
(tmp2=(LL)(2013*j)) %= Mod;
(tmp=(LL)(tp+tmp1+tmp2)) %= Mod;
if(tmp<=20)
{
//ma[i][j]=true;
d[i][j]=true;
}
}
}
FOR(i,1,501)
d[500][i]=true;
for(int i=499;i>=1;i--)
{
//if((i%2)==1)
{
FOR(j,1,501)
{
if(j>1)
flag1=(d[i+1][j-1]);
else
flag1=true;
if(j<500)
flag2=d[i+1][j+1];
else
flag2=true;
if (d[i+1][j] && (flag1&&flag2))
{
d[i][j]=true;
}
}
}
/**
else
{
FOR(j,1,501)
{
if(j>1)
flag1=(d[i+1][j-1]);
else
flag1=true;
if(j<500)
flag2=d[i+1][j+1];
else
flag1=true;
if ((d[i+1][j] || (flag1 || flag2)))
{
d[i][j]=true;
}
}
}
/**/
}
FOR(i,1,501)
{
if (!d[1][i])
{
Ans++;
}
}
cout << Ans << endl;
}
|
2489df447ca02d084791ef09b80ae58bc356118e
|
666b02b7051301ded941f1b4d6df23870d4eb570
|
/Source/ToonTanks/Pawns/ProjectileBase.cpp
|
aa8dc831e9ce3cdbcd33d103a80853a6104e9dc5
|
[] |
no_license
|
CS1CAgile5/Agile-3_Project
|
91106135caa178d5199227cd60aae6363bd4ad08
|
cc7c757b35c3c3fc092d03936b147f4a5da09d34
|
refs/heads/master
| 2023-01-01T23:51:22.364075
| 2020-10-22T23:29:20
| 2020-10-22T23:29:20
| 290,604,779
| 0
| 0
| null | 2020-10-22T01:30:29
| 2020-08-26T21:07:01
|
C++
|
UTF-8
|
C++
| false
| false
| 2,538
|
cpp
|
ProjectileBase.cpp
|
// Fill out your copyright notice in the Description page of Project Settings.
#include "ProjectileBase.h"
#include "Components/StaticMeshComponent.h"
#include "GameFramework/ProjectileMovementComponent.h"
#include "Kismet/GameplayStatics.h"
#include "Particles/ParticleSystemComponent.h"
#include "Particles/ParticleSystemComponent.h"
// Sets default values
/*! \brief Constructor
*
*
* This Function will construct the component based on the default values
*/
AProjectileBase::AProjectileBase()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
ProjectileMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("ProjectileMesh"));
ProjectileMesh->OnComponentHit.AddDynamic(this, &AProjectileBase::OnHit);
RootComponent = ProjectileMesh;
ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("Projectile Movement"));
ProjectileMovement->InitialSpeed = MovementSpeed;
ProjectileMovement->MaxSpeed = MovementSpeed;
ParticleTrail = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("Particle Trail"));
ParticleTrail->SetupAttachment(RootComponent);
InitialLifeSpan = 3.0f;
}
// Called when the game starts or when spawned
/*! \brief Game Start
*
*
* This Function will Begin this components existance
*/
void AProjectileBase::BeginPlay()
{
Super::BeginPlay();
UGameplayStatics::PlaySoundAtLocation(this, LaunchSound, GetActorLocation());
}
/*! \brief Ran on hit
*
*
* This Function will cause damage to an actor when the projectile hits something
* @param HitComp
* @param OtherActor
* @param OtherComp
* @param NormalImpulse
* @param Hit
*/
void AProjectileBase::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
// Try to get a reference to the owning class
AActor* MyOwner = GetOwner();
// If for some reason we can't get a valid reference, return as we need to check against the owner
if (!MyOwner)
{
return;
}
// If the other actor ISN'T self OR Owner AND exists, then apply damage
if (OtherActor && OtherActor != this && OtherActor != MyOwner)
{
UGameplayStatics::ApplyDamage(OtherActor, Damage, MyOwner->GetInstigatorController(), this, DamageType);
UGameplayStatics::SpawnEmitterAtLocation(this, HitParticle, GetActorLocation());
UGameplayStatics::PlaySoundAtLocation(this, HitSound, GetActorLocation());
Destroy();
}
Destroy();
}
|
d9c68b034fc2d2686f6284002a9b87db93769376
|
d071485633d10dcb400bb8973e26444c0d7e4a9a
|
/piscine/D14M/ex00/.svn/text-base/Citron.cpp.svn-base
|
bfe614d0d5ac7152089013a7f45c6556e19de7bd
|
[] |
no_license
|
Adrien-Pasina/dev
|
948751fbeb7f23e0eac0442f7631ebd4aaa858ee
|
68150a965a1a5d77469d7d53f90726c9fafde0ac
|
refs/heads/master
| 2020-12-13T02:20:06.176233
| 2013-01-05T20:35:01
| 2013-01-05T20:35:01
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 107
|
Citron.cpp.svn-base
|
/**
*
*
*
*/
#include "Citron.h"
Citron::Citron()
: Fruit("citron", 3) {
}
Citron::~Citron() {
}
|
|
5340e8bae58f42d692e19a54605809a08d4a0892
|
bee676d8e8614d2a8f5c92b278bb4b02a01f561d
|
/src/day9/day9.hpp
|
debe6eff6f44b4a530f28fbfe17e9d77b42909eb
|
[] |
no_license
|
Egg3141592654/advent_of_code_2020
|
40e6af35fa7614902eb2a24e846d4f2f7abf0251
|
56812ce5b63e2a4748e80d895034605cc4f17064
|
refs/heads/main
| 2023-02-04T04:10:01.489484
| 2020-12-17T01:17:15
| 2020-12-17T01:17:15
| 317,685,363
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 150
|
hpp
|
day9.hpp
|
#pragma once
namespace day9 {
int get_bad_coded_number();
long get_sum_of_highest_and_lowest_numbers_in_contiguous_set_adding_to_part_1();
}
|
d5970b63650986bddbd20cc327e4cfd7ff373cfe
|
cd4587f46b5f1393e46459c7b7959455a847c0db
|
/source/digits_hits/src/GateReadout.cc
|
fffaf1858bfca5bfca975061f6b8768d0697d19f
|
[] |
no_license
|
lynch829/Gate
|
8072e7e30d855b15a9152a5884fc1357c07539bc
|
02754973dbaeca343a7c3b9402521f45c05e9ccf
|
refs/heads/develop
| 2021-01-24T20:13:11.821931
| 2016-07-12T11:23:15
| 2016-07-12T11:23:15
| 66,326,268
| 1
| 0
| null | 2016-08-23T02:33:29
| 2016-08-23T02:33:29
| null |
UTF-8
|
C++
| false
| false
| 14,902
|
cc
|
GateReadout.cc
|
/*----------------------
Copyright (C): OpenGATE Collaboration
This software is distributed under the terms
of the GNU Lesser General Public Licence (LGPL)
See GATE/LICENSE.txt for further details
----------------------*/
#include "GateReadout.hh"
#include "G4UnitsTable.hh"
#include "GateOutputVolumeID.hh"
#include "GateReadoutMessenger.hh"
#include "GateTools.hh"
#include "GateDigitizer.hh"
#include "GateArrayComponent.hh"
#include "GateVSystem.hh"
/*
S. Stute - June 2014: complete redesign of the readout module and add a new policy to emulate PMT.
- Fix bug in choosing the maximum energy pulse.We now have some temporary lists of variables to deal
with the output pulses. These output pulses are only created at the end of the method. In previous
versions, the output pulse was accumulating energy as long as input pulses were merged together, but
the problem is that the comparison of energy was done between the input pulse and this output pulse
with increasing energy. So with more than 2 pulses to be merged together, the behaviour was undefined.
- Move all the processing into the upper method ProcessPulseList instead of using the mother version
working into the ProcessOnePulse method. Thus the ProcessOnePulse in this class is not used anymore.
- Create policy choice: now we can choose via the messenger between EnergyWinner and EnergyCentroid.
- For the EnergyCentroid policy, the centroid position is computed using the crystal indices in each
direction, doing the computation with floating point numbers, and then casting the result into
integer indices. Using that method, we ensure the centroid position to be in a crystal (if we work
with global position, we can fall between two crystals in the presence of gaps).
The depth is ignored with this strategy; it is forced to be at one level above the 'crystal' level.
If there a 'layer' level below the 'crystal' level, an energy winner strategy is adopted.
*/
GateReadout::GateReadout(GatePulseProcessorChain* itsChain,
const G4String& itsName)
: GateVPulseProcessor(itsChain,itsName),
m_depth(1),
m_policy(READOUT_POLICY_WINNER)
{
m_messenger = new GateReadoutMessenger(this);
// S. Stute: These variables are used for the energy centroid strategy
m_nbCrystalsX = -1;
m_nbCrystalsY = -1;
m_nbCrystalsZ = -1;
m_nbCrystalsXY = -1;
m_crystalDepth = -1;
m_systemDepth = -1;
m_system = NULL;
m_crystalComponent = NULL;
}
GateReadout::~GateReadout()
{
delete m_messenger;
}
void GateReadout::SetPolicy(const G4String& aPolicy)
{
if (aPolicy=="TakeEnergyWinner") m_policy = READOUT_POLICY_WINNER;
else if (aPolicy=="TakeEnergyCentroid")
{
// Find useful stuff for centroid based computation
m_policy = READOUT_POLICY_CENTROID;
// Get the system
GateVSystem* m_system = this->GetChain()->GetSystem();
if (m_system==NULL) G4Exception( "GateReadout::ProcessPulseList", "ProcessPulseList", FatalException,
"Failed to get the system corresponding to that processor chain. Abort.\n");
// Get the array component corresponding to the crystal level using the name 'crystal'
GateArrayComponent* m_crystalComponent = m_system->FindArrayComponent("crystal");
if (m_crystalComponent==NULL) G4Exception( "GateReadout::ProcessPulseList", "ProcessPulseList", FatalException,
"Failed to get the array component corresponding to the crystal. Abort.\n");
// Get the number of crystals in each direction
m_nbCrystalsZ = m_crystalComponent->GetRepeatNumber(2);
m_nbCrystalsY = m_crystalComponent->GetRepeatNumber(1);
m_nbCrystalsX = m_crystalComponent->GetRepeatNumber(0);
m_nbCrystalsXY = m_nbCrystalsX * m_nbCrystalsY;
if (m_nbCrystalsX<1 || m_nbCrystalsY<1 || m_nbCrystalsZ<1)
G4Exception( "GateReadout::ProcessPulseList", "ProcessPulseList", FatalException,
"Crystal repeater numbers are wrong !\n");
//G4cout << "[" << GetObjectName() << "] -> Found crystal array with associated repeater: ["
// << m_nbCrystalsX << ";" << m_nbCrystalsY << ";" << m_nbCrystalsZ << "]\n";
// Get tree depth of the system
m_systemDepth = m_system->GetTreeDepth();
//G4cout << " Depth of the system: " << m_systemDepth << Gateendl;
// Find the crystal depth in the system
GateSystemComponent* this_component = m_system->GetBaseComponent();
m_crystalDepth = 0;
while (this_component!=m_crystalComponent && m_crystalDepth+1<m_systemDepth)
{
this_component = this_component->GetChildComponent(0);
m_crystalDepth++;
}
if (this_component!=m_crystalComponent) G4Exception( "GateReadout::ProcessPulseList", "ProcessPulseList", FatalException,
"Failed to get the system depth corresponding to the crystal. Abort.\n");
//G4cout << " Crystal depth: " << m_crystalDepth << Gateendl;
// Now force m_depth to be right above the crystal depth
m_depth = m_crystalDepth - 1;
}
else G4Exception( "GateReadout::SetPolicy", "SetPolicy", FatalException, "Unknown provided policy, please see the guidance. Abort.\n");
}
// S. Stute: This function is virtual (but not pure) in the mother GateVPulseProcessor.
// We now overload it in order to be able to process all the pulses at a same time (not using the ProcessOnePulse method).
// This is only to be able to program the option EnergyCentroid based on crystal indices.
// So the ProcessOnePulse method right after this one is not used anymore.
// Note: this new strategy also allowed us to correct the bug for the energyWinner policy.
GatePulseList* GateReadout::ProcessPulseList(const GatePulseList* inputPulseList)
{
if (!inputPulseList)
return 0;
size_t n_pulses = inputPulseList->size();
if (nVerboseLevel>1)
G4cout << "[" << GetObjectName() << "::ProcessPulseList]: processing input list with " << n_pulses << " entries\n";
if (!n_pulses)
return 0;
GatePulseList* outputPulseList = new GatePulseList(GetObjectName());
// S. Stute: these variables are used for the energy centroid policy
G4double* final_time = NULL;
G4double* final_crystal_posX = NULL;
G4double* final_crystal_posY = NULL;
G4double* final_crystal_posZ = NULL;
G4double* final_energy = NULL;
G4int* final_nb_pulses = NULL;
GatePulse** final_pulses = NULL;
if (m_policy==READOUT_POLICY_CENTROID)
{
final_time = (G4double*)calloc(n_pulses,sizeof(G4double));
final_crystal_posX = (G4double*)calloc(n_pulses,sizeof(G4double));
final_crystal_posY = (G4double*)calloc(n_pulses,sizeof(G4double));
final_crystal_posZ = (G4double*)calloc(n_pulses,sizeof(G4double));
final_nb_pulses = (G4int*)calloc(n_pulses,sizeof(G4int));
}
// S. Stute: we need energy to sum up correctly for all output pulses and affect only at the end.
// In previous versions, even for take Winner, the energy was affected online so the
// final pulse was not the winner in all cases.
final_energy = (G4double*)calloc(n_pulses,sizeof(G4double));
final_pulses = (GatePulse**)calloc(n_pulses,sizeof(GatePulse*));
G4int final_nb_out_pulses = 0;
// Start loop on input pulses
GatePulseConstIterator iterIn;
for (iterIn = inputPulseList->begin() ; iterIn != inputPulseList->end() ; ++iterIn)
{
GatePulse* inputPulse = *iterIn;
const GateOutputVolumeID& blockID = inputPulse->GetOutputVolumeID().Top(m_depth);
if (blockID.IsInvalid())
{
if (nVerboseLevel>1)
G4cout << "[GateReadout::ProcessOnePulse]: out-of-block hit for \n"
<< *inputPulse << Gateendl
<< " -> pulse ignored\n\n";
continue;
}
// Loop inside the temporary output list to see if we have one pulse with same blockID as input
int this_output_pulse = 0;
for (this_output_pulse=0; this_output_pulse<final_nb_out_pulses; this_output_pulse++)
if (final_pulses[this_output_pulse]->GetOutputVolumeID().Top(m_depth) == blockID) break;
// Case: we found an output pulse with same blockID
if ( this_output_pulse!=final_nb_out_pulses )
{
// --------------------------------------------------------------------------------
// WinnerTakeAllPolicy (APD like)
// --------------------------------------------------------------------------------
if (m_policy==READOUT_POLICY_WINNER)
{
// If energy is higher then replace the pulse by the new one
if ( inputPulse->GetEnergy() > final_pulses[this_output_pulse]->GetEnergy() ) final_pulses[this_output_pulse] = inputPulse;
final_energy[this_output_pulse] += inputPulse->GetEnergy();
}
// --------------------------------------------------------------------------------
// EnergyCentroidPolicy1 (like block PMT)
// --------------------------------------------------------------------------------
else if (m_policy==READOUT_POLICY_CENTROID) // Crystal element is considered to be the deepest element
{
// First, if the energy of this pulse is higher than the previous one, take it as the reference
// in order to have an EnergyWinner policy at levels below the crystal, if any.
// The final energy and crystal position will be modified at the end anyway.
if ( inputPulse->GetEnergy() > final_pulses[this_output_pulse]->GetEnergy() ) final_pulses[this_output_pulse] = inputPulse;
// Add the energy to get the total
G4double energy = inputPulse->GetEnergy();
final_energy[this_output_pulse] += energy;
// Add the time in order to compute the mean time at the end
final_time[this_output_pulse] += inputPulse->GetTime();
// Get the crystal ID
int crystal_id = inputPulse->GetComponentID(m_crystalDepth);
// Decompose the crystal_id into X, Y and Z
int tmp_crysXY = crystal_id % m_nbCrystalsXY;
final_crystal_posZ[this_output_pulse] += energy * (((G4double)( crystal_id / m_nbCrystalsXY ))+0.5);
final_crystal_posY[this_output_pulse] += energy * (((G4double)( tmp_crysXY / m_nbCrystalsX ))+0.5);
final_crystal_posX[this_output_pulse] += energy * (((G4double)( tmp_crysXY % m_nbCrystalsX ))+0.5);
// Increment the number of pulses contributing to this output pulse
final_nb_pulses[this_output_pulse]++;
}
else
{
G4Exception( "GateReadout::ProcessOnePulse", "ProcessOnePulse", FatalException, "Unknown readout policy, this is an internal error. Abort.\n");
}
}
// Case: there is no output pulse with same blockID
else
{
G4double energy = inputPulse->GetEnergy();
if (m_policy==READOUT_POLICY_CENTROID)
{
// Time will be averaged then
final_time[final_nb_out_pulses] = inputPulse->GetTime();
// Currently there is one pulse contributing to this new pulse
final_nb_pulses[final_nb_out_pulses] = 1;
// Get the crystal ID
int crystal_id = inputPulse->GetComponentID(m_crystalDepth);
// Decompose the crystal_id into X, Y and Z
int tmp_crysXY = crystal_id % m_nbCrystalsXY;
final_crystal_posZ[final_nb_out_pulses] = energy * (((G4double)( crystal_id / m_nbCrystalsXY ))+0.5);
final_crystal_posY[final_nb_out_pulses] = energy * (((G4double)( tmp_crysXY / m_nbCrystalsX ))+0.5);
final_crystal_posX[final_nb_out_pulses] = energy * (((G4double)( tmp_crysXY % m_nbCrystalsX ))+0.5);
}
// Set the current energy
final_energy[final_nb_out_pulses] += energy;
// Store this pulse in the list
final_pulses[final_nb_out_pulses] = inputPulse;
// Increment the total number of output pulses
final_nb_out_pulses++;
}
} // End for input pulse
// S. Stute: create now the output pulse list
for (int p=0; p<final_nb_out_pulses; p++)
{
// Create the pulse
GatePulse* outputPulse = new GatePulse( final_pulses[p] );
// Affect energy
outputPulse->SetEnergy( final_energy[p] );
// Special affectations for centroid policy
if (m_policy==READOUT_POLICY_CENTROID)
{
// Affect time being the mean
outputPulse->SetTime( final_time[p] / ((G4double)final_nb_pulses[p]) );
// Compute integer crystal indices weighted by total energy
G4int crys_posX = ((G4int)(final_crystal_posX[p]/final_energy[p]));
G4int crys_posY = ((G4int)(final_crystal_posY[p]/final_energy[p]));
G4int crys_posZ = ((G4int)(final_crystal_posZ[p]/final_energy[p]));
// Compute final crystal id
G4int crystal_id = crys_posZ * m_nbCrystalsXY + crys_posY * m_nbCrystalsX + crys_posX;
// We change the level of the volumeID and the outputVolumeID corresponding to the crystal with the new crystal ID
outputPulse->ChangeVolumeIDAndOutputVolumeIDValue(m_crystalDepth,crystal_id);
// Change coordinates (we choose here to place the coordinates at the center of the chosen crystal)
//outputPulse->SetGlobalPos(m_system->ComputeObjectCenter(volID));
outputPulse->ResetGlobalPos(m_system);
outputPulse->ResetLocalPos();
}
if (nVerboseLevel>1)
G4cout << "Created new pulse for block " << outputPulse->GetOutputVolumeID().Top(m_depth) << ".\n"
<< "Resulting pulse is: \n"
<< *outputPulse << Gateendl << Gateendl ;
outputPulseList->push_back(outputPulse);
}
// Free temporary variables used by the centroid policy
if (m_policy==READOUT_POLICY_CENTROID)
{
free(final_time);
free(final_crystal_posX);
free(final_crystal_posY);
free(final_crystal_posZ);
free(final_nb_pulses);
}
// Free other variables
free(final_energy);
free(final_pulses);
if (nVerboseLevel==1)
{
G4cout << "[" << GetObjectName() << "::ProcessPulseList]: returning output pulse-list with " << outputPulseList->size() << " entries\n";
GatePulseIterator iterOut;
for (iterOut = outputPulseList->begin() ; iterOut != outputPulseList->end() ; ++iterOut)
G4cout << **iterOut << Gateendl;
G4cout << Gateendl;
}
return outputPulseList;
}
// S. Stute: obsolete method which is not used anymore. The content was moved in upper method ProcessPulseList overloaded right above.
void GateReadout::ProcessOnePulse(const GatePulse* ,GatePulseList& )
{
}
void GateReadout::DescribeMyself(size_t indent)
{
G4cout << GateTools::Indent(indent) << "Readout at depth: " << m_depth << Gateendl;
G4cout << GateTools::Indent(indent) << " --> policy: ";
if (m_policy==READOUT_POLICY_WINNER) G4cout << "TakeEnergyWinner\n";
else if (m_policy==READOUT_POLICY_CENTROID) G4cout << "TakeEnergyCentroid\n";
else G4cout << "Unknown policy !\n";
}
|
b9f049b360e7251da2f7ae8c481c00c002237486
|
133f855d21c8c8e7c063a8bc1fad8d22a87d1756
|
/AlphaClient/AlphaGraph/CGeometryBufferD3D9.h
|
45dd6a7745104a5ad0d1784abfd5b63fc72c25cd
|
[
"MIT"
] |
permissive
|
xujianming/Alpha
|
82510ef4ba867afe5ee3536f7e1b5c4bc2e3ec69
|
641f17b8091deede9869056cd62868c76035c975
|
refs/heads/master
| 2021-01-10T19:24:27.020806
| 2015-12-20T16:10:20
| 2015-12-20T16:10:20
| 20,998,143
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 756
|
h
|
CGeometryBufferD3D9.h
|
#pragma once
#include <d3d9.h>
#include "CGeometryBuffer.h"
class CGeometryBufferD3D9: public CGeometryBuffer
{
public:
CGeometryBufferD3D9(CGraphic* pGraphic, EResourceType eResType);
virtual void OnFreeMemory();
IDirect3DResource9* GetD3DBuffer();
protected:
IDirect3DResource9* m_pD3DBuffer;
};
class CVertexBufferD3D9: public CGeometryBufferD3D9
{
public:
CVertexBufferD3D9(CGraphic* pGraphic);
bool IsVertexBuffer() { return true; }
bool Lock(bool bDiscard);
void UnLock();
protected:
bool CheckBuffer();
};
class CIndexBufferD3D9: public CGeometryBufferD3D9
{
public:
CIndexBufferD3D9(CGraphic* pGraphic);
bool IsVertexBuffer() { return false; }
bool Lock(bool bDiscard);
void UnLock();
protected:
bool CheckBuffer();
};
|
5c48ff1deae3f634e5f47a47024488571cb1195f
|
db2dd87ccd792b7e94b520f178b31f96131fcbca
|
/UpdateEquation.h
|
49929ab4422d4b6256e692da374c6a7846c38981
|
[] |
no_license
|
plisdku/trogdor
|
84e9daced6476d466370bb70342fef843e59cf35
|
18c57f237bbd1f21a6437eb89083b29512611c05
|
refs/heads/master
| 2021-01-19T08:15:33.229622
| 2014-01-28T21:00:51
| 2014-01-28T21:00:51
| 16,267,724
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,812
|
h
|
UpdateEquation.h
|
/*
* Material.h
* TROGDOR
*
* Created by Paul Hansen on 7/18/09.
* Copyright 2009 Stanford University. All rights reserved.
*
*/
#ifndef _UPDATEEQUATION_
#define _UPDATEEQUATION_
#include "Pointer.h"
#include "geometry.h"
#include <string>
#include <iostream>
class VoxelizedPartition;
class CalculationPartition;
class CurrentSource;
class UpdateEquation
{
public:
UpdateEquation();
virtual ~UpdateEquation();
void setSubstanceName(const std::string & name) { mSubstanceName = name; }
const std::string & substanceName() const { return mSubstanceName; }
void setID(int id) { mID = id; }
int id() const { return mID; }
virtual void setCurrentSource(CurrentSource* source);
virtual void allocateAuxBuffers();
virtual void calcEPhase(int direction) = 0;
virtual void calcHPhase(int direction) = 0;
virtual long numRunlinesE() const = 0;
virtual long numRunlinesH() const = 0;
virtual long numHalfCellsE() const = 0;
virtual long numHalfCellsH() const = 0;
virtual void writeJ(int direction, std::ostream & binaryStream,
long startingIndex, const float* startingField, long length) const;
virtual void writeP(int direction, std::ostream & binaryStream,
long startingIndex, const float* startingField, long length) const;
virtual void writeK(int direction, std::ostream & binaryStream,
long startingIndex, const float* startingField, long length) const;
virtual void writeM(int direction, std::ostream & binaryStream,
long startingIndex, const float* startingField, long length) const;
virtual std::string modelName() const = 0;
private:
int mID;
std::string mSubstanceName;
};
typedef Pointer<UpdateEquation> UpdateEquationPtr;
#endif
|
bc5bdd3e3a4a0fc982d377743823fc61fb92a063
|
5639f3447de2c12b454461c1524522c3b6c13a52
|
/CPU-Scheduling/os_priority.cpp
|
d505de5cd448a155e91c37d7e830add5ef590614
|
[] |
no_license
|
dmhere/operating-systems
|
2c0004c067048b29403bede3f9eaaa20da4f1716
|
70162e9120638b5692ea424d78e40fe147f2c6ca
|
refs/heads/master
| 2021-05-08T07:37:44.081905
| 2017-11-24T10:55:54
| 2017-11-24T10:55:54
| 106,785,402
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,317
|
cpp
|
os_priority.cpp
|
#include<iostream>
using namespace std;
int main()
{
int n;
cout << "Enter the number of processes --- ";
cin >> n;
int p[n],bt[n],pri[n], wt[n],tat[n],i, k, temp;
float wtavg, tatavg;
for(i=0;i<n;i++)
{
p[i] = i;
cout << "Enter the Burst Time & Priority of Process "<<i<<" --- ";
cin >>bt[i]>>pri[i];
}
for(i=0;i<n;i++)
for(k=i+1;k<n;k++)
if(pri[i] > pri[k])
{
temp=p[i];
p[i]=p[k];
p[k]=temp;
temp=bt[i];
bt[i]=bt[k];
bt[k]=temp;
temp=pri[i];
pri[i]=pri[k];
pri[k]=temp;
}
wtavg = wt[0] = 0;
tatavg = tat[0] = bt[0];
for(i=1;i<n;i++)
{
wt[i] = wt[i-1] + bt[i-1];
tat[i] = tat[i-1] + bt[i];
wtavg = wtavg + wt[i];
tatavg = tatavg + tat[i];
}
cout << "\nPROCESS\t\tPRIORITY\tBURST TIME\tWAITING TIME\tTURNAROUND TIME";
for(i=0;i<n;i++)
cout << "\n"<<p[i]<<" \t\t "<<pri[i]<<" \t\t "<<bt[i]<<" \t\t "<<wt[i]<<" \t\t "<<tat[i];
cout << "\nAverage Waiting Time is --- "<<wtavg/n;
cout << "\nAverage Turnaround Time is --- "<<tatavg/n;
return 0;
}
|
7e8b77dd59e09056e2bca79155c84773290c27e8
|
a4ea1679e3febc4064946cd0afc980c692f7817e
|
/Lab6/queue-starter/QueueTester.h
|
2254b95a8ca4e0eba66bd7e5377804733fba79a7
|
[] |
no_license
|
jdavis37/Labs
|
a8f3137d3ba07790f45d9248eb0ea98dfba421d4
|
efb357f9981d54d736c6cccd1353914f158f38d9
|
refs/heads/master
| 2020-08-06T09:19:48.437298
| 2019-11-20T09:28:09
| 2019-11-20T09:28:09
| 212,921,394
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 766
|
h
|
QueueTester.h
|
#ifndef QUEUETESTER_H
#define QUEUETESTER_H
#include "Queue.h"
#include <iostream>
class QueueTester: public Queue
{
private:
Queue MyQueue;
public:
QueueTester();
~QueueTester();
void PrintResult(bool result);
void TestConstructorEmpty();
void TestConstructorPeek();
void TestEnqueuePeek();
void TestEnqueueEmpty();
void TestEnqueueEmptyMultiple();
void TestEnqueuePeekMultiple();
void TestEnqueuePeekMultiple2();
void TestEnqueueEmptyMultiple2();
void TestDequeueSingleEmpty();
void TestDequeueSinglePeek();
void TestDequeueOnEmpty();
void TestEnqueueDequeueMultiplePeek();
void TestEnqueueDequeueMultipleEmpty();
void TestEnqueueDequeueOBO();
};
#endif
|
ff14464aa3b765c44debb75be3908ecd8d3a1b55
|
779af6df217c38a9ad0fd999f8536752d54167a1
|
/students/alexeyqu/Stack/Stack_perverted_functions.cpp
|
bebcbf705917fe7242ef251d7ca901d04a6d5f2f
|
[] |
no_license
|
MIPT-ILab/programming-course
|
f55e6fc336dd70faae6b2d2eecb64bc5aebbf67b
|
95e991c79813b1c44cb30e8ce588677eb30fc18c
|
refs/heads/master
| 2021-01-19T16:09:30.385336
| 2017-04-14T20:12:05
| 2017-04-14T20:12:05
| 88,251,879
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,856
|
cpp
|
Stack_perverted_functions.cpp
|
/** ***************************************************************************
* @file Stack_perverted_functions.cpp
******************************************************************************/
#include "Stack.h"
int Stack_Perverted_Push (Stack_t* stack, const double value)
{
STACK_CHECK (stack);
if (Stack_Is_Full (stack))
{
Need_More_Memory (stack);
}
if (stack->cur_size == 0)
{
Stack_Push (stack, value);
STACK_CHECK (stack);
return 0;
}
Stack_t stack_2 = {}, stack_3 = {};
Stack_Construct (&stack_2);
Stack_Construct (&stack_3);
Stack_Space_Cpy (stack, &stack_2);
Stack_Space_Cpy (stack, &stack_3);
assert (Stack_Is_OK (&stack_2));
assert (Stack_Is_OK (&stack_3));
Tower_Move (stack, &stack_2, &stack_3, stack->cur_size);
Stack_Push (stack, value);
Tower_Move (&stack_2, stack, &stack_3, stack_2.cur_size);
STACK_CHECK (stack);
Stack_Destruct (&stack_2);
Stack_Destruct (&stack_3);
return 0;
}
int Stack_Perverted_Pop (Stack_t* stack, double* value)
{
STACK_CHECK (stack);
if (Stack_Is_Empty (stack)) return 1;
if (stack->cur_size == 1)
{
*value = stack->my_stack_data[--stack->cur_size];
STACK_CHECK (stack);
return 0;
}
Stack_t stack_2 = {}, stack_3 = {};
Stack_Construct (&stack_2);
Stack_Construct (&stack_3);
Stack_Space_Cpy (stack, &stack_2);
Stack_Space_Cpy (stack, &stack_3);
assert (Stack_Is_OK (&stack_2));
assert (Stack_Is_OK (&stack_3));
Tower_Move (stack, &stack_2, &stack_3, stack->cur_size - 1);
Stack_Pop (stack, value);
Tower_Move (&stack_2, stack, &stack_3, stack_2.cur_size);
STACK_CHECK (stack);
Stack_Destruct (&stack_2);
Stack_Destruct (&stack_3);
return 0;
}
void Stack_Space_Cpy (const Stack_t* from, Stack_t* to)
{
STACK_CHECK (from);
STACK_CHECK (to);
to->isenable = from->isenable;
to->max_size = from->max_size;
to->my_stack_data = (double* ) realloc (to->my_stack_data, to->max_size * sizeof (double));
STACK_CHECK (from);
STACK_CHECK (to);
}
void Tower_Move (Stack_t* from_stack, Stack_t* to_stack, Stack_t* temp_stack,
const int num_left)
{
STACK_CHECK (from_stack);
STACK_CHECK (to_stack);
STACK_CHECK (temp_stack);
if (num_left == 1)
{
to_stack->my_stack_data[to_stack->cur_size++] = from_stack->my_stack_data[--from_stack->cur_size];
return;
}
Tower_Move (from_stack, temp_stack, to_stack, num_left - 1);
to_stack->my_stack_data[to_stack->cur_size++] = from_stack->my_stack_data[--from_stack->cur_size];
Tower_Move (temp_stack, to_stack, from_stack, num_left - 1);
STACK_CHECK (from_stack);
STACK_CHECK (to_stack);
STACK_CHECK (temp_stack);
}
|
5f521961ff7f231f143c172f37f6f528fddf8bf0
|
028e188d85c2cbeb1ff853420664b0e564e0b0ce
|
/cpp/im/clientgui/clientgui/friendlist.cpp
|
2895d377eca7a7c822fb230dd64552ecedc82124
|
[] |
no_license
|
passedaway/misc
|
55e79083429a6aeb85f703fde389a9914773c9f5
|
f97070f698f6c07a9f391a3e3d28e8ec3d8b5d26
|
refs/heads/master
| 2021-01-02T08:33:55.695610
| 2016-09-22T12:11:19
| 2016-09-22T12:11:19
| 8,695,355
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,823
|
cpp
|
friendlist.cpp
|
/******************************************************************************/
/* Filename: friendlist.cpp */
/* Description: have the friend name, every sclientsocket has one firnelist*/
/* */
/* Author:zhaocq (changqing.1230@163.com) 2011/5/24 */
/******************************************************************************/
#include "friendlist.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/***************************************************************************************************
功能说明:初始化friendlist
参数说明:
输入参数:无
输出参数:无
返回:friendlist
***************************************************************************************************/
FriendList* friendlist_init()
{
FriendList *flt = (FriendList *)malloc(sizeof (FriendList));
flt->head = NULL;
flt->end = NULL;
return flt;
}
/***************************************************************************************************
功能说明:去初始化friendlist
参数说明:
输入参数:friendlist
输出参数:无
返回:无
***************************************************************************************************/
void friendlist_exit(FriendList *flt)
{
if(flt == NULL)
return;
else if(flt->head == NULL)
{
free(flt);
flt = NULL;
return;
}
else{
Friend *tmp = flt->head;
while(tmp != NULL)
{
tmp = flt->head;
flt->head = flt->head->next;
free(tmp);
tmp = NULL;
}
free(flt->end);
flt->head = flt->end = NULL;
free(flt);
flt = NULL;
}
}
/***************************************************************************************************
功能说明:friendlist 添加friend链
参数说明:
输入参数:friend
输出参数:无
返回:成功 1,错误 0
***************************************************************************************************/
int friendlist_add(FriendList *flt, Friend *fr)
{
if(fr == NULL || flt == NULL)
return 0;
else{
if(flt->head == NULL)
{
flt->head = fr;
flt->end = flt->head;
flt->end->next = NULL;
}else{
flt->end->next = fr;
flt->end = fr;
fr->next = NULL;
}
return 1;
}
return 0;
}
/***************************************************************************************************
功能说明:friendlist 删除friend链
参数说明:
输入参数:friend
输出参数:无
返回:成功 1,错误 0
***************************************************************************************************/
int friendlsit_del(FriendList *flt, char *userno)
{
Friend *dest = NULL;
if(userno == NULL || flt == NULL)
return 0;
else if(flt->head == NULL)
return 0;
for(dest = flt->head; dest != NULL; dest = dest->next)
if(!strncmp(userno, dest->userno, 6))
break;
if(dest)
{
if(dest == flt->head)
{
//删除头
if(flt->head == flt->end)
flt->head = flt->end = NULL;
else
flt->head = flt->head->next;
free(dest);
return 1;
}else{
Friend *pre = NULL;
for(pre = flt->head; pre->next != NULL && pre->next != dest; pre = pre->next)
;
if(pre->next == dest)
{
pre->next = dest->next;
free(dest);
return 1;
}
}
}
return 0;
}
Friend *friendlist_search(FriendList *flt, char *userno)
{
if(flt == NULL || userno == NULL)
{
return NULL;
}else{
Friend *tmp = flt->head;
while(tmp != NULL)
{
if( !strncmp(tmp->userno, userno, 6) )
{
return tmp;
}
tmp = tmp->next;
}
}
return NULL;
}
|
968126e172a137a0c4f053586ec0fe88dc06a3b6
|
a812f83ac38858f95725f1f8dd7b6ac1e0da71c0
|
/include/catrandomvar.hpp
|
f7d68aa5f886ce588b2f8654a5b68ed9e96d4028
|
[
"MIT"
] |
permissive
|
Viva-Lambda/randomvar
|
a40d84dcea6116e507343b6d92ce4d71e65689a8
|
f5204e4332343e49e89a971b07e676ec8ec793ce
|
refs/heads/master
| 2023-06-16T12:33:11.511165
| 2021-07-09T05:15:06
| 2021-07-09T05:15:06
| 384,274,517
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,283
|
hpp
|
catrandomvar.hpp
|
#pragma once
// represents random variable
#include <external.hpp>
#include <randomvar.hpp>
using namespace randomvar;
namespace randomvar {
template <class InVal, class OutVal> struct CatRVar {
std::string id;
std::function<OutVal(InVal)> fn;
std::vector<InVal> data;
CatRVar() {}
CatRVar(const std::string &varid, const std::function<OutVal(InVal)> &_fn,
const std::vector<InVal> &vdata)
: id(varid), fn(_fn), data(vdata) {}
};
template <class InVal, class OutVal, class DistVal, class RVar>
struct CatRandomVar : RandomVar<InVal, OutVal, DistVal, RVar> {
/**\brief Probability mass function of a categorical random variable*/
bool pmf(const RVar &var, OutVal x, DistVal &out) const { return false; }
bool mode(const RVar &var, DistVal &out) const { return false; }
};
template <class InVal, class OutVal, class DistVal>
struct CatRVarDist : CatRVar<InVal, OutVal> {
std::function<bool(OutVal, DistVal &)> dist;
CatRVarDist() : CatRVar<InVal, OutVal>() {}
CatRVarDist(const std::string &varid, const std::function<OutVal(InVal)> &_fn,
const std::vector<InVal> &vdata,
const std::function<bool(OutVal, DistVal &)> &d)
: CatRVar<InVal, OutVal>(varid, _fn, vdata), dist(d) {}
};
} // namespace randomvar
|
4d3ca4b28e15f1e08ec87cc90ac1273ed62f6d84
|
261f84525af86037f6e32f9234e44f74edefa621
|
/Ohjelmointi 3 harjoitustyö/Game/plane.h
|
ca18c456cf21824aba40a8389b87cb6a8b059fc1
|
[] |
no_license
|
kkemppi/TIE-courses
|
7cf0232b281e60b70e01e98da0febd6b92dcbe33
|
8a28a71120eb03213cbf1c18d6eed1d8df6fd820
|
refs/heads/master
| 2022-10-17T00:56:48.542490
| 2022-09-30T17:30:28
| 2022-09-30T17:30:28
| 231,389,998
| 0
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,120
|
h
|
plane.h
|
#ifndef PLANE_H
#define PLANE_H
#include <QObject>
#include <QGraphicsPixmapItem>
/**
*@file
* @brief Defines a class for enemyplanes flying horizontally and vertically in scene
*/
const int X_MIN = 0;
const int X_MAX = 1095;
const int Y_MIN = 0;
const int Y_MAX = 592;
namespace Students {
class Plane : public QObject, public QGraphicsPixmapItem
{
Q_OBJECT
public:
Plane();
/**
* @brief if plane flies out of map it will be removed and removePlane will be emitted
* @return true if position is valid, false if position is out of map
*/
bool checkPos();
/**
* @brief sets plane status to destroyed and sets correct pixmap
*/
void destroy();
bool status() const;
signals:
/**
* @brief remove plane signal will emit to bettermainwindow planeremoved slot
* @param pointer to plane that will be removed
*/
void removePlane(Plane *);
public slots:
/**
* @brief plane is moved every timer tick to correct direction
*/
void move();
private:
int direction_;
int speed_;
bool status_;
};
}
#endif // PLANE_H
|
493ff089802d60db490cac5ffd28b6d675e6d849
|
7a24b458b3211b52707dc87f7108e021f041dea0
|
/1356.根据数字二进制下-1-的数目排序.cpp
|
9e222a263beade51d267ba3cb839729ec6bdc5d9
|
[] |
no_license
|
Zzzode/myLeetCode
|
225570b3c635895d3909afa5d994c8f5191f3002
|
ecfc3322feab67a0e47a6a2d612ef70c3709fedd
|
refs/heads/master
| 2023-03-02T22:54:05.490320
| 2021-02-05T14:30:19
| 2021-02-05T14:30:19
| 295,231,282
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,028
|
cpp
|
1356.根据数字二进制下-1-的数目排序.cpp
|
/*
* @lc app=leetcode.cn id=1356 lang=cpp
*
* [1356] 根据数字二进制下 1 的数目排序
*
* https://leetcode-cn.com/problems/sort-integers-by-the-number-of-1-bits/description/
*
* algorithms
* Easy (67.45%)
* Likes: 34
* Dislikes: 0
* Total Accepted: 10.9K
* Total Submissions: 15.8K
* Testcase Example: '[0,1,2,3,4,5,6,7,8]'
*
* 给你一个整数数组 arr 。请你将数组中的元素按照其二进制表示中数字 1
* 的数目升序排序。
*
* 如果存在多个数字二进制中 1 的数目相同,则必须将它们按照数值大小升序排列。
*
* 请你返回排序后的数组。
*
*
*
* 示例 1:
*
* 输入:arr = [0,1,2,3,4,5,6,7,8]
* 输出:[0,1,2,4,8,3,5,6,7]
* 解释:[0] 是唯一一个有 0 个 1 的数。
* [1,2,4,8] 都有 1 个 1 。
* [3,5,6] 有 2 个 1 。
* [7] 有 3 个 1 。
* 按照 1 的个数排序得到的结果数组为 [0,1,2,4,8,3,5,6,7]
*
*
* 示例 2:
*
* 输入:arr = [1024,512,256,128,64,32,16,8,4,2,1]
* 输出:[1,2,4,8,16,32,64,128,256,512,1024]
* 解释:数组中所有整数二进制下都只有 1 个 1
* ,所以你需要按照数值大小将它们排序。
*
*
* 示例 3:
*
* 输入:arr = [10000,10000]
* 输出:[10000,10000]
*
*
* 示例 4:
*
* 输入:arr = [2,3,5,7,11,13,17,19]
* 输出:[2,3,5,17,7,11,13,19]
*
*
* 示例 5:
*
* 输入:arr = [10,100,1000,10000]
* 输出:[10,100,10000,1000]
*
*
*
*
* 提示:
*
*
* 1 <= arr.length <= 500
* 0 <= arr[i] <= 10^4
*
*
*/
#include "Header.h"
// @lc code=start
class Solution {
public:
vector<int> sortByBits(vector<int>& arr) {
vector<int> ans;
map<int, multiset<int>> ms;
for (int i = 0; i < arr.size(); i++) ms[count(arr[i])].emplace(arr[i]);
for (auto& m : ms)
for (auto& n : m.second) ans.emplace_back(n);
return ans;
}
int count(int n) {
int res = 0;
while (n) {
if (n % 2) res++;
n /= 2;
}
return res;
}
};
// @lc code=end
|
3ab9acc5e3a5d8f0c80ee0f1ee0acc440d86d6de
|
1c3dcf16dc132d5adf4a3358fe62b8d788f65954
|
/cdflib/beta_log.cpp
|
35a24a36a9e54f585159ab3d13055344d122f56e
|
[] |
no_license
|
LucDemortier/pValueMethods
|
56febfe8e1422ef2717d5f0ab65059e61ecee143
|
7caa8de666574569b136f1998d18929b8626179e
|
refs/heads/master
| 2021-08-28T18:23:06.926067
| 2021-08-08T04:02:20
| 2021-08-08T04:02:20
| 102,071,499
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,766
|
cpp
|
beta_log.cpp
|
# include <iomanip>
# include <cmath>
using namespace std;
# include "cdflib.hpp"
//****************************************************************************80
double beta_log ( double *a0, double *b0 )
//****************************************************************************80
//
// Purpose:
//
// BETA_LOG evaluates the logarithm of the beta function.
//
// Reference:
//
// Armido DiDinato and Alfred Morris,
// Algorithm 708:
// Significant Digit Computation of the Incomplete Beta Function Ratios,
// ACM Transactions on Mathematical Software,
// Volume 18, 1993, pages 360-373.
//
// Parameters:
//
// Input, double *A0, *B0, the parameters of the function.
// A0 and B0 should be nonnegative.
//
// Output, double *BETA_LOG, the value of the logarithm
// of the Beta function.
//
{
static double e = .918938533204673e0;
static double value,a,b,c,h,u,v,w,z;
static int i,n;
static double T1;
a = fifdmin1(*a0,*b0);
b = fifdmax1(*a0,*b0);
if(a >= 8.0e0) goto S100;
if(a >= 1.0e0) goto S20;
//
// PROCEDURE WHEN A .LT. 1
//
if(b >= 8.0e0) goto S10;
T1 = a+b;
value = gamma_log ( &a )+( gamma_log ( &b )- gamma_log ( &T1 ));
return value;
S10:
value = gamma_log ( &a )+algdiv(&a,&b);
return value;
S20:
//
// PROCEDURE WHEN 1 .LE. A .LT. 8
//
if(a > 2.0e0) goto S40;
if(b > 2.0e0) goto S30;
value = gamma_log ( &a )+ gamma_log ( &b )-gsumln(&a,&b);
return value;
S30:
w = 0.0e0;
if(b < 8.0e0) goto S60;
value = gamma_log ( &a )+algdiv(&a,&b);
return value;
S40:
//
// REDUCTION OF A WHEN B .LE. 1000
//
if(b > 1000.0e0) goto S80;
n = ( int ) ( a - 1.0e0 );
w = 1.0e0;
for ( i = 1; i <= n; i++ )
{
a -= 1.0e0;
h = a/b;
w *= (h/(1.0e0+h));
}
w = log(w);
if(b < 8.0e0) goto S60;
value = w+ gamma_log ( &a )+algdiv(&a,&b);
return value;
S60:
//
// REDUCTION OF B WHEN B .LT. 8
//
n = ( int ) ( b - 1.0e0 );
z = 1.0e0;
for ( i = 1; i <= n; i++ )
{
b -= 1.0e0;
z *= (b/(a+b));
}
value = w+log(z)+( gamma_log ( &a )+( gamma_log ( &b )-gsumln(&a,&b)));
return value;
S80:
//
// REDUCTION OF A WHEN B .GT. 1000
//
n = ( int ) ( a - 1.0e0 );
w = 1.0e0;
for ( i = 1; i <= n; i++ )
{
a -= 1.0e0;
w *= (a/(1.0e0+a/b));
}
value = log(w)-(double)n*log(b)+( gamma_log ( &a )+algdiv(&a,&b));
return value;
S100:
//
// PROCEDURE WHEN A .GE. 8
//
w = bcorr(&a,&b);
h = a/b;
c = h/(1.0e0+h);
u = -((a-0.5e0)*log(c));
v = b*alnrel(&h);
if(u <= v) goto S110;
value = -(0.5e0*log(b))+e+w-v-u;
return value;
S110:
value = -(0.5e0*log(b))+e+w-u-v;
return value;
}
|
95c354497687fe2e64d6fb37fa770f99e9b2a091
|
67ad3d5a2eebc2bd601da4e08f7a585b2ae3ed92
|
/Practica 2/GRASP/grasp.cpp
|
ddb163226d692d094026ab7834c0e4fb85c9530a
|
[] |
no_license
|
Espectro123/Metaheuristics_Practices
|
7536740c41019dfe0f816b0b15b60caebf2a5f85
|
ba254ce3f94518a90b64eeeda42fc5d94dc945a1
|
refs/heads/master
| 2020-04-09T18:31:15.598997
| 2018-12-05T12:40:30
| 2018-12-05T12:40:30
| 160,514,951
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,179
|
cpp
|
grasp.cpp
|
#include <iostream>
#include <utility>
#include <fstream>
#include <vector>
#include <stdlib.h>
#include <time.h>
#include <ctime>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
//Generador de numeros aleatorios
#define MASK 2147483647
#define PRIME 65539
#define SCALE 0.4656612875e-9
#define Rand() (( Seed = ( (Seed * PRIME) & MASK) ) * SCALE )
#define Randint(low,high) ( (int) (low + (high-(low)+1) * Rand()))
#define Randfloat(low,high) ( (low + (high-(low))*Rand()))
using namespace std;
//Variables glovales
int evaulaciones = 0;
int** matriz_flujo;
int** matriz_localizacion;
int TAM_MATRICES = 0;
const int MAX_ITER = 50000;
int Seed = 3;
void lectura_Fichero(char* archivo){
int contador = 0;
int limite = 0;
int numero = 0;
char vacio = ' ';
ifstream entrada;
entrada.open(archivo);
if(!entrada.is_open()){
cout << "No se ha encontrado el archivo: "<< archivo << " " << endl;
exit(-1);
}
//Tama�o del problema
entrada >> TAM_MATRICES;
cout << "El tamanio del problema es: " << TAM_MATRICES << endl;
//Creo la matriz de flujo
matriz_flujo = new int *[TAM_MATRICES];
for(int i = 0; i < TAM_MATRICES; i++) matriz_flujo[i] = new int[TAM_MATRICES];
//Creo la matriz de localizaciones
matriz_localizacion = new int *[TAM_MATRICES];
for(int i = 0; i < TAM_MATRICES; i++) matriz_localizacion[i] = new int[TAM_MATRICES];
//Relleno la matriz de localizaciones con los datos leido del fichero
for(int i = 0; i < TAM_MATRICES; i++){
for(int j = 0; j < TAM_MATRICES; j++){
entrada >> numero;
matriz_localizacion[i][j] = numero;
}
}
//Elimino el salto de linea que separa las dos matrices
entrada >> vacio;
//Relleno la matriz de flujo con los datos leidos del fichero.
for(int k = 0; k < TAM_MATRICES; k++){
for(int l = 0; l < TAM_MATRICES; l++){
entrada >> numero;
matriz_flujo[k][l] = numero;
}
}
//Termino la lectura y cierro el archivo
entrada.close();
}
//Funcion objetivo del problema
int funcion_Objetivo(vector<int> &telomero){
evaulaciones++;
int resultado = 0;
int contador = 0;
int indice = 0;
for(int i = 0; i < TAM_MATRICES; i++){
for(int j = 0; j < TAM_MATRICES; j++){
resultado += matriz_flujo[i][j] * matriz_localizacion[telomero[i]][telomero[j]];
}
}
return resultado;
}
//Operador de intercambio para la busquedad de vecinos
vector<int> intercambio(vector<int> vector_permutacion,int r, int s){
vector<int> respuesta; respuesta.resize(TAM_MATRICES);
int auxiliar = 0;
respuesta = vector_permutacion;
auxiliar = respuesta[r];
respuesta[r] = respuesta[s];
respuesta[s] = auxiliar;
return respuesta;
}
//Genera una solucion aleatoria del problema
void generar_solucion_aleatoria(vector<int> &solucion){
//vector<int> solucion; solucion.resize(TAM_MATRICES);
vector<int> auxiliar;
int contador = 0;
int aleatorio = 0;
//Creo el vector por defecto
for(int i = 0; i < TAM_MATRICES; i++){
auxiliar.push_back(i);
contador++;
}
//Probar este algoritmo
for(int i = 0; i < TAM_MATRICES; i++){
aleatorio = rand()%contador; //Obtengo un numero aleatorio entre 0 y contador
solucion[i] = auxiliar[aleatorio]; //Asigno al vector solucion un valor aleatorio.
auxiliar.erase(auxiliar.begin()+aleatorio); //Borro la posicion usada
contador--; //Reduzco el intervalor para generar el numero aleatorio
}
}
//Calcula el coste de la nueva solucion cuando se realiza un unico intercambio r-s
int factorizacion(vector<int> &vector,int r,int s){
int ganancia = 0;
evaulaciones++;
for(int k = 0; k < TAM_MATRICES; k++){
if(k != r && k != s){
ganancia += (
matriz_flujo[r][k] *
(matriz_localizacion[vector[s]][vector[k]] - matriz_localizacion[vector[r]][vector[k]])
+
matriz_flujo[s][k] *
(matriz_localizacion[vector[r]][vector[k]] - matriz_localizacion[vector[s]][vector[k]])
+
matriz_flujo[k][r] *
(matriz_localizacion[vector[k]][vector[s]] - matriz_localizacion[vector[k]][vector[r]])
+
matriz_flujo[k][s] *
(matriz_localizacion[vector[k]][vector[r]] - matriz_localizacion[vector[k]][vector[s]])
);
}
}
return ganancia;
}
//Imprime un vector
void imprimir_vector(vector<int> &vector){
for(int i = 0; i < TAM_MATRICES; i++){
cout << vector[i] << " ";
}
cout << endl;
}
vector<int> gredy_aleatorio(){
}
//Busqueda local
//Implementa el algoritmo de la busqueda_local
vector<int> busqueda_local(vector<int> vector_permutacion,int iteraciones,int& coste){
bool dlb[TAM_MATRICES];
bool mejora = true;
int valor_factorizacion = 0;
coste = funcion_Objetivo(vector_permutacion);
//Inicializo la mascara a false
for(int i = 0; i < TAM_MATRICES; i++) dlb[i] = false;
while(mejora){
for(int i = 0; i < TAM_MATRICES; i++){
if(dlb[i] == false){
mejora = false;
for(int j = 0; j < TAM_MATRICES; j++){
valor_factorizacion = factorizacion(vector_permutacion,i,j);
if(valor_factorizacion < 0){
vector_permutacion = intercambio(vector_permutacion,i,j);
dlb[i] = false; dlb[j] = false;
mejora = true;
coste = coste + valor_factorizacion;
}
}
if(!mejora) dlb[i] = true;
}
}
}
return vector_permutacion;
}
vector<int> GRASP(){
vector<int> solucion; solucion.resize(TAM_MATRICES);
vector<int> mejor_solucion; mejor_solucion.resize(TAM_MATRICES);
int coste = 0;
int mejor_coste = 0;
while(evaulaciones <= 50000){
solucion = gredy_aleatorio(solucion);
solucion = busquedad_local(solucion,50000,coste);
//Solo para la primera iteracion
if(mejor_coste == 0){
mejor_coste = coste;
mejor_solucion = solucion;
}
if(coste < mejor_coste){
mejor_solucion = solucion;
mejor_coste = coste;
}
}
}
int main(int argc, char** argv){
if(argc < 2){
cout << "Se requiere el archivo de datos" << endl;
exit(-1);
}
vector<int> solucion; solucion.resize(TAM_MATRICES);
solucion = GRASP();
cout << "El vector solucion es: ";
imprimir_vector(solucion);
cout << " Con coste: " << funcion_Objetivo(solucion) << endl;
}
|
0f7ee3e41cf2e76ee882486d0e7027359c8d4d00
|
a9764640e53fc598cdd565d56108749cc6471e08
|
/include/thread_run/mutex.h
|
9bee5124984e606afcea6460aa99f0863ee157fb
|
[] |
no_license
|
nunuNNN/navinfo-vio-msckf
|
4a64f2b8181df26d14bbe526811b5929f43bc563
|
8cdc2776599279a21324e49aada8ecd7de3f87a1
|
refs/heads/master
| 2023-02-25T00:04:13.624296
| 2021-02-01T02:08:38
| 2021-02-01T02:08:38
| 327,519,714
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,159
|
h
|
mutex.h
|
/*
* @filename mutex.h
* @brief 互斥量操作类
*/
#ifndef _BASE_MUTEX_H_
#define _BASE_MUTEX_H_
#include <pthread.h>
#include <thread_run/common.h>
class Mutex
{
public:
Mutex()
: _threadId(0)
{
pthread_mutex_init(&_mutex, NULL);
}
~Mutex()
{
pthread_mutex_destroy(&_mutex);
}
void lock()
{
pthread_mutex_lock(&_mutex);
_threadId = static_cast<uint32_t>(pthread_self());
}
void unlock()
{
_threadId = 0;
pthread_mutex_unlock(&_mutex);
}
pthread_mutex_t *getMutex()
{
return &_mutex;
}
private:
DISALLOW_EVIL_CONSTRUCTORS(Mutex);
uint32_t _threadId;
pthread_mutex_t _mutex;
};
class MutexGuard
{
public:
MutexGuard(Mutex &mutex)
: _mutex(mutex)
{
_mutex.lock();
}
~MutexGuard()
{
_mutex.unlock();
}
private:
DISALLOW_EVIL_CONSTRUCTORS(MutexGuard);
Mutex &_mutex;
};
#define MutexGuard(x) error "Missing MutexGuard object name"
#endif //_BASE_MUTEXLOCK_H_
|
c3562fb31dcf9208ca317c16e971dff24e910577
|
31589435071cbff4c5e95b357d8f3fa258f43269
|
/PPTVForWin8/ppbox_1.2.0/src/ppbox/peer/PeerModule.h
|
0cf37dee8908dce306ce2a43b2eac0f955593860
|
[] |
no_license
|
huangyt/MyProjects
|
8d94656f41f6fac9ae30f089230f7c4bfb5448ac
|
cd17f4b0092d19bc752d949737c6ed3a3ef00a86
|
refs/heads/master
| 2021-01-17T20:19:35.691882
| 2013-05-03T07:19:31
| 2013-05-03T07:19:31
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,143
|
h
|
PeerModule.h
|
// PeerModule.h
#ifndef _PPBOX_PEER_PEER_MODULE_H_
#define _PPBOX_PEER_PEER_MODULE_H_
#include <ppbox/common/PortManager.h>
#include <ppbox/peer_worker/ClientStatus.h>
#ifndef PPBOX_DISABLE_DAC
#include <ppbox/dac/DacModule.h>
#endif
#ifndef PPBOX_CONTAIN_PEER_WORKER
#include <framework/process/NamedMutex.h>
namespace framework
{
namespace process { class Process; }
namespace timer { class Timer; }
}
#endif
namespace ppbox
{
namespace peer
{
class PeerModule
: public ppbox::common::CommonModuleBase<PeerModule>
{
public:
PeerModule(
util::daemon::Daemon & daemon);
~PeerModule();
public:
virtual boost::system::error_code startup();
virtual void shutdown();
public:
boost::uint16_t port() const
{
return port_;
}
bool is_alive();
#ifndef PPBOX_CONTAIN_PEER_WORKER
framework::process::Process const & process() const
{
return *process_;
}
#endif
public:
ppbox::peer_worker::ClientStatus * alloc_status();
void free_status(
ppbox::peer_worker::ClientStatus * status);
void update_status(
ppbox::peer_worker::ClientStatus * status);
public:
static std::string version();
static std::string name();
private:
void check();
bool is_lock();
private:
#ifndef PPBOX_DISABLE_DAC
ppbox::dac::DacModule& dac_;
#endif
ppbox::common::PortManager &portMgr_;
boost::uint16_t port_;
framework::container::List<ppbox::peer_worker::ClientStatus> * stats_;
#ifndef PPBOX_CONTAIN_PEER_WORKER
private:
framework::process::Process * process_;
framework::timer::Timer * timer_;
framework::process::NamedMutex mutex_;
bool is_locked_;
#endif
};
} // namespace peer
} // namespace ppbox
#endif // _PPBOX_PEER_PEER_MODULE_H_
|
1b34d7dca8bc52875fd4e937fb0e7a543399b3c0
|
476a87d88b881c95aa39eb7a51082d2ac42d2d3e
|
/Sources/Server/GameEngine/Entities/Ships/ShipGreen/ShipGreen.cpp
|
6d951adfbaa1051f7c5fd82d4aacddfd66ef26dc
|
[] |
no_license
|
K6PIR/Rtype
|
7d72f9cbf3e2ac9a5a56db3e3ac09f3cd2d82ff8
|
5b13f23d9e6154283fb3ae82a357571006bddfaf
|
refs/heads/master
| 2022-03-24T15:06:15.995185
| 2019-12-02T16:25:36
| 2019-12-02T16:25:36
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 418
|
cpp
|
ShipGreen.cpp
|
/*
** EPITECH PROJECT, 2021
** CPP_rtype_2018
** File description:
** Created by kellian CIPIERRE,
*/
#include <iostream>
#include <random>
#include "ShipGreen.hpp"
ShipGreen::ShipGreen() : Ship("shipGreen") {
position.x = 50;
position.y = 850;
}
extern "C" {
#ifdef _WIN32
__declspec(dllexport) AEntity *buildEngine()
#elif defined (linux)
AEntity *buildEngine()
#endif
{
return new ShipGreen();
}
}
|
5af2008fc9a920b737c9fc2d34682ba0f475cb2f
|
f15d0accf241744982eb96b2b70453e0bd7a244c
|
/codes/LoadingScene.h
|
5ac2c57e1efc0652483c45b4d6ac7f137fbec00f
|
[] |
no_license
|
2329408386/lolita
|
124c6fa3f0732710be92adb0b41fc6f8cc8761c9
|
7272b95de85ecbf7669217815b9346e98c47333a
|
refs/heads/master
| 2021-04-05T20:54:55.133204
| 2018-03-14T09:18:32
| 2018-03-14T09:18:32
| 124,523,982
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 243
|
h
|
LoadingScene.h
|
#pragma once
#include "cocos2d.h"
#include "Comadata.h"
using namespace cocos2d;
class LoadingScene:public Layer
{
public:
bool init();
static Scene* createScene();
//static LoadingScene* creat();
CREATE_FUNC(LoadingScene);
};
|
a27fb190b8d7c82c21faf78f3bc52254b3f28728
|
1a67b8fb79506d1c3b6518038acec4ec5157f40c
|
/SAC-V2-Console/DriverIORequests.cpp
|
cdc465cea270666fb3ae2d9e1bf01ce798af4a0a
|
[
"MIT"
] |
permissive
|
fengjixuchui/Sagaan-AntiCheat-V2.0
|
a014fa63e16ab714eff8a25820c3f35236f209f7
|
dcc017aba7cdc735642dc8e2ca09e5ac4cccc5a7
|
refs/heads/master
| 2020-04-25T08:27:08.423407
| 2019-10-27T09:50:11
| 2019-10-27T09:50:11
| 172,647,607
| 0
| 0
|
MIT
| 2019-10-27T09:50:12
| 2019-02-26T05:57:30
|
C
|
UTF-8
|
C++
| false
| false
| 5,758
|
cpp
|
DriverIORequests.cpp
|
#include "DriverIORequests.h"
KERNEL_HEARTBEAT_REQUEST Blank; // For blank return
KERNEL_THREAD_REQUEST BlankThread; // For Blank return
namespace DriverRequest
{
bool SendProcessIDs(ULONG GmaeProcess)
{
if (hDriver == INVALID_HANDLE_VALUE)
return false;
DWORD Return, Bytes;
KERNEL_READ_REQUEST ReadRequest;
ReadRequest.UsermodeProgram = GetCurrentProcessId();
ReadRequest.GameProcess = GmaeProcess;
// send code to our driver with the arguments
if (DeviceIoControl(hDriver, IO_SEND_PROCESSID, &ReadRequest,
sizeof(ReadRequest), &ReadRequest, sizeof(ReadRequest), &Bytes, NULL))
{
return true;
}
else
{
return false;
}
}
bool SendProtectedThreadID(KERNEL_THREAD_REQUEST Threads)
{
if (hDriver == INVALID_HANDLE_VALUE)
return false;
DWORD Return, Bytes;
// send code to our driver with the arguments
if (DeviceIoControl(hDriver, IO_PROTECTIONT_THREADS, &Threads,
sizeof(Threads), &Threads, sizeof(Threads), &Bytes, NULL))
{
return true;
}
else
{
return false;
}
}
bool HideVAD(DWORD pid, uint64_t base, uint32_t size)
{
if (hDriver == INVALID_HANDLE_VALUE)
return false;
DWORD Return, Bytes;
HIDE_VAD ReadRequest;
ReadRequest.base = base;
ReadRequest.size = size;
ReadRequest.pid = pid;
// send code to our driver with the arguments
if (DeviceIoControl(hDriver, IO_VADPROTECTION, &ReadRequest,
sizeof(ReadRequest), &ReadRequest, sizeof(ReadRequest), &Bytes, NULL))
{
return true;
}
else
{
return false;
}
}
bool TerminatePrcoess(ULONG PID)
{
if (hDriver == INVALID_HANDLE_VALUE)
return false;
DWORD Return, Bytes;
KERNEL_READ_REQUEST ReadRequest;
ReadRequest.UsermodeProgram = PID;
// send code to our driver with the arguments
if (DeviceIoControl(hDriver, IO_TerminateProcess, &ReadRequest,
sizeof(ReadRequest), &ReadRequest, sizeof(ReadRequest), &Bytes, NULL))
{
return true;
}
else
{
return false;
}
}
bool SendCurrentProcessID()
{
if (hDriver == INVALID_HANDLE_VALUE)
return false;
DWORD Return, Bytes;
KERNEL_READ_REQUEST ReadRequest;
ReadRequest.UsermodeProgram = (ULONG)GetCurrentProcessId();
// send code to our driver with the arguments
if (DeviceIoControl(hDriver, IO_SEND_CURRENTPROCESS, &ReadRequest,
sizeof(ReadRequest), &ReadRequest, sizeof(ReadRequest), &Bytes, NULL))
{
return true;
}
else
{
return false;
}
}
KERNEL_THREAD_REQUEST THREADPROTECTION_RETURN_Function()
{
if (hDriver == INVALID_HANDLE_VALUE)
return BlankThread;
DWORD Return, Bytes;
KERNEL_THREAD_REQUEST ReadRequest;
// send code to our driver with the arguments
if (DeviceIoControl(hDriver, THREADPROTECTION_HEARTBEATFUCNTION_RETURN, &ReadRequest,
sizeof(ReadRequest), &ReadRequest, sizeof(ReadRequest), &Bytes, NULL))
{
return ReadRequest;
}
else
{
return ReadRequest;
}
}
KERNEL_HEARTBEAT_REQUEST HEARTBEATCREATEPROCESS_RETURN_Function()
{
if (hDriver == INVALID_HANDLE_VALUE)
return Blank;
DWORD Return, Bytes;
KERNEL_HEARTBEAT_REQUEST ReadRequest;
// send code to our driver with the arguments
if (DeviceIoControl(hDriver, HEARTBEATCREATEPROCESS_RETURN, &ReadRequest,
sizeof(ReadRequest), &ReadRequest, sizeof(ReadRequest), &Bytes, NULL))
{
return ReadRequest;
}
else
{
return ReadRequest;
}
}
bool HEARTBEATCREATEPROCESS_FORWARD_Function(ULONG Check_Encrypt_Random_Number1, ULONG Check_Encrypt_Random_Number2, ULONG Check_Encrypt_Random_Number3, ULONG Check_Encrypt_Random_Number4, ULONG Check_Encrypt_Random_Number5)
{
if (hDriver == INVALID_HANDLE_VALUE)
return false;
DWORD Return, Bytes;
KERNEL_HEARTBEAT_REQUEST ReadRequest;
ReadRequest.Encrypt1 = Check_Encrypt_Random_Number1;
ReadRequest.Encrypt2 = Check_Encrypt_Random_Number2;
ReadRequest.Encrypt3 = Check_Encrypt_Random_Number3;
ReadRequest.Encrypt4 = Check_Encrypt_Random_Number4;
ReadRequest.Encrypt5 = Check_Encrypt_Random_Number5;
// send code to our driver with the arguments
if (DeviceIoControl(hDriver, HEARTBEATCREATEPROCESS_FORWARD, &ReadRequest,
sizeof(ReadRequest), &ReadRequest, sizeof(ReadRequest), &Bytes, NULL))
{
return true;
}
else
{
return false;
}
}
bool HEARTBEATMAINSTART_FORWARD_Function(ULONG Encrypt_Random_Number1, ULONG Encrypt_Random_Number2, ULONG Encrypt_Random_Number3, ULONG Encrypt_Random_Number4, ULONG Encrypt_Random_Number5)
{
if (hDriver == INVALID_HANDLE_VALUE)
return false;
DWORD Return, Bytes;
KERNEL_HEARTBEAT_REQUEST ReadRequest;
ReadRequest.Encrypt1 = Encrypt_Random_Number1;
ReadRequest.Encrypt2 = Encrypt_Random_Number2;
ReadRequest.Encrypt3 = Encrypt_Random_Number3;
ReadRequest.Encrypt4 = Encrypt_Random_Number4;
ReadRequest.Encrypt5 = Encrypt_Random_Number5;
// send code to our driver with the arguments
if (DeviceIoControl(hDriver, HEARTBEATMAINSTART_FORWARD, &ReadRequest,
sizeof(ReadRequest), &ReadRequest, sizeof(ReadRequest), &Bytes, NULL))
{
return true;
}
else
{
return false;
}
}
KERNEL_HEARTBEAT_REQUEST HEARTBEATMAINSTART_RETURN_Function()
{
if (hDriver == INVALID_HANDLE_VALUE)
return Blank;
DWORD Return, Bytes;
KERNEL_HEARTBEAT_REQUEST ReadRequest;
// send code to our driver with the arguments
if (DeviceIoControl(hDriver, HEARTBEATMAINSTART_RETURN, &ReadRequest,
sizeof(ReadRequest), &ReadRequest, sizeof(ReadRequest), &Bytes, NULL))
{
return ReadRequest;
}
else
{
return ReadRequest;
}
}
}
|
757293d2e9d6940eccdcd2b987e6b2b2ef9739dd
|
d01911c430c472e85ad8e9ece26ab008ed1f8160
|
/include/signal.H
|
bd6710793433affcb54a48fe04f887915bdabb5d
|
[] |
no_license
|
andresarcia/binder
|
1de95a95f29a85f0a77d1c7c8431191d398cf862
|
809c726947254da7383fa7b01cc62b8d82d1f069
|
refs/heads/master
| 2021-01-09T05:42:20.425502
| 2017-02-03T09:40:35
| 2017-02-03T09:40:35
| 80,815,842
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,432
|
h
|
signal.H
|
# ifndef SIGNAL_H
# define SIGNAL_H
#include <signal.h>
#include <aleph.H>
/**
Signal
Signal sets the signal handler for a particular signal when
it's created and restore the old signal handler when it's
destroyed.
@autor Carlos Nava <navac@ula.ve>
*/
class Signal
{
public:
typedef void Sigfunc(int);
private:
/// Stored the old signal handler
struct sigaction oldSigaction;
/// Signal number
int signalNumber;
/* If this flag is set, a system call interrupted by the signal
signalNumber will be automatically restarted by the kernel */
bool restartCalls;
public:
Signal(int signo, Sigfunc *func, bool _restartcalls = true):
restartCalls(_restartcalls)
{
struct sigaction act, oact;
signalNumber = signo;
act.sa_handler = func;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
if (signo == SIGALRM)
{
#ifdef SA_INTERRUPT
act.sa_flags |= SA_INTERRUPT;
#endif
}
else
{
if (restartCalls)
{
#ifdef SA_RESTART
act.sa_flags |= SA_RESTART;
#endif
}
}
if (sigaction(signo, &act, &oact) < 0)
ERROR("Cannot modify the action associated with the %d signal",
signo);
oldSigaction = oact;
}
~Signal()
{
if (sigaction(signalNumber, &oldSigaction, NULL) < 0)
ERROR("Cannot modify the action associated with the %d signal",
signalNumber);
}
};
# endif //SIGANL_H
|
bf3a43a7b5213d3c9e1ed2ce248d6b1daa93e10d
|
a0ddd30bd57f0ac4803b80842bb7e583080abf7e
|
/Lynda_UpAndRunningWithCPP/Ascii.cpp
|
0bef6caf64bacbbf327918a3ad174234d77a0704
|
[] |
no_license
|
milind1992/CPlusPlus_Practice
|
57c5af0a30cfd13b9cdcdf7e0342905029404666
|
d7eca189040f877efbbd2208c3997c6fabbb5160
|
refs/heads/master
| 2021-01-22T03:33:21.691200
| 2017-02-03T07:28:16
| 2017-02-03T07:28:16
| 81,132,699
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 176
|
cpp
|
Ascii.cpp
|
#include<iostream>
using namespace std;
int main()
{
char temp;
for (int num = 0; num <= 127; num++)
{
temp = num;
cout << num << " : " << temp << endl;
}
return 0;
}
|
df0eb94a201f6e0f269df3a57746e2f3c0266230
|
05a0e3832ff62104382d4b53cf9d9dcf53b523d1
|
/hash/map.h
|
d2c4d9d65e634e4172eb512db0892322821af7c0
|
[] |
no_license
|
gfxcc/algorithms
|
fa7c48579a390ac1ff5fb00575ba29d4b4fb796f
|
16aaeb0172828e8bf3c8fb53ce6b683148972f86
|
refs/heads/master
| 2021-06-27T12:43:46.012228
| 2018-03-16T03:20:07
| 2018-03-16T03:20:07
| 95,735,247
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 531
|
h
|
map.h
|
class Solution {
public:
void f(vector<pair<int, int>>& vec) {
map<int, int> mp;
for (auto& ele : vec) {
mp.insert(map<int, int>::value_type(ele.first, 1));
mp.insert(map<int, int>::value_type(ele.second, -1));
}
vector<pair<int, int>> ret;
int cnt = 0, start = -1;
for (auto& ele : mp) {
cnt += ele.second;
if (cnt > 0 && start == -1) {
start = ele.first;
} else if (cnt == 0) {
ret.push_back({start, ele.first});
start = -1;
}
}
}
};
|
aae2052a2ddbaa7f90740cc42b1c7dc80e54f425
|
d7cef86b64c0aa296621f662da2b14d262f31bec
|
/task.cpp
|
9272bdca5de709a2eb788f4a5c8a0ddc454103c0
|
[
"MIT"
] |
permissive
|
yekm/bench
|
71409fbf594d5f80c441d99f35faace0f7a7c259
|
00279f7282d8beee64c0bf06a0ea3a4a15a7e4a4
|
refs/heads/master
| 2021-01-17T11:39:03.156000
| 2018-07-12T13:26:32
| 2018-07-12T13:26:32
| 2,062,971
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 778
|
cpp
|
task.cpp
|
#include "task.hpp"
Task::Task(const std::string &name, utils::PlotSettings s)
: m_name(name)
, m_plotsettings(s)
{
}
Task::~Task()
{
}
std::string Task::get_name() const
{
return m_name;
}
Task::algs_type & Task::get_algorithms()
{
return m_algs;
}
void Task::add_alg(algs_type::mapped_type a)
{
auto &alg = m_algs[a->get_name()];
alg = std::move(a);
}
/// TODO: wtf is this?
bool Task::algorithms_ok()
{
for (const auto & a : m_algs)
{
if (a.second->m_statistics.m_status.ok())
return true;
}
return false;
}
utils::PlotSettings & Task::get_plotsettings()
{
return m_plotsettings;
}
void Task::validate(const AResult &)
{
}
bool Task::get_n(std::size_t & n)
{
n < 2 ? n=2 : n*=2;
return true;
}
|
4805add578147e5d56ea63a2f8e511bc7a08be3b
|
cfeac52f970e8901871bd02d9acb7de66b9fb6b4
|
/generated/src/aws-cpp-sdk-mediastore-data/source/model/PutObjectRequest.cpp
|
8f22a3fe79c5853401fd1f2dae3479e8d6adfac8
|
[
"Apache-2.0",
"MIT",
"JSON"
] |
permissive
|
aws/aws-sdk-cpp
|
aff116ddf9ca2b41e45c47dba1c2b7754935c585
|
9a7606a6c98e13c759032c2e920c7c64a6a35264
|
refs/heads/main
| 2023-08-25T11:16:55.982089
| 2023-08-24T18:14:53
| 2023-08-24T18:14:53
| 35,440,404
| 1,681
| 1,133
|
Apache-2.0
| 2023-09-12T15:59:33
| 2015-05-11T17:57:32
| null |
UTF-8
|
C++
| false
| false
| 1,385
|
cpp
|
PutObjectRequest.cpp
|
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/mediastore-data/model/PutObjectRequest.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/HashingUtils.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
#include <utility>
using namespace Aws::MediaStoreData::Model;
using namespace Aws::Utils::Stream;
using namespace Aws::Utils;
using namespace Aws;
PutObjectRequest::PutObjectRequest() :
m_pathHasBeenSet(false),
m_cacheControlHasBeenSet(false),
m_storageClass(StorageClass::NOT_SET),
m_storageClassHasBeenSet(false),
m_uploadAvailability(UploadAvailability::NOT_SET),
m_uploadAvailabilityHasBeenSet(false)
{
}
Aws::Http::HeaderValueCollection PutObjectRequest::GetRequestSpecificHeaders() const
{
Aws::Http::HeaderValueCollection headers;
Aws::StringStream ss;
if(m_cacheControlHasBeenSet)
{
ss << m_cacheControl;
headers.emplace("cache-control", ss.str());
ss.str("");
}
if(m_storageClassHasBeenSet)
{
headers.emplace("x-amz-storage-class", StorageClassMapper::GetNameForStorageClass(m_storageClass));
}
if(m_uploadAvailabilityHasBeenSet)
{
headers.emplace("x-amz-upload-availability", UploadAvailabilityMapper::GetNameForUploadAvailability(m_uploadAvailability));
}
return headers;
}
|
79a084fabdf435e60acd64cb827b07b3265e39b7
|
1dda012fa86de13aba7637e025c6568ed6bba599
|
/src/cpp/allocators/uni_allocator/exception.h
|
6a2d1934096817dd8d68993c8f36498c28da0351
|
[
"Apache-2.0"
] |
permissive
|
typhoonzero/unimem
|
82e1f8b2768447671ee5c2a73c3133544fc58cfd
|
879d273d4ae0ef8d36a0f4dd39a31a075724abeb
|
refs/heads/master
| 2020-04-24T14:32:37.035877
| 2019-04-15T23:39:36
| 2019-04-15T23:39:36
| 172,024,009
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 364
|
h
|
exception.h
|
#pragma once
#include <string>
class DebugAssertionFail : public std::exception {
virtual const char* what() const throw() {
// TODO: add stack trace here.
return "Debug mode assertion failed";
}
};
class MemoryCorruptedException : public std::exception {
virtual const char* what() const throw() {
return "Memory Corrupted Exception";
}
};
|
0e448833d61964d9fdc3c920e670646d88c5c50f
|
79d11d81ffacf6fad9cf271256eda8ae4b30bdbc
|
/src/engine/win/atomic.cpp
|
4b94ae690c10c33eea480a693fb5a8e91cc1daa4
|
[
"MIT"
] |
permissive
|
nem0/LumixEngine
|
d6c46d8febc54ff41e5bc5e6d71d861410f5b155
|
e6314612df50c6f37b34fb0dfcad9683cc506ec7
|
refs/heads/master
| 2023-09-02T09:14:49.212586
| 2023-08-23T21:01:37
| 2023-08-23T21:01:37
| 14,590,125
| 3,660
| 518
|
MIT
| 2023-09-14T14:49:32
| 2013-11-21T14:43:55
|
C++
|
UTF-8
|
C++
| false
| false
| 1,386
|
cpp
|
atomic.cpp
|
#include "engine/atomic.h"
#include <intrin.h>
namespace Lumix
{
i64 atomicIncrement(i64 volatile* value)
{
return _InterlockedIncrement64((volatile long long*)value);
}
i32 atomicIncrement(i32 volatile* value)
{
return _InterlockedIncrement((volatile long*)value);
}
i32 atomicDecrement(i32 volatile* value)
{
return _InterlockedDecrement((volatile long*)value);
}
i32 atomicAdd(i32 volatile* addend, i32 value)
{
return _InterlockedExchangeAdd((volatile long*)addend, value);
}
i32 atomicSubtract(i32 volatile* addend, i32 value)
{
return _InterlockedExchangeAdd((volatile long*)addend, -value);
}
i64 atomicAdd(i64 volatile* addend, i64 value)
{
return _InterlockedExchangeAdd64((volatile long long*)addend, value);
}
i64 atomicSubtract(i64 volatile* addend, i64 value)
{
return _InterlockedExchangeAdd64((volatile long long*)addend, -value);
}
bool compareAndExchange(i32 volatile* dest, i32 exchange, i32 comperand)
{
return _InterlockedCompareExchange((volatile long*)dest, exchange, comperand) == comperand;
}
bool compareAndExchange64(i64 volatile* dest, i64 exchange, i64 comperand)
{
return _InterlockedCompareExchange64(dest, exchange, comperand) == comperand;
}
LUMIX_ENGINE_API void memoryBarrier()
{
#ifdef _M_AMD64
__faststorefence();
#elif defined _IA64_
__mf();
#else
int Barrier;
__asm {
xchg Barrier, eax
}
#endif
}
} // namespace Lumix
|
3b1b8c0630b90845bbbccee1447278700fe3cd34
|
4afa3ea25a438fc8bb88773b3a5cdf0429d3eed2
|
/Summer15 SFML Assignments/Pong/Game.h
|
884aef85c79a0c7251f77ea33e2776dca5be69e7
|
[] |
no_license
|
leaflet757/CPP-SFML-Assignments
|
67e05bab7c37050ee426e2b216b496d210de86dc
|
4191bac68b4e391ad46134385e6a389f75bd3c20
|
refs/heads/master
| 2021-01-25T07:39:32.980715
| 2015-07-20T23:13:43
| 2015-07-20T23:13:43
| 38,646,785
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 751
|
h
|
Game.h
|
#pragma once
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>
#include <cstdio>
#include <thread>
#include <mutex>
#include <iostream>
#include <MathFuncsDll.h> // test
#include "Ball.h"
using namespace std;
namespace OpenSFMLEngine
{
class Game
{
private:
sf::Window* window;
thread* renderingThread;
thread* updateThread;
vector<Actor2D*> actors;
std::mutex _lock;
sf::Clock* clock;
bool running = true;
float r = 0, g = 0.3, b = 0.6;
Game(Game const&) = delete;
void operator=(Game const&) = delete;
public:
Game();
~Game(); // TODO: would this be private too?
static Game& getInstance();
void start();
virtual void initActors();
void renderingFunction();
void updateFunction();
};
}
|
9ac849058f3947d7ef63e79f689784cfefc2b3ff
|
92e67b30497ffd29d3400e88aa553bbd12518fe9
|
/assignment2/part6/Re=110/43.3/phi
|
523f6a427af7a5831574b7dbf315a475686809d3
|
[] |
no_license
|
henryrossiter/OpenFOAM
|
8b89de8feb4d4c7f9ad4894b2ef550508792ce5c
|
c54b80dbf0548b34760b4fdc0dc4fb2facfdf657
|
refs/heads/master
| 2022-11-18T10:05:15.963117
| 2020-06-28T15:24:54
| 2020-06-28T15:24:54
| 241,991,470
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 42,990
|
phi
|
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class surfaceScalarField;
location "43.3";
object phi;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 3 -1 0 0 0 0];
internalField nonuniform List<scalar>
3880
(
-6.26537e-05
0.000592421
-0.000529768
5.49518e-07
0.000853982
-0.000917185
0.00025515
0.000914642
-0.00116924
0.0007279
0.00103061
-0.00150336
0.00142934
0.00134827
-0.00204971
0.00236274
0.00194495
-0.00287836
0.00352505
0.00285731
-0.00401962
0.00490414
0.00409715
-0.00547624
0.00647418
0.00565957
-0.00722961
0.00752814
0.0081865
-0.00924046
-3.53964e-05
0.000627818
8.33804e-05
0.000735206
0.00040382
0.000594202
0.000938804
0.000495625
0.00169065
0.00059642
0.0026599
0.000975706
0.00384658
0.00167063
0.00524706
0.00269668
0.00684761
0.00405901
0.0057647
0.00861105
5.13348e-06
0.000622685
0.000200005
0.000540334
0.000613772
0.000180435
0.00124079
-0.000131397
0.00207089
-0.000233672
0.00309768
-5.10884e-05
0.00432073
0.000447577
0.00574287
0.00127455
0.00736347
0.00243841
0.00396583
0.00916234
5.41849e-05
0.0005685
0.000350282
0.000244237
0.000886751
-0.000356034
0.00163852
-0.000883163
0.00257968
-0.00117483
0.00369311
-0.00116452
0.00497364
-0.000832954
0.00642676
-0.000178581
0.00806339
0.000801776
0.00214424
0.00988498
0.000115435
0.000453064
0.000532581
-0.000172909
0.00121915
-0.0010426
0.00212701
-0.00179103
0.00321236
-0.00226018
0.00444463
-0.00239679
0.00581036
-0.00219868
0.00731319
-0.00168141
0.00897124
-0.000856271
0.000306618
0.0108089
0.000186473
0.000266591
0.000741975
-0.000728411
0.00160025
-0.00190088
0.00268817
-0.00287895
0.00394306
-0.00351507
0.00532037
-0.0037741
0.00679677
-0.00367509
0.00837067
-0.0032553
0.0100619
-0.00254751
-0.00154549
0.011914
0.000265169
1.42261e-06
0.00097048
-0.00143372
0.00201195
-0.00294235
0.00328969
-0.00415669
0.00472254
-0.00494792
0.00625349
-0.00530505
0.00785067
-0.00527227
0.00950645
-0.00491108
0.0112382
-0.00427922
-0.00340728
0.0131
0.000348819
-0.000347396
0.00120743
-0.00229233
0.00242959
-0.00416451
0.00388721
-0.00561431
0.00548223
-0.00654293
0.00714877
-0.00697159
0.00885005
-0.00697356
0.0105743
-0.00663538
0.0123348
-0.00603968
-0.00525925
0.0141868
0.000434285
-0.000781681
0.00143993
-0.00329797
0.00282376
-0.00554835
0.00442887
-0.00721942
0.00614357
-0.00825763
0.00789863
-0.00872665
0.00965817
-0.0087331
0.0114099
-0.00838714
0.0131613
-0.00779103
-0.00706079
0.0149628
0.000517805
-0.00129949
0.0016534
-0.00443356
0.00316258
-0.00705753
0.00486109
-0.00891794
0.00662918
-0.0100257
0.00840177
-0.0104992
0.0101523
-0.0104837
0.0118774
-0.0101122
0.0135824
-0.00949599
0.0152594
-0.0087378
0.0120662
0.0458868
-0.0497665
0.0143083
0.0816527
-0.0838948
0.0141549
0.113334
-0.113181
0.0125805
0.139156
-0.137582
0.0104615
0.162633
-0.160514
0.00823085
0.186492
-0.184262
0.00606316
0.214147
-0.211979
0.00389375
0.247484
-0.245315
0.00177716
0.288868
-0.286752
0.335403
-0.333626
0.0127213
0.0417765
0.0156154
0.0787586
0.0159704
0.112979
0.0146066
0.14052
0.0124874
0.164752
0.0101219
0.188858
0.00772309
0.216546
0.00520443
0.250003
0.00254797
0.291525
0.337951
0.0133173
0.0376216
0.0168133
0.0752626
0.0177287
0.112064
0.0166319
0.141617
0.0145367
0.166847
0.0120415
0.191353
0.00939917
0.219188
0.00652079
0.252881
0.00332141
0.294724
0.341273
0.0138671
0.0336395
0.0178622
0.0712675
0.0193792
0.110547
0.0186105
0.142385
0.0165734
0.168884
0.0139604
0.193966
0.0110786
0.22207
0.00784205
0.256118
0.0040966
0.29847
0.345369
0.0143996
0.0300487
0.0187322
0.0669349
0.0208735
0.108406
0.020502
0.142757
0.0185691
0.170817
0.0158542
0.196681
0.0127368
0.225187
0.00914561
0.259709
0.00486252
0.302753
0.350232
0.0149462
0.0270165
0.0194094
0.0624717
0.0221657
0.105649
0.0222516
0.142671
0.0204743
0.172594
0.0176914
0.199464
0.0143594
0.228519
0.0104282
0.26364
0.00561722
0.307564
0.355849
0.0155155
0.024601
0.0198971
0.05809
0.0232284
0.102318
0.0238466
0.142053
0.0222899
0.174151
0.0194634
0.20229
0.0159254
0.232057
0.0116652
0.2679
0.00634764
0.312881
0.362197
0.0160671
0.0227207
0.0202089
0.0539483
0.0240057
0.0985212
0.0251719
0.140887
0.0239074
0.175416
0.0211099
0.205088
0.0174136
0.235753
0.0128559
0.272458
0.00705391
0.318683
0.369251
0.016466
0.0212175
0.0203537
0.0500606
0.0245945
0.0942803
0.0263886
0.139092
0.0254562
0.176348
0.0226801
0.207864
0.0188255
0.239608
0.0139794
0.277304
0.00772393
0.324939
0.376974
0.0164427
0.0200342
0.0201744
0.0463289
0.0247089
0.0897458
0.0271634
0.136638
0.0267698
0.176742
0.02417
0.210464
0.0202526
0.243525
0.0151067
0.28245
0.00843649
0.331609
0.385411
0.0481485
0.0286105
-0.0567249
0.0409439
0.0535335
0.0369945
0.0936952
0.0337131
0.139919
0.029097
0.181358
0.0230876
0.216473
0.0165626
0.25005
0.0101839
0.288829
0.00430732
0.337485
0.389718
0.0434103
0.0358855
-0.0506853
0.0359447
0.0609991
0.0317056
0.0979343
0.0294418
0.142183
0.0262649
0.184535
0.0213303
0.221408
0.0153611
0.25602
0.00927909
0.294911
0.00385643
0.342908
0.393575
0.0357117
0.0418988
-0.041725
0.0290227
0.0676881
0.0246867
0.10227
0.0228642
0.144006
0.0211849
0.186214
0.0179996
0.224593
0.0133238
0.260695
0.00807526
0.300159
0.00329801
0.347685
0.396873
0.0258434
0.0471345
-0.0310791
0.0202665
0.073265
0.0167048
0.105832
0.0158654
0.144845
0.0157828
0.186297
0.0143904
0.225985
0.0110447
0.264041
0.00678941
0.304414
0.00268922
0.351785
0.399562
0.0157454
0.0520292
-0.0206401
0.0104779
0.0785326
0.00703818
0.109272
0.00667622
0.145207
0.0080965
0.184876
0.00880626
0.225276
0.00754221
0.265305
0.00481088
0.307146
0.00178192
0.354814
0.401344
0.00680039
0.0565043
-0.0112754
0.00195866
0.0833743
-0.000802115
0.112032
-0.000702854
0.145108
0.00160183
0.182572
0.00372025
0.223157
0.00418537
0.26484
0.00282264
0.308508
0.000897242
0.35674
0.402241
-0.000723525
0.0611352
-0.00390741
-0.0060969
0.0887477
-0.0095367
0.115472
-0.00955368
0.145125
-0.0066348
0.179653
-0.00276042
0.219283
-6.91804e-05
0.262149
0.000448914
0.30799
-6.46772e-05
0.357253
0.402176
-0.00486312
0.0650896
0.000908668
-0.00945446
0.093339
-0.0128696
0.118887
-0.0135326
0.145788
-0.0112269
0.177347
-0.00726962
0.215326
-0.003763
0.258642
-0.00191846
0.306146
-0.00118391
0.356519
0.400993
-0.0085923
0.0697309
0.00395107
-0.0139301
0.0986769
-0.0178807
0.122838
-0.0187454
0.146653
-0.0162954
0.174897
-0.0115927
0.210623
-0.00687634
0.253926
-0.0036939
0.302963
-0.00200858
0.354834
0.398984
-0.00695808
0.00324985
-0.0120056
-0.0165841
-0.0187224
-0.0176955
-0.0141193
-0.0094995
-0.00570478
-0.00288413
0.0145973
-0.0561115
-0.0152107
0.0131787
-0.0492667
0.0117373
-0.0402835
0.0107288
-0.0300706
0.0103178
-0.0202291
0.0104877
-0.0114453
0.0111384
-0.00455807
0.0119955
5.15654e-05
0.0131898
0.00275681
0.00229718
0.0131142
-0.0550803
-0.0141454
0.0114874
-0.0476399
0.0100421
-0.0388382
0.00906985
-0.0290984
0.00867416
-0.0198334
0.00879287
-0.0115641
0.0093032
-0.00506839
0.0100282
-0.000673465
0.0109695
0.00181553
0.00159886
0.0112694
-0.0537868
-0.0125629
0.00956215
-0.0459327
0.00814306
-0.0374191
0.00719532
-0.0281507
0.00679348
-0.0194316
0.00685808
-0.0116287
0.00726398
-0.00547429
0.00786362
-0.00127311
0.00860336
0.00107579
0.00109194
0.00906689
-0.0523125
-0.0105412
0.00736146
-0.0442272
0.00601129
-0.0360689
0.00510672
-0.0272461
0.00470101
-0.0190259
0.00471756
-0.0116452
0.00504205
-0.00579878
0.00553762
-0.00176868
0.00612118
0.000492223
0.000730204
0.0065585
-0.0507082
-0.00816281
0.00489432
-0.042563
0.00363786
-0.0348125
0.00279733
-0.0264056
0.00240466
-0.0186332
0.00239402
-0.0116346
0.00266118
-0.00606594
0.00308212
-0.00218961
0.00354701
2.73299e-05
0.000472066
0.0038253
-0.0490172
-0.00551636
0.00221892
-0.0409567
0.00106927
-0.0336628
0.000322506
-0.0256588
-1.87864e-05
-0.0182919
-2.92886e-05
-0.0116241
0.000168013
-0.00626324
0.000530774
-0.00255238
0.000914841
-0.000356737
0.000285571
0.000961318
-0.0472891
-0.0026894
-0.000588688
-0.0394067
-0.00167144
-0.0325801
-0.00236679
-0.0249634
-0.00267859
-0.0179801
-0.00266652
-0.0116361
-0.00243078
-0.00649898
-0.00208416
-0.00289899
-0.00175271
-0.000688189
0.00013731
-0.00203475
-0.0454944
0.00024008
-0.00351177
-0.0379296
-0.00448227
-0.0316096
-0.00509558
-0.0243501
-0.00534183
-0.0177339
-0.00529309
-0.0116849
-0.00504555
-0.00674652
-0.00470958
-0.00323497
-0.00441137
-0.000986396
4.54968e-06
-0.00499834
-0.043646
0.00314997
-0.00637173
-0.0365562
-0.00725378
-0.0307275
-0.00779099
-0.0238129
-0.0079773
-0.0175476
-0.00788781
-0.0117744
-0.00762602
-0.0070083
-0.00729527
-0.00356571
-0.00701927
-0.0012624
-0.000132425
-0.00781091
-0.041816
0.00598085
-0.00910033
-0.0352668
-0.00990851
-0.0299193
-0.0103775
-0.0233439
-0.0105148
-0.0174103
-0.0103898
-0.0118994
-0.0101192
-0.00727898
-0.0097944
-0.00389048
-0.00953075
-0.00152605
-0.000280665
-0.0104077
-0.0400459
0.00863766
-0.0116262
-0.0340483
-0.0123824
-0.0291632
-0.0127876
-0.0229387
-0.0128922
-0.0173057
-0.012744
-0.0120475
-0.0124758
-0.00754723
-0.0121622
-0.00420402
-0.0119094
-0.00177885
-0.00044352
-0.0127636
-0.0383517
0.0110693
-0.0139048
-0.0329071
-0.0146246
-0.0284433
-0.0149726
-0.0225907
-0.0150633
-0.017215
-0.0149067
-0.0122041
-0.0146549
-0.00779906
-0.0143615
-0.00449741
-0.0141233
-0.00201709
-0.000616636
-0.0148361
-0.0367488
0.0132331
-0.0158992
-0.0318439
-0.0165958
-0.0277467
-0.0169002
-0.0222863
-0.0169939
-0.0171214
-0.0168472
-0.0123508
-0.0166263
-0.00802001
-0.0163649
-0.00475875
-0.0161499
-0.00223211
-0.000788098
-0.0166061
-0.0352446
0.0151019
-0.0175886
-0.0308614
-0.0182752
-0.02706
-0.0185521
-0.0220094
-0.0186641
-0.0170094
-0.0185474
-0.0124675
-0.0183715
-0.0081959
-0.0181567
-0.0049736
-0.0179777
-0.00241106
-0.000940101
-0.0180707
-0.0338323
0.0166584
-0.0189685
-0.0299636
-0.0196559
-0.0263726
-0.0199244
-0.0217409
-0.0200671
-0.0168667
-0.0200011
-0.0125335
-0.0198842
-0.00831287
-0.0197326
-0.00512521
-0.0196058
-0.00253781
-0.00105065
-0.0192387
-0.0324841
0.0178904
-0.02005
-0.0291524
-0.0207423
-0.0256804
-0.0210246
-0.0214586
-0.0212069
-0.0166844
-0.0212126
-0.0125278
-0.0211684
-0.00835706
-0.0210986
-0.00519499
-0.0210426
-0.0025938
-0.00109511
-0.0201234
-0.0311487
0.0187881
-0.0208537
-0.0284221
-0.0215448
-0.0249892
-0.0218663
-0.0211371
-0.0220952
-0.0164554
-0.0221934
-0.0124297
-0.0222368
-0.00831368
-0.0222687
-0.00516306
-0.0223038
-0.00255868
-0.00104747
-0.0207062
-0.0297855
0.019343
-0.0213864
-0.0277419
-0.0220689
-0.0243067
-0.022462
-0.020744
-0.0227482
-0.0161693
-0.02296
-0.0122179
-0.0231078
-0.00816588
-0.0232622
-0.0050086
-0.0234102
-0.00241073
-0.000881294
-0.0209467
-0.0284134
0.0195746
-0.0216582
-0.0270304
-0.0223284
-0.0236365
-0.0228267
-0.0202457
-0.0231853
-0.0158107
-0.0235309
-0.0118723
-0.0238017
-0.00789512
-0.0241004
-0.00470984
-0.0243848
-0.00212638
-0.000569813
-0.0209038
-0.0270967
0.0195872
-0.0217161
-0.0262182
-0.0223193
-0.0230333
-0.0229261
-0.0196388
-0.0233783
-0.0153585
-0.0238836
-0.011367
-0.0243154
-0.00746325
-0.0247926
-0.00423263
-0.0252551
-0.00166395
-8.94589e-05
-0.0819624
-0.0235822
0.0784479
-0.0875576
-0.0206231
-0.0920055
-0.0185853
-0.0962466
-0.0153978
-0.0993153
-0.0122899
-0.101708
-0.00897441
-0.103125
-0.00604598
-0.103945
-0.00341254
-0.104219
-0.00138996
-8.83584e-05
-0.100912
-0.0202566
0.0975868
-0.104621
-0.0169146
-0.107893
-0.0153136
-0.111078
-0.0122127
-0.113495
-0.00987289
-0.115413
-0.00705616
-0.116607
-0.0048523
-0.117318
-0.00270095
-0.117541
-0.00116678
-8.17315e-05
-0.119052
-0.0173957
0.116191
-0.121919
-0.0140474
-0.124633
-0.0126002
-0.127085
-0.00976057
-0.129016
-0.00794187
-0.130506
-0.00556587
-0.131437
-0.00392104
-0.131969
-0.00216945
-0.132116
-0.00101916
-7.13356e-05
-0.139258
-0.0150952
0.136957
-0.141573
-0.0117323
-0.143772
-0.0104012
-0.14569
-0.00784214
-0.147213
-0.00641908
-0.148368
-0.00441119
-0.149082
-0.00320723
-0.149479
-0.00177209
-0.149579
-0.000919698
-6.20032e-05
-0.163277
-0.0128781
0.16106
-0.165231
-0.00977793
-0.167053
-0.00857921
-0.168605
-0.00629048
-0.169847
-0.00517703
-0.170781
-0.00347726
-0.171378
-0.00260954
-0.171735
-0.00141571
-0.171855
-0.000799895
-2.93904e-05
-0.19217
-0.0106044
0.189896
-0.193945
-0.00800282
-0.195647
-0.00687746
-0.197037
-0.00490065
-0.198157
-0.00405649
-0.198996
-0.00263883
-0.199602
-0.00200271
-0.200029
-0.000989001
-0.200268
-0.000560521
3.44923e-05
-0.224211
-0.0081783
0.221785
-0.22649
-0.00572373
-0.228417
-0.00495068
-0.229762
-0.00355567
-0.230835
-0.00298384
-0.231659
-0.00181444
-0.232343
-0.00131839
-0.232877
-0.000455809
-0.233216
-0.000221385
0.000117785
-0.257469
-0.00552843
0.254819
-0.258827
-0.00436539
-0.260145
-0.00363289
-0.261318
-0.002383
-0.262397
-0.00190409
-0.263204
-0.00100828
-0.263862
-0.000659672
-0.264303
-1.5476e-05
-0.264565
4.1142e-05
0.000161428
-0.27834
-0.00281753
0.275629
-0.281086
-0.00161918
-0.28332
-0.00139876
-0.284734
-0.000968573
-0.28581
-0.000828315
-0.286381
-0.000437717
-0.286795
-0.000245681
-0.286892
8.20094e-05
-0.286941
8.9497e-05
9.52695e-05
-0.292967
0.29015
-0.294586
-0.295985
-0.296954
-0.297782
-0.29822
-0.298466
-0.298384
-0.298294
-0.0223404
0.0802355
0.0205528
-0.0231001
0.0983465
-0.0233277
0.116419
-0.0230433
0.136673
-0.0222439
0.16026
-0.0205671
0.188219
-0.0178375
0.219055
-0.011967
0.248948
-0.00718002
0.270842
0.28297
-0.0210889
0.0811949
0.0201296
-0.0217051
0.0989626
-0.0218159
0.11653
-0.021417
0.136274
-0.0205096
0.159353
-0.018804
0.186514
-0.016026
0.216278
-0.0115949
0.244517
-0.00632703
0.265574
0.276643
-0.0200814
0.0819367
0.0193395
-0.0205378
0.099419
-0.0205286
0.11652
-0.0200653
0.135811
-0.0191309
0.158418
-0.0174716
0.184854
-0.0147735
0.213579
-0.0107481
0.240492
-0.00575094
0.260577
0.270892
-0.0189503
0.082596
0.0182911
-0.0192649
0.0997336
-0.0191181
0.116373
-0.0185746
0.135267
-0.0176108
0.157455
-0.0159979
0.183242
-0.0134355
0.211017
-0.0097814
0.236838
-0.00515723
0.255953
0.265735
-0.0176545
0.083187
0.0170634
-0.0178579
0.0999371
-0.0175992
0.116115
-0.0169892
0.134657
-0.0160062
0.156472
-0.0144473
0.181683
-0.0120569
0.208626
-0.00874149
0.233522
-0.00457767
0.251789
0.261157
-0.0162125
0.0836912
0.0157084
-0.0163023
0.100027
-0.0159532
0.115766
-0.0152986
0.134003
-0.0143155
0.155489
-0.0128312
0.180198
-0.010641
0.206436
-0.00766546
0.230547
-0.00400497
0.248128
0.257152
-0.0146604
0.0840898
0.0142618
-0.0146278
0.0999942
-0.0141943
0.115332
-0.013507
0.133316
-0.0125396
0.154521
-0.0111519
0.178811
-0.0091849
0.204469
-0.00657099
0.227933
-0.00342681
0.244984
0.253725
-0.0130287
0.0843632
0.0127553
-0.0128735
0.099839
-0.0123576
0.114816
-0.0116417
0.1326
-0.0106987
0.153578
-0.0094239
0.177536
-0.0076968
0.202742
-0.00546632
0.225702
-0.00284097
0.242359
0.250884
-0.0113455
0.0844878
0.0112209
-0.0110741
0.0995676
-0.0104774
0.11422
-0.00973636
0.131859
-0.00882198
0.152664
-0.00767039
0.176384
-0.00619335
0.201265
-0.00435814
0.223867
-0.00225125
0.240252
0.248633
-0.00963778
0.0844335
0.00969209
-0.00926253
0.0991923
-0.00858221
0.113539
-0.00782101
0.131097
-0.00693635
0.151779
-0.0059155
0.175364
-0.00469367
0.200043
-0.0032565
0.22243
-0.0016649
0.23866
0.246968
-0.00793921
0.0841625
0.00821021
-0.00747897
0.0987321
-0.00670407
0.112764
-0.00592879
0.130322
-0.0050703
0.150921
-0.00418318
0.174476
-0.00321573
0.199076
-0.00217185
0.221386
-0.0010878
0.237576
0.24588
-0.00631581
0.083679
0.00679925
-0.00576068
0.098177
-0.00489658
0.1119
-0.0041018
0.129527
-0.00326741
0.150086
-0.00250348
0.173712
-0.00177877
0.198351
-0.00111832
0.220726
-0.000527104
0.236985
0.245353
-0.00481446
0.0829998
0.00549366
-0.00414707
0.0975096
-0.00320821
0.110961
-0.00238455
0.128704
-0.00157815
0.14928
-0.000927259
0.173062
-0.000435782
0.19786
-0.000139788
0.22043
-1.68354e-05
0.236862
0.245336
-0.0034626
0.0821511
0.00431129
-0.00265888
0.0967059
-0.00167458
0.109977
-0.00081495
0.127844
-8.26839e-05
0.148547
0.000551321
0.172428
0.000861527
0.19755
0.000829994
0.220461
0.000506319
0.237186
0.245843
-0.00227905
0.0811718
0.00325838
-0.00131528
0.0957421
-0.000341169
0.109003
0.000653215
0.12685
0.00149093
0.14771
0.00200256
0.171916
0.00210401
0.197448
0.00174513
0.22082
0.000991807
0.237939
0.246834
-0.00127331
0.080116
0.00232914
-0.000166529
0.0946353
0.000984536
0.107852
0.00204533
0.125789
0.00286368
0.146891
0.00330242
0.171477
0.00322827
0.197522
0.00257622
0.221472
0.00143125
0.239084
0.248266
-0.000450174
0.0790632
0.00150298
0.000969074
0.0932161
0.00217061
0.10665
0.00327119
0.124688
0.00410022
0.146062
0.00449343
0.171084
0.00427343
0.197742
0.003356
0.22239
0.00184613
0.240594
0.250112
0.000254883
0.0780627
0.000745565
0.00190182
0.0915691
0.00313689
0.105415
0.00427947
0.123546
0.00511969
0.145222
0.00547987
0.170724
0.00514541
0.198077
0.00401038
0.223525
0.00219054
0.242414
0.252302
0.00107143
0.0769938
-2.53165e-06
0.0027727
0.0898678
0.00405434
0.104134
0.00523952
0.122361
0.00610078
0.144361
0.00643926
0.170385
0.0059982
0.198518
0.00465127
0.224871
0.00253124
0.244534
0.254834
0.00139928
0.0763191
-0.000724593
0.00315688
0.0881102
0.00448716
0.102803
0.0056959
0.121152
0.00657566
0.143481
0.00692533
0.170036
0.00645327
0.19899
0.00500533
0.226319
0.0027078
0.246831
0.257541
-0.0681598
0.0686572
0.0758218
-0.0607796
0.08073
-0.0554979
0.0975218
-0.0498948
0.115549
-0.0440874
0.137674
-0.0376011
0.163549
-0.0299107
0.191299
-0.0208374
0.217246
-0.0106482
0.236642
0.246893
-0.0795233
0.0625785
0.085602
-0.0731436
0.0743502
-0.0672238
0.0916021
-0.0606044
0.108929
-0.0539546
0.131024
-0.0462182
0.155813
-0.0369153
0.181996
-0.0259007
0.206232
-0.0134955
0.224237
0.233398
-0.092778
0.056522
0.0988344
-0.0865022
0.0680744
-0.0798087
0.0849086
-0.0724853
0.101606
-0.0647684
0.123307
-0.0552785
0.146323
-0.0439702
0.170688
-0.0306109
0.192872
-0.0155369
0.209163
0.217861
-0.109237
0.0506963
0.115063
-0.102674
0.0615116
-0.0954746
0.077709
-0.087481
0.0936122
-0.078294
0.11412
-0.0667279
0.134757
-0.0531029
0.157063
-0.0370693
0.176839
-0.0192815
0.191375
0.198579
-0.128445
0.0442248
0.134917
-0.121694
0.0547605
-0.113672
0.0696875
-0.10412
0.0840601
-0.0925132
0.102513
-0.0782422
0.120486
-0.0617316
0.140553
-0.0423982
0.157505
-0.0212162
0.170193
0.177363
-0.153036
0.0381998
0.159061
-0.145318
0.0470426
-0.135842
0.0602117
-0.124202
0.0724199
-0.110017
0.0883276
-0.0930298
0.103499
-0.0732248
0.120748
-0.0503671
0.134647
-0.0261854
0.146011
0.151178
-0.17898
0.0306526
0.186527
-0.16986
0.0379222
-0.158258
0.0486098
-0.14391
0.0580723
-0.126519
0.0709364
-0.105706
0.0826857
-0.0811684
0.0962105
-0.053778
0.107257
-0.0258796
0.118113
0.125298
-0.208942
0.0226459
0.216948
-0.198113
0.0270936
-0.184383
0.0348801
-0.167502
0.0411906
-0.147085
0.05052
-0.122654
0.0582546
-0.0944311
0.0679875
-0.0641598
0.0769858
-0.0338695
0.0878226
0.0914286
-0.231197
0.0109337
0.242909
-0.217479
0.0133754
-0.199978
0.0173794
-0.17928
0.0204925
-0.15417
0.0254103
-0.125148
0.0292322
-0.0919567
0.0347962
-0.0547244
0.0397534
-0.0162531
0.0493513
0.0751755
-0.304966
0.3159
-0.291591
-0.274211
-0.253719
-0.228309
-0.199076
-0.16428
-0.124527
-0.0751755
-0.00175004
0.0776483
-7.64752e-05
-0.00328917
0.0871412
-0.00448826
0.100034
-0.00538089
0.115955
-0.00590858
0.135444
-0.00602114
0.159174
-0.00552631
0.186032
-0.00433582
0.215758
-0.00334166
0.241915
0.312558
-0.00128208
0.0796543
-0.000723867
-0.00297404
0.0888331
-0.00426474
0.101324
-0.00518097
0.116872
-0.00574545
0.136009
-0.00586233
0.15929
-0.00542533
0.185595
-0.00425572
0.214588
-0.00305804
0.240717
0.3095
-0.000627404
0.0815899
-0.00130824
-0.00230088
0.0905066
-0.0036006
0.102624
-0.00451032
0.117781
-0.00510346
0.136602
-0.00524164
0.159429
-0.00490435
0.185258
-0.00383189
0.213516
-0.00279147
0.239677
0.306709
-1.40949e-05
0.0835035
-0.00189952
-0.00161939
0.0921119
-0.00281643
0.103821
-0.00369207
0.118657
-0.00426468
0.137174
-0.00445073
0.159615
-0.00419173
0.184999
-0.00329812
0.212622
-0.00244412
0.238823
0.304265
0.000633456
0.0853835
-0.00251337
-0.000962055
0.0937074
-0.00206241
0.104921
-0.0028773
0.119472
-0.00340985
0.137707
-0.00361294
0.159818
-0.00342113
0.184807
-0.00270565
0.211907
-0.00204999
0.238167
0.302215
0.0012965
0.0872242
-0.00313727
-0.000255224
0.0952591
-0.00124624
0.105912
-0.00200074
0.120226
-0.00249703
0.138203
-0.00271038
0.160031
-0.0026005
0.184697
-0.00205811
0.211364
-0.00161939
0.237729
0.300595
0.00200223
0.0889875
-0.0037655
0.000594869
0.0966665
-0.00034221
0.106849
-0.00103285
0.120917
-0.00149251
0.138663
-0.00171876
0.160257
-0.00169536
0.184674
-0.00134922
0.211018
-0.00114967
0.237529
0.299445
0.00274042
0.0906419
-0.0043948
0.00149256
0.0979143
0.000640624
0.107701
-1.26968e-05
0.12157
-0.000399158
0.139049
-0.000647001
0.160505
-0.000693727
0.184721
-0.000586015
0.21091
-0.000637457
0.237581
0.298808
0.00350139
0.0921578
-0.00501729
0.00240632
0.0990094
0.0016603
0.108447
0.00113907
0.122092
0.000765863
0.139423
0.000500718
0.16077
0.000370764
0.184851
0.00022841
0.211053
-7.16605e-05
0.237881
0.298736
0.00427741
0.0934991
-0.00561875
0.00333497
0.0999518
0.00270321
0.109079
0.00228056
0.122514
0.00196125
0.139742
0.00169534
0.161036
0.00143317
0.185113
0.00110998
0.211376
0.000461056
0.23853
0.299197
0.00504683
0.0946235
-0.00617118
0.00425933
0.100739
0.00374771
0.109591
0.00342619
0.122836
0.00316646
0.140002
0.00289347
0.161309
0.00252797
0.185478
0.00198593
0.211918
0.00101989
0.239496
0.300217
0.00580196
0.0954907
-0.00666915
0.00517104
0.10137
0.00478452
0.109977
0.0045671
0.123053
0.00437006
0.140199
0.00409751
0.161582
0.00363225
0.185944
0.00287191
0.212678
0.00159148
0.240776
0.301809
0.00651049
0.0960767
-0.00709652
0.00604089
0.10184
0.00578231
0.110236
0.00567077
0.123165
0.00554472
0.140325
0.00528178
0.161845
0.00472414
0.186501
0.003758
0.213644
0.0021648
0.242369
0.303974
0.00715326
0.0963666
-0.0074432
0.00684916
0.102144
0.00671626
0.110369
0.00671035
0.123171
0.00666466
0.14037
0.00641899
0.16209
0.00578232
0.187138
0.00462516
0.214802
0.00272804
0.244266
0.306702
0.00771578
0.0963509
-0.00770003
0.00758138
0.102278
0.00756774
0.110382
0.00766507
0.123073
0.00770561
0.14033
0.00749171
0.162304
0.0067983
0.187831
0.00546605
0.216134
0.00328043
0.246452
0.309982
0.00818016
0.0960337
-0.00786295
0.00821775
0.102241
0.00831324
0.110287
0.00850759
0.122879
0.0086366
0.140201
0.00846483
0.162476
0.00773778
0.188558
0.00625272
0.217619
0.0038046
0.2489
0.313787
0.00855428
0.0954176
-0.00793817
0.00876819
0.102027
0.00895901
0.110096
0.00924261
0.122595
0.00946437
0.139979
0.00935026
0.16259
0.00861167
0.189297
0.00699707
0.219234
0.00430867
0.251588
0.318095
0.00878618
0.0945681
-0.00793672
0.00917071
0.101642
0.00944585
0.109821
0.00980462
0.122237
0.0101135
0.13967
0.0100646
0.162639
0.00934304
0.190019
0.00764356
0.220933
0.00475835
0.254474
0.322854
0.00905952
0.0934252
-0.00791663
0.0096039
0.101098
0.00992568
0.109499
0.0103347
0.121827
0.0107214
0.139284
0.0107407
0.16262
0.0100408
0.190718
0.00825902
0.222715
0.00518555
0.257547
0.328039
0.00885088
0.0924186
-0.00784424
0.00953995
0.100409
0.00996656
0.109073
0.0104264
0.121368
0.0108999
0.13881
0.0110108
0.162509
0.0104183
0.191311
0.00864075
0.224492
0.00550569
0.260682
0.333545
-0.0504298
0.0856864
0.0571619
-0.0428431
0.0928222
-0.0368846
0.103114
-0.0311716
0.115655
-0.0255637
0.133202
-0.0197899
0.156735
-0.0137796
0.185301
-0.00781029
0.218523
-0.00356096
0.256433
0.329984
-0.068108
0.0785626
0.0752318
-0.0606039
0.0853181
-0.0533295
0.0958397
-0.0455375
0.107863
-0.037889
0.125554
-0.0298766
0.148723
-0.0213486
0.176773
-0.0127864
0.209961
-0.00591461
0.249561
0.324069
-0.0874624
0.0711727
0.0948524
-0.0790062
0.0768618
-0.0698875
0.0867209
-0.0604987
0.0984739
-0.0512936
0.116349
-0.0410179
0.138447
-0.0298177
0.165572
-0.0182487
0.198392
-0.00817751
0.23949
0.315892
-0.108799
0.0627827
0.117189
-0.0982167
0.0662798
-0.0879881
0.0764924
-0.0776372
0.0881229
-0.0664998
0.105211
-0.05348
0.125427
-0.0393211
0.151414
-0.0244218
0.183492
-0.0108521
0.22592
0.30504
-0.131039
0.0526587
0.141163
-0.120101
0.0553414
-0.109787
0.066178
-0.0977413
0.0760777
-0.0840822
0.0915521
-0.0683725
0.109718
-0.0511802
0.134221
-0.0322398
0.164552
-0.0141004
0.207781
0.290939
-0.157633
0.0428269
0.167464
-0.146545
0.0442538
-0.135046
0.0546795
-0.120765
0.0617966
-0.105017
0.0758036
-0.0866039
0.0913047
-0.0657857
0.113403
-0.0421645
0.140931
-0.0193593
0.184976
0.27158
-0.189144
0.0312333
0.200738
-0.178253
0.0333629
-0.165053
0.0414796
-0.149492
0.0462351
-0.132047
0.0583587
-0.110492
0.0697495
-0.0855754
0.0884866
-0.0571468
0.112502
-0.0276526
0.155481
0.243927
-0.227546
0.0204104
0.238369
-0.215374
0.0211907
-0.200536
0.0266414
-0.184018
0.0297178
-0.164185
0.0385255
-0.140084
0.0456486
-0.112229
0.0606315
-0.0797576
0.0800307
-0.0428456
0.118569
0.201082
-0.278251
0.00861593
0.290046
-0.266221
0.00916004
-0.25123
0.011651
-0.235045
0.0135326
-0.214446
0.0179269
-0.190885
0.0220873
-0.161407
0.0311529
-0.124348
0.0429725
-0.0735486
0.0677697
0.127533
-0.343786
0.352402
-0.334626
-0.322975
-0.309443
-0.291516
-0.269428
-0.238275
-0.195303
-0.127533
0.00506822
0.0591031
-0.00700936
0.00226013
0.0780399
-0.000446146
0.0975587
-0.00234515
0.119088
-0.00399108
0.142809
-0.00530648
0.16878
-0.00580954
0.201241
-0.00578191
0.238341
-0.00394259
0.288206
0.34846
0.00542047
0.0606909
-0.00700835
0.00293035
0.08053
0.00035328
0.100136
-0.00170636
0.121147
-0.00346913
0.144572
-0.00484544
0.170156
-0.00548473
0.20188
-0.00547902
0.238336
-0.0037987
0.286526
0.344661
0.00606932
0.0616228
-0.00700118
0.00393895
0.0826604
0.00154945
0.102525
-0.000678663
0.123376
-0.0024803
0.146373
-0.00391746
0.171593
-0.00468258
0.202645
-0.00472851
0.238382
-0.00343909
0.285237
0.341222
0.00675011
0.0618855
-0.00701279
0.00501785
0.0843927
0.00278719
0.104756
0.000521932
0.125641
-0.00131892
0.148214
-0.00282486
0.173099
-0.00368849
0.203509
-0.00389821
0.238591
-0.00298038
0.284319
0.338241
0.00744693
0.0614891
-0.00705058
0.00615114
0.0856884
0.00409852
0.106809
0.00191857
0.127821
-0.000125193
0.150258
-0.00164075
0.174615
-0.00259614
0.204464
-0.00301501
0.23901
-0.00243766
0.283742
0.335804
0.00819261
0.060416
-0.00711944
0.00738593
0.0864951
0.00553491
0.10866
0.00341427
0.129941
0.00141414
0.152258
-0.000375816
0.176405
-0.00140536
0.205494
-0.00206543
0.23967
-0.00183498
0.283511
0.333969
0.00897885
0.0586641
-0.00722699
0.00871634
0.0867576
0.00710577
0.11027
0.0050494
0.131998
0.00302924
0.154278
0.00119481
0.178239
-9.85564e-05
0.206787
-0.00104295
0.240615
-0.00117741
0.283646
0.332791
0.0097837
0.0562619
-0.00738143
0.0101102
0.0864311
0.00878742
0.111593
0.00681157
0.133974
0.0047618
0.156328
0.00285896
0.180142
0.00134048
0.208306
-1.22096e-06
0.241956
-0.000463168
0.284108
0.332328
0.010584
0.0532667
-0.00758886
0.0115318
0.0854834
0.0105457
0.112579
0.00867349
0.135846
0.00659522
0.158406
0.00458787
0.182149
0.00285865
0.210035
0.00133362
0.243481
0.000279745
0.285161
0.332608
0.0113548
-0.00785461
0.0129434
0.0123414
0.0106056
0.00849835
0.00638597
0.00444176
0.0026085
0.00101825
0.000596485
-0.00189597
0.0018341
-0.00567118
0.00341533
-0.00863876
0.0051338
-0.0106364
0.00686998
-0.0117619
0.00857124
-0.0122005
0.0102284
-0.0121408
0.0118581
-0.0117419
0.0134945
-0.0111325
-0.010454
0.000659418
-0.00255539
0.00195691
-0.00696867
0.00354503
-0.0102269
0.00520374
-0.0122951
0.00682264
-0.0133808
0.00836726
-0.0137451
0.00984595
-0.0136195
0.0112862
-0.0131821
0.0127182
-0.0125645
-0.0118812
0.000704187
-0.00325958
0.00201252
-0.00827701
0.00353599
-0.0117504
0.00505372
-0.0138128
0.00647475
-0.0148018
0.00778805
-0.0150584
0.00902054
-0.014852
0.01021
-0.0143715
0.0113878
-0.0137423
-0.0130563
0.00072526
-0.00398484
0.00198954
-0.00954129
0.00337716
-0.013138
0.0046816
-0.0151173
0.00584051
-0.0159607
0.00686913
-0.016087
0.00781227
-0.0157951
0.00871727
-0.0152765
0.00962061
-0.0146457
-0.0139768
0.000717964
-0.0047028
0.00188169
-0.010705
0.00306927
-0.0143255
0.00410348
-0.0161515
0.00495638
-0.0168136
0.00566871
-0.0167994
0.0062995
-0.0164259
0.00690197
-0.015879
0.00751514
-0.0152588
-0.0146245
0.000679183
-0.00538198
0.00168884
-0.0117147
0.00262434
-0.015261
0.00334968
-0.0168768
0.00387278
-0.0173367
0.0042555
-0.0171821
0.00456525
-0.0167357
0.00485593
-0.0161696
0.00516511
-0.015568
-0.0149757
0.000607897
-0.00598988
0.001417
-0.0125238
0.00206337
-0.0159074
0.00245939
-0.0172729
0.00264589
-0.0175232
0.00269922
-0.0172354
0.00268868
-0.0167252
0.00266376
-0.0161447
0.0026555
-0.0155598
-0.0150096
0.00050544
-0.00649532
0.00107754
-0.0130959
0.00141329
-0.0162432
0.00147536
-0.0173349
0.00133149
-0.0173794
0.00106476
-0.0169687
0.000741203
-0.0164016
0.000403622
-0.0158071
7.74082e-05
-0.0152335
-0.0146922
0.000375379
-0.0068707
0.000685559
-0.013406
0.00070373
-0.0162613
0.000439665
-0.0170708
-2.01945e-05
-0.0169195
-0.000590156
-0.0163987
-0.00121386
-0.0157779
-0.00185818
-0.0151628
-0.00250792
-0.0145838
-0.0140501
0.000222912
-0.00709361
0.000258522
-0.0134417
-3.58238e-05
-0.015967
-0.000608171
-0.0164985
-0.0013608
-0.0161669
-0.00221485
-0.0155447
-0.00312129
-0.0148715
-0.00405616
-0.0142279
-0.00500967
-0.0136303
-0.0130789
8.75268e-05
-0.00718114
-0.000141249
-0.0132129
-0.000734192
-0.0153741
-0.00159644
-0.0156363
-0.00262351
-0.0151398
-0.00374289
-0.0144253
-0.00491527
-0.0136991
-0.00612377
-0.0130194
-0.00736366
-0.0123904
-0.0118049
-7.90681e-05
-0.00710207
-0.00057515
-0.0127168
-0.00144459
-0.0145046
-0.00256579
-0.0145151
-0.00383439
-0.0138712
-0.00518724
-0.0130724
-0.00659405
-0.0122923
-0.00804363
-0.0115699
-0.00953424
-0.0108998
-0.0102698
-0.000246038
-0.00685603
-0.000994134
-0.0119687
-0.0021145
-0.0133843
-0.00346413
-0.0131654
-0.00494368
-0.0123917
-0.00650039
-0.0115157
-0.00811177
-0.0106809
-0.00977067
-0.00991096
-0.0114767
-0.00919383
-0.00851335
-0.000407513
-0.00644852
-0.00138675
-0.0109895
-0.0027282
-0.0120428
-0.00427385
-0.0116198
-0.00593235
-0.0107332
-0.0076615
-0.00978659
-0.00944555
-0.00889683
-0.01128
-0.00807649
-0.0131646
-0.00730926
-0.006576
-0.000558276
-0.00589024
-0.00174334
-0.0098044
-0.00327401
-0.0105121
-0.00498236
-0.00991143
-0.0067868
-0.00892872
-0.00865547
-0.00791793
-0.0105787
-0.00697363
-0.0125539
-0.00610126
-0.0145801
-0.00528303
-0.00449773
-0.000694122
-0.00519612
-0.00205691
-0.00844162
-0.00374426
-0.00882478
-0.00558208
-0.0080736
-0.00749891
-0.0070119
-0.00947272
-0.00594412
-0.0114997
-0.00494663
-0.0135796
-0.00402136
-0.0157103
-0.00315233
-0.0023176
-0.000811981
-0.00438414
-0.00232303
-0.00693057
-0.00413527
-0.00701254
-0.00607059
-0.00613828
-0.00806669
-0.00501579
-0.0101102
-0.00390061
-0.0122033
-0.00285354
-0.0143492
-0.00187548
-0.0165454
-0.000956102
-7.49306e-05
-0.000909858
-0.00347428
-0.00253966
-0.00530077
-0.00444708
-0.00510511
-0.00645096
-0.00413441
-0.00849589
-0.00297086
-0.0105747
-0.00182183
-0.0126944
-0.000733775
-0.0148635
0.000293624
-0.0170824
0.00126275
0.00218563
-0.000986645
-0.00248764
-0.00270655
-0.00358086
-0.00468272
-0.00312894
-0.00673161
-0.00208552
-0.00880195
-0.000900522
-0.0108887
0.000264947
-0.0130001
0.0013776
-0.0151479
0.00244146
-0.0173356
0.00345036
0.00442466
-0.00104179
-0.00144585
-0.00282434
-0.00179831
-0.00484647
-0.00110681
-0.00692424
-7.75699e-06
-0.00901014
0.00118538
-0.0111003
0.00235508
-0.013199
0.00347633
-0.0153136
0.00455609
-0.0174601
0.00559687
0.00655173
-0.00107619
-0.000369662
-0.00289613
2.16287e-05
-0.00494402
0.000941078
-0.00703877
0.00208699
-0.00914174
0.00328835
-0.0112614
0.00447473
-0.0134199
0.00563482
-0.0156454
0.00678159
-0.0179796
0.00793107
0.00912494
-0.00108693
0.000717268
-0.00291421
0.00184891
-0.00496269
0.00298956
-0.00705438
0.00417868
-0.00915517
0.00538914
-0.0112762
0.00659575
-0.0134353
0.00779395
-0.0156425
0.00898874
-0.0178931
0.0101817
0.0113614
-0.00107325
0.00179052
-0.00287886
0.00365453
-0.00490138
0.00501208
-0.00696258
0.00623989
-0.00902585
0.00745241
-0.0110956
0.00866555
-0.0131773
0.0098756
-0.0152633
0.0110747
-0.0173308
0.0122493
0.0133701
-0.00103591
0.00282643
-0.00279086
0.00540947
-0.00475957
0.00698078
-0.00676063
0.00824095
-0.00875022
0.00944199
-0.0107238
0.0106392
-0.0126778
0.0118296
-0.0146002
0.0129971
-0.0164744
0.0141235
0.0151868
-0.000976511
0.00380294
-0.00265311
0.00708607
-0.00454135
0.00886902
-0.00645518
0.0101548
-0.0083418
0.0113286
-0.0101893
0.0124867
-0.0119908
0.0136312
-0.013738
0.0147442
-0.0154261
0.0158115
0.0168241
-0.000897447
0.00470039
-0.00247055
0.00865917
-0.00425459
0.0106531
-0.00605901
0.0119592
-0.00782187
0.0130915
-0.00952596
0.0141907
-0.011165
0.0152702
-0.0127367
0.016316
-0.0142459
0.0173207
0.0182866
-0.00080181
0.0055022
-0.00224969
0.0101071
-0.00390969
0.0123131
-0.00558796
0.0136375
-0.00721388
0.0147174
-0.00876625
0.0157431
-0.0102404
0.0167444
-0.0116396
0.0177151
-0.012974
0.0186551
0.0195744
-0.000693122
0.00619532
-0.00199809
0.011412
-0.00351834
0.0138333
-0.0050588
0.0151779
-0.00654075
0.0161993
-0.00793912
0.0171415
-0.00925041
0.0180557
-0.010481
0.0189457
-0.0116436
0.0198177
0.0206861
-0.000575034
0.00677036
-0.00172368
0.0125607
-0.00309261
0.0152023
-0.00448803
0.0165733
-0.00582361
0.0175349
-0.00706996
0.0183878
-0.00822321
0.0192089
-0.00929077
0.0200133
-0.0102851
0.020812
0.0216219
-0.000450819
0.00722117
-0.00143427
0.0135441
-0.00264427
0.0164123
-0.00389108
0.0178202
-0.0050815
0.0187253
-0.00618093
0.0194873
-0.00718353
0.0202115
-0.00809586
0.0209256
-0.00892849
0.0216447
0.0223855
-0.000357524
0.0075787
-0.00118239
0.014369
-0.0022302
0.0174601
-0.00332472
0.0189147
-0.00436917
0.0197698
-0.00532385
0.0204419
-0.00617974
0.0210674
-0.0069412
0.0216871
-0.00761606
0.0223196
0.0229797
-0.000243568
0.00782227
-0.000900982
0.0150264
-0.00178476
0.0183438
-0.00273067
0.0198606
-0.00363787
0.020677
-0.00446062
0.0212647
-0.00518563
0.0217924
-0.00581426
0.0223157
-0.00635157
0.0228569
0.0234273
-0.000135162
0.00795743
-0.000626974
0.0155182
-0.0013475
0.0190644
-0.00214803
0.0206611
-0.00292514
0.0214541
-0.00362697
0.0219665
-0.00423524
0.0224007
-0.00474795
0.0228284
-0.00516785
0.0232767
0.0237532
-3.48382e-05
0.00799227
-0.00036532
0.0158487
-0.000925778
0.0196248
-0.00158546
0.0213208
-0.0022404
0.022109
-0.00283298
0.0225591
-0.00333955
0.0229072
-0.00375459
0.0232435
-0.00407935
0.0236015
0.0239851
5.73876e-05
0.00793488
-0.000118539
0.0160246
-0.000525511
0.0200318
-0.00104977
0.0218451
-0.00159065
0.0226499
-0.00208554
0.023054
-0.00250522
0.0233269
-0.0028404
0.0235787
-0.00309179
0.0238529
0.0241517
0.00013789
0.00779699
0.000105728
0.0160568
-0.00015126
0.0202888
-0.00054605
0.0222399
-0.000980646
0.0230845
-0.00138854
0.0234619
-0.0017349
0.0236733
-0.00200581
0.0238496
-0.00220181
0.0240489
0.024279
0.000206927
0.00759006
0.000305724
0.015958
0.000192728
0.0204018
-7.7535e-05
0.0225101
-0.000413325
0.0234203
-0.000743705
0.0237923
-0.00102864
0.0239582
-0.00124812
0.0240691
-0.00139831
0.0241991
0.0243837
0.000264881
0.00732518
0.000484289
0.0157386
0.000504721
0.0203813
0.00035255
0.0226623
0.000109898
0.023663
-0.0001507
0.0240529
-0.000383289
0.0241908
-0.00056308
0.0242488
-0.000667944
0.0243039
0.0244613
0.000311924
0.00701326
0.000639458
0.015411
0.000784938
0.0202359
0.000744688
0.0227025
0.000588838
0.0238188
0.00038999
0.0242517
0.000200339
0.0243804
5.35199e-05
0.0243957
-3.79455e-05
0.0243954
0.0244208
0.000348607
0.00666465
0.000771561
0.0149881
0.00103312
0.0199743
0.00109925
0.0226364
0.00102554
0.0238925
0.000883154
0.0243941
0.000730489
0.0245331
0.000613036
0.0245131
0.000596987
0.0244115
0.0242932
0.000374183
0.00629047
0.000882528
0.0144797
0.00125551
0.0196013
0.00142764
0.0224643
0.00143566
0.0238845
0.00134163
0.0244881
0.0011947
0.02468
0.00100868
0.0246991
0.000715455
0.0247047
0.0249322
0.000400525
0.00588994
0.000984176
0.0138961
0.00145744
0.0191281
0.00172683
0.0221949
0.00180976
0.0238016
0.0017584
0.0245395
0.00161702
0.0248214
0.0014016
0.0249146
0.00109465
0.0250116
0.025303
0.000418008
0.00547193
0.00106539
0.0132487
0.00163163
0.0185618
0.00199726
0.0218292
0.00216034
0.0236385
0.00216463
0.0245352
0.00205542
0.0249306
0.00186062
0.0251094
0.00159426
0.025278
0.025589
0.000427937
0.005044
0.00112796
0.0125487
0.00178003
0.0179098
0.00224148
0.0213678
0.00249099
0.023389
0.00256321
0.024463
0.00250375
0.0249901
0.00234902
0.0252641
0.00213023
0.0254968
0.0258197
0.000431436
0.00461256
0.00117348
0.0118066
0.0019038
0.0171794
0.00245991
0.0208117
0.00280093
0.023048
0.00295061
0.0243133
0.00295301
0.0249877
0.00285087
0.0253662
0.00268648
0.0256612
0.0259928
0.000429488
0.00418307
0.00120322
0.0110329
0.00200345
0.0163792
0.00265176
0.0201634
0.00308801
0.0226117
0.00332338
0.0240779
0.00339844
0.0249126
0.00335976
0.0254049
0.00325551
0.0257654
0.0261111
0.000422946
0.00376013
0.00121827
0.0102376
0.00207913
0.0155184
0.00281559
0.0194269
0.00334919
0.0220781
0.0036772
0.0237499
0.00383434
0.0247555
0.00386799
0.0253713
0.00382856
0.0258048
0.0261741
0.000412561
0.00334757
0.00121958
0.00943057
0.00213073
0.0146072
0.00294941
0.0186082
0.00358045
0.0214471
0.00400615
0.0233242
0.00425306
0.0245086
0.00436666
0.0252577
0.00439769
0.0257738
0.026177
0.000399031
0.00294854
0.00120811
0.00862149
0.00215814
0.0136572
0.00305094
0.0177154
0.00377698
0.020721
0.00430311
0.0227981
0.00464562
0.0241661
0.00484569
0.0250576
0.00495317
0.0256663
0.0261129
0.000383059
0.00256548
0.00118512
0.00781944
0.00216177
0.0126805
0.00311829
0.0167589
0.00393396
0.0199054
0.00456039
0.0221717
0.00500195
0.0237245
0.00529332
0.0247662
0.005482
0.0254777
0.0259762
0.000348249
0.00221723
0.0011212
0.00704649
0.00210331
0.0116984
0.00310773
0.0157545
0.00400538
0.0190077
0.00473268
0.0214444
0.00527991
0.0231773
0.00567234
0.0243738
0.00595261
0.0251974
0.0257576
0.000326195
0.00189103
0.00107367
0.00629901
0.00205534
0.0107167
0.00309648
0.0147133
0.00406423
0.01804
0.00488245
0.0206262
0.00552767
0.0225321
0.00601449
0.023887
0.00637903
0.0248328
0.0254675
0.000302734
0.0015883
0.00101764
0.00558411
0.00198617
0.00974821
0.00304905
0.0136504
0.00407355
0.0170155
0.0049733
0.0197264
0.00571114
0.0217942
0.00628964
0.0233085
0.00673667
0.0243858
0.0251076
0.000277917
0.00131038
0.000953786
0.00490824
0.001897
0.008805
0.00296608
0.0125814
0.00403215
0.0159494
0.00500146
0.0187571
0.00582406
0.0209716
0.00648969
0.0226429
0.00701639
0.0238591
0.0246808
0.000251795
0.00105859
0.000882865
0.00427717
0.00178942
0.00789844
0.0028492
0.0115216
0.00394052
0.0148581
0.00496534
0.0177323
0.00586256
0.0200744
0.00660886
0.0218966
0.00721086
0.0232571
0.0241916
0.000224434
0.000834153
0.000805683
0.00369592
0.00166536
0.00703877
0.00270103
0.0104859
0.00380087
0.0137582
0.00486578
0.0166674
0.00582569
0.0191145
0.00664483
0.0210774
0.00731703
0.0225849
0.0236457
0.000195907
0.000638246
0.000723112
0.00316871
0.00152707
0.00623481
0.00252508
0.00948789
0.00361714
0.0126662
0.00470612
0.0155784
0.00571562
0.018105
0.0065991
0.0201939
0.00733769
0.0218463
0.0230452
0.000166309
0.000471937
0.000636122
0.0026989
0.00137714
0.00549379
0.00232572
0.00853932
0.0033949
0.011597
0.00449216
0.0144811
0.0055377
0.0170595
0.0064774
0.0192542
0.00728185
0.0210419
0.0223904
0.000135803
0.000336133
0.000545866
0.00228884
0.00121857
0.0048211
0.00210816
0.00764972
0.0031412
0.010564
0.00423174
0.0133906
0.00529881
0.0159924
0.00628445
0.0182686
0.0071651
0.0201612
0.0216388
0.000104673
0.00023146
0.00045379
0.00193972
0.00105485
0.00422004
0.00187858
0.00682599
0.00286475
0.00957779
0.00393521
0.0123201
0.00500933
0.0149183
0.00602336
0.0172546
0.00697056
0.019214
0.0207652
7.32542e-05
0.000158206
0.000362039
0.00165094
0.000891773
0.0036903
0.00164814
0.00606962
0.00258315
0.00864278
0.00362549
0.0112778
0.00469228
0.0138515
0.00569305
0.0162538
0.00651368
0.0183934
0.0202695
4.31318e-05
0.000115074
0.000273824
0.00142024
0.000733346
0.00323078
0.00142067
0.00538229
0.00229977
0.00776369
0.00330822
0.0102693
0.00436746
0.0127923
0.00539116
0.0152301
0.00629047
0.0174941
0.0195516
1.40197e-05
0.000101055
0.00018959
0.00124467
0.000582715
0.00283766
0.00120428
0.00476073
0.00203013
0.00693784
0.00300901
0.00929047
0.00407164
0.0117296
0.0051399
0.0141618
0.00613437
0.0164996
0.0186848
-1.36255e-05
0.00011468
0.00011205
0.001119
0.000445005
0.0025047
0.00100671
0.00419902
0.00178401
0.00616053
0.00273699
0.00833749
0.00380636
0.0106602
0.00492125
0.0130469
0.0060079
0.015413
0.0176799
-3.80889e-05
0.000152769
4.40996e-05
0.00103681
0.000325222
0.00222358
0.000835151
0.0036891
0.00157023
0.00542546
0.00250092
0.00740679
0.00357795
0.00958322
0.0047386
0.0118863
0.00591505
0.0142365
0.0165444
-5.8502e-05
0.000211272
-1.09886e-05
0.000989296
0.000228291
0.0019843
0.000696488
0.0032209
0.00139746
0.00472448
0.00231083
0.00649342
0.00339691
0.00849714
0.00460152
0.0106817
0.00586245
0.0129756
0.0152874
-7.38369e-05
0.000285109
-5.12638e-05
0.000966723
0.00015888
0.00177416
0.000597261
0.00278252
0.00127385
0.0040479
0.00217615
0.00559112
0.00327332
0.00739997
0.00451951
0.00943548
0.00585808
0.011637
0.0139185
-8.28736e-05
0.000367982
-7.29652e-05
0.000956815
0.000121857
0.00157934
0.000543808
0.00236057
0.0012069
0.00338481
0.00210516
0.00469286
0.0032158
0.00628932
0.00450105
0.00815023
0.00591022
0.0102278
0.0124472
-8.44399e-05
0.000452422
-7.32709e-05
0.000945646
0.00012225
0.00138381
0.000542851
0.00193997
0.00120439
0.00272327
0.00210599
0.00379126
0.00323223
0.00516308
0.00455343
0.00682903
0.0060256
0.00875567
0.010884
-7.73449e-05
-4.88842e-05
0.000165687
0.000602293
0.00127586
0.00218876
0.00333222
0.00468501
0.00621107
)
;
boundaryField
{
inlet
{
type calculated;
value uniform 0;
}
outlet
{
type calculated;
value nonuniform List<scalar>
40
(
0.0734391
0.103724
0.127416
0.148791
0.17387
0.207047
0.249306
0.299169
0.352013
0.3961
0.0141424
0.0116678
0.00911028
0.00648292
0.00380515
0.00110133
-0.00160445
-0.00427861
-0.00688229
-0.00938251
-0.0117466
-0.0139502
-0.0159784
-0.0178257
-0.0194953
-0.0209982
-0.0223515
-0.0235764
-0.0246963
-0.0257354
-0.10422
-0.117548
-0.132127
-0.149588
-0.171887
-0.200332
-0.233299
-0.264609
-0.286874
-0.298199
)
;
}
cylinder
{
type calculated;
value uniform 0;
}
top
{
type symmetryPlane;
value uniform 0;
}
bottom
{
type symmetryPlane;
value uniform 0;
}
defaultFaces
{
type empty;
value nonuniform 0();
}
}
// ************************************************************************* //
|
|
ec7b2147d1668b2c2f8913737f2dca706b5dd45a
|
0eff74b05b60098333ad66cf801bdd93becc9ea4
|
/second/download/curl/gumtree/curl_repos_function_1161_last_repos.cpp
|
8f6c07325c0d9e083a2f87e247f5bb685137bbe9
|
[] |
no_license
|
niuxu18/logTracker-old
|
97543445ea7e414ed40bdc681239365d33418975
|
f2b060f13a0295387fe02187543db124916eb446
|
refs/heads/master
| 2021-09-13T21:39:37.686481
| 2017-12-11T03:36:34
| 2017-12-11T03:36:34
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 230
|
cpp
|
curl_repos_function_1161_last_repos.cpp
|
static CURLcode imap_continue_authenticate(struct connectdata *conn,
const char *resp)
{
struct imap_conn *imapc = &conn->proto.imapc;
return Curl_pp_sendf(&imapc->pp, "%s", resp);
}
|
19b36817c4ac19331718b726ee68a133ac25c61e
|
9c7c58220a546d583e22f8737a59e7cc8bb206e6
|
/Project/MyProject/MyProject/Source/MyProject/Private/BaseFrame/Libs/FrameHandle/DaoJiShiTimer.h
|
bcfc61c2731205d0169361c23ece4d08c09790de
|
[] |
no_license
|
SiCoYu/UE
|
7176f9ece890e226f21cf972e5da4c3c4c4bfe41
|
31722c056d40ad362e5c4a0cba53b05f51a19324
|
refs/heads/master
| 2021-03-08T05:00:32.137142
| 2019-07-03T12:20:25
| 2019-07-03T12:20:25
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 333
|
h
|
DaoJiShiTimer.h
|
#ifndef __DaoJiShiTimer_H
#define __DaoJiShiTimer_H
#include "TimerItemBase.h"
#include "PlatformDefine.h"
MY_BEGIN_NAMESPACE(MyNS)
/**
* @brief 倒计时定时器
*/
class DaoJiShiTimer : public TimerItemBase
{
public:
virtual void OnTimer(float delta) override;
virtual void reset() override;
};
MY_END_NAMESPACE
#endif
|
4f1e3c6273eb83758a01e363e28d0db07a28b84c
|
37bf77c75be5e4a1e43ae67c195697b5a9c018c0
|
/src/api/xui/widgets/sourcesink/XUIGroupEventSource.h
|
7ff64e039d588866cdfab293af0eebc26886f7b5
|
[
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
mecctro/wasabi
|
dbaa656ad71f719fa7b227346dc892058212f96d
|
49d293042ce17b0d137b2e4c6fc82a52bdb05091
|
refs/heads/master
| 2020-12-29T01:11:56.251711
| 2013-09-01T20:08:51
| 2013-09-01T20:08:51
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 947
|
h
|
XUIGroupEventSource.h
|
// ----------------------------------------------------------------------------
// Generated by SourceSink Factory - DO NOT EDIT
//
// File : ../sourcesink/XUIGroupEventSource.h
// Class : XUIGroup
// class layer : Event Source for XUIGroup
// ----------------------------------------------------------------------------
#ifndef XUIGROUPEVENTSOURCE_H
#define XUIGROUPEVENTSOURCE_H
#include <bfc/eventsource.h>
class XUIObject;
class XUIGroupEventSink;
// ----------------------------------------------------------------------------
class XUIGroupEventSource {
protected:
XUIGroupEventSource() {}
virtual ~XUIGroupEventSource() {}
public:
void registerXUIGroupEventSink(XUIGroupEventSink *sink) { m_sinks.addItem(sink); }
void unregisterXUIGroupEventSink(XUIGroupEventSink *sink) { m_sinks.removeItem(sink); }
private:
PtrList<XUIGroupEventSink> m_sinks;
};
#endif // XUIGROUPEVENTSOURCE_H
|
5274a501d83f6f747a48aee8e0435afb9b0c3717
|
31ea1a7466ce98e76c5359d4683723fbc8b39334
|
/cpp-opencv-app/tests/Jetson-TK1-main(old)/v3.3.1/opencv-app/include/watchdog_class.cpp
|
837a6f099da64a071345685b8990a495500f0282
|
[] |
no_license
|
KNR-Selfie/selfie_carolocup2018
|
7f86da87071b9433704f65bdf013c6b07a3ba957
|
28408e3b4d944e7c6c6986ea6656df1690d6d6f7
|
refs/heads/master
| 2020-04-02T10:10:52.053330
| 2018-10-23T13:03:18
| 2018-10-23T13:03:18
| 154,328,051
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,725
|
cpp
|
watchdog_class.cpp
|
#include "watchdog_class.hpp"
bool Watchdog::init()
{
mem_id = shmget(key, MEMSIZE, IPC_CREAT | 0666);
if(mem_id < 0)
{
std::cout << "Error getting memmory access at given key" << std::endl;
return 0;
}
shared_variable = (char*) shmat(mem_id, NULL, 0);
if(shared_variable == (char*) -1)
{
std::cout << "Error at first memmory read" << std::endl;
return 0;
}
return 1;
}
bool Watchdog::get_access()
{
mem_id = shmget(key, MEMSIZE, 0666);
if(mem_id < 0)
{
std::cout << "Error getting memmory access at given key" << std::endl;
return 0;
}
shared_variable = (char*) shmat(mem_id, NULL, 0);
if(shared_variable == (char*) -1)
{
std::cout << "Error at first memmory read" << std::endl;
return 0;
}
return 1;
}
void Watchdog::push_flag(unsigned short flag)
{
switch(flag)
{
case 0:
memcpy(shared_variable, "0", 2);
break;
case 1:
memcpy(shared_variable, "1", 2);
break;
case 2:
memcpy(shared_variable, "2", 2);
break;
default:
std::cout << "Error wrong argument given!" << std::endl;
break;
}
end_of_variable = shared_variable;
end_of_variable += 1;
*end_of_variable = 0;
}
unsigned short Watchdog::pull_flag()
{
switch(*shared_variable)
{
case '0':
return 0;
break;
case '1':
return 1;
break;
case '2':
return 2;
break;
default:
std::cout << "Error unknown flag in shared memmory!" << std::endl;
break;
}
return 10;
}
void Watchdog::close()
{
system("ipcrm -M 55555");
}
|
de64ea8cee401cca30001336aae3ec8fa36129f2
|
225d6c61037d82a94285fcb33bc00be6048ca2e6
|
/spec/helpers/fake_file.cc
|
de8333c1b002578568c696ee3715458a53506f31
|
[
"MIT"
] |
permissive
|
fweiss/mcu-gif
|
927c8fbe8bfc3f102d54b88787054aa3d484febe
|
2f8a558b52db009c7c9805a3b080cd3c092748d8
|
refs/heads/master
| 2022-10-03T11:23:45.416112
| 2022-09-13T17:21:23
| 2022-09-13T17:21:23
| 216,144,197
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,672
|
cc
|
fake_file.cc
|
#include "fake_file.h"
#include <algorithm>
#include <iostream>
static const uint8_t *f_read_data = 0;
static size_t f_read_data_length = 0;
static size_t f_read_pos = 0;
ssize_t ff_read(void *buf, size_t rep, size_t count, void* fp) {
// printf("read %d %p %ld: %lx\n", fd, buf, count, f_read_pos);
size_t available = std::min(count, f_read_data_length - f_read_pos);
memcpy(buf, &f_read_data[f_read_pos], available);
f_read_pos += available;
return available;
}
extern void ff_open_memory(const uint8_t *data, long size) {
f_read_data = data;
f_read_data_length = size;
f_read_pos = 0;
}
extern void ff_open_memory(const vector<uint8_t> &data) {
// f_open_memory(data.data(), data.size());
f_read_data = data.data();
f_read_data_length = data.size();
f_read_pos = 0;
}
extern size_t ff_read_get_pos() {
return f_read_pos;
}
extern void ff_print_memory() {
std::cout << "=== hello " << std::hex;
// for (auto uint8_t& c : x)
for (int i=0; i < f_read_data_length; i++)
std::cout << "'" << (uint8_t)f_read_data[i]+0 << "' ";
std::cout << "\n";
}
// a little DSL to concatenate vectors
// provides for constructing test files out of blocks
// doesn't have to be efficient
std::vector<uint8_t> operator+(const std::vector<uint8_t>& lhs, const std::vector<uint8_t>& rhs)
{
if (lhs.empty()) return rhs;
if (rhs.empty()) return lhs;
std::vector<uint8_t> result {};
// printf("+ %d\n", lhs[0]);
result.reserve(lhs.size() + rhs.size());
result.insert(result.cend(), lhs.cbegin(), lhs.cend());
result.insert(result.cend(), rhs.cbegin(), rhs.cend());
return result;
}
|
c37b8ce024ac5280f2a0107ca8d67252c64e15c3
|
fe4de0070b7d7877e9b5712718c6956cc7e2108a
|
/term_Q2.cpp
|
58793bdc947b43ab853dbdcdd4bab06fef5bd17f
|
[] |
no_license
|
snghx/C_term-project
|
daed098fb8efbc90469baad6089eb38f3aabb7bb
|
856c725e38223294d999a2b6f1c2c861370cdffe
|
refs/heads/main
| 2023-03-22T15:45:23.587485
| 2021-03-11T10:18:03
| 2021-03-11T10:18:03
| 346,660,427
| 0
| 0
| null | null | null | null |
UHC
|
C++
| false
| false
| 933
|
cpp
|
term_Q2.cpp
|
//// [과제 02번] 소비자경제학과-2학년-1913455-노승혜
//#define _CRT_SECURE_NO_WARNINGS
//#include <stdio.h>
//
//int main(void) {
// int score[5];
// int i;
// for (i = 0; i < 5; i++) { //학생 점수를 입력받아 배열을 생성하기 위한 for문
// printf("%d, 학생 점수(0~100)? ", i + 1);
// scanf("%d", &score[i]);
// }
//
// float avg = (float)((score[0] + score[1] + score[2] + score[3] + score[4])) / 5; //평균값 avg에 저장
// int max = 0;
// int min=100;
//
// for (i = 0; i < 5; i++) { //최고 점수 구하는 for문
// if (max < score[i])
// max = score[i];
// }
//
// for (i = 0; i < 5; i++) { //최저 점수 구하는 for문
// if (min > score[i])
// min = score[i];
// }
//
// for (i = 0; i < 5; i++)
// printf("%d, ", score[i]);
// printf("=> 평균 점수: %.2f\n", avg);
// printf("최고 점수:%d, 최저 점수:%d\n", max, min);
//}
|
6aa4498906f0b56d74a0977eee4165a7e4a11baf
|
5b659a16e5b59f17921dd978192629eae39f1b6b
|
/vs_2015_project/CPlusPlus_WinodwsProgramming/create_request_value/create.cpp
|
b5bf4a4d554a55689c4dbacdfa9d71dd1187e283
|
[] |
no_license
|
jennyliuuu/program_practice
|
34d00d1985a1386948317f88c5865d11f72306cc
|
2944bb0e0b37adefd00cec4fb032282c0b67e237
|
refs/heads/master
| 2021-05-10T21:36:51.885775
| 2019-04-26T09:54:07
| 2019-04-26T09:54:07
| 118,232,216
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 286
|
cpp
|
create.cpp
|
#include <fstream>
#include <iostream>
using namespace std;
#define size 3000
void main()
{
fstream file;
char *str = new char[size];
memset(str, 'a', size);
file.open("Reader.txt", ios::out | ios::trunc);
file.write(str, size);
file.close();
delete[] str;
}
|
f3647c879c129f0bf936b9fadc3b9e3d2dc73746
|
e43a8b36acce69fd4dea0443e36c7806a114c00a
|
/rekayasa saya/anakAyams.cpp
|
e60aaaea89e4164a5899960892b1e0749b776b32
|
[] |
no_license
|
denzveloper/CPPSMK
|
d0392ca87e2b278f5ec4be8eef70e2e7a2009ff6
|
2d25a7b9ab9636ec4c2698ea7e2d976bde823880
|
refs/heads/master
| 2020-09-09T18:23:59.207950
| 2019-11-13T18:40:33
| 2019-11-13T18:40:33
| 221,525,285
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,100
|
cpp
|
anakAyams.cpp
|
#include<iostream>
using namespace std;
int main()
{
int i;
cout<< "====================================================================="<<endl;
cout<< "Program Anak Ayam..."<<endl;
cout<< "====================================================================="<<endl;
cout<< "Masukkan Jumlah Anak Ayam: "; cin>>i;
cout<<endl;
cout<< "#####################################################################"<<endl;
if (i>=1)
{
cout<< "Tek-kotek-kotek-kotek..."<<endl<<endl;
for (i; i > 0 ;)
{
cout<< "Anak ayam turun lah.. "<<i<<endl;
i--;
cout<< "Mati satu tinggal lah.. "<<i<<endl<<endl<<endl<<endl;
}
if (i==0)
{
cout<< "Ternyata..."<<endl;
cout<<"Anak Ayam Mati semua Karena Flu Burung..."<<endl <<"\a \a"<<endl;
return main();
}
}
else
{
cout<<"Anda Bangkrut Donk???!"<<endl <<"\a \a \a"<<endl<<endl;
return main();
}
}
|
fbe3317f06c59f46260faa6db78f1c60fdb63285
|
ab8316dada0f12a81fd9bb469f44b287240c490d
|
/deeplearning/ml4pl/graphs/llvm2graph/build_graph.h
|
f0853001b7252c61bd3d5faa3f2824f7ca5948ce
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
island255/ProGraML
|
7680b09526af6e9884770a1667afcfd424e1848a
|
6c4ea50639773009e7c287feb62c6994fa4f3445
|
refs/heads/master
| 2022-10-02T18:03:55.735979
| 2020-06-10T09:26:31
| 2020-06-10T09:26:31
| 271,277,075
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 553
|
h
|
build_graph.h
|
#include "deeplearning/ml4pl/graphs/programl.pb.h"
#include "labm8/cpp/statusor.h"
#include "labm8/cpp/string.h"
#include "llvm/IR/Module.h"
namespace ml4pl {
// Construct a program graph from the given module.
labm8::StatusOr<ProgramGraph> BuildGraph(llvm::Module& module);
// Construct a program graph from a buffer for a module.
labm8::StatusOr<ProgramGraph> BuildGraph(const llvm::MemoryBuffer& irBuffer);
// Construct a program graph from a string of IR.
labm8::StatusOr<ProgramGraph> BuildGraph(const string& irString);
} // namespace ml4pl
|
a643340111811c18773b01fc87bb2a4f3babb948
|
f1d0f8140af5ccf5408513719345775e5e5d1a75
|
/src/OpenGL/Camera/Camera.cpp
|
6cc005f29ced3a9d4f54be7e7cbc75d89219c593
|
[] |
no_license
|
annulment/w_vr3
|
f08c41f2405c970ca2aa0c826ec1f3f11a3d35f1
|
2d1a265faf8ba38710f7528973cafc5d2541bc5c
|
refs/heads/master
| 2023-03-22T13:20:06.032628
| 2021-03-13T17:56:49
| 2021-03-13T17:56:49
| 345,869,170
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,508
|
cpp
|
Camera.cpp
|
#include "Camera.h"
#include <glm/gtc/matrix_transform.hpp>
#include "..//..//Window/Window.h"
#include "..//..//Events/Events.h"
w_vr3::gl::Camera::Camera(w_vr3::Window* window, glm::vec3 position
, glm::vec3 up, float yaw, float pitch) : speed(2.5f), zoom(45.0f), front(glm::vec3(0.0f, 0.0f, -1.0f)),
window(window){
this->position = position;
this->world_up = up;
this->yaw = yaw;
this->pitch = pitch;
this->update_vectors();
}
glm::mat4 w_vr3::gl::Camera::getViewMatrix(){
return glm::lookAt(position, position + front, up);
}
glm::mat4 w_vr3::gl::Camera::getProjection(){
return glm::perspective(glm::radians(zoom), (float)window->get_window_width() / (float)window->get_window_height(), 0.1f, 100.0f);
}
void w_vr3::gl::Camera::update_vectors(){
glm::vec3 front;
front.x = cos(glm::radians(yaw)) * cos(glm::radians(pitch));
front.y = sin(glm::radians(pitch));
front.z = sin(glm::radians(yaw)) * cos(glm::radians(pitch));
this->front = glm::normalize(front);
right = glm::normalize(glm::cross(front, world_up));
up = glm::normalize(glm::cross(right, front));
}
w_vr3::gl::w_vr3_camera_transform::w_vr3_camera_transform(Camera* camera, float mouse_sensitivity)
: camera(camera), mouse_sensitivity(mouse_sensitivity){
}
void w_vr3::gl::w_vr3_camera_transform::mouse_transform(bool constrainPitch){
float x_offset = w_vr3::Events::deltaX;
float y_offset = -w_vr3::Events::deltaY;
x_offset *= this->mouse_sensitivity;
y_offset *= this->mouse_sensitivity;
camera->yaw += x_offset;
camera->pitch += y_offset;
if (constrainPitch) {
if (camera->pitch > 89.0f)
camera->pitch = 89.0f;
if (camera->pitch < -89.0f)
camera->pitch = -89.0f;
}
this->camera->update_vectors();
}
void w_vr3::gl::w_vr3_camera_transform::position_transform(camera_direction direction){
float velocity = camera->speed * w_vr3::Events::delta_time;
switch (direction){
case w_vr3::gl::w_vr3_camera_transform::cd_FORWARD:
camera->position += camera->front * velocity;
break;
case w_vr3::gl::w_vr3_camera_transform::cd_BACKWARD:
camera->position -= camera->front * velocity;
break;
case w_vr3::gl::w_vr3_camera_transform::cd_LEFT:
camera->position -= camera->right * velocity;
break;
case w_vr3::gl::w_vr3_camera_transform::cd_RIGHT:
camera->position += camera->right * velocity;
break;
}
}
|
61a0b093c3b0943563afae0d49dc9a38b6fc654c
|
2741058082c3e88afff85e9604f3d46b7b90123d
|
/montecarlo.h
|
a3cb67fc47dfbd118701b6f94ec534f6efc22b23
|
[] |
no_license
|
KineOdegardHanssen/Master
|
02acc17b2742bb603933bbfb8675b4fee5fb5b8b
|
a04a5c76e619e4ecfa63b2e2f8d77ae5b0e863b2
|
refs/heads/master
| 2021-08-20T05:45:27.480681
| 2017-11-28T09:33:21
| 2017-11-28T09:33:21
| 112,304,995
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,945
|
h
|
montecarlo.h
|
#ifndef MONTECARLO_H
#define MONTECARLO_H
#include <fstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <random>
#include <cmath>
#include <complex>
#include "lattice.h"
#include "site.h"
#include "bond.h"
#include "gaussiandeviate.h"
extern "C"
{
#include "fftw3.h"
}
using namespace std;
using std::ofstream; using std::string;
class MonteCarlo
{
public:
// Printing part
ofstream allFile;
ofstream bigFile;
ofstream compareFile;
ofstream spcorFilex;
ofstream spcorFiley;
ofstream spcorFilez;
ofstream spcorFiletot;
ofstream ftspcorFile;
ofstream mxyz_qycenter_File;
ofstream bootstrapFile;
ofstream randomtestFile;
ofstream qxFile;
ofstream qFile;
string filenamePrefix;
int N, eqsteps, mcsteps_inbin, no_of_bins, no_of_neighbours;
long int seed1, seed2, testseed;
double energy_old, acceptancerate;
bool isotropic, sianisotropy, magfield, dm;
bool nextnearest;
bool notperiodic;
bool dmdiffdirs;
bool printeveryMCstep, calculatespincorrelationfunction, randomtest;
bool center_m_calc;
bool dobootstrap;
bool DEBUG, MAJORDEBUG;
char type_lattice;
fftw_plan px, py, pz;
fftw_plan pinv;
// Random generators
std::default_random_engine generator_u;
std::uniform_real_distribution<double> distribution_u; //(-1,1)
std::default_random_engine generator_v;
std::uniform_real_distribution<double> distribution_v; //(-1,1)
std::default_random_engine generator_prob;
std::uniform_real_distribution<double> distribution_prob; // (0,1)
// For index.
std::default_random_engine generator_n;
std::uniform_int_distribution<int> distribution_n; // (0, N-1)
Lattice mylattice;
MonteCarlo();
MonteCarlo(int L1, int eqsteps, int mcsteps_inbin, int no_of_bins, long int latticeseed, long int seed1, bool isotropic, bool sianisotropy, bool magfield, bool dm, bool nextnearest, bool periodic, bool printeveryMCstep, bool calculatespincorrelationfunction, bool dobootstrap, char type_lattice, string filenamePrefix, vector<double> sitestrengthsin, vector<double> heisenbergin, vector<double> dm_in);
MonteCarlo(int L1, int L2, int L3, int eqsteps, int mcsteps_inbin, int no_of_bins, long int latticeseed, long int seed1, bool isotropic, bool sianisotropy, bool magfield, bool dm, bool nextnearest, bool periodic, bool printeveryMCstep, bool calculatespincorrelationfunction, bool dobootstrap, char type_lattice, string filenamePrefix, vector<double> sitestrengthsin, vector<double> heisenbergin, vector<double> dm_in);
// Debugging/testing functions
void debugmode(bool on);
void majordebugtrue();
void debug1d2p();
void testyopenfcc();
void testFFTW();
void compareFFTW_withmanual(double beta);
void compareFFTW_withmanual_av(double beta);
double check_the_energy(); // Function that finds the energy by going through every spin
void test_couplings_strengths();
void shortsim(double beta);
double dotproducts(int i, int j);
// Other initialization procedures
void initialize_energy();
void reset_energy();
// Function making a plan for the FFT
void givexplanforFFT(vector<double> &r, vector<complex<double> > &q);
void giveyplanforFFT(vector<double> &r, vector<complex<double> > &q);
void givezplanforFFT(vector<double> &r, vector<complex<double> > &q);
void giveplanforFFT_inverse(vector<double>& rout, vector<complex<double> >& q);
// Standard Metropolis functions
void runmetropolis(double beta);
void mcstepf_metropolis(double beta);
// Finding m(q=2pi[0,1,0])
vector<double> m_orderparameter_center(double beta); // Should be called by some bool in runmetropolis
// Printing functions
void writeallqstofile();
// Closing the output files
void endsims();
};
#endif // MONTECARLO_H
|
c27e9da696edd02f424d38e2149f830b25f54ca6
|
206bc173b663425bea338b7eb7bc8efc094167b5
|
/atcoder/abc/82/c_sub.cpp
|
ce4dd7283db37e588692723c503c892895446632
|
[] |
no_license
|
rika77/competitive_programming
|
ac6e7664fe95249a3623c814e6a0c363c5af5f33
|
a0f860c801e9197bcdd6b029ca3e46e73dfc4253
|
refs/heads/master
| 2022-03-01T09:03:01.056933
| 2019-11-07T01:45:28
| 2019-11-07T01:45:28
| 122,687,377
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 406
|
cpp
|
c_sub.cpp
|
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main(){
int n;
int a;
cin>>n;
int flag[1000000001] = {};
for (int i=0;i<n;i++) {
cin >> a;
flag[a] += 1;
}
int cnt = 0;
for (int i=1;i<=1000000000;i++) {
if (flag[i]) {
if (flag[i]>i) {
cnt += flag[i] - i;
}
else if (flag[i]<i) {
cnt += flag[i];
}
}
}
cout << cnt << endl;
return 0;
}
|
eb10a279614bd4e3a2bcf3c5769983e50d457d1f
|
9e838485df519302135da697fc7ba816761e8811
|
/projects/assigment2/code/triangulation2dapp.cc
|
8deb0994914ad83781902d0c1cb88ed30161920b
|
[
"MIT"
] |
permissive
|
Blinningjr/opengl-lab-env
|
80d7e775133ee87ad9c4a1db76ea0d734c44ab7b
|
dc041a6d502bf543f25271cd47dd7c5698eb33a1
|
refs/heads/master
| 2020-09-06T16:04:23.711882
| 2020-01-28T21:30:24
| 2020-01-28T21:30:24
| 220,473,458
| 1
| 0
|
MIT
| 2019-11-20T22:55:37
| 2019-11-08T13:34:19
|
C
|
UTF-8
|
C++
| false
| false
| 16,707
|
cc
|
triangulation2dapp.cc
|
#include "config.h"
#include "triangulation2dapp.h"
#include <cstring>
#include <glm/glm.hpp>
#include <glm/vec3.hpp> // glm::vec3
#include <glm/vec4.hpp> // glm::vec4
#include <glm/mat4x4.hpp> // glm::mat4
#include <glm/gtc/matrix_transform.hpp> // glm::translate, glm::rotate, glm::scale, glm::perspective
#include <math.h>
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include "imgui.h"
const GLchar* vs =
"#version 310 es\n"
"precision mediump float;\n"
"layout(location=0) in vec3 pos;\n"
"layout(location=1) in vec4 color;\n"
"layout(location=0) out vec4 Color;\n"
"#define M_PI 3.1415926535897932384626433832795\n"
"uniform float dist;\n"
"uniform float angle;\n"
"void main()\n"
"{\n"
" float newAngle = angle + M_PI * ((1.0/2.0) * (pos.x + 1.0 + pos.y + 1.0) * (pos.x + 1.0 + pos.y + 1.0 + 1.0) + (pos.y + 1.0)); \n" // Cantor pairing function https://en.wikipedia.org/wiki/Pairing_function
" vec4 vDist = vec4((cos(newAngle) -sin(newAngle)) * dist, (sin(newAngle) + cos(newAngle)) * dist, 0, 0);\n"
" gl_Position = vec4(pos, 1) + vDist;\n"
" Color = color;\n"
"}\n";
const GLchar* ps =
"#version 310 es\n"
"precision mediump float;\n"
"layout(location=0) in vec4 color;\n"
"out vec4 Color;\n"
"void main()\n"
"{\n"
" Color = color;\n"
"}\n";
namespace Triangulation2d {
Triangulation2dApp::Triangulation2dApp() {
this->bufLength = 0;
this->bufVBO = std::unique_ptr<GLfloat[]>(new GLfloat[this->bufLength]);
this->showPoints = true;
this->showConvexHull = false;
this->showTriangulation = true;
this->showTriangulationOutline = true;
this->showC = false;
this->angle = 0;
this->dist = 0.0f;
}
Triangulation2dApp::~Triangulation2dApp() {
if (this->vsBuffer) {
delete[] this->vsBuffer;
}
if (this->fsBuffer) {
delete[] this->fsBuffer;
}
}
/**
* Initaial setup of the app.
*/
bool Triangulation2dApp::Open() {
App::Open();
this->window = new Display::Window;
srand (static_cast <unsigned> (time(0)));
if (this->window->Open()) {
// set clear color to gray
glClearColor(0, 0, 0, 1.0f);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable( GL_BLEND );
// setup vertex shader
this->vertexShader = glCreateShader(GL_VERTEX_SHADER);
this->vsBufferLength = (GLint)std::strlen(vs);
this->vsBuffer = new GLchar[this->vsBufferLength];
for (int i = 0; i < this->vsBufferLength; i++) {
this->vsBuffer[i] = vs[i];
}
glShaderSource(this->vertexShader, 1, &this->vsBuffer, &this->vsBufferLength);
glCompileShader(this->vertexShader);
// get error log
GLint shaderLogSize;
glGetShaderiv(this->vertexShader, GL_INFO_LOG_LENGTH, &shaderLogSize);
if (shaderLogSize > 0)
{
GLchar* buf = new GLchar[shaderLogSize];
glGetShaderInfoLog(this->vertexShader, shaderLogSize, NULL, buf);
printf("[SHADER COMPILE ERROR]: %s", buf);
delete[] buf;
}
// setup pixel shader
this->pixelShader = glCreateShader(GL_FRAGMENT_SHADER);
this->fsBufferLength = (GLint)std::strlen(ps);
this->fsBuffer = new GLchar[this->fsBufferLength];
for (int i = 0; i < this->fsBufferLength; i++) {
this->fsBuffer[i] = ps[i];
}
glShaderSource(this->pixelShader, 1, &this->fsBuffer, &this->fsBufferLength);
glCompileShader(this->pixelShader);
// get error log
shaderLogSize;
glGetShaderiv(this->pixelShader, GL_INFO_LOG_LENGTH, &shaderLogSize);
if (shaderLogSize > 0)
{
GLchar* buf = new GLchar[shaderLogSize];
glGetShaderInfoLog(this->pixelShader, shaderLogSize, NULL, buf);
printf("[SHADER COMPILE ERROR]: %s", buf);
delete[] buf;
}
// create a program object
this->program = glCreateProgram();
glAttachShader(this->program, this->vertexShader);
glAttachShader(this->program, this->pixelShader);
glLinkProgram(this->program);
glGetProgramiv(this->program, GL_INFO_LOG_LENGTH, &shaderLogSize);
if (shaderLogSize > 0)
{
GLchar* buf = new GLchar[shaderLogSize];
glGetProgramInfoLog(this->program, shaderLogSize, NULL, buf);
printf("[PROGRAM LINK ERROR]: %s", buf);
delete[] buf;
}
// set ui rendering function
this->window->SetUiRender([this]()
{
this->RenderUI();
});
this->UpdateVBO();
return true;
}
return false;
}
/**
* Main app loop.
*/
void Triangulation2dApp::Run() {
while (this->window->IsOpen()) {
glClear(GL_COLOR_BUFFER_BIT);
this->window->Update();
this->angle += 0.05f;
// do stuff
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glBindBuffer(GL_ARRAY_BUFFER, this->triangle);
glUseProgram(this->program);
glLineWidth(3);
glPointSize(10);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(float32) * 7, NULL);
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(float32) * 7, (GLvoid*)(sizeof(float32) * 3));
GLuint angleID = glGetUniformLocation(this->program, "angle");
GLuint distID = glGetUniformLocation(this->program, "dist");
glUniform1f(angleID, this->angle);
glUniform1f(distID, this->dist);
int start = 0;
if (this->showTriangulation) {
glDrawArrays(GL_TRIANGLES, start, this->vertexcalc.getTriangulationLength() * 3);
}
start += this->vertexcalc.getTriangulationLength() * 3;
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
if (this->showTriangulationOutline) {
glDrawArrays(GL_TRIANGLES, start, this->vertexcalc.getTriangulationLength() * 3);
}
start += this->vertexcalc.getTriangulationLength() * 3;
if (this->showConvexHull) {
glDrawArrays(GL_POLYGON, start, this->vertexcalc.getConvexHullLength());
}
start += this->vertexcalc.getConvexHullLength();
if (this->showPoints) {
glDrawArrays(GL_POINTS, start, this->vertexcalc.getPointsLength());
}
start += this->vertexcalc.getPointsLength();
if (this->showC) {
glDrawArrays(GL_POINTS, start, 1);
}
start += 1;
glBindBuffer(GL_ARRAY_BUFFER, 0);
this->window->SwapBuffers();
}
}
/**
* Updates the VBO with this->buf.
*/
void Triangulation2dApp::UpdateVBO() {
int lengthTriangulation = this->vertexcalc.getTriangulationLength() * 3;
int lengthConvexHull = this->vertexcalc.getConvexHullLength();
int lengthPoints = this->vertexcalc.getPointsLength();
int lengthC = 1;
int prev = 0;
this->bufLength = (lengthTriangulation * 2 + lengthConvexHull + lengthPoints + lengthC) * 7;
this->bufVBO = std::unique_ptr<GLfloat[]>(new GLfloat[this->bufLength]);
// Adds triangulation.
std::shared_ptr<VertexCalc::Triangle[]> triangulation = this->vertexcalc.getTriangulation();
for (int i = 0; i < this->vertexcalc.getTriangulationLength(); i++) {
VertexCalc::Point p1 = triangulation[i].p1;
VertexCalc::Point p2 = triangulation[i].p2;
VertexCalc::Point p3 = triangulation[i].p3;
this->bufVBO[0 + i * 7 * 3 + prev] = p1.x;
this->bufVBO[1 + i * 7 * 3 + prev] = p1.y;
this->bufVBO[2 + i * 7 * 3 + prev] = p1.z;
this->bufVBO[3 + i * 7 * 3 + prev] = p1.r;
this->bufVBO[4 + i * 7 * 3 + prev] = p1.g;
this->bufVBO[5 + i * 7 * 3 + prev] = p1.b;
this->bufVBO[6 + i * 7 * 3 + prev] = 1;
this->bufVBO[7 + i * 7 * 3 + prev] = p2.x;
this->bufVBO[8 + i * 7 * 3 + prev] = p2.y;
this->bufVBO[9 + i * 7 * 3 + prev] = p2.z;
this->bufVBO[10 + i * 7 * 3 + prev] = p2.r;
this->bufVBO[11 + i * 7 * 3 + prev] = p2.g;
this->bufVBO[12 + i * 7 * 3 + prev] = p2.b;
this->bufVBO[13 + i * 7 * 3 + prev] = 1;
this->bufVBO[14 + i * 7 * 3 + prev] = p3.x;
this->bufVBO[15 + i * 7 * 3 + prev] = p3.y;
this->bufVBO[16 + i * 7 * 3 + prev] = p3.z;
this->bufVBO[17 + i * 7 * 3 + prev] = p3.r;
this->bufVBO[18 + i * 7 * 3 + prev] = p3.g;
this->bufVBO[19 + i * 7 * 3 + prev] = p3.b;
this->bufVBO[20 + i * 7 * 3 + prev] = 1;
}
prev += lengthTriangulation * 7;
// Adds triangulation outline.
for (int i = 0; i < this->vertexcalc.getTriangulationLength(); i++) {
VertexCalc::Point p1 = triangulation[i].p1;
VertexCalc::Point p2 = triangulation[i].p2;
VertexCalc::Point p3 = triangulation[i].p3;
this->bufVBO[0 + i * 7 * 3 + prev] = p1.x;
this->bufVBO[1 + i * 7 * 3 + prev] = p1.y;
this->bufVBO[2 + i * 7 * 3 + prev] = p1.z;
this->bufVBO[3 + i * 7 * 3 + prev] = 1;
this->bufVBO[4 + i * 7 * 3 + prev] = 1;
this->bufVBO[5 + i * 7 * 3 + prev] = 1;
this->bufVBO[6 + i * 7 * 3 + prev] = 1;
this->bufVBO[7 + i * 7 * 3 + prev] = p2.x;
this->bufVBO[8 + i * 7 * 3 + prev] = p2.y;
this->bufVBO[9 + i * 7 * 3 + prev] = p2.z;
this->bufVBO[10 + i * 7 * 3 + prev] = 1;
this->bufVBO[11 + i * 7 * 3 + prev] = 1;
this->bufVBO[12 + i * 7 * 3 + prev] = 1;
this->bufVBO[13 + i * 7 * 3 + prev] = 1;
this->bufVBO[14 + i * 7 * 3 + prev] = p3.x;
this->bufVBO[15 + i * 7 * 3 + prev] = p3.y;
this->bufVBO[16 + i * 7 * 3 + prev] = p3.z;
this->bufVBO[17 + i * 7 * 3 + prev] = 1;
this->bufVBO[18 + i * 7 * 3 + prev] = 1;
this->bufVBO[19 + i * 7 * 3 + prev] = 1;
this->bufVBO[20 + i * 7 * 3 + prev] = 1;
}
prev += lengthTriangulation * 7;
// Adds convexHull.
std::shared_ptr<VertexCalc::Point[]> convexHull = this->vertexcalc.getConvexHull();
for (int i = 0; i < lengthConvexHull; i++) {
this->bufVBO[0 + i * 7 + prev] = convexHull[i].x;
this->bufVBO[1 + i * 7 + prev] = convexHull[i].y;
this->bufVBO[2 + i * 7 + prev] = convexHull[i].z;
this->bufVBO[3 + i * 7 + prev] = 1;
this->bufVBO[4 + i * 7 + prev] = 0;
this->bufVBO[5 + i * 7 + prev] = 0;
this->bufVBO[6 + i * 7 + prev] = convexHull[i].a;
}
prev += lengthConvexHull * 7;
// Adds all points
std::shared_ptr<VertexCalc::Point[]> points = this->vertexcalc.getPoints();
for (int i = 0; i < lengthPoints; i++) {
this->bufVBO[0 + i * 7 + prev] = points[i].x;
this->bufVBO[1 + i * 7 + prev] = points[i].y;
this->bufVBO[2 + i * 7 + prev] = points[i].z;
this->bufVBO[3 + i * 7 + prev] = points[i].r;
this->bufVBO[4 + i * 7 + prev] = points[i].g;
this->bufVBO[5 + i * 7 + prev] = points[i].b;
this->bufVBO[6 + i * 7 + prev] = points[i].a;
}
prev += lengthPoints * 7;
// Adds point pickedC
VertexCalc::Point c = this->vertexcalc.getPickedC();
this->bufVBO[0 + prev] = c.x;
this->bufVBO[1 + prev] = c.y;
this->bufVBO[2 + prev] = c.z;
this->bufVBO[3 + prev] = c.r;
this->bufVBO[4 + prev] = c.g;
this->bufVBO[5 + prev] = c.b;
this->bufVBO[6 + prev] = c.a;
prev += lengthC * 7;
// setup vbo
glGenBuffers(1, &this->triangle);
glBindBuffer(GL_ARRAY_BUFFER, this->triangle);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * this->bufLength * 7, static_cast<void *> (this->bufVBO.get()), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
/**
* Handels the GUI.
*/
void Triangulation2dApp::RenderUI() {
static bool showRead = false;
static bool genPoints = false;
static bool exit = false;
static bool sameColor = false;
static bool interpolationColor = false;
static bool fourColor = false;
static int pickCOption = 0;
if (this->window->IsOpen()) {
if (ImGui::BeginMainMenuBar()) {
if (ImGui::BeginMenu("File")) {
ImGui::MenuItem("read file", NULL, &showRead);
ImGui::MenuItem("Exit", NULL, &exit);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Gen Points")) {
ImGui::MenuItem("read file", NULL, &showRead);
ImGui::MenuItem("Random Points", NULL, &genPoints);
ImGui::RadioButton("Random", &pickCOption, 0);
ImGui::RadioButton("Square Middle", &pickCOption, 1);
ImGui::RadioButton("Rotating Calipers", &pickCOption, 2);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Show")) {
ImGui::MenuItem("Points", NULL, &this->showPoints);
ImGui::MenuItem("Convex Hull", NULL, &this->showConvexHull);
ImGui::MenuItem("C", NULL, &this->showC);
ImGui::MenuItem("Triangulation", NULL, &this->showTriangulation);
ImGui::MenuItem("Triangulation Outline", NULL, &this->showTriangulationOutline);
ImGui::SliderFloat("Distans", &this->dist, 0.0f, 0.5f);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Color")) {
ImGui::MenuItem("Same Color", NULL, &sameColor);
ImGui::MenuItem("Interpolation Color", NULL, &interpolationColor);
ImGui::MenuItem("Four Color", NULL, &fourColor);
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}
}
if (showRead) this->ReaderUI(&showRead);
if (genPoints) this->GenRandPointsUI(&genPoints);
if (exit) this->window->Close();
if (sameColor) {
this->vertexcalc.colorSameColor(0, 0.5f, 1, 1);
sameColor = false;
this->UpdateVBO();
}
if (interpolationColor) {
this->vertexcalc.colorInterpolationColor();
interpolationColor = false;
this->UpdateVBO();
}
if (fourColor) {
this->vertexcalc.fourColor();
fourColor = false;
this->UpdateVBO();
}
this->vertexcalc.setPickCOption(pickCOption);
}
/**
* GUI for reading file.
*/
void Triangulation2dApp::ReaderUI(bool* open) {
if (ImGui::Begin("File reader", open, ImGuiWindowFlags_AlwaysAutoResize)) {
static char buf[100] = "";
ImGui::InputText("string", buf, IM_ARRAYSIZE(buf));
if (ImGui::Button("Read file")) {
std::string filePath(buf);
this->vertexcalc.ReadPoints(filePath);
this->UpdateVBO();
*open = false;
}
ImGui::End();
}
}
/**
* GUI for generating points.
*/
void Triangulation2dApp::GenRandPointsUI(bool* open) {
if (ImGui::Begin("Rand point gen", open, ImGuiWindowFlags_AlwaysAutoResize)) {
static int i0=3;
ImGui::InputInt("input int", &i0, 1, 5);
if (ImGui::Button("Gen Points")) {
this->vertexcalc.GenRandomPoints(i0);
this->UpdateVBO();
*open = false;
}
ImGui::End();
}
}
}
|
77a01e809a0de85b5a150c90eb501746c13f5eb2
|
a09a2fb5ab1d038855ff84f38c4f15482d98e885
|
/Analysis/HiggsNuNu/LightTreeAna/src/HistPlotter.cc
|
06cee311766a56776e49f66469ad4a7ea556e508
|
[] |
no_license
|
pmeridian/ICHiggsTauTau
|
2a352ab7f67906be8e7b348da00f815160ad3cf3
|
88b15992ad0cb6c97cd06ea786c363612958a9dc
|
refs/heads/master
| 2020-02-26T16:58:47.578354
| 2014-12-16T16:16:38
| 2014-12-16T16:16:38
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 18,312
|
cc
|
HistPlotter.cc
|
#include "UserCode/ICHiggsTauTau/Analysis/HiggsNuNu/LightTreeAna/interface/HistPlotter.h"
#include <iostream>
#include "TH1F.h"
#include "TF1.h"
#include "THStack.h"
#include "TCanvas.h"
#include "TLegend.h"
#include "TStyle.h"
#include <map>
#include "TVectorD.h"
//#include "CommonTools/Utils/interface/TFileDirectory.h"
#include <boost/algorithm/string.hpp>
#include "TDirectory.h"
#include "TFile.h"
#include "TPad.h"
#include "TLatex.h"
#include "TLine.h"
#include "TBox.h"
#include "TASImage.h"
namespace ic{
LTPlotElement::LTPlotElement(){
unit_="GeV";
in_stack_=false;
is_inrationum_=false;
is_inratioden_=false;
has_dderrors_=0;
};
LTPlotElement::~LTPlotElement(){ ;};
LTShapeElement::LTShapeElement(){
dology_=false;
};
LTShapeElement::~LTShapeElement(){ ;};
void LTPlotElement::ApplyStyle(){
hist_ptr_->SetName(legname_.c_str());
hist_ptr_->Scale(scale_);
if(draw_marker_){
hist_ptr_->SetMarkerColor(marker_color_);
hist_ptr_->SetMarkerStyle(marker_style_);
hist_ptr_->SetMarkerSize(marker_size_);
drawopts_+="P";
legopts_+="p";
}
if(draw_fill_){
hist_ptr_->SetFillColor(fill_color_);
hist_ptr_->SetFillStyle(fill_style_);
hist_ptr_->SetLineColor(line_color_);
drawopts_+="hist";
legopts_+="f";
}
if(draw_line_){
hist_ptr_->SetLineColor(line_color_);
hist_ptr_->SetLineStyle(line_style_);
hist_ptr_->SetLineWidth(line_width_);
legopts_+="l";
}
if(draw_stat_error_y_==true){
drawopts_+="E1";
legopts_+="e";
}
};
void HistPlotter::SetMCStackStyle(ic::LTPlotElement* ele) {
ele->set_fill_color(ele->color());
ele->set_fill_style(1001);
ele->set_draw_fill(true);
ele->set_draw_marker(false);
ele->set_draw_line(false);
ele->set_line_width(2);
ele->set_draw_stat_error_y(false);
ele->set_line_color(1);
return;
}
void HistPlotter::SetSignalStyle(ic::LTPlotElement* ele) {
ele->set_fill_style(1001);
ele->set_draw_fill(true);
ele->set_draw_marker(false);
ele->set_draw_line(true);
ele->set_draw_stat_error_y(false);
ele->set_draw_fill_in_legend(false);
ele->set_line_style(11);
ele->set_fill_color(0);
ele->set_line_color(ele->color());
ele->set_line_width(2);
return;
}
void HistPlotter::SetDataStyle(ic::LTPlotElement* ele) {
ele->set_marker_color(1);
ele->set_line_color(1);
ele->set_fill_color(1);
ele->set_fill_style(0);
ele->set_draw_fill(false);
ele->set_line_width(2);
ele->set_draw_marker(true);
ele->set_draw_line(true);
ele->set_marker_style(20);
ele->set_draw_stat_error_y(true);
ele->set_marker_size(1.1);
return;
}
HistPlotter::HistPlotter(std::string name) : LTModule(name){
do_ratio_=false;
do_ratio_line_=false;
do_ratio_fitline_=false;
add_underflows_=false;
add_overflows_=false;
};
HistPlotter::~HistPlotter(){ ;};
int HistPlotter::Init(TFile* fs){
fs_=fs;
std::cout<<"Initialisation info for "<<module_name_<<":"<<std::endl;
return 0;
};
int HistPlotter::Run(LTFiles* ){
std::cout<<module_name_<<":"<<std::endl;
TFile* file=fs_;
//GET DIRECTORY TO WRITE TO
TDirectory* writedir;
if(dirname_==""){
writedir=file->mkdir("controlplots");
}
else if(!fs_->GetDirectory(dirname_.c_str())){
writedir=file->mkdir(dirname_.c_str());
}
else{
writedir=file->GetDirectory(dirname_.c_str());
}
writedir->cd();
//SETUP STYLE
for(unsigned iElement=0;iElement<elements_.size();iElement++){
}
// if(histTitles_.size()!=shapes_.size()){
// std::cout<<"histTitles must be of the same size as shapes. Exiting with status 1"<<std::endl;
// return 1;
// }
//LOOP OVER ALL THE VARIABLES TO PLOT
for(unsigned iShape=0;iShape<shapes_.size();iShape++){
std::cout<<" Drawing plot for "<<shapes_[iShape].name()<<std::endl;
THStack *stack=new THStack("stack","stacked plots");
bool stackempty=true;
// if(!do_ratio_) stack->SetTitle(histTitles_[iShape].name().c_str());
if(!do_ratio_) stack->SetTitle(shapes_[iShape].histtitle().c_str());
//stack->GetXaxis()->SetTitle(shapes_[iShape].c_str());
//EXTRACT ALL THE HISTOS AND PUT THEM IN STACKED OR UNSTACKED GROUPS
std::cout<<" Getting histograms.."<<std::endl;
for(unsigned iElement=0;iElement<elements_.size();iElement++){
if(elements_[iElement].sample()==""){
std::cout<<"ERROR: Element with empty name exiting with status 1"<<std::endl;
return 1;
}
//std::cout<<" "<<elements_[iElement].sample()<<std::endl;
if(!fs_->GetDirectory(elements_[iElement].sample().c_str())){
std::cout<<"ERROR: No directory with name: "<<elements_[iElement].sample()<<std::endl;
std::cout<<"Exiting with status 1"<<std::endl;
return 1;
}
writedir->cd();
TH1F* histo =dynamic_cast<TH1F*>(file->Get((elements_[iElement].sample()+"/"+shapes_[iShape].name()).c_str()));
writedir->cd();
for(unsigned iblindshape=0;iblindshape<elements_[iElement].blindvar().size();iblindshape++){
if(shapes_[iShape].name()==elements_[iElement].blindvar()[iblindshape]){
for (int j = 0; j < histo->GetNbinsX(); ++j) {
double low_edge = histo->GetBinLowEdge(j+1);
double high_edge = histo->GetBinWidth(j+1)+histo->GetBinLowEdge(j+1);
double x_blind_min_=elements_[iElement].blindrange()[iblindshape].first;
double x_blind_max_=elements_[iElement].blindrange()[iblindshape].second;
if ((low_edge > x_blind_min_ && low_edge < x_blind_max_) || (high_edge > x_blind_min_ && high_edge < x_blind_max_)) {
histo->SetBinContent(j+1,0);
histo->SetBinError(j+1,0);
}
}
}
}
if (add_underflows_ || add_overflows_){
int tmpbins = histo->GetNbinsX();
double tmpmin = histo->GetXaxis()->GetBinLowEdge(1);
double tmpmax = histo->GetXaxis()->GetBinLowEdge(tmpbins+1);
double tmpsize = (tmpmax-tmpmin)/tmpbins;
if (add_underflows_) {
tmpbins+=1;
tmpmin = tmpmin-tmpsize;
}
if (add_overflows_){
tmpbins+=1;
tmpmax = tmpmax+tmpsize;
}
std::ostringstream tmpname;
tmpname << histo->GetName() << "_mod";
TH1F *histTmp = new TH1F(tmpname.str().c_str(),histo->GetTitle(),tmpbins,tmpmin,tmpmax);
histTmp->Sumw2();
if (add_underflows_) {
histTmp->SetBinContent(1,histo->GetBinContent(0));
histTmp->SetBinError(1,histo->GetBinError(0));
for (int ibin(1); ibin<histo->GetNbinsX()+1;++ibin){
histTmp->SetBinContent(ibin+1,histo->GetBinContent(ibin));
histTmp->SetBinError(ibin+1,histo->GetBinError(ibin));
}
}
else {
for (int ibin(1); ibin<histo->GetNbinsX()+1;++ibin){
histTmp->SetBinContent(ibin,histo->GetBinContent(ibin));
histTmp->SetBinError(ibin,histo->GetBinError(ibin));
}
}
if (add_overflows_) {
histTmp->SetBinContent(tmpbins,histo->GetBinContent(histo->GetNbinsX()+1));
histTmp->SetBinError(tmpbins,histo->GetBinError(histo->GetNbinsX()+1));
}
elements_[iElement].set_hist_ptr(histTmp);
}
else
elements_[iElement].set_hist_ptr(histo);
//SETUP STYLE
if(elements_[iElement].is_data()){
SetDataStyle(&(elements_[iElement]));
}
else if(elements_[iElement].in_stack()){
SetMCStackStyle(&(elements_[iElement]));
stackempty=false;
}
else{
SetSignalStyle(&(elements_[iElement]));
}
elements_[iElement].ApplyStyle();
//ADD STACKED HISTOS TO STACK
if((!elements_[iElement].is_data())&&elements_[iElement].in_stack()){
stack->Add(elements_[iElement].hist_ptr());
}
}
//SETUP THE CANVAS
TCanvas *c1=new TCanvas(shapes_[iShape].name().c_str(),shapes_[iShape].name().c_str());
c1->cd();
TPad* upper = nullptr;
TPad* lower = nullptr;
if(do_ratio_){
upper = new TPad("upper","pad",0, 0.26 ,1 ,1);
lower = new TPad("lower","pad",0, 0 ,1 ,0.26);
upper->SetBottomMargin(0.02);
upper->Draw();
upper->cd();
upper->SetLogy(shapes_[iShape].dology());
}
else c1->SetLogy(shapes_[iShape].dology());
bool first=true;
double ymax=0;
if(!stackempty) ymax=stack->GetMaximum();
for(unsigned iElement=0;iElement<elements_.size();iElement++){
if(elements_[iElement].hist_ptr()->GetMaximum()>ymax) ymax=elements_[iElement].hist_ptr()->GetMaximum();
}
//DRAW THE STACK AND ALL THE UNSTACKED HISTOS INCLUDING THE DATA
if(!stackempty){
std::cout<<" Drawing Stack.."<<std::endl;
if(first){
stack->SetMaximum(ymax);
//stack->GetXaxis()->SetTitle("");
stack->Draw("hist");
c1->Update();
first=false;
if(do_ratio_){
stack->GetXaxis()->SetLabelOffset(999);
stack->GetXaxis()->SetLabelSize(0);
std::string ytitle;
// ytitle=histTitles_[iShape].substr(histTitles_[iShape].find(";")+1);
ytitle=shapes_[iShape].histtitle().substr(shapes_[iShape].histtitle().find(";")+1);
ytitle=ytitle.substr(ytitle.find(";")+1);
ytitle=ytitle.substr(0,ytitle.find(";"));
stack->SetTitle((";;"+ytitle).c_str());
}
}
else stack->Draw("histsame");
}
std::cout<<" Drawing Unstacked.."<<std::endl;
for(unsigned iElement=0;iElement<elements_.size();iElement++){
if(!(elements_[iElement].in_stack())){
if(first){
elements_[iElement].hist_ptr()->Draw(elements_[iElement].drawopts().c_str());
elements_[iElement].hist_ptr()->GetYaxis()->SetRangeUser(0.,ymax+10);
elements_[iElement].hist_ptr()->Draw(elements_[iElement].drawopts().c_str());
c1->Update();
first=false;
if(do_ratio_){
elements_[iElement].hist_ptr()->GetXaxis()->SetLabelOffset(999);
elements_[iElement].hist_ptr()->GetXaxis()->SetLabelSize(0);
std::string ytitle;
ytitle=shapes_[iShape].histtitle().substr(shapes_[iShape].histtitle().find(";")+1);
ytitle=ytitle.substr(ytitle.find(";")+1);
ytitle=ytitle.substr(0,ytitle.find(";"));
elements_[iElement].hist_ptr()->GetYaxis()->SetTitle(ytitle.c_str());
}
}
else elements_[iElement].hist_ptr()->Draw(("same"+elements_[iElement].drawopts()).c_str());
}
}
//SETUP AND DRAW THE LEGEND
TLegend* leg =new TLegend(0.75,0.3,0.89,0.89);
leg->SetFillStyle(0);
leg->SetLineColor(10);
for(unsigned iElement=0;iElement<elements_.size();iElement++){
leg->AddEntry(elements_[iElement].hist_ptr(),elements_[iElement].hist_ptr()->GetName(),elements_[iElement].legopts().c_str());
}
leg->Draw("same");
c1->Update();
TLatex* lat=new TLatex();
lat->SetNDC();
//lat->SetTextSize(0.06);
lat->SetTextFont(42);
TLatex* lat2 = new TLatex();
lat2->SetNDC();
lat2->SetTextSize(0.04);
lat2->SetTextFont(42);
lat->DrawLatex(0.14,0.85,"CMS Preliminary");
lat->DrawLatex(0.14,0.78,"VBF H #rightarrow invisible");
lat2->DrawLatex(0.14,0.665,"#sqrt{s} = 8 TeV, L = 19.2 fb^{-1}");
c1->Update();
//DRAW RATIO PLOT
if(do_ratio_){
c1->cd();
lower->SetTopMargin(0.03);
lower->SetBottomMargin(0.2);
lower->Draw();
lower->cd();
lower->SetGridy();
bool firstnum=true;
bool firstden=true;
TH1F* num = 0;
TH1F* den = 0;
double dentoterr=0;
for(unsigned iElement=0;iElement<elements_.size();iElement++){
if(elements_[iElement].is_inrationum()){
//ADD TO num HIST
if(firstnum){
num=(TH1F*)(elements_[iElement].hist_ptr()->Clone("num"));
firstnum=false;
}
else num->Add(elements_[iElement].hist_ptr());
}
if(elements_[iElement].is_inratioden()){
//ADD TO den HIST
if(firstden){
den=(TH1F*)(elements_[iElement].hist_ptr()->Clone("den"));
firstden=false;
}
else den->Add(elements_[iElement].hist_ptr());
//get error on this contribution
double thiselementfracerr;
double thiselementintegral=Integral(elements_[iElement].hist_ptr());
if(elements_[iElement].has_dderrors()==1){
TVectorD* dennormerr =(TVectorD*)file->Get((elements_[iElement].sample()+"/normerrs").c_str());//!!
thiselementfracerr=sqrt(pow((*dennormerr)[0],2)+pow((*dennormerr)[1],2));
}
else{
thiselementfracerr=Error(elements_[iElement].hist_ptr())/thiselementintegral;
}
if(thiselementintegral!=0){
dentoterr=sqrt(pow(dentoterr,2)+pow(thiselementfracerr*thiselementintegral,2));
}
std::cout<<dentoterr<<std::endl;
}
}
if(firstnum||firstden)std::cout<<"To draw ratio plot you must specify elements to be numerator and denominator! Ratio plot will be missing."<<std::endl;
else{
//Set den error to zero will take den error into account in error band!!
double denfracerr=dentoterr/Integral(den);
double numfracerr=1/sqrt(Integral(num));
std::cout<<Integral(den);
std::cout<<denfracerr<<std::endl;
TH1F* errorband=(TH1F*)(den->Clone("errorband"));
for(int bin=0;bin<=den->GetNbinsX()+1;bin++){
den->SetBinError(bin,0);
errorband->SetBinContent(bin,Integral(num)/Integral(den));
errorband->SetBinError(bin,sqrt(pow(denfracerr,2)+pow(numfracerr,2)));
}
//DIVIDE NUM BY DEN and put in ratio
TH1F* ratio;
ratio=(TH1F*)(num->Clone("ratio"));
ratio->GetXaxis()->SetLabelSize(0.1);
ratio->GetYaxis()->SetLabelSize(0.1);
std::string xtitle;
xtitle=shapes_[iShape].histtitle().substr(shapes_[iShape].histtitle().find(";")+1);
xtitle=xtitle.substr(0,xtitle.find(";"));
ratio->GetXaxis()->SetTitle(xtitle.c_str());//!!GET TITLE FOR X AXIS
ratio->GetXaxis()->SetTitleSize(0.1);
ratio->GetXaxis()->SetTitleOffset(0.8);
ratio->GetYaxis()->SetRangeUser(0,2.0);
ratio->SetTitle("");
ratio->GetYaxis()->SetTitle("data/MC");
ratio->GetYaxis()->SetTitleSize(0.1);
ratio->GetYaxis()->SetTitleOffset(0.3);
ratio->Divide(den);
gStyle->SetOptStat(0);
ratio->SetStats(0);
errorband->SetMarkerSize(0);
errorband->SetFillColor(16);
errorband->SetFillStyle(1000);//3013);
errorband->SetLineWidth(1);
errorband->GetXaxis()->SetTitle(xtitle.c_str());//!!GET TITLE FOR X AXIS
errorband->GetXaxis()->SetTitleSize(0.1);
errorband->GetXaxis()->SetTitleOffset(0.8);
errorband->GetYaxis()->SetRangeUser(0,2.0);
errorband->SetTitle("");
errorband->GetYaxis()->SetTitle("data/MC");
errorband->GetYaxis()->SetTitleSize(0.1);
errorband->GetYaxis()->SetTitleOffset(0.3);
errorband->GetXaxis()->SetLabelSize(0.1);
errorband->GetYaxis()->SetLabelSize(0.1);
errorband->SetStats(0);
TF1* fiterrup;
TF1* fiterrdown;
TLine *averageLine;
TLine *averageupLine;
TLine *averagedownLine;
if(do_ratio_fitline_){
//ratio->Fit("pol0","E");
averageLine = new TLine(ratio->GetXaxis()->GetBinLowEdge(1),Integral(num)/Integral(den),ratio->GetXaxis()->GetBinLowEdge(ratio->GetNbinsX()+1),Integral(num)/Integral(den));
averageupLine = new TLine(ratio->GetXaxis()->GetBinLowEdge(1),(Integral(num)+sqrt(Integral(num)))/Integral(den),ratio->GetXaxis()->GetBinLowEdge(ratio->GetNbinsX()+1),(Integral(num)+sqrt(Integral(num)))/Integral(den));
averagedownLine = new TLine(ratio->GetXaxis()->GetBinLowEdge(1),(Integral(num)-sqrt(Integral(num)))/Integral(den),ratio->GetXaxis()->GetBinLowEdge(ratio->GetNbinsX()+1),(Integral(num)-sqrt(Integral(num)))/Integral(den));
averageLine->SetLineColor(2);
averageupLine->SetLineColor(3);
averagedownLine->SetLineColor(3);
averageupLine->SetLineStyle(3);
averagedownLine->SetLineStyle(3);
// fiterrup=new TF1("pol0up","pol0");
// TF1 *fitresult=ratio->GetFunction("pol0");
// //fiterrup->SetParameters(fitresult->GetParameter(0)+fitresult->GetParError(0),fitresult->GetParameter(1)+fitresult->GetParError(1));
// fiterrup->SetParameter(0,fitresult->GetParameter(0)+fitresult->GetParError(0));
// fiterrdown=new TF1("pol0up","pol0");
// //fiterrdown->SetParameters(fitresult->GetParameter(0)-fitresult->GetParError(0),fitresult->GetParameter(1)-fitresult->GetParError(1));
// fiterrdown->SetParameter(0,fitresult->GetParameter(0)-fitresult->GetParError(0));
// fiterrup->SetLineStyle(2);
// fiterrdown->SetLineStyle(2);
// fiterrup->SetLineColor(2);
// fiterrdown->SetLineColor(2);
}
if(do_ratio_fitline_){
//fiterrup->Draw("same");
//fiterrdown->Draw("same");
errorband->Draw("E2");
averageLine->Draw("same");
ratio->Draw("E1same");
//averageupLine->Draw("same");
//averagedownLine->Draw("same");
}
else ratio->Draw("E1");
TLine *centerLine = new TLine(ratio->GetXaxis()->GetBinLowEdge(1),1.0,ratio->GetXaxis()->GetBinLowEdge(ratio->GetNbinsX()+1),1.0);
centerLine->SetLineWidth(1);
if(!do_ratio_fitline_)centerLine->SetLineColor(2);
else centerLine->SetLineColor(1);
centerLine->Draw("same");
if(do_ratio_line_){
TLine *lowerLine = new TLine(ratio->GetXaxis()->GetBinLowEdge(1),0.9,ratio->GetXaxis()->GetBinLowEdge(ratio->GetNbinsX()+1),0.9);
TLine *upperLine = new TLine(ratio->GetXaxis()->GetBinLowEdge(1),1.1,ratio->GetXaxis()->GetBinLowEdge(ratio->GetNbinsX()+1),1.1);
lowerLine->SetLineWidth(2);
upperLine->SetLineWidth(2);
lowerLine->SetLineColor(7);
upperLine->SetLineColor(7);
lowerLine->Draw();
upperLine->Draw();
}
}
}
//save as PDF
c1->Update();
std::ostringstream lsave;
std::string tmpstr = file->GetName();
tmpstr.erase(std::string(file->GetName()).find(".root"),5);
lsave << tmpstr ;
lsave << ".pdf" ;
if (iShape==0) {
lsave << "[";
c1->Print(lsave.str().c_str());//open the file
lsave.str("");//reset for adding the first plot
lsave << tmpstr ;
lsave << ".pdf" ;
}
c1->Print(lsave.str().c_str());
if (iShape==shapes_.size()-1) {
lsave << "]";
c1->Print(lsave.str().c_str());//close the file
}
lsave.str("");
lsave << tmpstr << "_" << c1->GetName() << ".pdf" ;
c1->Print((lsave.str()).c_str());
//WRITE TO FILE
writedir->cd();
c1->Write();
c1->Close();
}
writedir->Close();
return 0;
};
}
|
3028186042c0cb480edda3dd4fcbbcf8749ca6c4
|
ab3760a49c72d1b2b65ed732028bb37141ea8f64
|
/soul/src/runtime/runtime.h
|
09ed5ad39d4cc73ef4e260de2c7a5d3660b52d79
|
[] |
no_license
|
kevyuu/soul
|
acfb4e177fd2081ee8baa06f125dc09d31bcbf9f
|
b132c47cf788d37a51c702773bd7e2ee24175bfd
|
refs/heads/main
| 2023-07-21T19:15:07.138275
| 2023-07-17T09:51:24
| 2023-07-17T09:51:24
| 138,812,031
| 7
| 1
| null | 2022-10-04T06:21:32
| 2018-06-27T01:11:36
|
C++
|
UTF-8
|
C++
| false
| false
| 2,979
|
h
|
runtime.h
|
#pragma once
#include "core/type_traits.h"
#include "runtime/data.h"
#include "runtime/system.h"
namespace soul::runtime
{
inline auto init(const Config& config) -> void { System::get().init(config); }
inline auto shutdown() -> void { System::get().shutdown(); }
inline auto begin_frame() -> void { System::get().begin_frame(); }
inline auto create_task(const TaskID parent = TaskID::ROOT()) -> TaskID
{
return System::get().create_task(parent, [](TaskID) {});
}
template <execution Execute>
auto create_task(const TaskID parent, Execute&& lambda) -> TaskID
{
return System::get().create_task(parent, std::forward<Execute>(lambda));
}
inline auto wait_task(TaskID taskID) -> void { System::get().wait_task(taskID); }
inline auto run_task(TaskID taskID) -> void { System::get().task_run(taskID); }
inline auto run_and_wait_task(TaskID task_id) -> void
{
run_task(task_id);
wait_task(task_id);
}
template <execution Execute>
auto create_and_run_task(TaskID parent, Execute&& lambda) -> TaskID
{
const TaskID taskID = create_task(parent, std::forward<Execute>(lambda));
run_task(taskID);
return taskID;
}
template <ts_fn<void,int> Fn>
auto parallel_for_task_create(TaskID parent, u32 count, u32 blockSize, Fn&& func)
-> TaskID
{
return System::get().create_parallel_for_task_recursive(
parent, 0, count, blockSize, std::forward<Fn>(func));
}
inline auto get_thread_id() -> u16 { return System::get().get_thread_id(); }
inline auto get_thread_count() -> u16 { return System::get().get_thread_count(); }
inline auto push_allocator(memory::Allocator* allocator) -> void
{
System::get().push_allocator(allocator);
}
inline auto pop_allocator() -> void { System::get().pop_allocator(); }
inline auto get_context_allocator() -> memory::Allocator*
{
return System::get().get_context_allocator();
}
inline auto get_temp_allocator() -> TempAllocator* { return System::get().get_temp_allocator(); }
inline auto allocate(u32 size, u32 alignment) -> void*
{
return System::get().allocate(size, alignment);
}
inline auto deallocate(void* addr, u32 size) -> void
{
return System::get().deallocate(addr, size);
}
struct AllocatorInitializer {
AllocatorInitializer() = delete;
explicit AllocatorInitializer(memory::Allocator* allocator) { push_allocator(allocator); }
auto end() -> void { pop_allocator(); }
};
struct AllocatorZone {
AllocatorZone() = delete;
explicit AllocatorZone(memory::Allocator* allocator) { push_allocator(allocator); }
~AllocatorZone() { pop_allocator(); }
};
#define STRING_JOIN2(arg1, arg2) DO_STRING_JOIN2(arg1, arg2)
#define DO_STRING_JOIN2(arg1, arg2) arg1##arg2
#define SOUL_MEMORY_ALLOCATOR_ZONE(allocator) \
soul::runtime::AllocatorZone STRING_JOIN2(allocatorZone, __LINE__)(allocator)
} // namespace soul::runtime
|
2c0d86433bb5460af8d4ec7ccad80d646b95d1e5
|
0453ffb96e2c233fb04bb78e59ee70d1e66c22a3
|
/binary-search/valid-perfect-square.cpp
|
e360dbd1fcf3013cd9eb297b3dfc5db1c1f17d17
|
[] |
no_license
|
rakshith53/LeetCode-Solution
|
4f8f08283610c54bf61135d16befad1c264eb054
|
bba00e9314b4ad36f1831387a9f9fab802562b8b
|
refs/heads/main
| 2023-02-15T14:13:04.870369
| 2021-01-13T08:15:38
| 2021-01-13T08:15:38
| 325,224,507
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 332
|
cpp
|
valid-perfect-square.cpp
|
class Solution {
public:
bool isPerfectSquare(int num) {
int l=1,r=num;
int mid,res,rem;
while(l<=r){
mid = (r-l)/2 + l;
if(num/mid==mid && num%mid==0) return true;
else if(mid < num/mid) l = mid+1;
else r = mid-1;
}
return false;
}
};
|
eac9397ff76b7cf0622cf99f8ba945dd2ce601be
|
76b39f71af6fdddb027a4c8457f76956d5939c67
|
/subset_sum_equal_partition.cpp
|
04d293beb5fb6f4b311f8ed6ee0d82ef5a83a401
|
[] |
no_license
|
piash76/uva-codeforces-lightoj-atcoder-spoj--7
|
b2ddbd223663735b1cbb68c49b983b101246fbb4
|
b549e64309e14fff8acdf79a07d81e1d36247395
|
refs/heads/main
| 2023-06-25T12:14:48.618742
| 2021-07-16T07:59:01
| 2021-07-16T07:59:01
| 386,539,536
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 908
|
cpp
|
subset_sum_equal_partition.cpp
|
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define cy cout<<"YES"<<endl
#define cn cout<<"NO"<<endl
using namespace std;
const ll inf=1e18;
const int mod=1e9+7;
const int mod2=2147483647; ///2^31-1
const int M=500005;
ll a[105],dp[105][200005];
ll solve(ll idx,ll sum) ///subset sum
{
if(sum==0) return 1;
if(idx<0 or sum<0) return 0;
if(dp[idx][sum]!=-1) return dp[idx][sum];
ll ans=solve(idx-1,sum-a[idx]) || solve(idx-1,sum);
return dp[idx][sum]=ans;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll t,i,j;
memset(dp,-1,sizeof(dp));
ll n;cin>>n;
for(i=0;i<n;i++) { cin>>a[i]; }
return 0;
}
|
8fd15bd37dffbc13011a05acf7d0a305d625d9ae
|
a31349460eda9e0aba3846344048490c1a108c24
|
/Qt/Widgets/qSlicerEMSegmentAnatomicalTreeWidget_p.h
|
1bcc2bf6bbc0641cb9fc92a89ad3f1e250d68aaf
|
[] |
no_license
|
jcfr/EMSegment3
|
58ce9f01a3dd86aff67b02226ae8710c6a49d8b1
|
44d4f1d5a3e442d70adc98f0227ceff559c91038
|
refs/heads/master
| 2021-03-12T23:02:21.886633
| 2011-04-28T21:15:35
| 2011-04-28T21:15:35
| 1,667,722
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,517
|
h
|
qSlicerEMSegmentAnatomicalTreeWidget_p.h
|
/*==============================================================================
Program: 3D Slicer
Copyright (c) 2010 Kitware Inc.
See Doc/copyright/copyright.txt
or http://www.slicer.org/copyright/copyright.txt for details.
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.
This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
and was partially funded by NIH grant 3P41RR013218-12S1
==============================================================================*/
#ifndef __qSlicerEMSegmentAnatomicalTreeWidget_p_h
#define __qSlicerEMSegmentAnatomicalTreeWidget_p_h
// Qt includes
#include <QObject>
// CTK includes
#include <ctkPimpl.h>
// EMSegment includes
#include "qSlicerEMSegmentAnatomicalTreeWidget.h"
#include "ui_qSlicerEMSegmentAnatomicalTreeWidget.h"
// VTK includes
#include <vtkType.h> // For vtkIdType
#include "qSlicerEMSegmentModuleExport.h"
class qSlicerEMSegmentAnatomicalTreeWidgetPrivate;
class QStandardItem;
class QStandardItemModel;
class QToolButton;
class QCheckBox;
class QTreeView;
class vtkMRMLEMSNode;
class vtkMRMLEMSTreeNode;
class vtkMRMLNode;
class vtkMRMLColorTableNode;
//-----------------------------------------------------------------------------
/// \ingroup Slicer_QtModules_EMSegment
class qSlicerEMSegmentAnatomicalTreeWidgetPrivate :
public QObject,
public Ui_qSlicerEMSegmentAnatomicalTreeWidget
{
Q_OBJECT
Q_DECLARE_PUBLIC(qSlicerEMSegmentAnatomicalTreeWidget);
protected:
qSlicerEMSegmentAnatomicalTreeWidget* const q_ptr;
public:
qSlicerEMSegmentAnatomicalTreeWidgetPrivate(qSlicerEMSegmentAnatomicalTreeWidget& object);
typedef qSlicerEMSegmentAnatomicalTreeWidgetPrivate Self;
enum
{
TreeNodeIDRole = Qt::UserRole + 1,
TreeItemTypeRole
};
enum TreeItemType
{
StructureNameItemType = 0,
LabelItemType,
MRMLIDItemType,
ClassWeightItemType,
UpdateClassWeightItemType,
AtlasWeightItemType,
AlphaItemType,
ProbabilityMapItemType
};
enum ColumnIds
{
StructureColumn = 0,
IdColumn,
LabelColumn,
ClassWeightColumn,
UpdateClassWeightColumn,
AtlasWeightColumn,
AlphaColumn,
ProbabilityMapColumn
};
void setupUi(qSlicerEMSegmentWidget * widget);
void initializeHorizontalHeader();
void populateTreeModel(vtkIdType treeNodeId, QStandardItem *item);
QStandardItem* insertTreeRow(QStandardItem * parentItem, vtkIdType treeNodeId,
vtkMRMLEMSTreeNode * treeNode);
QColor colorFromLabelId(int labelId);
public slots:
void onTreeItemChanged(QStandardItem * treeItem);
void onTreeItemSelected(const QModelIndex & index);
void onProbabilityMapChanged(vtkMRMLNode * node);
public:
vtkMRMLEMSNode * EMSNode;
vtkMRMLColorTableNode * CurrentColorTableNode;
QStandardItemModel * TreeModel;
bool StructureNameEditable;
bool LabelColumnVisible;
bool ClassWeightColumnVisible;
bool UpdateClassWeightColumnVisible;
bool AtlasWeightColumnVisible;
bool AlphaColumnVisible;
bool ProbabilityMapColumnVisible;
};
#endif
|
2fdf64ea9118d1014a46e20d792f03ea768847c9
|
8bbd41d72899b193bb134138a6779e1f2b60291b
|
/system/linux/usb/hello/storage.h
|
e4e214d3741b234ed16313f86142225ee3502833
|
[] |
no_license
|
guofuhua/test
|
fd86351784cb3ed2ca4d120900fd57c6b8d251b1
|
b8632a177cadf9178a5f0cc1dcdbca4a15f57be5
|
refs/heads/master
| 2021-05-06T07:59:44.824358
| 2018-03-29T07:58:30
| 2018-03-29T07:58:30
| 113,967,910
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,226
|
h
|
storage.h
|
#ifndef STORAGE_H
#define STORAGE_H
#define MAX_CHANNEL (32)
#define MAX_STORAGE_DEVICE_NUM (3)
#define RTSP_PATH_LEN (128)
#define SAVE_PATH_LEN (256)
/* 6A board type */
typedef enum
{
BOARD_NONE = 0,
BOARD_AV1 = 1,
BOARD_AV2 = 2,
BOARD_AV3 = 3,
BOARD_AV4 = 4,
BOARD_EXP = 5,
BOARD_BUTT
}BOARD_TYPE_E;
typedef enum
{
CHANNEL_SAVE_NONE = 0,
CHANNEL_SAVE_MAIN = 1,
CHANNEL_SAVE_SUB = 2,
CHANNEL_SAVE_ALL = 3,
CHANNEL_SAVE_BUTT
}SAVE_MODE_E;
typedef enum
{
NONE = 0,
ACTION_ADD = 1,
ACTION_REMOVE = 2,
SUBSYSTEM_BLOCK = 3,
DEVTYPE_DISK,
DEVTYPE_PARTITION,
HOT_PLUG_TYPE_BUTT
}EHOT_PLUG_TYPE;
typedef enum
{
STORAGE_DEVICE_NONE = 0,
STORAGE_DEVICE_INSERT = 1,
STORAGE_DEVICE_MOUNTED = 2,
STORAGE_DEVICE_REMOVED = 3,
STORAGE_DEVICE_MOUNT_E = 4, /* mount faile */
STORAGE_DEVICE_BUTT
}STORAGE_DEVICE_STATE_E;
typedef enum
{
UNKNOW_DEVICE = 0,
USB_DEVICE = 1,
HDD_DEVICE = 2,
BUTT_DEVICE
}STORAGE_DEVICE_TYPE_E;
typedef struct {
int channel_id;
BOARD_TYPE_E board;
SAVE_MODE_E save_mode;
char mainstream[RTSP_PATH_LEN];
char substream[RTSP_PATH_LEN];
char save_main_path[SAVE_PATH_LEN];
char save_sub_path[SAVE_PATH_LEN];
}CHANNEL_INFO;
typedef struct {
STORAGE_DEVICE_STATE_E state;
STORAGE_DEVICE_TYPE_E type;
char name[12];
char partition_name[32];
int partition_count;
int totalspace;
int partition_size[12]; /*分区大小,单位KB*/
char path[SAVE_PATH_LEN];
int freesize;
int authorize;
}STORAGE_DEVICE_INFO;
typedef struct {
int count;
STORAGE_DEVICE_INFO device[MAX_STORAGE_DEVICE_NUM];
}STORAGE_DEVICE_MANAGE;
typedef struct {
int channel_count;
CHANNEL_INFO channel[MAX_CHANNEL];
STORAGE_DEVICE_MANAGE storage_manage;
}MONITOR_RECORD;
typedef struct {
EHOT_PLUG_TYPE action;
EHOT_PLUG_TYPE block;
EHOT_PLUG_TYPE disk;
STORAGE_DEVICE_TYPE_E type;
char name[12];
int npart;
int partn;
}THOT_PLUG_MSG;
class storage
{
public:
storage();
static void init();
static void destroy();
};
#endif // STORAGE_H
|
10bd1e52752db552dcab695391977c76c7b97ddb
|
0b9fc8d6fa090c9ff23215b4dab16aa28d2c85d0
|
/Graphs/IReader.h
|
9f485ff8a1cfedc6b6b859a4e0a1684bd67f1079
|
[] |
no_license
|
birneAgeev/ShortestPaths
|
ee9b2a278d82ad097768ab82ba1b6212074432b6
|
5d326db5e4d8ad24e13bd8449fe25c10161c52c5
|
refs/heads/master
| 2021-01-10T14:14:40.118314
| 2015-10-02T09:19:56
| 2015-10-02T09:21:19
| 43,388,713
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 285
|
h
|
IReader.h
|
#pragma once
#include <string>
// TODO : Abstract reader based on NextChar() and HasNext()
class IReader {
public:
virtual ~IReader() {}
virtual bool HasNext() = 0;
virtual char NextChar() = 0;
virtual unsigned int NextUnsignedInt() = 0;
virtual std::string ReadLine() = 0;
};
|
69d0e9302826f3b7fe96f4396060e0cad1e16512
|
793258e0e7827ea2237ff1e128fe8d3f836b900e
|
/day06/custom-customs.cpp
|
8c853633a85be38047328cf6f76d7c07a5d924cb
|
[] |
no_license
|
tomlankhorst/advent-of-code-2020-cpp
|
445f0a9baaff7864d8c7cbd859e064e9a6d7d3da
|
6b5304a8639ba7c8748788b6bffe6af7a81edf30
|
refs/heads/main
| 2023-02-05T02:01:25.173237
| 2020-12-25T07:32:50
| 2020-12-25T11:27:06
| 317,498,205
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,857
|
cpp
|
custom-customs.cpp
|
#include <algorithm>
#include <numeric>
#include <set>
#include "day05/arg_input.hpp"
#include "day05/tokenize.hpp"
namespace ranges = std::ranges;
auto main(int argc, char* argv[]) -> int {
auto file = get_input(argc, argv);
if (std::holds_alternative<int>(file))
return std::get<int>(file);
auto& input = std::get<std::ifstream>(file);
auto tokens = tokenize(input);
struct person_t {
using answers_t = std::set<char>;
answers_t answers;
};
struct group_t {
std::set<char> any_answered;
std::set<char> all_answered;
std::vector<person_t> persons;
};
auto groups = std::vector<group_t> {};
group_t group {};
for (const auto& l : tokens) {
if (l.empty()) {
groups.push_back(group);
group = {};
continue;
}
auto answers = person_t::answers_t {};
ranges::copy(l, std::inserter(answers, answers.end()));
// union
ranges::copy(l, std::inserter(group.any_answered, group.any_answered.end()));
// intersection
if (group.persons.empty()) {
group.all_answered = answers;
} else {
auto intersect = person_t::answers_t {};
std::set_intersection(group.all_answered.cbegin(), group.all_answered.cend(), answers.cbegin(), answers.cend(), std::inserter(intersect, intersect.end()));
group.all_answered = intersect;
}
group.persons.emplace_back(person_t{answers});
}
if (!group.persons.empty())
groups.push_back(group);
auto sum = std::accumulate(groups.cbegin(), groups.cend(), 0, [](auto sum, const auto& group){
return sum + group.any_answered.size();
});
std::cout << "Part 1: sum is " << sum << "\n";
auto sum_p2 = std::accumulate(groups.cbegin(), groups.cend(), 0, [](auto sum, const auto& group){
return sum + group.all_answered.size();
});
std::cout << "Part 2: sum is " << sum_p2 << "\n";
}
|
59279f50d968c793cfa62bf2be1dfb7738f22d84
|
db485ccdc0e6a24141622f91e2db8728522aac7c
|
/include/scanner/probe_set.h
|
756a738e880f8b8c2e1048cbac09c6ee23b6b77b
|
[
"MIT"
] |
permissive
|
ryru/nxscanner
|
d017bfdcb620e3a2a2c5e43fae90e42ffe3305d1
|
ae1d541777042e44fc7747c9f72e9a985e89fcbb
|
refs/heads/master
| 2020-06-03T21:06:09.149367
| 2019-07-03T19:04:31
| 2019-07-03T19:04:31
| 191,731,239
| 1
| 0
| null | 2019-06-13T09:28:06
| 2019-06-13T09:20:18
|
C++
|
UTF-8
|
C++
| false
| false
| 622
|
h
|
probe_set.h
|
#ifndef NXSCANNER_INCLUDE_SCANNER_PROBE_SET_H_
#define NXSCANNER_INCLUDE_SCANNER_PROBE_SET_H_
#include "probe.h"
#include <utility>
namespace nxscan::scanner {
class Probes {
public:
Probes(Probe domain, Probe host, Probe randomHost)
: domain(std::move(domain)), host(std::move(host)), randomHost(std::move(randomHost)) {}
Probe &getDomain();
Probe &getHost();
Probe &getRandomHost();
Probe const &getDomain() const;
Probe const &getHost() const;
Probe const &getRandomHost() const;
private:
Probe domain;
Probe host;
Probe randomHost;
};
}
#endif //NXSCANNER_INCLUDE_SCANNER_PROBE_SET_H_
|
0ae235453dc5da83b1661a9597885f99185ddaf2
|
123d8e9c7e7cf559cfcbc7e132ef7d01ffdfa81e
|
/src/GUI/Container.hpp
|
4c8ae0d8121f6a022a4fe7e307fb49ff62ddee5a
|
[] |
no_license
|
jrobchin/zel
|
a1e521cb94e13b87c2c7f7d7eef4d67440d91bba
|
c6c4cf78f62023e6de80cf9b14430c603abd8eb5
|
refs/heads/master
| 2020-04-16T21:14:20.919526
| 2019-02-25T19:28:47
| 2019-02-25T19:28:47
| 165,917,677
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 757
|
hpp
|
Container.hpp
|
#ifndef GUI_CONTAINER_HPP
#define GUI_CONTAINER_HPP
#include <vector>
#include <SDL2/SDL.h>
#include "Math.hpp"
#include "Component.hpp"
/*
* Container that holds other components.
*/
class Container: public Component {
public:
Container(Point<int> origin=Point<int>(0, 0), int width=0, int height=0, int margin=0);
Container(Rectangle<int> rect, int margin=0);
/// Used to add child components to the container
void addChild(Component* component);
/// Handle inputs for the container and children
void handleInputs();
/// Render container and children
void render();
private:
/// Margin between contained components
int _margin;
/// Container children
std::vector<Component*> _children;
};
#endif
|
4fbe7ceda9f2dc94bff8b44e37d4cb3d378511c8
|
d3d1d7d99054b8684ed5fc784421024050a95c79
|
/codeforces/contest/1256/c.cpp
|
2b20e27d7bb10da66811595ee598c2ce50152d3f
|
[] |
no_license
|
rishabhSharmaOfficial/CompetitiveProgramming
|
76e7ac3f8fe8c53599e600fc2df2520451b39710
|
85678a6dc1ee437d917adde8ec323a55a340375e
|
refs/heads/master
| 2023-04-28T05:51:18.606350
| 2021-05-15T07:04:33
| 2021-05-15T07:04:33
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 567
|
cpp
|
c.cpp
|
#include <bits/stdc++.h>
#define ll long long int
#define ii pair<int, int>
#define iii pair<int, ii>
#define vi vector<int>
#define vii vector<ii>
using namespace std;
int main()
{
int n, m, d;
cin >> n >> m >> d;
vi arr(m);
for (int i = 0; i < m; i++)
cin >> arr[i];
vi ans(n);
int pt = 0;
for (int i = 0; i < n; i++)
{
if (!ans[i + d])
{
for (int j = 0; j < arr[pt]; j++)
{
ans[i + j] = arr[pt];
}
pt++;
}
}
return 0;
}
|
a2db8d8f32d65a0f5369dbcab60594259141d6ca
|
450a2cfcc06589388cc2bd7ef127d421577e70f8
|
/CourseWork/Example4_PointLight/Example4_PointLight/TerrainShader.cpp
|
194605ebe4f11f2668da1e2528f9f79dee309da8
|
[] |
no_license
|
Gabe-L/Shaders
|
78fe3056c742d549baaa97518acb4776c331d8da
|
9abec16bc70c8294b260154d720ad1080d24e6cb
|
refs/heads/master
| 2020-04-01T05:10:10.989704
| 2018-12-11T17:46:47
| 2018-12-11T17:46:47
| 152,892,717
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,516
|
cpp
|
TerrainShader.cpp
|
// tessellation shader.cpp
#include "TerrainShader.h"
TerrainShader::TerrainShader(ID3D11Device* device, HWND hwnd) : BaseShader(device, hwnd)
{
initShader(L"terrain_vs.cso", L"terrain_hs.cso", L"terrain_ds.cso", L"terrain_gs.cso", L"terrain_ps.cso");
}
TerrainShader::~TerrainShader()
{
if (sampleState)
{
sampleState->Release();
sampleState = 0;
}
if (matrixBuffer)
{
matrixBuffer->Release();
matrixBuffer = 0;
}
if (tessellationBuffer)
{
tessellationBuffer->Release();
tessellationBuffer = 0;
}
if (layout)
{
layout->Release();
layout = 0;
}
if (tessellationBuffer)
{
tessellationBuffer->Release();
tessellationBuffer = 0;
}
// Release the light constant buffer.
if (lightBuffer)
{
lightBuffer->Release();
lightBuffer = 0;
}
//Release base shader components
BaseShader::~BaseShader();
}
void TerrainShader::initShader(WCHAR* vsFilename, WCHAR* psFilename)
{
D3D11_BUFFER_DESC matrixBufferDesc;
D3D11_BUFFER_DESC tessellationBufferDesc;
D3D11_BUFFER_DESC lightBufferDesc;
D3D11_SAMPLER_DESC samplerDesc;
D3D11_BUFFER_DESC camBufferDesc;
// Load (+ compile) shader files
loadVertexShader(vsFilename);
loadPixelShader(psFilename);
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
renderer->CreateBuffer(&matrixBufferDesc, NULL, &matrixBuffer);
// Setup description of the tesselation buffer
tessellationBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
tessellationBufferDesc.ByteWidth = sizeof(TessellationBufferType);
tessellationBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
tessellationBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
tessellationBufferDesc.MiscFlags = 0;
tessellationBufferDesc.StructureByteStride = 0;
// Create buffer pointer
renderer->CreateBuffer(&tessellationBufferDesc, NULL, &tessellationBuffer);
// Creating light buffer
lightBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
lightBufferDesc.ByteWidth = sizeof(LightBufferType);
lightBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
lightBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
lightBufferDesc.MiscFlags = 0;
lightBufferDesc.StructureByteStride = 0;
renderer->CreateBuffer(&lightBufferDesc, NULL, &lightBuffer);
// Creating cam buffer
camBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
camBufferDesc.ByteWidth = sizeof(camBufferType);
camBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
camBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
camBufferDesc.MiscFlags = 0;
camBufferDesc.StructureByteStride = 0;
renderer->CreateBuffer(&camBufferDesc, NULL, &camBuffer);
// Create a texture sampler state description.
samplerDesc.Filter = D3D11_FILTER_ANISOTROPIC;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.MipLODBias = 0.0f;
samplerDesc.MaxAnisotropy = 1;
samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
samplerDesc.BorderColor[0] = 0;
samplerDesc.BorderColor[1] = 0;
samplerDesc.BorderColor[2] = 0;
samplerDesc.BorderColor[3] = 0;
samplerDesc.MinLOD = 0;
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
renderer->CreateSamplerState(&samplerDesc, &sampleState);
// Sampler for shadow map sampling.
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_BORDER;
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_BORDER;
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_BORDER;
samplerDesc.BorderColor[0] = 1.0f;
samplerDesc.BorderColor[1] = 1.0f;
samplerDesc.BorderColor[2] = 1.0f;
samplerDesc.BorderColor[3] = 1.0f;
renderer->CreateSamplerState(&samplerDesc, &sampleStateShadow);
}
void TerrainShader::initShader(WCHAR* vsFilename, WCHAR* hsFilename, WCHAR* dsFilename, WCHAR* gsFilename, WCHAR* psFilename)
{
// InitShader must be overwritten and it will load both vertex and pixel shaders + setup buffers
initShader(vsFilename, psFilename);
// Load other required shaders.
loadHullShader(hsFilename);
loadDomainShader(dsFilename);
loadGeometryShader(gsFilename);
}
XMFLOAT4 float3_to_float4(XMFLOAT3 input, float w_val = 0.f) //converts a float3 to a float4 for padding
{
return XMFLOAT4(input.x, input.y, input.z, w_val);
}
void TerrainShader::setShaderParameters(ID3D11DeviceContext* deviceContext, const XMMATRIX &worldMatrix, const XMMATRIX &viewMatrix, const XMMATRIX &projectionMatrix, ID3D11ShaderResourceView* grassTexture, ID3D11ShaderResourceView* heightTexture, ID3D11ShaderResourceView* mudTexture, Explosion* explosion, float tesselationFactor, XMFLOAT3 cameraPosition, float _showGrass, float _bladeCount, float time, Light* spotLight, ID3D11ShaderResourceView* spotLightDepth)
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
// Transpose the matrices to prepare them for the shader.
XMMATRIX tworld = XMMatrixTranspose(worldMatrix);
XMMATRIX tview = XMMatrixTranspose(viewMatrix);
XMMATRIX tproj = XMMatrixTranspose(projectionMatrix);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
MatrixBufferType* dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr->world = tworld;// worldMatrix;
dataPtr->view = tview;
dataPtr->projection = tproj;
// Spot light view info
dataPtr->spotLightProjection = XMMatrixTranspose(spotLight->getProjectionMatrix());
dataPtr->spotLightView = XMMatrixTranspose(spotLight->getViewMatrix());
dataPtr->explosionLightProjections = XMMatrixTranspose(explosion->getLight()->getProjectionMatrix());
// Explosion light view info
for (int i = 0; i < 6; i++) {
dataPtr->explosionLightViews[i] = XMMatrixTranspose(explosion->GenerateView(i));
}
deviceContext->Unmap(matrixBuffer, 0);
deviceContext->GSSetConstantBuffers(0, 1, &matrixBuffer);
// Passing in light info
LightBufferType* lightPtr;
deviceContext->Map(lightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
lightPtr = (LightBufferType*)mappedResource.pData;
// Explosion (point) light
lightPtr->ambient[0] = explosion->getLight()->getAmbientColour();
lightPtr->diffuse[0] = explosion->getLight()->getDiffuseColour();
lightPtr->direction[0] = float3_to_float4(explosion->getLight()->getDirection());
lightPtr->position[0] = float3_to_float4(explosion->getLight()->getPosition());
// Spot light
lightPtr->ambient[1] = spotLight->getAmbientColour();
lightPtr->diffuse[1] = spotLight->getDiffuseColour();
lightPtr->direction[1] = float3_to_float4(spotLight->getDirection());
lightPtr->position[1] = float3_to_float4(spotLight->getPosition());
deviceContext->Unmap(lightBuffer, 0);
deviceContext->PSSetConstantBuffers(0, 1, &lightBuffer);
// Lock the constant buffer so it can be written to.
result = deviceContext->Map(tessellationBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
TessellationBufferType* tessPtr = (TessellationBufferType*)mappedResource.pData;
tessPtr->tessellationFactor = tesselationFactor;
tessPtr->cameraPosition = cameraPosition;
deviceContext->Unmap(tessellationBuffer, 0);
deviceContext->HSSetConstantBuffers(0, 1, &tessellationBuffer);
camBufferType* camPtr;
deviceContext->Map(camBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
camPtr = (camBufferType*)mappedResource.pData;
camPtr->camPos = float3_to_float4(cameraPosition);
camPtr->time = time;
camPtr->showGrass = _showGrass;
camPtr->baldeCount = _bladeCount;
camPtr->padding = float(0.0f);
deviceContext->Unmap(camBuffer, 0);
deviceContext->GSSetConstantBuffers(1, 1, &camBuffer);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetSamplers(0, 1, &sampleState);
deviceContext->PSSetSamplers(1, 1, &sampleStateShadow);
deviceContext->PSSetShaderResources(0, 1, &mudTexture);
deviceContext->PSSetShaderResources(1, 1, &grassTexture);
deviceContext->PSSetShaderResources(2, 1, &spotLightDepth);
deviceContext->PSSetShaderResources(3, 6, explosion->getDepthResources().data());
deviceContext->DSSetShaderResources(0, 1, &heightTexture);
deviceContext->DSSetSamplers(0, 1, &sampleState);
}
|
00e47f63cdd0344c9955cfd6f9204e4875ddab55
|
4a5ed032e2a1d5f0149c5901e3cb55906abb20c4
|
/core/toolbutton.h
|
d4d8e76370cc00d498eebec63993aa015ca570d5
|
[] |
no_license
|
guchengzhi/ShowBoard
|
7c20af09a4d063bac245aabef0cef47a94f6db33
|
4bc5c155f30ef8976058590658670d443a942100
|
refs/heads/master
| 2023-08-24T01:56:36.567162
| 2021-10-25T01:04:31
| 2021-10-31T07:48:01
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,843
|
h
|
toolbutton.h
|
#ifndef TOOLBUTTON_H
#define TOOLBUTTON_H
#include "ShowBoard_global.h"
#include <QAction>
#include <QVariant>
class SHOWBOARD_EXPORT ToolButton : public QAction
{
Q_OBJECT
Q_PROPERTY(QByteArray name READ name WRITE setName)
Q_PROPERTY(bool dynamic READ isDynamic WRITE setDynamic) // need delete
Q_PROPERTY(bool static READ isStatic WRITE setStatic)
Q_PROPERTY(bool optionsGroup READ isOptionsGroup WRITE setOptionsGroup) // group of options
Q_PROPERTY(bool customWidget READ isCustomWidget WRITE setCustomWidget)
Q_PROPERTY(bool popup READ isPopup WRITE setPopup)
Q_PROPERTY(bool hideSelector READ isHideSelector WRITE setHideSelector)
Q_PROPERTY(bool needUpdate READ needUpdate WRITE setNeedUpdate)
Q_PROPERTY(bool unionUpdate READ unionUpdate WRITE setUnionUpdate)
Q_PROPERTY(QRectF itemRect READ itemRect WRITE setItemRect)
Q_PROPERTY(QString iconSource READ iconSource NOTIFY changed)
public:
static ToolButton SPLITTER;
static ToolButton LINE_BREAK;
static ToolButton LINE_SPLITTER;
static ToolButton PLACE_HOOLDER;
static constexpr char const * ACTION_PROPERTY = "toolaction";
typedef std::function<void()> action_t;
public:
enum Flag
{
Dynamic = 1, // need delete
Static = 2,
OptionsGroup = 4, // group of options
CustomWidget = 8,
Popup = 16,
Checkable = 32,
NeedUpdate = 64,
UnionUpdate = NeedUpdate | 128,
HideSelector = 1 << 8,
};
Q_DECLARE_FLAGS(Flags, Flag)
public:
static QIcon makeIcon(QString const & iconString, QSize const & size);
static QIcon makeIcon(QVariant& icon, QSize const & size, bool replace);
static ToolButton * makeButton(QString const & desc);
static QList<ToolButton *> makeButtons(QString const & tools);
public:
ToolButton();
ToolButton(ToolButton const & o);
ToolButton(QByteArray const & name, QString const & title,
Flags flags, QVariant const & icon = QVariant());
ToolButton(QByteArray const & name, QString const & title,
QByteArray const & flags, QVariant const & icon = QVariant());
signals:
void delayActive(bool done);
public:
QByteArray name() { return name_; }
void setName(QByteArray const & name) { name_ = name; }
bool isDynamic() const { return flags_.testFlag(Dynamic); }
bool isStatic() const { return flags_.testFlag(Static); }
bool isOptionsGroup() { return flags_.testFlag(OptionsGroup); }
bool isCustomWidget() { return flags_.testFlag(CustomWidget); }
bool isPopup() { return flags_.testFlag(Popup); }
bool isHideSelector() { return flags_.testFlag(HideSelector); }
bool needUpdate() { return flags_.testFlag(NeedUpdate); }
bool unionUpdate() { return flags_.testFlag(UnionUpdate); }
void setDynamic(bool v) { flags_.setFlag(Dynamic, v); }
void setStatic(bool v) { flags_.setFlag(Static, v); }
void setOptionsGroup(bool v) { flags_.setFlag(OptionsGroup, v); }
void setCustomWidget(bool v) { flags_.setFlag(CustomWidget, v); }
void setPopup(bool v) { flags_.setFlag(Popup, v); }
void setHideSelector(bool v) { flags_.setFlag(HideSelector, v); }
void setNeedUpdate(bool v) { flags_.setFlag(NeedUpdate, v); }
void setUnionUpdate(bool v) { flags_.setFlag(UnionUpdate, v); }
QRectF itemRect() const;
void setItemRect(QRectF const & rect);
public:
ToolButton(QByteArray const & name, Flags flags);
void parseFlags(QByteArray const & flags);
QIcon getIcon(QSize const & size = QSize());
void setIcon(QVariant const & icon);
QString iconSource();
QWidget* getCustomWidget();
private:
QByteArray name_;
Flags flags_;
QVariant icon_;
};
Q_DECLARE_METATYPE(ToolButton::action_t)
#endif // TOOLBUTTON_H
|
34cc0667523b80a45c17b36d446419576ce82b46
|
62d9a7dc6117edbe626b2d566663fed630ff7975
|
/Labs/vectors.cpp
|
52a3300df1eb632df68f41aefcd9a7469435bd3f
|
[] |
no_license
|
neil-kuldip/CSCI-135-136
|
6a6cc87c724d2823bfe5e58007612881d07a9ec9
|
9b3b9ba7979923ad74c6f3f8df23192ace38907f
|
refs/heads/master
| 2022-12-30T10:46:27.850672
| 2020-10-12T23:38:52
| 2020-10-12T23:38:52
| 264,583,234
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 791
|
cpp
|
vectors.cpp
|
/*
Author: Neil Kuldip
Course: CSCI-136
Instructor: Melissa Lynch
Assignment: Lab 12 - Task A
This program contains the function: program a function called vector<int> makeVector(int n)
that returns a vector of n integers that range from 0 to n-1
*/
#include <iostream>
#include <vector>
using namespace std;
vector<int> makeVector(int n)
{
vector<int> result; //Contains list of sequential integers up to n-1
for (int i = 0; i < n; i++)
{
result.push_back(i);
}
return result;
}
int main()
{
int num = 0;
cout << "Please enter a number: ";
cin >> num;
vector<int> result = makeVector(num); //Calls function and contains the result
for (int i = 0; i < result.size(); i++)
{
cout << result[i] << " "; //Prints each element in vector
}
}
|
3a521f6501625a4a91466464ee66ad25376a401c
|
86eb6a23e99d9aa27710cde1882368bb878d2794
|
/lib/UserInterfaceClass/bitmaps.inl
|
b7448cfd2073cc007b17ec3099e52e9ce8f58b7a
|
[] |
no_license
|
davidfobar/BrewController
|
b19e4465dbbbbf75e61409ac95a004aaa8b3eed5
|
9108b88b891d1c2f81f43f621a17467b72656cfe
|
refs/heads/master
| 2022-10-28T14:37:18.128628
| 2019-01-06T09:17:18
| 2019-01-06T09:17:18
| 151,956,719
| 1
| 0
| null | 2018-10-07T16:08:46
| 2018-10-07T15:38:31
|
C++
|
UTF-8
|
C++
| false
| false
| 736
|
inl
|
bitmaps.inl
|
#ifndef BITMAPS_inl
#define BITMAPS_inl
#include "Arduino.h"
const uint8_t lock_bitmap[] U8G_PROGMEM = {
0b0011100,
0b0100010,
0b0100010,
0b1111111,
0b1110111,
0b1100011,
0b1110111,
0b1111111
};
const uint8_t arrow_bitmap[] U8G_PROGMEM = {
0b0000000,
0b0001000,
0b0001100,
0b0001110,
0b1111111,
0b0001110,
0b0001100,
0b0001000
};
const uint8_t select_bitmap[] U8G_PROGMEM = {
0b0000000,
0b0011100,
0b0111110,
0b1111111,
0b1111111,
0b1111111,
0b0111110,
0b0011100
};
const uint8_t upArrow_bitmap[] U8G_PROGMEM = {
0b00100,
0b01110,
0b11111,
0b00100,
0b00100
};
const uint8_t downArrow_bitmap[] U8G_PROGMEM = {
0b00100,
0b00100,
0b11111,
0b01110,
0b00100
};
#endif
|
77fa3cdfbab04b9bed3baafe2e91b98773c24ddd
|
8564892a4c6b10cc843f7ed38344e44b0d1589ca
|
/Object Oriented Programming/Hw5 Connect Four Part5/ConnectFourPlusUndo.cpp
|
a75020fd357f3b1cb1d9566c6abff44c1e2d320d
|
[] |
no_license
|
utksezgin/GTU-Homeworks
|
9909142ead0f264b057909bafb5ac976250a3a52
|
9d19f79b2d7b7bcf1055441e09ef40bcf4fecb50
|
refs/heads/master
| 2021-07-04T05:08:01.088021
| 2021-06-22T14:36:16
| 2021-06-22T14:36:16
| 160,941,545
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 694
|
cpp
|
ConnectFourPlusUndo.cpp
|
#include "ConnectFourAbstract.h"
#include "ConnectFourPlus.h"
#include "ConnectFourPlusUndo.h"
#include "Cell.h"
#include <iostream>
#include <string>
#include <stdlib.h> //Exit
#include <fstream> //Read/Write files
using namespace std;
int myNameSpace::ConnectFourPlusUndo::undoLastMove(){
int h = 0, w = 0;
if(playsVector.size() != 0){
h = playsVector[playsVector.size()-1].first; //Getting the Height of the last move
w = playsVector[playsVector.size()-1].second; //Getting the Width of the last move
gameBoard[h][w].setStatus("Empty");
playsVector.pop_back();
--livingCells;
if(whosTurn == 1)
whosTurn = 2;
else
whosTurn = 1;
return 1;
}
else
return 0;
}
|
dae679b58dbb0a0027134caffa882372fdc9a103
|
1eb7e9a8068ee2fa2650fc976aad243f8f6a5ee0
|
/Vowels and Consonant in string.cpp
|
214092976619dd0bdb7f6242b1bfaea4879fc567
|
[] |
no_license
|
Amankumar-code/Data-Structure
|
d997421b058c2193127c588ff73f0fb33ad4de31
|
42351a913f05cb7d59928c79a841130ba5909c68
|
refs/heads/main
| 2023-07-11T00:55:23.325308
| 2021-08-18T07:11:07
| 2021-08-18T07:11:07
| 393,600,485
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 593
|
cpp
|
Vowels and Consonant in string.cpp
|
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str;
getline(cin, str);
int vow=0,co=0;
for(int i=0;str[i]!='\0';i++)
{
if(str[i]=='a' || str[i]=='e' || str[i]=='i' || str[i]=='o' || str[i]=='u' || str[i]=='A' || str[i]=='E' || str[i]=='I' || str[i]=='O' || str[i]=='U')
{
vow++;
}else if(str[i]>=65 && str[i]<=90 || str[i]>=90 && str[i]<=122){
co++;
}else{
continue;
}
}
cout<<"Vowels : "<<vow<<endl;
cout<<"Consonants : "<<co<<endl;
return 0;
}
|
d02bfd904b376d436c5d1ab98eeec398a3c74b29
|
b95b40fa30fccdc66d3f4c1b4340d4d6f93c20d7
|
/3Dcoor/feature_abscoord.h
|
7c7878ad1e2dd97d278a2f5bb69cc321ffc67829
|
[] |
no_license
|
chenying6/6D-PoseEst
|
31deee31917ec4dde8e5ebf7ac0a047620249137
|
e4293a99e4d237d078783dedd41198107752c67b
|
refs/heads/master
| 2020-08-27T05:34:53.373900
| 2018-06-13T12:19:08
| 2018-06-13T12:19:08
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,654
|
h
|
feature_abscoord.h
|
#pragma once
namespace jp
{
class FeatureAbsCoord
{
public:
FeatureAbsCoord() : off_x(0), off_y(0), channel(0), dimension(0), direction(0)
{
}
FeatureAbsCoord(int off_x, int off_y, int channel, int dimension, int direction)
: off_x(off_x), off_y(off_y), channel(channel), dimension(dimension), direction(direction)
{
}
uchar getType() const { return 10; }
double computeResponse(int x, int y, float scale, const jp::img_data_t& data) const
{
// auto-context feature channels might be stored sub-sampled, in this case the offset vector has also be sub-sampled
int acSubSample = GlobalProperties::getInstance()->fP.acSubsample;
// scale and clamp the offset vector
FeaturePoints fP = getFeaturePoints(
x/acSubSample,
y/acSubSample,
off_x/acSubSample,
off_y/acSubSample,
scale/acSubSample,
data.labelData[channel].cols,
data.labelData[channel].rows);
// probe the auto-context object coordinate feature channel
return data.coordData[channel](fP.y1, fP.x1)[dimension];
}
bool operator()(int x, int y, float scale, const jp::img_data_t& data) const
{
if(direction)
return computeResponse(x, y, scale, data) <= thresh;
else
return computeResponse(x, y, scale, data) > thresh;
}
void setThreshold(double thresh) { this->thresh = thresh; }
void print() const
{
std::cout << "Absolute Coord Feature (x: " << off_x << ", y: " << off_y
<< ", t: " << thresh << ")" << std::endl;
}
void store(std::ofstream& file) const
{
write(file, off_x);
write(file, off_y);
write(file, thresh);
write(file, channel);
write(file, dimension);
write(file, direction);
}
void restore(std::ifstream& file)
{
read(file, off_x);
read(file, off_y);
read(file, thresh);
read(file, channel);
read(file, dimension);
read(file, direction);
}
private:
int off_x, off_y; // offset vector of the pixel probe
int channel; // which auto context feature channel to probe (channels correspond to different objects)
int dimension; //which object coordinate component (x, y, z) to probe
int direction; //should the feature response be smaller or greater than the threshold?
jp::coord1_t thresh; // feature threshold
};
template<>
void write(std::ofstream& file, const FeatureAbsCoord& feature);
template<>
void read(std::ifstream& file, FeatureAbsCoord& feature);
class FeatureSamplerAbsCoord
{
public:
typedef FeatureAbsCoord feature_t;
FeatureSamplerAbsCoord(int off_max, int maxChannel) : off_max(off_max), maxChannel(maxChannel)
{
}
feature_t sampleFeature() const
{
return feature_t(getOffset(), getOffset(), getChannel(), getDimension(), getDirection());
}
std::vector<feature_t> sampleFeatures(unsigned count) const
{
// create number of thresholds of identical features
int offset1 = getOffset();
int offset2 = getOffset();
int channel = getChannel();
int dimension = getDimension();
int direction = getDirection();
std::vector<feature_t> features;
for(unsigned i = 0; i < count; i++)
{
features.push_back(feature_t(offset1, offset2, channel, dimension, direction));
}
return features;
}
private:
int off_max; // maximally allowed offset vector
int maxChannel; // number of auto-context feature channels
int getOffset() const { return irand(-off_max, off_max + 1); }
int getChannel() const { return irand(0, maxChannel); }
int getDimension() const { return irand(0, 3); }
int getDirection() const { return irand(0, 2); }
};
}
|
1ddd45cf1b2e7439d79a563c2869a327857ed39a
|
449ae14862d9803277babe446f7f030fe9b0f15e
|
/p2/tags/RELEASE_0_6/python/p2/elements/unmarshalField.cpp
|
ed77ae4b0e9d5057aac5ecae6b4505169b421bac
|
[] |
no_license
|
declarativitydotnet/declarativity
|
863ea58bed1c0efc57573d75b73e0006eca3f280
|
75096fb78264c517cd00e8486467c010038434cb
|
refs/heads/master
| 2021-01-10T11:58:00.700630
| 2015-12-08T17:44:39
| 2015-12-08T17:44:39
| 47,607,520
| 9
| 3
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 441
|
cpp
|
unmarshalField.cpp
|
#include <unmarshalField.h>
#include <boost/python.hpp>
using namespace boost::python;
void export_unmarshalField()
{
class_<UnmarshalField, bases<Element>, boost::shared_ptr<UnmarshalField>, boost::noncopyable>
("UnmarshalField", init<std::string, unsigned int>())
.def("class_name", &UnmarshalField::class_name)
.def("processing", &UnmarshalField::processing)
.def("flow_code", &UnmarshalField::flow_code)
;
}
|
de30e807cae3bfc40dc1f68e098f081ddb59abb0
|
7b6c90f59e6596f64e96d8105c51662853fdca0d
|
/Longest Substring Without Repeating Characters.cpp
|
05d07d215a359cc7f53d622442cdc16542a32017
|
[] |
no_license
|
VladaChernoray/Extra3
|
a74d054851495db632284f031ca8ce62ea1b0550
|
e2dd4ff1d791fc0b19ccfe08ba929f1c1070dec5
|
refs/heads/master
| 2022-12-14T05:56:30.776245
| 2020-09-16T16:54:19
| 2020-09-16T16:54:19
| 296,092,398
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 478
|
cpp
|
Longest Substring Without Repeating Characters.cpp
|
class Solution {
public:
int lengthOfLongestSubstring(string s) {
int temp = 0;
int max_length = 0;
int curr = 0;
for (int i = 0; i < s.length(); i++) {
for (int j = i - 1; j >= temp; --j) {
temp = (s[i] == s[j]) ? temp = j + 1 : temp;
}
curr = i - temp + 1;
max_length = (curr > max_length) ? curr : max_length;
}
return max_length;
}
};
|
f2ce9bb04fd2630b607a2f56cd29a384eff189e9
|
6d088ec295b33db11e378212d42d40d5a190c54c
|
/contrib/mul/mbl/tests/test_dyn_prog.cxx
|
0a79094a076a36da9dc1d9b5fc045696843e5b29
|
[
"LicenseRef-scancode-warranty-disclaimer"
] |
no_license
|
vxl/vxl
|
29dffd5011f21a67e14c1bcbd5388fdbbc101b29
|
594ebed3d5fb6d0930d5758630113e044fee00bc
|
refs/heads/master
| 2023-08-31T03:56:24.286486
| 2023-08-29T17:53:12
| 2023-08-29T17:53:12
| 9,819,799
| 224
| 126
| null | 2023-09-14T15:52:32
| 2013-05-02T18:32:27
|
C++
|
UTF-8
|
C++
| false
| false
| 4,036
|
cxx
|
test_dyn_prog.cxx
|
// This is mul/mbl/tests/test_dyn_prog.cxx
#include <iostream>
#ifdef _MSC_VER
# include "vcl_msvc_warnings.h"
#endif
#include <mbl/mbl_dyn_prog.h>
#include "testlib/testlib_test.h"
#include <mbl/mbl_combination.h>
#include "vnl/vnl_random.h"
static inline int mbl_abs(int i) { return i>=0 ? i : -i; }
double dp_cost1(const vnl_matrix<double>& W,
const vnl_vector<double>& pair_cost,
const std::vector<unsigned>& x)
{
unsigned n=x.size();
double sum=0.0;
for (unsigned i=0;i<n;++i) sum+=W(i,x[i]);
for (unsigned i=1;i<n;++i)
sum+=pair_cost(mbl_abs(int(x[i])-int(x[i-1])));
return sum;
}
double dp_cost2(const vnl_matrix<double>& W,
const vnl_vector<double>& pair_cost,
const std::vector<unsigned>& x)
{
unsigned n=x.size();
double sum=0.0;
for (unsigned i=0;i<n;++i) sum+=W(i,x[i]);
for (unsigned i=1;i<n;++i)
sum+=pair_cost(mbl_abs(int(x[i])-int(x[i-1])));
sum+=pair_cost(mbl_abs(int(x[0])-int(x[n-1])));
return sum;
}
double global_optima1(const vnl_matrix<double>& W,
const vnl_vector<double>& pair_cost,
std::vector<int>& x)
{
unsigned n = W.rows();
unsigned n_states = W.columns();
std::vector<unsigned> nd(n,n_states);
std::vector<unsigned> ux = mbl_combination_begin(nd);
std::vector<unsigned> best_x=ux;
double best_cost = dp_cost1(W,pair_cost,ux);
do
{
double cost = dp_cost1(W,pair_cost,ux);
if (cost<best_cost) { best_cost=cost; best_x=ux; }
} while (mbl_combination_next(ux,nd));
x.resize(n);
for (unsigned i=0;i<n;++i) x[i]=best_x[i];
return best_cost;
}
double global_optima2(const vnl_matrix<double>& W,
const vnl_vector<double>& pair_cost,
std::vector<int>& x)
{
unsigned n = W.rows();
unsigned n_states = W.columns();
std::vector<unsigned> nd(n,n_states);
std::vector<unsigned> ux = mbl_combination_begin(nd);
std::vector<unsigned> best_x=ux;
double best_cost = dp_cost2(W,pair_cost,ux);
do
{
double cost = dp_cost2(W,pair_cost,ux);
if (cost<best_cost) { best_cost=cost; best_x=ux; }
} while (mbl_combination_next(ux,nd));
x.resize(n);
for (unsigned i=0;i<n;++i) x[i]=best_x[i];
return best_cost;
}
void test_dyn_prog1(unsigned n, unsigned n_states)
{
std::cout<<n_states<<" states, "<<n<<" variables."<<std::endl;
// Generate some random data
vnl_random rand1(473849);
vnl_matrix<double> W(n,n_states);
for (unsigned i=0;i<n;++i)
for (unsigned j=0;j<n_states;++j)
W(i,j)=rand1.drand64(0,1);
vnl_vector<double> pair_cost(n_states);
for (unsigned i=0;i<n_states;++i) pair_cost[i]=0.1*i;
std::vector<int> x,true_x;
mbl_dyn_prog dp;
double min_cost = dp.solve(x,W,pair_cost);
double true_min=global_optima1(W,pair_cost,true_x);
TEST_NEAR("Min correct",min_cost,true_min,1e-6);
for (unsigned i=0;i<n;++i)
{
std::cout<<i<<") x="<<x[i]<<std::endl;
TEST("State correct",x[i],true_x[i]);
}
}
void test_dyn_prog_loop(unsigned n, unsigned n_states)
{
std::cout<<n_states<<" states, "<<n<<" variables."<<std::endl;
// Generate some random data
vnl_random rand1(473349);
vnl_matrix<double> W(n,n_states);
for (unsigned i=0;i<n;++i)
for (unsigned j=0;j<n_states;++j)
W(i,j)=rand1.drand64(0,1);
vnl_vector<double> pair_cost(n_states);
for (unsigned i=0;i<n_states;++i) pair_cost[i]=0.1*i;
std::vector<int> x,true_x;
mbl_dyn_prog dp;
double min_cost = dp.solve_loop(x,W,pair_cost);
double true_min=global_optima2(W,pair_cost,true_x);
TEST_NEAR("Min correct",min_cost,true_min,1e-6);
for (unsigned i=0;i<n;++i)
{
std::cout<<i<<") x="<<x[i]<<std::endl;
TEST("State correct",x[i],true_x[i]);
}
}
void test_dyn_prog()
{
std::cout << "********************\n"
<< " Testing mbl_dyn_prog\n"
<< "********************\n";
test_dyn_prog1(4,4);
test_dyn_prog1(5,5);
test_dyn_prog_loop(4,4);
test_dyn_prog_loop(5,5);
}
TESTMAIN(test_dyn_prog);
|
920d5f824b8c65dadccdb487223c6b26f503b6fb
|
6ac555ae691a7ae57fb44bb1c2f02ecbff53842d
|
/Relay/CapacitiveSoil_library/CapacitiveSoilSensor.cpp
|
772d28771f1df297a3c4c6c3b2f12e2597052291
|
[] |
no_license
|
esalcido/EasyFan
|
6f243315bb9408542702a7e3f275ae2fda2c0bcd
|
4d6ba34d624025bed76c8611bf0c1b7ada260859
|
refs/heads/master
| 2022-07-20T02:25:00.497754
| 2020-11-15T23:31:45
| 2020-11-15T23:31:45
| 79,675,652
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 960
|
cpp
|
CapacitiveSoilSensor.cpp
|
#include "CapacitiveSoilSensor.h"
#include "Arduino.h"
CapacitiveSoilSensor::CapacitiveSoilSensor(int pin)
{
_pin = pin;
const int AirValue = 520;
const int WaterValue = 260;
int intervals = (AirValue - WaterValue)/3;
int soilMoisture = 0;
}
// void CapacitiveSoilSensor::setup(){
// Serial.begin(115200);
// }
int CapacitiveSoilSensor::getMoistureValue(){
soilMoistureValue = analogRead(_pin); //put Sensor insert into soil
// Serial.println("getting moisture value.\n");
// Serial.println(soilMoistureValue);
if(soilMoistureValue > WaterValue && soilMoistureValue < (WaterValue + intervals))
{
Serial.println("Very Wet");
}
else if(soilMoistureValue > (WaterValue + intervals) && soilMoistureValue < (AirValue - intervals))
{
Serial.println("Wet");
}
else if(soilMoistureValue < AirValue && soilMoistureValue > (AirValue - intervals))
{
Serial.println("Dry");
}
// delay(100);
return soilMoistureValue;
}
|
0fd66310402428bc3f751460c0cadd81288e2f13
|
bbe2c5d98fd9c0ffaa16e60ec1ecd04a6ece058b
|
/UIKit Ripoff/constants.cpp
|
620bc95005991259baace6357e7aeccb14442821
|
[] |
no_license
|
BeeFl/GraphingCalculator-SFML
|
896d9b5af7ace49db21aefd24d5b49e935063772
|
2100c023307a47837042525da2ea15852cfb7daf
|
refs/heads/master
| 2021-10-28T14:47:27.301489
| 2019-04-24T04:55:24
| 2019-04-24T04:55:24
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,954
|
cpp
|
constants.cpp
|
//
// constants.hpp
// Graphing Calculator CAS
//
// Created by Jack Zhao on 11/19/18.
// Copyright © 2018 Jack Zhao. All rights reserved.
//
#include <string>
#include "SFML/Graphics.hpp"
const int FrameRate = 60;
const double H_W_RATIO = 0.5625; // 16:9
const int DEFAULT_W = 2600;
const int DEFAULT_H = DEFAULT_W * H_W_RATIO;
const float ZoomingRatio = 0.89089;
const int maxXSteps = 10;
const int maxYSteps = 6;
const std::string TITLE = "Graphing Calculator 0.2";
const std::string lightFont = "/Users/jackzhao/Documents/PCC Archived/Computer Science/CS 3A/Huge Final Project/Graphing Calculator CAS/Resources/SF-Light.otf";
const std::string regularFont = "/Users/jackzhao/Documents/PCC Archived/Computer Science/CS 3A/Huge Final Project/Graphing Calculator CAS/Resources/SF-Regular.otf";
const sf::Color darkGreyDefault = sf::Color{51,51,51};
const sf::Color darkGreyHighlighted = sf::Color{115,115,115};
const sf::Color darkGreyPressed = sf::Color{80,80,80};
const sf::Color lightGreyDefault = sf::Color{165,165,165};
const sf::Color lightGreyHighlighted = sf::Color{217,217,217};
const sf::Color lightGreyPressed = sf::Color{190,190,190};
const sf::Color orangeDefault = sf::Color{240,154,55};
const sf::Color orangeHighlighted = sf::Color{243,201,149};
const sf::Color orangePressed = sf::Color{240,180,120};
const sf::Color charcoalDefault = sf::Color{33,33,33};
const sf::Color charcoalHighlighted = sf::Color{77,77,77};
const sf::Color charcoalPressed = sf::Color{55,55,55};
const sf::Color TabDefault{50,50,50};
const sf::Color TabHover{70,70,70};
const sf::Color TabPressed{55,55,55};
const sf::Color TabSelected{110,110,110};
const sf::Color lineRed = sf::Color {185,77,70};
const sf::Color lineOrange = sf::Color {235,132,57};
const sf::Color lineBlue = sf::Color {62,112,174};
const sf::Color lineGreen = sf::Color {79,137,78};
const sf::Color linePurple = sf::Color {91,70,160};
const sf::Color lineWhite = sf::Color::White;
|
2d318ad36382fe75d5255743c825f47360ab87bc
|
37a70083bc016c1de5620b41229af42f989f9dae
|
/src/marker/marker.h
|
8477fb7343382057a90d0d56ed67ebbe17817fff
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
jiangtaojiang/FastMarkerLocalizer
|
ecc8de70aeaac44e2cc517d3f0d6554ac6e6ffb9
|
065f56602a59eceea8fd4c6a4e9e9e45ede6ba34
|
refs/heads/master
| 2022-01-16T06:57:20.187438
| 2018-07-30T22:17:50
| 2018-07-30T22:17:50
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 14,613
|
h
|
marker.h
|
/**
* definitions.h
*
* Created on: 13.02.2012
* Author: jung
*/
#ifndef MARKER_H_
#define MARKER_H_
#include <array>
#include <list>
#include <opencv2/opencv.hpp>
#include "location/pose2d.h"
using namespace std;
namespace fml {
struct MarkerRelation2D {
clock_t timestamp;
int src_id;
int dst_id;
int corners_in_image;
float x, y, angle;
float error;
MarkerRelation2D(const clock_t timestamp, const int src, const int dst, const float x, const float y, const float angle, const float error, const int corners_in_image=0) {
this->timestamp = timestamp;
this->src_id = src;
this->dst_id = dst;
this->x = x;
this->y = y;
this->angle = angle;
this->error = error;
this->corners_in_image = corners_in_image;
}
};
struct MarkerInfo {
int id;
int detection_error;
float length_mm;
Pose2d w_T_m;
cv::Point2f vertices[4];
float line_accuracy[4] = { -1, -1, -1, -1 };
MarkerInfo() {
id = -1;
detection_error = 0;
length_mm = 0;
w_T_m = Pose2d();
}
MarkerInfo(const float length_mm, const Pose2d &w_T_m) {
this->id = w_T_m.id;
this->detection_error = 0;
this->length_mm = length_mm;
this->w_T_m = w_T_m;
}
void addOffset(const cv::Point roi_base) {
for(size_t i = 0; i < 4; ++i) {
vertices[i].x += roi_base.x;
vertices[i].y += roi_base.y;
}
}
friend bool operator<(const MarkerInfo &mi1, const MarkerInfo &mi2) {
return(mi1.id < mi2.id);
}
};
struct MarkerROI {
int id;
int distance;
cv::Rect roi;
float projected_line_length[3] = { 0, 0, 0 }; // target length, min threshold, max threshold
bool corner_inside_image[4] = { true, true, true, true };
vector<cv::Point2f> corners;
MarkerROI(const int id) {
this->id = id;
this->distance = 0;
corners.reserve(4);
}
};
struct MarkerProjectedCorners {
Pose2d points[8];
MarkerProjectedCorners(const float marker_check_length, const float half_inner_marker) {
points[0] = Pose2d(1, 0, 0, 0, -marker_check_length, -marker_check_length, 0, 0);
points[1] = Pose2d(1, 0, 0, 0, +marker_check_length, -marker_check_length, 0, 0);
points[2] = Pose2d(1, 0, 0, 0, +marker_check_length, +marker_check_length, 0, 0);
points[3] = Pose2d(1, 0, 0, 0, -marker_check_length, +marker_check_length, 0, 0);
points[4] = Pose2d(1, 0, 0, 0, -half_inner_marker, -half_inner_marker, 0, 0);
points[5] = Pose2d(1, 0, 0, 0, +half_inner_marker, -half_inner_marker, 0, 0);
points[6] = Pose2d(1, 0, 0, 0, +half_inner_marker, +half_inner_marker, 0, 0);
points[7] = Pose2d(1, 0, 0, 0, -half_inner_marker, +half_inner_marker, 0, 0);
}
};
inline bool getMarkerROI(const vector<cv::Point2f> &corners, MarkerROI &marker_roi, const cv::Size &image_size) {
float min_x = corners[0].x, min_y = corners[0].y;
float max_x = min_x, max_y = min_y;
for(size_t i = 1; i < 4; ++i) {
if(corners[i].x < min_x)
min_x = corners[i].x;
else if(corners[i].x > max_x)
max_x = corners[i].x;
if(corners[i].y < min_y)
min_y = corners[i].y;
else if(corners[i].y > max_y)
max_y = corners[i].y;
}
min_x = FLOOR(max(min_x, 0.f));
min_y = FLOOR(max(min_y, 0.f));
max_x = CEIL(min(max_x, (float)image_size.width));
max_y = CEIL(min(max_y, (float)image_size.height));
// not in image (now x,y matters, before it was just a cutoff radius)
if(min_x >= max_x || min_y >= max_y) {
return(false);
}
marker_roi.roi.x = min_x;
marker_roi.roi.y = min_y;
marker_roi.roi.width = max_x - min_x;
marker_roi.roi.height = max_y - min_y;
return(true);
}
inline cv::Rect getBoundingBox(const cv::Point2f (&corners)[4], const cv::Size image_size, const int border) {
float min_x = corners[0].x, min_y = corners[0].y;
float max_x = min_x, max_y = min_y;
for(size_t i = 1; i < 4; ++i) {
if(corners[i].x < min_x)
min_x = corners[i].x;
else if(corners[i].x > max_x)
max_x = corners[i].x;
if(corners[i].y < min_y)
min_y = corners[i].y;
else if(corners[i].y > max_y)
max_y = corners[i].y;
}
min_x = FLOOR(max(min_x-border, 0.f));
min_y = FLOOR(max(min_y-border, 0.f));
max_x = CEIL(min(max_x+border, (float)(image_size.width-1)));
max_y = CEIL(min(max_y+border, (float)(image_size.height-1)));
return(cv::Rect(min_x, min_y, max_x-min_x+1, max_y-min_y+1));
}
/**
* Find the crossing of the two lines described by X = b + k * f. Use analytical formula instead of solving the equations all the time.
*
* @param b1
* @param f1
* @param b2
* @param f2
* @return
*/
inline cv::Point2f getCrossing(const cv::Vec4f &line1, const cv::Vec4f &line2) {
// extract the points from the line
cv::Point2f f1(line1.val[0], line1.val[1]);
cv::Point2f f2(line2.val[0], line2.val[1]);
cv::Point2f b1(line1.val[2], line1.val[3]);
cv::Point2f b2(line2.val[2], line2.val[3]);
// compute parameter k:
// insert into first equation: crossing is then b1 + k * f1*/
float k = (f2.x * (b1.y-b2.y) - f2.y * (b1.x-b2.x)) / (f1.x*f2.y - f1.y*f2.x);
return(b1 + k * f1);
// compute parameter l:
// insert into second equation: crossing is then b2 + l * f2
/*float l = (f1.x * (b1.y-b2.y) - f1.y * (b1.x-b2.x)) / (f1.x*f2.y - f1.y*f2.x);
return(b2 + l * f2);*/
}
// determine the minimal squared distance from a point to a line
inline float signedDistToLine(const int x, const int y, const cv::Vec4f &line) {
const float factor[2] { -1, 1 };
float dx2 = x - line[2];
float dy2 = y - line[3];
float t = (line[0]*dx2 + line[1]*dy2)/(line[0]*line[0] + line[1]*line[1]);
float dx = line[0] * t - dx2;
float dy = line[1] * t - dy2;
float retval = SQRT(dx*dx + dy*dy);
//float sign = copysignf(1.0f, dx+dy);
int o = line[0]*dy2 - dx2*line[1];
float sign = factor[o < 0];
return(sign*retval);
}
inline float residual(vector<cv::Point2f> &points, cv::Vec4f &line, bool f_x) {
// mean by construction of the line
float mean_x = line[2];
float mean_y = line[3];
float rnum = 1.0f/points.size();
float var_unexplained = 0;
if(f_x) {
float vdiv = line[1]/line[0];
for(size_t i = 0; i < points.size(); ++i) {
float y_value = (points[i].x - mean_x) * vdiv + mean_y;
float dy_unexplained = points[i].y - y_value;
var_unexplained += dy_unexplained * dy_unexplained;
}
} else {
float vdiv = line[0]/line[1];
for(size_t i = 0; i < points.size(); ++i) {
float x_value = (points[i].y - mean_y) * vdiv + mean_x;
float dx_unexplained = points[i].x - x_value;
var_unexplained += dx_unexplained * dx_unexplained;
}
}
return(var_unexplained * rnum);
}
// when applying distance constraints we spare ourselves the square root and compare the squared values instead
inline size_t squared_distance(const cv::Point &p1, const cv::Point &p2) {
int a = p2.y - p1.y;
int b = p2.x - p1.x;
return(a*a + b*b);
}
// when applying distance constraints we spare ourselves the square root and compare the squared values instead
inline float squared_distance(const cv::Point2f &p1, const cv::Point2f &p2) {
float a = p2.y - p1.y;
float b = p2.x - p1.x;
return(a*a + b*b);
}
inline cv::Point2f computeCenter(const cv::Point2f (&vertices)[4]) {
float sum_x = vertices[0].x + vertices[1].x + vertices[2].x + vertices[3].x;
float sum_y = vertices[0].y + vertices[1].y + vertices[2].y + vertices[3].y;
return(cv::Point2f(0.25f*sum_x, 0.25f*sum_y));
}
inline cv::Point2f computeCenter2(const cv::Point2f (&vertices)[4]) {
cv::Point2f b1(vertices[0]);
cv::Point2f b2(vertices[1]);
cv::Point2f f1(vertices[2] - vertices[0]);
cv::Point2f f2(vertices[3] - vertices[1]);
cv::Vec4f line1(f1.x, f1.y, b1.x, b1.y);
cv::Vec4f line2(f2.x, f2.y, b2.x, b2.y);
return(getCrossing(line1, line2));
}
/**
* Determine the center point based on two sequential edges of the quatrilateral. We determine the angle bisector and compute its crossing between the vector p1->p2
* This can be done analytically
*
* @param p1
* @param p2
* @param p3
* @return
*/
inline cv::Point2f angleBisectorCrossing(const cv::Point2f &p1, const cv::Point2f &p2, const cv::Point2f &p3) {
cv::Point2f a(p3-p2);
cv::Point2f b(p1-p2);
cv::Point2f c(p3-p1);
float length_a = SQRT(a.x*a.x + a.y*a.y);
float length_b = SQRT(b.x*b.x + b.y*b.y);
//float length_c = SQRT(c.x*c.x + c.y*c.y);
float c1_by_c = length_b/(length_a + length_b);
return(p1 + c1_by_c * c);
}
inline cv::Point2f computeCenter(const cv::Point2f (&vertices)[4], const cv::Point2f p_center) {
const size_t num_measurements = 8;
const size_t num_considered_values = 6; //(num_measurements >> 1) + 1;
cv::Point2f centers[num_measurements];
float weights[num_measurements];
size_t index = 0;
// the 2 opposing corner combos
// 02
centers[index++] = 0.5f * (vertices[0] + vertices[2]);
// 13
centers[index++] = 0.5f * (vertices[1] + vertices[3]);
// no min enclosing circle computation here, because it will give the same result as above
// all 3 combos (determine perpendicular bisector crossing and min enclosing circle)
// 012
centers[index++] = angleBisectorCrossing(vertices[0], vertices[1], vertices[2]);
//centers[index++] = perpendicularBisectorCrossing(vertices[0], vertices[1], vertices[2]);
// min enclosing circle
/*vector<cv::Point2f> vertices_copy;
vertices_copy.reserve(4);
vertices_copy.push_back(vertices[0]);
vertices_copy.push_back(vertices[1]);
vertices_copy.push_back(vertices[2]);
centers[index++] = circleCenter(vertices_copy);*/
// 123
centers[index++] = angleBisectorCrossing(vertices[1], vertices[2], vertices[3]);
//centers[index++] = perpendicularBisectorCrossing(vertices[1], vertices[2], vertices[3]);
// min enclosing circle
/*vertices_copy[0] = vertices[1];
vertices_copy[1] = vertices[2];
vertices_copy[2] = vertices[3];
centers[index++] = circleCenter(vertices_copy);*/
// 230
centers[index++] = angleBisectorCrossing(vertices[2], vertices[3], vertices[0]);
//centers[index++] = perpendicularBisectorCrossing(vertices[2], vertices[3], vertices[0]);
// min enclosing circle
/*vertices_copy[0] = vertices[2];
vertices_copy[1] = vertices[3];
vertices_copy[2] = vertices[0];
centers[index++] = circleCenter(vertices_copy);*/
// 301
centers[index++] = angleBisectorCrossing(vertices[3], vertices[0], vertices[1]);
//centers[index++] = perpendicularBisectorCrossing(vertices[3], vertices[0], vertices[1]);
// min enclosing circle
/*vertices_copy[0] = vertices[3];
vertices_copy[1] = vertices[0];
vertices_copy[2] = vertices[1];
centers[index++] = circleCenter(vertices_copy);*/
// all 4 (compute center as a) average of the points b) crossing of the two angle bisectors and c) min enclosing circle)
centers[index++] = computeCenter(vertices);
centers[index++] = computeCenter2(vertices);
// min enclosing circle
/*vertices_copy[0] = vertices[0];
vertices_copy[1] = vertices[1];
vertices_copy[2] = vertices[2];
vertices_copy.push_back(vertices[3]);
centers[index] = circleCenter(vertices_copy);*/
// set weights as euclidean distances
for(size_t i = 0; i < num_measurements; ++i) {
//cout << centers[i].x << "," << centers[i].y << ";" << endl;
float dx = centers[i].x - p_center.x;
float dy = centers[i].y - p_center.y;
weights[i] = dx*dx + dy*dy;
}
//cout << endl << endl;
vector<float> sorted_weights(weights, weights+num_measurements);
nth_element(sorted_weights.begin(), sorted_weights.begin()+num_considered_values, sorted_weights.end());
// relax the border a little and keep all values lower than the border
float max = sorted_weights[num_considered_values];
float rmax = 1.0f/max;
cv::Point2f center(0,0);
float weight_sum = 0;
for(size_t i = 0; i < num_measurements; ++i) {
if(weights[i] < max) {
float weight = 1 - SQRT(weights[i]*rmax);
center += weight * centers[i];
weight_sum += weight;
}
}
return(center * (1.0f/weight_sum));
}
inline float computeFXWeight(const cv::Point2f (&vertices)[4], const cv::Point2f &image_center) {
cv::Point2f vertices_center(computeCenter(vertices));
float dx = FABS(vertices_center.x - image_center.x);
float dy = FABS(vertices_center.y - image_center.y);
return(dx/(dx+dy));
}
inline array<float, 4> computeSideLengths(const cv::Point2f (&vertices)[4]) {
array<float, 4> lengths;
for(size_t i = 0; i < 4; ++i) {
int next = MOD4((i+1));
float dx = vertices[next].x - vertices[i].x;
float dy = vertices[next].y - vertices[i].y;
lengths[i] = SQRT(dx*dx + dy*dy);
}
return(lengths);
}
inline float computePerimeter(const cv::Point2f (&vertices)[4]) {
array<float, 4> side_length = computeSideLengths(vertices);
return(side_length[0] + side_length[1] + side_length[2] + side_length[3]);
}
inline float computePerimeter(const vector<cv::Point2f> &vertices) {
float perimeter = 0;
for(size_t i = 0; i < 4; ++i) {
int next = MOD4((i+1));
float dx = vertices[next].x - vertices[i].x;
float dy = vertices[next].y - vertices[i].y;
perimeter += SQRT(dx*dx + dy*dy);
}
return(perimeter);
}
inline array<float, 4> computeAngles(const cv::Point2f (&vertices)[4]) {
array<float, 4> angles;
array<float, 4> lengths = computeSideLengths(vertices);
for(size_t i = 0; i < 4; ++i) {
int next = MOD4((i+1));
int prev = MOD4((i+3));
cv::Point2f v1(vertices[next] - vertices[i]);
cv::Point2f v2(vertices[prev] - vertices[i]);
angles[i] = ACOS(min((v1.x*v2.x + v1.y*v2.y)/(lengths[i] * lengths[prev]), 1.0f));
}
return(angles);
}
inline float computeQuadArea(const cv::Point2f (&vertices)[4]) {
// use the cross products
cv::Point2f v01(vertices[1] - vertices[0]);
cv::Point2f v03(vertices[3] - vertices[0]);
float area1 = FABS(v01.x*v03.y - v01.y*v03.x);
cv::Point2f v21(vertices[1] - vertices[2]);
cv::Point2f v23(vertices[3] - vertices[2]);
float area2 = FABS(v21.x*v23.y - v21.y*v23.x);
return(0.5f * (area2 + area1));
}
// sort comparators
/**
* Compare by marker x position
* @param a
* @param b
* @return
*/
inline bool cmp_sort_x(const MarkerInfo* const a, const MarkerInfo* const b) {
return(a->w_T_m.translation3d[0] < b->w_T_m.translation3d[0]);
}
/**
* Compare by roi distance to border
* @param a
* @param b
* @return
*/
inline bool cmp_sort_dist(const MarkerROI a, const MarkerROI b) {
return(a.distance < b.distance);
}
} /* namespace fml */
#endif /* MARKER_H_ */
|
6f3ad051ca82caa28748a8ec243285cd4fb7ac0d
|
5de42c4e14a7ddbc284a742c66cb01b230ba43ce
|
/codeforces/34/E.cpp
|
3dd9c1e44a34a047a82293cf98ea26cc685768bd
|
[] |
no_license
|
NhatMinh0208/CP-Archive
|
42d6cc9b1d2d6b8c85e637b8a88a6852a398cc23
|
f95784d53708003e7ba74cbe4f2c7a888d29eac4
|
refs/heads/master
| 2023-05-09T15:50:34.344385
| 2021-05-04T14:25:00
| 2021-05-19T16:10:11
| 323,779,542
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,836
|
cpp
|
E.cpp
|
// Problem : E. Collisions
// Contest : Codeforces - Codeforces Beta Round #34 (Div. 2)
// URL : https://codeforces.com/problemset/problem/34/E
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
/*
A Submission by $%U%$
at time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FILE_IN "cseq.inp"
#define FILE_OUT "cseq.out"
#define ofile freopen(FILE_IN,"r",stdin);freopen(FILE_OUT,"w",stdout)
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nfio cin.tie(0);cout.tie(0)
#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))
#define ord(a,b,c) ((a>=b)and(b>=c))
#define MOD (ll(1000000007))
#define MAX 300001
#define mag 320
#define p1 first
#define p2 second.first
#define p3 second.second
#define fi first
#define se second
#define pow2(x) (ll(1)<<x)
#define pii pair<int,int>
#define piii pair<int,pii>
#define For(i,__,___) for(int i=__;i<=___;i++)
#define Rep(i,__,___) for(int i=__;i>=___;i--)
#define ordered_set tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update>
#define endl "\n"
#define bi BigInt
typedef long long ll;
//---------END-------//
#define endl '\n'
typedef long double dbl;
const dbl oo = DBL_MAX;
const dbl EPS = 1E-9;
dbl getime(dbl x1, dbl v1, dbl x2, dbl v2)
{
if(abs(v1 - v2) < EPS) return oo;
return (x1 - x2) / (v2 - v1);
}
int main()
{
fio;
int n, t;
cin >> n >> t;
vector<dbl> x(n), v(n), m(n);
for(int i = 0; i < n; ++i)
cin >> x[i] >> v[i] >> m[i];
for(dbl tx = 0; tx+EPS < t; )
{
dbl tmp = t-tx;
for(int i = 0; i < n; ++i)
for(int j = 0; j < i; ++j)
{
dbl cur = getime(x[i], v[i], x[j], v[j]);
if(cur < EPS) continue;
tmp = min(tmp, cur);
}
for(int i = 0; i < n; ++i)
x[i] = x[i] + v[i] * tmp;
for(int i = 0; i < n; ++i)
for(int j = 0; j < i; ++j)
if(abs(x[i] - x[j]) < EPS)
{
dbl v1 = ((m[i] - m[j]) * v[i] + 2.0 * m[j] * v[j]) / (m[i] + m[j]);
dbl v2 = ((m[j] - m[i]) * v[j] + 2.0 * m[i] * v[i]) / (m[i] + m[j]);
v[i] = v1; v[j] = v2;
}
tx += tmp;
}
for(int i = 0; i < n; ++i)
cout << fixed << setprecision(9) << x[i] << endl;
}
|
0fe5343f01b6d75825047471e0f0990bedd9fe2b
|
367e78b01dd7e03d32396d22d703c0f069121a32
|
/CodeLeet/MinimumPathSum.cpp
|
56e40f5314b52c274556c51b610700f6724bc25a
|
[] |
no_license
|
wencanluo/LeetCode
|
fc7ce2df36e275f33954d5ecdc49b67460814fc5
|
c56dabdefd43bc845f25655927f7e9842b704108
|
refs/heads/master
| 2021-01-18T21:18:40.876743
| 2017-02-13T02:35:08
| 2017-02-13T02:35:08
| 11,758,649
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,993
|
cpp
|
MinimumPathSum.cpp
|
/*Minimum Path Sum Mar 29 '123383 / 7463
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.
Note: You can only move either down or right at any point in time
Author: Wencan Luo
Language: C++
Date: 07/31/2013
*/
#include<iostream>
using namespace std;
#include<climits>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
//#include<unordered_set>
#include<queue>
#include<set>
// Definition for binary tree
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
//Definition for singly-linked list.
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
class Solution {
public:
struct mycompare {
bool operator() (pair<int,long> a, pair<int,long> b) { return (a.second > b.second); }
};
pair<int,int> getXY(int p, int m){
return make_pair(p/m, p%m);
}
int getP(int x, int y, int m){
return x*m+y;
}
int minPathSum(vector<vector<int> > &grid) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
int n=grid.size();
if(n<=0) return 0;
int m=grid[0].size();
vector<vector<long> >M;
M.resize(n);
for(int i=0;i<n;i++){
M[i].resize(m, INT_MAX);
}
M[0][0] = grid[0][0];
//BFS
priority_queue<pair<int,long>, vector<pair<int,long>>, mycompare> Q;
Q.push(make_pair(getP(0,0,m), M[0][0]));
while(!Q.empty()){
pair<int,long> pD = Q.top();
pair<int, int> p = getXY(pD.first, m);
Q.pop();
if(p.first == n-1 && p.second ==m-1){
return pD.second;
}
int x=p.first + 1;
int y=p.second;
if(x < n) {
if(grid[x][y] + M[p.first][p.second] < M[x][y]){
M[x][y] = grid[x][y] + M[p.first][p.second];
Q.push(make_pair(getP(x,y,m),M[x][y]));
}
}
/*x=p.first - 1;
y=p.second;
if(x > 0) {
if(grid[x][y] + M[p.first][p.second] < M[x][y]){
M[x][y] = grid[x][y] + M[p.first][p.second];
Q.push(make_pair(getP(x,y,m),M[x][y]));
}
}*/
x=p.first;
y=p.second+1;
if(y < m) {
if(grid[x][y] + M[p.first][p.second] < M[x][y]){
M[x][y] = grid[x][y] + M[p.first][p.second];
Q.push(make_pair(getP(x,y,m),M[x][y]));
}
}
/*
x=p.first;
y=p.second-1;
if(y > 0) {
if(grid[x][y] + M[p.first][p.second] < M[x][y]){
M[x][y] = grid[x][y] + M[p.first][p.second];
Q.push(make_pair(getP(x,y,m),M[x][y]));
}
}*/
}
return 0;
}
};
void main(){
Solution s;
int a[] = {1,2,3};
int b[] = {1,2,3};
vector<int> va(a, a+sizeof(a)/sizeof(a[0]));
vector<int> vb(b, b+sizeof(b)/sizeof(b[0]));
vector< vector<int> > v;
v.push_back(va);
v.push_back(vb);
cout << s.minPathSum(v);
system("pause");
}
|
eb7cdb9729628d969dfada3fca27b572a2bfb71c
|
02bc99819fba08876178b156515629c90b0bd1e1
|
/src/regression/Regression2LoggingOperator.cpp
|
daf4978d25455ca5221168a7fc62280b4913e994
|
[] |
no_license
|
vkolobara/fuzzy-time-series
|
c0f055b9e746739b93d73142cb7c5e4c6ca9a366
|
306172d04801e01c84362a095da5abcf6dc3f48e
|
refs/heads/master
| 2021-04-06T10:37:04.794647
| 2018-06-19T13:52:01
| 2018-06-19T13:52:01
| 124,761,241
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 624
|
cpp
|
Regression2LoggingOperator.cpp
|
//
// Created by vkolobara on 6/2/18.
//
#include "FinancialLoggingOperator.h"
#include "Regression2FTSEvalOp.h"
bool Regression2LoggingOperator::operate(StateP state) {
auto evalOp = (Regression2FTSEvalOp*) (state->getEvalOp().get());
if (evalOp->fileLogger) {
auto bestIndividual = state->getPopulation()->getHof()->getBest()[0];
auto dataset = evalOp->dataset;
auto testDataset = evalOp->testDataset;
evalOp->fileLogger->log(state->getGenerationNo(), bestIndividual->getFitness()->getValue(), evalOp->evaluate(bestIndividual, dataset)->getValue());
}
return true;
}
|
3444bac9315d0e13ff286bf7ec787251f5c79596
|
ae6dbcfd6a333bf598b871e15a7741fef81f964f
|
/Projects/Protect/src/CommonSfxTests/TestModule.cpp
|
a70d4b0207c070dfc4f196111250eedf8278d21b
|
[] |
no_license
|
xeon2007/WSProf
|
7d431ec6a23071dde25226437583141f68ff6f85
|
d02c386118bbd45237f6defa14106be8fd989cd0
|
refs/heads/master
| 2016-11-03T17:25:02.997045
| 2015-12-08T22:04:14
| 2015-12-08T22:04:14
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,697
|
cpp
|
TestModule.cpp
|
#include "stdafx.h"
#include "TestModule.h"
#include "..\CommonSfx\Module.h"
BEGIN_TEST_SUITE(TestModule)
ADD_TEST_METHOD(TestConstructorWithValidModuleName)
ADD_TEST_METHOD(TestConstructorWithInvalidModuleName)
END_TEST_SUITE()
void TestModule::TestConstructorWithValidModuleName()
{
Workshare::System::Module module(_T("kernel32.dll"));
assertMessage(::GetModuleHandle(_T("kernel32.dll")) == module.m_handle, _T("kernel32.dll always exists and should have been loaded"));
}
void TestModule::TestConstructorWithInvalidModuleName()
{
assertThrowsMessage(Workshare::System::Module module(_T("BooLaaDaa?.dll")), Workshare::System::SystemException, _T("Workshare::System::SystemException should be thrown for an invalid filename"));
}
//void TestModule::TestDestructor()
//{
// {
// Workshare::System::Module module(_T("MockModule.dll"));
// assertMessage(::GetModuleHandle(_T("MockModule.dll")) == module.m_handle, _T("MockModule.dll should have been loaded"));
// }
// assertMessage(NULL == ::GetModuleHandle(_T("MockModule.dll")), _T("Module::~Module didn't called FreeLibrary; or the call failed."));
//}
//
//void TestModule::TestGetProcAddressWithValidName()
//{
// Workshare::System::Module module(_T("MockModule.dll"));
// assertMessage(NULL != module.GetProcAddress(_T("_Foo@4")), _T("Expected void _stdcall Foo(LPCTSTR) to exist in 'MockModule.dll'"));
//}
//
//void TestModule::TestGetProcAddressWithInvalidName()
//{
// Workshare::System::Module module(_T("MockModule.dll"));
// assertThrowsMessage(module.GetProcAddress(_T("Baa")), Workshare::System::SystemException, _T("Expected Baa NOT to exist in 'MockModule.dll'"));
//}
//
//
//
|
5aedcd885fb2066bec59e5fafd94d4181404aa2b
|
48710b15736de7ed252eba07377a0afb9bfc7eaf
|
/cppSolutions/problems/source/p98.cpp
|
57d8bd2dffcda82e2436555b44e59d9cd73898da
|
[] |
no_license
|
nnard1616/projectEuler
|
dc579599d6e4305654638ff1741b45c7ea2460a7
|
77776f961417a35c86ed02a32226cceb02c24bc8
|
refs/heads/master
| 2021-07-09T16:17:24.496193
| 2018-05-21T04:54:55
| 2018-05-21T04:54:55
| 96,654,215
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,030
|
cpp
|
p98.cpp
|
#include <problems/p98.hpp>
namespace problems
{
/*--- Main Function --------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
long p98()
{
std::ifstream infile("../../cppSolutions/problems/txt/p098_words.txt");
std::map<string, vector<string>> wordAnagrams = load_word_anagrams(infile);
infile.close();
// Get largest possible anagram number from longest word in 'wordAnagrams'
double maxNum = 0;
for (auto it = wordAnagrams.begin(); it != wordAnagrams.end(); ++it)
maxNum = std::max(maxNum, pow(10, it->first.size()));
// Generate vector of square numbers up to 'maxNum'
vector<long> squares;
for (long i = 0; pow(i, 2) < maxNum; i++)
squares.push_back(pow(i, 2));
// Compare squares to anagramic words
for (auto rit = squares.rbegin(); rit != squares.rend(); ++rit)
for (auto it = wordAnagrams.begin(); it != wordAnagrams.end(); ++it)
if (std::to_string(*rit).size() == it->first.size()) // same length
if (have_equal_unique_char_num(*rit, it->first))
if (is_a_match(*rit, it->second[0])) // see function def below
if (is_a_square_anagram(*rit, it->second))
return *rit; // answer to projectEuler problem has been found
return 0; // answer not found
}
/*--- Load Function --------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
std::map<string, vector<string>> load_word_anagrams(std::istream& infile)
{
string word; // getline parser
std::map<string, vector<string>> nonAnagrams; // contains anagrams
std::map<string, vector<string>> anagrams; // subset of nonAnagrams
while (std::getline(infile, word, ','))
{
string subword = word.substr(1, word.length() - 2); // Gets rid of " "
if (subword.length() > 3) // I guess answer will be more than 3 letters
{
string letters = subword; // gonna alphabetize word's letters, map key
std::sort(letters.begin(), letters.end()); // alphabetized
// generate anagrams' map values
if (nonAnagrams[letters].size() > 0)
{ // we have a anagram pair/set
nonAnagrams[letters].push_back(subword);
anagrams[letters] = nonAnagrams[letters];
}
else // first word of this letters type, may or may not be anagram set
nonAnagrams[letters].push_back(subword);
}
}
// anagrams map example:
// Key: "OPST" -> Value: ["STOP", "POST", "SPOT"]
// NOTE: "OPST" is only anagram set with more than 2 words
return anagrams;
}
/*--- Matcher Functions ----------------------------------------------------*/
/*--------------------------------------------------------------------------*/
bool have_equal_unique_char_num(long& n, const string& letters)
{ // counts unique characters in 'n' and 'letters'
// returns true if same number of uniques, false otherwise
string alphaUniques;
for (auto it = letters.begin(); it != letters.end(); ++it)
if (alphaUniques.find(*it) == string::npos)
alphaUniques.push_back(*it);
string sn = std::to_string(n);
string digitUniques;
for (auto it = sn.begin(); it != sn.end(); ++it)
if (digitUniques.find(*it) == string::npos)
digitUniques.push_back(*it);
return alphaUniques.size() == digitUniques.size();
}
bool is_a_match(long& n, string& word)
{ // Match: n and word have identical char lengths and orders
std::map<int, char> dtoa; // digit to alpha
string sn = std::to_string(n);
for (auto it = sn.begin(); it != sn.end(); ++it)
// going over digits in 'n' to map them to a alpha in word
dtoa[*it] = word[sn.find(*it)];
string transcription; // word from number
for (auto it = sn.begin(); it != sn.end(); ++it)
transcription.push_back(dtoa[*it]);
return transcription == word;
}
bool is_a_square_anagram(long& n, vector<string>& words)
{
std::map<char, int> atod; // alpha to digit
string sn = std::to_string(n);
bool winner = false; // no chicken dinner
long transcription = 0; // number from word
for (int w = 0; w != 2; ++w)
{ // First iteration checks if first word creates anagramic square that
// transcribes to the second word in the string vector, words.
//
// Second iteration does the inverse, so I need for the 'x' index below.
//
// when w = 0, x = 1 and likewise when w = 1, x = 0
for (auto it = words[w].begin(); it != words[w].end(); ++it)
// going over letters in the word to map them to a digit in 'sn'
atod[*it] = sn[words[w].find(*it)] - '0'; // char -'0' yields digit
transcription = 0; // reset
int x = (w + 1) % 2; // index of other word in the string vector, words
for (long i = words[x].size() - 1; i != -1; --i)
transcription += atod[words[x][words[x].size() - i - 1]] * pow(10, i);
// The above for loop creates a new number, 'transcription', generated
// from the 'x' word from 'words' via the map made from the 'w' word.
// It's hard to describe how it computes 'transcription', but here's a
// brief and simple example demonstrating what it's doing:
// 483 = 4*10^2 + 8*10^1 + 3*10^0
// The boolean below first checks that 'transcription' is a square number,
// and then checks that they have the same number of digits. Without the
// second test, bugged answers occur due to leading 0's popping up in
// 'transcription':
// ex) 4501 has an anagram of 0145, but that is interpreted as 145.
if ((floor(pow(transcription, 0.5)) == pow(transcription, 0.5)) &&
(ceil(log10(transcription)) == ceil(log10(n))))
winner = true; // winner winner chicken dinner
}
return winner;
}
}
|
ac20163723cfad172493494bd7bffe48e3b8d36d
|
71b40ea6c16a26efee5afa56be6a4d879dacac7b
|
/pebblesolitaire/main.cc
|
1caf30ed3d8db21f97e27d3fd4eddbdc3ebfac97
|
[] |
no_license
|
XrXr/KattisSolutions
|
ae5292ca270809db231b3d080422bc09c3456cf7
|
149d4a971d796420e7a16c676a382cea496fd1a2
|
refs/heads/master
| 2021-01-24T06:36:34.284475
| 2019-02-19T02:55:38
| 2019-02-19T02:55:38
| 51,628,236
| 2
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,231
|
cc
|
main.cc
|
#include <iostream>
#include <bitset>
#include <algorithm>
#define INF 0x3f3f3f3f
using namespace std;
size_t best = INF;
void bt(const bitset<12> board) {
bool foundMove = false;
for (int i = 0; i < 12; i++) {
if (board.test(i) && i + 2 < 12 && board.test(i+1) && !board.test(i+2)) {
bitset<12> newboard(board);
newboard.reset(i);
newboard.reset(i+1);
newboard.set(i+2);
foundMove = true;
bt(newboard);
}
if (board.test(i) && i - 2 >= 0 && board.test(i-1) && !board.test(i-2)) {
bitset<12> newboard(board);
newboard.reset(i);
newboard.reset(i-1);
newboard.set(i-2);
foundMove = true;
bt(newboard);
}
}
if (!foundMove) {
best = min(best, board.count());
}
}
int main() {
int n;
cin >> n;
cin.ignore();
while (n--) {
string l;
getline(cin, l);
bitset<12> board;
int i = 0;
for (char c : l) {
if (c == 'o')
board ^= 1 << i;
i++;
}
best = INF;
bt(board);
cout << best << endl;
}
}
|
31d94aae6784fab87aa389452c5fc1dc1a895b13
|
e4822c6289a2db5ecaddc78c948970528b9a1e43
|
/fortunethread.cpp
|
3bfa287801f1a08ef88bbad32e13c5fc440cad60
|
[] |
no_license
|
atur94/BHQT
|
8d787022970310ac3f5b6881dd1cddb2e50d3d3c
|
1e8f82eedfabf3bd22f69c9144b4c47b96b913ac
|
refs/heads/master
| 2021-01-12T05:42:38.907063
| 2017-02-04T20:02:46
| 2017-02-04T20:02:46
| 77,174,288
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,316
|
cpp
|
fortunethread.cpp
|
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtWidgets>
#include <QtNetwork>
#include "fortunethread.h"
#include "dataget.h"
#include "datastruct.h"
#include "defines.h"
FortuneThread::FortuneThread(QObject *parent)
: QThread(parent), quit(false)
{
disp1 = new QGraphicsView();
scene1 = new QGraphicsScene();
dataBuffer = new Dataget();
s = new dataStruct();
}
//! [0]
FortuneThread::~FortuneThread()
{
mutex.lock();
cond.wakeOne();
mutex.unlock();
wait();
}
//! [0]
//! [1] //! [2]
void FortuneThread::requestNewFortune()
{
//! [1]
QMutexLocker locker(&mutex);
this->hostName = "192.168.1.110";
this->port = 5000;
//! [3]
if (!isRunning())
start();
else
cond.wakeOne();
}
//! [2] //! [3]
//! [4]
void FortuneThread::run()
{
mutex.lock();
//! [4] //! [5]
QString serverName = hostName;
quint16 serverPort = port;
//! [5]
QTcpSocket socket;
gSocket = &socket;
qint64 length;
mutex.unlock();
//! [6]
while (1) {
const int Timeout = 1 * 1000;
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(Timeout)) {
emit error(socket.error(), socket.errorString());
return;
}
QDataStream in(&socket);
in.setVersion(QDataStream::Qt_4_0);
QString fortune;
QString string;
do {
if (!socket.waitForReadyRead(Timeout)) {
dataBuffer->printOut();
qDebug() << "END PRINT";
dataBuffer->computeToXY();
qDebug() << "END COMPUTE";
dataBuffer->getData(s->data);
qDebug() << "END GETDATA";
dataBuffer->fillPlane(s->data);
emit draw();
dataBuffer->tabClear(dataBuffer->yxPOS);
emit error(socket.error(), socket.errorString());
return;
}
in.startTransaction();
in >> fortune;
in >> length;
string = socket.readLine();
dataBuffer->setData(string);
} while (1);
mutex.lock();
emit newFortune(fortune);
cond.wait(&mutex);
serverName = hostName;
serverPort = port;
mutex.unlock();
}
//! [15]
}
void FortuneThread::readTcpData(){
}
void FortuneThread::startScan(){
sendFlag = true;
w++;
}
void FortuneThread::plane1(){
plane = 1;
qDebug() << plane;
}
void FortuneThread::plane2(){
plane = 2;
qDebug() << plane;
}
void FortuneThread::getData(int out[ARRAYH][ARRAYW]){
for(int j = 0; j < ARRAYH; j++){
for (int k = 0; k < ARRAYW; k++){
out[j][k] = s->data[j][k];
}
}
}
void FortuneThread::getScene(QGraphicsScene *scene){
this->scene1 = scene;
}
void FortuneThread::DrawPlane(int xyPOS[ARRAYH][ARRAYW]){
qDebug() << "ENTERING DRAW FUNCTION";
for(int i = 0; i < ARRAYH; i++){
for(int j = 0; j < ARRAYW; j++){
if(xyPOS[i][j] == 1 ) {
scene1->addRect(i,j,1,1);
}else {
scene1->addRect(i,j,0,0);
}
}
}
emit clrSig();
}
void FortuneThread::clearTab(){
for(int j = 0; j < ARRAYH; j++){
for (int k = 0; k < ARRAYW; k++){
s->data[j][k] = 0;
}
}
}
int FortuneThread::getPoints(int area[ARRAYH][ARRAYW])
{
int areaSum = 0;
for(int i = 0; i < ARRAYH; i++){
for(int j = 0; j < ARRAYW; j++){
if(area[i][j] == 1){
areaSum++;
}
}
}
return areaSum;
}
void FortuneThread::debugMode()
{
dataBuffer->debugMode();
dataBuffer->getData(s->data);
qDebug() << "END GETDATA";
dataBuffer->fillPlane(s->data);
emit draw();
dataBuffer->tabClear(dataBuffer->yxPOS);
}
|
0d1c56b51d4371371f7ad0755deb78d95e8eb4a3
|
b505ef7eb1a6c58ebcb73267eaa1bad60efb1cb2
|
/source/graphics/core/win32/opengl/pixelshaderopengl.h
|
97f5a46989f77cb2b3e7a2322949d1c026637569
|
[] |
no_license
|
roxygen/maid2
|
230319e05d6d6e2f345eda4c4d9d430fae574422
|
455b6b57c4e08f3678948827d074385dbc6c3f58
|
refs/heads/master
| 2021-01-23T17:19:44.876818
| 2010-07-02T02:43:45
| 2010-07-02T02:43:45
| 38,671,921
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 653
|
h
|
pixelshaderopengl.h
|
#ifndef maid2_graphics_core_win32_opengl_pixelshaderopengl_h
#define maid2_graphics_core_win32_opengl_pixelshaderopengl_h
#include"../../../../config/define.h"
#include"../../ipixelshader.h"
#include"common.h"
namespace Maid { namespace Graphics {
class PixelShaderOpenGL
: public IPixelShader
, public IOpenGLObject
{
public:
PixelShaderOpenGL();
~PixelShaderOpenGL();
void Initialize( const void* pData, size_t length );
void Finalize();
GLuint GetID() const;
private:
GLuint m_ID;
};
typedef boost::shared_ptr<PixelShaderOpenGL> SPPIXELSHADEROPENGL;
}}
#endif
|
c9c76b90d2f29aa6b4983ebdbd37eca578948c4f
|
163829e90c4ef643882e4b6ddec100e464964537
|
/Source_Code/BFS/1009 back to underworld.cpp
|
dfe4e32d4d4b3ca4c5f463d03ecf160c13f18aad
|
[] |
no_license
|
Rijul1204/Algorithm_ACM
|
31b0d88750fc90f13f0c7188a78ac58a059de599
|
0477861d5476504faa02d3dfddda0ea8acaf5c2e
|
refs/heads/master
| 2021-07-03T07:34:08.169513
| 2021-05-30T19:55:03
| 2021-05-30T19:55:03
| 10,447,817
| 5
| 7
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,244
|
cpp
|
1009 back to underworld.cpp
|
#include<stdio.h>
#include<vector>
#include<map>
#include<queue>
#include<string.h>
using namespace std;
int col[20100];
int state[20100],on,tw;
vector<int>v[20100];
map<int,int>num;
queue<int>q;
void bfs(int s);
int max(int a,int b){
if(a>b) return a;
return b;
}
int flag;
int main(){
int i,j,k,l,test,t=1,sum;
int count1,n;
// freopen("in.txt","r",stdin);
scanf("%d",&test);
while(test--){
scanf("%d",&n);
num.clear();
memset(col,0,sizeof(col));
memset(state,0,sizeof(state));
for(i=0;i<=20010;i++){
v[i].clear();
}
count1=1;
for(i=1;i<=n;i++){
scanf("%d %d",&k,&l);
if(!num[k]) num[k]=count1++;
if(!num[l]) num[l]=count1++;
v[num[k]].push_back(num[l]);
v[num[l]].push_back(num[k]);
}
flag=1;
sum=0;
for(i=1;i<count1;i++){
if(!col[i]){
on=tw=0;
bfs(i);
sum+=max(on,tw);
}
}
printf("Case %d: %d\n",t++,sum);
}
return 0;
}
void bfs(int s){
col[s]=1;
state[s]=1;
on++;
q.push(s);
int i,j,k,l;
while(!q.empty()){
i=q.front(); q.pop();
for(j=0;j<v[i].size();j++){
k=v[i][j];
if(state[k]==state[i]) flag=0;
if(!col[k]){
state[k]=3-state[i];
if(state[k]==1) on++;
else tw++;
col[k]=1;
q.push(k);
}
}
}
}
|
23a43637624a23f01ebc07eefc4aa72f757eb8b8
|
68f78353a0b25aedd0cdf0b83c850d793a8c1274
|
/src/keyboard_layouts/akuhell.hpp
|
18b2bdc6c8007a20552b3245a70536c6e382bf09
|
[
"MIT"
] |
permissive
|
Aglezabad/akuhell
|
d107d19333b52cf651f9f4103ea78ccf8b5f3e0c
|
84b084f647ecb4898f40dc9c43f201546796d035
|
refs/heads/master
| 2021-01-18T15:53:06.406457
| 2017-03-30T14:46:13
| 2017-03-30T14:46:13
| 86,687,676
| 0
| 0
| null | 2017-03-30T09:59:50
| 2017-03-30T09:59:50
| null |
UTF-8
|
C++
| false
| false
| 14,895
|
hpp
|
akuhell.hpp
|
size_t Keyboard_write(KeyboardKeycode k, KeyModifier modifier)
{
if ((modifier & KeyModifier::leftCtrl)==KeyModifier::leftCtrl)
{
Keyboard.press(KEY_LEFT_CTRL);
}
if ((modifier & KeyModifier::leftShift)==KeyModifier::leftShift)
{
Keyboard.press(KEY_LEFT_SHIFT);
}
if ((modifier & KeyModifier::leftAlt)==KeyModifier::leftAlt)
{
Keyboard.press(KEY_LEFT_ALT);
}
if ((modifier & KeyModifier::leftWindows)==KeyModifier::leftWindows)
{
Keyboard.press(KEY_LEFT_WINDOWS);
}
if ((modifier & KeyModifier::altGr)==KeyModifier::altGr) // see Issue#1
{
Keyboard.press(KEY_RIGHT_ALT);
}
Keyboard.press(k);
Keyboard.releaseAll(); //todo: library-version of write calls release only when retval of press!=0 and returns retval
}
// EN_US version of this is the same as the values in HID_project\src\HID-APIs\ImprovedKeylayouts.h
size_t Keyboard_convertUtf8CharacterToKeycode(const String & ch, KeyboardKeycode & k, KeyModifier & modifier)
{
modifier=KeyModifier::none;
//const KeyModifier altGrModifier=(KeyModifier::leftCtrl|KeyModifier::leftAlt);
const KeyModifier altGrModifier=KeyModifier::altGr; // see Issue#1
if(ch.length()==1)
{
char firstByte=ch.charAt(0);
if (firstByte==0x08) { k=KEY_BACKSPACE; return 0; }
else if(firstByte==0x09) { k=KEY_TAB; return 0; }
else if(firstByte==0x0A) { k=KEY_ENTER; return 0; } //todo: use 0x0D (CR)?
else if(firstByte==0x1B) { k=KEY_ESC; return 0; }
else if(firstByte==0x20) { k=KEY_SPACE; return 0; }
else if(firstByte==0x21) { k=KEY_1; modifier=KeyModifier::leftShift; return 0; } // !
#if KEYBOARD_LAYOUT_LANG == KBD_LAYOUT_EN_US
else if(firstByte==0x22) { k=KEY_QUOTE; modifier=KeyModifier::leftShift; return 0; } // "
else if(firstByte==0x23) { k=KEY_3; modifier=KeyModifier::leftShift; return 0; } // #
#endif
#if KEYBOARD_LAYOUT_LANG == KBD_LAYOUT_DE_DE
else if(firstByte==0x22) { k=KEY_2; modifier=KeyModifier::leftShift; return 0; } // "
else if(firstByte==0x23) { k=KEY_BACKSLASH; return 0; } // #
#endif
else if(firstByte==0x24) { k=KEY_4; modifier=KeyModifier::leftShift; return 0; } // $
else if(firstByte==0x25) { k=KEY_5; modifier=KeyModifier::leftShift; return 0; } // %
#if KEYBOARD_LAYOUT_LANG == KBD_LAYOUT_EN_US
else if(firstByte==0x26) { k=KEY_7; modifier=KeyModifier::leftShift; return 0; } // &
else if(firstByte==0x27) { k=KEY_QUOTE; return 0; } // '
else if(firstByte==0x28) { k=KEY_9; modifier=KeyModifier::leftShift; return 0; } // (
else if(firstByte==0x29) { k=KEY_0; modifier=KeyModifier::leftShift; return 0; } // )
else if(firstByte==0x2A) { k=KEY_8; modifier=KeyModifier::leftShift; return 0; } // *
else if(firstByte==0x2B) { k=KEY_EQUAL; modifier=KeyModifier::leftShift; return 0; } // +
#endif
#if KEYBOARD_LAYOUT_LANG == KBD_LAYOUT_DE_DE
else if(firstByte==0x26) { k=KEY_6; modifier=KeyModifier::leftShift; return 0; } // &
else if(firstByte==0x27) { k=KEY_BACKSLASH; modifier=KeyModifier::leftShift; return 0; } // '
else if(firstByte==0x28) { k=KEY_8; modifier=KeyModifier::leftShift; return 0; } // (
else if(firstByte==0x29) { k=KEY_9; modifier=KeyModifier::leftShift; return 0; } // )
else if(firstByte==0x2A) { k=KEY_RIGHT_BRACE; modifier=KeyModifier::leftShift; return 0; } // *
else if(firstByte==0x2B) { k=KEY_RIGHT_BRACE; return 0; } // +
#endif
else if(firstByte==0x2C) { k=KEY_COMMA; return 0; } // ,
else if(firstByte==0x2E) { k=KEY_PERIOD; return 0; } // .
#if KEYBOARD_LAYOUT_LANG == KBD_LAYOUT_EN_US
else if(firstByte==0x2D) { k=KEY_MINUS; return 0; } // -
else if(firstByte==0x2F) { k=KEY_SLASH; return 0; } // /
#endif
#if KEYBOARD_LAYOUT_LANG == KBD_LAYOUT_DE_DE
else if(firstByte==0x2D) { k=KEY_SLASH; return 0; } // -
else if(firstByte==0x2F) { k=KEY_7; modifier=KeyModifier::leftShift; return 0; } // /
#endif
else if(firstByte==0x30) { k=KEY_0; return 0; } // 0
else if(firstByte>=0x31&&firstByte<=0x39) { k=(KeyboardKeycode)(KEY_1+(firstByte-0x31)); return 0; } // 1 to 9
#if KEYBOARD_LAYOUT_LANG == KBD_LAYOUT_EN_US
else if(firstByte==0x3A) { k=KEY_SEMICOLON; modifier=KeyModifier::leftShift; return 0; } // :
else if(firstByte==0x3B) { k=KEY_SEMICOLON; return 0; } // ;
else if(firstByte==0x3C) { k=KEY_COMMA; modifier=KeyModifier::leftShift; return 0; } // <
else if(firstByte==0x3D) { k=KEY_EQUAL; return 0; } // =
else if(firstByte==0x3E) { k=KEY_PERIOD; modifier=KeyModifier::leftShift; return 0; } // >
else if(firstByte==0x3F) { k=KEY_SLASH; modifier=KeyModifier::leftShift; return 0; } // ?
else if(firstByte==0x40) { k=KEY_2; modifier=KeyModifier::leftShift; return 0; } // @
#endif
#if KEYBOARD_LAYOUT_LANG == KBD_LAYOUT_DE_DE
else if(firstByte==0x3A) { k=KEY_PERIOD; modifier=KeyModifier::leftShift; return 0; } // :
else if(firstByte==0x3B) { k=KEY_COMMA; modifier=KeyModifier::leftShift; return 0; } // ;
else if(firstByte==0x3C) { k=KEY_NON_US; return 0; } // <
else if(firstByte==0x3D) { k=KEY_0; modifier=KeyModifier::leftShift; return 0; } // =
else if(firstByte==0x3E) { k=KEY_NON_US; modifier=KeyModifier::leftShift; return 0; } // >
else if(firstByte==0x3F) { k=KEY_MINUS; modifier=KeyModifier::leftShift; return 0; } // ?
else if(firstByte==0x40) { k=KEY_Q; modifier=altGrModifier; return 0; } // @
#endif
else if(firstByte>=0x41&&firstByte<=0x58) { k=(KeyboardKeycode)(KEY_A+(firstByte-0x41)); modifier=KeyModifier::leftShift; return 0; } // A to X
#if KEYBOARD_LAYOUT_LANG == KBD_LAYOUT_EN_US
else if(firstByte==0x59) { k=KEY_Y; modifier=KeyModifier::leftShift; return 0; } // Y
else if(firstByte==0x5A) { k=KEY_Z; modifier=KeyModifier::leftShift; return 0; } // Z
else if(firstByte==0x5B) { k=KEY_LEFT_BRACE; return 0; } // [
else if(firstByte==0x5C) { k=KEY_BACKSLASH; return 0; } // '\'
else if(firstByte==0x5D) { k=KEY_RIGHT_BRACE; return 0; } // ]
else if(firstByte==0x5E) { k=KEY_6; modifier=KeyModifier::leftShift; return 0; } // ^
else if(firstByte==0x5F) { k=KEY_MINUS; modifier=KeyModifier::leftShift; return 0; } // _
else if(firstByte==0x60) { k=KEY_TILDE; return 0; } // `
#endif
#if KEYBOARD_LAYOUT_LANG == KBD_LAYOUT_DE_DE
else if(firstByte==0x59) { k=KEY_Z; modifier=KeyModifier::leftShift; return 0; } // Y
else if(firstByte==0x5A) { k=KEY_Y; modifier=KeyModifier::leftShift; return 0; } // Z
else if(firstByte==0x5B) { k=KEY_8; modifier=altGrModifier; return 0; } // [
else if(firstByte==0x5C) { k=KEY_MINUS; modifier=altGrModifier; return 0; } // '\'
else if(firstByte==0x5D) { k=KEY_9; modifier=altGrModifier; return 0; } // ]
else if(firstByte==0x5E) { k=KEY_TILDE; return 0; } // ^
else if(firstByte==0x5F) { k=KEY_SLASH; modifier=KeyModifier::leftShift; return 0; } // _
else if(firstByte==0x60) { k=KEY_EQUAL; modifier=KeyModifier::leftShift; return 0; } // `
#endif
else if(firstByte>=0x61&&firstByte<=0x78) { k=(KeyboardKeycode)(KEY_A+(firstByte-0x61)); return 0; } // a to x
#if KEYBOARD_LAYOUT_LANG == KBD_LAYOUT_EN_US
else if(firstByte==0x79) { k=KEY_Y; return 0; } // y
else if(firstByte==0x7A) { k=KEY_Z; return 0; } // z
else if(firstByte==0x7B) { k=KEY_LEFT_BRACE; modifier=KeyModifier::leftShift; return 0; } // {
else if(firstByte==0x7C) { k=KEY_BACKSLASH; modifier=KeyModifier::leftShift; return 0; } // |
else if(firstByte==0x7D) { k=KEY_RIGHT_BRACE; modifier=KeyModifier::leftShift; return 0; } // }
else if(firstByte==0x7E) { k=KEY_TILDE; modifier=KeyModifier::leftShift; return 0; } // ~
#endif
#if KEYBOARD_LAYOUT_LANG == KBD_LAYOUT_DE_DE
else if(firstByte==0x79) { k=KEY_Z; return 0; } // y
else if(firstByte==0x7A) { k=KEY_Y; return 0; } // z
else if(firstByte==0x7B) { k=KEY_7; modifier=altGrModifier; return 0; } // {
else if(firstByte==0x7C) { k=KEY_NON_US; modifier=altGrModifier; return 0; } // |
else if(firstByte==0x7D) { k=KEY_0; modifier=altGrModifier; return 0; } // }
else if(firstByte==0x7E) { k=KEY_RIGHT_BRACE; modifier=altGrModifier; return 0; } // ~
#endif
else if(firstByte==0x7F) { k=KEY_DELETE; return 0; } // DEL(Entf)
}
else if(ch.length()==2)
{
byte firstByte=ch.charAt(0);
byte secondByte=ch.charAt(1);
//Serial.println("2bytes");
//Serial.println(firstByte, HEX);
//Serial.println(secondByte, HEX);
#if KEYBOARD_LAYOUT_LANG == KBD_LAYOUT_DE_DE
if(firstByte==0xC2 && secondByte==0xA7) { k=KEY_3; modifier=KeyModifier::leftShift; return 0; } // §
else if(firstByte==0xC2 && secondByte==0xB2) { k=KEY_2; modifier=altGrModifier; return 0; } // ²
else if(firstByte==0xC2 && secondByte==0xB3) { k=KEY_3; modifier=altGrModifier; return 0; } // ³
else if(firstByte==0xC2 && secondByte==0xB4) { k=KEY_EQUAL; return 0; } // ´
else if(firstByte==0xC2 && secondByte==0xB5) { k=KEY_M; modifier=altGrModifier; return 0; } // µ
else if(firstByte==0xC2 && secondByte==0xB0) { k=KEY_TILDE; modifier=KeyModifier::leftShift; return 0; } // ° (Degree) // 0xC2 0xBA 'MASCULINE ORDINAL INDICATOR' looks the same!
else if(firstByte==0xC3 && secondByte==0x84) { k=KEY_QUOTE; modifier=KeyModifier::leftShift; return 0; } // Ä
else if(firstByte==0xC3 && secondByte==0x96) { k=KEY_SEMICOLON; modifier=KeyModifier::leftShift; return 0; } // Ö
else if(firstByte==0xC3 && secondByte==0x9C) { k=KEY_LEFT_BRACE; modifier=KeyModifier::leftShift; return 0; } // Ü
else if(firstByte==0xC3 && secondByte==0x9F) { k=KEY_MINUS; return 0; } // ß
else if(firstByte==0xC3 && secondByte==0xA4) { k=KEY_QUOTE; return 0; } // ä
else if(firstByte==0xC3 && secondByte==0xB6) { k=KEY_SEMICOLON; return 0; } // ö
else if(firstByte==0xC3 && secondByte==0xBC) { k=KEY_LEFT_BRACE; return 0; } // ü
#endif
}
else if(ch.length()==3)
{
byte firstByte=ch.charAt(0); // when using 'char' the comparison does not seem to work and println prints e.g. FFFFFFE2
byte secondByte=ch.charAt(1);
byte thirdByte=ch.charAt(2);
#if KEYBOARD_LAYOUT_LANG == KBD_LAYOUT_DE_DE
//Serial.println("fb");
//Serial.println(firstByte, HEX);
//Serial.println(secondByte, HEX);
//Serial.println(thirdByte, HEX);
if(firstByte==0xE2 && secondByte==0x82 && thirdByte==0xAC) { k=KEY_E; modifier=altGrModifier; return 0; } // €
#endif
}
return 1; //unable to convert
}
void Keyboard_writeUtf8Character(const String & ch)
{
KeyboardKeycode k=KEY_RESERVED; //invalid
KeyModifier modifier=KeyModifier::none;
Keyboard_convertUtf8CharacterToKeycode(ch, k, modifier); //todo: check retval
//Serial.print("wutf ");
//Serial.print(k);
//Serial.print(" ");
//Serial.println(modifier);
Keyboard_write(k, modifier);
}
int utf8_charlen(byte firstByte)
{
if (firstByte>=0 && firstByte<=127) return 1;
else if ((firstByte & 0xE0) == 0xC0) return 2;
else if ((firstByte & 0xF0) == 0xE0) return 3;
else if ((firstByte & 0xF8) == 0xF0) return 4;
//else if ((firstByte & 0xFC) == 0xF8) return 5; //byte 5, unnecessary in 4 byte UTF-8
//else if ((firstByte & 0xFE) == 0xFC) return 6; //byte 6, unnecessary in 4 byte UTF-8
else return -1; //invalid utf8
}
int utf8_strlen(const String & str)
{
int currentByteIndex=0;
int currentCharIndex=0;
while(true)
{
if(currentByteIndex>=str.length())
{
break;
}
byte currentFirstByte = str.charAt(currentByteIndex);
int charLen = utf8_charlen(currentFirstByte);
if(currentFirstByte==-1)
{
return -1; //invalid utf8
}
currentByteIndex+=charLen;
++currentCharIndex;
}
return currentCharIndex;
}
// untested
String utf8_charAt(const String & str, int index)
{
int currentByteIndex=0;
int currentCharIndex=0;
while(true)
{
if(currentByteIndex>=str.length())
{
break;
}
byte currentFirstByte = str.charAt(currentByteIndex);
int charLen = utf8_charlen(currentFirstByte);
if(currentFirstByte==-1)
{
return ""; //invalid utf8
}
if(currentCharIndex==index)
{
return str.substring(currentByteIndex,currentByteIndex+charLen);
}
currentByteIndex+=charLen;
++currentCharIndex;
}
}
void Keyboard_writeUtf8String(const String & str)
{
int currentByteIndex=0;
while(true)
{
if(currentByteIndex>=str.length())
{
break;
}
byte currentFirstByte = str.charAt(currentByteIndex);
int charLen = utf8_charlen(currentFirstByte);
if(currentFirstByte==-1)
{
return; //invalid utf8
}
String currentChar=str.substring(currentByteIndex,currentByteIndex+charLen);
Keyboard_writeUtf8Character(currentChar);
currentByteIndex+=charLen;
}
}
|
5a216cbabc497d869a5eb3e8e9ad201b71b69949
|
f7b4e2e208d3bc12321924bbcddfa6501cf258ef
|
/CodeforcesProblems/Polycarp's Practice.cf.cpp
|
a2978a4a31d3cddaf8bd5828ed3523857c8b4cc8
|
[] |
no_license
|
Anik-Modak/OnlineJudgeProblemSolution
|
b476fecf1d112893bc71ea6012a17e26de75254d
|
a19076d346b1d6028cd75b4ee90b82c4e01cb9dc
|
refs/heads/master
| 2020-05-04T18:24:37.248578
| 2019-04-26T19:53:13
| 2019-04-26T19:53:13
| 179,351,861
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 635
|
cpp
|
Polycarp's Practice.cf.cpp
|
//Anik_Modak
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int a[n],s=0;
vector<int>v;
for(int i=0; i<n; i++)
{
cin>>a[i];
v.push_back(a[i]);
}
sort(a,a+n);
for(int i=k; i>0; i--)
{
s+=a[n-i];
mp[a[n-i]]++;
}
cout<<s<<endl;
int m=0,cnt=0,ind=0;
for(int i = 0; i < n; i++)
{
cnt++;
m++;
if(mp[a[i]])
{
ind++;
mp[a[i]]--;
if(ind == k) printf("%d\n", n - m + cnt);
else printf("%d ", cnt);
cnt = 0;
}
}
}
|
48e9e7de853f503b57b952b3d90332ac33cf5a50
|
06f5f8e660ef2ac6ad9c7cc7159a1611a7cd37f1
|
/thunder/storage/storage-inl.hpp
|
60cb90758d7301fe4c56ffdc3be07272a56d16c1
|
[
"Apache-2.0"
] |
permissive
|
benben-yunyun/Thunder
|
6971df8c610d9b617f1e4ad9df0ce7795af65de4
|
c98dcb2d6a7cfe09ea2a807959773300fb6d93c5
|
refs/heads/master
| 2020-12-29T03:07:44.163317
| 2014-08-10T07:26:07
| 2014-08-10T07:26:07
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,739
|
hpp
|
storage-inl.hpp
|
/*
* Copyright 2014 Xiang Zhang. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef THUNDER_STORAGE_STORAGE_INL_HPP
#define THUNDER_STORAGE_STORAGE_INL_HPP
#include "thunder/storage/storage.hpp"
#include <memory>
#include <utility>
namespace thunder {
template < typename T, typename A >
Storage< T, A >::Storage(const A &alloc)
: alloc_(alloc), size_(0), data_(nullptr) {}
template < typename T, typename A >
Storage< T, A >::Storage(size_type count, const A &alloc)
: alloc_(alloc), size_(count),
data_(size_ == 0 ? nullptr : alloc_.allocate(size_)) {}
template < typename T, typename A >
Storage< T, A >::Storage(size_type count, const_reference value, const A &alloc)
: alloc_(alloc), size_(count),
data_(size_ == 0 ? nullptr : alloc_.allocate(size_)) {
for (size_type i = 0; i < size_; ++i) {
data_[i] = value;
}
}
template < typename T, typename A >
Storage< T, A >::Storage(const Storage &other)
: alloc_(other.alloc_), size_(other.size_),
data_(size_ == 0 ? nullptr : alloc_.allocate(size_)) {
for (size_type i = 0; i < size_; ++i) {
data_[i] = other.data_[i];
}
}
template < typename T, typename A >
Storage< T, A >::Storage(Storage &&other)
: alloc_(::std::move(other.alloc_)), size_(::std::move(other.size_)),
data_(other.data_) {
other.data_ = nullptr;
}
template < typename T, typename A >
Storage< T, A >::Storage(::std::initializer_list< T > init, const A& alloc)
:alloc_(alloc), size_(init.size()),
data_(size_ == 0 ? nullptr : alloc_.allocate(size_)) {
size_t i = 0;
for (const T& value : init) {
data_[i++] = value;
}
}
template < typename T, typename A >
Storage< T, A >::~Storage() {
if (data_ != nullptr) {
alloc_.deallocate(data_, size_);
}
}
template < typename T, typename A >
Storage< T, A > &Storage< T, A >::operator=(Storage< T, A > other) {
std::swap(size_, other.size_);
std::swap(data_, other.data_);
std::swap(alloc_, other.alloc_);
return *this;
}
template < typename T, typename A >
typename Storage< T, A >::reference Storage< T, A >::operator[](size_type pos) {
return data_[pos];
}
template < typename T, typename A >
typename Storage< T, A >::const_reference Storage< T, A >::operator[](
size_type pos) const {
return data_[pos];
}
template < typename T, typename A >
typename Storage< T, A >::pointer Storage< T, A >::Data() {
return data_;
}
template < typename T, typename A >
typename Storage< T, A >::const_pointer Storage< T, A >::Data() const {
return data_;
}
template < typename T, typename A >
typename Storage< T, A >::iterator Storage< T, A >::begin() {
return data_;
}
template < typename T, typename A >
typename Storage< T, A >::const_iterator Storage< T, A >::begin() const {
return data_;
}
template < typename T, typename A >
typename Storage< T, A >::iterator Storage< T, A >::end() {
return data_ + size_;
}
template < typename T, typename A >
typename Storage< T, A >::const_iterator Storage< T, A >::end() const {
return data_ + size_;
}
template < typename T, typename A >
template < typename Other_T, typename Other_A >
void Storage< T, A >::Copy(const Storage< Other_T, Other_A > &other) {
if (this != reinterpret_cast<const Storage*> (&other)) {
Resize(static_cast<size_type>(other.Size()));
for (size_type i = 0; i < size_; ++i) {
data_[i] = static_cast<T> (
other[static_cast<
typename Storage< Other_T, Other_A >::size_type >(i)]);
}
}
}
template < typename T, typename A >
void Storage< T, A >::Resize(size_type count) {
if (size_ != count) {
if (data_ != nullptr) {
alloc_.deallocate(data_, size_);
}
pointer data = nullptr;
if (count > 0) {
data = alloc_.allocate(count);
}
size_ = count;
data_ = data;
}
}
template < typename T, typename A >
void Storage< T, A >::Resize(size_type count, const_reference value) {
Resize(count);
for (size_type i = 0; i < size_; ++i) {
data_[i] = value;
}
}
template < typename T, typename A >
typename Storage< T, A >::size_type Storage< T, A >::Size() const {
return size_;
}
} // namespace thunder
#endif // THUNDER_STORAGE_STORAGE_INL_HPP
|
5b04bb12dceb8932a9abbb9d3d030ff8fcd178b0
|
145caa22a58e0cb156daa2834fbf945c3597fba1
|
/Release_3 -versio݁n moodle/ConsoleApplication/Game.h
|
bf664174b88492e5f6868bb22e7ecc2575cfac1e
|
[] |
no_license
|
LouGPombo/Snake19
|
aef16d1fbfe0409625273dfd69de631725d00688
|
3ead666df5e543154214f657e5b060d377f56162
|
refs/heads/master
| 2020-05-23T07:50:33.626702
| 2017-02-27T10:22:16
| 2017-02-27T10:22:16
| 80,451,557
| 0
| 0
| null | null | null | null |
WINDOWS-1250
|
C++
| false
| false
| 2,450
|
h
|
Game.h
|
#pragma once
//Third-party libraries
#define GLM_FORCE_RADIANS
#include <glm/glm.hpp> //OpenGL Mathematics
#include <iostream>
#include <time.h>
#include "GameConstants.h"
#include "SDLInterface.h"
#include "InputManager.h"
#include "Sprite.h"
#include "Cell.h"
#include "Map.h"
#include "bar.h"
#include <iostream>
#include <time.h>
#include <rapidxml.hpp>
#include <rapidxml_iterators.hpp>
#include <rapidxml_print.hpp>
#include <rapidxml_utils.hpp>
#include "Score.h"
using namespace rapidxml;
using namespace std;
/*
* Maneja la ejecución del juego
*/
class Game {
public:
Game(std::string windowTitle, int screenWidth, int screenHeight); //Constructor
~Game(); //Destructor
void run();
//Game execution
private:
//Attributes
string playerName;
bool writeRanking1, writeRanking2, writeRakning3;
int result1, result2, result3;
bool activa;
bool writeName;
bool easy, medium, hard;
bool pause = false;
std::string _windowTitle; //SDLInterface Title
int _screenWidth; //Screen width in pixels
int _screenHeight; //Screen height in pixels
GameState _gameState; //It describes the game state
SDLInterface _graphic; //Manage the SDL graphic library
Sprite hero;
Sprite hello;
Snake snake;
Map _map;
int _level;
movement _nextMovement;
//Internal methods for the game execution
void init();
void gameLoop();
void executePlayerCommands();
void executeMenuCommands();
void executeGameMenuCommands();
void controlTime();
void chooseRanking();
void renderGame();
void drawMenu();
void drawGameMenu();
void drawGame();
void drawRanking();
void readEasyXML();
void readMediumXML();
void readHardXML();
void gameOver();
void drawSprite(Sprite & e);
void createRankingFile(char filename[100]);
void setNameFile();
string getNameFile();
void fileBusinessEndGame();
void quickSortScore(Score arr[], int left, int right);
void quickSort(int arr[], int left, int right);
//time:
float timer = 0; //Tiempo en segundos del nivel
float crono = 0; // se le resta al tiempo del nivel el valor de timer para dar el valor del crono
float snakeTimer;
float snakeCrono;
float snakeSpeed =0.5;
int snakeSize = 0;
int minutes = 0; //Conversion en minutos
int seconds = 0; //Conversion en segundos
bool timeOne = false, timeTwo = false, timeThree = false;
};
|
0cb7c23608d633da7a8d7c7e343290f5181c5dee
|
e9dcb76959047aea9c03e29a8d276f257967c4f2
|
/trunk/project_cpp/src/openssl/skp_AES.cpp
|
4ae8506498cda4eeb2df13244b1d5f6e2ef21b75
|
[] |
no_license
|
yefy/cpp_study
|
bfab5e8e2944afc6f8b9c9f327761825e9cbe9f8
|
8213e5f4d076bfc9580594feaff0689490662be8
|
refs/heads/master
| 2020-03-20T23:25:58.023147
| 2018-11-10T14:02:08
| 2018-11-10T14:02:08
| 137,846,030
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,314
|
cpp
|
skp_AES.cpp
|
#include "skp_AES.h"
#include "openssl/aes.h"
#include "gtest/gtest.h"
#include "src/skp_common.h"
#include "src/skp_log.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
SKP_TEST(openssl, opensll_AES1)
{
AES_KEY aes;
unsigned char key[AES_BLOCK_SIZE]; // AES_BLOCK_SIZE = 16
unsigned char iv[AES_BLOCK_SIZE]; // init vector
unsigned char* input_string;
unsigned char* encrypt_string;
unsigned char* decrypt_string;
unsigned int len; // encrypt length (in multiple of AES_BLOCK_SIZE)
unsigned int i;
int argc = 2;
char *argv[] = {"opensll_AES1", "123456133232331321321321321321312321321321321312312321321321312321321321312"
"31312321321321321321"
"3213123213213213213123"
"21321312312312331313123"};
// check usage
if (argc != 2) {
fprintf(stderr, "%s <plain text>\n", argv[0]);
exit(-1);
}
// set the encryption length
len = 0;
if ((strlen(argv[1]) + 1) % AES_BLOCK_SIZE == 0) {
len = strlen(argv[1]) + 1;
} else {
len = ((strlen(argv[1]) + 1) / AES_BLOCK_SIZE + 1) * AES_BLOCK_SIZE;
}
// set the input string
input_string = (unsigned char*)calloc(len, sizeof(unsigned char));
if (input_string == NULL) {
fprintf(stderr, "Unable to allocate memory for input_string\n");
exit(-1);
}
strncpy((char*)input_string, argv[1], strlen(argv[1]));
// Generate AES 128-bit key
for (i=0; i<16; ++i) {
key[i] = 32 + i;
}
// Set encryption key
for (i=0; i<AES_BLOCK_SIZE; ++i) {
iv[i] = 0;
}
if (AES_set_encrypt_key(key, 128, &aes) < 0) {
fprintf(stderr, "Unable to set encryption key in AES\n");
exit(-1);
}
// alloc encrypt_string
encrypt_string = (unsigned char*)calloc(len, sizeof(unsigned char));
if (encrypt_string == NULL) {
fprintf(stderr, "Unable to allocate memory for encrypt_string\n");
exit(-1);
}
// encrypt (iv will change)
AES_cbc_encrypt(input_string, encrypt_string, len, &aes, iv, AES_ENCRYPT);
// alloc decrypt_string
decrypt_string = (unsigned char*)calloc(len, sizeof(unsigned char));
if (decrypt_string == NULL) {
fprintf(stderr, "Unable to allocate memory for decrypt_string\n");
exit(-1);
}
// Set decryption key
for (i=0; i<AES_BLOCK_SIZE; ++i) {
iv[i] = 0;
}
if (AES_set_decrypt_key(key, 128, &aes) < 0) {
fprintf(stderr, "Unable to set decryption key in AES\n");
exit(-1);
}
// decrypt
AES_cbc_encrypt(encrypt_string, decrypt_string, len, &aes, iv,
AES_DECRYPT);
// print
printf("input_string = \n%s\n", input_string);
printf("encrypted string = ");
for (i=0; i<len; ++i) {
printf("%x%x", (encrypt_string[i] >> 4) & 0xf,
encrypt_string[i] & 0xf);
}
printf("\n");
printf("decrypted string = \n%s\n", decrypt_string);
ASSERT_STREQ((char *)input_string, (char *)decrypt_string);
}
SKP_TEST(openssl, opensll_AES2)
{
char *data = "123456";
printf("原始数据:\n%s\n",data);
int length = ((strlen(data)+AES_BLOCK_SIZE-1)/AES_BLOCK_SIZE)*AES_BLOCK_SIZE; //对齐分组
unsigned char userkey[AES_BLOCK_SIZE];
unsigned char *encrypt_result = (unsigned char *)malloc(length);
unsigned char *decrypt_result = (unsigned char *)malloc(length);
AES_KEY en_key;
AES_KEY de_key;
memset((void*)userkey,'k',AES_BLOCK_SIZE);
memset((void*)encrypt_result, 0, length);
memset((void*)decrypt_result, 0, length);
AES_set_encrypt_key(userkey, AES_BLOCK_SIZE*8, &en_key);
int len = 0;
/*循环加密,每次只能加密AES_BLOCK_SIZE长度的数据*/
while(len < length) {
AES_encrypt((unsigned char *)data+len, encrypt_result+len, &en_key);
len += AES_BLOCK_SIZE;
}
printf("AES_encrypt : \n%s\n",encrypt_result);
AES_set_decrypt_key(userkey, AES_BLOCK_SIZE*8, &de_key);
len = 0;
/*循环解密*/
while(len < length) {
AES_decrypt(encrypt_result+len, decrypt_result+len, &de_key);
len += AES_BLOCK_SIZE;
}
printf("AES_decrypt : \n%s\n",decrypt_result);
}
|
c51c9e3c78c91230ab4c39cffb0f5ee31cbd22c4
|
c990ba64b77b7b4034772fb15a5520a28f1ea5e7
|
/copasi/UI/CQTextDialog.cpp
|
a6561c3a9f00caafa2aa38a43270c556bde56b46
|
[
"LicenseRef-scancode-other-copyleft",
"Artistic-2.0",
"LicenseRef-scancode-proprietary-license"
] |
permissive
|
copasi/COPASI
|
a3fb515b4d9c667519ad756c52d8b82747a26e64
|
3ddf61e95191f2db09256dddc013f12041719a2c
|
refs/heads/develop
| 2023-09-01T19:32:39.004552
| 2023-06-02T15:01:23
| 2023-06-02T15:01:23
| 4,810,881
| 75
| 34
|
Artistic-2.0
| 2022-09-14T13:13:20
| 2012-06-27T16:35:48
|
Component Pascal
|
UTF-8
|
C++
| false
| false
| 1,336
|
cpp
|
CQTextDialog.cpp
|
// Copyright (C) 2010 - 2016 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.
// Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., EML Research, gGmbH, University of Heidelberg,
// and The University of Manchester.
// All rights reserved.
// Copyright (C) 2005 - 2007 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc. and EML Research, gGmbH.
// All rights reserved.
#include "CQTextDialog.h"
#include <QtCore/QVariant>
/*
* Constructs a CQTextDialog as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* true to construct a modal dialog.
*/
CQTextDialog::CQTextDialog(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, fl)
{
setObjectName(QString::fromUtf8(name));
setModal(modal);
setupUi(this);
}
/*
* Destroys the object and frees any allocated resources
*/
CQTextDialog::~CQTextDialog()
{
// no need to delete child widgets, Qt does it all for us
}
void CQTextDialog::setText(const QString & text)
{
mpTextEdit->setPlainText(text);
}
QString CQTextDialog::getText() const
{
return mpTextEdit->toPlainText();
}
|
8bdb5c3b0b2707d59d21993f51e827bfbe3eaf75
|
0c223a66cadf2d4488a6678a8f5578c39990aaec
|
/CF:543:A/b.cpp
|
7cb4ef98a0a14fe728ee5e146f88799a52c60ae9
|
[] |
no_license
|
prajogotio/upsolving
|
b71a1803b372960eec65c6effef2934065d36786
|
51078bf1118acd97af75683a53104bd59311686c
|
refs/heads/master
| 2021-01-10T01:00:18.757460
| 2015-07-21T18:48:02
| 2015-07-21T18:48:02
| 28,124,346
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 776
|
cpp
|
b.cpp
|
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
long long dp[2][510][510];
int n, m, b;
long long mod;
int a[510];
int main(){
cin >> n >> m >> b >> mod;
for(int i=1;i<=n;++i) scanf("%d",&a[i]);
dp[1][m][0] = 1;
for(int i=1;i<=n;++i){
int cur = i % 2;
int next = (i+1) % 2;
for(int t=0;t<=m;++t){
for(int k=0;k<=b;++k){
dp[next][t][k] = 0;
}
}
for(int t=m;t>=0;--t){
for(int k=0;k<=b;++k){
dp[next][t][k] += dp[cur][t][k];
dp[next][t][k] %= mod;
if(t>0 && k+a[i]<=b) {
dp[cur][t-1][k+a[i]] += dp[cur][t][k];
dp[cur][t-1][k+a[i]] %= mod;
}
}
}
}
long long ans = 0;
for(int i=0;i<=b;++i){
ans += dp[n%2][0][i];
ans %= mod;
}
cout << ans << endl;
return 0;
}
|
92e614d0ca92fada0c52008fd416303dc8a9a357
|
579dcdaaa1da36ebfb535a96ad75d7aad288814f
|
/WmgjTrainer/WmgjLibrary/ParamMgr.h
|
292c27ab909f49e8523b4dbaae5920ecb2a763b7
|
[
"BSD-3-Clause"
] |
permissive
|
fengjixuchui/WmgjTrainer
|
49c1aeb677fe14f4dbd0905b1e728e4b676281b3
|
cf9226dc99b3c477863daa05e64a4d751b50e0b9
|
refs/heads/master
| 2023-04-29T01:37:53.504353
| 2023-04-09T08:59:04
| 2023-04-09T08:59:04
| 220,045,194
| 0
| 0
|
BSD-3-Clause
| 2023-04-09T08:59:05
| 2019-11-06T16:47:23
|
C++
|
UTF-8
|
C++
| false
| false
| 215
|
h
|
ParamMgr.h
|
#pragma once
class ParamMgr
{
private:
static ParamMgr* paramMgr;
public:
AttackSkills attackSkills;
AttackMonsters attackMonsters;
private:
~ParamMgr();
public:
static ParamMgr* getParamMgrInstance();
};
|
4d88e865a33bde75ace75bffe13e014ac4a07f23
|
52459805f5891545bd40c5ad62851351b1dcb2d5
|
/trunk/zhSipStackDlg.cpp
|
3918baca2efcaff5aa8acf1aa48d78b68ac4013b
|
[] |
no_license
|
BGCX261/zhsipstack-svn-to-git
|
552344a3b56a41e4e009842dbeb7a435481c332f
|
d5b995a388424b569266ae2ee04aa8944a7748e0
|
refs/heads/master
| 2021-01-13T14:28:14.486313
| 2015-08-25T15:29:59
| 2015-08-25T15:29:59
| 41,486,320
| 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 7,596
|
cpp
|
zhSipStackDlg.cpp
|
// zhSipStackDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ThreadNet.h"
#include "zhSipStack.h"
#include "zhSipStackDlg.h"
#include "UserAgent.h"
#include "WwwAuthenticate.h"
#include "Phone.h"
#include "SipTransactionManager.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CZhSipStackDlg dialog
CZhSipStackDlg::CZhSipStackDlg(CWnd* pParent /*=NULL*/)
: CDialog(CZhSipStackDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CZhSipStackDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CZhSipStackDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CZhSipStackDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CZhSipStackDlg, CDialog)
//{{AFX_MSG_MAP(CZhSipStackDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON_PARSEINVITE, OnButtonParseinvite)
ON_BN_CLICKED(IDC_BUTTON_PARSESDP, OnButtonParsesdp)
ON_BN_CLICKED(IDC_BUTTON1, OnRegister)
ON_BN_CLICKED(IDC_BUTTON_INVITE, OnButtonInvite)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CZhSipStackDlg message handlers
BOOL CZhSipStackDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
char *pcProxyIp = "192.168.1.112";
int iProxyPort = 5060;
int iLocalPort = 5067;
char *pcLocalIp = CZhSocket::GetLocalIp();
m_Phone.SetListenAddr(AF_INET,SOCK_DGRAM,iLocalPort,pcLocalIp,0);
m_Phone.SetPhoneIdentity("7777","7777","7777");
m_Phone.SetProxyServer(pcProxyIp,iProxyPort);
return TRUE; // return TRUE unless you set the focus to a control
}
void CZhSipStackDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CZhSipStackDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CZhSipStackDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
int splitString(const char *str, char *split, CStringArray& strArray)
{
if (str == NULL)
{
return -1;
}
strArray.RemoveAll();
CString strTemp = str; //此赋值不能少
int nIndex = 0; //
while( 1 )
{
//多字节和单字节查找问题。
#if 0
char *pcStrTemp = strTemp.GetBuffer(strTemp.GetLength());
char *pcPos = strchr(pcStrTemp, split);
if (NULL != pcPos)
{
nIndex = pcPos - pcStrTemp;
}
else
{
nIndex = -1;
}
strTemp.ReleaseBuffer();
#else
nIndex = strTemp.Find( split,0 );
#endif
if( nIndex >= 0 )
{
strArray.Add( strTemp.Left( nIndex ) );
strTemp = strTemp.Right( strTemp.GetLength() - nIndex - 1 );
}
else break;
}
strArray.Add( strTemp );
return strArray.GetSize();
}
void CZhSipStackDlg::OnButtonParseinvite()
{
// TODO: Add your control notification handler code here
CWwwAuthenticate al;
al.Init();
FILE *pFile = fopen("e:\\myinvite.txt","rb");
if (pFile != NULL)
{
char buff[2048];
memset(buff,0,2048);
int iLen = 0;
iLen = fread(buff,1,2048,pFile);
if (iLen <= 0)
{
return;
}
// CThreadNet *pNet = CThreadNet::getInstance();
// pNet->ParseMessage(buff,iLen);
CSipMessage *sip;
CSipMessageParse parse;
parse.Parse(&sip,buff,iLen);
CSipMessage *dest;
sip->Clone(&dest);
CUac uac;
uac.Invite("sip:3200@192.168.1.3","sip:5550@192.168.1.5",NULL,"hello sip");
char *message;
unsigned int iLenMessage = 0;
sip->ToStr(&message,&iLenMessage);
{
FILE *pFile = fopen("e:\\myinvite.txt","wb");
if (pFile != NULL)
{
fwrite(message,1,strlen(message),pFile);
fclose(pFile);
}
}
CStringArray arr;
splitString(buff,"/r/n",arr);
char *bb = strchr(buff,'\n');
// CString strHead = arr.GetAt(0);
// CString strBody = arr.GetAt(1);
string sssss = buff;
int iindex = sssss.find("\r");
}
}
void CZhSipStackDlg::OnButtonParsesdp()
{
// TODO: Add your control notification handler code here
FILE *pFile = fopen("e:\\sdp.txt","rb");
if (pFile != NULL)
{
char buff[2048];
memset(buff,0,2048);
int iLen = 0;
iLen = fread(buff,1,2048,pFile);
if (iLen <= 0)
{
return;
}
// CThreadNet *pNet = CThreadNet::getInstance();
// pNet->ParseMessage(buff,iLen);
CSdpMessage sdp;
sdp.Parse(buff);
}
CPhone phone;
phone.SetListenAddr(AF_INET,SOCK_DGRAM,5060,NULL,1);
}
void CZhSipStackDlg::OnRegister()
{
// TODO: Add your control notification handler code here
m_Phone.Register();
}
void CZhSipStackDlg::OnButtonInvite()
{
// TODO: Add your control notification handler code here
m_Phone.Invite("sip:4567@192.168.1.112");
}
|
e566561404b2eeb721f127be08cffab71cbe091b
|
7ee5265bd83df4018c27e5fb3082f3ed890a1335
|
/sarl3/sarl_lattice_view_gtk.cpp
|
0094d687101cf675732dc24bd688658eabeaf796
|
[] |
no_license
|
richcole/Griff
|
878a8afd4585b2dc6e577502c6dece2e2d90a2d1
|
7c609b2c815171a92c9e248080fe3b6a1642e432
|
refs/heads/master
| 2016-09-11T02:17:17.001127
| 2010-02-06T21:29:36
| 2010-02-06T21:29:36
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 39,537
|
cpp
|
sarl_lattice_view_gtk.cpp
|
#include "sarl_lattice_view_gtk.h"
#include "sarl_diagram.h"
#include "sarl_lattice.h"
#include "sarl_bit_set.h"
#include "sarl_power_map.h"
#include "sarl_string_table.h"
#include "sarl_lattice_view_gtk_marshaller.h"
#include "sarl_label.h"
#include "sarl_lattice_view_gtk_privates.h"
#include "sarl_lattice_view_macros.h"
#include <gtk/gtksignal.h>
// ----------------------------------------------------------------------
// TODO List
//
// 1. Seperate out the style stuff into a style class, follow the Gnome
// standard for widget styles, if there is one that can be adopted.
//
// 2. Add object and attribute clarrification options
//
// 3. Add an option to display object and attribute instead of
// just listing the objects and attributes
//
// 4. Modify the label code to support vertical scrollbars. See if the
// gtk code supports drawing of the scrollbar. Try to adopt this.
// Alternatively could try using the code that draws list boxes, but this
// is likely to be too heavy weight.
//
// 5. Look into making labels GObjects. What is the advantage of this?
// ----------------------------------------------------------------------
// Internationalization
//
#ifdef ENABLE_NLS
#warning "What does this do?"
#define P_(String) dgettext(GETTEXT_PACKAGE "-properties",String)
#else
#define P_(String) (String)
#endif
// ----------------------------------------------------------------------
// Signals
//
enum {
SARL_LATTICE_VIEW_SELECT_CONCEPT_SIGNAL,
SARL_LATTICE_VIEW_SELECT_ATTRIBUTE_SIGNAL,
SARL_LATTICE_VIEW_SELECT_OBJECT_SIGNAL,
SARL_LATTICE_VIEW_ACTIVATE_CONCEPT_SIGNAL,
SARL_LATTICE_VIEW_ACTIVATE_OBJECT_SIGNAL,
SARL_LATTICE_VIEW_ACTIVATE_ATTRIBUTE_SIGNAL,
LAST_SIGNAL
};
enum {
PROP_SLV_DUMMY_START = 0,
PROP_SLV_FONT_SIZE,
PROP_SLV_FONT_DESC,
PROP_SLV_FONT_NAME,
PROP_SLV_CONCEPT_RADIUS,
PROP_SLV_CONCEPT_LINE_WIDTH,
PROP_SLV_LABEL_LINE_WIDTH,
PROP_SLV_SELECTED_CONCEPT,
PROP_SLV_SELECTED_OBJECT,
PROP_SLV_SELECTED_ATTRIBUTE,
PROP_SLV_SHOW_ATTRIBUTES,
PROP_SLV_SHOW_OBJECTS,
PROP_SLV_DUMMY_END
};
static guint sarl_lattice_view_signals[LAST_SIGNAL] = { 0 };
// ----------------------------------------------------------------------
// Proto
//
static void sarl_lattice_view_class_init(SarlLatticeViewClass *klass);
static void sarl_lattice_view_init(SarlLatticeView *view);
static sarl_unsigned_int
sarl_lattice_view_label_at(
SarlLatticeView *view, sarl_signed_int x, sarl_signed_int y);
static void
sarl_lattice_view_recalc_bbox(SarlLatticeView *view);
static void
sarl_lattice_view_recalc_transform(SarlLatticeView *view);
static void
sarl_lattice_view_recalc_labels(SarlLatticeView *view);
static void
sarl_lattice_view_recalc_font_size(SarlLatticeView *view);
static void
sarl_lattice_view_rescale_labels(SarlLatticeView *view);
static gboolean
sarl_lattice_view_expose_event_callback(
GtkWidget *widget, GdkEventExpose *event, gpointer data);
static gboolean
sarl_lattice_view_configure_event_callback(
GtkWidget *widget, GdkEventConfigure *event, gpointer data);
static gboolean
sarl_lattice_view_motion_event_callback(
GtkWidget *widget, GdkEventMotion *event, gpointer data);
static gboolean
sarl_lattice_view_button_release_event_callback(
GtkWidget *widget, GdkEventButton *event, gpointer data);
static gboolean
sarl_lattice_view_button_press_event_callback(
GtkWidget *widget, GdkEventButton *event, gpointer data);
static void
sarl_lattice_view_destroy(GtkObject *view);
static void
sarl_lattice_view_size_request(GtkWidget *widget, GtkRequisition *req);
// ----------------------------------------------------------------------
// Class Decl
//
G_DEFINE_TYPE(SarlLatticeView, sarl_lattice_view, GTK_TYPE_DRAWING_AREA);
static void
sarl_lattice_view_set_font_description(
SarlLatticeView *view, PangoFontDescription* fd
)
{
if ( view->p->fd ) {
pango_font_description_free(view->p->fd);
}
view->p->fd = fd;
g_object_notify(G_OBJECT(view), "font-description");
};
static void sarl_lattice_view_set_property(
GObject *gobj, guint prop_id, const GValue *value, GParamSpec *spec
)
{
SarlLatticeView *view = SARL_LATTICE_VIEW(gobj);
PangoFontDescription *fd;
switch(prop_id) {
case PROP_SLV_FONT_DESC:
fd = (PangoFontDescription *)g_value_get_boxed (value);
fd = pango_font_description_copy(fd);
sarl_lattice_view_set_font_description(view, fd);
break;
case PROP_SLV_FONT_NAME:
fd = pango_font_description_from_string(g_value_get_string(value));
sarl_lattice_view_set_font_description(view, fd);
break;
case PROP_SLV_FONT_SIZE:
sarl_lattice_view_set_font_size(view, g_value_get_uint(value));
break;
case PROP_SLV_SHOW_ATTRIBUTES:
sarl_lattice_view_set_show_attributes(view, g_value_get_boolean(value));
break;
case PROP_SLV_SHOW_OBJECTS:
sarl_lattice_view_set_show_objects(view, g_value_get_boolean(value));
break;
case PROP_SLV_CONCEPT_RADIUS:
view->p->concept_radius = g_value_get_uint(value);
sarl_lattice_view_update(view);
break;
case PROP_SLV_CONCEPT_LINE_WIDTH:
view->p->line_width = g_value_get_uint(value);
sarl_lattice_view_update(view);
break;
case PROP_SLV_LABEL_LINE_WIDTH:
view->p->label_line_width = g_value_get_uint(value);
sarl_lattice_view_update(view);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobj, prop_id, spec);
};
};
static void sarl_lattice_view_get_property(
GObject *gobj, guint prop_id, GValue *value, GParamSpec *spec
)
{
SarlLatticeView *view = SARL_LATTICE_VIEW(gobj);
g_object_freeze_notify(G_OBJECT(gobj));
switch(prop_id) {
case PROP_SLV_FONT_NAME:
g_value_set_string(value, "unknown");
break;
case PROP_SLV_FONT_DESC:
g_value_set_boxed(value, view->p->fd);
break;
case PROP_SLV_FONT_SIZE:
g_value_set_uint(value, view->p->font_size);
break;
case PROP_SLV_SHOW_ATTRIBUTES:
g_value_set_boolean(value, view->p->show_attributes);
break;
case PROP_SLV_SHOW_OBJECTS:
g_value_set_boolean(value, view->p->show_objects);
break;
case PROP_SLV_CONCEPT_RADIUS:
g_value_set_uint(value, view->p->concept_radius);
break;
case PROP_SLV_CONCEPT_LINE_WIDTH:
g_value_set_uint(value, view->p->line_width);
break;
case PROP_SLV_LABEL_LINE_WIDTH:
g_value_set_uint(value, view->p->label_line_width);
break;
case PROP_SLV_SELECTED_CONCEPT:
g_value_set_uint(value, view->selected_concept);
break;
case PROP_SLV_SELECTED_ATTRIBUTE:
g_value_set_uint(value, view->selected_attribute);
break;
case PROP_SLV_SELECTED_OBJECT:
g_value_set_uint(value, view->selected_object);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobj, prop_id, spec);
};
g_object_thaw_notify(G_OBJECT(gobj));
};
static void
sarl_lattice_view_init (SarlLatticeView *view)
{
view->p = (SarlLatticeViewPriv *)
GC_MALLOC_UNCOLLECTABLE(sizeof(SarlLatticeViewPriv));
view->p->diagram = 0;
view->p->lattice_map = 0;
view->p->labels = sarl_array_default_new();
view->p->interps = sarl_array_default_new();
view->p->st_objects = 0;
view->p->st_attributes = 0;
view->p->scale = 1;
view->p->line_width = 50;
view->p->label_line_width = 10;
view->p->concept_radius = 150;
view->p->font_size = 120;
view->p->fd = 0;
view->p->show_attributes = 1;
view->p->show_objects = 1;
view->selected_concept = 0;
view->selected_label = 0;
view->selected_layout_index = 0;
view->selected_object = 0;
view->selected_attribute = 0;
view->hover_label = 0;
view->hover_concept = 0;
view->dragged_concept = 0;
view->dragged_label = 0;
gdk_color_set(view->line_good_color, 0, 0, 0, 0);
gdk_color_set(view->line_bad_color, 0, 0xffff, 0, 0);
gdk_color_set(view->concept_color, 0, 0, 0, 0);
gdk_color_set(view->bg_color, 0, 0xffff, 0xffff, 0xffff);
gtk_widget_modify_bg(GTK_WIDGET(view), GTK_STATE_NORMAL, &view->bg_color);
}
// ----------------------------------------------------------------------
// Class Methods
//
GtkWidget*
sarl_lattice_view_new(
sarl_diagram_t *diagram,
sarl_string_table_t* st_objects,
sarl_string_table_t* st_attributes)
{
SarlLatticeView *view = (SarlLatticeView *)
g_object_new (SARL_LATTICE_VIEW_TYPE, 0);
view->p->st_objects = st_objects;
view->p->st_attributes = st_attributes;
view->p->diagram = diagram;
sarl_lattice_view_recalc_bbox(view);
sarl_lattice_view_recalc_labels(view);
sarl_lattice_view_recalc_font_size(view);
sarl_lattice_view_rescale_labels(view);
sarl_lattice_view_truncate_labels(view);
sarl_lattice_view_center_labels(view);
GtkWidget *widget = GTK_WIDGET(view);
view->p->fd = pango_font_description_from_string("Sans 12");
g_signal_connect(G_OBJECT(view), "expose_event",
G_CALLBACK (sarl_lattice_view_expose_event_callback), 0);
g_signal_connect(G_OBJECT(view), "configure_event",
G_CALLBACK (sarl_lattice_view_configure_event_callback), 0);
g_signal_connect(G_OBJECT(view), "motion_notify_event",
G_CALLBACK (sarl_lattice_view_motion_event_callback), 0);
g_signal_connect(GTK_OBJECT(view), "button_press_event",
G_CALLBACK (sarl_lattice_view_button_press_event_callback), 0);
g_signal_connect(GTK_OBJECT(view), "button_release_event",
G_CALLBACK (sarl_lattice_view_button_release_event_callback), 0);
gtk_widget_set_events(GTK_WIDGET(view),
GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK | GDK_BUTTON1_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK
);
return widget;
}
void sarl_lattice_view_destroy(GtkObject *object)
{
SarlLatticeView *view = SARL_LATTICE_VIEW(object);
// FIXME: find some way to call the parent class destroy method
view->selected_concept = 0;
view->selected_label = 0;
view->selected_layout_index = 0;
view->selected_object = 0;
view->selected_attribute = 0;
view->hover_label = 0;
view->hover_concept = 0;
view->dragged_concept = 0;
view->dragged_label = 0;
if ( view->p && view->p->fd ) {
pango_font_description_free(view->p->fd);
view->p->fd = 0;
}
if ( view->p ) {
GC_FREE(view->p);
view->p = 0;
}
};
void sarl_lattice_view_dispose_labels(sarl_array_t *labels)
{
sarl_label_t* label = 0;
SARL_ARRAY_FOR_EACH(sarl_label_t, label, labels);
sarl_label_dispose(label);
SARL_ARRAY_END;
sarl_array_clear(labels);
};
void sarl_lattice_view_recalc_labels_for(
SarlLatticeView *view, SarlLabelKind kind,
sarl_power_map_t* cont_map, sarl_string_table_t* st,
sarl_signed_int ox, sarl_signed_int oy)
{
sarl_label_t* label;
sarl_bit_set_t* cont;
sarl_point_t* p;
sarl_unsigned_int ob;
sarl_unsigned_int index;
GtkWidget *widget = GTK_WIDGET(view);
SARL_POWER_MAP_FOR_EACH(index, cont, cont_map);
if ( sarl_bit_set_count(cont) > 0 ) {
p = sarl_diagram_get_concept_pos(view->p->diagram, index);
label = sarl_label_new(index, kind, ox, oy);
sarl_array_push(view->p->labels, label);
SARL_BIT_SET_FOR_EACH(ob, cont);
sarl_array_push(label->layouts,
gtk_widget_create_pango_layout(widget,
sarl_string_table_get(st, ob)
));
label->before = gtk_widget_create_pango_layout(widget, "... %d before");
label->after = gtk_widget_create_pango_layout(widget, "... %d after");
SARL_BIT_SET_END;
}
SARL_POWER_MAP_END;
};
void sarl_lattice_view_recalc_labels(SarlLatticeView *view)
{
sarl_lattice_view_dispose_labels(view->p->labels);
if ( view->p->lattice_map == 0 ) {
sarl_lattice_view_recalc_labels_for(
view, SARL_LABEL_OBJECT_KIND,
view->p->diagram->lattice->concept_object_cont,
view->p->st_objects, 0, view->p->concept_radius
);
sarl_lattice_view_recalc_labels_for(
view, SARL_LABEL_ATTRIBUTE_KIND,
view->p->diagram->lattice->concept_attribute_cont,
view->p->st_attributes, 0, -view->p->concept_radius
);
}
else {
// need to document what happens when the lattice draws an embedding
sarl_not_implemented_error;
};
};
void
sarl_lattice_view_clear(SarlLatticeView *view)
{
sarl_lattice_view_dispose_labels(view->p->labels);
sarl_array_clear(view->p->interps);
view->p->diagram = 0;
view->p->st_objects = 0;
view->p->st_attributes = 0;
view->selected_concept = 0;
view->selected_label = 0;
view->selected_layout_index = 0;
view->selected_object = 0;
view->selected_attribute = 0;
view->hover_label = 0;
view->hover_concept = 0;
view->dragged_concept = 0;
view->dragged_label = 0;
}
void sarl_lattice_view_print_bbox(char *s, sarl_rect_t* bbox) {
fprintf(stderr, " %s: %d, %d -> %d, %d\n", s,
bbox->left, bbox->top, bbox->width, bbox->height);
};
void sarl_lattice_view_set_diagram(
SarlLatticeView *view, sarl_diagram_t *diagram,
sarl_string_table_t* objects, sarl_string_table_t *attributes)
{
sarl_lattice_view_clear(view);
view->p->diagram = diagram;
view->p->st_objects = objects;
view->p->st_attributes = attributes;
sarl_lattice_view_recalc_bbox(view);
sarl_lattice_view_recalc_transform(view);
sarl_lattice_view_recalc_labels(view);
sarl_lattice_view_recalc_font_size(view);
sarl_lattice_view_rescale_labels(view);
sarl_lattice_view_truncate_labels(view);
sarl_lattice_view_center_labels(view);
sarl_lattice_view_update(view);
};
void sarl_lattice_view_set_embedding(
SarlLatticeView *view, sarl_diagram_t *diagram,
sarl_string_table_t* objects, sarl_string_table_t *attributes,
sarl_lattice_map_t *lattice_map)
{
sarl_lattice_view_clear(view);
view->p->diagram = diagram;
view->p->st_objects = objects;
view->p->st_attributes = attributes;
view->p->lattice_map = lattice_map;
sarl_lattice_view_recalc_bbox(view);
sarl_lattice_view_recalc_transform(view);
sarl_lattice_view_recalc_labels(view);
sarl_lattice_view_recalc_font_size(view);
sarl_lattice_view_rescale_labels(view);
sarl_lattice_view_truncate_labels(view);
sarl_lattice_view_center_labels(view);
sarl_lattice_view_update(view);
};
void
sarl_lattice_view_recalc_transform(SarlLatticeView *view)
{
GtkWidget *widget = GTK_WIDGET(view);
/* calculate a transform to contain the items */
double box_width = view->p->bbox.width;
double box_height = view->p->bbox.height;
double widget_width = widget->allocation.width;
double widget_height = widget->allocation.height;
if ( widget_width <= 1 && widget_height <= 1 ) {
// avoid the case then the allocation is too small
widget_width = 500;
widget_height = 500;
}
double sx = widget_width / box_width;
double sy = widget_height / box_height;
view->p->scale = 0.8 * (sx < sy ? sx : sy);
view->p->offset.x = (int)(
(widget_width - (view->p->bbox.width * view->p->scale))/(2*view->p->scale) -
view->p->bbox.left);
view->p->offset.y = (int)(
(widget_height - (view->p->bbox.height * view->p->scale))/(2*view->p->scale) -
view->p->bbox.top);
}
void sarl_lattice_view_recalc_bbox(SarlLatticeView *view)
{
sarl_rect_t bbox;
sarl_unsigned_int concept_index;
sarl_rect_clear(&bbox);
sarl_unsigned_int is_first = 1;
SARL_LATTICE_FOR_EACH(concept_index, view->p->diagram->lattice);
sarl_point_t* concept_pos =
sarl_diagram_get_concept_pos(view->p->diagram, concept_index);
if ( is_first ) {
bbox.left = concept_pos->x;
bbox.top = concept_pos->y;
bbox.width = 0;
bbox.height = 0;
is_first = 0;
}
else {
sarl_rect_insert_point(&bbox, concept_pos);
}
SARL_LATTICE_END;
bbox.top -= view->p->concept_radius * 4;
bbox.height += view->p->concept_radius * 8;
view->p->bbox = bbox;
};
void sarl_lattice_view_draw_concepts(SarlLatticeView *view, GdkDrawable *dest, GdkGC *gc)
{
/* init for drawing */
int scaled_line_width = (int)(view->p->line_width * view->p->scale);
if ( scaled_line_width < 1 ) scaled_line_width = 1;
gdk_gc_set_line_attributes(
gc, scaled_line_width, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
gdk_gc_set_rgb_fg_color(gc, &view->concept_color);
/* draw the concepts */
sarl_unsigned_int concept_index;
SARL_LATTICE_FOR_EACH(concept_index, view->p->diagram->lattice);
sarl_point_t* concept_pos =
sarl_diagram_get_concept_pos(view->p->diagram, concept_index);
gdk_draw_arc(dest, gc, TRUE,
TR_X(concept_pos->x - view->p->concept_radius),
TR_Y(concept_pos->y - view->p->concept_radius),
(int)(view->p->concept_radius * 2 * view->p->scale),
(int)(view->p->concept_radius * 2 * view->p->scale),
0, 64*360
);
SARL_LATTICE_END;
};
void sarl_lattice_view_draw_lines(SarlLatticeView *view, GdkDrawable *dest, GdkGC *gc)
{
/* init for drawing */
int scaled_line_width = (int)(view->p->line_width * view->p->scale);
if ( scaled_line_width < 1 ) scaled_line_width = 1;
gdk_gc_set_line_attributes(
gc, scaled_line_width, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
/* draw the lines in the covering relation */
sarl_unsigned_int parent_index, child_index;
sarl_bit_set_t* children;
SARL_POWER_MAP_FOR_EACH(
parent_index, children, view->p->diagram->lattice->lower_covers
);
sarl_point_t* parent_pos =
sarl_diagram_get_concept_pos(view->p->diagram, parent_index);
SARL_BIT_SET_FOR_EACH(child_index, children);
sarl_point_t* child_pos =
sarl_diagram_get_concept_pos(view->p->diagram, child_index);
if ( TR_Y(child_pos->y) > TR_Y(parent_pos->y) ) {
gdk_gc_set_rgb_fg_color(gc, &view->line_good_color);
}
else {
gdk_gc_set_rgb_fg_color(gc, &view->line_bad_color);
}
gdk_draw_line(
dest, gc,
TR_X(child_pos->x), TR_Y(child_pos->y),
TR_X(parent_pos->x), TR_Y(parent_pos->y)
);
SARL_BIT_SET_END;
SARL_POWER_MAP_END;
};
void sarl_lattice_view_recalc_font_size(SarlLatticeView *view)
{
if ( view->p->fd == 0 ) {
view->p->fd = pango_font_description_from_string("Sans 12");
}
pango_font_description_set_size(view->p->fd,
(int)(PANGO_SCALE * view->p->font_size * view->p->scale));
};
void sarl_lattice_view_rescale_labels(SarlLatticeView *view)
{
if ( view->p->labels ) {
sarl_label_t *label = 0;
SARL_ARRAY_FOR_EACH(sarl_label_t, label, view->p->labels);
sarl_label_rescale(label, view->p->fd, view->p->font_size, view->p->scale);
SARL_ARRAY_END;
}
};
void sarl_lattice_view_draw_labels(
SarlLatticeView *view, GdkDrawable *dest, GdkGC *gc)
{
GtkWidget *widget = GTK_WIDGET(view);
sarl_label_t *label = 0;
sarl_bit_set_t *cont = 0;
sarl_power_map_t *cont_map = view->p->diagram->lattice->concept_object_cont;
sarl_point_t *p = 0;
sarl_unsigned_int label_index;
int do_draw = 1;
int scaled_line_width = (int)(view->p->label_line_width * view->p->scale);
if ( scaled_line_width < 1 ) scaled_line_width = 1;
gdk_gc_set_line_attributes(
gc, scaled_line_width, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
SARL_ARRAY_FOR_EACH_INDEX(label_index, sarl_label_t, label, view->p->labels);
cont = sarl_power_map_get(cont_map, label->concept);
p = sarl_diagram_get_concept_pos(view->p->diagram, label->concept);
switch (label->kind) {
case SARL_LABEL_OBJECT_KIND:
do_draw = view->p->show_objects;
if (label->bbox.top + (label->bbox.height/2) > 0) {
gdk_gc_set_rgb_fg_color(gc, &view->line_good_color);
}
else {
gdk_gc_set_rgb_fg_color(gc, &view->line_bad_color);
};
break;
case SARL_LABEL_ATTRIBUTE_KIND:
do_draw = view->p->show_attributes;
if (label->bbox.top + (label->bbox.height/2) < 0) {
gdk_gc_set_rgb_fg_color(gc, &view->line_good_color);
}
else {
gdk_gc_set_rgb_fg_color(gc, &view->line_bad_color);
};
break;
}
if ( do_draw ) {
gdk_draw_line(
dest, gc,
TR_X(p->x), TR_Y(p->y),
TR_X(p->x + label->bbox.left + (label->bbox.width/2)),
TR_Y(p->y + label->bbox.top + (label->bbox.height/2))
);
}
SARL_ARRAY_END;
SARL_ARRAY_FOR_EACH_INDEX(label_index, sarl_label_t, label, view->p->labels);
cont = sarl_power_map_get(cont_map, label->concept);
p = sarl_diagram_get_concept_pos(view->p->diagram, label->concept);
switch (label->kind) {
case SARL_LABEL_OBJECT_KIND:
do_draw = view->p->show_objects;
break;
case SARL_LABEL_ATTRIBUTE_KIND:
do_draw = view->p->show_attributes;
break;
}
if ( do_draw ) {
if ( label_index == view->hover_label ) {
sarl_label_draw_background_with_scrollbar(
view, dest, gc, label, p->x, p->y, &view->p->offset, view->p->scale
);
}
else {
sarl_label_draw_background(
view, dest, gc, label, p->x, p->y, &view->p->offset, view->p->scale
);
};
sarl_label_draw(
widget, dest, gc, label, p->x, p->y, &view->p->offset, view->p->scale
);
}
SARL_ARRAY_END;
};
static gboolean
sarl_lattice_view_expose_event_callback(
GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
SarlLatticeView *view = SARL_LATTICE_VIEW(widget);
/* setup the GC */
GdkDrawable *dest = GDK_DRAWABLE(widget->window);
GdkGC* gc = gdk_gc_new(dest);
gdk_gc_copy(gc, GET_FG_GC(widget));
sarl_lattice_view_draw_lines(view, dest, gc);
sarl_lattice_view_draw_concepts(view, dest, gc);
sarl_lattice_view_draw_labels(view, dest, gc);
g_object_unref(gc);
return FALSE;
};
static gboolean
sarl_lattice_view_configure_event_callback(
GtkWidget *widget, GdkEventConfigure *event, gpointer data)
{
SarlLatticeView* view = SARL_LATTICE_VIEW(widget);
sarl_lattice_view_recalc_transform(view);
sarl_lattice_view_recalc_font_size(view);
sarl_lattice_view_rescale_labels(view);
return TRUE;
};
static gboolean
sarl_lattice_view_motion_event_callback(
GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
SarlLatticeView *view = SARL_LATTICE_VIEW(widget);
int x = -1, y = -1, dx, dy;
GdkModifierType state;
guint gdk_button_mask =
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK;
if ( ! (event->state & gdk_button_mask) ) {
gdk_window_get_pointer(event->window, &x, &y, &state);
dx = x - view->prev_pt.x;
dy = y - view->prev_pt.y;
sarl_unsigned_int prev_hover_label = view->hover_label;
view->hover_label = sarl_lattice_view_label_at(view, ITR_X(x), ITR_Y(y));
if ( view->hover_label != prev_hover_label ) {
if ( prev_hover_label ) {
// FIXME: selected labels need to respect changes in the interp
sarl_label_set_active(
(sarl_label_t *)sarl_array_get(view->p->labels, prev_hover_label),
0
);
}
if ( view->hover_label ) {
// FIXME: selected labels need to respect changes in the interp
sarl_label_set_active(
(sarl_label_t *)sarl_array_get(view->p->labels, view->hover_label), 1);
}
sarl_lattice_view_update(view);
}
}
if ( (event->state & GDK_BUTTON1_MASK) && (view->dragged_concept) ) {
gdk_window_get_pointer(event->window, &x, &y, &state);
dx = x - view->prev_pt.x;
dy = y - view->prev_pt.y;
sarl_diagram_move_concept_by(
view->p->diagram, view->dragged_concept,
(int)(dx / view->p->scale), (int)(dy / view->p->scale)
);
view->prev_pt.y = y;
view->prev_pt.x = x;
sarl_lattice_view_update(view);
}
if ( (event->state & GDK_BUTTON1_MASK) && (view->dragged_label) ) {
gdk_window_get_pointer(event->window, &x, &y, &state);
dx = x - view->prev_pt.x;
dy = y - view->prev_pt.y;
// FIXME: selected labels need to respect changes in the interp
sarl_label_t* label =
(sarl_label_t*)sarl_array_get(view->p->labels, view->dragged_label);
sarl_point_t* p =
sarl_diagram_get_concept_pos(view->p->diagram, label->concept);
switch ( view->label_region ) {
case SARL_LABEL_REGION_CONTENTS:
sarl_label_move_by(
label, (int)(dx / view->p->scale), (int)(dy / view->p->scale));
break;
case SARL_LABEL_REGION_RESIZE:
sarl_label_resize_to(label, ITR_X(x) - p->x, ITR_Y(y) - p->y, view->p->font_size);
break;
default:
break;
}
view->prev_pt.y = y;
view->prev_pt.x = x;
sarl_lattice_view_update(view);
};
return TRUE;
};
void sarl_lattice_view_update(SarlLatticeView *view)
{
GtkWidget *widget = GTK_WIDGET(view);
gtk_widget_queue_draw_area(widget, 0, 0,
widget->allocation.width, widget->allocation.height
);
};
sarl_unsigned_int sarl_lattice_view_concept_at(
SarlLatticeView *view,
sarl_signed_int x,
sarl_signed_int y
)
{
sarl_unsigned_int index;
sarl_point_t* p;
for(index=view->p->diagram->lattice->num_concepts; index>0; --index) {
p = sarl_diagram_get_concept_pos(view->p->diagram, index);
if (
abs(p->x - x) < view->p->concept_radius &&
abs(p->y - y) < view->p->concept_radius
) {
return index;
}
}
return 0;
};
/* \arg{x,y} coorindates in the diagram space
\return 0 if no label is at x,y otherwise the label number is returned.
*/
sarl_unsigned_int sarl_lattice_view_label_at(
SarlLatticeView *view,
sarl_signed_int x,
sarl_signed_int y
)
{
sarl_label_t* label;
sarl_point_t p;
sarl_point_t* cp = 0;
sarl_unsigned_int index;
// FIXME: selected labels need to respect changes in the interp
for(index=view->p->labels->length; index>0; --index) {
if (view->p->labels->table[index-1]) {
label = (sarl_label_t *)view->p->labels->table[index-1];
cp = sarl_diagram_get_concept_pos(view->p->diagram, label->concept);
p.x = x - cp->x;
p.y = y - cp->y;
if ( sarl_rect_includes(&label->bbox, &p) ) {
return index;
}
}
}
return 0;
};
void sarl_lattice_view_center_labels(SarlLatticeView *view)
{
sarl_label_t* label;
SARL_ARRAY_FOR_EACH(sarl_label_t, label, view->p->labels);
if (label->kind == SARL_LABEL_ATTRIBUTE_KIND) {
sarl_rect_center_top_left_on(&label->rect,
label->margin - (label->bbox.width/2),
- (view->p->concept_radius + label->bbox.height - label->margin));
sarl_label_update_bbox(label, view->p->font_size);
}
else if (label->kind == SARL_LABEL_OBJECT_KIND) {
sarl_rect_center_top_left_on(&label->rect,
label->margin - (label->bbox.width/2),
view->p->concept_radius + label->margin);
sarl_label_update_bbox(label, view->p->font_size);
}
SARL_ARRAY_END;
};
void sarl_lattice_view_truncate_labels(SarlLatticeView *view)
{
sarl_label_t* label;
SARL_ARRAY_FOR_EACH(sarl_label_t, label, view->p->labels);
sarl_label_size_to_three_lines(label, view->p->scale, view->p->font_size);
SARL_ARRAY_END;
};
static void sarl_lattice_label_contents_hit(
SarlLatticeView *view, GdkEventButton *event,
sarl_label_t * label, sarl_signed_int cx, sarl_signed_int cy
)
{
sarl_unsigned_int prev_selected_object, prev_selected_attribute;
view->selected_layout_index =
sarl_label_layout_index_at(label, cx, cy, view->p->scale);
fprintf(stderr, "Layout Index: %u\n",
(sarl_unsigned_int)view->selected_layout_index
);
if ( view->selected_layout_index ) {
switch(label->kind) {
case SARL_LABEL_OBJECT_KIND:
prev_selected_object = view->selected_object;
view->selected_object =
sarl_bit_set_nth(
sarl_power_map_get(
view->p->diagram->lattice->concept_object_cont,
label->concept
),
view->selected_layout_index
);
if ( view->selected_object ) {
g_signal_emit(
G_OBJECT(view),
sarl_lattice_view_signals[SARL_LATTICE_VIEW_SELECT_OBJECT_SIGNAL],
0, view->selected_object, event
);
};
if ( prev_selected_object != view->selected_object ) {
g_object_notify(G_OBJECT(view), "selected-object");
}
break;
case SARL_LABEL_ATTRIBUTE_KIND:
prev_selected_attribute = view->selected_attribute;
view->selected_attribute =
sarl_bit_set_nth(
sarl_power_map_get(
view->p->diagram->lattice->concept_attribute_cont,
label->concept
),
view->selected_layout_index
);
if ( view->selected_attribute ) {
g_signal_emit(
G_OBJECT(view),
sarl_lattice_view_signals[SARL_LATTICE_VIEW_SELECT_ATTRIBUTE_SIGNAL],
0, view->selected_attribute, event
);
};
if ( prev_selected_attribute != view->selected_attribute ) {
g_object_notify(G_OBJECT(view), "selected-attribute");
}
break;
}
};
}
static gboolean
sarl_lattice_view_button_press_event_callback(
GtkWidget *widget, GdkEventButton *event, gpointer data)
{
SarlLatticeView *view = SARL_LATTICE_VIEW(widget);
sarl_unsigned_int prev_selected_concept;
view->prev_pt.x = (int)event->x;
view->prev_pt.y = (int)event->y;
sarl_signed_int cx = ITR_X(event->x);
sarl_signed_int cy = ITR_Y(event->y);
// see if we hit a concept
prev_selected_concept = view->selected_concept;
view->selected_concept = sarl_lattice_view_concept_at(view, cx, cy);
view->dragged_concept = view->selected_concept;
if ( view->selected_concept ) {
g_signal_emit(
G_OBJECT(view),
sarl_lattice_view_signals[SARL_LATTICE_VIEW_SELECT_CONCEPT_SIGNAL],
0, view->selected_concept, event
);
}
if ( view->selected_concept != prev_selected_concept ) {
g_object_notify(G_OBJECT(view), "selected-concept");
}
// see if we hit a label
if ( view->selected_concept == 0 ) {
view->selected_label =
sarl_lattice_view_label_at(view, cx, cy);
view->dragged_label = view->selected_label;
// see find out which line was hit
if ( view->selected_label != 0 ) {
sarl_label_t* label =
(sarl_label_t *)sarl_array_get(view->p->labels, view->selected_label);
// see what we hit in the label
// FIXMENOW region_type = sarl_label_region_at(label, cx, cy);
sarl_point_t* p =
sarl_diagram_get_concept_pos(view->p->diagram, label->concept);
switch (
view->label_region = sarl_label_region_at(label, cx - p->x, cy - p->y)
) {
case SARL_LABEL_REGION_CONTENTS:
fprintf(stderr, "Contents.\n");
sarl_lattice_label_contents_hit(view, event, label, cx - p->x, cy - p->y);
break;
case SARL_LABEL_REGION_UP_ARROW:
sarl_label_scroll_up(label);
sarl_lattice_view_update(view);
fprintf(stderr, "Up.\n");
break;
case SARL_LABEL_REGION_DOWN_ARROW:
sarl_label_scroll_down(label);
sarl_lattice_view_update(view);
fprintf(stderr, "Down.\n");
break;
case SARL_LABEL_REGION_RESIZE:
fprintf(stderr, "Resize.\n");
break;
case SARL_LABEL_REGION_OUTSIDE:
fprintf(stderr, "Outside.\n");
break;
case SARL_LABEL_REGION_SCROLL:
fprintf(stderr, "Scroll.\n");
break;
}
}
}
return TRUE;
};
static gboolean
sarl_lattice_view_button_release_event_callback(
GtkWidget *widget, GdkEventButton *event, gpointer data)
{
SarlLatticeView *view = SARL_LATTICE_VIEW(widget);
sarl_lattice_view_recalc_bbox(view);
sarl_lattice_view_recalc_transform(view);
sarl_lattice_view_recalc_font_size(view);
sarl_lattice_view_rescale_labels(view);
view->dragged_concept = 0;
view->dragged_label = 0;
view->selected_layout_index = 0;
view->selected_object = 0;
sarl_lattice_view_update(view);
return TRUE;
};
static void sarl_lattice_view_size_request(
GtkWidget *widget, GtkRequisition *req
)
{
req->width = 400; // Default value
req->height = 400; // Default value
}
void sarl_lattice_view_dump_to(SarlLatticeView *view, FILE *file)
{
sarl_label_t *label;
fprintf(file, "Dumping SarlLatticeView:\n");
SARL_ARRAY_FOR_EACH(sarl_label_t, label, view->p->labels);
fprintf(file, " label=%p, layouts=%p\n", label, label->layouts);
SARL_ARRAY_END;
};
void sarl_lattice_view_set_font_size(SarlLatticeView *view, gint size)
{
view->p->font_size = size;
// g_object_notify(G_OBJECT(view), "font-size");
sarl_lattice_view_recalc_font_size(view);
sarl_lattice_view_rescale_labels(view);
sarl_lattice_view_update(view);
}
void sarl_lattice_view_set_show_objects(
SarlLatticeView *view, gboolean is_shown)
{
view->p->show_objects = is_shown;
fprintf(stderr, "Show objects val=%d\n", (is_shown ? 1 : 0));
g_object_notify(G_OBJECT(view), "show-objects");
sarl_lattice_view_update(view);
}
void sarl_lattice_view_set_show_attributes(
SarlLatticeView *view, gboolean is_shown)
{
view->p->show_attributes = is_shown;
g_object_notify(G_OBJECT(view), "show-attributes");
sarl_lattice_view_update(view);
}
gint sarl_lattice_view_get_font_size(SarlLatticeView *view)
{
return view->p->font_size;
};
static void
sarl_lattice_view_class_init (SarlLatticeViewClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS(klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
//
// Methods inherrited from GObject.
//
// widget_class->realize = sarl_lattice_view_realize;
widget_class->size_request = sarl_lattice_view_size_request;
object_class->destroy = sarl_lattice_view_destroy;
gobject_class->set_property = sarl_lattice_view_set_property;
gobject_class->get_property = sarl_lattice_view_get_property;
//
// Properties.
//
#define SARL_INSTALL_INT_PROPERY(p, pl, pt, pd, iv) \
g_object_class_install_property( \
gobject_class, p, \
g_param_spec_uint( \
pl, P_(pt), P_(pd), 0, UINT_MAX, iv, \
(GParamFlags)G_PARAM_READWRITE \
) \
);
#define SARL_INSTALL_BOOL_PROPERY(p, pl, pt, pd, iv) \
g_object_class_install_property( \
gobject_class, p, \
g_param_spec_boolean( \
pl, P_(pt), P_(pd), iv, \
(GParamFlags)G_PARAM_READWRITE \
) \
);
#define SARL_INSTALL_INT_PROPERY_RO(p, pl, pt, pd, iv) \
g_object_class_install_property( \
gobject_class, p, \
g_param_spec_uint( \
pl,P_(pt), P_(pd), 0, UINT_MAX, iv, \
(GParamFlags)G_PARAM_READABLE \
) \
);
SARL_INSTALL_INT_PROPERY_RO(
PROP_SLV_SELECTED_CONCEPT, "selected-concept",
"selected concept", "The concept which is currently selected.",
0
);
SARL_INSTALL_INT_PROPERY_RO(
PROP_SLV_SELECTED_ATTRIBUTE, "selected-attribute",
"selected attribute", "The attribute which is currently selected.",
0
);
SARL_INSTALL_INT_PROPERY_RO(
PROP_SLV_SELECTED_OBJECT, "selected-object",
"selected object", "The object which is currently selected.",
0
);
SARL_INSTALL_INT_PROPERY(
PROP_SLV_CONCEPT_LINE_WIDTH, "concept-line-width",
"concept line width", "Line width of concept-concept lines.",
150
);
SARL_INSTALL_INT_PROPERY(
PROP_SLV_CONCEPT_RADIUS, "concept-radius",
"concept radius", "Radius of concepts in the diagram.",
150
);
SARL_INSTALL_INT_PROPERY(
PROP_SLV_LABEL_LINE_WIDTH, "label-line-width",
"label line width", "Line width of concept-label lines.",
150
);
SARL_INSTALL_INT_PROPERY(
PROP_SLV_FONT_SIZE, "font-size",
"font size", "Size of the fonts used in labels.",
150
);
SARL_INSTALL_BOOL_PROPERY(
PROP_SLV_SHOW_OBJECTS, "show-objects",
"show objects", "Whether or not the object labels are displayed.",
TRUE
);
SARL_INSTALL_BOOL_PROPERY(
PROP_SLV_SHOW_ATTRIBUTES, "show-attributes",
"show attributes", "Whether or not the attribute labels are displayed.",
TRUE
);
g_object_class_install_property(
gobject_class,
PROP_SLV_FONT_DESC,
g_param_spec_boxed(
"font-description", P_("Font Description"),
P_("Font description as a PangoFontDescription struct"),
PANGO_TYPE_FONT_DESCRIPTION,
(GParamFlags)G_PARAM_READWRITE
)
);
g_object_class_install_property(
gobject_class,
PROP_SLV_FONT_NAME,
g_param_spec_string(
"font-name",P_("Font Name"),
P_("name of the font used to render labels."),
"Sans", (GParamFlags)G_PARAM_READWRITE
)
);
//
// Signals
//
#define SARL_REGISTER_SIMPLE_SIGNAL(se, sn, st, sc) \
sarl_lattice_view_signals[se] = \
g_signal_new(sn, st, G_SIGNAL_RUN_LAST, 0, \
0, 0, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0 \
);
#define SARL_REGISTER_GUINT_SIGNAL(se, sn, st, sc) \
sarl_lattice_view_signals[se] = \
g_signal_new(sn, st, G_SIGNAL_RUN_LAST, 0, \
0, 0, g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, \
1, G_TYPE_UINT \
);
#define SARL_REGISTER_2_GUINT_SIGNAL(se, sn, st, sc) \
sarl_lattice_view_signals[se] = \
g_signal_new(sn, st, G_SIGNAL_RUN_LAST, 0, \
0, 0, g_cclosure_user_marshal_VOID__UINT_BOXED, G_TYPE_NONE, \
2, G_TYPE_UINT, GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE \
);
SARL_REGISTER_2_GUINT_SIGNAL(
SARL_LATTICE_VIEW_SELECT_CONCEPT_SIGNAL, "select-concept",
SARL_LATTICE_VIEW_TYPE, SarlLatticeViewClass
);
SARL_REGISTER_2_GUINT_SIGNAL(
SARL_LATTICE_VIEW_SELECT_OBJECT_SIGNAL, "select-object",
SARL_LATTICE_VIEW_TYPE, SarlLatticeViewClass
);
SARL_REGISTER_2_GUINT_SIGNAL(
SARL_LATTICE_VIEW_SELECT_ATTRIBUTE_SIGNAL, "select-attribute",
SARL_LATTICE_VIEW_TYPE, SarlLatticeViewClass
);
}
void sarl_lattice_view_save_image(SarlLatticeView *view, char *filename, char *format)
{
gint depth, width, height;
GdkDrawable *window = GTK_WIDGET(view)->window;
depth = gdk_drawable_get_depth(window);
gdk_drawable_get_size(window, &width, &height);
GdkPixmap *pixmap = gdk_pixmap_new(0, width, height, depth);
GdkDrawable *pixmap_drawable = GDK_DRAWABLE(pixmap);
GdkGC* gc = gdk_gc_new(pixmap_drawable);
gdk_gc_copy(gc, GET_FG_GC(GTK_WIDGET(view)));
gdk_draw_rectangle(pixmap_drawable, GET_WT_GC(GTK_WIDGET(view)),
TRUE, 0, 0, width, height);
sarl_lattice_view_draw_lines(view, pixmap_drawable, gc);
sarl_lattice_view_draw_concepts(view, pixmap_drawable, gc);
sarl_lattice_view_draw_labels(view, pixmap_drawable, gc);
gdk_gc_unref(gc);
GdkColormap *cmap = gdk_drawable_get_colormap(pixmap_drawable);
GdkPixbuf* pixbuf = gdk_pixbuf_get_from_drawable(
0, pixmap_drawable, cmap, 0, 0, 0, 0, width, height
);
GError *error = 0;
gdk_pixbuf_save(pixbuf, filename, format, &error, 0);
gdk_colormap_unref(cmap);
gdk_pixbuf_unref(pixbuf);
gdk_pixmap_unref(pixmap);
};
void sarl_lattice_view_update_labels(SarlLatticeView *view)
{
sarl_lattice_view_recalc_labels(view);
sarl_lattice_view_recalc_font_size(view);
sarl_lattice_view_rescale_labels(view);
sarl_lattice_view_truncate_labels(view);
sarl_lattice_view_center_labels(view);
sarl_lattice_view_update(view);
};
|
20d4894c6604827d96d4264c16c10399ed6b29a9
|
c602515b038d43d616ec2406915d5baae412c33d
|
/Source/UBomber/Items/Pickups/UBomberPickupBase.h
|
aac7cd7c9f4ff39fa121766fa1c191b219b7236d
|
[] |
no_license
|
ZimaXXX/UBomber
|
5ca09ccfc7bb808906af787b6ead4c6f43d5b1e0
|
d754272948b755a606b4716d315f6ddc3e69cf06
|
refs/heads/master
| 2021-10-24T18:34:14.675423
| 2019-03-27T14:51:01
| 2019-03-27T14:51:01
| 113,408,207
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,092
|
h
|
UBomberPickupBase.h
|
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Common/UBomberTypes.h"
#include "UBomberPickupBase.generated.h"
/**
* Actor containing Pickup information
*/
UCLASS()
class UBOMBER_API AUBomberPickupBase : public AActor
{
GENERATED_BODY()
public:
AUBomberPickupBase(const FObjectInitializer& ObjectInitializer);
/**
* Plane to step up on
*/
UPROPERTY(VisibleDefaultsOnly, Category = Default)
class UStaticMeshComponent* PlaneComponent;
/**
* Box for detecting collisions with Players
*/
UPROPERTY(VisibleDefaultsOnly, Category = Default)
class UBoxComponent* BoxComponent;
/**
* Type of Pickup contained by this Actor
*/
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Default)
TEnumAsByte<EPickupType::Type> PickupType;
protected:
/**
* Override for handling damage and destruction
*/
virtual float TakeDamage(float Damage, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, class AActor* DamageCauser) override;
};
|
0743fee04c1caff7fd594cd552fe7cf465ab2e24
|
2f886d648b308f53f8de7933cb235cab22b40a69
|
/QtSesionEleven_/tcpServerChat/tcpServerChat/dialog.h
|
e74533f9466ae32be5e2b5d2be5762bd0b041259
|
[] |
no_license
|
avnikasikci/QTFrameWorkStudy
|
1bdfcf5b21246e63a7b27129365fbd19e8286bdb
|
a08907ba9a8575bf6295867dc0361ef711a91507
|
refs/heads/main
| 2023-05-13T01:25:57.563320
| 2021-06-05T17:58:05
| 2021-06-05T17:58:05
| 342,936,856
| 2
| 0
| null | 2021-04-28T10:16:52
| 2021-02-27T19:09:07
|
C++
|
UTF-8
|
C++
| false
| false
| 680
|
h
|
dialog.h
|
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include <QPushButton>
#include <QMessageBox>
#include "server.h"
QT_BEGIN_NAMESPACE
namespace Ui { class Dialog; }
QT_END_NAMESPACE
class Dialog : public QDialog
{
Q_OBJECT
public:
Dialog(QWidget *parent = nullptr);
~Dialog();
private slots:
void on_btnStart_clicked();
void on_btnStop_clicked();
void next();
void back();
void changed();
void on_btnStartAction_clicked();
void on_btnStopAction_clicked();
private:
Ui::Dialog *ui;
QPushButton *btnNext;
QPushButton *btnBack;
Server server;
void init();
void enableButtons();
};
#endif // DIALOG_H
|
c43f1a4edc8f75ed7eedce126f50988315438a29
|
de51ca68306b46a9f0f9217cb4e5f9c4d5308e8e
|
/I/hw1/9/2.16a/rabbit.h
|
ea7dfe7d059bff320dac8a59e728e44d5aed1a96
|
[] |
no_license
|
alioshag/Cplusplus
|
5c180e2a5baf678be0a9f4c1425f283034e96936
|
9cf027a199529272fa32579f7ae421bca7a6c666
|
refs/heads/master
| 2020-12-24T06:57:24.199726
| 2016-08-25T16:43:10
| 2016-08-25T16:43:10
| 58,066,471
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 470
|
h
|
rabbit.h
|
//filename: rabbit.h
//Changes -> H2.14.1a
#ifndef RABBITH
#define RABBITH
#include "terminal.h"
class rabbit {
static const char c = 'r';
const terminal *const t; //H2.17a-> pointer t is read-only and always poinint to the same terminal
unsigned x, y;
//char c;
//rabbit(const rabbit& another); //H2.10c deliberately undefined
public:
rabbit(const terminal& initial_t, unsigned initial_x, unsigned initial_y);
~rabbit();
bool move();
};
#endif
|
91d70b7e4c7893465d447e62f61e0574caf38c5c
|
1fc0fbdab8bb0be2025ebde8162ed6064b652f97
|
/algospot/울타리 잘라내기.cpp
|
3445ca488b5837d78b9fdbdde2e7a5d35c2373ca
|
[] |
no_license
|
dojyj/Algorithm_Study
|
c58aec70e25b3e55d60aa913d2a6bfcf4f200454
|
d837bb41430c2f421d5ee29e6f7e6e54bfc95571
|
refs/heads/master
| 2023-03-29T12:05:09.725887
| 2021-04-03T03:12:09
| 2021-04-03T03:12:09
| 326,720,206
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,113
|
cpp
|
울타리 잘라내기.cpp
|
#include <iostream>
#include <vector>
using namespace std;
int C;
int solve(int left, int right, vector<int> &v)
{
// base case
if (left == right)
return v[left];
// mid, low, high 지정
int mid = (left + right) / 2;
int lo = mid;
int hi = mid+1;
// 분할정복으로 모든 울타리 비교
int ret = max(solve(left, lo, v), solve(hi, right, v));
// 인접한 두 울타리 비교
int min_h = min(v[lo], v[hi]);
ret = max(ret, 2 * min_h);
// mid, mid + 1를 기점으로 근접한 울타리 중 큰 울타리 하나씩 붙이며 최대값 비교
while (lo > left || hi < right){
if (hi < right && (lo == left || v[hi + 1] > v[lo - 1])){
++hi;
min_h = min(min_h, v[hi]);
}else{
--lo;
min_h = min(min_h, v[lo]);
}
ret = max(ret, min_h * (hi - lo + 1));
}
return ret;
}
int main() {
scanf("%d\n", &C);
for(int i = 0; i < C; i++){
int N;
vector<int> v;
scanf("%d\n", &N);
// input
for(int j = 0; j < N; j++){
int tmp;
scanf("%d ", &tmp);
v.push_back(tmp);
}
// solve
printf("%d\n", solve(0, N - 1, v));
}
return 0;
}
|
1a9b467790e53afce575faca1a314358030f4b5d
|
e9450baebfcc751108b07e2c663d1e5a2a783fdb
|
/src/BB/World/Stage.cpp
|
386fb5a068d3d1491aeaaa1e52afc2a57455d1fd
|
[] |
no_license
|
dymani/BrainBurst1
|
009e26c068bd959ec06f96d4a936d2b0ead9a4ea
|
7ea647b26f5aa81cbb430bb95b5b6af7243d97f0
|
refs/heads/master
| 2021-01-17T22:02:45.450106
| 2016-02-13T16:34:23
| 2016-02-13T16:34:23
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,853
|
cpp
|
Stage.cpp
|
#include "BB/World/Stage.h"
namespace bb {
Stage* Stage::create(luabridge::lua_State* L, std::string name) {
Stage* stage = new Stage();
stage->m_name = name;
std::string file = "assets/data/world/stages/" + stage->m_name + ".lua";
using namespace luabridge;
if(luaL_loadfile(L, file.c_str()) || lua_pcall(L, 0, 0, 0)) {
LogHandler::log<Stage>(ERR, "Stage \"" + file + "\" not found");
return nullptr;
}
LuaRef luaBackgroundTexture = getGlobal(L, "backgroundTexture");
stage->m_backgroundTexture = luaBackgroundTexture.cast<std::string>();
LuaRef luaObjectTexture = getGlobal(L, "objectTexture");
stage->m_objectTexture = luaObjectTexture.cast<std::string>();
LuaRef luatileSet = getGlobal(L, "tileSet");
stage->m_tileSet = luatileSet.cast<std::string>();
LuaRef luaDisplayNames = getGlobal(L, "displayNames");
std::string nameID, displayName;
for(int i = 1; i <= luaDisplayNames.length(); i++) {
LuaRef luaDisplayName = luaDisplayNames[i];
nameID = luaDisplayName["name"].cast<std::string>();
displayName = luaDisplayName["displayName"].cast<std::string>();
stage->m_displayNames[nameID] = displayName;
}
return stage;
}
Stage::Stage() {
}
std::string Stage::getBackgroundTexture() {
return m_backgroundTexture;
}
std::string Stage::getObjectTexture() {
return m_objectTexture;
}
std::string Stage::getTileSet() {
return m_tileSet;
}
std::string Stage::getDisplayName(std::string name) {
if(m_displayNames.find(name) != m_displayNames.end())
return m_displayNames[name];
return "NULL";
}
}
|
7909128bf5d91bfbd13ef79ecabd397d8bd24fe0
|
27fceff05ded45465dbbba658a2cc5079f30130b
|
/extern/TGUI-0.7.8/src/TGUI/Widgets/MessageBox.cpp
|
5d9e28897a4e3f4c1235037a1018711f149c1857
|
[
"MIT",
"Zlib"
] |
permissive
|
towzeur/PLT_2021
|
8e053517a6973a5dd6407adbe58937592b01d1ad
|
c2598b387929f76ec8766e4e4741efc1a0c0379d
|
refs/heads/master
| 2023-02-21T19:18:58.960318
| 2021-01-29T03:06:45
| 2021-01-29T03:06:45
| 297,877,100
| 4
| 2
|
MIT
| 2021-01-29T03:06:46
| 2020-09-23T06:39:47
|
C++
|
UTF-8
|
C++
| false
| false
| 13,228
|
cpp
|
MessageBox.cpp
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// Copyright (C) 2012-2017 Bruno Van de Velde (vdv_b@tgui.eu)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <TGUI/Widgets/MessageBox.hpp>
#include <TGUI/Loading/Theme.hpp>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace tgui
{
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
MessageBox::MessageBox()
{
m_callback.widgetType = "MessageBox";
addSignal<sf::String>("ButtonPressed");
m_renderer = std::make_shared<MessageBoxRenderer>(this);
reload();
add(m_label, "#TGUI_INTERNAL$MessageBoxText#");
m_label->setTextSize(m_textSize);
setSize({400, 150});
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
MessageBox::MessageBox(const MessageBox& messageBoxToCopy) :
ChildWindow {messageBoxToCopy},
m_loadedThemeFile(messageBoxToCopy.m_loadedThemeFile), // Did not compile in VS2013 when using braces
m_buttonClassName(messageBoxToCopy.m_buttonClassName), // Did not compile in VS2013 when using braces
m_textSize {messageBoxToCopy.m_textSize}
{
m_label = Label::copy(messageBoxToCopy.m_label);
add(m_label, "#TGUI_INTERNAL$MessageBoxText#");
for (auto it = messageBoxToCopy.m_buttons.begin(); it != messageBoxToCopy.m_buttons.end(); ++it)
{
Button::Ptr button = Button::copy(*it);
button->disconnectAll();
button->connect("Pressed", [=]() { m_callback.text = button->getText(); sendSignal("ButtonPressed", button->getText()); });
m_buttons.push_back(button);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
MessageBox& MessageBox::operator= (const MessageBox& right)
{
if (this != &right)
{
MessageBox temp(right);
ChildWindow::operator=(right);
std::swap(m_loadedThemeFile, temp.m_loadedThemeFile);
std::swap(m_buttonClassName, temp.m_buttonClassName);
std::swap(m_buttons, temp.m_buttons);
std::swap(m_label, temp.m_label);
std::swap(m_textSize, temp.m_textSize);
}
return *this;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
MessageBox::Ptr MessageBox::create()
{
return std::make_shared<MessageBox>();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
MessageBox::Ptr MessageBox::copy(MessageBox::ConstPtr messageBox)
{
if (messageBox)
return std::static_pointer_cast<MessageBox>(messageBox->clone());
else
return nullptr;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void MessageBox::setFont(const Font& font)
{
ChildWindow::setFont(font);
m_label->setFont(font);
for (unsigned int i = 0; i < m_buttons.size(); ++i)
m_buttons[i]->setFont(font);
rearrange();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void MessageBox::setText(const sf::String& text)
{
m_label->setText(text);
rearrange();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void MessageBox::setTextSize(unsigned int size)
{
m_textSize = size;
m_label->setTextSize(size);
for (unsigned int i = 0; i < m_buttons.size(); ++i)
m_buttons[i]->setTextSize(m_textSize);
rearrange();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void MessageBox::addButton(const sf::String& caption)
{
Button::Ptr button;
if (!getTheme() || m_buttonClassName.empty())
button = std::make_shared<Button>();
else
button = getTheme()->internalLoad(getPrimaryLoadingParameter(), m_buttonClassName);
button->setTextSize(m_textSize);
button->setText(caption);
button->connect("Pressed", [=](){ m_callback.text = caption; sendSignal("ButtonPressed", caption); });
add(button, "#TGUI_INTERNAL$MessageBoxButton$" + caption + "#");
m_buttons.push_back(button);
rearrange();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void MessageBox::rearrange()
{
float buttonWidth = 120;
float buttonHeight = 24;
// Calculate the button size
if (getFont())
{
buttonWidth = 5.0f * getFont()->getLineSpacing(m_textSize);
buttonHeight = getFont()->getLineSpacing(m_textSize) / 0.85f;
for (unsigned int i = 0; i < m_buttons.size(); ++i)
{
float width = sf::Text(m_buttons[i]->getText(), *getFont(), m_textSize).getLocalBounds().width;
if (buttonWidth < width * 10.0f / 9.0f)
buttonWidth = width * 10.0f / 9.0f;
}
}
// Calculate the space needed for the buttons
float distance = buttonHeight * 2.0f / 3.0f;
float buttonsAreaWidth = distance;
for (unsigned int i = 0; i < m_buttons.size(); ++i)
{
m_buttons[i]->setSize({buttonWidth, buttonHeight});
buttonsAreaWidth += m_buttons[i]->getSize().x + distance;
}
// Calculate the suggested size of the window
sf::Vector2f size = {2*distance + m_label->getSize().x, 3*distance + m_label->getSize().y + buttonHeight};
// Make sure the buttons fit inside the message box
if (buttonsAreaWidth > size.x)
size.x = buttonsAreaWidth;
// Set the size of the window
setSize(size);
// Set the text on the correct position
m_label->setPosition({distance, distance});
// Set the buttons on the correct position
float leftPosition = 0;
float topPosition = 2*distance + m_label->getSize().y;
for (unsigned int i = 0; i < m_buttons.size(); ++i)
{
leftPosition += distance + ((size.x - buttonsAreaWidth) / (m_buttons.size()+1));
m_buttons[i]->setPosition({leftPosition, topPosition});
leftPosition += m_buttons[i]->getSize().x;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void MessageBox::reload(const std::string& primary, const std::string& secondary, bool force)
{
ChildWindow::reload(primary, secondary, force);
if (!m_theme || primary == "")
getRenderer()->setTextColor({0, 0, 0});
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void MessageBoxRenderer::setProperty(std::string property, const std::string& value)
{
property = toLower(property);
if (property == "textcolor")
setTextColor(Deserializer::deserialize(ObjectConverter::Type::Color, value).getColor());
else if (property == "button")
m_messageBox->m_buttonClassName = Deserializer::deserialize(ObjectConverter::Type::String, value).getString();
else if (property == "childwindow")
{
if (m_messageBox->getTheme() == nullptr)
throw Exception{"Failed to load scrollbar, ChatBox has no connected theme to load the scrollbar with"};
tgui::ChildWindow::Ptr childWindow = m_messageBox->getTheme()->internalLoad(
m_messageBox->m_primaryLoadingParameter,
Deserializer::deserialize(ObjectConverter::Type::String, value).getString()
);
for (auto& pair : childWindow->getRenderer()->getPropertyValuePairs())
setProperty(pair.first, std::move(pair.second));
}
else
ChildWindowRenderer::setProperty(property, value);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void MessageBoxRenderer::setProperty(std::string property, ObjectConverter&& value)
{
property = toLower(property);
if (value.getType() == ObjectConverter::Type::Color)
{
if (property == "textcolor")
setTextColor(value.getColor());
else
ChildWindowRenderer::setProperty(property, std::move(value));
}
else if (value.getType() == ObjectConverter::Type::String)
{
if (property == "button")
m_messageBox->m_buttonClassName = value.getString();
else if (property == "childwindow")
{
if (m_messageBox->getTheme() == nullptr)
throw Exception{"Failed to load scrollbar, ChatBox has no connected theme to load the scrollbar with"};
tgui::ChildWindow::Ptr childWindow = m_messageBox->getTheme()->internalLoad(m_messageBox->m_primaryLoadingParameter, value.getString());
for (auto& pair : childWindow->getRenderer()->getPropertyValuePairs())
setProperty(pair.first, std::move(pair.second));
}
else
ChildWindowRenderer::setProperty(property, std::move(value));
}
else
ChildWindowRenderer::setProperty(property, std::move(value));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ObjectConverter MessageBoxRenderer::getProperty(std::string property) const
{
property = toLower(property);
if (property == "textcolor")
return m_messageBox->m_label->getTextColor();
else
return ChildWindowRenderer::getProperty(property);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
std::map<std::string, ObjectConverter> MessageBoxRenderer::getPropertyValuePairs() const
{
auto pairs = ChildWindowRenderer::getPropertyValuePairs();
pairs["TextColor"] = m_messageBox->m_label->getTextColor();
return pairs;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void MessageBoxRenderer::setTextColor(const Color& color)
{
m_messageBox->m_label->setTextColor(color);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
std::shared_ptr<WidgetRenderer> MessageBoxRenderer::clone(Widget* widget)
{
auto renderer = std::make_shared<MessageBoxRenderer>(*this);
renderer->m_messageBox = static_cast<MessageBox*>(widget);
return renderer;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
19c30cf53b07a822a024409db10c586560bebc10
|
f60730c08e85c3e2e3e1342f2594de1fbe6ad5ee
|
/main.h
|
323db5cd1e01bdd2f7069312872c4273611db180
|
[
"MIT"
] |
permissive
|
paulbelches/ParserGenerator
|
3344f18463a778ea9498c5cab4ebc4092e788838
|
18200befdc2e9aba8ffc1ee0c4d4972adecf5a3c
|
refs/heads/main
| 2023-05-12T15:22:07.837943
| 2021-06-04T20:02:00
| 2021-06-04T20:02:00
| 366,460,263
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 31,525
|
h
|
main.h
|
#include <iostream>
#include <bits/stdc++.h>
#include <utility>
#include <fstream>
#include <string>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <chrono>
/* File:
* main.cpp
*
* Purpose:
* Using a input regular expression the code generates 3 automatas.
* A non/deterministic finite automata, a deterministic finite automata and
* a deterministic finite automata using the direct method. After the automatas
* are generated, using a input string the program simulates the automatas to see whether
* they acept the string or not.
*
* Input:
* the regular expresion, and the string to be review
*
* Output:
* the process done to create an simulate the automatas, 5 text files with the
* representation of the automatas generated, and the result of the simulation
*
* Compile:
* c++ main.cpp -o main.run
*
* Usage:
* main.run <'regular expresion'> <'string'>
*
*/
using namespace std::chrono;
using namespace std;
/*---------------------------------------------------------------------
* Function: isOperator
* Purpose: Determine whether a character is a operator or not
* In arg: v, the character that is going to be review
* Return val: Whether a character is a operand or not
*/
bool isOperator(char v){
string ops = "()|.*?+";
for (int i = 0; i < ops.length(); i = i + 1){
if (ops[i] == v)
return 1;
}
return 0;
}
/*---------------------------------------------------------------------
* Function: prcedence
* Purpose: Optain operand precedence
* In arg: v, the character that is going to be review
* Return val: An integer representing the value of the precedence
*/
int precedence(char v){
if (v == '?' || v == '+'){
return 4;
}
string ops = "()|.*";
for (int i = 0; i < ops.length(); i = i + 1){
if (ops[i] == v)
return i;
}
return -1;
}
/*---------------------------------------------------------------------
* Class: Node
* Purpose: Represent nodes of a syntax tree
* Attributes:
* id The id of the node
* data The character it represents
* nullable Whether is nullable or not
* firstpos Firstpos value
* lastpos LastPos value
* followpos Followpos value
* left Child node to the left
* right Child node to the right
*/
class Node{
public:
int id;
string data;
bool nullable;
set<Node*> firstpos;
set<Node*> lastpos;
set<Node*> followpos;
Node* left;
Node* right;
/*---------------------------------------------------------------------
* Contructor
* In arg: d value of the node, left child, right child
*/
Node(string d, Node* left, Node* right, set<int>& registerIds){
id = rand() % 5000 + 1;
while (registerIds.find(id) != registerIds.end()){
id = rand() % 5000 + 1;
}
registerIds.insert(id);
data=d;
this->left=left;
this->right=right;
}
};
/*---------------------------------------------------------------------
* Function: expand
* Purpose: Expand a regular expresion to include characters for concatenation
* In arg: expr, the regular expresion
* Return val: The expand expresion
*/
string expand(string expr){
string r = "";
int cont = 0;
bool operand = 0;
bool readingString = false;
for (int i = 0; i < expr.length(); i = i + 1){
if (readingString){
if (expr[i] == '"'){
readingString = false;
cont = 1;
}
} else if (expr[i] == '|'){
cont = 0;
operand = 0;
} else if (expr[i] == '('){
if (cont == 1){
r = r + '.';
cont = 0;
operand = 0;
}
} else if (expr[i] == ')' || expr[i] == '*' || expr[i] == '+' || expr[i] == '?'){
operand = 0;
} else if (expr[i] == '"'){
readingString = true;
cont = cont + 1;
} else {
if (!operand) {
operand = 1;
cont = cont + 1;
}
}
if (cont == 2){
r = r + '.' + expr[i];
cont = 1;
} else {
r = r + expr[i];
}
}
return r;
}
/*---------------------------------------------------------------------
* Function: nullable
* Purpose: Calculate nullable of a node of the syntax tree
* In arg: root, a node from the tree
* Return val: Whether is nullable or not
*/
bool nullable(Node* root){
if (root->data[0] == '$'){
return true;
} else if (root->data[0] == '|'){
return nullable(root->left) || nullable(root->right);
} else if (root->data[0] == '.'){
return nullable(root->left) && nullable(root->right);
} else if (root->data[0] == '*'){
return true;
} else {
return false;
}
}
/*---------------------------------------------------------------------
* Function: lastpos
* Purpose: Calculate lastpos of a node of the syntax tree
* In arg: root, a node from the tree
* Return val: The result lastpos set of nodes
*/
set<Node*> lastpos(Node* root){
set<Node*> result;
set<Node*> tempSet;
if (root->data[0] == '$'){
return result;
} else if (root->data[0] == '|'){
tempSet = lastpos(root->right);
result = lastpos(root->left);
result.insert(tempSet.begin(), tempSet.end());
} else if (root->data[0] == '.'){
if (nullable(root->right)){
tempSet = lastpos(root->right);
result = lastpos(root->left);
result.insert(tempSet.begin(), tempSet.end());
} else {
result = lastpos(root->right);
}
} else if (root->data[0] == '*'){
result = lastpos(root->left);
} else {
result.insert(root);
}
return result;
}
/*---------------------------------------------------------------------
* Function: firstpos
* Purpose: Calculate firstpos of a node of the syntax tree
* In arg: root, a node from the tree
* Return val: The result lastpos set of nodes
*/
set<Node*> firstpos(Node* root){
set<Node*> result;
set<Node*> tempSet;
if (root->data[0] == '$'){
return result;
} else if (root->data[0] == '|'){
tempSet = firstpos(root->right);
result = firstpos(root->left);
result.insert(tempSet.begin(), tempSet.end());
} else if (root->data[0] == '.'){
if (nullable(root->left)){
tempSet = firstpos(root->right);
result = firstpos(root->left);
result.insert(tempSet.begin(), tempSet.end());
} else {
result = firstpos(root->left);
}
} else if (root->data[0] == '*'){
result = firstpos(root->left);
} else {
result.insert(root);
}
return result;
}
/*---------------------------------------------------------------------
* Function: fillFunctions
* Purpose: Calculate nullable, firstpos and lastpos of a node of the syntac tree
* In arg: root, a node from the tree
* Return val: -------
*/
void fillFunctions(Node* root){
root->nullable = nullable(root);
root->firstpos = firstpos(root);
root->lastpos = lastpos(root);
if (root->left != NULL) {
fillFunctions(root->left);
}
if (root->right != NULL) {
fillFunctions(root->right);
}
}
/*---------------------------------------------------------------------
* Function: getAlphabet
* Purpose: Get the alphabet (operands) of a regular expresion
* In arg: s, the regular expresion
* Return val: -------
*/
set<string> getAlphabet(string s){
//string nonAlphabet = '.*|()';
set<string> result;
string tempValue = "";
bool readingString = false;
for (int i=0; i<s.length();i++){
if ((s[i] != '.' && s[i] != '*' && s[i] != '|' && s[i] != '(' && s[i] != ')' && s[i] != '$' && s[i] != '?' && s[i] != '+') || readingString) {
if (s[i] == '"') {
readingString = readingString ? false : true;
}
string t(1,s[i]);
tempValue = tempValue + t;
} else {
if (tempValue.size()>0) {
result.insert(tempValue);
}
tempValue = "";
}
}
if (tempValue.size() > 0){
result.insert(tempValue);
}
return result;
}
/*---------------------------------------------------------------------
* Class: SyntaxTree
* Purpose: Represents a SyntaxTree
* Attributes:
* root The root node
*/
class SyntaxTree{
public:
Node* root;
void join(Node* tree, set<int>& registerIds);
/*---------------------------------------------------------------------
* Contructor
* In arg: expr, the regular expresion
*/
SyntaxTree(string expr, set<int>& registerIds){
stack<char> opStack;
string tempValue = "";
bool readingString = false;
//Read the expression
vector<string> result;
for (int i = 0; i < expr.length(); i = i + 1){
//cout << expr[i] << endl;
if (isOperator(expr[i])){
if(tempValue.size() > 0){
result.push_back(tempValue);
tempValue = "";
}
if (opStack.size() == 0){
opStack.push(expr[i]);
} else {
if (expr[i] == '(') {
opStack.push(expr[i]);
} else if (expr[i] == ')') {
while (opStack.top() != '('){
string s(1,opStack.top());
result.push_back(s);
opStack.pop();
}
opStack.pop();
}else if (precedence(expr[i]) > precedence(opStack.top())) {
opStack.push(expr[i]);
} else {
while (precedence(expr[i]) <= precedence(opStack.top())){
string s(1,opStack.top());
result.push_back(s);
opStack.pop();
if (opStack.empty()) {
break;
}
}
opStack.push(expr[i]);
}
}
} else {
tempValue = tempValue + expr[i];
}
}
if(tempValue.size() > 0){
result.push_back(tempValue);
tempValue = "";
}
//cout << result << endl;
while (!opStack.empty()){
string s(1,opStack.top());
result.push_back(s);
opStack.pop();
}
stack<Node*> tree;
for (int i=0; i < result.size(); i=i+1){
if (isOperator(result[i][0])){
if (result[i][0] == '*'){
//cout << tree.front()->data << "\n";
if (tree.size() == 0){
throw std::invalid_argument( "bad expresion received" );
}
Node* temp = new Node("*", tree.top(), NULL, registerIds);
tree.top() = temp;
} else if (result[i][0] == '.' || result[i][0] == '|'){
if (tree.size() == 0){
throw std::invalid_argument( "bad expresion received" );
}
Node* firstValue = tree.top();
tree.pop();
if (tree.size() == 0){
throw std::invalid_argument( "bad expresion received" );
}
string value(1, result[i][0]);
Node* temp = new Node(value, tree.top(), firstValue, registerIds);
tree.top() = temp;
} else if (result[i][0] == '+'){
if (tree.size() == 0){
throw std::invalid_argument( "bad expresion received" );
}
Node* firstValue = new Node("*", tree.top(), NULL, registerIds);
Node* temp = new Node(".", tree.top(), firstValue, registerIds);
tree.top() = temp;
} else if (result[i][0] == '?'){
if (tree.size() == 0){
throw std::invalid_argument( " bad expresion received" );
}
Node* firstValue = new Node("$", NULL, NULL, registerIds);
Node* temp = new Node("|", tree.top(), firstValue, registerIds);
tree.top() = temp;
}
//cout << result[i][0] << "\n";
} else {
tree.push(new Node(result[i], NULL, NULL, registerIds));
}
//opStack.push(new Node(opStack.top(), NULL, NULL););
}
//cout << "Resultado: " << result << "\n";
//cout << "stack: " << tree.size() << "\n";
root = tree.top();
}
};
/*---------------------------------------------------------------------
* Function: join
* Purpose: Joins 2 syntax trees
* In arg: tree, syntax tree to join with
* Return val: -------
*/
void SyntaxTree::join(Node* tree, set<int>& registerIds){
root = new Node("|", root, tree, registerIds);
}
/*---------------------------------------------------------------------
* Function: setNodeToSetInt
* Purpose: Generate a set of ints from a set of nodes
* In arg: nodes, set of nodes
* Return val: Resulting set
*/
set<int> setNodeToSetInt(set<Node*> nodes){
set<int> result;
for (auto const &e: nodes) {
result.insert(e->id);
}
return result;
}
/*---------------------------------------------------------------------
* Class: AFDirect
* Purpose: Represents a direct deterministic finite automata
* Attributes:
* nodes the number of nodes in the follow pos
* followposV Which node represents each position in followpos
* ids The ids of each node
* leafs The char value of each node
* states The states of the automata, the vector representes the states in the afd and the set contains the afn states
* transitions The transitions of each of the the automata nodes
* alphabet The alphabet of the automata
*/
class AFDirect{
public:
//followpos table
vector<int> nodes; //which node represents each position in followpos
vector<set<int>> followposV;
//Reference table
vector<int> ids;
vector<string> leafs;
//AFDode* start;
vector <set<int>> states;
vector <vector <int>> transitions;
set<string> alphabet;
vector<int> finalids;
vector<string> expressions;
vector<string> expressionsId;
map<string,bool> exceptTokens;
map<string, string> keywords;
set<int> whitespaces;
//Methods
int isTerminal(int currentState);
void followpos(Node* node);
set<int> getFollowpos(int id);
string getLetter(int id);
int getNumber(string letter);
void simulate(string chain);
int getTransition(string charcterNumber);
/*---------------------------------------------------------------------
* Contructor
* In arg: start, the root of the syntax tree alphabet, the automata alphabet
*/
AFDirect(Node* start, set<string> alphabet, vector<int> finalids, vector<string> expressions , vector<string> expressionsId,
set<int> whitespaces, map<string,bool> exceptTokens, map<string, string> keywords){
followpos(start);
// cout << "alhabet " << setToString(alphabet) << endl;
this->finalids = finalids;
this->alphabet = alphabet;
this->expressions = expressions;
this->expressionsId = expressionsId;
this->whitespaces = whitespaces;
this->exceptTokens = exceptTokens;
this->keywords = keywords;
queue<set<int>> pendingStates;
states.push_back(setNodeToSetInt(start->firstpos));
pendingStates.push(setNodeToSetInt(start->firstpos));
while (!pendingStates.empty()){
vector<int> temporalTransitions;
for (auto const &e: alphabet) {
//cout << e << endl;
set<int> newState;
set<int> result;
for (auto const &h: pendingStates.front()) {
if(getLetter(h).compare(e) == 0){
//cout << h << getLetter(h) << " " << printIntSet(getFollowpos(h)) << "\n";
result = getFollowpos(h);
newState.insert(result.begin(), result.end());
}
}
int pos = -1;
if (newState.size() > 0){
//ver si existe
for (int i = 0; i < states.size(); i = i + 1){
if (equal(states[i].begin(), states[i].end(), newState.begin(), newState.end())){
pos = i;
}
}
//sino agreagar al pool de estados
if (pos == -1){
states.push_back(newState);
pendingStates.push(newState);
pos = states.size() - 1;
}
//Agregar transicipon
}
temporalTransitions.push_back(pos);
//cout << printIntSet(pendingStates.front()) << " " << e << " " << printIntSet(newState) << pos << "\n";
}
transitions.push_back(temporalTransitions);
pendingStates.pop();
}
}
};
/*---------------------------------------------------------------------
* Function: followpos
* Purpose: Calculate the followpos from a syntax tree node
* In arg: node, a syntaxtree node
* Return val: -------
*/
void AFDirect::followpos(Node* node){
Node* root;
set<int> result;
queue<Node*> pendingnodes;
pendingnodes.push(node);
while(!pendingnodes.empty()){
Node* root = pendingnodes.front();
pendingnodes.pop();
if (root->data[0] == '.'){
for (auto const &e: lastpos(root->left)) {
int pos = -1;
for (int i = 0; i < nodes.size(); i = i + 1){
if (e->id == nodes[i]){
pos = i;
}
} if (pos == -1){
nodes.push_back(e->id);
set<int> dummy;
followposV.push_back(dummy);
pos = nodes.size() - 1;
}
result = setNodeToSetInt(firstpos(root->right));
followposV[pos].insert(result.begin(), result.end());
}
} else if (root->data[0] == '*'){
for (auto const &e: root->lastpos) {
int pos = -1;
for (int i = 0; i < nodes.size(); i = i + 1){
if (e->id == nodes[i]){
pos = i;
}
}
if (pos == -1){
nodes.push_back(e->id);
set<int> dummy;
followposV.push_back(dummy);
pos = nodes.size() - 1;
}
result = setNodeToSetInt(root->firstpos);
followposV[pos].insert(result.begin(), result.end());
};
} else if (root->data[0] != '|'){ //create reference table
int pos = -1;
for (int i = 0; i < ids.size(); i = i + 1){
if (root->id == ids[i]){
pos = i;
}
}
if (pos = -1){
ids.push_back(root->id);
leafs.push_back(root->data);
}
}
// follow pos
if (root->left != NULL) {
pendingnodes.push(root->left);
}
if (root->right != NULL) {
pendingnodes.push(root->right);
}
}
}
/*---------------------------------------------------------------------
* Function: getFollowpos
* Purpose: Optain the followpos from a node
* In arg: id, id of the node
* Return val: set of ints that contain the ids of the followpos result
*/
set<int> AFDirect::getFollowpos(int id){
set<int> result;
for (int i = 0; i < nodes.size(); i = i + 1){
if (nodes[i] == id){
result = followposV[i];
}
}
return result;
}
/*---------------------------------------------------------------------
* Function: getLetter
* Purpose: Optain the the letter of a node using its id
* In arg: id, id of the node
* Return val: nodes letter
*/
string AFDirect::getLetter(int id){
for (int i = 0; i < ids.size(); i= i +1){
if (ids[i] == id){
return leafs[i];
}
}
}
/*---------------------------------------------------------------------
* Function: getNumber
* Purpose: Optain the the id of a node using its letter
* In arg: letter, letter of the node
* Return val: nodes id
*/
int AFDirect::getNumber(string letter){
for (int i = 0; i < leafs.size(); i= i +1){
if (leafs[i].compare(letter) == 0){
return ids[i];
}
}
return -1;
}
/*---------------------------------------------------------------------
* Function: isTerminal
* Purpose: Check is a state is a terminal state
* In arg: currentState, the state to be checked
* Return val: -------
*/
int AFDirect::isTerminal(int currentState){
for (int j = 0; j < finalids.size(); j = j + 1){
int finalNum = finalids[j];
if (states[currentState].find(finalNum) != states[currentState].end()){
return j;
}
}
return -1;
}
/*---------------------------------------------------------------------
* Function: getTransition
* Purpose: Get the position of the character in the alphabets set
* In arg: charcterNumber, the character that is going to be search
* Return val: The position of the character
*/
int AFDirect:: getTransition(string charcterNumber){
int cont = 0 ;
int transition = -1 ;//check if it does not change
//Make transition
for (auto const &e: alphabet) {
//cout << e << " " << charcterNumber << endl;
if ( charcterNumber == e ){
//cout << "si" << endl;
transition = cont;
//subStringlength = subchain.size();
}
cont = cont + 1;
}
return transition;
}
/*---------------------------------------------------------------------
* Function: simulate
* Purpose: Simulate a direct deterministic finite automata for a input chain
* In arg: afd, the direct deterministic finite automata chain, the input chain
* Return val: -------
*/
void AFDirect::simulate(string chain){
//check alphabet
stack<int> chequedStates;
int i = 0;
int currentState = 0;
chequedStates.push(0);
string readCharacters = "";
while(i < chain.size()){
if (this->whitespaces.find((int)chain[i]) != whitespaces.end()){
//check if terminal state
i = i + 1;
} else {
int transition = getTransition(to_string((int)chain[i]));
if (transitions[currentState][transition] == -1 || transition == -1){
//cout << readCharacters << " " << chain[i] << " " << (int)chain[i] << " " << currentState << " " << transition << " " << transitions[currentState][transition] << endl;
if (chequedStates.size() == 1){
readCharacters = readCharacters + chain[i];
i++;
cout << "<" << readCharacters << ", error>\n";
readCharacters = "";
} else {
int goback = 0;
int terminalId = isTerminal(currentState);
while(terminalId == -1){
if (chequedStates.size() == 1){
cout << "<" << readCharacters << ", error>\n";
readCharacters = "";
currentState = 0;
chequedStates.top() = 0;
goback = -1;
break;
}
chequedStates.pop();
currentState = chequedStates.top();
terminalId = isTerminal(currentState);
goback++;
}
if (goback > -1){
i = i - goback;
terminalId = isTerminal(currentState);
readCharacters = readCharacters.substr(0, readCharacters.size()-goback);
if (exceptTokens[expressionsId[terminalId]] && keywords[readCharacters].size() > 0){
cout << "<" << readCharacters << ", " << keywords[readCharacters] << ">" << endl;
} else {
cout << "<" << readCharacters << "," << expressionsId[terminalId] << ">" << endl;
}
readCharacters = "";
while (chequedStates.size() > 1){
chequedStates.pop();
}
currentState = 0;
}
}
} else {
currentState = transitions[currentState][transition];
chequedStates.push(currentState);
readCharacters = readCharacters + chain[i];
i++;
}
}
}
//Process the pending chain
int terminalId = isTerminal(currentState);
if (terminalId > 0){
if (exceptTokens[expressionsId[terminalId]] && keywords[readCharacters].size() > 0){
cout << "<" << readCharacters << ", " << keywords[readCharacters] << ">" << endl;
} else {
cout << "<" << readCharacters << "," << expressionsId[terminalId] << ">" << endl;
}
}
}
/*---------------------------------------------------------------------
* Function: generateStream
* Purpose: Read input file
* In arg: file the pointer where the file is going to be saved filepath the file path
* Return val: Resulting state
*/
int generateStream(string& file, string filePath){
string filename(filePath);
vector<char> bytes;
char byte = 0;
ifstream input_file(filename);
if (!input_file.is_open()) {
throw std::invalid_argument( "Could not open input file");
}
while (input_file.get(byte)) {
bytes.push_back(byte);
}
for (const auto &i : bytes) {
file = file + i;
//cout << i << " " << (int)i << " " << isspace(i) << endl;
}
input_file.close();
return 1;
}
class Scanner {
public:
vector<string> expressions;
vector<string> expressionsId;
map<string,bool> exceptTokens;
vector<int> finalids;
map<string,string> savedCharacters;
set<int> whitespaces;
set<int> registerIds;
map<string,string> keywords;
SyntaxTree* syntaxtree;
AFDirect* afdirect;
Scanner(string input){
whitespaces.insert(13);
whitespaces.insert(10);
whitespaces.insert(9);
exceptTokens["startcode"] = 0;
expressions.push_back("(40)(46)");
expressionsId.push_back("startcode");
exceptTokens["char"] = 0;
expressions.push_back("(39)((47))?(65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122)(39)");
expressionsId.push_back("char");
exceptTokens["endcode"] = 0;
expressions.push_back("(46)(41)");
expressionsId.push_back("endcode");
exceptTokens["charinterval"] = 0;
expressions.push_back("(67)(72)(82)(40)(48|49|50|51|52|53|54|55|56|57)((48|49|50|51|52|53|54|55|56|57))*(41)(46)(46)(67)(72)(82)(40)(48|49|50|51|52|53|54|55|56|57)((48|49|50|51|52|53|54|55|56|57))*(41)");
expressionsId.push_back("charinterval");
exceptTokens["charnumber"] = 0;
expressions.push_back("(67)(72)(82)(40)(48|49|50|51|52|53|54|55|56|57)((48|49|50|51|52|53|54|55|56|57))*(41)");
expressionsId.push_back("charnumber");
exceptTokens["string"] = 0;
expressions.push_back("(34)(((33|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126))*)(34)");
expressionsId.push_back("string");
exceptTokens["ident"] = 1;
expressions.push_back("(65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122)((65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122)|(48|49|50|51|52|53|54|55|56|57))*");
expressionsId.push_back("ident");
exceptTokens["nontoken"] = 0;
expressions.push_back("(33|34|35|36|37|38|39|42|44|47|48|49|50|51|52|53|54|55|56|57|58|59|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|92|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|126)");
expressionsId.push_back("nontoken");
string expr = expand(expressions[0]);
set<string> alphabet = getAlphabet(expr);
expr = '(' + expr + ").#";
SyntaxTree* syntaxtree = new SyntaxTree(expr,registerIds);
finalids.push_back(syntaxtree->root->right->id);
for (int i = 1; i < expressions.size(); i = i + 1){
string expr = expand(expressions[i]);
set<string> tempAlphabet = getAlphabet(expr);
alphabet.insert(tempAlphabet.begin(), tempAlphabet.end());
expr = '(' + expr + ").#";
SyntaxTree* tempsyntaxtree = new SyntaxTree(expr,registerIds);;
finalids.push_back(tempsyntaxtree->root->right->id);
syntaxtree->join(tempsyntaxtree->root,registerIds);
}
fillFunctions(syntaxtree->root);
AFDirect* afdirect = new AFDirect(syntaxtree->root, alphabet, finalids, expressions, expressionsId, whitespaces, exceptTokens, keywords);
afdirect->simulate(input);
}
};
/*
int main(int argc, char **argv) {
if (argc < 2){
cout << "An error ocurred\n";
cout << "Missing file path argument" << endl;
return 0;
}
try {
string filePath = argv[1];
string input;
generateStream(input, filePath);
if (input.size() <= 0){
cout << "Input file is empty\n";
return 0;
}
Scanner* s = new Scanner(input);
} catch (std::exception& e) {
cout << "Error: An error ocurred\n";
cout << "Check your expression and try again\n";
}
return 0;
}*/
|
f8584eb2362619c1c54f6adc1cf42c67ec87cff8
|
e2fc7e28cb7eb8f533b88ba1953e896c8668b2e9
|
/Real-Time-Rendering/RasterizeWireframe.cpp
|
35e3f1ca427d0c10e2e07a9fdf8c7f46ad497acc
|
[] |
no_license
|
AndrewJRichardson/Real-Time-Rendering
|
08d1c2bdf5529bcec5e4467cfb828206d34a0f41
|
86d84480856c63ceeb56fc3ea282328d9f402a19
|
refs/heads/master
| 2021-09-22T11:55:55.197414
| 2018-09-10T08:25:10
| 2018-09-10T08:25:10
| 106,158,968
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,019
|
cpp
|
RasterizeWireframe.cpp
|
#include "RasterizeWireframe.h"
//? Decide where to place bresenham method
//Renders objects in a wireframe mode (a line is drawn between vertexes)
//Currently uses bresenham line method
void rtr::RasterizeWireframe::operator()(FaceVertSet point1, FaceVertSet point2,
FaceVertSet point3, Device& device,
const Object&){
if (point1.v.x > 0 && point1.v.x < device.bufferWidth &&
point2.v.x > 0 && point2.v.x < device.bufferWidth &&
point3.v.x > 0 && point3.v.x < device.bufferWidth &&
point1.v.y > 0 && point1.v.y < device.bufferHeight &&
point2.v.y > 0 && point2.v.y < device.bufferHeight &&
point3.v.y > 0 && point3.v.y < device.bufferHeight){
if (point1.v.z >= 0 && point2.v.z >= 0) {
device.DrawLineBresenham(point1.v, point2.v);
}
if (point2.v.z >= 0 && point3.v.z >= 0) {
device.DrawLineBresenham(point2.v, point3.v);
}
if (point1.v.z >= 0 && point3.v.z >= 0) {
device.DrawLineBresenham(point3.v, point1.v);
}
}
}
|
640870e1272a302fc4e7714e4b894a79d647be6a
|
e6389d3cd6fe210fbe8a4a5c23531bab17eb40d0
|
/samples/type_name/test.cpp
|
a9bdd17eb9eda819217a1bd2286c28756636c5d2
|
[
"BSD-3-Clause"
] |
permissive
|
bigjun/mrpt
|
7b107cb35fbc2fefb2e456552695557780e0164c
|
99b922ed9aee1778e9d01780a70673ac3456031d
|
refs/heads/master
| 2021-01-21T09:11:25.927850
| 2013-12-12T18:27:07
| 2013-12-12T18:27:07
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,983
|
cpp
|
test.cpp
|
/* +---------------------------------------------------------------------------+
| The Mobile Robot Programming Toolkit (MRPT) |
| |
| http://www.mrpt.org/ |
| |
| Copyright (c) 2005-2013, Individual contributors, see AUTHORS file |
| Copyright (c) 2005-2013, MAPIR group, University of Malaga |
| Copyright (c) 2012-2013, University of Almeria |
| All rights reserved. |
| |
| Redistribution and use in source and binary forms, with or without |
| modification, are permitted provided that the following conditions are |
| met: |
| * Redistributions of source code must retain the above copyright |
| notice, this list of conditions and the following disclaimer. |
| * Redistributions in binary form must reproduce the above copyright |
| notice, this list of conditions and the following disclaimer in the |
| documentation and/or other materials provided with the distribution. |
| * Neither the name of the copyright holders nor the |
| names of its contributors may be used to endorse or promote products |
| derived from this software without specific prior written permission.|
| |
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR|
| PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE |
| FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL|
| DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR|
| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| POSSIBILITY OF SUCH DAMAGE. |
+---------------------------------------------------------------------------+ */
#include <mrpt/base.h>
#include <mrpt/graphs.h>
using namespace mrpt;
using namespace mrpt::utils;
using namespace mrpt::poses;
using namespace std;
/* ------------------------------------------------------------------------
Test: Type Names
Demonstration of MRPT's compile-time template TTypeName, which
recursively obtains the name of arbitrarily complex data types.
------------------------------------------------------------------------ */
void Test_TypeName()
{
cout << "Type: " << TTypeName<int32_t>::get() << endl;
cout << "Type: " << TTypeName<double>::get() << endl;
cout << "Type: " << TTypeName<CPose2D>::get() << endl;
// cout << "Type: " << TTypeName<mrpt::slam::COccupancyGridMap2D>::get() << endl;
cout << "Type: " << TTypeName<vector_double>::get() << endl;
cout << "Type: " << TTypeName<vector<int32_t> >::get() << endl;
cout << "Type: " << TTypeName<set<double> >::get() << endl;
cout << "Type: " << TTypeName<set< vector<double> > >::get() << endl;
cout << "Type: " << TTypeName<pair<int32_t,int32_t> >::get() << endl;
cout << "Type: " << TTypeName<pair<int32_t, pair<int32_t,int32_t> > >::get() << endl;
cout << "Type: " << TTypeName<map< double, set<int32_t> > >::get() << endl;
cout << "Type: " << TTypeName<set< multimap<double, pair<CPose3DPDFGaussian, /*COccupancyGridMap2D*/ CPose2D > > > >::get() << endl;
cout << "Type: " << TTypeName<CMatrixDouble33>::get() << endl;
cout << "Type: " << TTypeName<map<CMatrixDouble13,CMatrixFloat> >::get() << endl;
cout << "Type: " << TTypeName<CArrayNumeric<double,3> >::get() << endl;
cout << "Type: " << TTypeName<CArrayDouble<5> >::get() << endl;
cout << "Type: " << TTypeName< deque<vector<vector<int32_t> > > >::get() << endl;
// classes in mrpt::graphs
cout << "Type: " << TTypeName< mrpt::graphs::CNetworkOfPoses2D >::get() << endl;
}
// ------------------------------------------------------
// MAIN
// ------------------------------------------------------
int main(int argc, char **argv)
{
try
{
Test_TypeName();
return 0;
} catch (std::exception &e)
{
std::cout << "Exception: " << e.what() << std::endl;
return -1;
}
catch (...)
{
printf("Untyped exception!");
return -1;
}
}
|
7ab6e88f878dc24ac066123e53a3978bafa1d115
|
2d35b36c831db8a4f75f60f1e3ab9ac0d538dda2
|
/primer/lc/1261_find_elements_in_a_contaminated_binary_tree.cc
|
a8626729c5b31c127f5b5abcb0e0870960e32ba4
|
[] |
no_license
|
whutaihejin/repo
|
55ab38f29420e9674ae3f8e84d7c1ea0a085fb40
|
33137d826ae24dcd0b0552a4b44b7aae1c25a6e7
|
refs/heads/master
| 2022-05-02T16:34:13.302691
| 2022-04-16T04:40:01
| 2022-04-16T04:40:01
| 98,664,795
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,014
|
cc
|
1261_find_elements_in_a_contaminated_binary_tree.cc
|
#include <iostream>
#include <unordered_map>
// Definition for a binary tree node.
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
class FindElements {
public:
FindElements(TreeNode* root): root_(root) {
if (root) {
root->val = 0;
recover(root_);
}
}
bool find(int target) {
return map_.find(target) != map_.end();
}
private:
void recover(TreeNode* root) {
if (!root) return;
map_[root->val] = 1;
if (root->left) root->left->val = root->val * 2 + 1;
if (root->right) root->right->val = root->val * 2 + 2;
recover(root->left);
recover(root->right);
}
std::unordered_map<int, int> map_;
TreeNode* root_;
};
/**
* Your FindElements object will be instantiated and called as such:
* FindElements* obj = new FindElements(root);
* bool param_1 = obj->find(target);
*/
int main() {
return 0;
}
|
36d9930c8792a87c3345f293152119cdc35805be
|
4c0141feca9f48679aaf2b6d4bc7f7994e1cdda3
|
/light.hpp
|
285ddd8f7cef9454bde1c472c9f8c5b56e96f480
|
[] |
no_license
|
mchenwang/MLight2d
|
20b10d93ff1b14f7c40f9caa61adf207f5843a01
|
0cb4c78decbe45b3537d7e2fda2f92faeb96efb8
|
refs/heads/main
| 2023-04-27T09:36:07.320555
| 2021-05-14T13:19:18
| 2021-05-14T13:19:18
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,323
|
hpp
|
light.hpp
|
#ifndef __LIGHT_H__
#define __LIGHT_H__
#include <cmath>
namespace MLight {
struct color {
unsigned char r, g, b;
color(int r_=0, int g_=0, int b_=0) noexcept
: r(r_ < 255 ? r_ : 255), g(g_ < 255 ? g_ : 255), b(b_ < 255 ? b_ : 255) {}
};
template<typename T> struct point {
T x, y;
point() noexcept {}
template<typename U>
point(U x_, U y_) noexcept
: x((T)x_), y((T)y_) {}
};
using pointf = point<float>;
using pointi = point<int>;
class Light {
protected:
color light_color;
public:
Light() noexcept: light_color(color(255,255,255)) {}
Light(color c) noexcept: light_color(c) {}
virtual float getSDF(pointf p) const = 0;
color getColor() const { return light_color; }
};
class CircleLight: public Light {
pointf center;
float r;
public:
CircleLight() noexcept { }
CircleLight(pointf c_, float r_) noexcept
: center(c_), r(r_) {}
CircleLight(pointf c_, float r_, color c) noexcept
: Light(c), center(c_), r(r_) {}
virtual float getSDF(pointf p) const override {
float ux = p.x - center.x, uy = p.y - center.y;
return sqrt(ux * ux + uy * uy) - r;
}
};
}
#endif
|
b70945e92b32a35fa60dc362906a1e1453a389b2
|
5d83739af703fb400857cecc69aadaf02e07f8d1
|
/Archive2/9e/d4f4a452123398/main.cpp
|
fd24465d45748bc0fd4dfe0c2d386e41c5d93563
|
[] |
no_license
|
WhiZTiM/coliru
|
3a6c4c0bdac566d1aa1c21818118ba70479b0f40
|
2c72c048846c082f943e6c7f9fa8d94aee76979f
|
refs/heads/master
| 2021-01-01T05:10:33.812560
| 2015-08-24T19:09:22
| 2015-08-24T19:09:22
| 56,789,706
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,807
|
cpp
|
main.cpp
|
#include <algorithm>
#include <functional>
#include <iostream>
#include <utility>
#include <vector>
template<class FwdIt, class Equal = std::equal_to<>>
void cluster(FwdIt first, FwdIt last, Equal eq = Equal{})
{
for (auto it = first; it != last; /* increment inside loop */)
it = std::partition(it, last, [=](auto const& elem){
return eq(elem, *it);
});
}
template<class RndIt, class Equal = std::equal_to<>, class Compare = std::less<>>
void sort_within(RndIt first, RndIt last, Equal eq = Equal{}, Compare cmp = Compare{})
{
for (auto it = first; it != last; /* increment inside loop */) {
auto next = std::find_if_not(it, last, [=](auto const& elem){
return eq(elem, *it);
});
std::sort(it, next, cmp);
it = next;
}
}
int main()
{
using Elem = std::pair<int, int>;
auto v = std::vector<Elem> { {0,2}, {1,2}, {3,2}, {4,0}, {0,1}, {2,2}, {1,1}, {2,0}, {4,2}, {3,1} };
std::cout << "input data: \n";
for (auto&& e : v)
std::cout << "{" << e.first << "," << e.second << "}, ";
std::cout << "\n\n";
cluster(begin(v), end(v), [](auto const& L, auto const& R){
return L.first == R.first;
});
std::cout << "after clustering: \n";
for (auto&& e : v)
std::cout << "{" << e.first << "," << e.second << "}, ";
std::cout << "\n\n";
sort_within(begin(v), end(v),
[](auto const& L, auto const& R){ return L.first == R.first; },
[](auto const& L, auto const& R){ return L.second < R.second; }
);
std::cout << "after sorting within clusters: \n";
for (auto&& e : v)
std::cout << "{" << e.first << "," << e.second << "}, ";
std::cout << "\n";
}
|
93773f940bc3ea9a305a87e6f380210db3ffd6e2
|
6b40e9dccf2edc767c44df3acd9b626fcd586b4d
|
/NT/base/fs/hsm/inc/wsbdb.h
|
36978d4dea88f2881a13002b7c7e4618c85c872a
|
[] |
no_license
|
jjzhang166/WinNT5_src_20201004
|
712894fcf94fb82c49e5cd09d719da00740e0436
|
b2db264153b80fbb91ef5fc9f57b387e223dbfc2
|
refs/heads/Win2K3
| 2023-08-12T01:31:59.670176
| 2021-10-14T15:14:37
| 2021-10-14T15:14:37
| 586,134,273
| 1
| 0
| null | 2023-01-07T03:47:45
| 2023-01-07T03:47:44
| null |
WINDOWS-1252
|
C++
| false
| false
| 7,497
|
h
|
wsbdb.h
|
/*++
© 1998 Seagate Software, Inc. All rights reserved.
Module Name:
Wsbdb.h
Abstract:
These classes provide support for data bases.
Author:
Ron White [ronw] 19-Nov-1996
Revision History:
--*/
#ifndef _WSBDB_
#define _WSBDB_
// Are we defining imports or exports?
#if defined(IDB_IMPL)
#define IDB_EXPORT __declspec(dllexport)
#else
#define IDB_EXPORT __declspec(dllimport)
#endif
#include "wsbdef.h"
#include "wsbdbent.h"
#define IDB_MAX_REC_TYPES 16
#define IDB_MAX_KEYS_PER_REC 10
// Maximum key size in bytes; Jet limit is currently 255 so we limit
// all implementations
#define IDB_MAX_KEY_SIZE 255
// IDB_SYS_INIT_FLAG_* flags for use with IWsbDbSys::Init
#define IDB_SYS_INIT_FLAG_FULL_LOGGING 0x00000000 // I.e. the default
#define IDB_SYS_INIT_FLAG_LIMITED_LOGGING 0x00000001
#define IDB_SYS_INIT_FLAG_SPECIAL_ERROR_MSG 0x00000002
#define IDB_SYS_INIT_FLAG_NO_BACKUP 0x00000004
#define IDB_SYS_INIT_FLAG_NO_LOGGING 0x00000008
// IDB_CREATE_FLAG_* flags for use with IWsbDb::Create
#define IDB_CREATE_FLAG_NO_TRANSACTION 0x00000001
#define IDB_CREATE_FLAG_FIXED_SCHEMA 0x00000002
// IDB_DELETE_FLAG_* flags for use with IWsbDb::Delete
#define IDB_DELETE_FLAG_NO_ERROR 0x00000001
// IDB_DUMP_FLAG_* flags for use with IWsbDB::Dump
#define IDB_DUMP_FLAG_DB_INFO 0x00000001
#define IDB_DUMP_FLAG_REC_INFO 0x00000002
#define IDB_DUMP_FLAG_KEY_INFO 0x00000004
#define IDB_DUMP_FLAG_RECORDS 0x00000008
#define IDB_DUMP_FLAG_EVERYTHING 0x0000000F
#define IDB_DUMP_FLAG_RECORD_TYPE 0x00000010
#define IDB_DUMP_FLAG_APPEND_TO_FILE 0x00000100
// IDB_KEY_FLAG_* flags for use in IDB_KEY_INFO structure:
#define IDB_KEY_FLAG_DUP_ALLOWED 0x00000001 // Duplicate keys allowed
#define IDB_KEY_FLAG_PRIMARY 0x00000002 // Primary key
// IDB_KEY_INFO - data about record keys
// Note: Only one key per record type can be a primary key. The primary
// key can not be modified in a record. In general, the primary key is
// used for the physical clustering of the records in the DB.
typedef struct : _COM_IDB_KEY_INFO {
// ULONG Type; // Key type ID; must be > 0
// ULONG Size; // Key size in bytes
// ULONG Flags; // IDB_KEY_FLAG_* values
} IDB_KEY_INFO;
// IDB_REC_FLAG_* flags for use in IDB_REC_INFO structur
#define IDB_REC_FLAG_VARIABLE 0x00000001 // Record size is not fixed
// IDB_REC_INFO - data about IDB records
// Note: It there are multiple keys, the first key is taken as the
// default key to use for a new entity created by GetEntity.
typedef struct : _COM_IDB_REC_INFO {
IDB_KEY_INFO *Key; // Key info (must be allocated by derived DB object)
} IDB_REC_INFO;
// IDB_BACKUP_FLAG_* flags for use with IWsbDbSys::Backup
#define IDB_BACKUP_FLAG_AUTO 0x00000001 // Start auto backup thread
#define IDB_BACKUP_FLAG_FORCE_FULL 0x00000002 // Force a full backup
/*++
Class Name:
CWsbDb
Class Description:
The base class for a data base object.
--*/
class IDB_EXPORT CWsbDb :
public CWsbPersistable,
public IWsbDbPriv
{
public:
// CComObjectRoot
public:
STDMETHOD(FinalConstruct)(void);
void FinalRelease(void);
// IPersist
public:
STDMETHOD(GetClassID)(LPCLSID pclsid);
// IPersistStream
public:
STDMETHOD(GetSizeMax)(ULARGE_INTEGER* /*pSize*/) {
return(E_NOTIMPL); }
STDMETHOD(Load)(IStream* pStream);
STDMETHOD(Save)(IStream* pStream, BOOL clearDirty);
// IWsbDb
public:
STDMETHOD(Close)(IWsbDbSession* pSession);
STDMETHOD(Create)(OLECHAR* path, ULONG flags = 0);
STDMETHOD(Delete)(OLECHAR* path, ULONG flags = 0);
STDMETHOD(Dump)(OLECHAR* Filename, ULONG Flags, ULONG Data);
STDMETHOD(GetEntity)(IWsbDbSession* pSession, ULONG RecId, REFIID riid, void** ppEntity);
STDMETHOD(GetName)(OLECHAR** /*pName*/) { return(E_NOTIMPL); }
STDMETHOD(GetPath)(OLECHAR** /*pPath*/) { return(E_NOTIMPL); }
STDMETHOD(GetVersion)(ULONG* /*pVer*/) { return(E_NOTIMPL); }
STDMETHOD(Locate)(OLECHAR* path);
STDMETHOD(Open)(IWsbDbSession** ppSession);
// IWsbDbPriv - For internal use only!
STDMETHOD(GetKeyInfo)(ULONG RecType, USHORT nKeys, COM_IDB_KEY_INFO* pKeyInfo);
STDMETHOD(GetRecInfo)(ULONG RecType, COM_IDB_REC_INFO* pRecInfo);
STDMETHOD(Lock)(void) { CWsbPersistable::Lock(); return(S_OK); }
STDMETHOD(Unlock)(void) { CWsbPersistable::Unlock(); return(S_OK); }
STDMETHOD(GetJetIds)(JET_SESID SessionId, ULONG RecType,
JET_TABLEID* pTableId, ULONG* pDataColId);
STDMETHOD(GetJetIndexInfo)(JET_SESID SessionId, ULONG RecType, ULONG KeyType,
ULONG* pColId, OLECHAR** pName, ULONG bufferSize);
STDMETHOD(GetNewSQN)(ULONG /*RecType*/, ULONG* /*pSeqNum*/)
{ return(E_NOTIMPL); }
private:
HRESULT db_info_from_file_block(void* block);
HRESULT db_info_to_file_block(void* block);
HRESULT rec_info_from_file_block(int index, void* block);
HRESULT rec_info_to_file_block(int index, void* block);
HRESULT session_current_index(IWsbDbSession* pSession);
HRESULT jet_init(void);
HRESULT jet_make_index_name(ULONG key_type, char* pName, ULONG bufsize);
HRESULT jet_make_table_name(ULONG rec_type, char* pName, ULONG bufsize);
HRESULT jet_load_info(void);
HRESULT jet_save_info(void);
protected:
// Values to be supplied by derived class:
CComPtr<IWsbDbSys> m_pWsbDbSys; // Strong reference to DbSys object - ensures that
// this object dies after the DBs
// Note: CWsbDbSys must NOT have strong reference to
// objects of this class (WsbDb)
ULONG m_version; // DB version
USHORT m_nRecTypes; // Number of record (object) types
IDB_REC_INFO* m_RecInfo; // Record/key info (must be allocated
// by derived DB object)
// Not to be changed by derived class:
CWsbStringPtr m_path;
void * m_pImp; // Secret stuff
ULONG m_SessionIndex;
};
#define WSB_FROM_CWSBDB \
STDMETHOD(Close)(IWsbDbSession* pSession) \
{return(CWsbDb::Close(pSession));} \
STDMETHOD(Create)(OLECHAR* path, ULONG flags = 0) \
{return(CWsbDb::Create(path, flags));} \
STDMETHOD(Delete)(OLECHAR* path, ULONG flags = 0) \
{return(CWsbDb::Delete(path, flags));} \
STDMETHOD(Dump)(OLECHAR* Filename, ULONG Flags, ULONG Data) \
{return(CWsbDb::Dump(Filename, Flags, Data));} \
STDMETHOD(GetEntity)(IWsbDbSession* pSession, ULONG RecId, REFIID riid, void** ppEntity) \
{return(CWsbDb::GetEntity(pSession, RecId, riid, ppEntity));} \
STDMETHOD(GetName)(OLECHAR** pName) \
{return(CWsbDb::GetName(pName)); } \
STDMETHOD(GetPath)(OLECHAR** pPath) \
{return(CWsbDb::GetPath(pPath)); } \
STDMETHOD(GetVersion)(ULONG* pVer) \
{return(CWsbDb::GetVersion(pVer)); } \
STDMETHOD(Locate)(OLECHAR* path) \
{return(CWsbDb::Locate(path));} \
STDMETHOD(Open)(IWsbDbSession** ppSession) \
{return(CWsbDb::Open(ppSession));} \
#endif // _WSBDB_
|
82e6ec81d4899405e39d56c3541aeb1f3ba2e2fc
|
7c63a96fad4257f4959ffeba0868059fc96566fb
|
/cpp/std-17/m_bancila-modern_cpp_programming_cookbook/ch_01-core_lang/13-structured_bindings.cpp
|
1299db04d8479fd7412890bbf19fb03d4dbd44aa
|
[
"MIT"
] |
permissive
|
ordinary-developer/education
|
b426148f5690f48e0ed4853adfc3740bd038b72c
|
526e5cf86f90eab68063bb7c75744226f2c54b8d
|
refs/heads/master
| 2023-08-31T14:42:37.237690
| 2023-08-30T18:15:18
| 2023-08-30T18:15:18
| 91,232,306
| 8
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,898
|
cpp
|
13-structured_bindings.cpp
|
// region [how to do it]
#include <tuple>
#include <iostream>
namespace example_01
{
std::tuple<int, std::string, double> find() {
return std::make_tuple(1, "marius", 1234.5);
}
std::tuple<int, std::string, double> find2() {
return std::make_tuple(1, "marius2", 1234.5);
}
void run() {
auto [id, name, score] = find();
std::cout << name << std::endl;
if (auto [id, name, score] = find2(); score > 1000) {
std::cout << name << std::endl;
}
}
} // example_01
// endregion [how to do it]
// region [how it works]
#include <map>
#include <string>
namespace example_02
{
void run() {
std::map<int, std::string> m{};
auto result = m.insert({ 1, "one" });
std::cout << "inserted = " << result.second << std::endl
<< "value = " << result.first->second << std::endl;
}
} // example_02
#include <map>
#include <string>
namespace example_03 {
void run() {
std::map<int, std::string> m{};
std::map<int, std::string>::iterator it{};
bool inserted{};
std::tie(it, inserted) = m.insert({ 1, "one" });
std::cout << "inserted = " << inserted << std::endl
<< "value = " << it->second << std::endl;
std::tie(it, inserted) = m.insert({ 1, "two" });
std::cout << "inserted = " << inserted << std::endl
<< "value = " << it->second << std::endl;
}
} // example_03
#include <map>
#include <string>
namespace example_04
{
void run() {
std::map<int, std::string> m{};
{
auto [it, inserted] = m.insert({ 1, "one" });
std::cout << "inserted = " << inserted << std::endl
<< "value = " << it->second << std::endl;
}
{
auto [it, inserted] = m.insert({ 1, "two" });
std::cout << "inserted = " << inserted << std::endl
<< "value = " << it->second << std::endl;
}
}
} // example_04
#include <iostream>
#include <map>
#include <string>
namespace example_05 {
void run() {
std::map<int, std::string> m{};
if (auto [it, inserted] = m.insert({ 1, "two" }); inserted) {
std::cout << it->second << std::endl;
}
}
} // namespace example_05
// endregion [how it dorks]
#include <iostream>
int main() {
std::cout << "example_01 =>" << std::endl;
example_01::run();
std::cout << std::endl << std::endl;
std::cout << "example_02 =>" << std::endl;
example_02::run();
std::cout << std::endl << std::endl;
std::cout << "example_03 =>" << std::endl;
example_03::run();
std::cout << std::endl << std::endl;
std::cout << "example_04 =>" << std::endl;
example_04::run();
std::cout << std::endl << std::endl;
std::cout << "example_05 =>" << std::endl;
example_05::run();
std::cout << std::endl << std::endl;
std::cout << "DONE" << std::endl;
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.