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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
49223de3e8d99efd757c99c9819e9a1b46c9770c | cc63466d8a66bb8925508791c007c0054149ce5a | /msj_archives/code/Msj1296.src/Thin Client/ChangeValueFrame.cpp | ab5956d8d39fcdc9a3a7d781aba470b33adf021b | [
"Unlicense"
] | permissive | liumorgan/misc-code | 9675cc258162064083126a22d97902dae36739c9 | d47a8d1cc41f19701ce628c9f15976bb5baa239d | refs/heads/master | 2022-06-29T20:41:54.288305 | 2020-05-13T00:20:05 | 2020-05-13T00:20:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,270 | cpp | ChangeValueFrame.cpp | // ChangeValueFrame.cpp
#include "stdeos.hpp" // this header file must be first for precompiled headers to work
#ifndef CHANGEVALUEFRAME_HPP
#include <ChangeValueFrame.hpp>
#endif
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
//ChangeValueFrame
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
ChangeValueFrame::ChangeValueFrame() : EosFramework(),
value()
{
CONNECT_ChangeValueFrame()
}
ChangeValueFrame::ChangeValueFrame(const ChangeValueFrame& src) : EosFramework(src),
value(src.value)
{
CONNECT_ChangeValueFrame()
}
ChangeValueFrame::~ChangeValueFrame()
{
disconnect();
}
ChangeValueFrame& ChangeValueFrame::operator =(const ChangeValueFrame& src)
{
EOS_PROBE_LOCK(*this);
if (this != &src)
{
EosFramework::operator=(src);
value = src.value;
}
return *this;
}
void ChangeValueFrame::add()
{
value += 15;
}
void ChangeValueFrame::subtract()
{
value -= 15;
}
//BEGIN EOS BIND >>>>>> Don't edit this comment //////////////////////////////////////////////////
// This part Copyright (c) 1992-1996 ViewSoft, Inc. All Rights Reserved.
EOS_IMPLEMENT_REF(ChangeValueFrame,EosFramework)
extern void EOS_NVNV_prim(EosObject&,EosProbeMemberPointer&,EosParameterList&);
EOS_BND()
EOS_FNOFT_H(ChangeValueFrame)
EOS_FNOFT_V(ChangeValueFrame,void,(),0)
EOS_FNOFT_V(ChangeValueFrame,void,(),1)
EOS_FNOFT_T(ChangeValueFrame)
EOS_FNOFT_E(ChangeValueFrame,add,EOS_NVNV_prim)
EOS_FNOFT_E(ChangeValueFrame,subtract,EOS_NVNV_prim)
EOS_FNOFT_ET(ChangeValueFrame)
EOS_FNOPT_H(ChangeValueFrame,EosFramework,2)
EOS_FNOPT_E(ChangeValueFrame,0)
EOS_FNOPT_E(ChangeValueFrame,1)
EOS_FNOPT_T(ChangeValueFrame)
EOS_FIOFT_H(ChangeValueFrame)
EOS_FIOFT_V(ChangeValueFrame,EosInt,0)
EOS_FIOFT_T(ChangeValueFrame)
EOS_FIOFT_E(ChangeValueFrame,value)
EOS_FIOFT_ET(ChangeValueFrame)
EOS_FIOPT_H(ChangeValueFrame,EosFramework,1)
EOS_FIOPT_E(ChangeValueFrame,0,0)
EOS_FIOPT_T(ChangeValueFrame)
EOS_CTC(ChangeValueFrame,0,CHANGEVALUE)
EOS_CREATE(ChangeValueFrame)
EOS_GET_MO(ChangeValueFrame)
//END EOS BIND >>>>>> Don't edit this comment //////////////////////////////////////////////////
|
32e7107671e9235bfcb76d743731cf23ccaf2bee | 7816a4e09ad76831011ecda4f1bf2b93d8943483 | /factorial.cpp | 3da8a98d30686fa9e4559f789a2c6a76bf361e14 | [] | no_license | sbhattarai5/google-test | e5bda3e2f0ceae06ccf7a16ed2da384982d07340 | 6f6dffc7c2c417c9265c7c1fa95f7af5a996ec33 | refs/heads/master | 2023-03-26T18:52:16.710228 | 2021-03-21T00:19:36 | 2021-03-21T00:19:36 | 349,863,387 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 835 | cpp | factorial.cpp | #include <gtest/gtest.h> // including the library
int factorial(int n)
{
if (n < 0) return -1; // invalid case
int prod = 1;
while (n != 0)
{
prod *= n--;
}
return prod;
}
TEST(FactorialTest, ZeroTest) // for factorial of Zero
{
EXPECT_EQ(1, factorial(0));
}
TEST(FactorialTest, PosTest) // for factorial of Positive Numbers
{
EXPECT_EQ(120, factorial(5));
EXPECT_EQ(1, factorial(1));
EXPECT_EQ(6, factorial(3));
}
TEST(FactorialTest, NegTest) // for factorial of Negative Numbers
{
EXPECT_EQ(-1, factorial(-5));
EXPECT_EQ(-1, factorial(-1));
EXPECT_EQ(-1, factorial(-10));
}
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv); // initializing it
return RUN_ALL_TESTS(); // this will run all your tests
}
|
74a95902adabdfa80a9ddff4e6fdfb6a18e8c87e | b20353e26e471ed53a391ee02ea616305a63bbb0 | /trunk/game/gas/GameGas/CMagicOpCfgArg.h | 8bee417777a054b86a7187d6a0b807001616edeb | [] | no_license | trancx/ybtx | 61de88ef4b2f577e486aba09c9b5b014a8399732 | 608db61c1b5e110785639d560351269c1444e4c4 | refs/heads/master | 2022-12-17T05:53:50.650153 | 2020-09-19T12:10:09 | 2020-09-19T12:10:09 | 291,492,104 | 0 | 0 | null | 2020-08-30T15:00:16 | 2020-08-30T15:00:15 | null | UTF-8 | C++ | false | false | 4,864 | h | CMagicOpCfgArg.h | #pragma once
#include "CCfgArg.h"
class CNormalSkillServerSharedPtr;
class CMagicStateCfgServerSharedPtr;
class CTriggerStateCfgServerSharedPtr;
class CDamageChangeStateCfgServerSharedPtr;
class CCumuliTriggerStateCfgServerSharedPtr;
class CSpecialStateCfgServerSharedPtr;
class CAureMagicCfgServerSharedPtr;
class CMoveMagicCfgServerSharedPtr;
class CTransferableMagicCfgServerSharedPtr;
class CBulletMagicCfgServerSharedPtr;
class CPositionMagicCfgServerSharedPtr;
class CCastingProcessCfgServerSharedPtr;
class CShockWaveMagicCfgServerSharedPtr;
class CBarrierMagicCfgServerSharedPtr;
class CMagicEffServerSharedPtr;
class CBaseStateCfg;
class CPlayerSkillCfgArg
:public CCfgArg
{
public:
CPlayerSkillCfgArg(CNormalSkillServerSharedPtr* pCfg,uint32 uSkillLevel);
~CPlayerSkillCfgArg(){}
CNormalSkillServerSharedPtr* m_pCfg;
uint32 m_uSkillLevel;
};
class CTriggerStateCfgArg
:public CCfgArg
{
public:
CTriggerStateCfgArg(CTriggerStateCfgServerSharedPtr* pCfg);
~CTriggerStateCfgArg(){};
CTriggerStateCfgServerSharedPtr* m_pCfg;
};
class CAureMagicCfgArg
:public CCfgArg
{
public:
CAureMagicCfgArg(CAureMagicCfgServerSharedPtr* pCfg);
CAureMagicCfgServerSharedPtr* m_pCfg;
};
class CMagicStateCfgArg
:public CCfgArg
{
public:
CMagicStateCfgArg(CMagicStateCfgServerSharedPtr* pCfg);
CMagicStateCfgServerSharedPtr* m_pCfg;
};
class CMagicStateCfgMultiArg
:public CMagicStateCfgArg
{
public:
CMagicStateCfgMultiArg(CMagicStateCfgServerSharedPtr* pCfg, const string& szArg);
~CMagicStateCfgMultiArg();
CCfgCalc* m_pArg;
};
class CDamageChangeStateCfgArg
:public CCfgArg
{
public:
CDamageChangeStateCfgArg(CDamageChangeStateCfgServerSharedPtr* pCfg);
~CDamageChangeStateCfgArg(){}
CDamageChangeStateCfgServerSharedPtr* m_pCfg;
};
class CCumuliTriggerStateCfgArg
:public CCfgArg
{
public:
CCumuliTriggerStateCfgArg(CCumuliTriggerStateCfgServerSharedPtr* pCfg);
~CCumuliTriggerStateCfgArg(){};
CCumuliTriggerStateCfgServerSharedPtr* m_pCfg;
};
class CSpecialStateCfgArg
:public CCfgArg
{
public:
CSpecialStateCfgArg(CSpecialStateCfgServerSharedPtr* pCfg);
~CSpecialStateCfgArg(){}
CSpecialStateCfgServerSharedPtr* m_pCfg;
};
class CMoveMagicCfgArg
:public CCfgArg
{
public:
CMoveMagicCfgArg(CMoveMagicCfgServerSharedPtr* pCfg);
~CMoveMagicCfgArg(){}
CMoveMagicCfgServerSharedPtr* m_pCfg;
};
class CMoveMagicCfgMultiArg
:public CCfgArg
{
public:
CMoveMagicCfgMultiArg(CMoveMagicCfgServerSharedPtr* pCfg, const string& szArg);
~CMoveMagicCfgMultiArg();
CMoveMagicCfgServerSharedPtr* m_pCfg;
CCfgCalc* m_pArg;
};
class CTransferableMagicCfgArg
:public CCfgArg
{
public:
CTransferableMagicCfgArg(CTransferableMagicCfgServerSharedPtr* pCfg);
CTransferableMagicCfgServerSharedPtr* m_pCfg;
};
class CBulletMagicCfgArg
:public CCfgArg
{
public:
CBulletMagicCfgArg(CBulletMagicCfgServerSharedPtr* pCfg);
CBulletMagicCfgServerSharedPtr* m_pCfg;
};
class CPositionMagicCfgArg
:public CCfgArg
{
public:
CPositionMagicCfgArg(CPositionMagicCfgServerSharedPtr* pCfg, const string& szArg);
~CPositionMagicCfgArg();
CPositionMagicCfgServerSharedPtr* m_pCfg;
CCfgCalc* m_pArg;
};
class CDelayPositionMagicCfgArg
:public CCfgArg
{
public:
CDelayPositionMagicCfgArg(uint32 uDelayTime, CPositionMagicCfgServerSharedPtr* pCfg);
~CDelayPositionMagicCfgArg();
uint32 m_uDelayTime;
CPositionMagicCfgServerSharedPtr* m_pCfg;
};
class CShockWaveMagicCfgArg
:public CCfgArg
{
public:
CShockWaveMagicCfgArg(CShockWaveMagicCfgServerSharedPtr* pCfg);
CShockWaveMagicCfgServerSharedPtr* m_pCfg;
};
class CBarrierMagicCfgArg
:public CCfgArg
{
public:
CBarrierMagicCfgArg(CBarrierMagicCfgServerSharedPtr* pCfg);
CBarrierMagicCfgServerSharedPtr* m_pCfg;
};
class CMagicEffCfgArg
:public CCfgArg
{
public:
CMagicEffCfgArg(CMagicEffServerSharedPtr* pCfg, const string& szArg);
~CMagicEffCfgArg();
CMagicEffServerSharedPtr* m_pCfg;
CCfgCalc* m_pArg;
};
class CBaseStateCfgArg
:public CCfgArg
{
public:
CBaseStateCfgArg(CBaseStateCfg* pCfg);
CBaseStateCfg* m_pCfg;
};
class CDisplayMsgCfgArg
:public CCfgArg
{
public:
CDisplayMsgCfgArg(uint32 uArg1, const string& szArg2);
uint32 m_uArg1;
string m_strArg2;
};
class CTwoCfgCalcArg
:public CCfgArg
{
public:
CTwoCfgCalcArg(const string& szArg1, const string& szArg2);
~CTwoCfgCalcArg();
CCfgCalc* m_pArg1;
CCfgCalc* m_pArg2;
};
class CTwoStringArg
:public CCfgArg
{
public:
CTwoStringArg(const string& szArg1, const string& szArg2);
string m_strArg1;
string m_strArg2;
};
class CPosDelayCreateNPCArg
:public CCfgArg
{
public:
CPosDelayCreateNPCArg(uint32 uArg1, const string& szArg2);
uint32 m_uArg1;
string m_strArg2;
};
|
4d7ab48501afaf93baff341321e43c683a03f0c7 | 7233691d7aa83bb3e93cc4d4c472c99c332f39cc | /1114.cpp | 2af507b03717d31c1c0071d775ccd38a03777cdf | [] | no_license | Sawom/URI-problem-solving | 708f0cecfde0b104e821b7e2cd0ce72880534614 | d71a38416912e894da8e312b28d1f3f3e77ad528 | refs/heads/main | 2023-08-24T20:03:43.539695 | 2021-09-21T10:46:36 | 2021-09-21T10:46:36 | 311,331,842 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 289 | cpp | 1114.cpp | #include<iostream>
using namespace std;
int main(){
int x;
while(1){
cin>>x;
if(x==2002){
cout<<"Acesso Permitido"<<endl;
break;
}
else{
cout<<"Senha Invalida"<<endl;
}
}
return 0;
}
|
af55c19a1f78ca19252bcad4b428040e8d1f094b | 025e31348577d6081e0839ff2d9765d2fa4ef8e0 | /Segundo Semestre 2018-2/IPOO/Clases/Herencia_Polimorfismo/3/Main.cpp | da7101a8f8922f93513759c207890dbafd4dc74f | [] | no_license | camilojm27/Universidad | 0d777644d021049b2c238af623df67f70ce8c29b | 7ce4f0fbfa65d68414555b1f670b6ad59c10293e | refs/heads/master | 2022-01-15T18:45:51.915970 | 2019-07-27T16:10:03 | 2019-07-27T16:10:03 | 150,368,266 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,086 | cpp | Main.cpp | /*
Archivo: Main.cpp
Autor: Ángel García Baños
Email: angel.garcia@correounivalle.edu.co
Fecha creación: 2019-03-08
Fecha última modificación: 2019-03-08
Versión: 0.1
Licencia: GPL
*/
// Utilidad: Entender la herencia con polimorfismo (una única interfaz con muchas implementaciones).
// El polimorfismo significa que puedo acceder a una colección de objetos de clases distintas
// de manera uniforme, sin diferenciarlos. El único requerimiento es que hereden de la misma
// clase base.
// Es decir, puedo guardarlos en el mismo array, a pesar de ser de tipos distintos. Y puedo acceder
// a ellos por medio de un puntero a la clase base.
// La principal ventaja de la herencia es que permite polimorfismo.
// En lenguajes como Ruby el polimorfismo existe siempre, es automático y no hay que hacer nada para
// conseguirlo. En lenguajes como C++ y Java, para conseguir polimorfismo hay que crear un árbol de
// herencia.
// En este ejemplo vamos a desarrollar lo básico de un programa de dibujo, que permite manejar círculos,
// rectánculos y triángulos isósceles.
#include "Figura.h"
#include "Rectangulo.h"
#include "Circulo.h"
#include "TrianguloIsosceles.h"
#include<iostream>
using namespace std;
int main()
{
// Figura a("aaaa", 2,3); // No se puede fabricar este objeto porque le faltan las funciones virtuales puras.
int cantidadDeFiguras=5;
Figura **misFiguras = new Figura*[cantidadDeFiguras];
misFiguras[0] = new Rectangulo(10,20);
misFiguras[1] = new TrianguloIsosceles(40,30);
misFiguras[2] = new TrianguloIsosceles(20,80);
misFiguras[3] = new Circulo(100,100);
misFiguras[4] = new Rectangulo(2,5);
for(int cualFigura=0; cualFigura<cantidadDeFiguras; cualFigura++)
cout << "Figura: " << misFiguras[cualFigura]->comoTeLlamas() << " Área= "
<< misFiguras[cualFigura]->area() << " Perímetro= "
<< misFiguras[cualFigura]->perimetro() << endl;
for(int cualFigura=0; cualFigura<cantidadDeFiguras; cualFigura++)
delete misFiguras[cualFigura];
delete [] misFiguras;
return 0;
}
|
6d7bb9ceeeba51cfd1b4272af13593975eca4dbb | f90372c080cbd63ab6da7fc0deb310327335972f | /String/PalindromicAutoMaton/[URAL2040]PalindromesAndSuperAbilities2(回文自动机).cpp | d779ab9da317321d9a7dfbd3483001699690c166 | [] | no_license | EbolaEmperor/OI-Learning | 7382b2c7d72516dd4cd1ac129348c2d7ff546645 | 14b3d5efbf671e39421258cbfd65e9e21991faec | refs/heads/master | 2020-04-01T19:40:44.675796 | 2019-07-13T13:12:50 | 2019-07-13T13:12:50 | 153,566,156 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 700 | cpp | [URAL2040]PalindromesAndSuperAbilities2(回文自动机).cpp | #include<bits/stdc++.h>
using namespace std;
const int MAXN=5000010;
char ss[MAXN];
int s[MAXN],n;
int ch[MAXN][2],sz;
int fail[MAXN],lst;
int len[MAXN];
int newnode(int l){len[++sz]=l;return sz;}
void init()
{
sz=-1;
n=lst=0;
newnode(0);
newnode(-1);
fail[0]=1;
s[0]=-1;
}
int find(int p)
{
while(s[n]!=s[n-len[p]-1]) p=fail[p];
return p;
}
bool insert(int c)
{
bool flag=0;
s[++n]=c;
int cur=find(lst);
if(!ch[cur][c])
{
flag=1;
int now=newnode(len[cur]+2);
fail[now]=ch[find(fail[cur])][c];
ch[cur][c]=now;
}
lst=ch[cur][c];
return flag;
}
int main()
{
scanf("%s",ss);
init();
int l=strlen(ss);
for(int i=0;i<l;i++)
printf("%d",insert(ss[i]-'a'));
return 0;
}
|
352e8306ddf1fca97b5866445cb5f1c6889e621d | fb127294ed7fb48e37342ca0950a34015fe8bd4e | /components/game_mod/r_stream.cpp | c94ff0a33f5fc6e9b212e47150b0b43b3af561ce | [] | no_license | Nukem9/LinkerMod | 89c826f42cfc0aabe111002ca3696df07ac156c9 | 72ee05bbf42dfb2a1893e655788b631be63ea317 | refs/heads/development | 2021-07-14T16:23:00.813862 | 2020-04-09T05:05:38 | 2020-04-09T05:05:38 | 30,128,803 | 134 | 56 | null | 2021-04-04T14:04:54 | 2015-01-31T22:35:11 | C++ | UTF-8 | C++ | false | false | 58,602 | cpp | r_stream.cpp | #include "stdafx.h"
#define IMAGE_BIT_IS_SET(var, bits) ((var)[BIT_INDEX_32(bits)] & BIT_MASK_32(bits))
#define IMAGE_BIT_SET(var, bits) ((var)[BIT_INDEX_32(bits)] |= BIT_MASK_32(bits));
#define IMAGE_BIT_UNSET(var, bits) ((var)[BIT_INDEX_32(bits)] &= ~BIT_MASK_32(bits));
GfxWorld*& rgp_world = *(GfxWorld **)0x0396A24C;
GfxWorldDpvsStatic*& g_worldDpvs = *(GfxWorldDpvsStatic **)0x0460C0AC;
StreamFrontendGlob streamFrontendGlob;
pendingRequest s_pendingRequests[STREAM_MAX_REQUESTS];
DObj *s_forcedLoadEntities[4];
int s_numForcedLoadEntities;
streamerHintInfo s_streamHints[4];
int s_numStreamHintsActive;
Material *s_preventMaterials[32];
bool streamIsInitialized;
volatile long disableCount;
float4 __declspec(align(16)) s_viewPos;
// /gfx_d3d/r_stream.cpp:266
bool R_StreamIsEnabled()
{
return disableCount == 0;
}
// /gfx_d3d/r_stream.cpp:271
void R_StreamPushDisable()
{
InterlockedIncrement(&disableCount);
}
// /gfx_d3d/r_stream.cpp:276
void R_StreamPopDisable()
{
int value = InterlockedDecrement(&disableCount);
ASSERT_MSG(value >= 0, "disableCount >= 0");
}
// /gfx_d3d/r_stream.cpp:283
void R_StreamSetInitData(int buffer_size)
{
streamFrontendGlob.mainBufferSize = buffer_size;
}
// /gfx_d3d/r_stream.cpp:288
void R_StreamSetDefaultConfig(bool clear)
{
streamFrontendGlob.forceDiskOrder = false;
streamFrontendGlob.touchedImageImportance = FLT_MAX / 2.0f;
streamFrontendGlob.initialImageImportance = FLT_MAX / 4.0f;
streamFrontendGlob.forcedImageImportance = FLT_MAX / 2.0f;
if (clear)
{
memset(streamFrontendGlob.imageInitialBits, 0, sizeof(streamFrontendGlob.imageInitialBits));
memset(streamFrontendGlob.imageForceBits, 0, sizeof(streamFrontendGlob.imageForceBits));
streamFrontendGlob.imageInitialBitsSet = false;
streamFrontendGlob.initialLoadAllocFailures = 0;
streamFrontendGlob.preloadCancelled = false;
}
streamFrontendGlob.diskOrderImagesNeedSorting = true;
}
// /gfx_d3d/r_stream.cpp:308
void R_StreamSetUIConfig(bool clear)
{
R_StreamSetDefaultConfig(clear);
streamFrontendGlob.forceDiskOrder = true;
streamFrontendGlob.touchedImageImportance = FLT_MAX / 2.0f;
streamFrontendGlob.initialImageImportance = FLT_MAX / 4.0f;
streamFrontendGlob.forcedImageImportance = 0.00001f;
}
// /gfx_d3d/r_stream.cpp:366
float R_Stream_GetProgress()
{
if (!com_waitForStreamer->current.integer)
return 1.0f;
if (streamFrontendGlob.initialLoadAllocFailures > 0)
return 1.0f;
if (streamFrontendGlob.imageInitialBitsSet)
{
int total = 0;
int complete = 0;
for (int idx = 0; idx < STREAM_MAX_IMAGE_BITS; idx++)
{
unsigned int bits = streamFrontendGlob.imageInitialBits[idx] | streamFrontendGlob.imageForceBits[idx];
total += CountBitsEnabled(bits);
complete += CountBitsEnabled(streamFrontendGlob.imageUseBits[idx] & bits);
}
// If (any images were pending)
if (total > 0)
return (float)complete / (float)total + 0.001f;
// No images waiting, so it's considered complete
return 1.0f;
}
return 0.0f;
}
// /gfx_d3d/r_stream.cpp:734
void R_Stream_InvalidateRequest(pendingRequest *request)
{
memset(request, 0, sizeof(pendingRequest));
request->status = STREAM_STATUS_INVALID;
}
// /gfx_d3d/r_stream.cpp:746
stream_status R_StreamRequestImageAllocation(pendingRequest *request, GfxImage *image, bool highMip, float importance)
{
ASSERT(image);
ASSERT(request);
ASSERT(image->streaming != GFX_TEMP_STREAMING);
ASSERT(image->streaming != GFX_NOT_STREAMING);
if (image->streaming == GFX_NOT_STREAMING)
return STREAM_STATUS_EOF;
ASSERT(request->image == nullptr);
ASSERT(request->status == STREAM_STATUS_INVALID);
request->image = image;
request->imagePart = 0;
request->importance = importance;
request->startTime = Sys_Milliseconds();
request->bufferSize = 0;
request->buffer = nullptr;
request->highMip = highMip;
if (r_streamLog && r_streamLog->current.integer > 0)
{
Com_PrintMessage(
16,
va(
"-STREAM-allocation complete. bytes=%d,image=%s,importance=%f\n",
request->bufferSize,
image->name,
importance),
0);
}
int imageIndex = DB_GetImageIndex(image);
ASSERT(!IMAGE_BIT_IS_SET(streamFrontendGlob.imageLoading, imageIndex));
IMAGE_BIT_SET(streamFrontendGlob.imageLoading, imageIndex);
request->status = STREAM_STATUS_PRE;
request->id[0] = -1;
return STREAM_STATUS_INPROGRESS;
}
// /gfx_d3d/r_stream.cpp:813
void R_StreamUpdate_ReadTextures()
{
static int lastIdx = 0;
R_StreamAlloc_Lock();
pendingRequest *request = nullptr;
int numRequests = 0;
for (int i = 0; i < STREAM_MAX_REQUESTS; i++)
{
int idx = (lastIdx + i) % STREAM_MAX_REQUESTS;
if (s_pendingRequests[idx].status != STREAM_STATUS_QUEUED)
continue;
if (!request)
{
request = &s_pendingRequests[idx];
request->status = STREAM_STATUS_INPROGRESS;
lastIdx = (idx + 1) % STREAM_MAX_REQUESTS;
}
numRequests++;
}
// Create a temporary struct copy of the image (reason unknown)
GfxImage tempImage;
bool tempHighMip = false;
if (request)
{
tempHighMip = request->highMip;
memcpy(&tempImage, request->image, sizeof(GfxImage));
}
// Allow other threads to use the global request array
R_StreamAlloc_Unlock();
if (request)
{
char *tempBuffer;
int tempBufferSize;
bool status = Image_LoadToBuffer(&tempImage, tempHighMip, &tempBuffer, &tempBufferSize);
// Image done loading, so lock the array again
R_StreamAlloc_Lock();
{
if (request->status == STREAM_STATUS_INPROGRESS)
{
if (status)
{
// Now copy the temporary struct back over
request->status = STREAM_STATUS_FINISHED;
request->buffer = tempBuffer;
request->bufferSize = tempBufferSize;
memcpy(request->image, &tempImage, sizeof(GfxImage));
}
else
{
request->status = STREAM_STATUS_CANCELLED;
}
}
else
{
Z_VirtualFree(tempBuffer, 20);
}
}
R_StreamAlloc_Unlock();
Sleep(1);
}
// Tell Stream_Thread if there are more requests pending
if (numRequests > 1)
Sys_WakeStream();
}
// /gfx_d3d/r_stream.cpp:856
bool R_StreamRequestImageRead(pendingRequest *request)
{
GfxImage *unloadImage = nullptr;
GfxImage *image = request->image;
int imageIndex = DB_GetImageIndex(image);
request->status = STREAM_STATUS_QUEUED;
if (!request->highMip)
{
Sys_WakeStream();
return true;
}
if (R_StreamAlloc_CanAllocate(image->baseSize, request->importance, &unloadImage) && unloadImage)
{
// Find the next free pending request entry
pendingRequest *unloadRequest = nullptr;
for (int i = 0; i < STREAM_MAX_REQUESTS; i++)
{
if (s_pendingRequests[i].status == STREAM_STATUS_INVALID)
{
unloadRequest = &s_pendingRequests[i];
break;
}
}
// Queue the request to read the image
if (unloadRequest)
{
int unloadImagePartIndex = DB_GetImageIndex(unloadImage);
ASSERT(IMAGE_BIT_IS_SET(streamFrontendGlob.imageUseBits, unloadImagePartIndex));
if (R_StreamRequestImageAllocation(
unloadRequest,
unloadImage,
false,
streamFrontendGlob.imageImportance[unloadImagePartIndex])
&& R_StreamRequestImageRead(unloadRequest))
{
unloadImage = nullptr;
}
}
}
if (!unloadImage)
{
Sys_WakeStream();
return true;
}
IMAGE_BIT_UNSET(streamFrontendGlob.imageLoading, imageIndex);
R_Stream_InvalidateRequest(request);
return false;
}
// /gfx_d3d/r_stream.cpp:1127
float PointDistSqFromBounds(const float *v, const float *mins, const float *maxs)
{
float distBelowMin;
float distAboveMax;
distBelowMin = mins[0] - v[0];
distAboveMax = v[0] - maxs[0];
double xDist = max(distBelowMin, 0.0) + max(distAboveMax, 0.0);
distBelowMin = mins[1] - v[1];
distAboveMax = v[1] - maxs[1];
double yDist = max(distBelowMin, 0.0) + max(distAboveMax, 0.0);
distBelowMin = mins[2] - v[2];
distAboveMax = v[2] - maxs[2];
double zDist = max(distBelowMin, 0.0) + max(distAboveMax, 0.0);
return (float)((xDist * xDist) + (yDist * yDist) + (zDist * zDist));
}
// /gfx_d3d/r_stream.cpp:1169
bool R_StreamUpdate_ProcessFileCallbacks()
{
bool workDone = false;
for (int i = 0; i < STREAM_MAX_REQUESTS; i++)
{
pendingRequest *request = &s_pendingRequests[i];
// Skip invalid statuses for this function
if (request->status == STREAM_STATUS_INVALID ||
request->status == STREAM_STATUS_PRE ||
request->status == STREAM_STATUS_QUEUED ||
request->status == STREAM_STATUS_INPROGRESS)
continue;
GfxImage *image = request->image;
ASSERT(image != nullptr);
int imageIndex = DB_GetImageIndex(image);
ASSERT(IMAGE_BIT_IS_SET(streamFrontendGlob.imageLoading, imageIndex));
// Unset the imageLoading bit when the request is 'finished'
if (request->status == STREAM_STATUS_CANCELLED ||
request->status == STREAM_STATUS_READFAILED ||
request->status == STREAM_STATUS_EOF)
{
IMAGE_BIT_UNSET(streamFrontendGlob.imageLoading, imageIndex);
Z_VirtualFree(request->buffer, 20);
R_Stream_InvalidateRequest(request);
continue;
}
workDone = true;
ASSERT(request->status == STREAM_STATUS_FINISHED);
if (Sys_IsRenderThread())
{
GfxImage temp;
memcpy(&temp, image, sizeof(temp));
image->texture.basemap->AddRef();
Image_Release(image);
ASSERT(!image->texture.basemap);
GfxImageFileHeader *fileHeader = (GfxImageFileHeader *)request->buffer;
char *imageData = request->buffer + sizeof(GfxImageFileHeader);
Image_LoadFromData(image, fileHeader, imageData, 2);
Z_VirtualFree(fileHeader, 20);
if (!image->texture.basemap)
{
Image_Release(image);
memcpy(image, &temp, sizeof(temp));
}
else
{
temp.texture.basemap->Release();
}
}
else
{
((void(__cdecl *)(GfxImage *, char *))0x006FC1E0)(image, request->buffer);
// RB_Resource_ReloadTexture(image, request->buffer);
}
if (request->highMip)
{
ASSERT(!IMAGE_BIT_IS_SET(streamFrontendGlob.imageUseBits, imageIndex));
IMAGE_BIT_SET(streamFrontendGlob.imageUseBits, imageIndex);
}
else
{
ASSERT(IMAGE_BIT_IS_SET(streamFrontendGlob.imageUseBits, imageIndex));
IMAGE_BIT_UNSET(streamFrontendGlob.imageUseBits, imageIndex);
}
IMAGE_BIT_UNSET(streamFrontendGlob.imageLoading, imageIndex);
R_Stream_InvalidateRequest(request);
}
return workDone;
}
// /gfx_d3d/r_stream.cpp:1409
void R_StreamUpdate_SetupInitialImageList()
{
R_StreamSetDefaultConfig(true);
if (r_streamLowDetail && r_streamLowDetail->current.enabled)
R_Stream_ForceLoadLowDetail();
else
memset(streamFrontendGlob.imageForceBits, 0, sizeof(streamFrontendGlob.imageForceBits));
streamFrontendGlob.diskOrderImagesNeedSorting = true;
streamFrontendGlob.imageInitialBitsSet = true;
streamFrontendGlob.initialLoadAllocFailures = 0;
streamFrontendGlob.preloadCancelled = true;
}
// /gfx_d3d/r_stream.cpp:???
void R_Stream_ForceLoadLowDetail()
{
// Code removed completely
}
// /gfx_d3d/r_stream.cpp:1463
void R_StreamUpdate_AddInitialImages(float importance)
{
for (int imagePartIndex = 0; imagePartIndex < STREAM_MAX_IMAGES; imagePartIndex++)
{
if (IMAGE_BIT_IS_SET(streamFrontendGlob.imageInitialBits, imagePartIndex))
R_Stream_AddImagePartImportance(imagePartIndex, importance);
}
}
// /gfx_d3d/r_stream.cpp:1474
void R_StreamUpdate_AddForcedImages(float forceImportance, float touchImportance)
{
// Toggle between index 1 and 0
streamFrontendGlob.activeImageTouchBits ^= 1;
for (int index = 0; index < STREAM_MAX_IMAGE_BITS; index++)
{
unsigned int touchBits = streamFrontendGlob.imageTouchBits[index][0] | streamFrontendGlob.imageTouchBits[index][1];
unsigned int forceBits = streamFrontendGlob.imageForceBits[index] | touchBits;
unsigned int useBits = streamFrontendGlob.imageUseBits[index] & ~forceBits;
for (int bitIndex = NextMSBSet(forceBits); bitIndex >= 0; bitIndex = NextMSBSet(forceBits))
{
const int mask = BIT_MASK_32(bitIndex);
ASSERT(forceBits & mask);
forceBits &= ~mask;
int part;
part = (bitIndex + 32 * index) & 0x80000000;
part = max(part, 0) + 1;
if (mask & touchBits)
R_Stream_AddImagePartImportance(bitIndex + 32 * index, touchImportance / (float)part);
else
R_Stream_AddImagePartImportance(bitIndex + 32 * index, forceImportance / (float)part);
}
for (int bitIndex = NextMSBSet(useBits); bitIndex >= 0; bitIndex = NextMSBSet(useBits))
{
const int mask = BIT_MASK_32(bitIndex);
ASSERT(useBits & mask);
useBits &= ~mask;
R_Stream_AddImagePartImportance(bitIndex + 32 * index, 0.0f);
}
}
memset(&streamFrontendGlob.imageTouchBits[0][streamFrontendGlob.activeImageTouchBits ^ 1], 0, STREAM_MAX_IMAGE_BITS * sizeof(unsigned int));
}
// /gfx_d3d/r_stream.cpp:1583
void R_Stream_ForceLoadImage(GfxImage *image, int part)
{
if (!image || image->streaming == GFX_NOT_STREAMING)
return;
int imageIndex = DB_GetImageIndex(image);
if (part)
{
if (part >= 0)
{
for (int partIndex = 0; partIndex < part && partIndex < STREAM_MAX_IMAGES; partIndex++)
IMAGE_BIT_SET(streamFrontendGlob.imageForceBits, partIndex + imageIndex);
}
else
{
int partIndex = (part + 1 < 0) ? 0 : part + 1;
for (; partIndex >= 0; partIndex--)
IMAGE_BIT_SET(streamFrontendGlob.imageForceBits, partIndex + imageIndex);
}
}
else
{
for (int partIndex = 0; partIndex < STREAM_MAX_IMAGES; partIndex++)
IMAGE_BIT_UNSET(streamFrontendGlob.imageForceBits, partIndex + imageIndex);
}
streamFrontendGlob.diskOrderImagesNeedSorting = true;
}
// /gfx_d3d/r_stream.cpp:1631
void R_Stream_ForceLoadMaterial(Material *material, int part)
{
if (!material)
return;
int textureCount = material->textureCount;
for (int textureIter = 0; textureIter != textureCount; textureIter++)
{
MaterialTextureDef *texDef = &material->textureTable[textureIter];
ASSERT(texDef);
if (texDef->semantic == TS_WATER_MAP)
continue;
ASSERT(texDef->u.image);
R_Stream_ForceLoadImage(texDef->u.image, part);
}
}
// /gfx_d3d/r_stream.cpp:1657
void R_Stream_ForceLoadModel(XModel *model, int part)
{
if (!model)
return;
for (int lod = 0; lod < MAX_LODS; lod++)
{
XSurface *surfaces = nullptr;
Material * const *material = nullptr;
int surfCount = XModelGetSurfaces(model, &surfaces, lod);
material = XModelGetSkins(model, lod);
for (int surfIter = 0; surfIter != surfCount;)
{
R_Stream_ForceLoadMaterial(*material, part);
surfIter++;
material++;
}
}
}
// /gfx_d3d/r_stream.cpp:1684
bool R_StreamTouchDObjAndCheck(DObj *obj, int level)
{
ASSERT(obj);
ASSERT(Sys_IsMainThread());
ASSERT(useFastFile->current.enabled);
bool streamed = true;
int boneIndex = 0;
int modelCount = DObjGetNumModels(obj);
ASSERT(modelCount <= DOBJ_MAX_SUBMODELS);
int surfPartBits[9];
surfPartBits[0] = 0;
surfPartBits[1] = 0;
surfPartBits[2] = 0;
surfPartBits[3] = 0;
surfPartBits[4] = 0;
surfPartBits[5] = 0;
surfPartBits[6] = 0;
surfPartBits[7] = 0;
surfPartBits[8] = 0;
for (int modelIndex = 0; modelIndex < modelCount;)
{
XModel *model = DObjGetModel(obj, modelIndex);
ASSERT(model);
Material * const *materials = XModelGetSkins(model, 0);
int boneCount = XModelNumBones(model);
XSurface *surfaces;
int surfaceCount = XModelGetSurfaces(model, &surfaces, 0);
ASSERT(surfaces);
ASSERT(surfaceCount);
unsigned int targBoneIndexHigh = boneIndex >> 5;
unsigned int targBoneIndexLow = boneIndex & 0x1F;
unsigned int invTargBoneIndexLow = 32 - (boneIndex & 0x1F);
unsigned int partBits[5];
unsigned int hidePartBits[5];
DObjGetHidePartBits(obj, hidePartBits);
ASSERT(surfaceCount <= DOBJ_MAX_SURFS);
for (int surfaceIndex = 0; surfaceIndex < surfaceCount; surfaceIndex++)
{
XSurface *xsurf = &surfaces[surfaceIndex];
for (int i = 0; i < 5; i++)
surfPartBits[i + 4] = xsurf->partBits[i];
if (boneIndex & 0x1F)
{
partBits[0] = (unsigned int)surfPartBits[4 - targBoneIndexHigh] >> targBoneIndexLow;
partBits[1] = ((unsigned int)surfPartBits[5 - targBoneIndexHigh] >> targBoneIndexLow) | (surfPartBits[4 - targBoneIndexHigh] << invTargBoneIndexLow);
partBits[2] = ((unsigned int)surfPartBits[6 - targBoneIndexHigh] >> targBoneIndexLow) | (surfPartBits[5 - targBoneIndexHigh] << invTargBoneIndexLow);
partBits[3] = ((unsigned int)surfPartBits[7 - targBoneIndexHigh] >> targBoneIndexLow) | (surfPartBits[6 - targBoneIndexHigh] << invTargBoneIndexLow);
partBits[4] = ((unsigned int)surfPartBits[8 - targBoneIndexHigh] >> targBoneIndexLow) | (surfPartBits[7 - targBoneIndexHigh] << invTargBoneIndexLow);
}
else
{
partBits[0] = surfPartBits[4 - targBoneIndexHigh];
partBits[1] = surfPartBits[5 - targBoneIndexHigh];
partBits[2] = surfPartBits[6 - targBoneIndexHigh];
partBits[3] = surfPartBits[7 - targBoneIndexHigh];
partBits[4] = surfPartBits[8 - targBoneIndexHigh];
}
if (!(partBits[4] & hidePartBits[4] | partBits[3] & hidePartBits[3] | partBits[2] & hidePartBits[2] | partBits[1] & hidePartBits[1] | partBits[0] & hidePartBits[0]))
streamed &= R_StreamTouchMaterialAndCheck(materials[surfaceIndex], level);
}
modelIndex++;
boneIndex += boneCount;
}
return streamed;
}
// /gfx_d3d/r_stream.cpp:1781
void R_StreamTouchMaterial(Material *material)
{
int imageCount = Material_GetTextureCount(material);
for (int i = 0; i < imageCount; i++)
R_StreamTouchImage(Material_GetTexture(material, i));
}
// /gfx_d3d/r_stream.cpp:1794
bool R_StreamTouchMaterialAndCheck(Material *material, int level)
{
ASSERT_MSG(level >= 0 && level < STREAM_MAX_IMAGE_PARTS, "level doesn't index STREAM_MAX_IMAGE_PARTS");
bool streamed = true;
int imageCount = Material_GetTextureCount(material);
for (int i = 0; i < imageCount; i++)
streamed &= R_StreamTouchImageAndCheck(Material_GetTexture(material, i), level);
return streamed;
}
// /gfx_d3d/r_stream.cpp:1814
void R_StreamTouchImage(GfxImage *image)
{
if (image->streaming == GFX_NOT_STREAMING)
return;
int imagePartIndex = DB_GetImageIndex(image);
for (int part = 0; part < STREAM_MAX_IMAGE_PARTS;)
{
// Set the bit to 1/'enable'
streamFrontendGlob.imageTouchBits[BIT_INDEX_32(imagePartIndex)][streamFrontendGlob.activeImageTouchBits] |= BIT_MASK_32(imagePartIndex);
part++;
imagePartIndex++;
}
}
// /gfx_d3d/r_stream.cpp:1832
bool R_StreamTouchImageAndCheck(GfxImage *image, int level)
{
ASSERT_MSG(level >= 0 && level < STREAM_MAX_IMAGE_PARTS, "level doesn't index STREAM_MAX_IMAGE_PARTS");
if (image->streaming == GFX_NOT_STREAMING)
return true;
int imagePartIndex = DB_GetImageIndex(image);
int levelPartIndex = imagePartIndex - ((level > 0) ? 0 : level);
for (int part = 0; part < STREAM_MAX_IMAGE_PARTS;)
{
// Set the bit to 1/'enable'
streamFrontendGlob.imageTouchBits[BIT_INDEX_32(imagePartIndex)][streamFrontendGlob.activeImageTouchBits] |= BIT_MASK_32(imagePartIndex);
part++;
imagePartIndex++;
}
return IMAGE_BIT_IS_SET(streamFrontendGlob.imageUseBits, levelPartIndex) != 0;
}
// /gfx_d3d/r_stream.cpp:1860
bool R_StreamImageCheck(GfxImage *image, int level)
{
ASSERT_MSG(level >= 0 && level < STREAM_MAX_IMAGE_PARTS, "level doesn't index STREAM_MAX_IMAGE_PARTS");
if (image->streaming == GFX_NOT_STREAMING)
return true;
int imageIndex = DB_GetImageIndex(image);
int levelIndex = (level > 0) ? 0 : level;
return IMAGE_BIT_IS_SET(streamFrontendGlob.imageUseBits, imageIndex - levelIndex) != 0;
}
// /gfx_d3d/r_stream.cpp:1961
void R_Stream_ResetHintEntities()
{
s_numStreamHintsActive = 0;
memset(s_streamHints, 0, sizeof(s_streamHints));
}
// /gfx_d3d/r_stream.cpp:2075
void R_StreamUpdatePreventedMaterials()
{
memset(streamFrontendGlob.materialPreventBits, 0, sizeof(streamFrontendGlob.materialPreventBits));
for (int i = 0; i < ARRAYSIZE(s_preventMaterials); i++)
{
if (!s_preventMaterials[i])
continue;
int materialIndex = DB_GetMaterialIndex(s_preventMaterials[i]);
IMAGE_BIT_SET(streamFrontendGlob.materialPreventBits, materialIndex);
}
}
// /gfx_d3d/r_stream.cpp:2101
void R_StreamInit()
{
R_StreamAlloc_InitTempImages();
streamFrontendGlob.frame = 0;
streamFrontendGlob.queryInProgress = 0;
streamFrontendGlob.queryClient = -1;
for (int i = 0; i < STREAM_MAX_REQUESTS; i++)
R_Stream_InvalidateRequest(&s_pendingRequests[i]);
memset(streamFrontendGlob.imageInSortedListBits, 0, sizeof(streamFrontendGlob.imageInSortedListBits));
memset(s_preventMaterials, 0, sizeof(s_preventMaterials));
streamFrontendGlob.sortedImageCount = 0;
streamFrontendGlob.diskOrderImagesNeedSorting = true;
streamIsInitialized = true;
}
// /gfx_d3d/r_stream.cpp:2177
void R_StreamShutdown()
{
R_StreamSetDefaultConfig(true);
memset(s_preventMaterials, 0, sizeof(s_preventMaterials));
memset(streamFrontendGlob.imageInSortedListBits, 0, sizeof(streamFrontendGlob.imageInSortedListBits));
streamFrontendGlob.sortedImageCount = 0;
streamFrontendGlob.diskOrderImagesNeedSorting = true;
}
// /gfx_d3d/r_stream.cpp:2200
void R_Stream_ReleaseImage(GfxImage *image, bool lock, bool delayDirty)
{
ASSERT(image);
if (image->streaming == GFX_NOT_STREAMING)
return;
if (lock)
R_StreamAlloc_Lock();
int freedSize;
char *memory = R_StreamAlloc_FreeImage(image, 0, delayDirty, &freedSize);
if (freedSize > 0)
{
ASSERT(memory);
R_StreamAlloc_Deallocate(memory);
}
int imageIndex = DB_GetImageIndex(image);
for (int part = 0; part < STREAM_MAX_IMAGE_PARTS; part++)
{
IMAGE_BIT_UNSET(streamFrontendGlob.imageInitialBits, imageIndex + part);
IMAGE_BIT_UNSET(streamFrontendGlob.imageForceBits, imageIndex + part);
}
streamFrontendGlob.diskOrderImagesNeedSorting = true;
if (lock)
R_StreamAlloc_Unlock();
}
// /gfx_d3d/r_stream.cpp:2277
void R_Stream_Sync()
{
ASSERT(streamIsInitialized);
ASSERT(!R_StreamIsEnabled());
if (streamFrontendGlob.queryInProgress)
R_StreamUpdate_EndQuery();
ASSERT(!streamFrontendGlob.queryInProgress);
R_StreamAlloc_Lock();
for (int i = 0; i < STREAM_MAX_REQUESTS; i++)
{
pendingRequest *request = &s_pendingRequests[i];
switch (request->status)
{
case STREAM_STATUS_PRE:
case STREAM_STATUS_QUEUED:
IMAGE_BIT_UNSET(streamFrontendGlob.imageLoading, DB_GetImageIndex(request->image));
R_Stream_InvalidateRequest(request);
break;
case STREAM_STATUS_INPROGRESS:
case STREAM_STATUS_FINISHED:
IMAGE_BIT_UNSET(streamFrontendGlob.imageLoading, DB_GetImageIndex(request->image));
Z_VirtualFree(request->buffer, 20);
R_Stream_InvalidateRequest(request);
break;
}
}
R_StreamAlloc_Unlock();
}
// /gfx_d3d/r_stream.cpp:2462
void R_StreamSyncThenFlush(bool flushAll)
{
if (!streamIsInitialized)
return;
Sys_EnterCriticalSection(CRITSECT_STREAM_SYNC_COMMAND);
R_StreamPushDisable();
R_Stream_Sync();
if (flushAll)
{
R_StreamAlloc_Lock();
R_StreamAlloc_Flush();
R_StreamAlloc_Unlock();
}
streamFrontendGlob.frame = 0;
streamFrontendGlob.queryInProgress = 0;
streamFrontendGlob.calculateTotalBytesWanted = false;
Sys_EnterCriticalSection(CRITSECT_STREAM_FORCE_LOAD_COMMAND);
s_numForcedLoadEntities = 0;
for (int i = 0; i < ARRAYSIZE(s_forcedLoadEntities); i++)
s_forcedLoadEntities[i] = nullptr;
Sys_LeaveCriticalSection(CRITSECT_STREAM_FORCE_LOAD_COMMAND);
R_StreamPopDisable();
Sys_LeaveCriticalSection(CRITSECT_STREAM_SYNC_COMMAND);
}
// /gfx_d3d/r_stream.cpp:2517
void R_StreamPushSyncDisable()
{
if (streamIsInitialized)
{
Sys_EnterCriticalSection(CRITSECT_STREAM_SYNC_COMMAND);
R_StreamPushDisable();
R_Stream_Sync();
Sys_LeaveCriticalSection(CRITSECT_STREAM_SYNC_COMMAND);
}
else
{
// Avoid a more expensive sync/critical section when we can
R_StreamPushDisable();
}
}
// /gfx_d3d/r_stream.cpp:2532
void R_StreamPopSyncDisable()
{
ASSERT(!R_StreamIsEnabled());
if (streamIsInitialized)
{
Sys_EnterCriticalSection(CRITSECT_STREAM_SYNC_COMMAND);
R_Stream_Sync();
R_StreamPopDisable();
Sys_LeaveCriticalSection(CRITSECT_STREAM_SYNC_COMMAND);
}
else
{
// Avoid a more expensive sync/critical section when we can
R_StreamPopDisable();
}
}
// /gfx_d3d/r_stream.cpp:2691
void R_CheckHighmipAabbs()
{
float mins[3];
mins[0] = -131072.0f;
mins[1] = -131072.0f;
mins[2] = -131072.0f;
float maxs[3];
maxs[0] = 131072.0f;
maxs[1] = 131072.0f;
maxs[2] = 131072.0f;
ASSERT(false);
//R_CheckHighmipAabbs_r(rgp_world, 0, mins, maxs);
}
// /gfx_d3d/r_stream.cpp:2816
bool R_StreamUpdate_TryBeginQuery()
{
// Streaming must be enabled by user
if (!R_StreamIsEnabled())
return false;
// Can't have another query already happening
if (streamFrontendGlob.queryInProgress)
return false;
// Debug dump image list to console
if (streamFrontendGlob.outputImageList)
{
R_ImageList_Output();
streamFrontendGlob.outputImageList = false;
}
memset(streamFrontendGlob.materialImportance, 0, sizeof(streamFrontendGlob.materialImportance));
memset(streamFrontendGlob.materialImportanceBits, 0, sizeof(streamFrontendGlob.materialImportanceBits));
memset(streamFrontendGlob.modelDistance, 0, sizeof(streamFrontendGlob.modelDistance));
memset(streamFrontendGlob.modelDistanceBits, 0, sizeof(streamFrontendGlob.modelDistanceBits));
memset(streamFrontendGlob.imageImportance, 0, sizeof(streamFrontendGlob.imageImportance));
memset(streamFrontendGlob.imageImportanceBits, 0, sizeof(streamFrontendGlob.imageImportanceBits));
memset(streamFrontendGlob.dynamicModelDistance, 0, sizeof(streamFrontendGlob.dynamicModelDistance));
memset(streamFrontendGlob.dynamicModelDistanceBits, 0, sizeof(streamFrontendGlob.dynamicModelDistanceBits));
return true;
}
// /gfx_d3d/r_stream.cpp:2895
void R_StreamUpdate_Idle()
{
if (!DB_FinishedLoadingAssets())
return;
if (R_StreamUpdate(nullptr))
R_StreamUpdate_EndQuery();
}
// /gfx_d3d/r_stream.cpp:2909
void R_StreamUpdate_CompletePreload(void(__cdecl *pumpfunc)())
{
R_BeginRemoteScreenUpdate();
while (R_IsRemoteScreenUpdateActive())
{
if (!R_StreamIsEnabled())
break;
if (streamFrontendGlob.preloadCancelled)
break;
R_StreamAlloc_Lock();
float progress = R_Stream_GetProgress();
R_StreamAlloc_Unlock();
if (progress >= 1.0f || streamFrontendGlob.initialLoadAllocFailures > 0)
break;
Sleep(10);
}
R_EndRemoteScreenUpdate(pumpfunc);
}
// /gfx_d3d/r_stream.cpp:3170
bool R_StreamUpdate(const float *viewPos)
{
bool updateCalled = false;
if (r_streamClear->current.enabled || r_stream->modified)
{
R_StreamSyncThenFlush(true);
Dvar_ClearModified(r_streamSize);
Dvar_ClearModified(r_stream);
Dvar_SetBool(r_streamClear, false);
}
if (r_streamSize->modified)
{
R_StreamSyncThenFlush(false);
Dvar_ClearModified(r_streamSize);
}
if (r_streamLowDetail->modified)
{
if (r_streamLowDetail->current.enabled)
R_Stream_ForceLoadLowDetail();
else
memset(streamFrontendGlob.imageForceBits, 0, sizeof(streamFrontendGlob.imageForceBits));
Dvar_ClearModified(r_streamLowDetail);
streamFrontendGlob.diskOrderImagesNeedSorting = true;
}
if (r_reflectionProbeGenerate->current.enabled)
return false;
if (r_stream->current.integer > 0)
updateCalled = R_StreamUpdate_FindImageAndOptimize(viewPos);
return updateCalled;
}
// /gfx_d3d/r_stream.cpp:3344
void R_Stream_AddImagePartImportance(int imagePartIndex, float importance)
{
ASSERT_MSG(imagePartIndex >= 0 && imagePartIndex < STREAM_MAX_IMAGES, "imagePartIndex doesn't index TOTAL_IMAGE_PARTS");
streamFrontendGlob.imageImportance[imagePartIndex] = max(importance, streamFrontendGlob.imageImportance[imagePartIndex]);
if (!IMAGE_BIT_IS_SET(streamFrontendGlob.imageImportanceBits, imagePartIndex))
{
IMAGE_BIT_SET(streamFrontendGlob.imageImportanceBits, imagePartIndex);
if (!IMAGE_BIT_IS_SET(streamFrontendGlob.imageInSortedListBits, imagePartIndex))
{
IMAGE_BIT_SET(streamFrontendGlob.imageInSortedListBits, imagePartIndex);
streamFrontendGlob.sortedImages[streamFrontendGlob.sortedImageCount++] = (__int16)imagePartIndex;
}
}
ASSERT(streamFrontendGlob.sortedImageCount < ARRAYSIZE(streamFrontendGlob.sortedImages));
}
// /gfx_d3d/r_stream.cpp:3361
void R_StreamTouchImagesFromMaterial(Material *remoteMaterial, float importance)
{
int textureCount = remoteMaterial->textureCount;
if (!textureCount)
return;
for (int textureIter = 0; textureIter != textureCount; textureIter++)
{
MaterialTextureDef *texDef = &remoteMaterial->textureTable[textureIter];
ASSERT(texDef);
if (texDef->semantic == TS_WATER_MAP)
continue;
GfxImage *image = texDef->u.image;
ASSERT(image);
if (image->streaming)
{
int imageIndex = DB_GetImageIndex(image);
R_Stream_AddImagePartImportance(imageIndex, importance);
}
}
}
// /gfx_d3d/r_stream.cpp:3454
float FastPointDistSqFromBounds(const float4& mins, const float4& maxs)
{
float4 rvec;
rvec.v[0] = min(maxs.v[0], max(s_viewPos.v[0], mins.v[0]));
rvec.v[1] = min(maxs.v[1], max(s_viewPos.v[1], mins.v[1]));
rvec.v[2] = min(maxs.v[2], max(s_viewPos.v[2], mins.v[2]));
return
(((rvec.v[0] - s_viewPos.v[0]) * (rvec.v[0] - s_viewPos.v[0])) +
((rvec.v[1] - s_viewPos.v[1]) * (rvec.v[1] - s_viewPos.v[1]))) +
((rvec.v[2] - s_viewPos.v[2]) * (rvec.v[2] - s_viewPos.v[2]));
}
// /gfx_d3d/r_stream.cpp:3461
void MultiplePointDistSqFromBounds(distance_data *distances, const float *v, const float *mip0mins, const float *mip0maxs, float himipRadiusSq, float distanceScale)
{
STATIC_ASSERT_SIZE(float4, sizeof(float) * 4);
// These variables are expected to be 16-byte aligned
ASSERT(((size_t)(&s_viewPos.v[0]) & 15) == 0);
ASSERT(((size_t)((void*)mip0mins) & 15) == 0);
ASSERT(((size_t)((void*)mip0maxs) & 15) == 0);
float4 mins;
memcpy(mins.v, mip0mins, sizeof(float) * 4);
float4 maxs;
memcpy(maxs.v, mip0maxs, sizeof(float) * 4);
distances->distanceForHimip = FastPointDistSqFromBounds(mins, maxs) * distanceScale;
distances->importance = himipRadiusSq / (distances->distanceForHimip + 100.0f);
}
// /gfx_d3d/r_stream.cpp:3491
void R_StreamUpdateForXModel(XModel *remoteModel, float distSq)
{
const float distNotSq = sqrt(distSq);
Material **materialHandles = remoteModel->materialHandles;
XModelHighMipBounds *highMipBounds = remoteModel->streamInfo.highMipBounds;
for (int surf = 0; surf < remoteModel->numsurfs; surf++)
{
if (!materialHandles[surf]->textureCount)
continue;
XModelHighMipBounds *bounds = &highMipBounds[surf];
if (highMipBounds[surf].himipRadiusSq != 0.0f)
{
float distanceForHimip = distNotSq - Vec3Length(bounds->center);
float importance = bounds->himipRadiusSq / (max(distanceForHimip * distanceForHimip, 0.0f) + 100.0f);
int materialIndex = DB_GetMaterialIndex(materialHandles[surf]);
ASSERT(materialIndex >= 0);
ASSERT(materialIndex < MAX_MATERIAL_POOL_SIZE);
streamFrontendGlob.materialImportance[materialIndex] = max(importance, streamFrontendGlob.materialImportance[materialIndex]);
}
}
}
// /gfx_d3d/r_stream.cpp:3539
void R_StreamUpdateForXModelTouched(XModel *model)
{
if (!model)
return;
for (int lod = 0; lod < MAX_LODS; lod++)
{
XSurface *surfaces = nullptr;
Material * const *material = nullptr;
int surfCount = XModelGetSurfaces(model, &surfaces, lod);
material = XModelGetSkins(model, lod);
for (int surfIter = 0; surfIter != surfCount;)
{
R_StreamTouchMaterial(*material);
surfIter++;
material++;
}
}
}
// /gfx_d3d/r_stream.cpp:3561
void R_StreamUpdateTouchedModels()
{
for (int modelIndex = 0; modelIndex < STREAM_MAX_MODELS; modelIndex++)
{
if (!IMAGE_BIT_IS_SET(streamFrontendGlob.modelTouchBits, modelIndex))
continue;
XModel *model = DB_GetXModelAtIndex(modelIndex);
ASSERT(model);
R_StreamUpdateForXModelTouched(model);
}
}
// /gfx_d3d/r_stream.cpp:3585
void R_StreamUpdateForBModel(const float *viewPos, unsigned int frame, unsigned int surfId, GfxBrushModel *bmodel, const float *origin, float maxDistSq, Material *altMaterial, bool isVisible, float *distanceScale)
{
__debugbreak();
}
// /gfx_d3d/r_stream.cpp:3652
void R_StreamUpdate_AddXModelDistance(XModel *model, const float *viewPos, const float *origin, const float scale, bool visible, float *distanceScale)
{
int modelIndex = DB_GetXModelIndex(model);
float distSq = (Vec3DistanceSq(viewPos, origin) / scale) * distanceScale[visible];
if (IMAGE_BIT_IS_SET(streamFrontendGlob.modelDistanceBits, modelIndex))
{
streamFrontendGlob.modelDistance[modelIndex] = min(distSq, streamFrontendGlob.modelDistance[modelIndex]);
}
else
{
streamFrontendGlob.modelDistance[modelIndex] = distSq;
IMAGE_BIT_SET(streamFrontendGlob.modelDistanceBits, modelIndex);
}
}
// /gfx_d3d/r_stream.cpp:3670
void R_StreamUpdate_AddDynamicXModelDistance(XModel *model, const float *viewPos, const float *origin, const float scale, bool visible, float *distanceScale)
{
int modelIndex = DB_GetXModelIndex(model);
float distSq = (Vec3DistanceSq(viewPos, origin) / scale) * distanceScale[visible];
if (IMAGE_BIT_IS_SET(streamFrontendGlob.dynamicModelDistanceBits, modelIndex))
{
streamFrontendGlob.dynamicModelDistance[modelIndex] = min(distSq, streamFrontendGlob.dynamicModelDistance[modelIndex]);
}
else
{
streamFrontendGlob.dynamicModelDistance[modelIndex] = distSq;
IMAGE_BIT_SET(streamFrontendGlob.dynamicModelDistanceBits, modelIndex);
}
}
// /gfx_d3d/r_stream.cpp:3690
void R_StreamUpdateDynamicModels(const float *viewPos, float maxDistSq, unsigned int frame, float *distanceScale)
{
memcpy((void *)0x03E5B664, &s_viewPos, 16);
static DWORD dwCall = 0x006FA4F0;
__asm
{
mov edi, viewPos
push distanceScale
call [dwCall]
add esp, 0x4
}
}
// /gfx_d3d/r_stream.cpp:3802
void R_StreamUpdateStaticModel(int staticModelIndex, const float *viewPos, float maxDistSq, float *distanceScale)
{
R_StreamUpdate_AddXModelDistance(
rgp_world->dpvs.smodelDrawInsts[staticModelIndex].model,
viewPos,
rgp_world->dpvs.smodelDrawInsts[staticModelIndex].placement.origin,
rgp_world->dpvs.smodelDrawInsts[staticModelIndex].placement.scale,
((0x80000000 >> (staticModelIndex & 0x1F)) & rgp_world->dpvs.smodelVisDataCameraSaved[staticModelIndex >> 5]) != 0,
distanceScale);
}
// /gfx_d3d/r_stream.cpp:3824
void R_StreamUpdateWorldSurface(int surfId, const float *viewPos, float maxDistSq, float *distanceScale)
{
//ASSERT(surfId >= 0 && surfId < rgp_world->surfaceCount);
GfxSurface *surface = &rgp_world->dpvs.surfaces[surfId];
bool isVisible = rgp_world->dpvs.surfaceVisDataCameraSaved[surfId] != 0;
if (!*(DWORD *)0x396EE10 || isVisible)
{
distance_data distSq;
MultiplePointDistSqFromBounds(
&distSq,
viewPos,
surface->tris.mins,
surface->tris.maxs,
surface->tris.himipRadiusSq,
distanceScale[isVisible]);
int materialIndex = DB_GetMaterialIndex(surface->material);
streamFrontendGlob.materialImportance[materialIndex] = max(distSq.importance, streamFrontendGlob.materialImportance[materialIndex]);
}
}
// /gfx_d3d/r_stream.cpp:3888
void R_StreamUpdate_CombineImportance()
{
for (int modelIndex = 0; modelIndex < STREAM_MAX_MODELS; modelIndex++)
{
unsigned int mask = BIT_MASK_32(modelIndex);
unsigned int staticBit = mask & streamFrontendGlob.modelDistanceBits[BIT_INDEX_32(modelIndex)];
unsigned int dynamicBit = mask & streamFrontendGlob.dynamicModelDistanceBits[BIT_INDEX_32(modelIndex)];
XModel *model = DB_GetXModelAtIndex(modelIndex);
if (dynamicBit & staticBit)
{
ASSERT(model);
R_StreamUpdateForXModel(model, min(streamFrontendGlob.dynamicModelDistance[modelIndex], streamFrontendGlob.modelDistance[modelIndex]));
}
else if (staticBit)
{
ASSERT(model);
R_StreamUpdateForXModel(model, streamFrontendGlob.modelDistance[modelIndex]);
}
else if (dynamicBit)
{
ASSERT(model);
R_StreamUpdateForXModel(model, streamFrontendGlob.dynamicModelDistance[modelIndex]);
}
}
for (int materialIndex = 0; materialIndex < STREAM_MAX_MATERIALS; materialIndex++)
{
if (streamFrontendGlob.materialImportance[materialIndex] != 0.0f
&& !IMAGE_BIT_IS_SET(streamFrontendGlob.materialPreventBits, materialIndex))
{
Material *material = DB_GetMaterialAtIndex(materialIndex);
ASSERT(material);
R_StreamTouchImagesFromMaterial(material, streamFrontendGlob.materialImportance[materialIndex]);
}
}
}
// /gfx_d3d/r_stream.cpp:3953
void R_StreamUpdateAabbNode_r_0_(int aabbTreeNode, const float *viewPos, float maxDistSq, float *distanceScale)
{
ASSERT(aabbTreeNode >= 0 && aabbTreeNode < rgp_world->streamInfo.aabbTreeCount);
GfxStreamingAabbTree *tree = &rgp_world->streamInfo.aabbTrees[aabbTreeNode];
float distSq = PointDistSqFromBounds(viewPos, tree->mins, tree->maxs);
if (distSq > maxDistSq)
return;
if (tree->childCount)
{
int childBegin = tree->firstChild;
int childEnd = childBegin + tree->childCount;
for (int childIter = childBegin; childIter != childEnd; childIter++)
R_StreamUpdateAabbNode_r_0_(childIter, viewPos, maxDistSq, distanceScale);
}
else
{
int *leafRefBegin = &rgp_world->streamInfo.leafRefs[tree->firstItem];
int *leafRefEnd = leafRefBegin + tree->itemCount;
for (int *leafRefIter = leafRefBegin; leafRefIter != leafRefEnd; leafRefIter++)
{
int ref = *leafRefIter;
if (ref < 0)
R_StreamUpdateStaticModel(~ref, viewPos, maxDistSq, distanceScale);
else
R_StreamUpdateWorldSurface(ref, viewPos, maxDistSq, distanceScale);
}
}
}
// /gfx_d3d/r_stream.cpp:4020
void R_StreamUpdateStatic(const float *viewPos, float maxDistSq, float *distanceScale)
{
ASSERT(viewPos);
s_viewPos.v[0] = viewPos[0];
s_viewPos.v[1] = viewPos[1];
s_viewPos.v[2] = viewPos[2];
if (rgp_world->streamInfo.aabbTreeCount > 0)
R_StreamUpdateAabbNode_r_0_(0, viewPos, maxDistSq, distanceScale);
}
// /gfx_d3d/r_stream.cpp:4084
void importance_swap_func(void **a, void **b)
{
void *temp = *a;
*a = *b;
*b = temp;
}
// /gfx_d3d/r_stream.cpp:4092
bool importance_compare_func(void *a, void *b)
{
const int indexA = (int)a;
const int indexB = (int)b;
return *(int *)&streamFrontendGlob.imageImportance[indexA] > *(int *)&streamFrontendGlob.imageImportance[indexB];
}
struct importance_and_offset_pred
{
importance_and_offset_pred(bool DiskOrder)
{
}
inline bool operator() (const int& a, const int& b)
{
return importance_compare_func((void *)a, (void *)b);
}
};
// /gfx_d3d/r_stream.cpp:4099
void importance_merge_sort(void **list, const int list_count)
{
static void *aux_buffer[STREAM_MAX_IMAGES];
if (list_count >= 3)
{
importance_merge_sort(list, list_count / 2);
importance_merge_sort(&list[list_count / 2], list_count - list_count / 2);
void **b = &list[list_count / 2];
void **a = &list[list_count / 2 - 1];
if (importance_compare_func(list[list_count / 2], *a))
{
void **t = aux_buffer;
aux_buffer[0] = *a;
for (a = &list[list_count / 2 - 2]; a >= list && importance_compare_func(*b, *a); --a)
{
++t;
*t = *a;
}
++a;
*a = *b;
++b;
while (t >= aux_buffer && b < &list[list_count])
{
++a;
if (importance_compare_func(*t, *b))
{
*a = *t;
--t;
}
else
{
*a = *b;
++b;
}
}
while (t >= aux_buffer)
{
++a;
*a = *t;
--t;
}
}
}
else if (list_count == 2 && importance_compare_func(list[1], list[0]))
{
importance_swap_func(list, list + 1);
}
}
// /gfx_d3d/r_stream.cpp:4127
void R_StreamUpdate_EndQuerySort(bool diskOrder)
{
for (int index = 0; index < streamFrontendGlob.sortedImageCount;)
{
int imagePartIndex = streamFrontendGlob.sortedImages[index];
ASSERT(IMAGE_BIT_IS_SET(streamFrontendGlob.imageInSortedListBits, imagePartIndex));
if (IMAGE_BIT_IS_SET(streamFrontendGlob.imageImportanceBits, imagePartIndex))
{
index++;
}
else
{
streamFrontendGlob.sortedImages[index] = streamFrontendGlob.sortedImages[--streamFrontendGlob.sortedImageCount];
IMAGE_BIT_UNSET(streamFrontendGlob.imageInSortedListBits, imagePartIndex);
}
}
if (diskOrder)
{
if (streamFrontendGlob.diskOrderImagesNeedSorting || streamFrontendGlob.forceDiskOrder)
{
std::sort(
streamFrontendGlob.sortedImages,
streamFrontendGlob.sortedImages + streamFrontendGlob.sortedImageCount,
importance_and_offset_pred(diskOrder));
streamFrontendGlob.diskOrderImagesNeedSorting = false;
}
}
else
{
importance_merge_sort((void **)streamFrontendGlob.sortedImages, streamFrontendGlob.sortedImageCount);
}
}
// /gfx_d3d/r_stream.cpp:4254
void R_StreamUpdateForcedModels(unsigned int frame)
{
int surfCountPrevLods = 0;
Sys_EnterCriticalSection(CRITSECT_STREAM_FORCE_LOAD_COMMAND);
for (int i = 0; i < s_numForcedLoadEntities; i++)
{
int modelCount = DObjGetNumModels(s_forcedLoadEntities[i]);
float distSq = streamFrontendGlob.forcedImageImportance;
for (int modelIter = 0; modelIter != modelCount; modelIter++)
{
XModel *model = DObjGetModel(s_forcedLoadEntities[i], modelIter);
for (int lod = 0; lod < MAX_LODS; lod++)
{
XSurface *surfaces = nullptr;
Material * const *material = nullptr;
int surfCount = XModelGetSurfaces(model, &surfaces, lod);
material = XModelGetSkins(model, lod);
for (int surfIter = 0; surfIter != surfCount;)
{
if ((*material)->textureCount)
R_StreamTouchImagesFromMaterial(*material, distSq);
surfIter++;
material++;
}
surfCountPrevLods += surfCount;
}
}
}
Sys_LeaveCriticalSection(CRITSECT_STREAM_FORCE_LOAD_COMMAND);
}
// /gfx_d3d/r_stream.cpp:4300
void R_StreamUpdate_EndQuery_Internal()
{
if (Sys_IsRenderThread())
R_StreamUpdate_ProcessFileCallbacks();
for (int sortedIndex = 0; sortedIndex != streamFrontendGlob.sortedImageCount;)
{
// Find the next applicable stream load request
pendingRequest *request = nullptr;
for (int i = 0; i < STREAM_MAX_REQUESTS; i++)
{
if (request || s_pendingRequests[i].status != STREAM_STATUS_INVALID || i >= STREAM_MAX_REQUESTS)
{
if (s_pendingRequests[i].status == STREAM_STATUS_PRE)
R_StreamRequestImageRead(&s_pendingRequests[i]);
}
else
{
request = &s_pendingRequests[i];
}
}
if (!request)
return;
if (sortedIndex < streamFrontendGlob.sortedImageCount)
{
int imagePartIndex = 0;
GfxImage *image = nullptr;
while (true)
{
imagePartIndex = streamFrontendGlob.sortedImages[sortedIndex];
const unsigned int imageIndex = BIT_INDEX_32(imagePartIndex);
const unsigned int imageMask = BIT_MASK_32(imagePartIndex);
if (!(streamFrontendGlob.imageUseBits[imageIndex] & imageMask) && !(streamFrontendGlob.imageLoading[imageIndex] & imageMask))
{
image = DB_GetImageAtIndex(imagePartIndex);
if (image->streaming)
{
if (image->streaming != GFX_TEMP_STREAMING && image->skippedMipLevels)
break;
}
}
if (++sortedIndex >= streamFrontendGlob.sortedImageCount)
goto LABEL_23;
}
stream_status status = R_StreamRequestImageAllocation(request, image, true, streamFrontendGlob.imageImportance[imagePartIndex]);
if (status == STREAM_STATUS_INPROGRESS)
{
streamFrontendGlob.initialLoadAllocFailures = 0;
if (!R_StreamRequestImageRead(request))
return;
LABEL_23:
continue;
}
// bool GfxGlobals::isMultiplayer;
if (!*(bool *)0x396A4B1 || status != STREAM_STATUS_READFAILED && status != STREAM_STATUS_CANCELLED)
streamFrontendGlob.initialLoadAllocFailures++;
return;
}
}
}
// /gfx_d3d/r_stream.cpp:4516
void R_StreamUpdate_EndQuery()
{
ASSERT(streamFrontendGlob.queryInProgress == 1);
Sys_WaitWorkerCmdInternal(&r_stream_sortWorkerCmd);
streamFrontendGlob.queryInProgress = 0;
R_StreamAlloc_Lock();
R_StreamUpdate_EndQuery_Internal();
R_StreamAlloc_Unlock();
}
// /gfx_d3d/r_stream.cpp:4531
bool R_StreamUpdate_FindImageAndOptimize(const float *viewPos)
{
ASSERT(streamIsInitialized);
// Don't do anything if user froze image streaming globally
if (r_streamFreezeState->current.enabled)
return false;
if (r_streamCheckAabb->current.enabled)
R_CheckHighmipAabbs();
Sys_EnterCriticalSection(CRITSECT_STREAM_SYNC_COMMAND);
if (streamFrontendGlob.queryInProgress)
R_StreamUpdate_EndQuery();
if (!R_StreamUpdate_TryBeginQuery())
{
Sys_LeaveCriticalSection(CRITSECT_STREAM_SYNC_COMMAND);
return false;
}
ASSERT(streamFrontendGlob.queryClient == -1);
float maxDistSq = r_streamMaxDist->current.value * r_streamMaxDist->current.value;
streamFrontendGlob.queryInProgress = 1;
streamFrontendGlob.queryClient = 0;
// If there was no client active screen pos (before renderer is fully loaded), take the easy way out and sort
if (!rgp_world || !viewPos)
{
streamFrontendGlob.frame++;
streamFrontendGlob.diskOrder = true;
R_StreamUpdate_AddForcedImages(
streamFrontendGlob.forcedImageImportance,
streamFrontendGlob.touchedImageImportance);
R_StreamUpdate_AddInitialImages(streamFrontendGlob.initialImageImportance);
StreamSortCmd sortCmd;
sortCmd.frontend = &streamFrontendGlob;
sortCmd.diskOrder = true;
Sys_AddWorkerCmdInternal(&r_stream_sortWorkerCmd, &sortCmd, nullptr);
streamFrontendGlob.queryClient = -1;
Sys_LeaveCriticalSection(CRITSECT_STREAM_SYNC_COMMAND);
return true;
}
// Otherwise use the world position/distance to optimize sorting
streamFrontendGlob.diskOrderImagesNeedSorting = true;
streamFrontendGlob.frame++;
streamFrontendGlob.diskOrder = streamFrontendGlob.forceDiskOrder;
R_StreamUpdatePreventedMaterials();
R_StreamUpdateForcedModels(streamFrontendGlob.frame);
R_StreamUpdateTouchedModels();
memset(streamFrontendGlob.modelTouchBits, 0, sizeof(streamFrontendGlob.modelTouchBits));
R_StreamUpdate_AddForcedImages(
streamFrontendGlob.forcedImageImportance,
streamFrontendGlob.touchedImageImportance);
ASSERT(viewPos);
StreamUpdateCmd updateCmd;
updateCmd.frontend = &streamFrontendGlob;
updateCmd.viewPos[0] = viewPos[0];
updateCmd.viewPos[1] = viewPos[1];
updateCmd.viewPos[2] = viewPos[2];
updateCmd.maxDistSq = maxDistSq;
updateCmd.distanceScale[1] = 1.0f;
updateCmd.distanceScale[0] = r_streamHiddenPush->current.value;
Sys_AddWorkerCmdInternal(&r_stream_updateWorkerCmd, &updateCmd, nullptr);
for (int hint = 0; hint < ARRAYSIZE(s_streamHints); hint++)
{
if (s_streamHints[hint].importance <= 0.0f)
continue;
updateCmd.distanceScale[1] = 1.0f / s_streamHints[hint].importance;
updateCmd.distanceScale[0] = updateCmd.distanceScale[1];
updateCmd.viewPos[0] = s_streamHints[hint].origin[0];
updateCmd.viewPos[1] = s_streamHints[hint].origin[1];
updateCmd.viewPos[2] = s_streamHints[hint].origin[2];
Sys_AddWorkerCmdInternal(&r_stream_updateWorkerCmd, &updateCmd, nullptr);
}
Sys_LeaveCriticalSection(CRITSECT_STREAM_SYNC_COMMAND);
return true;
}
// /gfx_d3d/r_stream.cpp:4644
void R_StreamUpdatePerClient(const float *viewPos)
{
ASSERT(streamIsInitialized);
if (r_streamFreezeState->current.enabled || !rgp_world || !viewPos)
return;
Sys_EnterCriticalSection(CRITSECT_STREAM_SYNC_COMMAND);
// Exit the function if there's no query active at all
if (!streamFrontendGlob.queryInProgress || streamFrontendGlob.queryClient == -1)
{
Sys_LeaveCriticalSection(CRITSECT_STREAM_SYNC_COMMAND);
return;
}
float maxDistSq = r_streamMaxDist->current.value * r_streamMaxDist->current.value;
if (streamFrontendGlob.queryClient > 0)
{
ASSERT(viewPos);
StreamUpdateCmd updateCmd;
updateCmd.frontend = &streamFrontendGlob;
updateCmd.viewPos[0] = viewPos[0];
updateCmd.viewPos[1] = viewPos[1];
updateCmd.viewPos[2] = viewPos[2];
updateCmd.maxDistSq = maxDistSq;
updateCmd.distanceScale[1] = 1.0f;
updateCmd.distanceScale[0] = r_streamHiddenPush->current.value;
Sys_AddWorkerCmdInternal(&r_stream_updateWorkerCmd, &updateCmd, nullptr);
}
float distanceScale[2];
distanceScale[1] = 1.0f;
distanceScale[0] = r_streamHiddenPush->current.value;
R_StreamUpdateDynamicModels(viewPos, maxDistSq, streamFrontendGlob.frame, distanceScale);
streamFrontendGlob.queryClient++;
Sys_LeaveCriticalSection(CRITSECT_STREAM_SYNC_COMMAND);
}
// /gfx_d3d/r_stream.cpp:4705
void R_StreamUpdate_End()
{
ASSERT(streamFrontendGlob.queryClient > 0);
Sys_EnterCriticalSection(CRITSECT_STREAM_SYNC_COMMAND);
StreamCombineCmd combineCmd;
combineCmd.frontend = &streamFrontendGlob;
Sys_AddWorkerCmdInternal(&r_stream_combineWorkerCmd, &combineCmd, nullptr);
StreamSortCmd sortCmd;
sortCmd.frontend = &streamFrontendGlob;
sortCmd.diskOrder = streamFrontendGlob.diskOrder;
Sys_AddWorkerCmdInternal(&r_stream_sortWorkerCmd, &sortCmd, nullptr);
streamFrontendGlob.queryClient = -1;
Sys_LeaveCriticalSection(CRITSECT_STREAM_SYNC_COMMAND);
}
// /gfx_d3d/r_stream.cpp:4729
void R_Stream_UpdateStaticModelsCmd(void *data)
{
StreamUpdateCmd *cmd = (StreamUpdateCmd *)data;
s_viewPos.v[0] = cmd->viewPos[0];
s_viewPos.v[1] = cmd->viewPos[1];
s_viewPos.v[2] = cmd->viewPos[2];
for (unsigned int instId = 0; instId < g_worldDpvs->smodelCount; instId++)
R_StreamUpdateStaticModel(instId, cmd->viewPos, cmd->maxDistSq, cmd->distanceScale);
}
// /gfx_d3d/r_stream.cpp:4770
void R_Stream_UpdateStaticSurfacesCmd(void *data)
{
StreamUpdateCmd *cmd = (StreamUpdateCmd *)data;
s_viewPos.v[0] = cmd->viewPos[0];
s_viewPos.v[1] = cmd->viewPos[1];
s_viewPos.v[2] = cmd->viewPos[2];
for (unsigned int surfId = 0; surfId < g_worldDpvs->staticSurfaceCount; surfId++)
R_StreamUpdateWorldSurface(surfId, cmd->viewPos, cmd->maxDistSq, cmd->distanceScale);
}
// /gfx_d3d/r_stream.cpp:4808
void R_Stream_SortCmd(void *data)
{
StreamSortCmd *cmd = (StreamSortCmd *)data;
R_StreamUpdate_EndQuerySort(cmd->diskOrder);
}
// /gfx_d3d/r_stream.cpp:4807
void R_Stream_CombineCmd(void *data)
{
R_StreamUpdate_CombineImportance();
}
// /gfx_d3d/r_stream.cpp:4905
int r_stream_update_staticmodelsCallback(jqBatch *batch)
{
// This command doesn't allow multiple module instances (s_viewPos)
if (*(DWORD *)(batch->Module + 20) > 1)
return 1;
void *data = jqLockData(batch);
R_Stream_UpdateStaticModelsCmd(data);
jqUnlockData(batch, data);
return 0;
}
// /gfx_d3d/r_stream.cpp:4917
int r_stream_update_staticsurfacesCallback(jqBatch *batch)
{
// This command doesn't allow multiple module instances (s_viewPos)
if (*(DWORD *)(batch->Module + 20) > 1)
return 1;
void *data = jqLockData(batch);
R_Stream_UpdateStaticSurfacesCmd(data);
jqUnlockData(batch, data);
return 0;
}
// /gfx_d3d/r_stream.cpp:4929
int r_stream_sortCallback(jqBatch *batch)
{
if (jqPoll((jqBatchGroup *)0xBA5EB0) || jqPoll((jqBatchGroup *)0xBA5E30))
return 1;
void *data = jqLockData(batch);
R_Stream_SortCmd(data);
jqUnlockData(batch, data);
return 0;
}
// /gfx_d3d/r_stream.cpp:4941
int r_stream_combineCallback(jqBatch *batch)
{
if (jqPoll((jqBatchGroup *)0xBA5E30) || jqPoll((jqBatchGroup *)0xBA5E50) || jqPoll((jqBatchGroup *)0xBA5E70))
return 1;
void *data = jqLockData(batch);
R_Stream_CombineCmd(data);
jqUnlockData(batch, data);
return 0;
}
// /gfx_d3d/r_stream.cpp:4953
int r_stream_updateCallback(jqBatch *batch)
{
// This command doesn't allow multiple module instances (s_viewPos)
if (*(DWORD *)(batch->Module + 20) > 1)
return 1;
void *data = jqLockData(batch);
StreamUpdateCmd *cmd = (StreamUpdateCmd *)data;
s_viewPos.v[0] = cmd->viewPos[0];
s_viewPos.v[1] = cmd->viewPos[1];
s_viewPos.v[2] = cmd->viewPos[2];
R_StreamUpdateStatic(cmd->viewPos, cmd->maxDistSq, cmd->distanceScale);
jqUnlockData(batch, data);
return 0;
}
GfxImage *CL_CompositeSetupImage()
{
return R_StreamAlloc_SetupTempImage(D3DFMT_A8R8G8B8, false, 128, 128, 5);
}
void CL_CompositeSetupImageCallback(void *param)
{
*(GfxImage **)param = CL_CompositeSetupImage();
}
void __declspec(naked) hk_R_StreamTouchImageAndCheck()
{
__asm
{
push ecx
push eax
call R_StreamTouchImageAndCheck
add esp, 0x8
retn
}
}
void __declspec(naked) hk_R_StreamUpdatePerClient()
{
__asm
{
push eax
call R_StreamUpdatePerClient
add esp, 0x4
retn
}
}
void Patch_R_Stream()
{
#define DO_NOT_USE(x) /*PatchMemory((x), (PBYTE)"\xCC", 1);*/
DO_NOT_USE(0x00472980);
DO_NOT_USE(0x004F3E30);
DO_NOT_USE(0x0052C280);
DO_NOT_USE(0x005FB280);
DO_NOT_USE(0x004561D0);
DO_NOT_USE(0x005A1DC0);
// CL_CompositeSetupImageCallback for R_StreamAlloc_SetupTempImage
Detours::X86::DetourFunction((PBYTE)0x00635AD0, (PBYTE)&CL_CompositeSetupImageCallback);
DO_NOT_USE(0x006F8BF0);
DO_NOT_USE(0x006F8C50); Detours::X86::DetourFunction((PBYTE)0x006F8C50, (PBYTE)&R_StreamSetInitData);
DO_NOT_USE(0x006F8C60);
DO_NOT_USE(0x006F8D00);
DO_NOT_USE(0x006F8D70); Detours::X86::DetourFunction((PBYTE)0x006F8D70, (PBYTE)&R_StreamUpdate_ReadTextures);
DO_NOT_USE(0x006F8EB0);
DO_NOT_USE(0x006F8FE0); Detours::X86::DetourFunction((PBYTE)0x006F8FE0, (PBYTE)&R_StreamUpdate_ProcessFileCallbacks);
DO_NOT_USE(0x006F91A0); Detours::X86::DetourFunction((PBYTE)0x006F91A0, (PBYTE)&R_StreamUpdate_SetupInitialImageList);
DO_NOT_USE(0x006F9250);
DO_NOT_USE(0x006F94E0); Detours::X86::DetourFunction((PBYTE)0x006F94E0, (PBYTE)&R_StreamTouchDObjAndCheck);
DO_NOT_USE(0x006F9760); Detours::X86::DetourFunction((PBYTE)0x006F9760, (PBYTE)&R_StreamTouchMaterial);
DO_NOT_USE(0x006F97D0); Detours::X86::DetourFunction((PBYTE)0x006F97D0, (PBYTE)&R_StreamTouchMaterialAndCheck);
DO_NOT_USE(0x006F9880); Detours::X86::DetourFunction((PBYTE)0x006F9880, (PBYTE)&hk_R_StreamTouchImageAndCheck); // USERCALL
DO_NOT_USE(0x006F98F0);
DO_NOT_USE(0x006F9950); Detours::X86::DetourFunction((PBYTE)0x006F9950, (PBYTE)&R_StreamInit);
DO_NOT_USE(0x006F99D0); Detours::X86::DetourFunction((PBYTE)0x006F99D0, (PBYTE)&R_StreamShutdown);
DO_NOT_USE(0x006F9A70); Detours::X86::DetourFunction((PBYTE)0x006F9A70, (PBYTE)&R_Stream_ReleaseImage); // BROKEN
DO_NOT_USE(0x006F9B00);
DO_NOT_USE(0x006F9C10); Detours::X86::DetourFunction((PBYTE)0x006F9C10, (PBYTE)&R_StreamSyncThenFlush);
DO_NOT_USE(0x006F9CC0); Detours::X86::DetourFunction((PBYTE)0x006F9CC0, (PBYTE)&R_StreamPushSyncDisable);
DO_NOT_USE(0x006F9D00); Detours::X86::DetourFunction((PBYTE)0x006F9D00, (PBYTE)&R_StreamPopSyncDisable);
DO_NOT_USE(0x006F9D40);
DO_NOT_USE(0x006F9DF0); Detours::X86::DetourFunction((PBYTE)0x006F9DF0, (PBYTE)&R_StreamUpdate_Idle);
DO_NOT_USE(0x006F9E10); Detours::X86::DetourFunction((PBYTE)0x006F9E10, (PBYTE)&R_StreamUpdate_CompletePreload);
DO_NOT_USE(0x006F9E80); Detours::X86::DetourFunction((PBYTE)0x006F9E80, (PBYTE)&R_StreamUpdate);
DO_NOT_USE(0x006F9F60);
DO_NOT_USE(0x006F9FE0);
DO_NOT_USE(0x006FA030);
DO_NOT_USE(0x006FA130);
DO_NOT_USE(0x006FA260);
DO_NOT_USE(0x006FA2B0);
DO_NOT_USE(0x006FA2F0);
DO_NOT_USE(0x006FA440);
DO_NOT_USE(0x006FA4F0);
DO_NOT_USE(0x006FA9F0);
DO_NOT_USE(0x006FAA40);
DO_NOT_USE(0x006FAB10);
DO_NOT_USE(0x006FAC20);
DO_NOT_USE(0x006FAD40);
DO_NOT_USE(0x006FAE00);
DO_NOT_USE(0x006FAF10);
DO_NOT_USE(0x006FB040);
DO_NOT_USE(0x006FB080);
DO_NOT_USE(0x006FB2C0); Detours::X86::DetourFunction((PBYTE)0x006FB2C0, (PBYTE)&hk_R_StreamUpdatePerClient); // USERCALL
DO_NOT_USE(0x006FB3D0); Detours::X86::DetourFunction((PBYTE)0x006FB3D0, (PBYTE)&R_StreamUpdate_End);
DO_NOT_USE(0x006FB430);
DO_NOT_USE(0x006FB570);
DO_NOT_USE(0x006FB5C0); Detours::X86::DetourFunction((PBYTE)0x006FB5C0, (PBYTE)&r_stream_update_staticmodelsCallback);
DO_NOT_USE(0x006FB5F0); Detours::X86::DetourFunction((PBYTE)0x006FB5F0, (PBYTE)&r_stream_update_staticsurfacesCallback);
DO_NOT_USE(0x006FB620); Detours::X86::DetourFunction((PBYTE)0x006FB620, (PBYTE)&r_stream_sortCallback);
DO_NOT_USE(0x006FB670); Detours::X86::DetourFunction((PBYTE)0x006FB670, (PBYTE)&r_stream_combineCallback);
DO_NOT_USE(0x006FB6D0); Detours::X86::DetourFunction((PBYTE)0x006FB6D0, (PBYTE)&r_stream_updateCallback);
DO_NOT_USE(0x006FB770);
DO_NOT_USE(0x006FB8D0);
DO_NOT_USE(0x006FBEC0);
DO_NOT_USE(0x006FBF00);
DO_NOT_USE(0x006FBFA0); Detours::X86::DetourFunction((PBYTE)0x006FBFA0, (PBYTE)&R_StreamAlloc_ReleaseTempImage);
DO_NOT_USE(0x006FBFF0);
DO_NOT_USE(0x006FC0C0);
// Patch inlined R_StreamAlloc_Lock/R_StreamAlloc_Unlock in RB_RenderThread
PatchMemory_WithNOP(0x006EBE67, 5); Detours::X86::DetourFunction((PBYTE)0x006EBE67, (PBYTE)&R_StreamAlloc_Lock, Detours::X86Option::USE_CALL);
PatchMemory_WithNOP(0x006EBE71, 12); Detours::X86::DetourFunction((PBYTE)0x006EBE71, (PBYTE)&R_StreamAlloc_Unlock, Detours::X86Option::USE_CALL);
PatchMemory_WithNOP(0x006EBF45, 5); Detours::X86::DetourFunction((PBYTE)0x006EBF45, (PBYTE)&R_StreamAlloc_Lock, Detours::X86Option::USE_CALL);
PatchMemory_WithNOP(0x006EBF4F, 12); Detours::X86::DetourFunction((PBYTE)0x006EBF4F, (PBYTE)&R_StreamAlloc_Unlock, Detours::X86Option::USE_CALL);
// Patch streamFrontendGlob.frame reference in SCR_UpdateFrame
void *ptr = &streamFrontendGlob.frame;
PatchMemory(0x007A17D1 + 0x2, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x007A188C + 0x2, (PBYTE)&ptr, sizeof(DWORD));
// R_StreamUpdateDynamicModels
ptr = &streamFrontendGlob.dynamicModelDistanceBits;
PatchMemory(0x006FA5E7 + 0x3, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x006FA6E7 + 0x3, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x006FA84E + 0x3, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x006FA8EC + 0x3, (PBYTE)&ptr, sizeof(DWORD));
ptr = &streamFrontendGlob.dynamicModelDistance;
PatchMemory(0x006FA5F5 + 0x5, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x006FA611 + 0x5, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x006FA61C + 0x5, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x006FA6F5 + 0x5, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x006FA711 + 0x5, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x006FA71C + 0x5, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x006FA869 + 0x5, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x006FA885 + 0x5, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x006FA890 + 0x5, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x006FA907 + 0x5, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x006FA923 + 0x5, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x006FA92E + 0x5, (PBYTE)&ptr, sizeof(DWORD));
// R_Stream_AddImagePartImportance for R_StreamUpdateForBModel for R_StreamUpdateDynamicModels
ptr = &streamFrontendGlob.imageImportance;
PatchMemory(0x006F9F60 + 0x5, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x006F9F91 + 0x5, (PBYTE)&ptr, sizeof(DWORD));
ptr = &streamFrontendGlob.imageImportanceBits;
PatchMemory(0x006F9F9A + 0x2, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x006F9FA6 + 0x2, (PBYTE)&ptr, sizeof(DWORD));
ptr = &streamFrontendGlob.imageInSortedListBits;
PatchMemory(0x006F9FAC + 0x2, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x006F9FB8 + 0x2, (PBYTE)&ptr, sizeof(DWORD));
ptr = &streamFrontendGlob.sortedImages;
PatchMemory(0x006F9FC7 + 0x3, (PBYTE)&ptr, sizeof(DWORD));
ptr = &streamFrontendGlob.sortedImageCount;
PatchMemory(0x006F9FBE + 0x2, (PBYTE)&ptr, sizeof(DWORD));
PatchMemory(0x006F9FCE + 0x2, (PBYTE)&ptr, sizeof(DWORD));
} |
69c80835e25797c9f81972ff83162b3995d28722 | aa96ae5fee9e0dedaaf73bfb6c820db3e844a5de | /Sources/Interface/OptionsDlg.h | e936897d1b153652f5ee4795f40cce47557e514e | [] | no_license | jotak/shahnarman | 1aded6d198d8b8abfd1c43f7f8230403b5034762 | 0876f31e0572b9f465cf9d5ff4582045488788e9 | refs/heads/master | 2021-01-01T18:33:26.850009 | 2012-09-17T20:19:10 | 2012-09-17T20:19:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 756 | h | OptionsDlg.h | #ifndef _OPTIONS_DLG_H
#define _OPTIONS_DLG_H
#include "../GUIClasses/guiDocument.h"
class LocalClient;
class guiPopup;
class OptionsDlg : public guiDocument
{
public:
OptionsDlg(int iWidth, int iHeight, LocalClient * pLocalClient);
~OptionsDlg();
virtual void update(double delta);
// Handlers
bool onButtonEvent(ButtonAction * pEvent, guiComponent * pCpnt);
private:
void onAcceptGameParameters();
void onAcceptVideoParameters();
void onAcceptAudioParameters();
LocalClient * m_pLocalClient;
guiPopup * m_pGameOptionsDlg;
guiPopup * m_pVideoOptionsDlg;
guiPopup * m_pAudioOptionsDlg;
guiPopup * m_pConfirmVideoModeDlg;
float m_fConfirmVideoModeTimer;
int m_iSelectedLanguage;
};
#endif
|
3b5abaabdd329c4aa277d1dbd4a21cf8e7a54fd5 | c709c3a135ffa0b90a4371aa1bdaf9e18a7786d0 | /main.cpp | 6e463b9139900dcefa89948b6a20fb51397e6edd | [] | no_license | mystery110/DS_LinkedList | ef77672a913f343805be56d9fbc4e9bb9d0ea5fb | e948919496a65a2ffa89a4bd2bd01709dc27594c | refs/heads/master | 2020-04-25T16:46:42.041498 | 2019-02-27T13:50:12 | 2019-02-27T13:50:12 | 172,923,936 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,700 | cpp | main.cpp | #include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<cstring>
using namespace std;
typedef enum {entry,head}tagfield;
typedef struct {
int col;
int row;
int value;}entry_Node;
typedef struct matrixNode * Pointer_Node;
struct matrixNode{
Pointer_Node down,right;
tagfield tag;
union {
entry_Node entry;
Pointer_Node next;}u;
};
vector <string>Input_Splitted;
//..........................Function Used.....................
bool Seperation(string);
int getValue();
Pointer_Node mread();
void mwrite(Pointer_Node);
Pointer_Node mtranspose(Pointer_Node);
Pointer_Node mmult(Pointer_Node,Pointer_Node);
int Number_Matrix=0;
int main (){
Pointer_Node MatrixA=mread();
Pointer_Node MatrixB=mread();
cout<<"b Transpose"<<endl;
Pointer_Node MatrixB_Tran=mtranspose(MatrixB);
mwrite(MatrixB_Tran);
Pointer_Node MatrixC=mmult(MatrixA,MatrixB);
if(MatrixC){
cout<<"a*b transpose"<<endl;
cout<<"numRows="<<MatrixC->u.entry.row<<",numcols="<<MatrixC->u.entry.col;
cout<<"The Matrix by row,column and value:"<<endl;
mwrite(MatrixC);}
else {
cout<<"Error, the matrix cant multiply"<<endl;}
}
bool Seperation(string input){
istringstream ss(input);
char Split_char=' ';
string temp;
while(getline(ss,temp,Split_char)){
Input_Splitted.push_back(temp);
}
if (Input_Splitted.size()<1)
return false;
else
return true;
}
int getValue(){
int temp=stoi(Input_Splitted.at(0),NULL);
Input_Splitted.erase(Input_Splitted.begin());
return temp;
}
Pointer_Node mread(){
Pointer_Node tempNode;//temporaty pointer to a node
int Number_Element=0;
Input_Splitted.clear();
cout<<"Please enter the number of row , column and non-zero term"<<endl;
string stringtemp;
do{
getline(cin,stringtemp);
if (Seperation(stringtemp)){
int Number_Row=getValue(),Number_Column=getValue();
int Number_NonZero=getValue(),Number_Head;
Pointer_Node Ini_Node=new matrixNode();
Ini_Node->u.entry.row=Number_Row;
Ini_Node->u.entry.col=Number_Column;
Ini_Node->u.entry.value=Number_NonZero;
if(Number_Row>Number_Column){
Number_Head=Number_Row;}
else {
Number_Head=Number_Column;}
Pointer_Node Header_Node[Number_Head];
for (int i=0;i<Number_Head;i++){
tempNode=new matrixNode;
Header_Node[i]=tempNode;
Header_Node[i]->right=tempNode;
Header_Node[i]->u.next=tempNode;
Header_Node[i]->tag=head;
}
int temp_Col,temp_Row,temp_Value,current_row=0;
//variable to store row , column and value for each line
cout<<"Start enter the matrix :"<<endl;
Pointer_Node lastNode=Header_Node[0];//To record the last node of each row
current_row=0;
while(Number_Element<Number_NonZero){
getline(cin,stringtemp);
if(Seperation(stringtemp)){
temp_Row=getValue();
temp_Col=getValue();
temp_Value=getValue();
if(temp_Row!=current_row){
lastNode->right=Header_Node[current_row];
current_row=temp_Row;
lastNode=Header_Node[current_row];
}
tempNode=new matrixNode;
lastNode->right=tempNode;
tempNode->u.entry.col=temp_Col;
tempNode->u.entry.row=temp_Row;
tempNode->u.entry.value=temp_Value;
tempNode->tag=entry;
lastNode=lastNode->right;
Header_Node[temp_Col]->u.next->down=tempNode;
Header_Node[temp_Col]->u.next=tempNode;
Number_Element++;
}
}
lastNode->right=Header_Node[current_row];
for (int i=0;i<Number_Column;i++){
Header_Node[i]->u.next->down=Header_Node[i];
}
for (int i=0;i<Number_Head-1;i++){
//number_head -1 because the last node.next need to linked to the initial>node
Header_Node[i]->u.next=Header_Node[i+1];
}
Header_Node[Number_Head-1]->u.next=Ini_Node;
Ini_Node->right=Header_Node[0];
Number_Matrix++;
return Ini_Node;
}
else {
cout<<"Please enter valid number"<<endl;
}
}while(!Seperation(stringtemp));
}
void mwrite(Pointer_Node k){
int Number_Column=k->u.entry.col;
int Number_Row=k->u.entry.row;
int Number_Head;
if(Number_Row>Number_Column){
Number_Head=Number_Row;}
else {
Number_Head=Number_Column;}
Pointer_Node Current_Header=k->right;
while(Current_Header!=k){
Pointer_Node tempNode=Current_Header->right;
while(tempNode!=Current_Header){
cout<<tempNode->u.entry.row<<" "<<tempNode->u.entry.col<<" ";
cout<<tempNode->u.entry.value<<endl;
tempNode=tempNode->right;
}
Current_Header=Current_Header->u.next;
}
}
Pointer_Node mtranspose(Pointer_Node k){
int Number_Column=k->u.entry.col;
int Number_Row=k->u.entry.row;
int Number_NonZero=k->u.entry.value;
int Number_Head;
if(Number_Row>Number_Column){
Number_Head=Number_Row;}
else {
Number_Head=Number_Column;}
cout<<"Number of row:"<<Number_Column<<",Number of column:"<<Number_Row<<endl;
cout<<"The matrix by row,column and value:"<<endl;
Pointer_Node Ini_Node=new matrixNode(),tempNode,Current_Header,lastNode;
Ini_Node->u.entry.row=Number_Column;
Ini_Node->u.entry.col=Number_Row;
Ini_Node->u.entry.value=Number_NonZero;
Pointer_Node Header_Node[Number_Head];
for (int i=0;i<Number_Head;i++){
tempNode=new matrixNode;
Header_Node[i]=tempNode;
Header_Node[i]->right=tempNode;
Header_Node[i]->u.next=tempNode;
Header_Node[i]->tag=head;
}
int temp_Row,temp_Col,temp_Value,Col_index=0;
Pointer_Node temp_New_Node;
Current_Header=k->right;
while(Current_Header!=k){
tempNode=Current_Header->down;
lastNode=Header_Node[Col_index];
while(tempNode!=Current_Header){
temp_Row=tempNode->u.entry.col;
temp_Col=tempNode->u.entry.row;
temp_Value=tempNode->u.entry.value;
temp_New_Node=new matrixNode;
temp_New_Node->u.entry.row=temp_Row;
temp_New_Node->u.entry.col=temp_Col;
temp_New_Node->u.entry.value=temp_Value;
lastNode->right=temp_New_Node;
lastNode=lastNode->right;
Header_Node[temp_Col]->u.next->down=temp_New_Node;
Header_Node[temp_Col]->u.next=temp_New_Node;
tempNode=tempNode->down;
}
lastNode->right=Header_Node[Col_index++];
Current_Header=Current_Header->u.next;
}
for (int i=0;i<Number_Column;i++){
Header_Node[i]->u.next->down=Header_Node[i];
}
for (int i=0;i<Number_Head-1;i++){
//number_head -1 because the last node.next need to linked to the initial>node
Header_Node[i]->u.next=Header_Node[i+1];
}
Header_Node[Number_Head-1]->u.next=Ini_Node;
Ini_Node->right=Header_Node[0];
Number_Matrix++;
return Ini_Node;
}
Pointer_Node mmult(Pointer_Node A,Pointer_Node B){
//Assung B is transpose
int Number_Row=B->u.entry.col;
int Number_Col=A->u.entry.col;
if (Number_Col!=Number_Row){
return NULL;}
else {
Pointer_Node tempNode,Ini_Node;
Number_Row=A->u.entry.row;
Number_Col=B->u.entry.row;
int Number_Head,sum=0;
if(Number_Row>Number_Col){
Number_Head=Number_Row;}
else {
Number_Head=Number_Col;}
Ini_Node=new matrixNode;
Ini_Node->u.entry.col=Number_Col;
Ini_Node->u.entry.row=Number_Row;
Pointer_Node Header_Node[Number_Head];
for (int i=0;i<Number_Head;i++){
tempNode=new matrixNode;
Header_Node[i]=tempNode;
Header_Node[i]->right=tempNode;
Header_Node[i]->u.next=tempNode;
Header_Node[i]->tag=head;
}
Pointer_Node temp_Head_A,temp_Head_B,tempA,tempB,lastNode;
temp_Head_A=A->right;
while(temp_Head_A!=A){
tempA=temp_Head_A->right;
temp_Head_B=B->right;
int current_col=tempA->u.entry.row,current_row;
while(temp_Head_B!=B){
tempB=temp_Head_B->right;
current_row=tempB->u.entry.row;
lastNode=Header_Node[current_col];
while(tempB!=temp_Head_B&&tempA!=temp_Head_A){
if(tempB->u.entry.col==tempA->u.entry.col){
sum+=tempB->u.entry.value*tempA->u.entry.value;
tempA=tempA->right;
tempB=tempB->right;
}
else if(tempB->u.entry.col>tempA->u.entry.col){
tempA=tempA->right;
}
else if(tempB->u.entry.col<tempA->u.entry.col){
tempB=tempB->right;}
}
if(sum){
tempNode=new matrixNode;
lastNode->down=tempNode;
tempNode->u.entry.col=current_row;
tempNode->u.entry.row=current_col;
tempNode->u.entry.value=sum;
tempNode->tag=entry;
lastNode=lastNode->down;
Header_Node[current_row]->u.next->right=tempNode;
Header_Node[current_row]->u.next=tempNode;
sum=0;
}
temp_Head_B=temp_Head_B->u.next;
tempA=temp_Head_A->right;
}
lastNode->down=Header_Node[current_col];
temp_Head_A=temp_Head_A->u.next;
}
for (int i=0;i<Number_Row;i++){
Header_Node[i]->u.next->right=Header_Node[i];
}
for (int i=0;i<Number_Head-1;i++){
//number_head -1 because the last node.next need to linked to the initial>node
Header_Node[i]->u.next=Header_Node[i+1];
}
Header_Node[Number_Head-1]->u.next=Ini_Node;
Ini_Node->right=Header_Node[0];
return Ini_Node;
}
}
|
4aad93b40de028436b7ecfa4d96561f7f6e0e936 | c3a001285a07793217247e9985216dafae38a090 | /4Lab/Math32/Win32Dll/math32.cpp | b795369e259444dd7adc7994f98abfa621492705 | [] | no_license | DcDrugs/LabaCSharp | a5d80963b33e55eb7cde22d1e5b1bbedb539f7b9 | aecf7f327f2dff33931f8d99e7d5b464f17efea5 | refs/heads/master | 2021-05-22T20:18:42.683336 | 2020-05-16T15:05:40 | 2020-05-16T15:05:40 | 253,077,120 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,709 | cpp | math32.cpp |
#include "pch.h"
#include <utility>
#include <limits.h>
#include "math32.h"
static double k_ = 0;
static double b_ = 0;
double f(double x)
{
if (x == 0)
{
return 1;
}
return k_ * x + b_;
}
double summ(double* point,int number_of_point)
{
double result = 0;
for (int i = 0; i < number_of_point; i++)
{
result += point[i];
}
return result;
}
bool find_error_point(double* pointX, double* pointY, int &number_of_point, double epsilon)
{
if (epsilon < 0)
{
return false;
}
double max = 0;
int index = -1;
for (int i = 0; i < number_of_point; i++)
{
double temp = fabs(f(pointX[i]) - pointY[i]);
if (temp > epsilon && max < temp)
{
max = temp;
index = i;
}
}
if (index != -1)
{
double reverse = pointX[index];
pointX[index] = pointX[number_of_point - 1];
pointX[number_of_point - 1] = pointX[index];
reverse = pointY[index];
pointY[index] = pointY[number_of_point - 1];
pointY[number_of_point - 1] = pointY[index];
number_of_point--;
return true;
}
return false;
}
bool find_factor(double* const_PointX, double* const_PointY, int number_of_point, double epsilon)
{
double average_array[] = { 0,0,0,0 };
double* temp = new double[number_of_point];
double* pointX = new double[number_of_point];
double* pointY = new double[number_of_point];
for (int i = 0; i < number_of_point; i++)
{
pointX[i] = const_PointX[i];
pointY[i] = const_PointY[i];
}
do
{
for (int i = 0; i < number_of_point; i++)
{
temp[i] = pointX[i] * pointY[i];
}
average_array[0] = summ(temp, number_of_point) / number_of_point;
average_array[1] = (summ(pointX, number_of_point) / number_of_point) * (summ(pointY, number_of_point) / number_of_point);
for (int i = 0; i < number_of_point; i++)
{
temp[i] = pointX[i] * pointX[i];
}
average_array[2] = summ(temp, number_of_point) / number_of_point;
average_array[3] = (summ(pointX, number_of_point) / number_of_point) * (summ(pointX, number_of_point) / number_of_point);
k_ = (average_array[0] - average_array[1]) / (average_array[2] - average_array[3]);
b_ = (summ(pointY, number_of_point) / number_of_point) - k_ * (summ(pointX, number_of_point) / number_of_point);
} while (find_error_point(pointX, pointY, number_of_point, epsilon));
delete[] temp;
return true;
}
double get_tlit_angle()
{
return k_;
}
double get_factor_b()
{
return b_;
}
|
00621980e6631c9f163b6f999e6753672b5a495a | f34dc62905311dc0e53da1ad7886ca31edc90844 | /encapsulated/Client.cpp | b500927fa1a3a2aaa4ee01b758f0cc0bbd631f0e | [] | no_license | dragonII/fun-for-server-and-client | 35c31fac72af9653a2a19e33c7f22219ac0ebe1d | 8d792174389aa45214d7624635d2832d984abfa0 | refs/heads/master | 2018-12-28T04:15:43.671745 | 2010-08-07T07:18:59 | 2010-08-07T07:18:59 | 32,122,422 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,625 | cpp | Client.cpp | #include <Ice/Ice.h>
#include <Callback.h>
#include <iostream>
#include <fstream>
using namespace std;
using namespace Demo;
#define BLOCK_SIZE 1024
class CallbackReceiverI : public CallbackReceiver
{
public:
virtual void callback(const Ice::Current&)
{
cout << "Client callbacked " << endl;
}
};
class CallbackClient : public Ice::Application
{
public:
CallbackClient();
virtual int run(int, char* []);
};
int main(int argc, char* argv[])
{
CallbackClient app;
return app.main(argc, argv, "config.client");
}
CallbackClient::CallbackClient():
Ice::Application(Ice::NoSignalHandling)
{
}
int CallbackClient::run(int argc, char* argv[])
{
if(argc > 1)
{
cerr << appName() << ": too many argvments" << endl;
return EXIT_FAILURE;
}
//default: twoway, no timeout, no secure
CallbackSenderPrx sProxy = CallbackSenderPrx::checkedCast(
communicator()->propertyToProxy("CallbackSender.Proxy"));
if(!sProxy)
{
cerr << appName() << ": Invalid proxy" << endl;
return EXIT_FAILURE;
}
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Callback.Client");
CallbackReceiverPtr cr = new CallbackReceiverI;
adapter->add(cr, communicator()->stringToIdentity("callbackReceiver"));
adapter->activate();
CallbackReceiverPrx rProxy = CallbackReceiverPrx::uncheckedCast(
adapter->createProxy(communicator()->stringToIdentity("callbackReceiver")));
try
{
sProxy->initiateCallback(rProxy);
}catch(const Ice::Exception& ex)
{
cerr << ex << endl;
}
char c;
cout << "--> ";
cin >> c;
while(cin.good() && c != 'x');
sProxy->shutdown();
return EXIT_SUCCESS;
}
|
52587eabbcc73dcde206ce394a38021fba2c4ebd | 634120df190b6262fccf699ac02538360fd9012d | /Develop/Server/GameServer/unittest/TestItemUser.cpp | 64eaf1e03b070f7a984b90dbe503f2ffb99b5124 | [] | no_license | ktj007/Raiderz_Public | c906830cca5c644be384e68da205ee8abeb31369 | a71421614ef5711740d154c961cbb3ba2a03f266 | refs/heads/master | 2021-06-08T03:37:10.065320 | 2016-11-28T07:50:57 | 2016-11-28T07:50:57 | 74,959,309 | 6 | 4 | null | 2016-11-28T09:53:49 | 2016-11-28T09:53:49 | null | UTF-8 | C++ | false | false | 3,481 | cpp | TestItemUser.cpp | #include "stdafx.h"
#include "GEntityPlayer.h"
#include "GTestForward.h"
#include "FBaseGame.h"
#include "GItemUser.h"
#include "GItemHolder.h"
#include "GPlayerTalent.h"
#include "GQuestInfo.h"
#include "GPlayerQuests.h"
#include "GConditionInfo.h"
#include "GConditionsInfo.h"
#include "GEquipmentSlot.h"
SUITE(ItemUser)
{
struct Fixture : public FBaseGame
{
Fixture(){}
~Fixture(){}
GItemUser m_ItemUser;
};
TEST_FIXTURE(Fixture, Equip)
{
GItem* pItem = test.item.GainShieldItem(m_pPlayer);
CHECK(true == m_ItemUser.Use(m_pPlayer, pItem->m_nSlotID));
CHECK_EQUAL(true, m_pPlayer->GetItemHolder()->GetEquipment().IsEquipItem(pItem));
}
TEST_FIXTURE(Fixture, TalentUse)
{
GItem* pItem = test.item.GiveNewItem(m_pPlayer);
GTalentInfo* pTalentInfo = test.talent.NewItemTalentInfo();
pItem->m_pItemData->m_ItemType = ITEMTYPE_USABLE;
pItem->m_pItemData->m_nUsableType = USABLE_TALENT_USE;
pItem->m_pItemData->m_vecUsableParam.push_back(pTalentInfo->m_nID);
int nBeforeItemQuantity = pItem->GetAmount();
CHECK(true == gsys.pItemSystem->GetUser().Use(m_pPlayer, pItem->m_nSlotID));
CHECK_EQUAL(true, m_pPlayer->GetTalent().IsEnableUseItemTalent(pTalentInfo->m_nID));
CHECK_EQUAL(nBeforeItemQuantity, pItem->GetAmount());
CHECK_EQUAL(MC_ITEM_TALENT, m_pLink->GetCommand(0).GetID());
}
TEST_FIXTURE(Fixture, TalentTrain)
{
// arrange
GItem* pItem = test.item.GiveNewItem(m_pPlayer);
pItem->m_pItemData->m_ItemType = ITEMTYPE_USABLE;
pItem->m_pItemData->m_nUsableType = USABLE_TALENT_TRAIN;
vector<GTalentInfo*> vecTalentInfo;
for(int i = 0; i < 3; i++)
{
GTalentInfo* pInfo = test.talent.NewTalentInfo();
vecTalentInfo.push_back(pInfo);
pInfo->m_bByLicense = true;
pInfo->m_bNeedTraining = true;
m_pPlayer->GetTalent().AddTP(1);
pItem->m_pItemData->m_vecUsableParam.push_back(vecTalentInfo[i]->m_nID);
}
// act
CHECK(true == gsys.pItemSystem->GetUser().Use(m_pPlayer, pItem->m_nSlotID));
// assert
for(size_t i = 0; i < vecTalentInfo.size(); i++)
{
CHECK_EQUAL(true, m_pPlayer->GetTalent().IsTrainedTalent(vecTalentInfo[i]));
}
}
TEST_FIXTURE(Fixture, QuestAdd)
{
MockLink* pLink = NewLink(m_pPlayer);
GQuestInfo* pQuestInfo = test.quest.NewQuestInfo();
GItem* pItem = test.item.GiveNewItem(m_pPlayer);
pItem->m_pItemData->m_ItemType = ITEMTYPE_USABLE;
pItem->m_pItemData->m_nUsableType = USABLE_QUEST_ADD;
pItem->m_pItemData->m_vecUsableParam.push_back(pQuestInfo->nID);
CHECK(true == gsys.pItemSystem->GetUser().Use(m_pPlayer, pItem->m_nSlotID));
pLink->OnRecv(MC_QUEST_GIVE_REQ, 1, NEW_INT(pQuestInfo->nID));
CHECK(true == m_pPlayer->GetQuests().IsDoingQuest(pQuestInfo->nID));
}
TEST_FIXTURE(Fixture, CheckCondition)
{
GConditionsInfo* pConditionsInfo = test.condition.NewCondI(test.condition.NewCondLForLevel(10), true);
GTalentInfo* pTalentInfo = test.talent.NewItemTalentInfo();
GItem* pItem = test.item.GiveNewItem(m_pPlayer);
pItem->m_pItemData->m_ItemType = ITEMTYPE_USABLE;
pItem->m_pItemData->m_nUsableType = USABLE_TALENT_USE;
pItem->m_pItemData->m_vecUsableParam.push_back(pTalentInfo->m_nID);
pItem->m_pItemData->m_nConditionsInfoID = pConditionsInfo->m_nID;
m_pPlayer->GetPlayerInfo()->nLevel = 9;
CHECK(false == gsys.pItemSystem->GetUser().Use(m_pPlayer, pItem->m_nSlotID));
m_pPlayer->GetPlayerInfo()->nLevel = 10;
CHECK(true == gsys.pItemSystem->GetUser().Use(m_pPlayer, pItem->m_nSlotID));
}
} |
be2a65193c81b0d03e428cdc224a6a305ff5e442 | 67fce22ba3660fd346846e343eb6e739a493958c | /include/BinaryOperator.hpp | 20f9133027c4f06ac83f00d32602fd825b586f28 | [] | no_license | Ziple/ShadeGen | 71e7d75c25f2bad8ec98d263c9c03929bc139c5b | e72b4f9c375f04ad292a5084a2baba7fd6ea01e0 | refs/heads/master | 2016-08-07T20:14:28.262294 | 2014-08-30T17:27:52 | 2014-08-30T17:27:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 418 | hpp | BinaryOperator.hpp | #ifndef __SC_BINRARYOPERATOR_HPP__
#define __SC_BINRARYOPERATOR_HPP__
#include "Operator.hpp"
#include <Utils/SharablePointer.hpp>
class BinaryOperator : public Operator, public Sharable<BinaryOperator>
{
public:
BinaryOperator( Operator::Ptr first, Operator::Ptr second );
void ResolveTypes();
protected:
Operator::Ptr myFirst;
Operator::Ptr mySecond;
};
#endif // __SC_BINRARYOPERATOR_HPP__
|
0707f600618d45ecf36d69d2e4782838a5031609 | c54f156ec3b98a07a760df58a4a05b64d136dad3 | /@fox_radio/addons/@fox_radio/interface.hpp | b635fb434f80f181ad71c544fa60e7bfc6db6a54 | [] | no_license | taskforceheadbanger/fox_radio | 11a9401c29c1ede51a09e1bf97c71d1e092beba2 | 40b8575cf045312094ee574696f445d708093690 | refs/heads/master | 2023-06-12T13:12:08.812553 | 2018-11-24T21:41:23 | 2018-11-24T21:41:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,892 | hpp | interface.hpp | class RscText;
class RscEdit;
class RscPicture;
class RscListBox;
class RscButton;
class fox_radio
{
idd = 6000;
onLoad = "call fox_radio_fnc_open";
onUnload = "";
duration = 32000;
fadeIn = 0;
fadeOut = 0;
enableSimulation = 1;
class controls
{
class background : RscPicture
{
idc = 1623;
x = "SafeZoneX + (460.30048 / 1920) * SafeZoneW";
y = "SafeZoneY + (294.8346 / 1080) * SafeZoneH";
w = "(1000 / 1920) * SafeZoneW";
h = "(500 / 1080) * SafeZoneH";
text = "\fox_radio\radio.paa";
};
class ListMusic : RscListBox
{
idc = 77661;
text = "List Box";
x = "SafeZoneX + (665.000000000001 / 1920) * SafeZoneW";
y = "SafeZoneY + (379.67028 / 1080) * SafeZoneH";
w = "(724.999999999999 / 1920) * SafeZoneW";
h = "(350.000000000001 / 1080) * SafeZoneH";
font = "RobotoCondensed";
colorBackground[] = { 1, 1, 1, 0.3 };
onLBSelChanged = "['onLBSelChanged',_this] call fox_artillery_fnc_handleAction;";
onLBDblClick = "['onLBDblClick',_this] call fox_artillery_fnc_handleAction;";
};
class Stop : RscButton
{
idc = 77652;
x = "SafeZoneX + (515.000000000001 / 1920) * SafeZoneW";
y = "SafeZoneY + (530.8346 / 1080) * SafeZoneH";
w = "(90 / 1920) * SafeZoneW";
h = "(50 / 1080) * SafeZoneH";
text = "Stop";
action = "[vehicle player] call fox_radio_fnc_deleteRadio;";
};
class Play : RscButton
{
idc = 77650;
text = "Play";
x = "SafeZoneX + (515.000000000001 / 1920) * SafeZoneW";
y = "SafeZoneY + (485 / 1080) * SafeZoneH";
w = "(90 / 1920) * SafeZoneW";
h = "(50 / 1080) * SafeZoneH";
action = "[] call fox_radio_fnc_selectMusic;";
};
class AMP : RscButton
{
idc = 77651;
text = "AMP";
x = "SafeZoneX + (515.000000000001 / 1920) * SafeZoneW";
y = "SafeZoneY + (365.000000000001 / 1080) * SafeZoneH";
w = "(90 / 1920) * SafeZoneW";
h = "(50 / 1080) * SafeZoneH";
action = "[] call fox_radio_fnc_setAMP;";
soundClick[] = {"\A3\ui_f\data\sound\RscButton\soundClick",0,1};
soundEnter[] = {"\A3\ui_f\data\sound\RscButton\soundEnter",0,1};
soundEscape[] = {"\A3\ui_f\data\sound\RscButton\soundEscape",0,1};
soundPush[] = {"\A3\ui_f\data\sound\RscButton\soundPush",0,1};
};
class MODE: RscButton
{
idc = 77653;
text = "Public";
x = "SafeZoneX + (515.000000000001 / 1920) * SafeZoneW";
y = "SafeZoneY + (410.000000000001 / 1080) * SafeZoneH";
w = "(90 / 1920) * SafeZoneW";
h = "(50 / 1080) * SafeZoneH";
action = "[] call fox_radio_fnc_setMode;";
soundClick[] = {"\A3\ui_f\data\sound\RscButton\soundClick",0,1};
soundEnter[] = {"\A3\ui_f\data\sound\RscButton\soundEnter",0,1};
soundEscape[] = {"\A3\ui_f\data\sound\RscButton\soundEscape",0,1};
soundPush[] = {"\A3\ui_f\data\sound\RscButton\soundPush",0,1};
};
};
};
|
35b86c0dfa9a810c81148db17e2de68f8ad62fe2 | 2ae43dabf4aa3c43a83c7296c11f312d89e824f6 | /modules/web/Web04_TcpSyncClient/include/FortuneThread.h | ae333206e0a3d073421ccd0dda0647abeac3c8ce | [
"MIT"
] | permissive | chengfzy/QtStudy | 323933b09df0c7f824796038d7b6e6cd1c5bacc3 | 0a3905c038d3fa4bd44da9c18a09036ce6eb83e6 | refs/heads/master | 2023-05-11T13:49:38.765492 | 2023-05-05T01:13:28 | 2023-05-05T01:13:28 | 155,650,217 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 559 | h | FortuneThread.h | #pragma once
#include <QMutex>
#include <QThread>
#include <QWaitCondition>
class FortuneThread : public QThread {
Q_OBJECT
public:
explicit FortuneThread(QObject* parent = nullptr);
~FortuneThread();
public:
void requestNewFortune(const QString& hostName, const quint16& port);
void run() override;
signals:
void newFortune(const QString& fortune);
void error(int socketError, const QString& message);
private:
QString hostName_;
quint16 port_;
QMutex mutex_;
QWaitCondition cond_;
bool quit_;
};
|
1dc70db0bec714fddc295c395cf8439c7f987d9e | e3a97b316fdf07b170341da206163a865f9e812c | /vital/util/compare.h | 7aff18a5632a0e0a8fb543fcea28beb014e2a527 | [
"BSD-3-Clause"
] | permissive | Kitware/kwiver | 09133ede9d05c33212839cc29d396aa8ca21baaf | a422409b83f78f31cda486e448e8009513e75427 | refs/heads/master | 2023-08-28T10:41:58.077148 | 2023-07-28T21:18:52 | 2023-07-28T21:18:52 | 23,229,909 | 191 | 92 | NOASSERTION | 2023-06-26T17:18:20 | 2014-08-22T15:22:20 | C++ | UTF-8 | C++ | false | false | 729 | h | compare.h | // This file is part of KWIVER, and is distributed under the
// OSI-approved BSD 3-Clause License. See top-level LICENSE file or
// https://github.com/Kitware/kwiver/blob/master/LICENSE for details.
/// \file
/// Comparison utilities.
#ifndef KWIVER_VITAL_UTIL_COMPARE_H_
#define KWIVER_VITAL_UTIL_COMPARE_H_
namespace kwiver {
namespace vital {
// ----------------------------------------------------------------------------
/// Return -1 if \p lhs < \p rhs, 1 if \p lhs > \p rhs, or 0 if they are equal.
// TODO(C++20) Replace with <=>
template < class T >
int
threeway_compare( T const& lhs, T const& rhs )
{
return ( lhs < rhs ) ? -1 : ( ( rhs < lhs ) ? 1 : 0 );
}
} // namespace vital
} // namespace kwiver
#endif
|
865e6c4991128b642462500f9aa24c0ee91c5915 | 92ac81571b4f27236fe283bdee4ab9dee1395325 | /DeprecatedCode/Driven/Core/Yw3dShader.h | d52cc7bf0756e5bdd2f5cf224c2f91a1ec28c730 | [
"MIT"
] | permissive | ArcherLew/YwSoftRenderer | 897451685e65581f820c5f30395f55ed0732df03 | 20042112308b7d48951cc9c4497e0d2225f0cf73 | refs/heads/master | 2020-05-31T05:48:45.694625 | 2019-05-25T15:57:01 | 2019-05-25T15:57:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,212 | h | Yw3dShader.h | // Add by Yaukey at 2018-02-22.
// YW Soft Renderer 3d shader class (vertex-shader, triangle-shader and pixel shader).
#ifndef __YW_3D_SHADER_H__
#define __YW_3D_SHADER_H__
#include "Yw3dBase.h"
#include "Yw3dTypes.h"
#include "Yw3dBaseShader.h"
namespace yw
{
// Defines the vertex shader interface.
class IYw3dVertexShader : public IYw3dBaseShader
{
friend class Yw3dDevice;
protected:
// Accessible by Yw3dDevice.
// This is the core function of a vertex shader: It transforms vertex positions to homogeneous clipping space and sets up registers for the pixel shader.
// @param[in] vsShaderInput vertex shader input registers, data is loaded from the active vertex streams.
// @param[out] position vertex position transformed to homogeneous clipping space.
// @param[out] vsShaderOutput vertex shader output registers which will be interpolated and passed to the pixel shader.
virtual void Execute(const Yw3dShaderRegister* vsShaderInput, Vector4& position, Yw3dShaderRegister* vsShaderOutput) = 0;
// Returns the type of a particular output register. Member of the enumeration Yw3dShaderRegType; if a given register is not used, return Yw3d_SRT_Unused.
// @param[in] register index of register, e [0,YW3D_PIXEL_SHADER_REGISTERS].
virtual Yw3dShaderRegisterType GetOutputRegisters(uint32_t register) = 0;
};
// Defines the triangle shader interface.
class IYw3dTriangleShader : public IYw3dBaseShader
{
friend class Yw3dDevice;
protected:
// Accessible by Yw3dDevice.
// This is the core function of a triangle shader: It performs per triangle operations on vertices.
// @param[in,out] shaderRegister0 shader registers outputted from vertex shader for the first triangle vertex.
// @param[in,out] shaderRegister1 shader registers outputted from vertex shader for the second triangle vertex.
// @param[in,out] shaderRegister2 shader registers outputted from vertex shader for the third triangle vertex.
// @note A triangle shader may operate on the registers outputted by the vertex shader.
// @return false if triangle should not be rendered.
virtual bool Execute(Yw3dShaderRegister* shaderRegister0, Yw3dShaderRegister* shaderRegister1, Yw3dShaderRegister* shaderRegister2) = 0;
};
// Defines the pixel shader interface.
class IYw3dPixelShader : public IYw3dBaseShader
{
friend class Yw3dDevice;
protected:
// Accessible by Yw3dDevice which is the only class that may create.
IYw3dPixelShader();
protected:
// Accessible by Yw3dDevice. Returns the type of the pixel shader; member of the enumeration Yw3dPixelShaderOutput. Default: Yw3d_PSO_ColorOnly.
virtual Yw3dPixelShaderOutput GetShaderOutput() { return Yw3d_PSO_ColorOnly; }
// Returns true incase support for pixel-killing for Yw3d_PSO_ColorOnly-shader-types shall be enabled.
virtual bool MightKillPixels() { return true; }
// Accessible by Yw3dDevice.
// This is the core function of a pixel shader: It receives interpolated register data from the vertex shader and can output a new color and depth value for the pixel currently being drawn.
// @param[in] input pixel shader input registers, which have been set up in the vertex shader and interpolated during rasterization.
// @param[in,out] color contains the value of the pixel in the rendertarget when Execute() is called. The pixel shader may perform blending with this value and setting it to a new color. Make sure to override GetShaderOutput() to the correct shader type.
// @param[in,out] depth contains the depth of the pixel in the rendertarget when Execute() is called. The pixel shader may set this to a new value. Make sure to override GetShaderOutput() to the correct shader type.
// @return true if the pixel shall be written to the rendertarget, false in case it shall be killed.
virtual bool Execute(const Yw3dShaderRegister* input, Vector4& color, float& depth) = 0;
protected:
// Accessible by Yw3dDevice - Sets the triangle info.
// @param[in] vsOutputs pointer to the pixel shader input register-types.
// @param[in] triangleInfo pointer to the triangle info structure.
void SetInfo(const Yw3dShaderRegisterType* vsOutputs, const struct Yw3dTriangleInfo* triangleInfo);
// This functions computes the partial derivatives of a shader register with respect to the screen space coordinates.
// @param[in] register index of the source shader register.
// @param[out] ddx partial derivative with respect to the x-screen space coordinate.
// @param[out] ddy partial derivative with respect to the y-screen space coordinate.
void GetPartialDerivatives(uint32_t register, Vector4& ddx, Vector4& ddy) const;
private:
// Register type info.
const Yw3dShaderRegisterType* m_VsOutputs;
// Gradient info about the triangle that is currently being drawn.
const struct Yw3dTriangleInfo* m_TriangleInfo;
};
}
#endif // !__YW_3D_SHADER_H__
|
22aba06e80377c490cc6a10c1c56bf12055f1d84 | bd2ba216e095c26a1fa3145f6cb03d707be3c4f8 | /FileSystemEDII/api.cpp | 5b22bbe0af1654ace90b7c20f78bb6505c0fc614 | [] | no_license | moniquestigter/FileSystemEDII | f0d6bcc4e16d3575743c8a9f3ff0f7752785726d | a7e3ef8bbf0ec8cc5cfd84365f12f4ca9d22983a | refs/heads/master | 2021-01-25T09:20:29.922592 | 2017-06-19T05:04:24 | 2017-06-19T05:04:24 | 93,814,702 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,826 | cpp | api.cpp | #include "api.h"
#include <qmessagebox.h>
API::API()
{
cantIdx = 0;
}
//Funciones para cargar too desde el .txt
BloqueArchivo * API::initArchivoFromChar(char * nombre, BloqueFolder * actual,int nB,int tB,int lB)
{
actual->setCantArchivos(actual);
Archivo * archivo = dv->getArchivo();
archivo->abrir();
BloqueArchivo * ba = new BloqueArchivo(nombre,nB,tB,dv->getArchivo());
ba->setFileEntry(nombre,nB,lB,false,tB);
actual->agregarFileEntry(ba->fe);
actual->listaBloqueArchivo.push_back(ba);
dv->listaBloqueArchivo.push_back(ba);
nombres.push_back(nombre);
return ba;
}
BloqueFolder * API::initFolderFromChar(char * nombre, BloqueFolder * actual,int nB,int tB,int lB)
{
actual->setCantArchivos(actual);
Archivo * archivo = dv->getArchivo();
BloqueFolder * bf = new BloqueFolder(nombre,nB,tB,archivo);
bf->setFileEntry(nombre,nB,lB,true,tB);
actual->agregarFileEntry(bf->fe);
actual->listaBloqueFolder.push_back(bf);
dv->listaBloqueFolder.push_back(bf);
nombres.push_back(nombre);
return bf;
}
int API::initFromChar(BloqueFolder * actual){
char * nombre = {"DiscoVirtual.txt"};
Archivo * arch = new Archivo(nombre,256*4096);
int pos1 = actual->fe->getFirstBLock()*4096;
int lon = (actual->fe->getLastBlock() - actual->fe->getFirstBLock()+1)*4096;
char * data = arch->leer(pos1,lon);
int pos = 0;
int cant;
memcpy(&cant, &(data[pos]), 4);
pos += 4;
for(int x = 0;x<cant;x++){
char * nombre2 = new char[35];
memcpy(nombre2, &(data[pos]), 35);
pos += 35;
int firstBlock;
memcpy(&firstBlock, &(data[pos]), 4);
pos += 4;
int lastBlock;
memcpy(&lastBlock, &(data[pos]), 4);
pos += 4;
bool esFolder;
memcpy(&esFolder, &(data[pos]), 1);
pos += 1;
int size;
memcpy(&size, &(data[pos]), 4);
pos += 4;
if(esFolder == true)
{
BloqueFolder * bf = initFolderFromChar(nombre2,actual,firstBlock,size,lastBlock);
if(lastBlock > dv->mb->getSigDisponible())
dv->mb->setSiguienteDisponible(lastBlock+1);
initFromChar(bf);
}
else if(esFolder == false)
{
initArchivoFromChar(nombre2,actual,firstBlock,size,lastBlock);
}
}
return 0;
}
//Crear Archivo o Folder
void API::addRoot(){
char * ra = {"Raiz"};
BloqueFolder * bloque = new BloqueFolder(ra,1,0,dv->getArchivo());
bloque->setFileEntry(ra,1,3,true,0);
this->root = bloque;
root->listaBloqueArchivo.clear();
root->listaBloqueFolder.clear();
}
BloqueArchivo * API::crearArchivo(char * nombre, BloqueFolder * actual, char * contenido)
{
Archivo * archivo = dv->getArchivo();
archivo->abrir();
int pos = dv->getMasterBlock()->getSigDisponible();
BloqueArchivo * ba = new BloqueArchivo(nombre,pos,strlen(contenido),dv->getArchivo());
actual->fe->setSize(strlen(contenido));
int size = strlen(contenido)/4096;
if(size<1)
{
dv->getMasterBlock()->setSiguienteDisponible(pos+1);
ba->setFileEntry(nombre,pos,pos,false,strlen(contenido));
}
else if(size>=1)
{
if(strlen(contenido)%4096>0)
size++;
dv->getMasterBlock()->setSiguienteDisponible(pos+size);
ba->setFileEntry(nombre,pos,pos+size,false,strlen(contenido));
}
actual->setCantArchivos(actual);
archivo->escribir(contenido,pos*4096,strlen(contenido));
actual->agregarFileEntry(ba->fe);
dv->getHashTable()->agregarIdxEntry(nombre, ba->numBloque,dv->getHashTable()->ie->getNumEntry(),strlen(contenido));
IdxEntry * idx = dv->getHashTable()->hash(nombre);
setCantIdxArchivos();
escribirIdxEntries(idx);
escribirEntries(ba->fe,actual);
actual->listaBloqueArchivo.push_back(ba);
dv->listaBloqueArchivo.push_back(ba);
nombres.push_back(nombre);
return ba;
}
BloqueFolder * API::crearFolder(char * nombre,BloqueFolder * actual)
{
actual->setCantArchivos(actual);
Archivo * archivo = dv->getArchivo();
int pos = dv->getMasterBlock()->getSigDisponible();
BloqueFolder * bf = new BloqueFolder(nombre,pos,0,archivo);
dv->getMasterBlock()->setSiguienteDisponible(pos+1);
bf->setFileEntry(nombre,pos,pos,true,0);
actual->agregarFileEntry(bf->fe);
escribirEntries(bf->fe,actual);
dv->getHashTable()->agregarIdxEntry(nombre, bf->numBloque,dv->getHashTable()->ie->getNumEntry(),0);
IdxEntry * idx = dv->getHashTable()->hash(nombre);
setCantIdxArchivos();
escribirIdxEntries(idx);
actual->listaBloqueFolder.push_back(bf);
dv->listaBloqueFolder.push_back(bf);
nombres.push_back(nombre);
return bf;
}
string API::duplicadosAux(string nombre, int cant,int tamanoPalabra,int tipo)
{
string a = nombre;
for(int x = 0;x<nombres.size();x++)
{
char * charTemp = nombres.at(x);
std::string n(charTemp);
if(toLowerCase(n) == toLowerCase(nombre))
{
string z = to_string(cant);
if(nombre.size() > tamanoPalabra)
a = a.substr(0,nombre.size()-2);
return duplicadosAux(a+"_"+z,cant+1,tamanoPalabra,tipo);
}
}
return nombre;
}
string API::Duplicados(string nombre,int tipo)
{
return duplicadosAux(nombre,1,nombre.size(),tipo);
}
string API::toLowerCase(string palabra)
{
locale loc;
string palabraNueva;
for (string::size_type i=0; i<palabra.length(); ++i)
palabraNueva = palabraNueva+tolower(palabra[i],loc);
return palabraNueva;
}
//Manipular Archivos
char * API::leerArchivoh(char * nombre)
{
char * nombre2 = {"DiscoVirtual.txt"};
Archivo * arch = new Archivo(nombre2,256*4096);
char * contenido = {""};
IdxEntry * idx = dv->getHashTable()->hash(nombre);
int tamano = idx->getSizeBloque();
int numBloque = idx->getNumBloque();
contenido = arch->leer(numBloque*4096,tamano);
return contenido;
}
BloqueFolder * API::abrirFolderh(char * nombre)
{
char * nombre2 = {"DiscoVirtual.txt"};
Archivo * arch = new Archivo(nombre2,256*4096);
char * data;
IdxEntry * idx = dv->getHashTable()->hash(nombre);
int tamano = idx->getSizeBloque();
int numBloque = idx->getNumBloque();
data = arch->leer(numBloque*4096,tamano);
BloqueFolder * bf = new BloqueFolder(nombre,numBloque,tamano,arch);
int pos = 0;
int cant;
memcpy(&cant, &(data[pos]), 4);
pos += 4;
for(int x = 0;x<cant;x++){
char * n = new char[35];
memcpy(n, &(data[pos]), 35);
pos += 35;
int firstBlock;
memcpy(&firstBlock, &(data[pos]), 4);
pos += 4;
int lastBlock;
memcpy(&lastBlock, &(data[pos]), 4);
pos += 4;
bool esFolder;
memcpy(&esFolder, &(data[pos]), 1);
pos += 1;
int size;
memcpy(&size, &(data[pos]), 4);
pos += 4;
FileEntry * fe = new FileEntry();
fe->setTodoFileEntry(n,firstBlock,lastBlock,esFolder,size);
bf->agregarFileEntry(fe);
}
return bf;
}
//Crear Disco
void API::crearDiscoVirtual()
{
char * c = {"DiscoVirtual.txt"};
Archivo * archivo = new Archivo(c,1048576);
dv = new DiscoVirtual(archivo,1048576,4096);
dv->cargar();
addRoot();
dv->setFolderActual(root);
dv->mb->setSiguienteDisponible(7);
}
void API::formatear()
{
FILE * file = fopen("DiscoVirtual.txt","w");
fseek(file,4096*256,SEEK_SET);
fputc('\0',file);
fclose(file);
dv->listaBloqueArchivo.clear();
dv->listaBloqueFolder.clear();
nombres.clear();
dv->formatear();
addRoot();
dv->setFolderActual(root);
}
//Entries y idxEntries
void API::escribirEntries(FileEntry *fe,BloqueFolder * actual)
{
char * data = new char[48];
int firstBlock = fe->getFirstBLock();
int lastBlock = fe->getLastBlock();
int size = fe->getSize();
int esFolder = fe->getEsFolder();
int pos = 0;
memcpy(&data[pos], fe->getNombre(), 32);
pos+=35;
memcpy(&data[pos], &firstBlock,4);
pos+=4;
memcpy(&data[pos], &lastBlock, 4);
pos+=4;
memcpy(&data[pos], &esFolder, sizeof(bool));
pos+=1;
memcpy(&data[pos], &size, 4);
pos+=4;
dv->getArchivo()->abrir();
int x = actual->listaEntries.size();
dv->getArchivo()->escribir(data,(4096*actual->fe->getFirstBLock())+(x*48)-48+4,48);
}
void API::setCantIdxArchivos()
{
cantIdx++;
char * nombre = {"DiscoVirtual.txt"};
Archivo * arch = new Archivo(nombre,256*4096);
char * cant = new char[4];
memcpy(&cant[0], &cantIdx , 4);
arch->escribir(cant,(4096*4),4);
}
void API::escribirIdxEntries(IdxEntry * ie){
char * data = new char[47];
int numBlock = ie->getNumEntry();
int numEnt = ie->getNumEntry();
int size = ie->getSizeBloque();
int pos = 0;
memcpy(&data[pos], ie->getNombre(), 35);
pos+=35;
memcpy(&data[pos], &numBlock, 4);
pos+=4;
memcpy(&data[pos], &numEnt, 4);
pos+=4;
memcpy(&data[pos], &size, 4);
pos+=4;
dv->getArchivo()->abrir();
int x = dv->getHashTable()->hashTable.size();
dv->getArchivo()->escribir(data,(4096*4)+(x*47)+4,47);
}
void API::initIDX(){
char * nombre = {"DiscoVirtual.txt"};
Archivo * arch = new Archivo(nombre,256*4096);
char * data = arch->leer(4096*4,4096*3);
int pos = 0;
int cant;
memcpy(&cant, &(data[pos]), 4);
pos += 4;
for(int x = 0;x<cant;x++){
char * nombre = new char[35];
memcpy(nombre, &(data[pos]), 35);
pos += 35;
int bloque;
memcpy(&bloque, &(data[pos]), 4);
pos += 4;
int numE;
memcpy(&numE, &(data[pos]), 4);
pos += 4;
int size;
memcpy(&size, &(data[pos]), 4);
pos += 4;
dv->getHashTable()->agregarIdxEntry(nombre, bloque,numE,size);
}
cantIdx = cant;
}
char * API::leerArchivo(char *nombre, BloqueFolder *actual){
char * contenido = {""};
for(int x = 0;x < actual->listaBloqueArchivo.size();x++)
{
char * n = actual->listaBloqueArchivo.at(x)->nombre;
if(strcmp(n,nombre)==0)
{
contenido = actual->listaBloqueArchivo.at(x)->leer();
return contenido;
}
}
return NULL;
}
BloqueFolder * API::abrirFolder(char * nombre,BloqueFolder * actual)
{
for(int x = 0;x < actual->listaBloqueFolder.size();x++)
{
char * n = actual->listaBloqueFolder.at(x)->nombre;
if(strcmp(n,nombre)==0)
{
dv->setFolderActual(actual->listaBloqueFolder.at(x));
return actual->listaBloqueFolder.at(x);
}
}
return NULL;
}
|
95b172aaa3e010033752a592fddf31c54b0a92dc | ac18a18cb845eeaec55ed6974199e0f0cfc20203 | /h/Semap.h | 847ba12e4ba109b48d71333385c8d174b2a5fcdb | [
"MIT"
] | permissive | ZivkovicA013/OSKernel | 454f8c4671777d53f124eca80d0ff9d52ad35525 | 911973d5f6ded370b9a73360e994ae9913e12cb8 | refs/heads/master | 2022-11-13T20:23:20.456164 | 2020-07-14T14:54:24 | 2020-07-14T14:54:24 | 255,463,142 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 436 | h | Semap.h | /*
* Semap.h
*
* Created on: Apr 25, 2020
* Author: OS1
*/
#ifndef SEMAP_H_
#define SEMAP_H_
#include"KerSem.h"
typedef unsigned int Time;
class Semaphore {
public:
Semaphore(int init=1);
virtual int wait(Time maxTimeToWait);
virtual int signal(int n=0);
int val () const;
KernelSem* GetMyImpl();
virtual ~Semaphore();
private:
KernelSem* myImpl;
};
#endif /* SEMAP_H_ */
|
3b3a8f7509477d5ff28f69b5204cfbb04559662b | a8c3a937f0bd4a119ee268744fc46dbc02102883 | /tetris/Game/MemoryClass.cc | 0d93bfad9fccb0c46bb308f7e0b2e8a1ef497100 | [] | no_license | alexch/www.stinky.com | c1206ddba915daac40a6e6c7cb81ed292a98a7d2 | ec2bbdc7c23632414540844e2ffc0dcccf0c2626 | HEAD | 2016-08-04T23:11:30.754826 | 2015-08-12T17:26:16 | 2015-08-12T17:26:16 | 7,101,205 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 860 | cc | MemoryClass.cc | #include "MemoryClass.h"
#ifdef MACINTOSH
#include <stdlib.h>
#else
#include <stdlib.h>
#endif
#include "assert.h"
#define ASSERT assert
MemoryClass::MemoryClass(int size)
{
ASSERT(size >= 0 && size < MaxMemSize);
this->size = size;
data = (int*) malloc(sizeof(int) * size);
}
MemoryClass::~MemoryClass(void)
{
free(data);
}
MemoryClass * MemoryClass::Copy(void)
{
MemoryClass * mem = new MemoryClass(size);
memcpy(mem->data, this->data, size * sizeof(int));
return mem;
}
int MemoryClass::Peek(int i)
{
ASSERT( i >= 0 && i < size );
return data[i];
}
int MemoryClass::Poke(int i, int val)
{
int valOld = Peek(i);
data[i] = val;
return valOld;
}
void MemoryClass::Clear(void)
{
int i;
for (i=0; i<size; ++i)
data[i] = 0;
}
int MemoryClass::GetSize(void)
{
return size;
}
/* EOF */
|
3bcc84e0e483319a31d57570e1078633335e0562 | fed8f16e93f9a63d5bc350fbf6b2086c21b4843f | /Graph Theory/MST Kruskal's algorithm.cpp | 01f07ce0ae6a13c0a57b33a5fbe9b93c5e3c3bfd | [] | no_license | marksman2op/cp | 199faabccd7cc7764c81e93a15ef88fef16f8414 | bda1bf982f4fbc8498579d4d9b30b43ef0f80b5d | refs/heads/master | 2023-08-17T10:16:13.123785 | 2021-10-04T07:59:39 | 2021-10-04T07:59:39 | 244,225,646 | 1 | 0 | null | 2020-07-23T19:02:22 | 2020-03-01T21:21:42 | C++ | UTF-8 | C++ | false | false | 1,997 | cpp | MST Kruskal's algorithm.cpp | // Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long
/*
MST with Krushkal's Algorithm
- The graph must be: Weighted, Undirected, Connected/Disconnected
- Runs for disconnected graph without any modifications.
- Steps:
- Sort all the edges in non-decreasing order of their weight.
- Pick the smallest edge. Check if it forms a cycle with the spanning-tree formed so far. If the cycle is not formed, include this edge. Else, discard it.
- Repeat step#2 until there are (V - 1) edges in the spanning tree.
- https://stackoverflow.com/questions/1195872/when-should-i-use-kruskal-as-opposed-to-prim-and-vice-versa
- Time complexity: O(E log (V) + V + E) ≡ O(E log (V))
*/
struct Edge {
int u, v, w;
bool operator<(Edge const& other) {
return w < other.w;
}
};
const int N = 1e5 + 5;
int n, m;
vector<Edge> edges;
vector<int> rnk(N), par(N);
void init(int v) {
par[v] = v;
rnk[v] = 0;
}
int find(int v) {
if (v == par[v])
return v;
return par[v] = find(par[v]);
}
void union_sets(int a, int b) {
a = find(a);
b = find(b);
if (a != b) {
if (rnk[a] < rnk[b])
swap(a, b);
par[b] = a;
if (rnk[a] == rnk[b])
rnk[a]++;
}
}
void kruskal() {
int cost = 0;
vector<Edge> res;
for (int i = 1; i <= n; i++)
init(i);
sort(edges.begin(), edges.end());
for (Edge e : edges) {
if (find(e.u) != find(e.v)) {
cost += e.w;
res.push_back(e);
union_sets(e.u, e.v);
}
}
cout << cost << '\n';
}
signed main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T = 1;
// cin >> T;
while (T--) {
cin >> n >> m;
while (m--) {
int u, v, w;
cin >> u >> v >> w;
edges.push_back({u, v, w});
}
kruskal();
}
return 0;
}
|
e0c3cc470365e6e0753a73ffe2414f83e0657e5f | 52e41e2f7d6f77fab7246954d56cc38ad25a5489 | /23_min_spanning_tree/kruscal.cpp | eef0249be1ad33fe8756a46647f258cb5e9d076e | [] | no_license | shulgaalexey/algorithms | 70b0c00eda5bf7c6010ad38e23027f967ff254c5 | 602fa48595bb6465a884897c0dfb2b01d6fd84de | refs/heads/master | 2020-04-12T03:53:54.800527 | 2017-02-08T08:25:51 | 2017-02-08T08:25:51 | 65,423,784 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,979 | cpp | kruscal.cpp | #include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
class edge {
public:
char from;
char to;
int w;
edge(char f, char t, int _w) : from(f), to(t), w(_w) {}
};
bool edgesort(edge a, edge b)
{
return a.w < b.w;
}
vector<edge> min_spanning_tree(const vector<char> &V, vector<edge> &E)
{
map<char, set<char> *> parts;
vector<set<char> *> __PPOOL;
for (size_t i = 0; i < V.size(); i++) {
set<char> *p = new set<char>();
p->insert(V[i]);
parts[V[i]] = p;
__PPOOL.push_back(p);
}
std::sort(E.begin(), E.end(), edgesort);
vector<edge> spanning_tree;
for (size_t i = 0; i < E.size(); i++) {
const edge e = E[i];
set<char> *pfrom = parts[e.from];
set<char> *pto = parts[e.to];
if (pfrom != pto) {
spanning_tree.push_back(e);
if (pfrom->size() < pto->size()) {
for (set<char>::iterator it = pfrom->begin();
it != pfrom->end(); ++it) {
pto->insert(*it);
parts[*it] = pto;
}
} else {
for (set<char>::iterator it = pto->begin();
it != pto->end(); ++it) {
pfrom->insert(*it);
parts[*it] = pfrom;
}
}
}
}
for (size_t i = 0; i < __PPOOL.size(); i++)
delete __PPOOL[i];
return spanning_tree;
}
int main(void)
{
vector<char> V;
for (char ch = 'a'; ch <= 'i'; ch++)
V.push_back(ch);
vector<edge> E;
E.push_back(edge('a', 'b', 4));
E.push_back(edge('a', 'h', 8));
E.push_back(edge('b', 'h', 11));
E.push_back(edge('b', 'c', 8));
E.push_back(edge('c', 'i', 2));
E.push_back(edge('c', 'd', 7));
E.push_back(edge('c', 'f', 4));
E.push_back(edge('d', 'e', 9));
E.push_back(edge('d', 'f', 14));
E.push_back(edge('e', 'f', 10));
E.push_back(edge('g', 'f', 2));
E.push_back(edge('g', 'h', 1));
vector<edge> MST = min_spanning_tree(V, E);
int total = 0;
for (size_t i = 0; i < MST.size(); i++) {
cout << MST[i].from << ", " << MST[i].to << endl;
total += MST[i].w;
}
cout << "total: " << total << endl;
return 0;
}
|
0b19e7005cfc8336336e142410767fb742da3d3f | c20b9846c869cc6b9d745122788d32a34657d75b | /main.cpp | c3d7970634efb6eb24b00b44e98a101b62b7c38f | [] | no_license | persja40/PSRS_p2 | e06f977cd9c5406646004d67cdf64ee3499e9d79 | ea9709565b043c31cc26d8a239597690a4fc1bc4 | refs/heads/master | 2020-03-14T05:40:58.610691 | 2018-05-05T08:41:02 | 2018-05-05T08:41:02 | 131,469,353 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,112 | cpp | main.cpp | #include <upcxx/upcxx.hpp>
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <future>
#include <limits>
#include <utility>
using namespace std;
int main(int argc, char *argv[])
{
// setup UPC++ runtime
upcxx::init();
int numprocs = upcxx::rank_n();
int myid = upcxx::rank_me();
// PHASE I
// read data from file
upcxx::global_ptr<int> global_data_size = nullptr;
upcxx::global_ptr<int> global_data = nullptr;
if (myid == 0)
{
string input_file;
if (argc == 2)
input_file = argv[1];
else
input_file = "example.txt";
ifstream ifile;
vector<int> data_to_sort{};
ifile.open(input_file);
while (!ifile.eof())
{
int t;
ifile >> t;
data_to_sort.push_back(t);
}
ifile.close();
global_data_size = upcxx::new_<int>(data_to_sort.size());
global_data = upcxx::new_array<int>(data_to_sort.size());
auto iter = global_data;
for (int i = 0; i < data_to_sort.size(); i++)
{
upcxx::rput(data_to_sort[i], iter).wait();
iter++;
}
}
global_data_size = upcxx::broadcast(global_data_size, 0).wait();
global_data = upcxx::broadcast(global_data, 0).wait();
// PHASE II
auto fut = rget(global_data_size);
fut.wait();
int size = fut.result();
{
int min_index = ceil(static_cast<double>(myid) / numprocs * size); //start from this index
int limit = ceil(static_cast<double>(myid + 1) / numprocs * size);
int max_index = limit > size ? size : limit; //end before this
vector<int> local_data{};
for (int i = min_index; i < max_index; i++)
{
auto fut = rget(global_data + i);
fut.wait();
local_data.push_back(fut.result());
}
sort(begin(local_data), end(local_data));
for (int i = 0; i < local_data.size(); i++)
upcxx::rput(local_data[i], global_data + min_index + i).wait();
// cout << "ID: " << myid << " start " << min_index << " stop " << max_index << endl;
}
// PHASE III
upcxx::barrier();
upcxx::global_ptr<int> final_data = nullptr;
upcxx::global_ptr<int> data_part = nullptr;
if (myid == 0)
{
vector<int> piv{};
for (int i = 0; i < numprocs; i++) //each thread
{
int min_index = ceil(static_cast<double>(i) / numprocs * size); //start from this index
int limit = ceil(static_cast<double>(i + 1) / numprocs * size);
int max_index = limit > size ? size : limit; //end before this
for (int j = 0; j < numprocs; j++)
{ //find thread_nr pivots
auto fut = rget(global_data + min_index + round(j * static_cast<double>(max_index - min_index) / (numprocs)));
fut.wait();
piv.push_back(fut.result());
}
}
sort(begin(piv), end(piv));
// cout << "Piv: ";
// for (const auto &e : piv)
// cout << e << " ";
// cout << endl;
vector<int> pivots{};
final_data = upcxx::new_array<int>(size);
for (int i = 1; i < numprocs; i++) //select pivots value
pivots.push_back(piv[numprocs * i]);
pivots.push_back(std::numeric_limits<int>::max()); //fake max pivot for iteration in phase iv
// cout << "Pivots: ";
// for (const auto &e : pivots)
// cout << e << " ";
// cout << endl;
// PHASE IV
vector<vector<int>> merge_data{};//size of local tables when size%numrpocs!=0 will slightly change
for (int i = 0; i < numprocs; i++)
merge_data.push_back(*new vector<int>());
vector<int> ind(numprocs); //indexes for iteration over final_data
fill(begin(ind), end(ind), 0);
vector<pair<int, int>> piv_ind{}; //pivot's indexes <start, max> for each thread
for (int i = 0; i < numprocs; i++)
{
int min_index = ceil(static_cast<double>(i) / numprocs * size); //start from this index
int limit = ceil(static_cast<double>(i + 1) / numprocs * size);
int max_index = limit > size ? size : limit; //end before this
piv_ind.push_back(make_pair(min_index, max_index));
}
// cout << "Pivots indexes: ";
// for (const auto &e : piv_ind)
// cout << get<0>(e) << ":" << get<1>(e) << " ";
// cout << endl;
data_part = upcxx::new_<int>(numprocs);
for (int i = 0; i < numprocs; i++)
{ //each thread
int curr_piv = 0; //current pivot
int range = get<1>(piv_ind[i]) - get<0>(piv_ind[i]);
for (int j = 0; j < range; j++)
{
auto fut = rget(global_data + j + get<0>(piv_ind[i]));
fut.wait();
int v = fut.result();
if (v < pivots[curr_piv])
{
merge_data[curr_piv].push_back(v);
ind[curr_piv]++;
}
else
{ //retry with next pivot
curr_piv++;
j--;
continue;
}
}
}
// cout << "Ind: ";
// for (const auto &e : ind)
// cout << e << " ";
// cout << endl;
// cout << "Merge_data: " << endl;
// for (const auto &e : merge_data)
// {
// for (const auto &f : e)
// cout << f << " ";
// cout << endl;
// }
int t = 0;
int d = 0;
int inx = 0;
for (const auto &e : merge_data)
{
for (const auto &f : e)
{
upcxx::rput(f, final_data + t).wait();
t++;
}
inx += e.size();
upcxx::rput(inx, data_part + d).wait();
d++;
}
upcxx::delete_array(global_data);
}
final_data = upcxx::broadcast(final_data, 0).wait();
data_part = upcxx::broadcast(data_part, 0).wait();
// PHASE V
{
int min_index;
if (myid == 0)
min_index = 0;
else
{
auto fut = rget(data_part + myid - 1);
fut.wait();
min_index = fut.result();
}
auto fut = rget(data_part + myid);
fut.wait();
int max_index = fut.result();
vector<int> local_data{};
for (int i = min_index; i < max_index; i++)
{
auto fut = rget(final_data + i);
fut.wait();
local_data.push_back(fut.result());
}
sort(begin(local_data), end(local_data));
for (int i = 0; i < local_data.size(); i++)
upcxx::rput(local_data[i], final_data + min_index + i).wait();
// cout << "ID: " << myid << " start " << min_index << " stop " << max_index << endl;
}
upcxx::barrier();
//Check if sorted
if (myid == 0)
{
vector<int> check{};
for (int i = 0; i < size; i++)
{
auto fut = rget(final_data + i);
fut.wait();
check.push_back(fut.result());
}
cout << "Is it sorted: " << is_sorted(begin(check), end(check)) << endl;
ofstream ofile;
ofile.open("result.txt");
for (auto &e : check)
ofile << e << " ";
ofile.close();
}
//COUT TEST SECTION
// if (myid == 0)
// cout << "liczba wątków: " << numprocs << endl;
// if (myid == 2)
// {
// auto fut = rget(global_data_size);
// fut.wait();
// cout << "Ilosc elem: " << fut.result() << endl;
// }
// upcxx::barrier();
// if (myid == 2)
// {
// for (int i = 0; i < numprocs - 1; i++)
// {
// auto fut = rget(pivots + i);
// fut.wait();
// cout << fut.result() << " ";
// }
// cout << endl;
// }
// if (myid == 2)
// {
// cout << "Final data: ";
// for (int i = 0; i < size; i++)
// {
// auto fut = rget(final_data + i);
// fut.wait();
// cout << fut.result() << " ";
// }
// cout << endl;
// }
// if (myid == 1)
// {
// cout << "Data part: ";
// for (int i = 0; i < numprocs; i++)
// {
// auto fut = rget(data_part + i);
// fut.wait();
// cout << fut.result() << " ";
// }
// cout << endl;
// }
// if (myid == 1)
// {
// cout << "Global data: ";
// for (int i = 0; i < size; i++)
// {
// auto fut = rget(global_data + i);
// fut.wait();
// cout << fut.result() << " ";
// }
// cout << endl;
// }
// close down UPC++ runtime
upcxx::finalize();
return 0;
}
|
36e2d60dec06107bea6c14e2e3e6e67a70689f69 | 853051eb473691ee9cdea4651913db38cb6e49d4 | /sources/common/test/unitTest/EventSignal.cpp | 8744b4b4a981df91e62a3ee2437102fb12f2563f | [
"MIT"
] | permissive | WojciechRynczuk/vcdMaker | fb67c74cc2d89da586f0d108ac673c34be7a8a5a | 9432d45164806d583016df586f515b0e335304e6 | refs/heads/v4_release | 2021-07-09T02:16:25.451579 | 2020-12-27T18:09:40 | 2020-12-27T18:09:40 | 46,375,377 | 34 | 1 | MIT | 2020-12-27T18:09:41 | 2015-11-17T21:04:52 | C++ | UTF-8 | C++ | false | false | 3,025 | cpp | EventSignal.cpp | /// @file common/test/unitTest/EventSignal.cpp
///
/// Unit test for EventSignal class.
///
/// @ingroup UnitTest
///
/// @par Copyright (c) 2017 vcdMaker team
///
/// Permission is hereby granted, free of charge, to any person obtaining a
/// copy of this software and associated documentation files (the "Software"),
/// to deal in the Software without restriction, including without limitation
/// the rights to use, copy, modify, merge, publish, distribute, sublicense,
/// and/or sell copies of the Software, and to permit persons to whom the
/// Software is furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included
/// in all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
/// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
/// IN THE SOFTWARE.
#include "catch.hpp"
#include "EventSignal.h"
#include "stub/DummySignal.h"
/// Create valid VCD line for EventSignal.
static inline std::string getEventSignalPrint()
{
return ('1' + std::string(DummySignal::DUMMY_NAME));
}
/// Create EventSignal.
static inline SIGNAL::EventSignal getEventSignal()
{
return {DummySignal::DUMMY_NAME,
DummySignal::DUMMY_TIMESTAMP,
DummySignal::DUMMY_HANDLE};
}
/// Unit test for EventSignal::Print().
TEST_CASE("EventSignal::Print")
{
const SIGNAL::EventSignal signal = getEventSignal();
const std::string expectedPrint = getEventSignalPrint();
REQUIRE(signal.Print() == expectedPrint);
}
/// Unit test for EventSignal::Footprint().
TEST_CASE("EventSignal::Footprint")
{
const SIGNAL::EventSignal signal = getEventSignal();
REQUIRE(signal.Footprint().empty());
}
/// Unit test for EventSignal::EqualTo().
/// Note that EventSignal compares false to everything.
TEST_CASE("EventSignal::EqualTo")
{
SIGNAL::EventSignal signal1 = getEventSignal();
SIGNAL::Signal &rSignal1 = signal1;
SIGNAL::EventSignal signal2 = getEventSignal();
SIGNAL::Signal &rSignal2 = signal2;
DummySignal dummySignal(DummySignal::DUMMY_NAME,
DummySignal::DUMMY_TIMESTAMP);
SIGNAL::Signal &rDummySignal = dummySignal;
SECTION("operator==")
{
REQUIRE_FALSE(rSignal1 == rSignal1);
REQUIRE_FALSE(rSignal1 == rSignal2);
REQUIRE_FALSE(rSignal1 == rDummySignal);
REQUIRE_FALSE(rDummySignal == rSignal1);
}
SECTION("operator!=")
{
REQUIRE(rSignal1 != rSignal1);
REQUIRE(rSignal1 != rSignal2);
REQUIRE(rSignal1 != rDummySignal);
REQUIRE(rDummySignal != rSignal1);
}
}
|
79f6feb3913d8051bf7988535148c9828f8c9357 | 456d4a833e9e1aedb204b88593e572a24627a4d0 | /src/core/renderer/src/main/c++/dormouse-engine/renderer/shader/Technique.cpp | 912684fca3fe6bc20493653c9e1628b68769a25f | [
"MIT"
] | permissive | blockspacer/dormouse-engine | 14342768be3db8ae8dcf9e8b3f86c87f0c4b5929 | 07ab12f2aaad2a921299d4e9b8f89c97c9ee8da5 | refs/heads/master | 2021-08-27T21:27:35.493849 | 2017-10-22T12:43:40 | 2017-10-22T12:43:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 675 | cpp | Technique.cpp | #include "Technique.hpp"
using namespace dormouse_engine;
using namespace dormouse_engine::renderer;
using namespace dormouse_engine::renderer::shader;
void Technique::bind(graphics::CommandList& commandList) const {
inputLayout_.bind(commandList);
vertexShader_.bind(commandList);
geometryShader_.bind(commandList);
domainShader_.bind(commandList);
hullShader_.bind(commandList);
pixelShader_.bind(commandList);
}
void Technique::render(command::DrawCommand& cmd, const Property& root) const
{
vertexShader_.render(cmd, root);
geometryShader_.render(cmd, root);
domainShader_.render(cmd, root);
hullShader_.render(cmd, root);
pixelShader_.render(cmd, root);
}
|
3059e7ab24d6f56f6f0d2b7f86ad825006913d23 | 225e224f2d06bf34d30bb221d3a513527a6d123f | /tests/serializable/interfaces/comparable.cpp | 1372232a3ea7ae48cb707a4fd5911facea5bd3a6 | [
"MIT"
] | permissive | molw5/framework | 68763ceb6ba52c43262d7084530953d436ef98b9 | 4ebb4ff15cc656f60bd61626a0893c02e5f3bbcd | refs/heads/master | 2021-01-10T21:33:59.970104 | 2013-04-10T23:15:31 | 2013-04-11T00:44:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,142 | cpp | comparable.cpp | // Copyright (C) 2012 iwg molw5
// For conditions of distribution and use, see copyright notice in COPYING
#include <iostream>
#include <sstream>
#include <array>
#include <UnitTest++/UnitTest++.h>
#include <framework/serializable/base_types.hpp>
#include <framework/serializable/inline_object.hpp>
#include <framework/serializable/containers/value.hpp>
#include <framework/serializable/common_macros.hpp>
SUITE(framework_serializable_interfaces_comparable_hpp)
{
TEST(Basic)
{
using namespace framework::serializable;
using test_type = inline_object <
value <NAME("Field 1"), uint64_t>,
value <NAME("Field 2"), float>>;
test_type const lhs {1, 2.0f};
test_type const rhs_equal {1, 2.0f};
test_type const rhs_less {1, 1.0f};
test_type const rhs_greater {1, 3.0f};
// lhs == rhs
CHECK(!less(lhs, rhs_equal));
CHECK(!less(rhs_equal, lhs));
// rhs < lhs
CHECK(!less(lhs, rhs_less));
CHECK(less(rhs_less, lhs));
// lhs < rhs
CHECK(less(lhs, rhs_greater));
CHECK(!less(rhs_greater, lhs));
}
TEST(Helpers)
{
using namespace framework::serializable;
using test_type = inline_object <
value <NAME("Field 1"), int>>;
for (int i=-10; i < 10; ++i)
{
for (int j=-10; j < 10; ++j)
{
test_type const lhs {i};
test_type const rhs {j};
if (i < j) CHECK(less(lhs, rhs));
else CHECK(!less(lhs, rhs));
if (i > j) CHECK(greater(lhs, rhs));
else CHECK(!greater(lhs, rhs));
if (i <= j) CHECK(less_or_equal(lhs, rhs));
else CHECK(!less_or_equal(lhs, rhs));
if (i >= j) CHECK(greater_or_equal(lhs, rhs));
else CHECK(!greater_or_equal(lhs, rhs));
if (i == j) CHECK(equal(lhs, rhs));
else CHECK(!equal(lhs, rhs));
}
}
}
}
|
9d5a055389e7bfd65263161411805b764706d73e | 7f62f204ffde7fed9c1cb69e2bd44de9203f14c8 | /NtlLib/Server/servercommon/EventableObject.cpp | 5539e67d1503a59abd4916b0681088b2d7192722 | [] | no_license | 4l3dx/DBOGLOBAL | 9853c49f19882d3de10b5ca849ba53b44ab81a0c | c5828b24e99c649ae6a2953471ae57a653395ca2 | refs/heads/master | 2022-05-28T08:57:10.293378 | 2020-05-01T00:41:08 | 2020-05-01T00:41:08 | 259,094,679 | 3 | 3 | null | 2020-04-29T17:06:22 | 2020-04-26T17:43:08 | null | UTF-8 | C++ | false | false | 7,715 | cpp | EventableObject.cpp | #include "stdafx.h"
#include "EventableObject.h"
EventableObject::~EventableObject()
{
/* decrement event count on all events */
//if (m_events.size() == 0)
// return;
//EventMap::iterator itr = m_events.begin();
//for(; itr != m_events.end(); ++itr)
//{
// itr->second->deleted = true;
// itr->second->DecRef();
//}
//m_events.clear();
}
EventableObject::EventableObject()
{
/* commented, these will be allocated when the first event is added. */
m_holder = 0;
m_event_Instanceid = -1;
}
void EventableObject::event_AddEvent(TimedEvent * ptr)
{
if(!m_holder)
{
m_event_Instanceid = event_GetInstanceID();
m_holder = g_pEventMgr->GetEventHolder(m_event_Instanceid);
}
ptr->IncRef();
ptr->instanceId = m_event_Instanceid;
std::pair<unsigned int,TimedEvent*> p(ptr->eventType, ptr);
m_events.insert( p );
/* Add to event manager */
if(!m_holder)
{
/* relocate to -1 eventholder :/ */
m_event_Instanceid = -1;
m_holder = g_pEventMgr->GetEventHolder(m_event_Instanceid);
NTL_ASSERT(m_holder);
}
m_holder->AddEvent(ptr);
}
void EventableObject::event_RemoveByPointer(TimedEvent * ev)
{
EventMap::iterator itr = m_events.find(ev->eventType);
EventMap::iterator it2;
if(itr != m_events.end())
{
do
{
it2 = itr++;
if(it2->second == ev)
{
it2->second->deleted = true;
// it2->second->DecRef();
// m_events.erase(it2);
return;
}
} while(itr != m_events.upper_bound(ev->eventType));
}
}
void EventableObject::event_RemoveEvents(unsigned int EventType)
{
if(m_events.size() == NULL)
{
return;
}
if(EventType == EVENT_REMOVAL_FLAG_ALL)
{
EventMap::iterator itr = m_events.begin();
for(; itr != m_events.end(); ++itr)
{
itr->second->deleted = true;
//itr->second->DecRef();
}
//m_events.clear();
}
else
{
EventMap::iterator itr = m_events.find(EventType);
EventMap::iterator it2;
if(itr != m_events.end())
{
do
{
it2 = itr++;
it2->second->deleted = true;
// it2->second->DecRef();
// m_events.erase(it2);
} while(itr != m_events.upper_bound(EventType));
}
}
}
void EventableObject::event_RemoveEvents()
{
event_RemoveEvents(EVENT_REMOVAL_FLAG_ALL);
}
void EventableObject::event_ModifyTimeLeft(unsigned int EventType, DWORD TimeLeft,bool unconditioned)
{
if(!m_events.size())
{
return;
}
EventMap::iterator itr = m_events.find(EventType);
if(itr != m_events.end())
{
do
{
if(unconditioned)
itr->second->currTime = TimeLeft;
else itr->second->currTime = ((signed __int32)TimeLeft > itr->second->msTime) ? itr->second->msTime : (signed __int32)TimeLeft;
++itr;
} while(itr != m_events.upper_bound(EventType));
}
}
bool EventableObject::event_GetTimeLeft(unsigned int EventType, unsigned int * Time)
{
if(!m_events.size())
{
return false;
}
EventMap::iterator itr = m_events.find(EventType);
if(itr != m_events.end())
{
do
{
if( itr->second->deleted )
{
++itr;
continue;
}
*Time = (unsigned int)itr->second->currTime;
return true;
} while(itr != m_events.upper_bound(EventType));
}
return false;
}
void EventableObject::event_ModifyTime(unsigned int EventType, DWORD Time)
{
if(!m_events.size())
{
return;
}
EventMap::iterator itr = m_events.find(EventType);
if(itr != m_events.end())
{
do
{
itr->second->msTime = Time;
++itr;
} while(itr != m_events.upper_bound(EventType));
}
}
void EventableObject::event_ModifyTimeAndTimeLeft(unsigned int EventType, DWORD Time)
{
if(!m_events.size())
{
return;
}
EventMap::iterator itr = m_events.find(EventType);
if(itr != m_events.end())
{
do
{
itr->second->currTime = itr->second->msTime = Time;
++itr;
} while(itr != m_events.upper_bound(EventType));
}
}
bool EventableObject::event_HasEvent(unsigned int EventType)
{
bool ret = false;
if(!m_events.size())
{
return false;
}
//ret = m_events.find(EventType) == m_events.end() ? false : true;
EventMap::iterator itr = m_events.find(EventType);
if(itr != m_events.end())
{
do
{
if(!itr->second->deleted)
{
ret = true;
break;
}
++itr;
} while(itr != m_events.upper_bound(EventType));
}
return ret;
}
DWORD EventableObject::event_GetTimeLeft(unsigned int EventType)
{
if (!m_events.size())
{
return 0;
}
EventMap::iterator itr = m_events.find(EventType);
if (itr != m_events.end())
{
return itr->second->msTime;
}
return 0;
}
DWORD EventableObject::event_GetRepeatLeft(unsigned int EventType)
{
if (!m_events.size())
{
return 0;
}
EventMap::iterator itr = m_events.find(EventType);
if (itr != m_events.end())
{
return itr->second->repeats;
}
return 0;
}
EventableObjectHolder::EventableObjectHolder(int instance_id) : m_InstanceId(instance_id)
{
g_pEventMgr->AddEventHolder(this, instance_id);
}
EventableObjectHolder::~EventableObjectHolder()
{
g_pEventMgr->RemoveEventHolder(this);
/* decrement events reference count */
EventList::iterator itr = m_events.begin();
for(; itr != m_events.end(); ++itr)
(*itr)->DecRef();
}
void EventableObjectHolder::Update(DWORD time_difference)
{
/* Insert any pending objects in the insert pool. */
//InsertableQueue::iterator iqi;
//InsertableQueue::iterator iq2 = m_insertPool.begin();
//while(iq2 != m_insertPool.end())
//{
// iqi = iq2++;
// if((*iqi)->deleted || (*iqi)->instanceId != mInstanceId)
// (*iqi)->DecRef();
// else
// m_events.push_back( (*iqi) );
// m_insertPool.erase(iqi);
//}
/* Now we can proceed normally. */
EventList::iterator itr = m_events.begin();
EventList::iterator it2;
TimedEvent * ev;
while(itr != m_events.end())
{
it2 = itr++;
// Event Update Procedure
ev = *it2;
if (ev->deleted) //check if event has to be deleted
{
// remove from this list.
ev->DecRef();
m_events.erase(it2);
continue;
}
if(ev->currTime <= time_difference)
{
ev->cb->execute(); //execute event
if (ev->deleted == false)//check if event has been deleted inside execution
{
if (ev->eventFlag & EVENT_FLAG_DELETES_OBJECT) // if event has to be deleted after first execution
{
ev->deleted = true;
continue;
}
//reset the timer
ev->currTime = ev->msTime;
if (ev->repeats != 0xFFFFFFFF) //check if infinite event
{
if (--ev->repeats == 0) //decrease repeat count. And check if 0
{
ev->deleted = true;
}
}
}
}
else
{
// event is still "waiting", subtract time difference
ev->currTime -= time_difference;
}
}
}
void EventableObject::event_Relocate()
{
/* prevent any new stuff from getting added */
EventableObjectHolder * nh = g_pEventMgr->GetEventHolder(event_GetInstanceID());
if(nh != m_holder)
{
// whee, we changed event holder :>
// doing this will change the instanceid on all the events, as well as add to the new holder.
// no need to do this if we don't have any events, though.
if(!nh)
nh = g_pEventMgr->GetEventHolder(-1);
nh->AddObject(this);
// reset our m_holder pointer and instance id
m_event_Instanceid = nh->GetInstanceID();
m_holder = nh;
}
/* safe again to add */
}
unsigned int EventableObject::event_GetEventPeriod(unsigned int EventType)
{
unsigned int ret = 0;
EventMap::iterator itr = m_events.find(EventType);
if(itr != m_events.end())
ret = (unsigned int)itr->second->msTime;
return ret;
}
void EventableObjectHolder::AddEvent(TimedEvent * ev)
{
// m_lock NEEDS TO BE A RECURSIVE MUTEX
ev->IncRef();
// if(!m_lock.AttemptAcquire())
// {
// m_insertPool.push_back( ev );
// }
// else
{
m_events.push_back( ev );
}
}
void EventableObjectHolder::AddObject(EventableObject * obj)
{
UNREFERENCED_PARAMETER(obj);
}
|
bf26fea3108235b9593227d650deeef642f18442 | 151b1ed23a4d972582cdd26b21c49d8689c804bb | /population.h | 9fe163efa5a04a648208c12267d6f46a870ab925 | [] | no_license | Chuzzle/masters_thesis | 63cf48996c35e6752f82e4ef169d6bace16e83eb | f785d0d6a4ddc45490f73c343fc23d7c686c631a | refs/heads/master | 2020-05-21T19:10:22.282789 | 2017-08-12T18:01:28 | 2017-08-12T18:01:28 | 61,619,714 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 709 | h | population.h | #include <vector>
#include <string>
#include <algorithm>
#include "illegal_event_exception.h"
#include "constants_runspec.h"
#ifndef POPULATION_H
#define POPULATION_H
class Population {
public:
explicit Population();
Population(std::vector<int> initializer) : populations(initializer) {};
int get_pop(std::string index);
int get_pop(int index);
int get_total_pop();
int get_infected();
int get_carriers();
int get_infected_invasive();
int get_carriers_invasive();
int move_pop(std::string move_from, std::string move_to);
int increment_pop(std::string index);
int decrease_pop(std::string index);
private:
Constants_runspec constants;
std::vector<int> populations;
};
#endif
|
cfd5e881b162bfb595165fa34dd4be96c3313241 | a0315b6cdff3cd53cc6343f7be98130e3ec48e29 | /main.cpp | 5bcf66ee8fdb26395c8be8f0ee30ca8e5977dbc1 | [] | no_license | K4liber/NeuralNetwork | 792920e3af82b1c5354096fa66dfc801a0a8067f | 4401d98d90f7737d2bdcedac5453b9f46decf460 | refs/heads/master | 2021-01-10T16:41:02.346085 | 2016-04-28T13:02:02 | 2016-04-28T13:02:02 | 53,145,922 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,075 | cpp | main.cpp | #include "lib.h"
using namespace std;
int main(int argc,char *argv[])
{
double epsilon;
srand( time( NULL ) );
if(argv[1])
epsilon = atof(argv[1]);
else
epsilon = 0.01;
/*
generateData();
vector<double> dataFromFile = getData("dane1.txt");
// int StreamSize = getStreamSize(fileName);
vector< vector<int> > pixels = getPixels(dataFromFile,epsilon);
vector<double> lines = getLines(pixels);
//drawRecursiveDiagram(dataFromFile, epsilon);
vector<double> histogram = getHistogram(lines);
cout<<"Entropia: "<<getEntropy(histogram)<<endl;
cout<<"Lines: "<<int(lines.size())<<endl;
//logisticMap(epsilon);
//0.63 , 4.82 , 4.91 - uporzadkowanie , 2.235
drawRecursiveDiagram(dataFromFile, epsilon);
//vector <double> getNeuronDeviation(int N, double g, double time, double timeStep )
//void drawEntropy(int N, double time, double timeStep, double gStart, double gStop, double gStep, double epsilon)
*/
//drawEntropy(100, 24000, 1, 0, 5, 0.02,epsilon);
//drawReturnsMap(2.22);
double g = 3.24;
vector <double> neuronDeviationData = getNeuronDeviation(100, g , 26400, 0,24, 1);
vector <double> normalizedNeuronDeviationData = normalizeData(neuronDeviationData);
drawRecursiveDiagram(normalizedNeuronDeviationData, epsilon);
drawReturnsMapFromData(neuronDeviationData,1);
writeToFile(neuronDeviationData);
vector< vector<int> > pixels = getPixels(neuronDeviationData,epsilon);
vector<double> lines = getLines(pixels);
vector<double> histogram = getHistogram(lines);
cout<<"Entropia: "<<getEntropy(histogram)<<" g: "<<g<<endl;
/*
double g = 0.83;
vector <double> neuronDeviationData = getNeuronDeviation(100, g , 26400, 0,24, 1);
generateData();
vector <double> Data = getData("dane1.txt");
writeToFile(Data);
drawRecursiveDiagram(Data, epsilon);
drawReturnsMapFromData(Data,1);
vector< vector<int> > pixels = getPixels(Data,epsilon);
vector<double> lines = getLines(pixels);
vector<double> histogram = getHistogram(lines);
cout<<"Entropia: "<<getEntropy(histogram)<<" g: "<<g<<endl;
logisticMap(0.01);
*/
return( 0 );
}
|
70c924ec3fdef46a347f6a265d314d9bf4809625 | 0eea8d4513039059627c812c755d8b40a8ce2374 | /RayTracingInOneWeekend/vec3.h | 648513a1b335bdcf84cf9a99ec54e0344edb9ddf | [] | no_license | hyperwired/rt1w | 0c5a1992c7cf39c5adc15087271802b6f65ddadd | 2ed919ffd59edb75e7f473f97b452eb4c89d58f4 | refs/heads/master | 2022-04-15T00:20:47.955640 | 2020-04-13T13:20:37 | 2020-04-13T13:20:37 | 255,219,336 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,525 | h | vec3.h | #pragma once
#include <iostream>
class Vec3 {
public:
Vec3() : e{ 0.f, 0.f, 0.f } {}
Vec3(float e0, float e1, float e2);
float x() const { return e[0]; }
float y() const { return e[1]; }
float z() const { return e[2]; }
Vec3 operator-() const { return Vec3(-e[0], -e[1], -e[2]); }
float operator[](int i) const { return e[i]; }
float& operator[](int i) { return e[i]; }
Vec3& operator+=(const Vec3& v);
Vec3& operator*=(float t);
Vec3& operator/=(float t);
float length() const;
float lengthSq() const;
void writeColor(std::ostream& out, int samplesPerPixel) const;
public:
float e[3];
public:
static const Vec3 ZeroVec; // (0,0,0)
static const Vec3 OneVec; // (1,1,1)
static Vec3 random();
static Vec3 random(float min, float max);
};
inline std::ostream& operator<<(std::ostream& out, const Vec3& v)
{
return out << v.e[0] << ' ' << v.e[1] << ' ' << v.e[2];
}
inline Vec3 operator+(const Vec3& u, const Vec3& v)
{
return Vec3(u.e[0] + v.e[0], u.e[1] + v.e[1], u.e[2] + v.e[2]);
}
inline Vec3 operator-(const Vec3& u, const Vec3& v)
{
return Vec3(u.e[0] - v.e[0], u.e[1] - v.e[1], u.e[2] - v.e[2]);
}
inline Vec3 operator*(const Vec3& u, const Vec3& v)
{
return Vec3(u.e[0] * v.e[0], u.e[1] * v.e[1], u.e[2] * v.e[2]);
}
inline Vec3 operator*(float t, const Vec3& v)
{
return Vec3(t * v.e[0], t * v.e[1], t * v.e[2]);
}
inline Vec3 operator*(const Vec3& v, float t)
{
return t * v;
}
inline Vec3 operator/(const Vec3& v, float t) {
return (1 / t) * v;
}
inline float dot(const Vec3& u, const Vec3& v)
{
const float dp =
( u.e[0] * v.e[0]
+ u.e[1] * v.e[1]
+ u.e[2] * v.e[2]);
return dp;
}
inline Vec3 cross(const Vec3& u, const Vec3& v)
{
const Vec3 cp =
Vec3(u.e[1] * v.e[2] - u.e[2] * v.e[1],
u.e[2] * v.e[0] - u.e[0] * v.e[2],
u.e[0] * v.e[1] - u.e[1] * v.e[0]);
return cp;
}
inline Vec3 unitVector(const Vec3& v)
{
const Vec3 uv = (v / v.length());
return uv;
}
inline Vec3 reflect(const Vec3& v, const Vec3& n)
{
// Reflect incoming direct vector v against surface unit normal n
// returning outgoing direction vector from surface
// N (unit vec)
// ^
// | R
// \ | /|
// V \ | / | B
// \|/ |
// --------x---+----- surface
// \ |
// V \ | B
// \|
//
// R = V + (-2B * N)
// where B is scalar length of V_in projected onto unit vec N
// negation is required due to V pointing
// i.e. B = dot(V, N)
return v - 2*dot(v, n) * n;
}
|
652b99b1b6693159c493e9874292a91648ee5b1a | 222c3d2fd75c460e7c5cb9e01ee8af4a19f29804 | /aula_14/ConteudoMinistrado.hpp | bc963dd18086f3cec31c64866de32e417e708eef | [
"MIT"
] | permissive | matheusalanojoenck/aula_cpp | e4b8883317fd8af5f2dea256e164228d99bf73f1 | 039bd4f4b11a736f1d800cad97a530e212b30375 | refs/heads/master | 2022-12-15T05:26:21.139261 | 2020-09-11T15:51:20 | 2020-09-11T15:51:20 | 257,736,518 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 435 | hpp | ConteudoMinistrado.hpp | #ifndef CONTEUDO_MINISTRADO_HPP
#define CONTEUDO_MINISTRADO_HPP
#include<string>
class ConteudoMinistrado{
public:
ConteudoMinistrado(std::string descricao, unsigned short cargaHorariaConteudo);
std::string& getDescricao();
unsigned short getCargaHorariaConteudo();
unsigned int getId();
private:
static unsigned int proxId;
std::string descricao;
unsigned short cargaHorariaConteudo;
unsigned int id;
};
#endif
|
6efb8a687a3c7dae5e5032bee915e93f1bb6801d | e331d567c1fd927b4a757ae41ad6319442a4a15e | /main.cpp | 4cd15af2eec0c74f20465dd6976038d6714201b9 | [] | no_license | pmslavin/hanjie | 4b7e6d2bdcc369a968289926640ad7227e6313dd | 6f92d85b9efcc473547847c52bf72babcbcb12bc | refs/heads/master | 2021-01-20T04:29:47.548470 | 2015-01-28T22:41:13 | 2015-01-28T22:41:13 | 29,756,901 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,882 | cpp | main.cpp | #include "Cell.h"
#include "Grid.h"
#include "Frame.h"
#include "SDL2/SDL.h"
std::vector<std::string>
puppy = { "00000011111111111110",
"00111110000000110011",
"01110001110000011001",
"11110111111000001101",
"11101100011000000101",
"11101101011001000101",
"11100110100000000110",
"11100011101110000100",
"11100000001110000100",
"00011000000100001100",
"00001100000100011000",
"01111110001010111110",
"11000111111111100011",
"10000011100111000001",
"10101011000011010101"
};
std::vector<std::string>
whale = { "00111011000000000000",
"01111111100000000000",
"01100100100000000000",
"01000100000000000000",
"00000100000000000000",
"00111111100001110111",
"01111111110011111110",
"01111111111010001100",
"11111111111100100110",
"11111110011110000011",
"11111111011111100111",
"01010111111111111110",
"01010101111001111110",
"01110101011100111000",
"00011111111111110010"
};
std::vector<std::string>
cross = { "0001000",
"0001000",
"0001000",
"1111111",
"0001000",
"0001000",
"0001000"
};
std::vector<std::string>
emma = { "0111110",
"0100000",
"0111110",
"0100000",
"0111110"
};
int main()
{
/* Cell c(7,5);
c.showState();
c.setState(State::Filled);
c.showState();
std::cout << c;
Grid g(20, 15);
Row row = g.getRow(3);
Column col = g.getColumn(7);
for(auto& e: row)
std::cout << *e;
for(auto& e: col)
std::cout << *e;
*/
bool active = true;
const int delay = 100;
SDL_Event event;
Grid pg(whale, "Whale");
// Grid pg(20, 15);
Frame f(1200, 900, &pg);
std::cout << pg.getWidth() << ","
<< pg.getHeight() << std::endl;
for(int r=0; r<pg.getHeight(); ++r){
std::cout << pg.writeRow(r) << std::endl;
}
std::vector<int> code;
for(int r=0; r<pg.getHeight(); ++r){
code = pg.encode(pg.getRow(r));
for(auto i: code)
std::cout << i << " ";
std::cout << std::endl;
}
std::cout << std::endl;
code.clear();
for(int c=0; c<pg.getWidth(); ++c){
code = pg.encode(pg.getColumn(c));
for(auto i: code)
std::cout << i << " ";
std::cout << std::endl;
}
f.refresh();
while(active){
while(SDL_PollEvent(&event)){
switch(event.type){
case SDL_QUIT:
active = false;
break;
case SDL_KEYDOWN:
if(event.key.keysym.sym == 'q')
active = false;
if(event.key.keysym.sym == 'b')
f.writeBMP("output.bmp");
if(event.key.keysym.sym == 'c')
f.clearAllCells();
if(event.key.keysym.sym == 'h')
f.toggleHide();
if(event.key.keysym.sym == 'i')
f.invertGrid();
if(event.key.keysym.sym == 'r')
f.revert();
if(event.key.keysym.sym == 's')
f.scale();
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEMOTION:
f.mouseAction(&event);
break;
}
}
f.refresh();
SDL_Delay(delay);
}
return 0;
}
|
47a69cf279e761347cd7eae518f85d422df0d7dc | f1873886241571eaf4175ec0633a978fa10fc4d0 | /StudentSchedule/Cr.cpp | ea10f415868cb98a7442509e3c4d4558cd3bced6 | [] | no_license | RepTambe/CS-235 | 9dec1c3104828f0cbdfa55c9c190a457604ac5ba | 5c787e530144263a21cadec1fe4d36cbb1b01b58 | refs/heads/master | 2022-04-09T00:48:07.764033 | 2020-03-21T02:39:39 | 2020-03-21T02:39:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 443 | cpp | Cr.cpp | #include <iostream>
#include<string>
#include<iomanip>
#include<sstream>
using namespace std;
#include"Course.h"
#include "Cr.h"
Cr::Cr(string studentCourse, string room)
{
this->room = room;
this->studentCourse = studentCourse;
}
string Cr::GetRoom() const
{
return room;
}
string Cr::toString() const
{
stringstream out;
out << "(" << GetStudentCourse() << "," << GetRoom() << ")";
return out.str();
}
|
67c514a0bae51dc3f92ab00fca7fd72fb3d627b5 | 70418d8faa76b41715c707c54a8b0cddfb393fb3 | /10620.cpp | bee33b1a0a1e7684c45c12a9a7c3efc642b5bb71 | [] | no_license | evandrix/UVa | ca79c25c8bf28e9e05cae8414f52236dc5ac1c68 | 17a902ece2457c8cb0ee70c320bf0583c0f9a4ce | refs/heads/master | 2021-06-05T01:44:17.908960 | 2017-10-22T18:59:42 | 2017-10-22T18:59:42 | 107,893,680 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 874 | cpp | 10620.cpp | #include <bits/stdc++.h>
using namespace std;
/*
Aflea on a chessboard
10620
*/
//typedef __int64 ss;
typedef long long ss;
ss S, X, Y, dx, dy;
struct cor
{
int x, y;
};
int Inside()
{
ss x, y;
x = X / S;
y = Y / S;
if (X % S && Y % S)
{
if ((x + y) % 2)
{
return 1;
}
}
return 0;
}
void Cal()
{
ss i, x, y;
x = X / S;
y = Y / S;
if (X % S && Y % S)
{
if ((x + y) % 2)
{
printf("After 0 jumps the flea lands at (%lld, %lld).\n", X, Y);
return;
}
}
for (i = 0; i < 1100; i++)
{
X += dx;
Y += dy;
if (Inside())
{
printf("After %lld jumps the flea lands at (%lld, %lld).\n", i + 1, X, Y);
return;
}
}
printf("The flea cannot escape from black squares.\n");
}
int main()
{
while (scanf("%lld%lld%lld%lld%lld", &S, &X, &Y, &dx, &dy) == 5)
{
if (!S && !X && !Y && !dx && !dy)
{
break;
}
Cal();
}
return 0;
}
|
22cfa458a9f737aa6adea4975a00fb41309165ea | ff590bcdaddd559b934c84d71ddfbf00ed7ae86a | /bsdiff/patch_reader_unittest.cc | 8de346d77225e82fe08d03cabe90d59cc619fee5 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | Laymer/updater-hack | d3a0e9a174d9d097ceec2f4677a3f69de08b4297 | 966fe0bb51b76547bfb11effcb205d742e5b79ae | refs/heads/master | 2020-05-14T19:24:31.200944 | 2019-01-17T16:54:25 | 2019-01-17T16:54:25 | 181,929,216 | 1 | 0 | null | 2019-04-17T16:28:01 | 2019-04-17T16:28:00 | null | UTF-8 | C++ | false | false | 9,309 | cc | patch_reader_unittest.cc | // Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "bsdiff/patch_reader.h"
#include <unistd.h>
#include <algorithm>
#include <limits>
#include <string>
#include <vector>
#include <gtest/gtest.h>
#include "bsdiff/brotli_compressor.h"
#include "bsdiff/bz2_compressor.h"
#include "bsdiff/utils.h"
namespace {
void EncodeInt64(int64_t x, uint8_t* buf) {
uint64_t y = x < 0 ? (1ULL << 63ULL) - x : x;
for (int i = 0; i < 8; ++i) {
buf[i] = y & 0xff;
y /= 256;
}
}
} // namespace
namespace bsdiff {
class PatchReaderTest : public testing::Test {
protected:
void CompressData() {
for (size_t i = 0; i < diff_data_.size(); i++) {
uint8_t buf[24];
EncodeInt64(diff_data_[i].size(), buf);
EncodeInt64(extra_data_[i].size(), buf + 8);
EncodeInt64(offset_increment_[i], buf + 16);
EXPECT_TRUE(ctrl_stream_->Write(buf, sizeof(buf)));
EXPECT_TRUE(diff_stream_->Write(
reinterpret_cast<const uint8_t*>(diff_data_[i].data()),
diff_data_[i].size()));
EXPECT_TRUE(extra_stream_->Write(
reinterpret_cast<const uint8_t*>(extra_data_[i].data()),
extra_data_[i].size()));
}
EXPECT_TRUE(ctrl_stream_->Finish());
EXPECT_TRUE(diff_stream_->Finish());
EXPECT_TRUE(extra_stream_->Finish());
}
void ConstructPatchHeader(int64_t ctrl_size,
int64_t diff_size,
int64_t new_size,
std::vector<uint8_t>* patch_data) {
EXPECT_EQ(static_cast<size_t>(8), patch_data->size());
// Encode the header.
uint8_t buf[24];
EncodeInt64(ctrl_size, buf);
EncodeInt64(diff_size, buf + 8);
EncodeInt64(new_size, buf + 16);
std::copy(buf, buf + sizeof(buf), std::back_inserter(*patch_data));
}
void ConstructPatchData(std::vector<uint8_t>* patch_data) {
ConstructPatchHeader(ctrl_stream_->GetCompressedData().size(),
diff_stream_->GetCompressedData().size(),
new_file_size_, patch_data);
// Concatenate the three streams into one patch.
std::copy(ctrl_stream_->GetCompressedData().begin(),
ctrl_stream_->GetCompressedData().end(),
std::back_inserter(*patch_data));
std::copy(diff_stream_->GetCompressedData().begin(),
diff_stream_->GetCompressedData().end(),
std::back_inserter(*patch_data));
std::copy(extra_stream_->GetCompressedData().begin(),
extra_stream_->GetCompressedData().end(),
std::back_inserter(*patch_data));
}
void VerifyPatch(const std::vector<uint8_t>& patch_data) {
BsdiffPatchReader patch_reader;
EXPECT_TRUE(patch_reader.Init(patch_data.data(), patch_data.size()));
EXPECT_EQ(new_file_size_, patch_reader.new_file_size());
// Check that the decompressed data matches what we wrote.
for (size_t i = 0; i < diff_data_.size(); i++) {
ControlEntry control_entry(0, 0, 0);
EXPECT_TRUE(patch_reader.ParseControlEntry(&control_entry));
EXPECT_EQ(diff_data_[i].size(), control_entry.diff_size);
EXPECT_EQ(extra_data_[i].size(), control_entry.extra_size);
EXPECT_EQ(offset_increment_[i], control_entry.offset_increment);
uint8_t buffer[128] = {};
EXPECT_TRUE(patch_reader.ReadDiffStream(buffer, diff_data_[i].size()));
EXPECT_EQ(0, memcmp(buffer, diff_data_[i].data(), diff_data_[i].size()));
EXPECT_TRUE(patch_reader.ReadExtraStream(buffer, extra_data_[i].size()));
EXPECT_EQ(0,
memcmp(buffer, extra_data_[i].data(), extra_data_[i].size()));
}
EXPECT_TRUE(patch_reader.Finish());
}
// Helper function to check that invalid headers are detected. This method
// creates a new header with the passed |ctrl_size|, |diff_size| and
// |new_size| and appends after the header |compressed_size| bytes of extra
// zeros. It then expects that initializing a PatchReader with this will fail.
void InvalidHeaderTestHelper(int64_t ctrl_size,
int64_t diff_size,
int64_t new_size,
size_t compressed_size) {
std::vector<uint8_t> patch_data;
std::copy(kBSDF2MagicHeader, kBSDF2MagicHeader + 5,
std::back_inserter(patch_data));
patch_data.push_back(static_cast<uint8_t>(CompressorType::kBrotli));
patch_data.push_back(static_cast<uint8_t>(CompressorType::kBrotli));
patch_data.push_back(static_cast<uint8_t>(CompressorType::kBrotli));
ConstructPatchHeader(ctrl_size, diff_size, new_size, &patch_data);
patch_data.resize(patch_data.size() + compressed_size);
BsdiffPatchReader patch_reader;
EXPECT_FALSE(patch_reader.Init(patch_data.data(), patch_data.size()))
<< "Where ctrl_size=" << ctrl_size << " diff_size=" << diff_size
<< " new_size=" << new_size << " compressed_size=" << compressed_size;
}
size_t new_file_size_{500};
std::vector<std::string> diff_data_{"HelloWorld", "BspatchPatchTest",
"BspatchDiffData"};
std::vector<std::string> extra_data_{"HelloWorld!", "BZ2PatchReaderSmoke",
"BspatchExtraData"};
std::vector<int64_t> offset_increment_{100, 200, 300};
// The compressor streams.
std::unique_ptr<CompressorInterface> ctrl_stream_{nullptr};
std::unique_ptr<CompressorInterface> diff_stream_{nullptr};
std::unique_ptr<CompressorInterface> extra_stream_{nullptr};
};
TEST_F(PatchReaderTest, PatchReaderLegacyFormatSmoke) {
ctrl_stream_.reset(new BZ2Compressor());
diff_stream_.reset(new BZ2Compressor());
extra_stream_.reset(new BZ2Compressor());
CompressData();
std::vector<uint8_t> patch_data;
std::copy(kLegacyMagicHeader, kLegacyMagicHeader + 8,
std::back_inserter(patch_data));
ConstructPatchData(&patch_data);
VerifyPatch(patch_data);
}
TEST_F(PatchReaderTest, PatchReaderNewFormatSmoke) {
// Compress the data with one bz2 and two brotli compressors.
ctrl_stream_.reset(new BZ2Compressor());
diff_stream_.reset(new BrotliCompressor(11));
extra_stream_.reset(new BrotliCompressor(11));
CompressData();
std::vector<uint8_t> patch_data;
std::copy(kBSDF2MagicHeader, kBSDF2MagicHeader + 5,
std::back_inserter(patch_data));
patch_data.push_back(static_cast<uint8_t>(CompressorType::kBZ2));
patch_data.push_back(static_cast<uint8_t>(CompressorType::kBrotli));
patch_data.push_back(static_cast<uint8_t>(CompressorType::kBrotli));
ConstructPatchData(&patch_data);
VerifyPatch(patch_data);
}
TEST_F(PatchReaderTest, InvalidHeaderTest) {
// Negative values are not allowed.
InvalidHeaderTestHelper(-1, 0, 20, 50);
InvalidHeaderTestHelper(30, -3, 20, 50);
InvalidHeaderTestHelper(30, 8, -20, 50);
// Values larger than the patch size are also not allowed for ctrl and diff,
// or for the sum of both.
InvalidHeaderTestHelper(30, 5, 20, 10); // 30 > 10
InvalidHeaderTestHelper(5, 30, 20, 10); // 30 > 10
InvalidHeaderTestHelper(30, 5, 20, 32); // 30 + 5 > 32
// Values that overflow int64 are also not allowed when used combined
const int64_t kMax64 = std::numeric_limits<int64_t>::max();
InvalidHeaderTestHelper(kMax64 - 5, 5, 20, 20);
InvalidHeaderTestHelper(5, kMax64 - 5, 20, 20);
// 2 * (kMax64 - 5) + sizeof(header) is still positive due to overflow, but
// the patch size is too small.
InvalidHeaderTestHelper(kMax64 - 5, kMax64 - 5, 20, 20);
}
TEST_F(PatchReaderTest, InvalidCompressionHeaderTest) {
std::vector<uint8_t> patch_data;
std::copy(kBSDF2MagicHeader, kBSDF2MagicHeader + 5,
std::back_inserter(patch_data));
// Set an invalid compression value.
patch_data.push_back(99);
patch_data.push_back(static_cast<uint8_t>(CompressorType::kBrotli));
patch_data.push_back(static_cast<uint8_t>(CompressorType::kBrotli));
ConstructPatchHeader(10, 10, 10, &patch_data);
patch_data.resize(patch_data.size() + 30);
BsdiffPatchReader patch_reader;
EXPECT_FALSE(patch_reader.Init(patch_data.data(), patch_data.size()));
}
TEST_F(PatchReaderTest, InvalidControlEntryTest) {
// Check that negative diff and extra values in a control entry are not
// allowed.
ctrl_stream_.reset(new BZ2Compressor());
diff_stream_.reset(new BrotliCompressor(11));
extra_stream_.reset(new BrotliCompressor(11));
// Encode the header.
uint8_t buf[24];
EncodeInt64(-10, buf);
EncodeInt64(0, buf + 8);
EncodeInt64(0, buf + 16);
ctrl_stream_->Write(buf, sizeof(buf));
CompressData();
std::vector<uint8_t> patch_data;
std::copy(kBSDF2MagicHeader, kBSDF2MagicHeader + 5,
std::back_inserter(patch_data));
patch_data.push_back(static_cast<uint8_t>(CompressorType::kBZ2));
patch_data.push_back(static_cast<uint8_t>(CompressorType::kBrotli));
patch_data.push_back(static_cast<uint8_t>(CompressorType::kBrotli));
ConstructPatchData(&patch_data);
BsdiffPatchReader patch_reader;
EXPECT_TRUE(patch_reader.Init(patch_data.data(), patch_data.size()));
ControlEntry control_entry(0, 0, 0);
EXPECT_FALSE(patch_reader.ParseControlEntry(&control_entry));
}
} // namespace bsdiff
|
797a0ae90e9c35680efe325b8aa7a2221213dc8e | 4d6c3307eaf391b3f7a7a0f7ea23f5d7a49e9b8f | /src/plugins/domeadapter/DomeAdapterDriver.cpp | 49a449423bb73fdb1d8fde5e812f716feff6ffd6 | [
"Apache-2.0"
] | permissive | EricKTCheung/dmlite | f35241c41497781ed3b448639b6cc9f26766882c | 7fe31e16fc18e3c3d8b048a3507f7769ef3f8a9d | refs/heads/master | 2021-01-23T10:38:50.515420 | 2017-05-30T08:44:05 | 2017-05-30T08:44:05 | 93,076,189 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,621 | cpp | DomeAdapterDriver.cpp | /// @file DomeAdapterDriver.cpp
/// @brief Dome adapter catalog
/// @author Georgios Bitzes <georgios.bitzes@cern.ch>
#include <dmlite/cpp/dmlite.h>
#include <dmlite/cpp/catalog.h>
#include <iostream>
#include "DomeAdapter.h"
#include "DomeAdapterDriver.h"
#include "DomeAdapterPools.h"
#include "utils/DomeTalker.h"
#include "utils/DomeUtils.h"
#include "DomeAdapterUtils.h"
#include <boost/property_tree/json_parser.hpp>
using namespace dmlite;
#define SSTR(message) static_cast<std::ostringstream&>(std::ostringstream().flush() << message).str()
DomeAdapterPoolDriver::DomeAdapterPoolDriver(DomeAdapterFactory *factory) {
factory_ = factory;
secCtx_ = NULL;
}
DomeAdapterPoolDriver::~DomeAdapterPoolDriver() {
}
std::string DomeAdapterPoolDriver::getImplId() const throw() {
return "DomeAdapterPoolDriver";
}
void DomeAdapterPoolDriver::setStackInstance(StackInstance* si) throw (DmException) {
si_ = si;
}
void DomeAdapterPoolDriver::setSecurityContext(const SecurityContext* secCtx) throw (DmException) {
secCtx_ = secCtx;
// Id mechanism
if (factory_->tokenUseIp_)
userId_ = secCtx_->credentials.remoteAddress;
else
userId_ = secCtx_->credentials.clientName;
}
PoolHandler* DomeAdapterPoolDriver::createPoolHandler(const std::string& poolname) throw (DmException) {
return new DomeAdapterPoolHandler(this, poolname);
}
DomeAdapterPoolHandler::DomeAdapterPoolHandler(DomeAdapterPoolDriver *driver, const std::string& poolname) {
driver_ = driver;
poolname_ = poolname;
}
DomeAdapterPoolHandler::~DomeAdapterPoolHandler() {
}
std::string DomeAdapterPoolHandler::getPoolType(void) throw (DmException) {
return "filesystem";
}
std::string DomeAdapterPoolHandler::getPoolName(void) throw (DmException) {
return this->poolname_;
}
void DomeAdapterPoolDriver::toBeCreated(const Pool& pool) throw (DmException) {
{
DomeTalker talker(factory_->davixPool_, secCtx_, factory_->domehead_,
"POST", "dome_addpool");
if(!talker.execute("poolname", pool.name)) {
throw DmException(talker.dmlite_code(), talker.err());
}
}
std::vector<boost::any> filesystems = pool.getVector("filesystems");
for(unsigned i = 0; i < filesystems.size(); ++i) {
Extensible fs = boost::any_cast<Extensible>(filesystems[i]);
DomeTalker talker(factory_->davixPool_, secCtx_, factory_->domehead_,
"POST", "dome_addfstopool");
boost::property_tree::ptree params;
params.put("server", fs.getString("server"));
params.put("fs", fs.getString("fs"));
params.put("poolname", pool.name);
if(!talker.execute(params)) {
throw DmException(talker.dmlite_code(), talker.err());
}
}
}
void DomeAdapterPoolDriver::justCreated(const Pool& pool) throw (DmException) {
// nothing to do here
}
bool contains_filesystem(std::vector<boost::any> filesystems, std::string server, std::string filesystem) {
for(unsigned i = 0; i < filesystems.size(); ++i) {
Extensible fs = boost::any_cast<Extensible>(filesystems[i]);
if(fs.getString("server") == server && fs.getString("fs") == filesystem) {
return true;
}
}
return false;
}
void DomeAdapterPoolDriver::update(const Pool& pool) throw (DmException) {
DomeTalker talker(factory_->davixPool_, secCtx_, factory_->domehead_,
"GET", "dome_statpool");
if(!talker.execute("poolname", pool.name)) {
throw DmException(talker.dmlite_code(), talker.err());
}
try {
Pool oldpool = deserializePool(talker.jresp().get_child("poolinfo").begin());
std::vector<boost::any> oldfilesystems = oldpool.getVector("filesystems");
std::vector<boost::any> filesystems = pool.getVector("filesystems");
// detect which filesystems have been removed
for(unsigned i = 0; i < oldfilesystems.size(); i++) {
Extensible ext = boost::any_cast<Extensible>(oldfilesystems[i]);
std::string server = ext.getString("server");
std::string fs = ext.getString("fs");
if(!contains_filesystem(filesystems, server, fs)) {
// send rmfs to dome to remove this filesystem
Log(Logger::Lvl1, domeadapterlogmask, domeadapterlogname, "Removing filesystem '" << fs << "' on server '" << server << "'");
DomeTalker rmfs(factory_->davixPool_, secCtx_, factory_->domehead_,
"POST", "dome_rmfs");
boost::property_tree::ptree params;
params.put("server", server);
params.put("fs", fs);
if(!rmfs.execute(params)) {
throw DmException(rmfs.dmlite_code(), rmfs.err());
}
}
}
// detect which filesystems need to be added
for(unsigned i = 0; i < filesystems.size(); i++) {
Extensible ext = boost::any_cast<Extensible>(filesystems[i]);
std::string server = ext.getString("server");
std::string fs = ext.getString("fs");
std::cout << "checking " << server << " - " << fs << std::endl;
if(!contains_filesystem(oldfilesystems, server, fs)) {
// send addfs to dome to add this filesystem
Log(Logger::Lvl1, domeadapterlogmask, domeadapterlogname, "Adding filesystem '" << fs << "' on server '" << server << "'");
DomeTalker addfs(factory_->davixPool_, secCtx_, factory_->domehead_,
"POST", "dome_addfstopool");
boost::property_tree::ptree params;
params.put("server", server);
params.put("fs", fs);
params.put("poolname", pool.name);
if(!addfs.execute(params)) {
throw DmException(addfs.dmlite_code(), addfs.err());
}
}
}
}
catch(boost::property_tree::ptree_error &e) {
throw DmException(EINVAL, SSTR("Error when parsing json response: " << talker.response()));
}
}
void DomeAdapterPoolDriver::toBeDeleted(const Pool& pool) throw (DmException) {
DomeTalker talker(factory_->davixPool_, secCtx_, factory_->domehead_,
"POST", "dome_rmpool");
if(!talker.execute("poolname", pool.name)) {
throw DmException(talker.dmlite_code(), talker.err());
}
}
uint64_t DomeAdapterPoolHandler::getPoolField(const std::string &field, uint64_t def) throw (DmException) {
DomeTalker talker(driver_->factory_->davixPool_, driver_->secCtx_, driver_->factory_->domehead_,
"GET", "dome_statpool");
if(!talker.execute("poolname", poolname_)) {
throw DmException(talker.dmlite_code(), talker.err());
}
try {
return talker.jresp().get_child("poolinfo").begin()->second.get<uint64_t>(field, def);
}
catch(boost::property_tree::ptree_error &e) {
throw DmException(DMLITE_SYSERR(DMLITE_MALFORMED), SSTR("Error parsing json response when retrieving field '" << field << "'. Error: '" << e.what() << "' Response: '" << talker.response() << "'"));
}
}
uint64_t DomeAdapterPoolHandler::getTotalSpace(void) throw (DmException) {
Log(Logger::Lvl4, domeadapterlogmask, domeadapterlogname, " Entering ");
return this->getPoolField("physicalsize", 0);
}
uint64_t DomeAdapterPoolHandler::getFreeSpace(void) throw (DmException) {
Log(Logger::Lvl4, domeadapterlogmask, domeadapterlogname, " Entering ");
return this->getPoolField("freespace", 0);
}
bool DomeAdapterPoolHandler::poolIsAvailable(bool write) throw (DmException) {
Log(Logger::Lvl4, domeadapterlogmask, domeadapterlogname, " Entering ");
uint64_t poolstatus = this->getPoolField("poolstatus", std::numeric_limits<uint64_t>::max());
if(poolstatus == FsStaticActive) {
return true;
}
if(poolstatus == FsStaticDisabled) {
return false;
}
if(poolstatus == FsStaticReadOnly) {
return ! write;
}
throw DmException(EINVAL, SSTR("Received invalid value from Dome for poolstatus: " << poolstatus));
}
bool DomeAdapterPoolHandler::replicaIsAvailable(const Replica& replica) throw (DmException) {
Log(Logger::Lvl4, domeadapterlogmask, domeadapterlogname, " rfn: " << replica.rfn);
if (replica.status != dmlite::Replica::kAvailable) {
Log(Logger::Lvl3, domeadapterlogmask, domeadapterlogname, " poolname:" << poolname_ << " replica: " << replica.rfn << " has status " << replica.status << " . returns false");
return false;
}
DomeTalker talker(driver_->factory_->davixPool_, driver_->secCtx_, driver_->factory_->domehead_,
"GET", "dome_statpool");
if(!talker.execute("poolname", poolname_)) {
throw DmException(talker.dmlite_code(), talker.err());
}
try {
using namespace boost::property_tree;
std::string filesystem = Extensible::anyToString(replica["filesystem"]);
ptree fsinfo = talker.jresp().get_child("poolinfo").get_child(poolname_).get_child("fsinfo");
ptree::const_iterator begin = fsinfo.begin();
ptree::const_iterator end = fsinfo.end();
for(ptree::const_iterator it = begin; it != end; it++) {
if(it->first == replica.server) {
for(ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); it2++) {
if(it2->first == filesystem) {
bool active = it2->second.get<int>("fsstatus") != FsStaticDisabled;
return active;
}
}
}
}
return false;
}
catch(boost::property_tree::ptree_error &e) {
throw DmException(EINVAL, SSTR("Error when parsing json response: " << talker.response()));
}
}
void DomeAdapterPoolHandler::removeReplica(const Replica& replica) throw (DmException) {
Log(Logger::Lvl4, domeadapterlogmask, domeadapterlogname, " rfn: " << replica.rfn);
DomeTalker talker(driver_->factory_->davixPool_, driver_->secCtx_, driver_->factory_->domehead_,
"POST", "dome_delreplica");
boost::property_tree::ptree params;
params.put("server", DomeUtils::server_from_rfio_syntax(replica.rfn));
params.put("pfn", DomeUtils::pfn_from_rfio_syntax(replica.rfn));
if(!talker.execute(params)) {
throw DmException(talker.dmlite_code(), talker.err());
}
}
void DomeAdapterPoolHandler::cancelWrite(const Location& loc) throw (DmException) {
Log(Logger::Lvl4, domeadapterlogmask, domeadapterlogname, " Entering. ");
Replica replica;
replica.rfn = loc[0].url.domain + ":" + loc[0].url.path;
Log(Logger::Lvl4, domeadapterlogmask, domeadapterlogname, " rfn: " << replica.rfn);
this->removeReplica(replica);
}
Location DomeAdapterPoolHandler::whereToWrite(const std::string& lfn) throw (DmException) {
Log(Logger::Lvl4, domeadapterlogmask, domeadapterlogname, " lfn: " << lfn);
DomeTalker talker(driver_->factory_->davixPool_, driver_->secCtx_, driver_->factory_->domehead_,
"POST", "dome_put");
if(!talker.execute("pool", poolname_, "lfn", lfn)) {
throw DmException(talker.dmlite_code(), talker.err());
}
try {
Chunk single;
single.url.domain = talker.jresp().get<std::string>("host");
single.url.path = talker.jresp().get<std::string>("pfn");
single.offset = 0;
single.size = 0;
single.url.query["sfn"] = lfn;
std::string userId1;
if (driver_->si_->contains("replicate"))
userId1 = dmlite::kGenericUser;
else
userId1 = driver_->userId_;
single.url.query["token"] = dmlite::generateToken(userId1, single.url.path,
driver_->factory_->tokenPasswd_,
driver_->factory_->tokenLife_, true);
return Location(1, single);
}
catch(boost::property_tree::ptree_error &e) {
throw DmException(EINVAL, SSTR("Error when parsing json response: " << e.what() << " - " << talker.response()));
}
}
Location DomeAdapterPoolHandler::whereToRead(const Replica& replica) throw (DmException) {
Log(Logger::Lvl4, domeadapterlogmask, domeadapterlogname, " poolname:" << poolname_ << " replica:" << replica.rfn);
Url rloc(replica.rfn);
Chunk single;
single.url.domain = rloc.domain;
single.url.path = rloc.path;
single.offset = 0;
try {
single.size = this->driver_->si_->getCatalog()->extendedStatByRFN(replica.rfn).stat.st_size;
}
catch (DmException& e) {
switch (DMLITE_ERRNO(e.code())) {
case ENOSYS: case DMLITE_NO_INODE:
break;
default:
throw;
}
single.size = 0;
}
single.url.query["token"] = dmlite::generateToken(driver_->userId_, rloc.path,
driver_->factory_->tokenPasswd_,
driver_->factory_->tokenLife_);
Log(Logger::Lvl4, domeadapterlogmask, domeadapterlogname, " poolname:" << poolname_ << " replica:" << replica.rfn << " returns" << single.toString());
return Location(1, single);
}
|
3322e2fd787f3da6b791f78b5a437af1054f8710 | a5f3b0001cdb692aeffc444a16f79a0c4422b9d0 | /main/dbaccess/source/ui/inc/queryorder.hxx | c0fea6b5bdf321cc68bc885ece6d8e340e0f0434 | [
"Apache-2.0",
"CPL-1.0",
"bzip2-1.0.6",
"LicenseRef-scancode-other-permissive",
"Zlib",
"LZMA-exception",
"LGPL-2.0-or-later",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-philippe-de-muyter",
"OFL-1.1",
"LGPL-2.1-only",
"MPL-1.1",
"X11",
"LGPL-2.1-or-later",
"GPL-2.0-only",
... | permissive | apache/openoffice | b9518e36d784898c6c2ea3ebd44458a5e47825bb | 681286523c50f34f13f05f7b87ce0c70e28295de | refs/heads/trunk | 2023-08-30T15:25:48.357535 | 2023-08-28T19:50:26 | 2023-08-28T19:50:26 | 14,357,669 | 907 | 379 | Apache-2.0 | 2023-08-16T20:49:37 | 2013-11-13T08:00:13 | C++ | UTF-8 | C++ | false | false | 3,449 | hxx | queryorder.hxx | /**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 DBAUI_QUERYORDER_HXX
#define DBAUI_QUERYORDER_HXX
#ifndef _DIALOG_HXX //autogen
#include <vcl/dialog.hxx>
#endif
#ifndef _LSTBOX_HXX //autogen
#include <vcl/lstbox.hxx>
#endif
#ifndef _EDIT_HXX //autogen
#include <vcl/edit.hxx>
#endif
#ifndef _FIXED_HXX //autogen
#include <vcl/fixed.hxx>
#endif
#ifndef _BUTTON_HXX //autogen
#include <vcl/button.hxx>
#endif
#define DOG_ROWS 3
namespace rtl
{
class OUString;
}
namespace com
{
namespace sun
{
namespace star
{
namespace sdb
{
class XSingleSelectQueryComposer;
}
namespace sdbc
{
class XConnection;
}
namespace container
{
class XNameAccess;
}
namespace beans
{
struct PropertyValue;
class XPropertySet;
}
}
}
}
//==================================================================
// DlgOrderCrit
//==================================================================
namespace dbaui
{
class DlgOrderCrit : public ModalDialog
{
protected:
ListBox aLB_ORDERFIELD1;
ListBox aLB_ORDERVALUE1;
ListBox aLB_ORDERFIELD2;
ListBox aLB_ORDERVALUE2;
ListBox aLB_ORDERFIELD3;
ListBox aLB_ORDERVALUE3;
FixedText aFT_ORDERFIELD;
FixedText aFT_ORDERAFTER1;
FixedText aFT_ORDERAFTER2;
FixedText aFT_ORDEROPER;
FixedText aFT_ORDERDIR;
OKButton aBT_OK;
CancelButton aBT_CANCEL;
HelpButton aBT_HELP;
FixedLine aFL_ORDER;
String aSTR_NOENTRY;
::rtl::OUString m_sOrgOrder;
::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer> m_xQueryComposer;
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColumns;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection;
ListBox* m_aColumnList[DOG_ROWS];
ListBox* m_aValueList[DOG_ROWS];
DECL_LINK( FieldListSelectHdl, ListBox * );
void EnableLines();
public:
DlgOrderCrit( Window * pParent,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConnection,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer>& _rxComposer,
const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _rxCols);
~DlgOrderCrit();
void BuildOrderPart();
::rtl::OUString GetOrderList( ) const;
::rtl::OUString GetOrignalOrder() const { return m_sOrgOrder; }
private:
void impl_initializeOrderList_nothrow();
};
}
#endif // DBAUI_QUERYORDER_HXX
|
3af5773a7a258dd375d7444000341d01d06d193f | 3e814f0ed8f3563880228f837c851021fc561ba4 | /Lab4_Chow_Katrine/university.hpp | 4f743048e56814238fef575baf615ce5192d97f3 | [] | no_license | katrinechow/OSU-CS-162 | a356ba8cdcc48b89d051283dd415b55eb186d0aa | 082fba9bb4bfa1de742d6e9cdc1e1d74c546e1e0 | refs/heads/master | 2020-06-08T16:07:12.269212 | 2019-06-22T17:42:20 | 2019-06-22T17:42:20 | 193,259,431 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 987 | hpp | university.hpp | /*******************************************************************************
** Program Name: Lab 4 - OSU Information System: university.hpp
** Author: Katrine Chow
** Date: January 29, 2018
** Description: This is the header file that declares class University and its
** member variables and functions.
*******************************************************************************/
#include <vector>
#include <string>
#include "building.hpp"
#include "person.hpp"
#ifndef UNIVERSITY_HPP
#define UNIVERSITY_HPP
using std::string;
using std::vector;
class University
{
private:
string name = "Oregon State University";
int bnum; //Number of Buildings
int pnum; //Number of Persons
// vector <Building> bptr;
// vector <Person> pptr;
public:
University(); //Default constructor
University(int, int);
void printBuilding(vector<Building>&); //Prints all info on all buildings
void printPerson(int, int, Person*&); //Prints all info on all Persons
};
#endif
|
bb6496d851efad4ceda62804b4d23d241df1a40d | 13b541ec3d5c16a3eb9217e43b8a80c160fd99cf | /Assignments/asn0/src/Calculator.cpp | f3addbf6f4941fac48bbdc7fe011898d055dc383 | [] | no_license | Shanaconda/CPSC2720 | 1b2a476325439891bcf5bab1900d44a6797c0c33 | bfb976f25d40b9234c17b519b72f5b28741f7b40 | refs/heads/master | 2022-04-15T07:44:48.566401 | 2020-04-03T05:07:48 | 2020-04-03T05:07:48 | 236,245,323 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 401 | cpp | Calculator.cpp | #include "Calculator.h"
#include "Exception.h"
Calculator::Calculator() {
//ctor
}
Calculator::~Calculator() {
//dtor
}
int Calculator::add(int x, int y) {
return x+y;
}
int Calculator::sub(int x, int y) {
return x-y;
}
int Calculator::mult(int x, int y) {
return x*y;
}
int Calculator::div(int x, int y) {
if(y==0)
throw div_by_zero_error("Error");
return x/y;
}
|
1b43828e22a15f7de5c75a278990929cc51a6b5c | 17c77c9f30817431791e019f0333b699d9c4534c | /inventorywidget.h | b82acfe92bd7b9986a6e61ddd708f4bc3d45f121 | [] | no_license | OOPDS-CEME-NUST/project-for-object-oriented-programming-and-data-structures-pied-piper | b8588ab9f789828ac6c9d43a1062421f47ea39ad | 64c901775401b24cf0e4e1c4846d079d2d6c4eb1 | refs/heads/master | 2020-04-17T09:12:37.918129 | 2019-01-18T17:48:05 | 2019-01-18T17:48:05 | 166,449,090 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 634 | h | inventorywidget.h | #ifndef INVENTORYWIDGET_H
#define INVENTORYWIDGET_H
#include "const.h"
#include <QWidget>
#include <QSqlQuery>
#include <QSqlQueryModel>
namespace Ui {
class InventoryWidget;
}
class InventoryWidget : public QWidget
{
Q_OBJECT
public:
explicit InventoryWidget(QWidget *parent = nullptr);
~InventoryWidget();
private:
Ui::InventoryWidget *ui;
QSqlQuery *qry;
QSqlQueryModel *model;
void refreshInventoryTable();
signals:
void inbounded();
void outbounded();
private slots:
void on_pushButtonInbound_clicked();
void on_pushButtonOutbound_clicked();
};
#endif // INVENTORYWIDGET_H
|
7ff128403d36e21257bbc3d88319ad866382eace | a70051a3422c1d2333008a3b1a8f17a5796ef577 | /BatMon/BatMon.ino | 715a06b507b8f929ccc9322e76358f678f41b210 | [] | no_license | svenlindvall/BatMon | 3ff122c40a728c45e3a912adc5567bc94b5ef7db | d656dfb5a53084ecc760fa549bc6e277ad95c4f8 | refs/heads/master | 2021-01-22T20:19:16.852029 | 2015-01-12T10:36:55 | 2015-01-12T10:36:55 | 29,130,634 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,609 | ino | BatMon.ino | #include <SoftwareSerial.h>
#include <Wire.h>
#include <EEPROM.h>
#include <Adafruit_INA219.h>
Adafruit_INA219 ina219;
int eepromAddr = 0;
int val = 0;
byte x = 0;
const int anaTempPin = A0;
int tempVal = 0;
int sensVal = 0;
SoftwareSerial serLCD(10, 11); // RX, TX
unsigned long currentMillis; // store the current value from millis()
unsigned long previousMillis; // for comparison with currentMillis
unsigned int samplingInterval = 32; // default sampling interval is 33ms
unsigned int i2cReadDelayTime = 0; // default delay time between i2c read request and Wire.requestFrom()
struct batInfo_t {
float volt;
float amps;
float ah;
};
batInfo_t batInfo[2];
byte i2cRxData[32];
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
Serial.println("Batteri Monitor V.1.0.0!");
ina219.begin();
// set the data rate for the SoftwareSerial port
serLCD.begin(9600);
serLCD.println("Batteri Monitor V.1.0.0!");
}
void loop() // run over and over
{
currentMillis = millis();
if (currentMillis - previousMillis > samplingInterval)
{
previousMillis += samplingInterval;
if (Serial.available()) serLCD.write(Serial.read());
Wire.requestFrom(2, 6); // request 6 bytes from slave device #2
while(Wire.available()) // slave may send less than requested
{
char c = Wire.read(); // receive a byte as character
Serial.print(c); // print the character
val = int(c);
EEPROM.write(eepromAddr, val);
eepromAddr = eepromAddr + 1;
if (eepromAddr == 512) eepromAddr = 0;
}
Wire.beginTransmission(4); // transmit to device #4
Wire.write(x); // sends one byte
Wire.endTransmission(); // stop transmitting
sensVal = analogRead(anaTempPin);
tempVal = map(sensVal, 0, 1023, 0, 255);
float shuntvoltage = 0;
float busvoltage = 0;
float current_mA = 0;
float loadvoltage = 0;
shuntvoltage = ina219.getShuntVoltage_mV();
busvoltage = ina219.getBusVoltage_V();
current_mA = ina219.getCurrent_mA();
loadvoltage = busvoltage + (shuntvoltage / 1000);
Serial.print("Bus Voltage: "); Serial.print(busvoltage); Serial.println(" V");
Serial.print("Shunt Voltage: "); Serial.print(shuntvoltage); Serial.println(" mV");
Serial.print("Load Voltage: "); Serial.print(loadvoltage); Serial.println(" V");
Serial.print("Current: "); Serial.print(current_mA); Serial.println(" mA");
Serial.println("");
}
}
|
96fa685d949343f7a0a8103e700047516be2b908 | 29911ed02983d040acb22501d4638e76773f4b1d | /app/src/main/cpp/session/HttpSession.h | 02eda0574604d91edd1b8ed94795eb05c5f04e09 | [] | no_license | XiaoShenOL/EnvProxy | cfa6dadd676c4cf063dc38a1ef8d03855e07af18 | e07993f293e87143e562daa3a754db89f69726ee | refs/heads/master | 2023-03-17T07:49:07.154929 | 2018-12-18T12:31:06 | 2018-12-18T12:31:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 579 | h | HttpSession.h | //
// Created by Rqg on 24/04/2018.
//
#ifndef ENVPROXY_TASKHTTP_H
#define ENVPROXY_TASKHTTP_H
#include "Session.h"
class HttpSession : public Session {
public:
HttpSession(SessionInfo *sessionInfo);
virtual ~HttpSession();
int onTunDown(SessionInfo *sessionInfo, DataBuffer *downData) override;
int onTunUp(SessionInfo *sessionInfo, DataBuffer *upData) override;
int onSocketDown(SessionInfo *sessionInfo, DataBuffer *downData) override;
int onSocketUp(SessionInfo *sessionInfo, DataBuffer *upData) override;
};
#endif //ENVPROXY_TASKHTTP_H
|
44c5566750e73803d2655aa864109c4375cc6eec | e37718db54d1b1dc5d999ff8c4f533923b3ad867 | /src/lib/assembleMatrix.hh | b8aa1080a77d180bfa45bb27a9d387e717d68fdf | [] | no_license | modsim/redicon-dune-immo | 724205b6c35c967d2313e4d00d0a623fce82d3ba | d743ab78f1c8800446ba1855b9b91f8bcecb3532 | refs/heads/master | 2021-01-10T06:05:54.812948 | 2016-04-13T11:56:23 | 2016-04-13T11:56:23 | 47,982,551 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,441 | hh | assembleMatrix.hh | #ifndef DUNE_ASSEMBLE_MATRIX_HH
# define DUNE_ASSEMBLE_MATRIX_HH
#include"dune/common/dynmatrix.hh"
//#define DEBUG
#include "integrateEntityDynamic.hh"
#include "pointSource.hh"
#include "updateMatrix.hh"
//#define DEBUG
template<class GridView, class Function, class Source>
Dune::DynamicMatrix<typename Function::ftype> assembleMatrix (const GridView & gv, Function & func, int p, std::vector<Source*> slist)
{
Dune::DynamicMatrix<typename Function::ftype> M = assembleMatrix (gv, func, p);
updateMatrix<GridView, typename Function::ftype, Function::fdimension, Source> (M, gv, slist);
return M;
}
template<class GridView, class Function>
Dune::DynamicMatrix<typename Function::ftype> assembleMatrix (const GridView & gv, Function & func, int p)
{
int dim = GridView::dimension;
int fdim = Function::fdimension;
Dune::DynamicMatrix<typename Function::ftype> M;
int N = gv.size (GridView::dimension) * fdim;
M.resize (N,N);
M = 0;
// MAtrix indeces
typedef typename GridView::IndexSet iSet;
const iSet & set = gv.indexSet();
// get iterator type
typedef typename GridView :: template Codim<0> :: Iterator LeafIterator;
for (LeafIterator it = gv.template begin <0>(); it != gv.template end<0>(); ++it)
{
// FIXME: Same code in Function::vertexSize(): make final in Cx011
Dune::GeometryType gt = it->type();
const Dune::template GenericReferenceElement<typename GridView::ctype, GridView::dimension> &ref =
Dune::GenericReferenceElements<typename GridView::ctype, GridView::dimension>::general(gt);
int vertexsize = ref.size(dim);
Dune::DynamicVector<typename Function::ftype> m = integrateEntityDynamic (*it, func, p);
#ifdef DO_CHECKS
if (vertexsize != func.vertexSize(e))
DUNE_THROW (Dune::Exception, "User provided function gives wrong vertex size");
int size = vertexsize * fdim;
size *= size;
if (m.size() != size)
DUNE_THROW (Dune::Exception, "User provided function returns DynamicVector of wrong size");
#endif
for (int i = 0; i < vertexsize; i++)
for (int j = 0; j < vertexsize; j++)
for (int a = 0; a < fdim; a++)
for (int b = 0; b < fdim; b++)
{
int ind1 = set.subIndex(*it, i, dim) * fdim + a;
int ind2 = set.subIndex(*it, j, dim) * fdim + b;
int ind = i * fdim * fdim * vertexsize + j * fdim * fdim + a * fdim + b;
M[ind1][ind2] += m[ind];
}
}
//updateMatrix<GridView, typename Function::ftype, Function::fdimension, Source> (M, gv, slist);
/*
//#define DO_CHECKS
for (typename std::vector<Source*>::iterator ps = slist.begin(); ps != slist.end(); ++ps)
{
Source * is = *ps;
Dune::DynamicVector<typename Function::ftype> m = (*is) ();
int vertexsize = is->entityVertexSize ();
unsigned int size = vertexsize * fdim;
size *= size;
#ifdef DO_CHECKS
if (m.size() != size)
DUNE_THROW (Dune::Exception, "Point Sources: User provided function returns DynamicVector of wrong size");
#endif
for (int i = 0; i < vertexsize; i++)
for (int j = 0; j < vertexsize; j++)
for (int a = 0; a < fdim; a++)
for (int b = 0; b < fdim; b++)
{
int ind = i * fdim * fdim * vertexsize + j * fdim * fdim + a * fdim + b;
int ind1 = is->entityIndex (i) * fdim + a;
int ind2 = is->entityIndex(j) * fdim + b;
M[ind1][ind2] += m[ind];
std::cerr << "M[" << ind1 << "][" << ind2
<< "]+= " << m[ind] << std::endl;
}
}
*/
return M;
}
#undef DO_CHECKS
#endif
|
876be0c010659409c3e2bc5488746b91e4a8a273 | 374f318e06e0cc050a7fc7916fa9be1d6f3f5931 | /Pass 2/Object_Code.cpp | fa866322952b44c53cd92506833a0acfce756e16 | [] | no_license | usseif97/Assembler | 5f39c0587bd932ae726dba26036a4311860dab93 | 7634af45f7f1a96ff87ccbc455355a5db2dc58e2 | refs/heads/master | 2020-06-19T18:42:32.633833 | 2019-07-14T11:45:34 | 2019-07-14T11:45:34 | 196,826,779 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 24,291 | cpp | Object_Code.cpp | #include "Object_Code.h"
#include "Mnemonic.h"
#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <regex>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
Object_Code::Object_Code()
{
//ctor
}
Object_Code::~Object_Code()
{
//dtor
}
vector <std::array<string, 3>> symbolTable;
vector <pair<string, string>> base_addresses;
Mnemonic mnemonic;
bool base = false;
int Object_Code :: operation (int a, int b, string operatoor)
{
if (operatoor == "+")
{
return a+b;
}
else if (operatoor == "-")
{
return a-b;
}
else if (operatoor == "/")
{
return a/b;
}
else if (operatoor == "*")
{
return a*b;
}
}
bool Object_Code :: checkAandR (string exprssion1, string operation, string exprssion2)
{
if (exprssion1 == "Absolute" && exprssion2 == "Relocatable" && operation == "-")
{
return false;
}
else if (exprssion1 == "Relocatable" && exprssion2 == "Absolute" && operation == "/")
{
return false;
}
else if (exprssion1 == "Relocatable" && exprssion2 == "Absolute" && operation == "*")
{
return false;
}
else if (exprssion1 == "Absolute" && exprssion2 == "Relocatable" && operation == "/")
{
return false;
}
else if (exprssion1 == "Absolute" && exprssion2 == "Relocatable" && operation == "*")
{
return false;
}
else if (exprssion1 == "Relocatable" && exprssion2 == "Relocatable" && operation == "+")
{
return false;
}
else if (exprssion1 == "Relocatable" && exprssion2 == "Relocatable" && operation == "*")
{
return false;
}
else if (exprssion1 == "Relocatable" && exprssion2 == "Relocatable" && operation == "/")
{
return false;
}
else
{
return true;
}
}
bool Object_Code :: checkIfExp(string attribute) {
regex expr("^([0-9|A-Z]+)([*|+|/|/|\-])([0-9|A-Z]+)$");
smatch matcher;
return std::regex_search(attribute, matcher, expr);
}
std::string Object_Code :: getRegisterNum(string registerN) {
if (registerN == "A") {
return "0";
} else if (registerN == "X") {
return "1";
} else if (registerN == "L") {
return "2";
} else if (registerN == "b") {
return "3";
} else if (registerN == "S") {
return "4";
} else if (registerN == "T") {
return "5";
} else if (registerN == "F") {
return "6";
}
}
std::vector<std::string> Object_Code :: split(string line) {
std::string text = line;
std::istringstream iss(text);
std::vector<std::string> results(std::istream_iterator<std::string>{iss}, std::istream_iterator<std::string>());
return results;
}
string Object_Code :: calcDisplacement(string address, string nextaddress, string attribute, bool isPlus) {
base = false;
stringstream str;
str<<nextaddress;
signed pcAddr;
signed baseAddr;
signed tAddr;
signed disp;
bool found = false;
bool isNumber = true;
str>>std::hex>>pcAddr;
if (isPlus) {
pcAddr = 0x0;
}
string tempAttr = "";
if (attribute[0] == '#') {
for (int i = 1; i < attribute.length(); i++) {
tempAttr += attribute[i];
if (!isdigit(attribute[i])) {
isNumber = false;
}
}
} else if (attribute == "*") {
stringstream str;
str<<address;
str>>hex>>pcAddr;
cout<<to_string(pcAddr)<<endl;
return to_string(pcAddr);
} else {
tempAttr = attribute;
isNumber = false;
}
if (isNumber) {
return tempAttr;
}
// checks if it's an expression and get the 2 operands & operator
string operand1 = "";
string operand2 = "";
string operatoor = "";
bool isOperand1 = false;
bool isOperand2 = false;
int a;
int b;
bool operand1Flag = true;
bool isExp = false;
if (checkIfExp(attribute)) {
isExp = true;
for (int i = 0; i < attribute.length(); i++) {
if (attribute[i] == ' ') {
continue;
operand1Flag = false;
} else if (attribute[i] == '+') {
operatoor = "+";
operand1Flag = false;
} else if (attribute[i] == '-') {
operatoor = "-";
operand1Flag = false;
} else if (attribute[i] == '*') {
operatoor = "*";
operand1Flag = false;
} else if (attribute[i] == '/') {
operatoor = "/";
operand1Flag = false;
} else {
if (operand1Flag) {
operand1 += attribute[i];
} else {
operand2 += attribute[i];
}
}
}
for (int i=0 ; i < symbolTable.size(); i++) {
std::array<string,3> temp=symbolTable[i];
if (temp[0] == operand1) {
a = stoi(temp[1]);
isOperand1 = true;
continue;
}
if (temp[0] == operand2) {
b = stoi(temp[1]);
isOperand2 = true;
continue;
}
if (isOperand1 && isOperand2) {
break;
}
}
if (!isOperand1) {
a = stoi(operand1);
}
if (!isOperand2) {
b = stoi(operand2);
}
tAddr = operation(a, b, operatoor);
}
if (!isExp) {
// searches for the target symbol in the symbol table
for (int i=0 ; i < symbolTable.size(); i++) {
std::array<string,3> temp=symbolTable[i];
if (temp[0] == tempAttr) {
int tempTarget = stoi(temp[1]);
stringstream str3;
str3<<to_string(tempTarget);
str3>>dec>>tAddr;
found = true;
break;
}
}
// checks if the symbol table doesn't have the target symbol
if (!found && attribute[0] != '#') {
return "error the target address is wrong as no such target exists";
}
if (!found) {
tAddr = 0x0;
}
if (attribute[0] == '#') {
pcAddr = 0x0;
}
}
disp = tAddr - pcAddr;
// checks if the displacement is less than 2047 or of format 4
if (disp <= 2047 || isPlus) {
return to_string(disp);
} else {
if (base_addresses.empty()) {
return "error base relative can't happen";
} else {
attribute = base_addresses[base_addresses.size() - 1].second;
signed tempBase;
for (int i=0 ; i < symbolTable.size(); i++) {
std::array<string,3> temp=symbolTable[i];
if (temp[0] == attribute) {
int tempTarget = stoi(temp[1]);
stringstream str3;
str3<<to_string(tempTarget);
str3>>dec>>tempBase;
found = true;
break;
}
}
disp = tAddr - tempBase;
base = true;
return to_string(disp);
}
}
}
std::set<std::string> Object_Code :: fillExceptionsIndex() {
std::set<std::string> exceptionsIndex;
exceptionsIndex.insert("ADDR");
exceptionsIndex.insert("COMPR");
exceptionsIndex.insert("RMO");
return exceptionsIndex;
}
void Object_Code :: setSymbolTable(vector <std::array<string, 3>> s) {
symbolTable = s;
}
std::vector<std::string> Object_Code :: getErrorMes() {
vector<string> errorsMes;
errorsMes.push_back("error base relative can't happen");
errorsMes.push_back("error the target address is wrong as no such target exists");
return errorsMes;
}
string Object_Code :: evaluateLine(string line, string nextline) {
std::vector<std::string> results = split(line);
std::vector<std::string> nextresults;
if (nextline != "") {
nextresults = split(nextline);
}
std::set<std::string> exceptionsIndex;
std::vector<std::string> errorsMes;
exceptionsIndex = fillExceptionsIndex();
errorsMes = getErrorMes();
bool extensions[6] = {false};
int resultsSize = results.size();
string mnemonicName;
string operand;
string disp;
if (resultsSize == 5) { // if the length of the line words is 5
mnemonicName = results[3];
// checks for format 4 "e"
if (mnemonicName[0] == '+') {
extensions[5] = true;
string temp = "";
for (int j = 1; j < mnemonicName.length(); j++) {
temp += mnemonicName[j];
}
mnemonicName = temp;
}
// checks if the mnemonic is BASE and add the operand to the base vector
if (mnemonicName == "BASE") {
pair<string, string> p;
p.first = results[1];
p.second = results[4];
base_addresses.push_back(p);
string printing = "";
printing += results[1];
string spaces = "";
for (int j = 0; j < 13 - results[1].length(); j++) {
spaces += " ";
}
printing += spaces;
spaces = "";
for (int j = 0; j < 10; j++) {
spaces += " ";
}
printing += spaces;
for (int i = 2; i < results.size(); i++) {
printing += results[i];
string spaces = " ";
printing += spaces;
}
cout<<printing<<endl<<endl;
return "";
}
if ((results[4][0] == 'X' || results[4][0] == 'C') && results[4][1] == '\'') {
string tempWord = "";
if (results[4][0] == 'X') {
for (int i = 2; i < results[4].length() - 1; i++) {
tempWord += results[4][i];
}
cout<<"X : "<<tempWord<<endl;
} else if (results[4][0] == 'C') {
for (int i = 2; i < results[4].length() - 1; i++) {
int ascii = results[4][i];
stringstream str9;
str9<<hex<<ascii;
tempWord += str9.str();
}
cout<<"C : "<<tempWord<<endl;
}
string printing = "";
printing += results[1];
string spaces = "";
for (int j = 0; j < 13 - results[1].length(); j++) {
spaces += " ";
}
printing += spaces;
printing += tempWord;
spaces = "";
for (int j = 0; j < 10 - tempWord.length(); j++) {
spaces += " ";
}
printing += spaces;
for (int i = 2; i < results.size(); i++) {
printing += results[i];
string spaces = " ";
printing += spaces;
}
cout<<printing<<endl<<endl;
return tempWord;
}
// checks if the mnemonic is WORD or BYTE and make its op code
if (mnemonicName == "WORD" || mnemonicName == "BYTE") {
int tempWord;
tempWord = stoi(results[4]);
string res;
stringstream ss;
ss<<setfill('0')<<setw(6)<<hex<<tempWord;
res = ss.str();
string printing = "";
printing += results[1];
string spaces = "";
for (int j = 0; j < 13 - results[1].length(); j++) {
spaces += " ";
}
printing += spaces;
printing += res;
spaces = "";
for (int j = 0; j < 10 - res.length(); j++) {
spaces += " ";
}
printing += spaces;
for (int i = 2; i < results.size(); i++) {
printing += results[i];
string spaces = " ";
printing += spaces;
}
cout<<printing<<endl<<endl;
return res;
}
// checks if the mnemonic doesn't have op code
if (!mnemonic.isFound(mnemonicName) || mnemonicName[0] == '.' || results[0][0] == '*') {
string printing = "";
printing += results[1];
string spaces = "";
for (int j = 0; j < 13 - results[1].length(); j++) {
spaces += " ";
}
printing += spaces;
spaces = "";
for (int j = 0; j < 10; j++) {
spaces += " ";
}
printing += spaces;
for (int i = 2; i < results.size(); i++) {
printing += results[i];
string spaces = " ";
printing += spaces;
}
cout<<printing<<endl<<endl;
return "";
}
if (mnemonic.getLength(results[3]) == 2) {
string register1 = "";
string register2 = "";
register1 += results[4][0];
register2 += results[4][2];
string res = "";
res = mnemonic.getOpCode(results[3]) + getRegisterNum(register1) + getRegisterNum(register2);
string printing = "";
printing += results[1];
string spaces = "";
for (int j = 0; j < 13 - results[1].length(); j++) {
spaces += " ";
}
printing += spaces;
printing += res;
spaces = "";
for (int j = 0; j < 10 - res.length(); j++) {
spaces += " ";
}
printing += spaces;
for (int i = 2; i < results.size(); i++) {
printing += results[i];
string spaces = " ";
printing += spaces;
}
cout<<printing<<endl<<endl;
return res;
} else { // checks for indexed "x"
operand = results[4];
if (operand[operand.length() - 1] == 'X' && operand[operand.length() - 2] == ',') {
extensions[2] = true;
string temp = "";
for (int j = 0; j < operand.length() - 2; j++) {
temp += operand[j];
}
operand = temp;
}
}
// checks for indirect and immediate "n, i"
if (results[4][0] == '#') {
extensions[0] = false;
extensions[1] = true;
} else if (results[4][0] == '@') {
extensions[0] = true;
extensions[1] = false;
} else {
extensions[0] = true;
extensions[1] = true;
}
} else if (resultsSize == 4) { // if the length of the line words is 4
mnemonicName = results[2];
// checks for format 4 "e"
if (mnemonicName[0] == '+') {
extensions[5] = true;
string temp = "";
for (int j = 1; j < mnemonicName.length(); j++) {
temp += mnemonicName[j];
}
mnemonicName = temp;
}
// checks if the mnemonic is BASE and add the operand to the base vector
if (mnemonicName == "BASE") {
pair<string, string> p;
p.first = results[1];
p.second = results[3];
base_addresses.push_back(p);
string printing = "";
printing += results[1];
string spaces = "";
for (int j = 0; j < 13 - results[1].length(); j++) {
spaces += " ";
}
printing += spaces;
spaces = "";
for (int j = 0; j < 10; j++) {
spaces += " ";
}
printing += spaces;
for (int i = 2; i < results.size(); i++) {
printing += results[i];
string spaces = " ";
printing += spaces;
}
cout<<printing<<endl<<endl;
return "";
}
if ((results[3][0] == 'X' || results[3][0] == 'C') && results[3][1] == '\'') {
string tempWord = "";
if (results[3][0] == 'X') {
for (int i = 2; i < results[3].length() - 1; i++) {
tempWord += results[4][i];
}
cout<<"X : "<<tempWord<<endl;
} else if (results[3][0] == 'C') {
for (int i = 2; i < results[3].length() - 1; i++) {
int ascii = results[3][i];
stringstream str9;
str9<<hex<<ascii;
tempWord += str9.str();
}
cout<<"C : "<<tempWord<<endl;
}
string printing = "";
printing += results[1];
string spaces = "";
for (int j = 0; j < 13 - results[1].length(); j++) {
spaces += " ";
}
printing += spaces;
printing += tempWord;
spaces = "";
for (int j = 0; j < 10 - tempWord.length(); j++) {
spaces += " ";
}
printing += spaces;
for (int i = 2; i < results.size(); i++) {
printing += results[i];
string spaces = " ";
printing += spaces;
}
cout<<printing<<endl<<endl;
return tempWord;
}
// checks if the mnemonic is WORD or BYTE and make its op code
if (mnemonicName == "WORD" || mnemonicName == "BYTE") {
int tempWord;
tempWord = stoi(results[3]);
string res;
stringstream ss;
ss<<setfill('0')<<setw(6)<<hex<<tempWord;
res = ss.str();
string printing = "";
printing += results[1];
string spaces = "";
for (int j = 0; j < 13 - results[1].length(); j++) {
spaces += " ";
}
printing += spaces;
printing += res;
spaces = "";
for (int j = 0; j < 10 - res.length(); j++) {
spaces += " ";
}
printing += spaces;
for (int i = 2; i < results.size(); i++) {
printing += results[i];
string spaces = " ";
printing += spaces;
}
cout<<printing<<endl<<endl;
return res;
}
// checks if the mnemonic doesn't have op code
if (!mnemonic.isFound(mnemonicName) || mnemonicName[0] == '.' || results[0][0] == '*') {
string printing = "";
printing += results[1];
string spaces = "";
for (int j = 0; j < 13 - results[1].length(); j++) {
spaces += " ";
}
printing += spaces;
spaces = "";
for (int j = 0; j < 10; j++) {
spaces += " ";
}
printing += spaces;
for (int i = 2; i < results.size(); i++) {
printing += results[i];
string spaces = " ";
printing += spaces;
}
cout<<printing<<endl<<endl;
return "";
}
if (mnemonic.getLength(results[2]) == 2) {
string register1 = "";
string register2 = "";
register1 += results[3][0];
register2 += results[3][2];
string res = "";
res = mnemonic.getOpCode(results[2]) + getRegisterNum(register1) + getRegisterNum(register2);
string printing = "";
printing += results[1];
string spaces = "";
for (int j = 0; j < 13 - results[1].length(); j++) {
spaces += " ";
}
printing += spaces;
printing += res;
spaces = "";
for (int j = 0; j < 10 - res.length(); j++) {
spaces += " ";
}
printing += spaces;
for (int i = 2; i < results.size(); i++) {
printing += results[i];
string spaces = " ";
printing += spaces;
}
cout<<printing<<endl<<endl;
return res;
} else { // checks for indexed "x"
operand = results[3];
if (operand[operand.length() - 1] == 'X' && operand[operand.length() - 2] == ',') {
extensions[2] = true;
string temp = "";
for (int j = 0; j < operand.length() - 2; j++) {
temp += operand[j];
}
operand = temp;
}
}
// checks for indirect and immediate "n, i"
if (results[3][0] == '#') {
extensions[0] = false;
extensions[1] = true;
} else if (results[3][0] == '@') {
extensions[0] = true;
extensions[1] = false;
} else {
extensions[0] = true;
extensions[1] = true;
}
} else {
return "";
}
// calculating the displacement and checks for PC or Base relative
if (nextline != "") {
disp = calcDisplacement(results[1], nextresults[1], operand, extensions[5]);
if (extensions[5]) {
extensions[3] = false;
extensions[4] = false;
} else if (operand[0] == '#') {
extensions[3] = false;
extensions[4] = false;
} else if (base) {
extensions[3] = true;
extensions[4] = false;
} else {
extensions[3] = false;
extensions[4] = true;
}
}
// printing out the extension of the line
string tempExten;
for (int i = 0; i < 6; i++) {
if (extensions[i]) {
tempExten += "1";
} else {
tempExten += "0";
}
}
// checks for error calculating the displacement
if ((find(errorsMes.begin(), errorsMes.end(), disp) != errorsMes.end()) || disp == "") {
return disp;
}
// converting the displacement into hex and cut it according to format 3 or 4
int hexDisp = stoi(disp);
stringstream str;
str<<setfill('0') << setw(8)<<std::hex<<hexDisp;
string res = str.str();
string ans;
if (extensions[5]) {
ans = res.substr(3, 7);
} else {
ans = res.substr(5, 7);
}
// converts the opcode into binary and removes the last 2 bits
stringstream ss;
ss << hex << mnemonic.getOpCode(mnemonicName);
unsigned n;
ss >> n;
bitset<8> b(n);
// shifting the op code by 2 bits
n = n / (4);
bitset<6> b3(n);
stringstream ss3;
ss3 << hex << uppercase << b3.to_ulong();
// making the opcode concatenation
bitset<12> b4;
// adding the op code
for (int i = 6; i < 12; i++) {
if (b3[i - 6]) {
b4.set(i);
} else {
b4.reset(i - 6);
}
}
// adding the extension
for (int i = 0; i < 6; i++) {
if (tempExten[5 - i] == '0') {
b4.reset(i);
} else {
b4.set(i);
}
}
stringstream ss4;
ss4 << hex << uppercase << b4.to_ulong();
// concatenates all results into one string and converts it into hex
string finOpCode = b3.to_string();
string finExten = tempExten;
string finDisp = ans;
string finRes = ss4.str() + finDisp;
string printing = "";
printing += results[1];
string spaces = "";
for (int j = 0; j < 13 - results[1].length(); j++) {
spaces += " ";
}
printing += spaces;
printing += finRes;
spaces = "";
for (int j = 0; j < 10 - finRes.length(); j++) {
spaces += " ";
}
printing += spaces;
for (int i = 2; i < results.size(); i++) {
printing += results[i];
string spaces = " ";
printing += spaces;
}
cout<<"\t\tn="<<tempExten[0]<<" i="<<tempExten[1]<<" x="<<tempExten[2]<<" b="<<tempExten[3]<<" p="<<tempExten[4]<<" e="<<tempExten[5]<<endl;
cout<<printing<<endl<<endl;
return finRes;
}
|
ec5fe053afb39963123720303f5283c975b5de2e | 8a5976285ef19b03c8f92f88cc2eeff5ff064c26 | /src/pollard.h | 12740e77d6ab006495fd9e92311734a380c57589 | [] | no_license | YaZko/ECM | 470b87b60b9d4fe3c551320ede15c933844b2749 | cd1db935423912fd175b28753e62dd776610b7d0 | refs/heads/master | 2021-01-25T08:42:36.447985 | 2012-05-08T15:52:25 | 2012-05-08T15:52:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 332 | h | pollard.h | //
// pollard.h
//
//
// Created by MOi on 13/04/12.
// Copyright (c) 2012 Ecole Normale Supérieure de Cachan. All rights reserved.
//
#ifndef _pollard_h
#define _pollard_h
#include <vector>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include "utils.h"
using namespace std;
vector<long> pollard(long n);
#endif
|
6794cf94323246f912edc4a6f5e77475305bf4a0 | e65a4dbfbfb0e54e59787ba7741efee12f7687f3 | /cad/freehdl/files/patch-freehdl_kernel-sig-info.hh | 2c178a3c3cf3397212ab184fae426023f7ed63b7 | [
"BSD-2-Clause"
] | permissive | freebsd/freebsd-ports | 86f2e89d43913412c4f6b2be3e255bc0945eac12 | 605a2983f245ac63f5420e023e7dce56898ad801 | refs/heads/main | 2023-08-30T21:46:28.720924 | 2023-08-30T19:33:44 | 2023-08-30T19:33:44 | 1,803,961 | 916 | 918 | NOASSERTION | 2023-09-08T04:06:26 | 2011-05-26T11:15:35 | null | UTF-8 | C++ | false | false | 720 | hh | patch-freehdl_kernel-sig-info.hh | --- freehdl/kernel-sig-info.hh.orig 2013-02-25 17:49:33.000000000 +0000
+++ freehdl/kernel-sig-info.hh
@@ -164,10 +164,6 @@ template<class T>class sig_info : public
type_info_interface *type, char attr, sig_info_base *base_sig,
acl *aclp, vtime delay, void *sr) :
sig_info_base(iname, n, sln, type, attr, base_sig, aclp, delay, sr) {};
- /* Constructor to instantiate a guard signal */
- sig_info(name_stack &iname, const char *n, const char *sln,
- void *reader, void *sr) :
- sig_info_base(iname, n, sln, reader, sr) {};
/* Constructor to instantiate an alias signal */
sig_info(name_stack &iname, const char *n, const char *sln,
type_info_interface *ty, sig_info_base *aliased_sig,
|
1414befa2246a961e1f6dba8ba1c0f86ae2e445c | 29c1a92c7aa0d67e3ae5c97f6e8621a4126c7962 | /qminer/demo/demo_app.cpp | a0cee3279ad8e4aa48623662223f074796e5194e | [] | no_license | bergloman/docker-images | 793754aa955e77b369e67fbd989724b4fe0d64e0 | 492feb50261feccdbd6a398f00f129dbaf879d5c | refs/heads/master | 2020-04-23T15:12:16.637224 | 2019-10-26T09:15:33 | 2019-10-26T09:15:33 | 171,256,853 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 598 | cpp | demo_app.cpp | #include <qminer.h>
int main(int argc, char **argv) {
#ifndef NDEBUG
// report we are running with all Asserts turned on
printf("*** Running in debug mode ***\n");
#endif
Env = TEnv(argc, argv, TNotify::StdNotify);
TQm::TEnv::Init();
TQm::TEnv::InitLogger(2, "std");
TQm::InfoLog("Hello");
// Env.PrepArgs("Stream processing", 0);
try {
// do some magic
} catch (PExcept Except) {
TQm::ErrorLog(TStr::Fmt("Error: %s\n", Except->GetMsgStr().CStr()));
} catch (...) {
TQm::ErrorLog("Unknown exception!");
}
return 0;
}
|
46ce3c55f6adaa89ec81a53788edfa591f77513d | eaa3e394d3bfbc201c3f90b8362fc071673855d9 | /cuda-template-master/Linal2/src/Linal2.cpp | bef3c56d70ec0b56e0337b97dbf168849f641410 | [
"MIT"
] | permissive | moarseniy/MechMath-4th-year-thesis | de48c14a082153ce94bae9c886ae686634e2d9db | 3a61c2c991571de7c838a8ad393c42bef55f7c32 | refs/heads/main | 2023-06-09T06:16:47.695974 | 2021-06-14T14:58:48 | 2021-06-14T14:58:48 | 356,969,701 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 26,346 | cpp | Linal2.cpp |
#include <iostream>
//#include <fstream>
#include "Linal2.h"
//#include <cmath>
using namespace std;
MyArray::MyArray() {
this->array_size = 0;
this->p = nullptr;
}
MyArray::MyArray(int array_size) {
this->array_size = array_size;
this->p = new double[array_size];
for (int i = 0; i < array_size; i++) {
p[i] = 0.0;
}
}
MyArray::MyArray(const MyArray &a) {
this->array_size = a.array_size;
this->p = new double[array_size];
for (int i = 0; i < array_size; i++) {
p[i] = a.p[i];
}
}
MyArray::~MyArray() {
delete [] p;
}
void MyArray::Show() {
for (int i = 0; i < array_size; i++) {
cout << p[i] << " ";
}
cout << endl;
}
void MyArray::Set(int index, double value) {
if (p != nullptr) {
if((index >= 0) && (index < array_size)) {
p[index] = value;
}
}
}
int MyArray::get_size() {
return array_size;
}
double* MyArray::get_data() {
return p;
}
void MyArray::zap() {
for (int i = 0; i < array_size; i++) {
p[i] = rand() % 10;
}
}
double & MyArray::operator [](int index) {
return p[index];
}
MyArray MyArray::operator =(const MyArray &a) {
this->array_size = a.array_size;
this->p = new double[array_size];
for (int i = 0; i < array_size; i++) {
p[i] = a.p[i];
}
return *this;
}
double MyArray::norma() {
double res = 0;
for (int i = 0; i < array_size; i++) {
res += p[i] * p[i];
//cout<<"res= "<<res<<endl;
}
return sqrt(abs(res));
}
void MyArray::grad(double (*f)(MyArray x), MyArray &res, double eps) {
double tau = 0.1 * sqrt(eps);
//double fx = f(x);
//cout<<"fx= "<<fx<<endl;
for (int i = 0; i < array_size; i++) {
double tmp1 = p[i];
p[i] += tau;
double fx1 = f(*this);
p[i] = tmp1;
double tmp2 = p[i];
p[i]-=tau;
double fx2 = f(*this);
p[i] = tmp2;
res[i] = (fx1 - fx2) / (2 * tau);
}
}
void MyArray::Hessian(double (*f)(MyArray x), Matrix &matr, double eps) {
double tau = 0.1 * sqrt(eps);
int k = 0, n = array_size;
MyArray tmp1(n), tmp2(n), tmp3(n), tmp4(n);
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
if (i == j) {
for (k = 0; k < n; k++) {
if (k == j) {
tmp1[k] = p[k] + tau;
tmp2[k] = p[k] - tau;
} else {
tmp1[k] = p[k];
tmp2[k] = p[k];
}
}
matr(i, j) = (f(tmp1) - 2 * f(*this) + f(tmp2)) / (tau * tau);
} else {
for (k = 0; k < n; k++) {
if (k == i) {
tmp1[k] = p[k] + tau;
tmp2[k] = p[k] + tau;
tmp3[k] = p[k] - tau;
tmp4[k] = p[k] - tau;
}
if (k == j) {
tmp1[k] = p[k] + tau;
tmp2[k] = p[k] - tau;
tmp3[k] = p[k] + tau;
tmp4[k] = p[k] - tau;
} else {
tmp1[k] = p[k];
tmp2[k] = p[k];
tmp3[k] = p[k];
tmp4[k] = p[k];
}
}
matr(i, j) = (f(tmp1) - f(tmp2) - f(tmp3) + f(tmp4)) / (4 * tau * tau);
matr(j, i) = (f(tmp1) - f(tmp2) - f(tmp3) + f(tmp4)) / (4 * tau * tau);
}
}
}
}
void MyArray::WriteToFile() {
fstream out;
out.open("output.txt", fstream::out);
if (array_size > 0) {
for (int i = 0; i < array_size; i++) {
out << p[i] << " ";
}
out << endl;
} else {
cout << "Incorrect data! : WriteToFile" << endl;
}
}
void MyArray::ReadFromFile() {
fstream in;
in.open("input.txt", fstream::in);
if (array_size > 0) {
for (int i = 0; i < array_size; i++) {
in >> p[i];
}
} else {
cout << "Incorrect data! : ReadFromFile" << endl;
}
}
///////////////////
//////MATRIX///////
///////////////////
Matrix::Matrix() {
this->row = 0;
this->col = 0;
this->m = nullptr;
}
Matrix::Matrix(int n) {
this->row = n;
this->col = n;
this->m = new double[row * col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
m[j + i * col] = 0.0;
}
}
}
Matrix::Matrix(int row, int col) {
this->row = row;
this->col = col;
this->m = new double[row * col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
m[j + i * col] = 0.0;
}
}
}
Matrix::Matrix(const Matrix &a) {
this->row = a.row;
this->col = a.col;
m = new double[row * col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
m[j + i * col] = a.m[j + i * col];
}
}
}
Matrix::~Matrix() {
delete [] m;
}
double & Matrix::operator ()(int i, int j) {
return m[j + i * col];
}
void Matrix::Show() {
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
cout << "[" << j + i * col << "] = " << m[j + i * col] << " ";
}
cout << endl;
}
cout << endl;
}
void Matrix::Set(int index1, int index2, double value) {
if ((index1 >= 0) && (index2 >= 0) && (index1 < row) && (index2 < col)) {
m[index2 + index1 * col] = value;
}
}
int Matrix::get_row() {
return row;
}
int Matrix::get_col() {
return col;
}
void Matrix::zap() {
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
m[j + i * col] = rand() % 10;
}
}
}
Matrix Matrix::operator =(const Matrix &a) {
this->row = a.row;
this->col = a.col;
this->m = new double[row * col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
m[j + i * col] = a.m[j + i * col];
}
}
return *this;
}
void Matrix::scale(double value) {
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
m[j + i * col] *= value;
}
}
}
Matrix Matrix::Sum(Matrix &a) {
Matrix temp(a.row, a.col);
if (row == a.row || col == a.col) {
for (int i = 0; i < temp.row; i++) {
for (int j = 0; j < temp.col; j++) {
temp(i, j) = m[j + i * col] + a(i, j);
}
}
} else {
cout << "ERROR! Sum: row1!=row2 or col1!=col2" << endl;
}
return temp;
}
Matrix Matrix::Difference(Matrix &a) {
Matrix temp(a.row, a.col);
if (row == a.row || col == a.col) {
for (int i = 0; i < temp.row; i++) {
for (int j = 0; j < temp.col; j++) {
temp(i, j) = m[j + i * col] - a(i, j);
}
}
} else {
cout << "ERROR! Difference: row1!=row2 or col1!=col2" << endl;
}
return temp;
}
Matrix Matrix::Product(Matrix &a) {
Matrix temp(row, a.col);
if (col == a.row) {
for (int i = 0; i < row; i++) {
for (int j = 0; j < a.col; j++) {
temp(i, j) = 0.0;
for (int k = 0; k < col; k++) {
temp(i, j) += m[k + i * col] * a(k, j);
}
}
}
} else {
cout << "ERROR! Product: col1 != row2" << endl;
}
return temp;
}
MyArray Matrix::Product(MyArray &v) {
MyArray temp(row);
if (col == v.get_size()) {
for (int i = 0; i < row; i++) {
temp[i] = 0.0;
for (int j = 0; j < col; j++) {
temp[i] += m[j + i * col] * v[j];
}
}
} else {
cout << "ERROR! Product: col != vector size" << endl;
}
return temp;
}
void Matrix::LU_decomposition(Matrix &L, Matrix &U, int n) {
U = *this;
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
L.m[i + j * col] = U.m[i + j * col] / U.m[i + i * col];
}
}
for (int k = 1; k < n; k++) {
for (int i = k - 1; i < n; i++) {
for (int j = i; j < n; j++) {
L.m[i + j * col] = U.m[i + j * col] / U.m[i + i * col];
}
}
for (int i = k; i < n; i++) {
for (int j = k - 1; j < n; j++) {
U.m[j + i * col] = U.m[j + i * col] - L.m[k - 1 + i * col] * U.m[j + (k - 1) * col];
}
}
}
L.isDiag = true;
U.isDiag = true;
}
Matrix & Matrix::transpose() {
double temp;
if (col == row) {
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
if (i > j) {
temp = m[j + i * col];
m[j + i * col] = m[i + j * row];
m[i + j * row] = temp;
}
}
}
this->isTrans = true;
} else {
cout << "ERROR! transpose: col != row" << endl;
}
return *this;
}
void Matrix::transpose2() {
Matrix temp_matr(row, col);
temp_matr = *this;
int temp_size = row;
this->row = col;
this->col = temp_size;
if (col == row) {
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
//temp_matr(i, j) = m[i + j * row];
m[j + i * col] = temp_matr.m[i + j * row];
}
}
//this->isTrans = true;
} else {
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
m[j + i * col] = temp_matr.m[i + j * row];
// temp_matr(i, j) = m[i + j * col];
//m[j + i * col] = temp_matr.m[i + j * row];
}
}
}
//return *this;
}
void Matrix::transpose_not_square() {
}
//not ideal
Matrix & Matrix::Gauss() {
double t = 0.0;
for (int k = 0; k < row; k++) {
for (int i = k + 1; i < row; i++) {
t = (double)m[k + i * col] / m[k + k * col];
for (int j = 0; j < col; j++) {
m[j + i * col] -= m[j + k * col] * t;
}
}
}
this->isDiag = true;
return *this;
}
//not ideal
double Matrix::det_gauss() {
double determinant = 1.0;
Matrix temp(row, col);
temp = *this;
if (!(temp.isDiag))
temp.Gauss();
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
if (i == j) {
determinant *= temp.m[j + i * col];
}
}
}
return determinant;
}
void Matrix::Get_matrix(int n, Matrix &temp_matr, int indRow, int indCol) {
int ki = 0;
for (int i = 0; i < n; i++) {
if (i != indRow) {
for (int j = 0, kj = 0; j < n; j++) {
if (j != indCol) {
temp_matr(ki, kj) = m[j + i * col];
kj++;
}
}
ki++;
}
}
}
double det3x3(double a0, double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8) {
Matrix temp(3, 3);
temp(0, 0) = a0;
temp(0, 1) = a1;
temp(0, 2) = a2;
temp(1, 0) = a3;
temp(1, 1) = a4;
temp(1, 2) = a5;
temp(2, 0) = a6;
temp(2, 1) = a7;
temp(2, 2) = a8;
return temp.det(3);
}
double Matrix::det(int n) {
double temp = 0;
int k = 1;
if (n == 1) {
return m[0];
} else if (n == 2) {
return m[0 + 0 * col] * m[1 + 1 * col] - m[0 + 1 * col] * m[1 + 0 * col];
} else if (n == 3) {
return m[0]*m[4]*m[8] +
m[1]*m[6]*m[5] +
m[2]*m[3]*m[7] -
m[6]*m[4]*m[2] -
m[0]*m[5]*m[7] -
m[1]*m[3]*m[8];
} else if (n == 4) {
double v1 = det3x3(m[5], m[6], m[7], m[9], m[10], m[11], m[13], m[14], m[15]);
double v2 = det3x3(m[1], m[2], m[3], m[9], m[10], m[11], m[13], m[14], m[15]);
double v3 = det3x3(m[1], m[2], m[3], m[5], m[6], m[7], m[13], m[14], m[15]);
double v4 = det3x3(m[1], m[2], m[3], m[5], m[6], m[7], m[9], m[10], m[11]);
return v1 - v2 + v3 - v4;
} else if (n >= 5) {
for (int i = 0; i < n; i++) {
int p = n - 1;
Matrix temp_matr(p, p);
this->Get_matrix(n, temp_matr, 0, i);
temp += k * m[i + 0 * col] * temp_matr.det(p);
k -= k;
}
return temp;
}
cout << "Det = 0.0!!!";
return 0.0;
}
void Matrix::inverse(Matrix &matr, int n, bool isDiag) {
Matrix inverse_matr(n, n);
double determinant = this->det(n);
if (determinant) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
int p = n - 1;
Matrix temp_matr(p, p);
this->Get_matrix(n, temp_matr, i, j);
inverse_matr(i, j) = pow(-1.0, i + j + 2) * temp_matr.det(p) / determinant;
}
}
} else {
cout << "ERROR! inverse: DETERMINANT = 0!" << endl;
exit(-1);
}
inverse_matr.transpose();
matr = inverse_matr;
}
void Matrix::Solve_Gauss_reverse(Matrix matr, MyArray B, MyArray &res, int n, bool isDown) {
if (!isDown) {
for (int i = n - 1; i >= 0; i--) {
double temp = 0.0;
for (int j = i + 1; j < n; j++) {
temp += matr(i, j) * res[j];
}
res[i] = (B[i] - temp) / matr(i, i);
}
} else {
for (int i = 0; i < n; i++) {
double temp = 0.0;
for (int j = i - 1; j >= 0; j--) {
temp += matr(i, j) * res[j];
}
res[i] = (B[i] - temp) / matr(i, i);
}
}
}
void Matrix::LU_solve(Matrix A, MyArray B, MyArray &result, int n) {
MyArray res_tmp(n);
Matrix L(n, n), U(n, n);
A.LU_decomposition(L, U, n);
std::cout << "LU_decomposition success\n";
// std::cout << "L = \n";
// L.Show();
// std::cout << "U = \n";
// U.Show();
Solve_Gauss_reverse(L, B, res_tmp, n, 1);
Solve_Gauss_reverse(U, res_tmp, result, n, 0);
}
void Matrix::CGM_solve(Matrix A, MyArray B, MyArray &x_k, int n) {
int k = 1;
double eps = 0.00001;
double *z_k = new double[n];
double *r_k = new double[n];
double *Az = new double[n];
double alpha, beta, mf = 0.0;
double Spr, Spr1, Spz;
for (int i = 0; i < n; i++) {
mf += B[i] * B[i];
x_k[i] = 0.2;
}
for (int i = 0; i < n; i++) {
Az[i] = 0.0;
for (int j = 0; j < n; j++) {
Az[i] += A(i, j) * x_k[j];
}
r_k[i] = B[i] - Az[i];
z_k[i] = r_k[i];
}
do{
Spz=0.0;
Spr=0.0;
for (int i = 0; i < n; i++) {
Az[i] = 0.0;
for (int j = 0; j < n; j++) {
Az[i] += A(i, j) * z_k[j];
}
Spz += Az[i] * z_k[i];
Spr += r_k[i] * r_k[i];
}
alpha = Spr / Spz;
Spr1 = 0.0;
for (int i = 0; i < n; i++) {
x_k[i] += alpha * z_k[i];
r_k[i] -= alpha * Az[i];
Spr1 += r_k[i] * r_k[i];
cout << "Iter #" << k;
cout << " " << "X[" << i << "] = " << x_k[i] << endl;
}
cout << endl;
k++;
beta = Spr1 / Spr;
for (int i = 0; i < n; i++) {
z_k[i] = r_k[i] + beta * z_k[i];
}
} while(Spr1 / mf > eps * eps);
cout << endl;
delete [] Az;
delete [] z_k;
delete [] r_k;
}
void Matrix::WriteToFile() {
fstream out;
out.open("output.txt", fstream::out);
if (row > 0 && col > 0) {
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
out << m[j + i * col] << " ";
}
out << endl;
}
} else {
cout << "Incorrect data! : WriteToFile" << endl;
}
}
void Matrix::ReadFromFile() {
fstream in;
in.open("input.txt", fstream::in);
if (row > 0 && col > 0) {
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
in >> m[j + i * col];
}
}
} else {
cout << "Incorrect data! : ReadFromFile" << endl;
}
}
///////////////////////
/////SPARSE MATRIX/////
///////////////////////
SparseMatrix::SparseMatrix(int size) {
this->sparse_size = size;//size * size;//72
this->x = new int[sparse_size];
this->y = new int[sparse_size];
this->data = new double[sparse_size];
}
SparseMatrix::SparseMatrix(const SparseMatrix &m) {
sparse_size = m.sparse_size;
this->x = new int[sparse_size];
this->y = new int[sparse_size];
this->data = new double[sparse_size];
for (int i = 0; i < sparse_size; i++) {
x[i] = m.x[i];
y[i] = m.y[i];
data[i] = m.data[i];
}
}
SparseMatrix SparseMatrix::operator =(const SparseMatrix &m) {
sparse_size = m.sparse_size;
this->x = new int[sparse_size];
this->y = new int[sparse_size];
this->data = new double[sparse_size];
for (int i = 0; i < sparse_size; i++) {
x[i] = m.x[i];
y[i] = m.y[i];
data[i] = m.data[i];
}
return *this;
}
SparseMatrix::~SparseMatrix() {
delete [] x;
delete [] y;
delete [] data;
}
void SparseMatrix::resize() {
int *x_new = new int[sparse_size];
int *y_new = new int[sparse_size];
double *data_new = new double[sparse_size];
for (int i = 0; i < sparse_size; i++) {
x_new[i] = x[i];
y_new[i] = y[i];
data_new[i] = data[i];
}
delete [] x;
delete [] y;
delete [] data;
x = x_new;
y = y_new;
data = data_new;
}
void SparseMatrix::resize(int size) {
int *x_new = new int[size];
int *y_new = new int[size];
double *data_new = new double[size];
for (int i = 0; i < size; i++) {
x_new[i] = x[i];
y_new[i] = y[i];
data_new[i] = data[i];
}
delete [] x;
delete [] y;
delete [] data;
x = x_new;
y = y_new;
data = data_new;
sparse_size = size;
}
int SparseMatrix::get_size() {
return sparse_size;
}
void SparseMatrix::set_value(int row, int col, double value) {
for (int i = 0; i < sparse_size; i++) {
if (x[i] == row && y[i] == col) {
data[i] = value;
}
}
}
int SparseMatrix::get_x(int index) {
return x[index];
}
int SparseMatrix::get_y(int index) {
return y[index];
}
double SparseMatrix::get_value(int index) {
return data[index];
}
int* SparseMatrix::get_x() {
return x;
}
int* SparseMatrix::get_y() {
return y;
}
double* SparseMatrix::get_data() {
return data;
}
SparseMatrix SparseMatrix::DeleteZeros() {
int new_size = sparse_size;
int k = 0;
SparseMatrix temp(sparse_size);
for (int i = 0; i < sparse_size; i++) {
if (data[i] != 0) {
temp.x[k] = x[i];
temp.y[k] = y[i];
temp.data[k] = data[i];
k++;
} else {
new_size--;
}
}
cout<<"new_size = " << new_size<<endl;
temp.resize(new_size);
return temp;
}
int SparseMatrix::CountNonZero() {
int nonzero = 0;
for (int i = 0; i < sparse_size; i++) {
if (data[i] != 0) {
nonzero++;
}
}
return nonzero;
}
//int CountNonZero(std::vector<Triplet> t) {
// int nonzero = 0;
// for (int i = 0; i < t.size(); i++) {
// if (t[i].get_value() != 0.0) {
// nonzero++;
// } else {
// t.erase(t.begin() + i);
// }
// }
// return nonzero;
//}
void SparseMatrix::ConvertTripletToSparse(std::vector<Triplet> t) {
int new_size = sparse_size;
int k = 1;
int index = 0;
bool changeme = false;
for (int i = 0; i < sparse_size; i++ ) {
//t[i].Show();
if (i == 0) {
x[0] = t[0].x_value;
y[0] = t[0].y_value;
data[0] = t[0].value;
this->v.push_back(t[0]);
//t[0].Show();
} else {
for (int j = 0; j < k; j++) {
if (t[i].x_value == x[j] && t[i].y_value == y[j]) {
// if (t[i].x_value == 0 && t[i].y_value == 1) {
// std::cout << index << " ";
// }
changeme = true;
index = j;
}
}
if (changeme == true) {
//if (t[i].x_value == x[index] && t[i].y_value == y[index]) {
// if (t[i].x_value == 0 && t[i].y_value == 0) {
// std::cout << index << " ";
// }
data[index] += t[i].value;
new_size--;
changeme = false;
//}
} else {
x[k] = t[i].x_value;
y[k] = t[i].y_value;
data[k] = t[i].value;
this->v.push_back(t[i]);
k++;
}
}
}
sparse_size = new_size;
// bool changeme = false;
// for (int i = 0; i < sparse_size; i++ ) {
// if (i == 0) {
// x[i] = t[i].x_value;
// y[i] = t[i].y_value;
// data[i] = t[i].value;
// this->v.push_back(t[i]);
// } else {
// for (int j = 0; j < i; j++) {
// if (t[i].x_value == x[j] && t[i].y_value == y[j]) {
// changeme = true;
// t[i].Show();
// }
// }
// if (changeme == true) {
// for (int j = 0; j < i; j++) {
// if (t[i].x_value == x[j] && t[i].y_value == y[j]) {
// data[j] += t[i].value;
// new_size--;
// changeme = false;
// }
// }
// } else {
// x[i] = t[i].x_value;
// y[i] = t[i].y_value;
// data[i] = t[i].value;
// this->v.push_back(t[i]);
// }
// }
// }
// sparse_size = new_size;
// int i = 0;
// for (std::vector<Triplet>::iterator it = t.begin(); it != t.end(); ++it) {
// x[i] = it->x;
// y[i] = it->y;
// data[i] = it->data;
// i++;
// }
}
// void SparseMatrix::ConvertToMatrix(Matrix &M) {
// int k = 0;
// for (int i = 0; i < M.get_row(); i++) {
// for (int j = 0; j < M.get_col(); j++) {
// if (x[k] == i && y[k] == j) {
// M(i, j) = data[k];
// //cout<<data[k]<<" ";
// k++;
// } else {
// M(i, j) = 0.0;
// }
// }
// }
// }
void SparseMatrix::ConvertToMatrix(Matrix &M) {
int n = M.get_row();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
for (int k = 0; k < sparse_size; k++) {
if (i == x[k] && j == y[k] && data[k] != 0) {
M(i, j) += data[k];
}
}
}
}
}
void SparseMatrix::SortIt() {
int temp;
double temp_value;
for (int i = 0; i < sparse_size; i++) {
for (int j = 0; j < sparse_size - 1; j++) {
if (x[j] > x[j + 1]) {
temp = x[j];
x[j] = x[j + 1];
x[j + 1] = temp;
temp = y[j];
y[j] = y[j + 1];
y[j + 1] = temp;
temp_value = data[j];
data[j] = data[j + 1];
data[j + 1] = temp_value;
}
}
}
for (int i = 0; i < sparse_size; i++) {
for (int j = 0; j < sparse_size - 1; j++) {
if (y[j] > y[j + 1] && x[j] == x[j + 1]) {
temp = x[j];
x[j] = x[j + 1];
x[j + 1] = temp;
temp = y[j];
y[j] = y[j + 1];
y[j + 1] = temp;
temp_value = data[j];
data[j] = data[j + 1];
data[j + 1] = temp_value;
}
}
}
}
void SparseMatrix::ConvertToCSR(int *ptr, int *ind, double *data_csr, int n) {
for (int i = 0; i < n + 1; i++)
{
//ptr[i] = 0.0;
}
for (int i = 0; i < sparse_size; i++)
{
data_csr[i] = data[i];
ind[i] = y[i];
//ptr[x[i] + 1]++;
}
for (int i = 0; i < n; i++)
{
//ptr[i + 1] += ptr[i];
}
}
void SparseMatrix::WriteData() {
for (int i = 0; i < sparse_size; i++) {
cout << data[i] << " ";
}
}
void SparseMatrix::SparseLU() {
// for (int i = 0; i < n; i++) {
// for (int j = i; j < n; j++) {
// L.m[i + j * col] = U.m[i + j * col] / U.m[i + i * col];
// }
// }
// for (int k = 1; k < n; k++) {
// for (int i = k - 1; i < n; i++) {
// for (int j = i; j < n; j++) {
// L.m[i + j * col] = U.m[i + j * col] / U.m[i + i * col];
// }
// }
// for (int i = k; i < n; i++) {
// for (int j = k - 1; j < n; j++) {
// U.m[j + i * col] = U.m[j + i * col] - L.m[k - 1 + i * col] * U.m[j + (k - 1) * col];
// }
// }
// }
// float value1;
// int x1, y1;
// cout << "SparseLU ------\n";
// SparseMatrix U(*this);
// SparseMatrix L(sparse_size);
// for (int i = 0; i < sparse_size; i++) {
// if (x[i] == y[i]) {
// value1 = data[i];
// x1 = x[i];
// y1 = y[i];
// }
// for (int j = i; j < sparse_size; j++) {
// L.data[j] = U.data[j] / value1;
// }
// }
// for (int k = 1; k < sparse_size; k++) {
// for (int i = k - 1; i < sparse_size; i++) {
// if (x[i] == y[i]) {
// value1 = data[i];
// x1 = x[i];
// y1 = y[i];
// }
// for (int j = i; j < sparse_size; j++) {
// L.data[j] = U.data[j] / value1;
// }
// }
// for (int i = k; i < sparse_size; i++) {
// for (int j = k - 1; j < sparse_size; j++) {
// U.data[j] = U.data[j] - L.data[k - 1 + i * col] * U.data[j + (k - 1) * col];
// }
// }
// }
// cout<<"U=\n";
// U.Show();
// cout<<"L=\n";
// L.Show();
// for (int i = 0; i < sparse_size; i++) {
// if (x[i] == y[i]) {
// value1 = data[i];
// x1 = x[i];
// y1 = y[i];
// }
// for (int j = 0; j < sparse_size; j++) {
// if (x[j] == x1) {
// data[j] = (data[j] * value1 > 0) ? data[j] - data[j] / value1 * data[j]
// : data[j] + data[j] / value1 * data[j];
// } else if (y[j] == y1) {
// }
// }
// }
}
void SparseMatrix::CGM_solve(MyArray B, MyArray &x_k, int n) {
int k = 1;
double eps = 1e-20;
double *z_k = new double[n];
double *r_k = new double[n];
double *Az = new double[n];
double alpha, beta, mf = 0.0;
double Spr, Spr1, Spz;
for (int i = 0; i < n; i++) {
mf += B[i] * B[i];
x_k[i] = 0.2;
}
for (int i = 0; i < n; i++) {
Az[i] = 0.0;
}
for (int i = 0; i < sparse_size; i++) {
Az[x[i]] += data[i] * x_k[y[i]];
}
for (int i = 0; i < n; i++) {
r_k[i] = B[i] - Az[i];
z_k[i] = r_k[i];
}
do{
Spz=0.0;
Spr=0.0;
for (int i = 0; i < n; i++) {
Az[i] = 0.0;
}
for (int i = 0; i < sparse_size; i++) {
Az[x[i]] += data[i] * z_k[y[i]];
}
for (int i = 0; i < n; i++) {
Spz += Az[i] * z_k[i];
Spr += r_k[i] * r_k[i];
}
alpha = Spr / Spz;
Spr1 = 0.0;
for (int i = 0; i < n; i++) {
x_k[i] += alpha * z_k[i];
r_k[i] -= alpha * Az[i];
Spr1 += r_k[i] * r_k[i];
//cout << "Iter #" << k;
//cout << " " << "X[" << i << "] = " << x_k[i] << endl;
}
//cout << endl;
k++;
beta = Spr1 / Spr;
for (int i = 0; i < n; i++) {
z_k[i] = r_k[i] + beta * z_k[i];
}
} while(Spr1 / mf > eps * eps);
//cout << endl;
delete [] Az;
delete [] z_k;
delete [] r_k;
}
void SparseMatrix::Show() {
cout << "X\tY\tValue\n";
for (int i = 0; i < sparse_size; i++) {
cout << x[i] << "\t" << y[i] << "\t" << data[i] << endl;
}
}
void SparseMatrix::ShowAsMatrix(int n) {
int k = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (x[k] == i && y[k] == j) {
cout << data[k] << " ";
k++;
} else {
cout << "0 ";
}
}
cout << endl;
}
}
|
a69f897b10885a8058289c265e04a585bd060941 | d7ebe2640ecfa89b69448d4c9388123bffe3b277 | /src/game.h | 3e7b303f6881875da08aac2590ae44c1fbb14aa7 | [] | no_license | kesslern/fallingsand | 3b436fc5670665db0b6bac0cdc18d77947625238 | 4fea2d40ff634767a7b05c80ad5f58d2c9d6e675 | refs/heads/master | 2021-01-21T13:14:16.041440 | 2015-07-15T03:12:18 | 2015-07-15T03:12:18 | 38,594,102 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 710 | h | game.h | #ifndef GAME_H
#define GAME_H
class Particle;
class SDL_Window;
class SDL_Renderer;
class Game
{
public:
Game(int screen_width, int screen_height);
~Game();
bool run();
int screen_width_;
int screen_height_;
unsigned int current_frame_ = 0;
Particle** particles;
private:
/* Create walls. */
void leftClick(int x, int y);
/* Delete particles. */
void rightClick(int x, int y);
/* Calculate the FPS at some given interval. */
void calculateFps();
/* Process mouse buttons and key presses. */
void processEvents();
/* Update all the particles on the screen. */
void update();
SDL_Window* window_;
SDL_Renderer* renderer_;
int fps_;
bool quit_ = false;
};
#endif
|
13a519a3f3f63b25f0944d2000733b5ccd63594d | 83e79571a6d4d1778d54de3f13d602d5254adcd1 | /src/dal/data_common/Filename.h | 82f745811888ccd7d60b1dfe0ca68241f3361d14 | [] | no_license | jjdmol/DAL | d15d15df36956a2f710170b0f058cf93ea93d604 | f2eb2877d606520b1a660b030532c193ab48cdbb | refs/heads/master | 2021-01-16T21:51:41.112844 | 2011-05-17T11:37:40 | 2011-05-17T11:37:40 | 1,733,529 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 13,219 | h | Filename.h | /***************************************************************************
* Copyright (C) 2009 *
* Lars B"ahren (bahren@astron.nl) *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef FILENAME_H
#define FILENAME_H
// Standard library header files
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
namespace DAL { // Namespace DAL -- begin
/*!
\class Filename
\ingroup DAL
\ingroup data_common
\brief Class to generate filenames matching the LOFAR convention
\author Lars Bähren
\date 2009/09/28
\test tFilename.cc
<h3>Prerequisite</h3>
<ul type="square">
<li>\ref dal_icd_005
</ul>
<h3>Synopsis</h3>
This class implements the naming conventions for files, as laid down in
the LOFAR Data Format ICD LOFAR-USG-ICD-005. According to the ICD the name
of a LOFAR data file is constructed as follows:
\verbatim
<Prefix><Observation ID>_<Optional Descriptors>_<Filetype>.<Extension>
\endverbatim
In this the individual fields are defined as follows:
<ul>
<li><b>Prefix</b>, for a standard LOFAR dataset, is a fixed single
character, 'L'.
<li><b>Observation ID</b> -- unique identifier of the observation
as part of which (or based on which) this data product was created.
<b>Optional Descriptors</b> are used to further indicate the
nature of the data stored within the file. It is best to keep the
file name as short as possible; optional descriptors should only be
used if necessary to better uniquely identify a file.<br>
While the descriptors can be used to e.g. indicate a specific sub-band,
beam or date it is <b>not to be used for ranges</b>.
Digits should be padded with zero's. Please note that the number of
digits can increase in the future; software should be made flexible
to take this into account.
<li><b>Filetype</b> is a marker for the contents of the
file. There will be several different kinds of data produced by
LOFAR, see table below. Importantly, filetype signifies the kind of
LOFAR data that comprise the particular data file, and therefore,
will also signal the appropriate interface control document for
further reference, should users find that necessary. The options for
the file type along with their abbreviations are listed in the table below.
</ul>
For data that is basically generated by further processing of a standard
data product it is advised to keep the identifiers of the standard product
and add extra descriptors as needed just before the \e Extension separated by
one or more dots.
\verbatim
<Prefix><Observation ID>_<Optional Descriptors>_<Filetype>.<Other descriptors>.<Extension>
\endverbatim
In this the individual fields are defined as follows:
<ul>
<li><b>Prefix</b>, for a standard LOFAR dataset, is a fixed single
character, 'L'.
<li><b>Observation ID</b> is the SAS identifier for the process that
generated the data product that this data product is derived from.
<li><b>Optional Descriptors</b> are the same as defined under the
previous section, if applicable.
<li><b>Filetype</b> is the same as defined under the previous section,
if applicable.
<li><b>Other descriptors</b> is relatively free form and could for example
be things like \c flagged, \c manual, \c pub_version3,
\c Nature.page45.image. Basically anything that can't be caught by the
standard descriptors from the previous section. Note if needed these should
preferably be separated by dots, not underscores, to separate them from the
more standardized descriptors.
<li><b>Extension</b> should be last, so it is easy to identify the type of
data product and what tools are needed to read it.
</ul>
<h3>Example(s)</h3>
<ol>
<li>Simple example to generate filename for a HDF5-based BF dataset:
\code
// Set up the input parameters
std::string observationID = "123456789";
DAL::Filename::Type filetype = Filename::bf;
DAL::Filename::Extension extension = Filename::h5;
// Create object ...
DAL::Filename filename (observationID,
filetype,
extension);
// ... and retrieve filename
std::string name = filename.filename();
\endcode
The result will be: <tt>name = "L123456789_bf.h5"</tt>
</ol>
*/
class Filename {
public:
/*!
\brief Marker for the contents of the file
There will be several different kinds of data produced by
LOFAR, see table below. Importantly, filetype signifies the kind of
LOFAR data that comprise the particular data file, and therefore,
will also signal the appropriate interface control document for
further reference, should users find that necessary.
*/
enum Type {
/*! LOFAR visibility file containing correlation UV information. */
uv,
/*! Standard LOFAR Image cube containing RA, Dec, frequency and
polarization information. */
sky,
/*! Rotation Measure Synthesis Cube with axes of RA, Dec, Faraday
Depth and polarization. */
rm,
/*! A Near Field sky Image with axes of position on the sky (x, y, z),
frequency time and polarization. */
nfi,
/*! Dynamic Spectra file with axes of time, frequency and polarization. */
dynspec,
/*! A Beam-Formed file contains time series data with axes of frequency
vs time. */
bf,
/*! TBB dump file is raw time-series: (1) with intensity as a function of
frequency, or (2) containing voltage vs time. */
tbb
};
/*!
\brief File extensions
Files generated by CASA/casacore will continue the currently existing
conventions using upper-case suffixes.
*/
enum Extension {
//! CASA/casacore MeasurementSet.
MS,
//! HDF5 file.
h5,
//! FITS file.
fits,
//! Logfile.
log,
//! A parset file.
parset,
//! Local sky model.
lsm,
//! CASA/casacore image file (PagedImage).
IM,
//! ParmDB file generated by BBS.
PD,
//! Dataset description file.
vds,
//! Dataset description file.
gds,
//! Configuration file (mostly local to station).
conf,
//! Raw Beam-Formed (non-Incoherentstokes) file written from the Blue Gene/P.
raw,
//! Raw Beam-Formed Incoherent-Stokes file written from Blue Gene/P.
incoherentstokes
};
private:
//! Prefix of the filename, preceeding the observation ID
std::string itsPrefix;
//! Unique identifier for the observation
std::string observationID_p;
//! Optional descriptors
std::string itsOptionalDescriptor;
//! Marker for the contents of the file
Filename::Type itsFiletype;
//! Extension of the file
Filename::Extension itsExtension;
//! Path to the location of the file
std::string itsPath;
public:
// === Construction =========================================================
//! Default constructor
Filename ();
//! Argumented constructor
Filename (std::string const &observationID,
Type const &filetype);
//! Argumented constructor
Filename (std::string const &observationID,
Type const &filetype,
Extension const &extension,
std::string const &path="");
//! Argumented constructor
Filename (std::string const &observationID,
std::string const &optionalDescription,
Type const &filetype,
Extension const &extension,
std::string const &path="");
//! Copy constructor
Filename (Filename const &other);
// === Destruction ==========================================================
//! Destructor
~Filename ();
// === Operators ============================================================
//! Overloading of the copy operator
Filename& operator= (Filename const &other);
// === Parameter access =====================================================
//! Get the prefix of the filename ("L" for a standard LOFAR dataset)
inline std::string prefix () const {
return itsPrefix;
}
//! Set the prefix of the filename
inline void setPrefix (std::string const &prefix) {
itsPrefix = prefix;
}
//! Get the unique observation ID
inline std::string observationID () const {
return observationID_p;
}
//! Set the unique observation ID
inline void setObservationID (std::string const &observationID) {
observationID_p = observationID;
}
//! Get optional descriptors
inline std::string optionalDescription () const {
return itsOptionalDescriptor;
}
//! Set optional descriptors
void setOptionalDescription (std::string const &optionalDescription);
//! Get the file type
inline Type filetype () const {
return itsFiletype;
}
//! Get the file type name
inline std::string filetypeName () const {
return getName(itsFiletype);
}
//! Set the file type
inline void setFiletype (Type const &filetype) {
itsFiletype = filetype;
}
//! Get the file extension type
inline Extension extension () const {
return itsExtension;
}
//! Get the file extension name
inline std::string extensionName () const {
return getName (itsExtension);
}
//! Set the file extension
inline void setExtension (Extension const &extension) {
itsExtension = extension;
}
//! Get the path to the file
inline std::string path () const {
return itsPath;
}
//! Set the path to the file
inline void setPath (std::string const &path) {
itsPath = path;
}
/*!
\brief Get the name of the class
\return className -- The name of the class, Filename.
*/
inline std::string className () const {
return "Filename";
}
//! Provide a summary of the internal status
inline void summary () {
summary (std::cout);
}
//! Provide a summary of the internal status
void summary (std::ostream &os);
// === Public methods =======================================================
//! Get the name of the file
std::string filename (bool const &fullpath=false);
// === Static methods =======================================================
//! Get map of file extension types and names.
static std::map<Filename::Extension,std::string> extensionMap ();
//! Get array/vector with the extension types
static std::vector<Filename::Extension> extensionTypes ();
//! Get array/vector with the extension names
static std::vector<std::string> extensionNames ();
//! Get the file extension as string
static std::string getName (Filename::Extension const &extension);
//! Get map of file-type types and names.
static std::map<Filename::Type,std::string> filetypeMap ();
//! Get array/vector with the file-type types
static std::vector<Filename::Type> filetypeTypes ();
//! Get array/vector with the file-type names
static std::vector<std::string> filetypeNames ();
//! Get the file type as string
static std::string getName (Filename::Type const &filetype);
private:
//! Initialize the internal parameters held by an object of this class
void init ();
//! Unconditional copying
void copy (Filename const &other);
//! Unconditional deletion
void destroy(void);
}; // Class Filename -- end
} // Namespace DAL -- end
#endif /* FILENAME_H */
|
ea18ec9e109f09f16707dde4446983b253c28b08 | bdbbc3bdbb90dad659ae54305c5d8615c314801a | /src/mm2_model.h | 4f1d55e9a6e990ed52bd633f86ffff3289aa4a34 | [] | no_license | Diatosta/mm2hook | 45d8c35f6eea99facd00e7d0c8db3dcf49f064f6 | bcb44806ac22c9bc4c0072911fd5c219c4320f0e | refs/heads/master | 2022-12-22T00:32:48.680888 | 2022-10-14T23:00:53 | 2022-10-14T23:00:53 | 59,736,193 | 0 | 0 | null | 2016-05-26T09:08:01 | 2016-05-26T09:08:01 | null | UTF-8 | C++ | false | false | 10,950 | h | mm2_model.h | #pragma once
#include "mm2_common.h"
#include "mm2_gfx.h"
#include "mm2_base.h"
namespace MM2
{
// Forward declarations
class modModel;
class modPackage;
class modShader;
class modStatic;
class asMeshSetForm;
// External declarations
extern class Stream;
extern class gfxPacket;
extern class gfxPacketList;
extern class gfxTexture;
class modShader {
public:
gfxTexture *Texture;
gfxMaterial *Material;
public:
static hook::Type<gfxMaterial *> sm_Materials;
static hook::Type<int> sm_StaticMaterialCount;
static AGE_API void BeginEnvMap(gfxTexture *tex, const Matrix34 &mtx)
{ return hook::StaticThunk<0x4A41B0>::Call<void>(tex, &mtx); }
static AGE_API void EndEnvMap(void) { return hook::StaticThunk<0x4A4420>::Call<void>(); }
static AGE_API modShader ** LoadShaderSet(Stream *stream, int *a2, int *a3, bool a4)
{ return hook::StaticThunk<0x4A3F60>::Call<modShader **>(stream, a2, a3, a4); }
static AGE_API gfxMaterial * AddStaticMaterial(const gfxMaterial &mtl)
{ return hook::StaticThunk<0x4A3930>::Call<gfxMaterial *>(&mtl); }
static AGE_API void KillAll(void) { return hook::StaticThunk<0x4A3B20>::Call<void>(); }
AGE_API void Load(Stream *stream, bool a2) { return hook::Thunk<0x4A3B30>::Call<void>(this, stream, a2); }
AGE_API void PreLoad(void) { return hook::Thunk<0x4A40C0>::Call<void>(this); }
};
class modPackage {
private:
modPackage *next;
Stream *stream;
char file[32];
uint magic;
uint fileSize;
public:
ANGEL_ALLOCATOR
AGE_API modPackage(void) {
scoped_vtable x(this);
hook::Thunk<0x4A46D0>::Call<void>(this);
}
AGE_API ~modPackage(void) {
scoped_vtable x(this);
hook::Thunk<0x4A46F0>::Call<void>(this);
}
AGE_API bool Open(LPCSTR dir, LPCSTR filename) { return hook::Thunk<0x4A4700>::Call<bool>(this, dir, filename); }
AGE_API void Close(void) { return hook::Thunk<0x4A4790>::Call<void>(this); }
AGE_API Stream * OpenFile(LPCSTR file) { return hook::Thunk<0x4A47B0>::Call<Stream *>(this, file); }
AGE_API void CloseFile(void) { return hook::Thunk<0x4A4800>::Call<void>(this); }
AGE_API void SkipTo(LPCSTR file) { return hook::Thunk<0x4A48D0>::Call<void>(this, file); }
AGE_API void Skip(void) { return hook::Thunk<0x4A4970>::Call<void>(this); }
};
class modStatic {
public:
uint8_t PacketCount;
uint8_t Flags;
uint16_t FvfFlags;
uint8_t *ShaderIndices;
gfxPacket **ppPackets;
gfxPacketList **ppPacketLists;
public:
AGE_API int GetTriCount(void) const { return hook::Thunk<0x4A4DE0>::Call<int>(this); }
AGE_API int GetAdjunctCount(void) const { return hook::Thunk<0x4A4DB0>::Call<int>(this); }
AGE_API void CopyFrom(const modStatic *mod) { return hook::Thunk<0x4A4D60>::Call<void>(this, mod); }
AGE_API modStatic * Clone(void) const { return hook::Thunk<0x4A4CA0>::Call<modStatic *>(this); }
AGE_API void Optimize(modShader *shader) { return hook::Thunk<0x4A49A0>::Call<void>(this, shader); }
AGE_API void Draw(modShader *shader) const { return hook::Thunk<0x4A4550>::Call<void>(this, shader); }
AGE_API void DrawNoAlpha(modShader *shader) const { return hook::Thunk<0x4A4A20>::Call<void>(this, shader); }
AGE_API void DrawEnvMapped(modShader *shader, gfxTexture *tex, float a3) const
{ return hook::Thunk<0x4A4A50>::Call<void>(this, shader, tex, a3); }
AGE_API void DrawOrthoMapped(modShader *shader, gfxTexture *tex, float a3, uint a4) const
{ return hook::Thunk<0x4A4B30>::Call<void>(this, shader, tex, a3, a4); }
AGE_API void DrawWithTexGenAndTexMatrix(void) const { return hook::Thunk<0x4A4C50>::Call<void>(this); }
static void BindLua(LuaState L) {
LuaBinding(L).beginClass<modStatic>("modStatic")
//functions
.addFunction("GetTriCount", &GetTriCount)
.addFunction("GetAdjunctCount", &GetAdjunctCount)
.endClass();
}
};
class modModel {
private:
byte numMaterials; // Shader + Packet count
byte numMatrices;
byte flags;
byte reserved; // unused (padding)
modShader *shaders;
gfxPacket **packets;
public:
static AGE_API bool ModelAlreadyLoaded(LPCSTR model) { return hook::StaticThunk<0x597A20>::Call<bool>(model); }
static AGE_API void DeleteModelHash(LPCSTR model) { return hook::StaticThunk<0x597A40>::Call<void>(model); }
AGE_API void GetBoundingBox(Vector3 &a1, Vector3 &a2, Matrix34 *a3) const
{ return hook::Thunk<0x597FB0>::Call<void>(this, &a1, &a2, a3); }
AGE_API int GetAdjunctCount(void) const { return hook::Thunk<0x598190>::Call<int>(this); }
AGE_API Vector3 & GetPosition(Vector3 &outPos, int a2) const
{ return hook::Thunk<0x598230>::Call<Vector3 &>(this, &outPos, a2); }
AGE_API void SetPosition(const Vector3 &pos, int a2) const
{ return hook::Thunk<0x598290>::Call<void>(this, &pos, a2); }
AGE_API void Draw(const Matrix44 *mtx, modShader *shader, uint a3) const
{ return hook::Thunk<0x597D00>::Call<void>(this, mtx, shader, a3); }
AGE_API void DrawPlain(const Matrix44 *mtx, uint a2) const
{ return hook::Thunk<0x597F00>::Call<void>(this, mtx, a2); }
AGE_API void DrawWithTexGenCoords(const Matrix44 *mtx, gfxTexture &tex, uint a3) const
{ return hook::Thunk<0x597EA0>::Call<void>(this, mtx, &tex, a3); }
AGE_API modShader * CopyShaders(void) const { return hook::Thunk<0x5981C0>::Call<modShader *>(this); }
};
class asMeshSetForm : public asNode {
private:
modStatic* ModStatic;
int VariantCount;
modShader** Shaders;
modShader* ChosenShaderSet;
int dword_28;
int Flags;
Matrix34 Matrix;
public:
inline Matrix34 getMatrix() {
return this->Matrix;
}
inline void setMatrix(Matrix34 a1) {
this->Matrix = a1;
}
inline void setVariant(int variant) {
if (this->Shaders == nullptr || variant >= this->VariantCount)
return;
this->ChosenShaderSet = Shaders[variant];
}
inline int getVariant() {
if (this->Shaders == nullptr)
return -1;
//compare shader sets to our current
for (int i = 0; i < this->VariantCount; i++) {
if (this->ChosenShaderSet == this->Shaders[i])
return i;
}
return -1;
}
inline int getVariantCount() {
return this->VariantCount;
}
inline Vector3 getPosition() {
return Vector3(this->Matrix.m30, this->Matrix.m31, this->Matrix.m32);
}
inline void setPosition(Vector3 position) {
this->Matrix.m30 = position.X;
this->Matrix.m31 = position.Y;
this->Matrix.m32 = position.Z;
}
public:
AGE_API asMeshSetForm(void) {
scoped_vtable x(this);
hook::Thunk<0x533600>::Call<void>(this);
}
AGE_API ~asMeshSetForm(void) {
scoped_vtable x(this);
hook::Thunk<0x5339D0>::Call<void>(this);
}
/*
asNode virtuals
*/
virtual AGE_API void Cull(void) { hook::Thunk<0x533810>::Call<void>(this); };
virtual AGE_API void Update(void) { hook::Thunk<0x5337F0>::Call<void>(this); };
//Last arg is never used, so I've set it to nullptr. It's a Vector3 reference, which was meant for offset I guess.
AGE_API void SetShape(LPCSTR modelName, LPCSTR dirName, bool useLVertex)
{ hook::Thunk<0x533660>::Call<void>(this, modelName, dirName, useLVertex, nullptr); }
AGE_API void SetZRead(bool a1) { hook::Thunk<0x533770>::Call<void>(this, a1); }
AGE_API void SetZWrite(bool a1) { hook::Thunk<0x533790>::Call<void>(this, a1); }
AGE_API void EnableLighting(bool a1) { hook::Thunk<0x5337B0>::Call<void>(this, a1); }
AGE_API void EnableAlpha(bool a1) { hook::Thunk<0x5337D0>::Call<void>(this, a1); }
static void BindLua(LuaState L) {
LuaBinding(L).beginExtendClass<asMeshSetForm, asNode>("asMeshSetForm")
.addConstructor(LUA_ARGS())
.addProperty("Matrix", &getMatrix, &setMatrix)
.addProperty("Position", &getPosition, &setPosition)
.addProperty("Variant", &getVariant, &setVariant)
.addPropertyReadOnly("NumVariants", &getVariantCount)
.addFunction("SetShape", &SetShape)
.addFunction("SetZRead", &SetZRead)
.addFunction("SetZWrite", &SetZWrite)
.addFunction("EnableLighting", &EnableLighting)
.addFunction("EnableAlpha", &EnableAlpha)
.endClass();
}
};
AGE_EXT modStatic * modGetStatic(LPCSTR file, float &a2, bool a3);
AGE_EXT modStatic * modGetStatic(LPCSTR file, void(*a2)(Vector3 &, void *), void *a3, bool a4);
AGE_EXT modModel * modGetModel(LPCSTR filename, uint a2, bool a3, bool a4);
AGE_EXT void modConvertModel(LPCSTR filename, LPCSTR newFilename, bool a3);
AGE_EXT bool GetPivot(Matrix34 &, LPCSTR basename, LPCSTR file);
template<>
void luaAddModule<module_model>(LuaState L) {
luaBind<modStatic>(L);
luaBind<asMeshSetForm>(L);
}
} |
7623da440496746f9016f298862607eec46159e7 | 67b12f8403572d8114b6baccc58d20661159a2ee | /src/neva/pal/public/pal_factory.cc | 270106f974f5f946a5649d9b12a596165845684b | [
"BSD-3-Clause"
] | permissive | Igalia/chromium68 | 08b257ce3b99bb827c2eaf701f61752cc31d6333 | c4d219c3e4b8936e1a94a77bc047b2a08dfd09b8 | refs/heads/integrate_upstream_ozone | 2021-06-30T18:23:01.034847 | 2018-12-06T08:12:07 | 2018-12-06T08:12:07 | 159,666,720 | 0 | 4 | null | 2018-12-18T14:17:14 | 2018-11-29T12:59:43 | null | UTF-8 | C++ | false | false | 1,201 | cc | pal_factory.cc | // Copyright (c) 2018 LG Electronics, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
#include "pal/public/pal_factory.h"
#include "base/command_line.h"
#include "pal/public/pal.h"
#include "remote_pal_ipc/remote_pal_ipc.h"
namespace pal {
//static
Pal* GetInstance() {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
std::string process_type = command_line.GetSwitchValueASCII("type");
if(process_type == "") {
return Pal::GetPlatformInstance();
} else if (process_type == "renderer") {
return RemotePalIPC::GetRemoteInstance();
} else {
return nullptr;
}
}
} // namespace pal
|
e7667626e0f5899c1c97e9a6c5f9fd8b8483aba4 | e1951b7f7a739b96e961797f8849e58dcb41f00d | /test/coordinates/array_coordinates.hpp | c8016c1bf7609795bde0fec68fc8eb993659af64 | [
"MIT"
] | permissive | jonathanpoelen/falcon | fcf2a92441bb2a7fc0c025ff25a197d24611da71 | 5b60a39787eedf15b801d83384193a05efd41a89 | refs/heads/master | 2021-01-17T10:21:17.492484 | 2016-03-27T23:28:50 | 2016-03-27T23:28:50 | 6,459,776 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 125 | hpp | array_coordinates.hpp | #ifndef _FALCON_TEST_COORDINATES_INDEX_HPP
#define _FALCON_TEST_COORDINATES_INDEX_HPP
void array_coordinates_test();
#endif |
4c2ed75edc50074462397f215566b25081a2551d | 8cce708c237041daa227063fefdd7965e0b81434 | /Krimp/trunk/croupier/afopt/Global.h | 50732227308e7ab2af9b981d0f7058be0d3e103b | [
"Apache-2.0"
] | permissive | arcchitjain/Mistle | 21842571646a181d3854a6341372a624826d67ff | 60d810046a6856860ac6dbb61f0b54a6d8b73e84 | refs/heads/master | 2023-03-12T21:18:40.961852 | 2021-03-01T09:44:51 | 2021-03-01T09:44:51 | 218,982,946 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,226 | h | Global.h | //
// Copyright (c) 2005-2012, Matthijs van Leeuwen, Jilles Vreeken, Koen Smets
// 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 Universiteit Utrecht, Universiteit Antwerpen, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _GLOBAL_H
#define _GLOBAL_H
#define VERBOSE 0
#define INT_BIT_LEN 32
#define SUMMARY_FILENAME "afopt.sum.txt"
//four parameters for choose proper structures for conditional database representation.
/*
#define MAX_BUCKET_SIZE 10
#define BUILD_TREE_ITEM_THRESHOLD 20
#define BUILD_TREE_MINSUP_THRESHOLD 0.05
#define BUILD_TREE_AVGSUP_THRESHOLD 0.10
*/
#define MAX_BUCKET_SIZE 10
//#define BUILD_TREE_ITEM_THRESHOLD 2000
//#define BUILD_TREE_MINSUP_THRESHOLD 2
//#define BUILD_TREE_AVGSUP_THRESHOLD 2
#define MAX(x,y) x>=y?x:y
#define MIN(x,y) x<=y?x:y
namespace Afopt {
//parameter settings
extern int gnmin_sup;
//some statistic information about the data
extern int gndb_size;
extern int gndb_ntrans;
extern int gnmax_trans_len;
extern int gnmax_item_id;
//pattern statistics
extern int gntotal_freqitems;
extern unsigned long long gntotal_patterns;
extern int gnmax_pattern_len;
extern int gntotal_singlepath;
extern int *gppat_counters;
//program running statistics
extern int gndepth;
extern int gntotal_call;
extern int gnfirst_level;
extern int gnfirst_level_depth;
extern int *gpheader_itemset;
typedef struct
{
int item;
int support;
int ntrans;
int order;
} ITEM_COUNTER;
typedef struct
{
int nmax_len;
int nmax_item_id;
int nmin_item_id;
int bitmap;
} MAP_NODE;
#define AFOPT_FLAG 0x0002
//header node of a transaction stored in array structure
typedef struct TRANS_HEAD_NODE
{
int length;
int frequency;
int nstart_pos;
int *ptransaction;
TRANS_HEAD_NODE *next; // the next node with the same item.
} TRANS_HEAD_NODE;
//arry node in single branches of AFOPT-tree
typedef struct
{
int order;
int support;
int ntrans;
} ARRAY_NODE;
//AFOPT-tree node.
//An AFOPT-node can either point to a single branch stored as arrays or point to a child AFOPT-node
typedef struct AFOPT_NODE
{
int frequency;
int ntrans;
short order;
short flag; // -1: pchild==NULL; 0: point to child node; >0: length of the single branch;
union
{
ARRAY_NODE *pitemlist;
AFOPT_NODE *pchild;
};
AFOPT_NODE* prightsibling;
} AFOPT_NODE;
//the information stored in a header node;
typedef struct
{
int item;
int nsupport;
int ntrans;
union
{
TRANS_HEAD_NODE *parray_conddb;
AFOPT_NODE *pafopt_conddb;
int *pbuckets;
};
short order;
short flag; //to indicate whether the conditional database is an AFOPT-tree
} HEADER_NODE;
typedef HEADER_NODE *HEADER_TABLE;
int comp_item_freq_asc(const void *e1, const void *e2);
int comp_int_asc(const void *e1, const void *e2);
void PrintSummary();
}
#endif
|
58d1368ad2ea59b465096c90adef8d1164f6cc0a | 42886436abf12b3551f9807c5ed4c2899485a1ba | /glow/src/camera.h | 1110421322a4f7304ad0481c1029a0fdd4aa221e | [] | no_license | tfiner/cpsc-599 | 39086cfd689bff19148fabfe1b7b299743b454e5 | b4a3a2dc003ab0f2455fb661a8969bb2d29ff34e | refs/heads/master | 2021-01-01T20:12:37.491849 | 2014-11-09T08:52:31 | 2014-11-09T08:52:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,947 | h | camera.h | // Tim Finer
// tfiner@csu.fullerton.edu
// CPSC-599
//
#pragma once
#include "geometry.h"
#include "color.h"
#include <vector>
namespace glow {
class Scene;
using ColorFilm = std::vector<Color>;
using Samples = std::vector<Vector3>;
// These are the constants during a render of an entire frame.
struct FrameParams {
float xBegin;
float yBegin;
float pixelSize;
float centerX;
float centerY;
Vector3 u, v, w;
};
// This returns the results of rendering a pixel.
struct RenderResults {
RenderResults(const Scene& s);
Color color;
float closest;
float hits;
};
class Camera {
public:
Camera(const Point3& pos, const Vector3& dir, const Vector3& up_);
virtual ~Camera();
void Render( Scene& s );
const Point3& Position() const { return position; }
const Vector3& Direction() const { return direction; }
protected:
Point3 position;
Vector3 direction;
Vector3 up;
// Roll angle in radians around direction.
float roll;
private:
// The difference between Orthogonal and Perspective cameras
// is boiled down to this call.
// xv and yv are normalized viewplane vectors that have already
// been scaled by the orthonormal basis u and v vectors.
// w is part of the orthonomal basis.
virtual Ray GetRay(const Vector3& xv, const Vector3& yv, const Vector3& w) const = 0;
// Roll the camera about the direction axis.
void Roll(Vector3&, Vector3&, Vector3&) const;
// Renders a single pixel.
RenderResults RenderPixel(const Scene& s,
const Samples& samples,
const FrameParams& fp,
int x, int y) const;
};
} // namespace glow {
|
932bedd0e0a02e42099d162f90b2b690991e6f44 | 26cda148730d0306dc31524db1aa2efdb1f92294 | /hw1/SimSearcher.cpp | a3a020987e8dc27a09c08245ddca84fdbb017c83 | [] | no_license | qq775193759/database | d3d2683d7181e36fddfd4f47a13ef60b9123a3a8 | eb6d53822f93f34a22056c11b569154ad5618196 | refs/heads/master | 2021-01-21T04:50:46.838263 | 2016-06-21T15:49:53 | 2016-06-21T15:49:53 | 54,774,759 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,442 | cpp | SimSearcher.cpp | #include "SimSearcher.h"
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
using namespace std;
int compare_gram_freq(vector<int> * a, vector<int> * b)
{
if(a == 0) return 1;
if(b == 0) return 0;
return a->size() < b->size();
}
SimSearcher::SimSearcher()
{
}
SimSearcher::~SimSearcher()
{
}
int SimSearcher::createIndex(const char *filename, unsigned q)
{
this->q = q;
readFile(filename);
for(int i=0;i<words.size();i++)
{
addWord(i);
addGram(i);
}
result_map = new vector<int>(words.size());
return SUCCESS;
}
void SimSearcher::readFile(const char *filename)
{
ifstream fin(filename);
string s;
while(getline(fin,s))
{
words.push_back(s);
}
fin.close();
}
void SimSearcher::addWord(int n)
{
string& a=words[n];
int a_size = a.size();
for(int i=0;i<=a.size()-q;i++)
{
string temp = a.substr(i,q);
//for(int j=MAX_THRESHOLD;j<=MAX_THRESHOLD;j++)
int j = MAX_THRESHOLD;
for(int k=-j;k<=j;k++)
{
vector<int> &temp_v = index[a_size+k][temp];
if(temp_v.empty() || temp_v.back() != n)
temp_v.push_back(n);
}
}
}
void SimSearcher::addGram(int n)
{
words_set.clear();
stringstream ss(words[n]);
string temp_gram;
while(ss>>temp_gram)
{
words_set.insert(temp_gram);
}
//words_set_vector.push_back(words_set);
int w_size = words_set.size();
for(unordered_set<string>::iterator it=words_set.begin(); it!=words_set.end();it++)
{
gram_index[w_size][*it].push_back(n);
}
}
int SimSearcher::searchJaccard(const char *query, double threshold, vector<pair<unsigned, double> > &result)
{
result.clear();
words_set.clear();
stringstream ss(query);
string temp_gram;
while(ss>>temp_gram)
{
words_set.insert(temp_gram);
}
int q_size = words_set.size();
int min_size = ceil((double)q_size*threshold);
int max_size = floor((double)q_size/threshold);
max_size = min(256, max_size);
pair<unsigned, double> temp_pair;
for(int i=min_size;i<=max_size;i++)
{
int co=0;
int temp_min_size = ceil((q_size + i)*threshold/(1+threshold));
int j_parameter_size = ceil(temp_min_size/J_PARAMETER);
temp_min_size = max(temp_min_size, min_size);
for(unordered_set<string>::iterator it=words_set.begin(); it!=words_set.end();it++)
{
if(gram_index[i].find(*it) != gram_index[i].end()) co++;
}
if(co < temp_min_size) continue;
j_candidate.clear();
j_more_candidate.clear();
dirty.clear();
co = 0;
for(unordered_set<string>::iterator it=words_set.begin(); it!=words_set.end();it++)
{
co++;
if(gram_index[i].count(*it) == 0) continue;
vector<int> &temp_v = gram_index[i][*it];
if(co <= (q_size - temp_min_size + j_parameter_size))
{
for(vector<int>::iterator iter = temp_v.begin(); iter != temp_v.end();iter++)
{
(*result_map)[*iter]++;
if((*result_map)[*iter] == 1) dirty.push_back(*iter);
if((*result_map)[*iter] == j_parameter_size) j_more_candidate.push_back(*iter);
if((*result_map)[*iter] == temp_min_size) j_candidate.push_back(*iter);
}
}
else
{
for(vector<int>::iterator iter = j_more_candidate.begin(); iter != j_more_candidate.end();iter++)
{
if(binary_search(temp_v.begin(), temp_v.end(), *iter))
{
(*result_map)[*iter]++;
if((*result_map)[*iter] == temp_min_size) j_candidate.push_back(*iter);
}
}
}
}
for(vector<int>::iterator it=j_candidate.begin(); it!=j_candidate.end();it++)
{
double distance = (*result_map)[*it];
distance = distance/(q_size + i - distance);
if(distance > threshold)
{
temp_pair.first = *it;
temp_pair.second = distance;
result.push_back(temp_pair);
}
}
for(vector<int>::iterator it=dirty.begin(); it!=dirty.end();it++)
{
(*result_map)[*it] = 0;
}
}
sort(result.begin(), result.end());
return SUCCESS;
}
int SimSearcher::searchED(const char *query, unsigned threshold, vector<pair<unsigned, unsigned> > &result)
{
result.clear();
len_list.clear();
candidate.clear();
string a(query);
int a_size = a.size();
int min_cross = a_size-q+1-q*threshold;
if(min_cross <= 0)
{
violence(a, threshold, result);
return SUCCESS;
}
//heap search
//make list
string temp;
pair<unsigned, unsigned> temp_pair;
unordered_map<string, vector<int> > &index_asize = index[a_size];
for(int i=0;i<=a.size()-q;i++)
{
temp = a.substr(i,q);
if(index_asize.count(temp))
len_list.push_back(&index_asize[temp]);
else
len_list.push_back(0);
}
sort(len_list.begin(), len_list.end(), compare_gram_freq);
for(int i=0;i<=q*threshold;i++)
{
if(len_list[i] == 0) continue;
for(vector<int>::iterator it = len_list[i]->begin();it != len_list[i]->end();it++)
{
candidate.insert(*it);
}
}
for(unordered_set<int>::iterator it = candidate.begin();it != candidate.end();it++)
{
if(checkED(a,words[*it],threshold))
{
temp_pair.first = *it;
temp_pair.second = ed_res;
result.push_back(temp_pair);
}
}
sort(result.begin(), result.end());
//violence
//violence(a, threshold, result);
return SUCCESS;
}
int SimSearcher::checkED(const string &a, const string &b, int threshold)
{
int a_size = a.size();
int b_size = b.size();
int delta_ab = a_size - b_size;
if(abs(delta_ab) > threshold) return 0;
int min_size = a_size;
int wide_size = 2*threshold + 1;
int ed[min_size][wide_size];
int a_equel_b;
for(int j=0; j<threshold; j++)
ed[0][j] = threshold - j;
for(int j=threshold; j<wide_size; j++)
ed[0][j] = min(j - threshold + 1 - (a[0] == b[j - threshold]), ed[0][j-1]+1);
for(int i=1; i<min_size; i++)
{
int bigger_than_threshold=0;
a_equel_b = (i>=threshold) && (a[i] == b[i - threshold]);
ed[i][0] = min(ed[i-1][0] + 1 - a_equel_b, ed[i-1][1]+1);
if(ed[i][0] + abs(delta_ab - threshold) > threshold) bigger_than_threshold++;
for(int j=1; j<wide_size-1; j++)
{
a_equel_b = ((i + j - threshold)>=0 && (i + j - threshold)<b_size) && (a[i] == b[i + j - threshold]);
ed[i][j] = min(ed[i-1][j] + 1 - a_equel_b, min(ed[i][j-1]+1, ed[i-1][j+1]+1));
if(ed[i][j] + abs(delta_ab - threshold + j) > threshold) bigger_than_threshold++;
}
a_equel_b = ((i + threshold) < b_size) && (a[i] == b[i + threshold]);
ed[i][wide_size-1] = min(ed[i-1][wide_size-1] + 1 - a_equel_b, ed[i][wide_size-2]+1);
if(ed[i][wide_size-1] + abs(delta_ab + threshold) > threshold) bigger_than_threshold++;
if(bigger_than_threshold == wide_size) return 0;
}
if(ed[a_size-1][b_size+threshold-a_size] > threshold) return 0;
ed_res = ed[a_size-1][b_size+threshold-a_size];
return 1;
}
int SimSearcher::checkED_naive(const string &a, const string &b, int threshold)
{
int ed[a.size() + 1][b.size() + 1];
for(int i=0;i<=b.size();i++)
ed[0][i]=i;
for(int i=0;i<=a.size();i++)
ed[i][0]=i;
for(int i=0;i<a.size();i++)
for(int j=0;j<b.size();j++)
ed[i+1][j+1] = min(ed[i][j] + 1 - (a[i] == b[j]), min(ed[i][j+1] + 1, ed[i+1][j] + 1));
ed_res = ed[a.size()][b.size()];
if(ed[a.size()][b.size()] > threshold) return 0;
return 1;
}
void SimSearcher::violence(const string &a, unsigned threshold, vector<pair<unsigned, unsigned> > &result)
{
//violence
pair<unsigned, unsigned> temp;
for(int i=0;i<words.size();i++)
{
int delta = abs((int)a.size() - (int)words[i].size());
if(delta > (int)threshold)continue;
if(checkED(a,words[i],threshold))
{
temp.first = i;
temp.second = ed_res;
result.push_back(temp);
}
}
}
double SimSearcher::checkJaccard(int n)
{
} |
a478f58ab11655e9a648bbd72e1563481a153539 | 798439d1d649ea0aafd2a2f4b04d3682bdade428 | /HW 1/Mandelbrot_serial.cpp | 55e091246b7e3e518a7fdcf7175ece4c0963f972 | [] | no_license | maxterk/sf2568 | baabec785356cedf644bf071164185d79f13fa7c | c6e7ce5f7b512842ae7e6e780e11f1f6526681f1 | refs/heads/master | 2021-09-14T01:00:04.758459 | 2018-05-06T21:49:14 | 2018-05-06T21:49:14 | 119,403,797 | 0 | 1 | null | 2018-02-04T20:01:06 | 2018-01-29T15:49:12 | C++ | UTF-8 | C++ | false | false | 2,033 | cpp | Mandelbrot_serial.cpp | #include <iostream>
#include <mpi.h>
#include <cmath>
using namespace std;
class Pixel
{
double re,im;
int pixelValue=-1;
public:
Pixel(double a=0, double b=0)
{
re=a;
im=b;
}
Pixel set_pixel(double a, double b){
re=a;
im=b;
}
int calcPixel(double b, int N)
{
if (pixelValue==-1) {
//This is z_0
double tempReal=0, tempImaginary=0,
nextReal,nextImaginary,currentAbsolute;
int iters=1;
double bb=pow(b,2);
do
{
iters++;
nextReal= re+pow(tempReal,2)-pow(tempImaginary, 2);
nextImaginary=im+2*tempReal*tempImaginary;
currentAbsolute=pow(nextReal,2)+pow(nextImaginary,2);
tempReal=nextReal;
tempImaginary=nextImaginary;
} while(currentAbsolute<bb && iters<N);
pixelValue=iters;
return pixelValue;
}
else
{
return pixelValue;
}
}
};
/*serial test */
int main(int argc, char *argv[]) {
double b=2; // size of picture
int w=2048;// number of pixels along the x-axis
int h=2048;//number of pixels along the y-axis
double dx= (double) 2*b/(w-1); // increment in width
double dy= (double) 2*b/(h-1); // increment in height
double dreal; // temporary variable
double dimag;
FILE *fp;
fp = fopen("color.txt","w");
int rc = MPI_Init(&argc,&argv);
int size,rank;
MPI_Status status;
int hello = MPI_Comm_size(MPI_COMM_WORLD, &size);
int hello2 = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
// very important to set the number of nodes to 1 when running this with mpirun!
Pixel * pixel_array;
pixel_array= new Pixel [w*h];
for(int x=0;x<w;x++){ // for each column in picture
dreal=(double)x*dx-b;
for(int y=0;y<h;y++ ){ // for each row picture
dimag=(double)y*dy-b;
pixel_array[x*h+y].set_pixel(dreal,dimag);
fprintf(fp, "%hhu", pixel_array[x*h+y].calcPixel(2.0,256)); // printing pixelvalue to file
fprintf(fp, "\n");
}
}
MPI_Finalize();
fclose(fp);
return 0;
}
|
dfb19eac6d9b425f79b40e2cca8e67d223b59400 | 859714cebe3661399f13c430d456bfc51f02ad3e | /c++/test_private_members.cc | 6d7236765fa9e382d3068876d18de760d8c0704e | [
"Unlicense"
] | permissive | ahamez/snippets | ffa9bae57b5f30f1ecc2a4a56269757e8865231f | d048f12697b8fe1629bb7c5a8796f2406fd8b07a | refs/heads/master | 2023-04-30T18:53:56.566367 | 2023-04-25T07:44:36 | 2023-04-25T07:46:59 | 146,336,349 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 338 | cc | test_private_members.cc | #include <iostream>
template <typename T> struct tester;
class foo
{
int x_;
template <typename T> friend struct tester;
};
template <>
struct tester<foo>
{
static int x(const foo& f)
{
return f.x_;
}
};
int main (int argc, char const *argv[])
{
auto f = foo{};
std::cout << tester<foo>::x(f) << '\n';
return 0;
} |
fddc8b03de35c35e569c891f933cf27963a3ba3d | 61c7bd39ef8718be81e88782f4013bc26ade0708 | /FollowActor.h | 8f659ab3d6e7ff9f49901bdd3872eb84c8e9d280 | [] | no_license | Mohamed-Abdelhafiz/Cross3DEngine | 2a1f402f96cdd32cdf99b88b6db7819b41b71df8 | 9101ce2500fb5a10c9795a7c036be8053dd692d6 | refs/heads/master | 2020-03-20T22:46:00.788282 | 2018-03-17T15:32:31 | 2018-03-17T15:32:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 354 | h | FollowActor.h | // Ahmed S. Tolba 2015-2018
#pragma once
#include "Actor.h"
class FollowActor : public Actor
{
public:
FollowActor(class Game* game);
void ActorInput(const uint8_t* keys) override;
void SetVisible(bool visible);
private:
class MoveComponent* mMoveComp;
class FollowCamera* mCameraComp;
class SkeletalMeshComponent* mMeshComp;
bool mMoving;
};
|
7a09a8213cf7e2d45f0e56d27c7bf913670235ac | a5e0c76e55204c3afcdf443c1b83076c4cd8d05a | /cowGymnastics.cpp | 780641254e80d889a5c0098a8b76597b86cd3cda | [] | no_license | nathanblan/competitive_programming | 4451f3f3983774a0af8685a8d7ca36edbe896a68 | 7d61f1eb2cfbebfeb64f867804ff408291514c5e | refs/heads/master | 2022-11-10T13:23:15.523527 | 2020-06-25T05:48:08 | 2020-06-25T05:48:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 948 | cpp | cowGymnastics.cpp | #include<iostream>
#include<vector>
#include<cassert>
#include<fstream>
using namespace std;
ifstream fin("x.in");
ofstream fout("x.out");
int mat[100][100];
int ranks[100][100];
int n, k;
bool compare(int a, int b){
for(int w=1;w<=k;w++){
if(ranks[a][w]<ranks[b][w]) {
continue;
}
else {
return false;
}
}
return true;
}
bool compare1(int a, int b){
for(int w=1;w<=k;w++){
if(ranks[a][w]>=ranks[b][w]) {
continue;
}
else {
return false;
}
}
return true;
}
int main(){
ifstream cin("gymnastics.in");
ofstream cout("gymnastics.out");
cin >> k>> n;
for(int i=1;i<=k;i++){
for(int j=1;j<=n;j++){
int x;
cin >> x;
ranks[x][i]=j;
}
}
int count=0;
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
if(compare(i, j)){
count++;
}
else if(compare1(i, j)){
count++;
}
}
}
cout << count << endl;
}
|
15e17849256dd238b6ce49ee11a85d7272878dfa | f302db83ff02f46a4037b066e4cad2d072b1cef6 | /src/xyz_subscriber.cpp | caff8dfa0a449c6ebdd4174f041afd9cf54bcae0 | [] | no_license | supermandugi/virtualFence | f201ea1ba47da7f37373e86828530258f31c785e | 2d07efb2899862cdac7c8e8ca34920953eccffc1 | refs/heads/master | 2020-07-05T21:57:59.454340 | 2016-12-16T04:54:49 | 2016-12-16T04:54:49 | 73,978,347 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,339 | cpp | xyz_subscriber.cpp | #include "ros/ros.h"
#include <cstdlib>
#include "gazebo_msgs/GetModelState.h"
#include <stdio.h>
#define PI 3.14159265358979
int main(int argc, char **argv)
{
ros::init(argc, argv, "xyz_subscriber");
ros::NodeHandle n;
ros::ServiceClient client = n.serviceClient<gazebo_msgs::GetModelState>("gazebo/get_model_state");
gazebo_msgs::GetModelState state;
geometry_msgs::Pose pose;
std::stringstream sts;
sts << "mobile_base";
state.request.model_name = sts.str();
double x, y, z, w;
double sqx, sqy, sqz, sqw;
double roll, pitch, yaw;
while(ros::ok())
{
if(client.call(state))
{
//ROS_INFO("succed: ");
x = state.response.pose.orientation.x;
y = state.response.pose.orientation.y;
z = state.response.pose.orientation.z;
w = state.response.pose.orientation.w;
//x = state.response.pose.position.x;
//y = state.response.pose.position.y;
//z = state.response.pose.position.z;
sqx = x * x;
sqy = y * y;
sqz = z * z;
sqw = w * w;
yaw = (double)(atan2(2.0 * (x*y + z*w), (sqx -sqy -sqz +sqw)));
yaw = yaw * 180 / PI ;
std::cout << "theta : " << yaw << std::endl;
}
else
{
ROS_INFO("failed");
}
}
//ros::service::call(gazebo/get_model_state '{model_name: mobile_base}');
return 0;
}
|
77c281efcf0e1dfc42c20b0e6ab6df3d70d45da3 | 0bf4e9718ac2e2845b2227d427862e957701071f | /tc/srm/528/ColorfulCookie.cpp | 6cd1bbfe046ab6430495f8e081ea8601012158df | [] | no_license | unjambonakap/prog_contest | adfd6552d396f4845132f3ad416f98d8a5c9efb8 | e538cf6a1686539afb1d06181252e9b3376e8023 | refs/heads/master | 2022-10-18T07:33:46.591777 | 2022-09-30T14:44:47 | 2022-09-30T15:00:33 | 145,024,455 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,961 | cpp | ColorfulCookie.cpp | // BEGIN CUT HERE
// END CUT HERE
#line 5 "ColorfulCookie.cpp"
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <climits>
//#include <ext/hash_map>
using namespace std;
using namespace __gnu_cxx;
#define REP(i,n) for(int i = 0; i < int(n); ++i)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define FE(i,t) for (typeof((t).begin())i=(t).begin();i!=(t).end();++i)
#define two(x) (1LL << (x))
#define ALL(a) (a).begin(), (a).end()
#define pb push_back
#define ST first
#define ND second
#define MP(x,y) make_pair(x, y)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
template<class T> void checkmin(T &a, T b){if (b<a)a=b;}
template<class T> void checkmax(T &a, T b){if (b>a)a=b;}
template<class T> void out(T t[], int n){REP(i, n)cout<<t[i]<<" "; cout<<endl;}
template<class T> void out(vector<T> t, int n=-1){for (int i=0; i<(n==-1?t.size():n); ++i) cout<<t[i]<<" "; cout<<endl;}
inline int count_bit(int n){return (n==0)?0:1+count_bit(n&(n-1));}
inline bool bit_set(int a, int b){return (a&two(b));}
inline int low_bit(int n){return (n^n-1)&n;}
inline int ctz(int n){return (n==0?-1:ctz(n>>1)+1);}
int toInt(string s){int a; istringstream(s)>>a; return a;}
string toStr(int a){ostringstream os; os<<a; return os.str();}
const int maxn=64;
const int inf=1e6;
int X, Y;
int n;
vi tb;
int M;
int dp[maxn][2222];
int go(int p, int a){
checkmax(a, 0);
if (p==n) return a?-inf:0;
int &r=dp[p][a];
if (r!=-1) return r;
r=-inf;
REP(i, tb[p]/X+1){
int j=(tb[p]-i*X)/Y;
if (i+j>M) checkmax(r, max(go(p+1, a-i)+M-i, go(p+1, a-(M-j))+j));
else checkmax(r, go(p+1, a-i)+j);
}
return r;
}
class ColorfulCookie {
public:
int getMaximum(vector <int> cookies, int P1, int P2) {
tb=cookies;
n=tb.size();
X=P1; Y=P2;
int H=2111, T=0;
memset(dp, -1, sizeof(dp));
while(T+1<H){
M=(T+H)/2;
memset(dp, -1, sizeof(dp));
if (go(0,M)>=M) T=M;
else H=M;
}
return T*(X+Y);
}
// BEGIN CUT HERE
public:
void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); }
private:
template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
void verify_case(int Case, const int &Expected, const int &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } }
//void test_case_0() { int Arr0[] = {1958, 1892, 1921, 1851, 1891, 1991, 1944, 1840, 1824, 1934, 1879, 1841, 1962, 1821, 1885, 1955, 1977, 1827, 1807, 1911, 1963, 1886, 1935, 1810, 1891, 1984, 1840, 1820, 1974, 1952, 1880, 1804, 1975, 1848, 1824, 1941, 1829, 1869, 1911, 1987, 1800, 1957, 1836, 1975, 1802, 1860, 1963, 1845, 1897, 1934}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 93; int Arg2 = 107; int Arg3 = 200; verify_case(0, Arg3, getMaximum(Arg0, Arg1, Arg2)); }
void test_case_0() { int Arr0[] = {1603, 416}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 126; int Arg2 = 179; int Arg3 = 200; verify_case(0, Arg3, getMaximum(Arg0, Arg1, Arg2)); }
//void test_case_0() { int Arr0[] = {100, 100}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 50; int Arg2 = 50; int Arg3 = 200; verify_case(0, Arg3, getMaximum(Arg0, Arg1, Arg2)); }
void test_case_1() { int Arr0[] = {50, 250, 50}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 50; int Arg2 = 100; int Arg3 = 300; verify_case(1, Arg3, getMaximum(Arg0, Arg1, Arg2)); }
void test_case_2() { int Arr0[] = {2000}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 100; int Arg2 = 200; int Arg3 = 0; verify_case(2, Arg3, getMaximum(Arg0, Arg1, Arg2)); }
void test_case_3() { int Arr0[] = {123, 456, 789, 555}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 58; int Arg2 = 158; int Arg3 = 1728; verify_case(3, Arg3, getMaximum(Arg0, Arg1, Arg2)); }
// END CUT HERE
};
// BEGIN CUT HERE
int main(){
ColorfulCookie ___test;
___test.run_test(0);
}
// END CUT HERE
|
28f5f578155a91e937c0ee00eca65669b66cad74 | 7167cef28f9c2848bb404d0def7e8a744354ced3 | /NativeDesigner/app/src/main/cpp/native-lib.cpp | fe0d19502b6e425199b8dc11375ccd21fdefa912 | [] | no_license | geogie/NDK | 3956aaf2382e48682ed0166b190bce7d62e1e5fc | 539f2a72c7344bd4315adc0baf4fc781940aa761 | refs/heads/master | 2020-09-10T01:32:17.530064 | 2019-11-14T05:15:05 | 2019-11-14T05:15:05 | 221,615,862 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,750 | cpp | native-lib.cpp | #include <jni.h>
#include <string>
#include <android/log.h>
// 日志定义
#define LOG_TAG "测试-"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
// 第三方so中的方法引入
extern "C" std::string getMyString();
extern "C" int add(int a,int b);
extern "C" int sub(int a,int b);
extern "C" int mul(int a,int b);
extern "C" int divi(int a,int b);
using namespace std;
// 自动生成部分
extern "C" JNIEXPORT jstring JNICALL
Java_cn_george_nativedesigner_MainActivity_stringFromJNI(
JNIEnv *env,
jobject /* this */) {
std::string hello = "Hello from C++";
return env->NewStringUTF(hello.c_str());
}
// 在本文件中调用第三方so中的代码
extern "C" JNIEXPORT jstring JNICALL
Java_cn_george_nativedesigner_MainActivity_customPrint(
JNIEnv *env,
jobject /* this */) {
std::string hello = "Hello from C++";
LOGD("测试-2-%s",getMyString().c_str());
return env->NewStringUTF(getMyString().c_str());
}
extern "C" JNIEXPORT int JNICALL
Java_cn_george_nativedesigner_MainActivity_add(
JNIEnv *env,
jobject /* this */,jint a,jint b) {
LOGD("加法");
return add(a,b);
}
extern "C" JNIEXPORT int JNICALL
Java_cn_george_nativedesigner_MainActivity_sub(
JNIEnv *env,
jobject /* this */,jint a,jint b) {
LOGD("减法");
return sub(a,b);
}
extern "C" JNIEXPORT int JNICALL
Java_cn_george_nativedesigner_MainActivity_mul(
JNIEnv *env,
jobject /* this */,jint a,jint b) {
LOGD("乘法");
return mul(a,b);
}
extern "C" JNIEXPORT int JNICALL
Java_cn_george_nativedesigner_MainActivity_divi(
JNIEnv *env,
jobject /* this */,jint a,jint b) {
LOGD("除法");
return divi(a,b);
}
|
00757ea318158856167220b59f0322319a7f36fd | db8dfd7ef00432842d187335ca6598341edc1922 | /apps/code/console_edit_cell.h | 5d350041156aabdd24d33bfa996c645fdac8ea74 | [] | no_license | EmilieNumworks/epsilon | a60746285ede5a603916e5dc9361a689926f0fbd | bb3baa7466f39f32b285f2d14b6dc1f28e22e7a5 | refs/heads/master | 2023-01-28T20:49:55.903580 | 2022-09-02T13:15:05 | 2022-09-02T13:15:05 | 102,631,554 | 1 | 0 | null | 2017-09-06T16:20:48 | 2017-09-06T16:20:48 | null | UTF-8 | C++ | false | false | 1,290 | h | console_edit_cell.h | #ifndef CODE_EDIT_CELL_H
#define CODE_EDIT_CELL_H
#include <escher/responder.h>
#include <escher/highlight_cell.h>
#include <escher/text_field.h>
#include <escher/text_field_delegate.h>
#include <escher/pointer_text_view.h>
namespace Code {
class ConsoleEditCell : public Escher::HighlightCell, public Escher::Responder {
public:
ConsoleEditCell(Escher::Responder * parentResponder = nullptr, Escher::InputEventHandlerDelegate * inputEventHandlerDelegate = nullptr, Escher::TextFieldDelegate * delegate = nullptr);
// View
int numberOfSubviews() const override;
Escher::View * subviewAtIndex(int index) override;
void layoutSubviews(bool force = false) override;
// Responder
void didBecomeFirstResponder() override;
/* HighlightCell */
Escher::Responder * responder() override {
return this;
}
// Edit cell
void setEditing(bool isEditing);
const char * text() const override { return m_textField.text(); }
void setText(const char * text);
bool insertText(const char * text);
void setPrompt(const char * prompt);
const char * promptText() const { return m_promptView.text(); }
void clearAndReduceSize();
const char * shiftCurrentTextAndClear();
private:
Escher::PointerTextView m_promptView;
Escher::TextField m_textField;
};
}
#endif
|
3ba2896199556728fdeeb09a8a2c384baee192a4 | 72aca11f973b7c337012475ad3111cd20a5dd589 | /luogu/04-Senior/P4025-Test.cpp | f6efdcc74a9bc85ba63458f952b13e8c8d4e674f | [] | no_license | aplqo/exercises | a4cee1acbef91e64aee2bd096cd7e0bb834926a4 | e28f14eaf89481c34bc1a27206e8cea2d2d94869 | refs/heads/master | 2021-06-25T06:34:09.535835 | 2021-04-08T13:52:39 | 2021-04-08T13:52:39 | 217,698,619 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,489 | cpp | P4025-Test.cpp | #include <algorithm>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <utility>
#include "debug_tools/tester.h"
using namespace std;
using namespace apdebug::tester;
using mon = pair<int, int>;
const int maxn = 100000;
enum class Return : int {
Accepted = 0,
Vedirect = 1,
Sequence = 2,
Output = 3
};
ifstream out;
mon m[maxn + 10];
mon* sel[maxn + 10];
unsigned int n;
int z;
template <class... Args>
void fail(Return ret, Args... args)
{
(cout << ... << args) << endl;
exit(static_cast<int>(ret));
}
bool TestVedi(const char* fans)
{
ifstream ans(fans);
string av, ov;
ans >> av;
ans.close();
ov = ReadOutput<string>(out);
if (av != ov)
fail(Return::Vedirect, "Wrong vedirect. Expected=", av, " Read=", ov, ".");
return av == "NIE";
}
void TestSel()
{
int c = z;
for (unsigned int i = 0; i < n; ++i) {
c -= sel[i]->first;
if (c <= 0) fail(Return::Sequence, "Wrong order.z<0 on ", i, ".");
}
}
void ReadDat(const char* c)
{
ifstream in(c);
in >> n >> z;
for_each(m, m + n, [&in](mon& i) -> void { in >> i.first >> i.second; });
}
void ReadOut()
{
for (unsigned int i = 0; i < n; ++i)
sel[i] = m + ReadOutput<unsigned int>(out);
}
int main(int argc, char* argv[])
{
out.open(argv[2]);
try {
if (TestVedi(argv[3])) return (int)Return::Accepted;
ReadDat(argv[1]);
ReadOut();
}
catch (exceptions::ReadFail) {
fail(Return::Output, "Output too short.");
}
return (int)Return::Accepted;
}
|
7908faabba448c183135cfca88e3baa7826ee8b5 | 8a3ac97df15fc2fad495e8c31a94475ef66f5bbe | /Contact Playground/Contact Playground/Reward.h | b46b2fb391dcb74a38e215f4d665a7e53556b36f | [] | no_license | jchen114/ContactSimulation | d2332123796d599735e66951c271b4fd8ce355e1 | f416d399aa36861d95730e354b35b769bfdea424 | refs/heads/master | 2021-01-11T08:32:53.004617 | 2017-11-13T22:02:01 | 2017-11-13T22:02:01 | 76,490,325 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 481 | h | Reward.h | #pragma once
#include "LinearMath\btVector3.h"
#include <set>
#include <memory>
class ColliderObject;
class CollideeObject;
class Reward
{
public:
Reward(std::unique_ptr<ColliderObject> &feelerObj, std::set<CollideeObject *> &collisionObjs, float lowerBound);
Reward(float reward);
Reward();
~Reward();
float GetReward();
float GetDistToCollidingObject();
private:
float m_reward;
float m_distance;
float RewardFunc(float query, float width, float lowerBound);
};
|
0366bbd08af7f369aea91a449e6977e8cd9efdb0 | f7edc75e2fa0ec8c9efc6bc4b03f69c027511524 | /C++/2018_practice/OJ3-9(图上的游走)/B2.cpp | cf753b5217a1bae5c431b77ce7de866fbd11a27b | [] | no_license | Ricky-Ting/coding-in-NJU | 12ce237e2d0b50e78081acab9b3ac635dcca9220 | 7e3d815be3a2c748c92b7e6011b9adebce9f83d1 | refs/heads/master | 2021-05-03T16:44:33.289070 | 2019-05-07T06:22:32 | 2019-05-07T06:22:32 | 120,440,565 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,053 | cpp | B2.cpp | #include<cstdio>
#include<algorithm>
#include<iostream>
#define NODE 410
using namespace std;
int n, m;
struct Node{
int head;
int d;
} node[NODE];
struct Edge{
int n;
int v;
bool c;
int oppos;
} edge[42000];
int P;
bool check[NODE];
//int number = 0;
int deep = 1;
bool dfs(int u){
//number++;
//if(number >= 1000)
// return false;
if(deep == n)
return true;
int now = node[u].head;
while(edge[now].n != -1){
int v = edge[now].v;
if(check[v]){
now = edge[now].n;
continue;
}
check[v] = true;
deep++;
if(dfs(v))
return true;
deep--;
check[v] = false;
now = edge[now].n;
}
return false;
}
int dep = 0;
bool get_path(int u, int fa){
if(dep == m)
return true;
int now = node[u].head;
while(edge[now].n != -1){
//cout << "# " << u << " " << now << endl;
/*
if(edge[now].v == fa){
edge[now].c = true;
}
*/
if(edge[now].c ){
now = edge[now].n;
//node[u].head = now;
continue;
}
else{
int v = edge[now].v;
edge[now].c = true;
edge[edge[now].oppos].c = true;
dep++;
if(get_path(v, u)){
//cout << dep << " ";
//dep--;
printf("%d %d\n", u, v);
return true;
}
edge[now].c = false;
edge[edge[now].oppos].c = false;
dep--;
now = edge[now].n;
}
}
return false;
}
int main(){
//number = 0;
P = 1;
scanf("%d %d", &n, &m);
for(int i(1);i <= n;i++){
node[i].head = i;
node[i].d = 0;
edge[i].n = -1;
check[i] = false;
P++;
}
int reduce = 0;
for(int i(0);i < m;i++){
int u, v;
scanf("%d %d", &u, &v);
edge[P].n = node[u].head;
edge[P].v = v;
edge[P].c = false;
edge[P].oppos = P+1;
node[u].head = P;
node[u].d++;
P++;
if(u == v){
node[v].d++;
edge[P-1].oppos-1;
reduce++;
continue;
}
swap(u, v);
edge[P].n = node[u].head;
edge[P].v = v;
edge[P].c = false;
edge[P].oppos = P-1;
node[u].head = P;
node[u].d++;
P++;
}
//m -= reduce;
int odd = 0;
//int odd1, odd2 = 1;
int only = 0;
for(int i(1);i <= n;i++){
if(node[i].d%2 == 1){
odd++;
//odd1 = odd2;
//odd2 = i;
}
if(node[i].d == 1){
only++;
}
}
bool is_meet_girl = false;
bool is_meet_boss = false;
if(only > 2){
is_meet_girl = true;
}
else if(only == 0){
check[1] = true;
if(!dfs(1))
is_meet_girl = true;
}
else{
int start = 0;
for(int i(1);i <= n;i++){
if(node[i].d == 1){
start = i;
break;
}
}
check[start] = true;
if(!dfs(start))
is_meet_girl = true;
}
if(odd != 0){
is_meet_boss = true;
}
if(is_meet_girl){
printf("Miss Shizue\n");
return 0;
}
if(is_meet_boss){
printf("Miss Leon\n");
return 0;
}
printf("Find Leon\n");
get_path(1, 0);
}
/*
5
10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
7
21
1 2
1 3
1 4
1 5
1 6
1 7
2 3
2 4
2 5
2 6
2 7
3 4
3 5
3 6
3 7
4 5
4 6
4 7
5 6
5 7
6 7
*/
|
306b19c831c7ca6c9197fdbbda560e0a9f386b36 | 861e49fdbda2da5428932ee180ee78f8dcd12f13 | /vaslib/src/weather.h | 956d9d6481b4a8f11d13f533a2237111c0bbe9f8 | [] | no_license | tegami-lpr/vasfmc | b45d08bd864a9f60b963f8b0d862927562f4f1ae | e317b69afae556a4e4c158fd687b6c41122515eb | refs/heads/master | 2023-07-06T19:09:20.219216 | 2021-08-12T13:47:32 | 2021-08-12T13:47:32 | 361,862,282 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,265 | h | weather.h | ///////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2005-2007 Alexander Wemmer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
///////////////////////////////////////////////////////////////////////////////
/*! \file weather.h
\author Alexander Wemmer, alex@wemmer.at
*/
#ifndef WEATHER_H
#define WEATHER_H
#include <QObject>
#include <QString>
#include <QNetworkAccessManager>
#include <QNetworkReply>
class Config;
/////////////////////////////////////////////////////////////////////////////
//! weather data access
class Weather : public QObject
{
Q_OBJECT
public:
Weather(const QString& weather_config_filename);
~Weather();
void requestMetar(const QString& airport);
void requestSTAF(const QString& airport);
void requestTAF(const QString& airport);
signals:
void signalGotWeather(const QString& airport, const QString& date_string, const QString& weather_string);
void signalError(const QString& error_string);
protected slots:
void slotCmdFin(int id, bool error);
void slotReadyRead();
void requestFinished(QNetworkReply *reply);
protected:
void setupDefaultConfig();
void setupFtp();
void requestWeather(const QString airport, const QString& directory);
protected:
Config* m_weather_config;
QNetworkAccessManager *m_netManager;
QString m_airport;
private:
//! Hidden copy-constructor
Weather(const Weather&);
//! Hidden assignment operator
const Weather& operator = (const Weather&);
};
#endif /* WEATHER_H */
// End of file
|
28ea49b00cdcc2ec0d1fba29a79afc38c5bd351c | 7867463739545b28a690ce6f258a15ef3721e700 | /AdventureOfLino/srcs/Scene/SubSceneItemMenu.h | 53efc90f15c573cdc5377264feb854ff651b3dfe | [] | no_license | horita-k/MyCreatedGame-AdventureOfLino- | 5dc62b3c76f48317463faa20c8a96272fbce50ff | 59b62f9189958e42fd146c70e56717c8f1e630af | refs/heads/master | 2021-06-02T11:40:32.362297 | 2020-10-05T09:18:51 | 2020-10-05T09:18:51 | 96,800,867 | 0 | 1 | null | 2020-10-05T09:16:18 | 2017-07-10T16:53:28 | C++ | SHIFT_JIS | C++ | false | false | 2,646 | h | SubSceneItemMenu.h | /* -*- mode: c++; coding: shift_jis-dos; tab-width: 4; -*- */
//---------------------------------------------------
/**
* アイテムメニュー選択
* @author SPATZ.
* @data 2015/07/13 23:38:22
*/
//---------------------------------------------------
#ifndef __ITEM_MENU_SELECT_H__
#define __ITEM_MENU_SELECT_H__
#include "AppLib/Graphic/ModelBase.h"
#include "SceneBase.h"
#include "SceneInfo.h"
#include "AppLib/Graphic/LayoutBase.h"
#include "AppLib/Graphic/ModelMap.h"
#include "AppLib/Graphic/LayoutNumber.h"
/*=====================================*
class
*=====================================*/
class SubSceneItemMenu : public SubSceneBase {
public:
static const BYTE kPLATE_LAYOUT_NUM = 3;
/* 定数 */
enum {
ePHASE_NONE = 0,
ePHASE_ITEM_ENTER,
ePHASE_ITEM_DOING,
ePHASE_ITEM_LEVE,
ePHASE_COSPLAY_ENTER,
ePHASE_COSPLAY_DOING,
ePHASE_COSPLAY_LEVE,
ePHASE_KEY_ENTER,
ePHASE_KEY_DOING,
ePHASE_KEY_LEVE,
ePHASE_FINISH,
ePHASE_MAX,
};
enum {
eMENU_KIND_ITEM = 0,
eMENU_KIND_COSPLAY,
eMENU_KIND_KEY,
eMENU_KIND_MAX,
};
/* 関数 */
SubSceneItemMenu();
~SubSceneItemMenu();
void Create(void) {}
void Create(BYTE defMenuKind, int lyt_num);
bool Update(void);
void Destroy(void);
void ChangePhase(BYTE setPhase);
eItemKind GetSelectWeapon(void) { return mSelectWeapon; }
void SetDefMenuKind(BYTE& rDefMenuKind);
private:
/*=====================================*
* phase
*=====================================*/
typedef void (SubSceneItemMenu::*PHASE_FUNC)(void);
static PHASE_FUNC mPhaseFunc[ePHASE_MAX];
void phaseNone(void);
void phaseItemEnter(void);
void phaseItemDoing(void);
void phaseItemLeave(void);
void phaseCosplayEnter(void);
void phaseCosplayDoing(void);
void phaseCosplayLeave(void);
void phaseKeyEnter(void);
void phaseKeyDoing(void);
void phaseKeyLeave(void);
void phaseFinish(void);
void updateSelect(void);
/* 変数 */
int mRingLytNum;
BYTE mItemNum;
int mNowItemIndex;
int mNextItemIndex;
int mRotCnt;
bool mIsRight;
float mIconDist;
BYTE mMenuKind;
BOOL mIsAlertMessage;
// アイテム選択時のアイテム数レイアウト
LayoutNumber* mpSelectItemNumLayoutList;
LayoutBase mInfoLayout;
LayoutBase mPlateLayout[kPLATE_LAYOUT_NUM];
LayoutBase mSquareLayout;
LayoutBase mMsgLayout;
eItemKind mSelectWeapon;
LayoutBase mHeartPieceLayout;
LayoutNumber mHeartPieceNumLayout;
};
#endif // __ITEM_MENU_SELECT_H__
/**** end of file ****/
|
f0df45073129ec091ca3ae8382267bdf8c81b370 | fc1fb34b183981f5285dd166fb3969a36c796e67 | /practical-02/function-2-1.cpp | 2499b8cab96b57a28a91661b2bd591f9bccf7e67 | [] | no_license | jinshanwang/OOP | 177deb490c2e523d3ebadb42bff38cf12fc13d7d | 424839a8bdda5ccd1ef5563bfa668b0d93376167 | refs/heads/master | 2021-04-06T09:37:58.115761 | 2018-03-13T04:39:13 | 2018-03-13T04:39:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 424 | cpp | function-2-1.cpp | #include <sstream>
#include <string>
#include <iostream>
using namespace std;
void print_as_binary(std::string decimal_number)
{
int decimal;
std::stringstream ss;
ss<< decimal_number;
ss>> decimal;
int i,j=0;
int a[100];
i = decimal;
while(i){
a[j] = i % 2;
i/=2;
j++;
}
for(i=j-1; i>=0; i--){
std::cout << a[i];
}
std::cout << std::endl;
}
|
4afb2b448d4fb9140e6a9ceaba08791fa2fb47c7 | 9d6e336e453166a96d4296fe8bca342bf3e6462a | /20200204/alarm_2884.cpp | 97ca6731e13394b9c0bec05bf74de61a696c7902 | [] | no_license | foreverlearn95/baekjoon | cddec62bbc322e7f5cb8161f8c666eb97c13f308 | b9e21edca59624699d44fbb37ef715d8cfff0cc5 | refs/heads/master | 2022-11-11T01:32:18.681262 | 2020-07-07T14:25:21 | 2020-07-07T14:25:21 | 277,650,508 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 212 | cpp | alarm_2884.cpp | //baekjoon 2884
#include <iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
if(b-45<0){
a--;
if(a<0)
a=23;
b=b+60;
}
printf("%d %d",a,b-45);
} |
e0a9a7e1fa2e07195fb94eeb00ef5f208d394b9b | dc65afa5cf0a1dad64d4749a30882953e0c63513 | /src/errors.h | 6ba9854be4fa8ced090fc4f6fe646450829624c2 | [
"Apache-2.0",
"BSD-3-Clause"
] | permissive | unbornchikken/arrayfire_js | a55d92be75ebf9a0c1251f20c3ac045a1bdad545 | 812e7690066ba7bd7e0e9370b6fff3c3d7e84083 | refs/heads/master | 2021-01-22T00:59:48.914819 | 2015-06-23T20:12:40 | 2015-06-23T20:12:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,341 | h | errors.h | /*
Copyright 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)
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 FIRE_ERRORS_H
#define FIRE_ERRORS_H
#include <nan.h>
#include <stdexcept>
#include <sstream>
struct fire_error : public std::runtime_error
{
fire_error(const char* what): runtime_error(what) {}
};
inline void _NanThrow(const char* what, const char* file, int line)
{
using namespace std;
stringstream s;
s << what << " in '" << file << "' at " << line << ".";
NanThrowError(s.str().c_str());
}
#define NAN_THROW(what) _NanThrow(what, __FILE__, __LINE__)
#define NAN_THROW_INVALID_ARGS() NAN_THROW("Invalid arguments.")
#define NAN_THROW_INVALID_NO_OF_ARGS() NAN_THROW("Invalid number of arguments.")
#define NAN_THROW_CB_EXPECTED() NAN_THROW("Callback argument expected.")
#define NAN_THROW_INVALID_DTYPE() NAN_THROW("Invalid dtype argument!")
#define FIRE_THROW(what) \
{\
std::stringstream s;\
s << what << " in '" << __FILE__ << "' at " << __LINE__ << ".";\
throw fire_error(s.str().c_str());\
}
#define FIRE_THROW_ARG_IS_NOT_AN_OBJ() FIRE_THROW("Argument is not an object.");
#define FIRE_THROW_ARG_IS_NOT_A_DIM4() FIRE_THROW("Argument is not a Dim4 object.");
#define FIRE_THROW_ARG_IS_NOT_A_CPLX() FIRE_THROW("Argument is not a Complex object.");
#define FIRE_THROW_ARG_IS_NOT_A_SEQ() FIRE_THROW("Argument is not a Seq object.");
#define FIRE_THROW_ARG_IS_NOT_AN_INDEX() FIRE_THROW("Argument is not an Index.");
#define FIRE_THROW_CB_EXPECTED() FIRE_THROW("Callback argument expected.");
#define FIRE_CATCH \
catch(fire_error &ex) { return NanThrowError(ex.what()); } \
catch(af::exception &ex) { return NAN_THROW(ex.what()); } \
catch(std::exception &ex) { return NAN_THROW(ex.what()); } \
catch(...) { return NAN_THROW("Unknown error!"); }
#endif // FIRE_ERRORS_H
|
542fe6a942b54f9e70bf2bd9cdca427b4964769b | 462c5a969430d97e245b2bc182fd73d55633ea03 | /c++/sort.cpp | c8aa90315fdc235a2b8ccdf135821facad90acb1 | [] | no_license | JH-R/learngit | be509145bf4313ec1f2deb7a57965af13623d987 | d1cee90f589971b889faf8ede4e91d7af2748a86 | refs/heads/master | 2022-06-18T06:02:39.806720 | 2020-05-15T09:54:57 | 2020-05-15T09:54:57 | 257,562,839 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 262 | cpp | sort.cpp | #include<bits/stdc++.h>
using namespace std;
bool comp(int a,int b);
int main()
{
int a[10];
for(int i=0;i<10;i++)
cin>>a[i];
sort(a+0,a+10,comp);
for(int i=0;i<10;i++)
cout<<a[i]<<" ";
cout<<endl;
return 0;
}
bool comp(int a,int b)
{
return a>b;
}
|
5e87d10d98c263b05d685f384606dfee5b6fefcd | a2d8b10890dfb1aa14d989d6e32856345acaf545 | /includes/eeros/hal/SBGEllipseA.hpp | 62ee6663a5090a8d0d2be856d13f0250d9bff6a9 | [
"Apache-2.0"
] | permissive | eeros-project/eeros-framework | 0a1e39788ee3a70c7f65062fb0e2f5bf9835d512 | edd6574260127924ecbc6c0d907e0162e240c40e | refs/heads/master | 2023-07-08T16:00:33.621592 | 2023-06-28T11:21:05 | 2023-06-28T11:21:05 | 17,247,637 | 16 | 15 | Apache-2.0 | 2023-06-27T09:52:11 | 2014-02-27T12:11:16 | C++ | UTF-8 | C++ | false | false | 8,524 | hpp | SBGEllipseA.hpp | #ifndef ORG_EEROS_HAL_SBGELLIPSEA_HPP_
#define ORG_EEROS_HAL_SBGELLIPSEA_HPP_
#include <eeros/logger/Logger.hpp>
#include <eeros/core/Thread.hpp>
#include <eeros/math/Matrix.hpp>
#include <sbgEComLib.h>
#include <atomic>
using namespace eeros::math;
using namespace eeros::logger;
namespace eeros {
namespace hal {
/**
* This class is part of the hardware abstraction layer.
* It is used by \ref eeros::control::SBGEllipseAInput class.
* Do not use it directly.
*
* @since v1.3
*/
class SBGEllipseA : public eeros::Thread {
public:
/**
* Constructs a thread to get SBGEllipseA (IMU) sensors data \n
*
* @param dev - string with device name
* @param priority - execution priority of thread to get sensors data
*/
explicit SBGEllipseA(std::string dev, int priority)
: Thread(priority), starting(true), running(false), enableFastData(false), log(Logger::getLogger()) {
auto errorCode = sbgInterfaceSerialCreate(&sbgInterface, dev.c_str(), 921600);
log.info() << "SbgEllipseA: interfaceSerialCreate = " << errorCode;
if (errorCode != SBG_NO_ERROR){
log.error() << "SbgEllipseA: Unable to create serial interface";
return;
}
errorCode = sbgEComInit(&comHandle, &sbgInterface);
if(errorCode != SBG_NO_ERROR){
log.error() << "SbgEllipseA: Unable to initialize the sbgECom library";
sbgInterfaceSerialDestroy(&sbgInterface);
}
errorCode = sbgEComCmdGetInfo(&comHandle, &deviceInfo);
if (errorCode == SBG_NO_ERROR)
log.info() << "SbgEllipseA: Device " << deviceInfo.serialNumber << " found";
disableUnusedLogs();
if (enableFastData){
log.info() << "SbgEllipseA: Enabling IMU fast data rate";
configureLogsHighRate(); // IMU data (1kHz) -> see "sbgEComCmdOutput.c"
} else {
log.info() << "SbgEllipseA: Enabling IMU 200 Hz data rate";
configureLogsLowRate(); // IMU data, euler angles and quaternions (200Hz) -> see "sbgEComCmdOutput.c"
}
errorCode = sbgEComCmdSettingsAction(&comHandle, SBG_ECOM_SAVE_SETTINGS);
errorCode = sbgEComSetReceiveLogCallback(&comHandle, onLogReceived, NULL); // -> see: sbgECom.c
starting = false;
}
/**
* Destructs a the thread.
*/
~SBGEllipseA() {
running = false;
join();
sbgEComClose(&comHandle);
sbgInterfaceSerialDestroy(&sbgInterface);
}
static Vector3 eulerData, accData, gyroData;
static Vector4 quatData;
static uint32_t timestampEuler, timestampQuat, timestampAcc, timestampGyro;
static uint32_t count, count0, countEuler, countQuat, countImu;
private:
std::atomic<bool> starting;
std::atomic<bool> running;
bool enableFastData;
Logger log;
SbgEComHandle comHandle;
SbgInterface sbgInterface;
int32 retValue;
SbgEComDeviceInfo deviceInfo;
/**
* Main run method. Gets sensor measurements \n
*/
virtual void run() {
while(starting);
running = true;
while (running) {
sbgEComHandle(&comHandle); // -> see: sbgECom.
usleep(1000);
}
}
/**
* Disable logs which are not used. No data transmission for these log types \n
*/
void disableUnusedLogs() {
sbgEComCmdOutputSetConf(&comHandle, SBG_ECOM_OUTPUT_PORT_A, SBG_ECOM_CLASS_LOG_ECOM_0, SBG_ECOM_LOG_MAG, SBG_ECOM_OUTPUT_MODE_DISABLED);
sbgEComCmdOutputSetConf(&comHandle, SBG_ECOM_OUTPUT_PORT_A, SBG_ECOM_CLASS_LOG_ECOM_0, SBG_ECOM_LOG_SHIP_MOTION, SBG_ECOM_OUTPUT_MODE_DISABLED);
sbgEComCmdOutputSetConf(&comHandle, SBG_ECOM_OUTPUT_PORT_A, SBG_ECOM_CLASS_LOG_ECOM_0, SBG_ECOM_LOG_STATUS, SBG_ECOM_OUTPUT_MODE_DISABLED);
sbgEComCmdOutputSetConf(&comHandle, SBG_ECOM_OUTPUT_PORT_A, SBG_ECOM_CLASS_LOG_ECOM_0, SBG_ECOM_LOG_UTC_TIME, SBG_ECOM_OUTPUT_MODE_DISABLED);
sbgEComCmdOutputSetConf(&comHandle, SBG_ECOM_OUTPUT_PORT_A, SBG_ECOM_CLASS_LOG_ECOM_0, SBG_ECOM_LOG_IMU_DATA, SBG_ECOM_OUTPUT_MODE_DISABLED);
sbgEComCmdOutputSetConf(&comHandle, SBG_ECOM_OUTPUT_PORT_A, SBG_ECOM_CLASS_LOG_ECOM_0, SBG_ECOM_LOG_EKF_EULER, SBG_ECOM_OUTPUT_MODE_DISABLED);
sbgEComCmdOutputSetConf(&comHandle, SBG_ECOM_OUTPUT_PORT_A, SBG_ECOM_CLASS_LOG_ECOM_0, SBG_ECOM_LOG_EKF_QUAT, SBG_ECOM_OUTPUT_MODE_DISABLED);
}
/**
* Configures log types for high rate data acquisition
*/
void configureLogsHighRate(){
auto errorCode = sbgEComCmdOutputSetConf(&comHandle, SBG_ECOM_OUTPUT_PORT_A, SBG_ECOM_CLASS_LOG_ECOM_1, SBG_ECOM_LOG_FAST_IMU_DATA, SBG_ECOM_OUTPUT_MODE_HIGH_FREQ_LOOP);
if(errorCode != SBG_NO_ERROR) log.error() << "SbgEllipseA: Unable to configure output log SBG_ECOM_LOG_FAST_IMU_DATA";
else log.info() << "SbgEllipseA: configured output log SBG_ECOM_LOG_FAST_IMU_DATA";
}
/**
* Configures log types for slow rate data acquisition
*/
void configureLogsLowRate() {
auto errorCode = sbgEComCmdOutputSetConf(&comHandle, SBG_ECOM_OUTPUT_PORT_A, SBG_ECOM_CLASS_LOG_ECOM_0, SBG_ECOM_LOG_IMU_DATA,
SBG_ECOM_OUTPUT_MODE_MAIN_LOOP);
if(errorCode != SBG_NO_ERROR) log.error() << "SbgEllipseA: Unable to configure output log SBG_ECOM_LOG_IMU_DATA";
else log.info() << "SbgEllipseA: configured output log SBG_ECOM_LOG_IMU_DATA";
errorCode = sbgEComCmdOutputSetConf(&comHandle, SBG_ECOM_OUTPUT_PORT_A, SBG_ECOM_CLASS_LOG_ECOM_0, SBG_ECOM_LOG_EKF_EULER,
SBG_ECOM_OUTPUT_MODE_MAIN_LOOP);
if(errorCode != SBG_NO_ERROR) log.error() << "SbgEllipseA: Unable to configure output log SBG_ECOM_LOG_EKF_EULER";
else log.info() << "SbgEllipseA: configured output log SBG_ECOM_LOG_EKF_EULER";
errorCode = sbgEComCmdOutputSetConf(&comHandle, SBG_ECOM_OUTPUT_PORT_A, SBG_ECOM_CLASS_LOG_ECOM_0, SBG_ECOM_LOG_EKF_QUAT,
SBG_ECOM_OUTPUT_MODE_MAIN_LOOP);
if(errorCode != SBG_NO_ERROR) log.error() << "SbgEllipseA: Unable to configure output log SBG_ECOM_LOG_EKF_QUAT";
else log.info() << "SbgEllipseA: configured output log SBG_ECOM_LOG_EKF_QUAT";
}
/**
* Callback definition called each time a new log is received.
* @param pHandle Valid handle on the sbgECom instance that has called this callback.
* @param msgClass Class of the message we have received
* @param msg Message ID of the log received.
* @param pLogData Contains the received log data as an union.
* @param pUserArg Optional user supplied argument.
* @return SBG_NO_ERROR if the received log has been used successfully.
*/
static SbgErrorCode onLogReceived(SbgEComHandle *pHandle, SbgEComClass msgClass, SbgEComMsgId msg, const SbgBinaryLogData *pLogData, void *pUserArg) {
count++;
switch (msg) {
case SBG_ECOM_LOG_EKF_EULER:
eulerData << pLogData->ekfEulerData.euler[0],
pLogData->ekfEulerData.euler[1],
pLogData->ekfEulerData.euler[2];
timestampEuler = pLogData->ekfEulerData.timeStamp;
countEuler++;
break;
case SBG_ECOM_LOG_EKF_QUAT:
quatData << pLogData->ekfQuatData.quaternion[0],
pLogData->ekfQuatData.quaternion[1],
pLogData->ekfQuatData.quaternion[2],
pLogData->ekfQuatData.quaternion[3];
timestampQuat = pLogData->ekfQuatData.timeStamp;
countQuat++;
break;
case SBG_ECOM_LOG_IMU_DATA:
accData << pLogData->imuData.accelerometers[0],
pLogData->imuData.accelerometers[1],
pLogData->imuData.accelerometers[2];
timestampAcc = pLogData->imuData.timeStamp;
gyroData << pLogData->imuData.gyroscopes[0],
pLogData->imuData.gyroscopes[1],
pLogData->imuData.gyroscopes[2];
timestampGyro = pLogData->imuData.timeStamp;
countImu++;
break;
case SBG_ECOM_LOG_FAST_IMU_DATA: // sbgEComBinaryLogImu.h
accData << pLogData->fastImuData.accelerometers[0],
pLogData->fastImuData.accelerometers[1],
pLogData->fastImuData.accelerometers[2];
timestampAcc = pLogData->fastImuData.timeStamp;
gyroData << pLogData->fastImuData.gyroscopes[0],
pLogData->fastImuData.gyroscopes[1],
pLogData->fastImuData.gyroscopes[2];
timestampGyro = pLogData->fastImuData.timeStamp;
break;
default:
count0++;
break;
}
return SBG_NO_ERROR;
}
};
}
}
#endif /* ORG_EEROS_HAL_SBGELLIPSEA_HPP_ */
|
96aff557eb2946ccffb1149e47aae0bd89c34264 | ceea3bfb7f90d48c142123fa93f0761ecfea35aa | /KFTools/KFDeploy/KFDeployDefine.h | ec26e52233b9440b852b1400e7f9bd7cac635ffd | [
"Apache-2.0"
] | permissive | lori227/KFrame | c0d56b065b511d5832247cf7283eee1f0898e23a | 6d5ee260654cc19307eb947f09bae055d3703d95 | refs/heads/master | 2021-06-21T17:07:17.628294 | 2021-05-21T02:19:08 | 2021-05-21T02:19:08 | 138,002,897 | 25 | 9 | null | null | null | null | UTF-8 | C++ | false | false | 1,135 | h | KFDeployDefine.h | #ifndef __KF_DEPLOY_DEFINE_H__
#define __KF_DEPLOY_DEFINE_H__
#include "KFrame.h"
#include "stdafx.h"
using namespace KFrame;
namespace KFDeploy
{
static const char* _deploy_file = "deploy.xml";
static const char* _log_name[] =
{
"All",
"Debug",
"Info",
"Warn",
"Error",
};
static uint32 _log_count = std::extent<decltype( _log_name )>::value;
static const char* _status_name[] =
{
"关闭",
"运行",
};
static uint32 _status_count = std::extent<decltype( _status_name )>::value;
static const char* _mode_name[] =
{
"Release",
"Debug",
};
static uint32 _mode_count = std::extent<decltype( _mode_name )>::value;
static const char* _net_name[] =
{
"请选择",
"内网",
"外网",
};
static uint32 _net_count = std::extent<decltype( _net_name )>::value;
}
static std::string& GetEditText( CEdit& edit )
{
CString strtext;
edit.GetWindowTextA( strtext );
static std::string _result;
_result = strtext.GetBuffer();
return _result;
}
#endif
|
af08590453b9eb96ba2b2f5822b710a9a25d3afd | d76c5b40e37a79a5d0009a5b0bf7f36d73612e12 | /FiboKernelLib/ke_scoped_unicode_string.cpp | b77b98cd27e299d6a0a0da60002fa781bc66b21c | [
"BSL-1.0"
] | permissive | pvthuyet/fibo-windows-kernel-lib | d2141a0d48a5a0c8aa35968f394b439d9e68fc05 | ae0387d71c880c43600ba7b30a487633ec52cd73 | refs/heads/master | 2022-12-27T19:16:59.668777 | 2020-10-03T09:39:17 | 2020-10-03T09:39:17 | 298,961,468 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,850 | cpp | ke_scoped_unicode_string.cpp | #include "ke_scoped_unicode_string.h"
#include "ke_memory.h"
#include "ke_strutils.h"
#include "ke_utility.h"
namespace fibo::kernel
{
ScopedUnicodeString::ScopedUnicodeString() :
ScopedUnicodeString(PagedPool, 0)
{
}
ScopedUnicodeString::ScopedUnicodeString(PCWCH src, size_t count, POOL_TYPE type, ULONG tag) :
ScopedUnicodeString(type, tag)
{
NT_ASSERT(src);
auto numOfBytes = (0 == count) ? (StrUtils::lengthInbytes(src) + sizeof(wchar_t)) : ((count + 1) * sizeof(wchar_t));
if (numOfBytes > 0)
{
auto status = allocate(numOfBytes);
if (!NT_SUCCESS(status)) {
ExRaiseStatus(STATUS_NO_MEMORY);
}
status = append(src);
if (!NT_SUCCESS(status)) {
ExRaiseStatus(status);
}
}
}
ScopedUnicodeString::ScopedUnicodeString(PCUNICODE_STRING src, POOL_TYPE type, ULONG tag) :
ScopedUnicodeString(type, tag)
{
NT_ASSERT(src);
auto status = allocate(src->MaximumLength + sizeof(wchar_t));
if (!NT_SUCCESS(status)) {
ExRaiseStatus(STATUS_NO_MEMORY);
}
RtlCopyUnicodeString(&mUniStr, src);
}
ScopedUnicodeString::ScopedUnicodeString(size_t numOfAllocBytes, PCUNICODE_STRING src, POOL_TYPE type, ULONG tag) :
ScopedUnicodeString(type, tag)
{
NT_ASSERT(numOfAllocBytes > 0);
auto status = allocate(numOfAllocBytes);
if (!NT_SUCCESS(status)) {
ExRaiseStatus(STATUS_NO_MEMORY);
}
RtlCopyUnicodeString(&mUniStr, src);
}
ScopedUnicodeString::ScopedUnicodeString(POOL_TYPE type, ULONG tag) :
mUniStr{ 0 },
mPoolType{ type },
mTag{ tag }
{
}
ScopedUnicodeString::~ScopedUnicodeString()
{
release();
}
ScopedUnicodeString::operator bool() const
{
return valid();
}
bool ScopedUnicodeString::valid() const
{
return 0 != mUniStr.MaximumLength;
}
USHORT ScopedUnicodeString::length() const
{
return mUniStr.Length / sizeof(wchar_t);
}
PCUNICODE_STRING ScopedUnicodeString::get() const
{
return &mUniStr;
}
PUNICODE_STRING ScopedUnicodeString::get()
{
return &mUniStr;
}
NTSTATUS ScopedUnicodeString::copy(PCUNICODE_STRING src)
{
if (!valid()) {
return STATUS_MEMORY_NOT_ALLOCATED;
}
RtlCopyUnicodeString(&mUniStr, src);
return STATUS_SUCCESS;
}
NTSTATUS ScopedUnicodeString::append(PCWSTR src)
{
return RtlAppendUnicodeToString(&mUniStr, src);
}
NTSTATUS ScopedUnicodeString::append(PCUNICODE_STRING src)
{
return RtlAppendUnicodeStringToString(&mUniStr, src);
}
NTSTATUS ScopedUnicodeString::allocate(size_t numOfBytes)
{
return allocate(numOfBytes, mPoolType, mTag);
}
NTSTATUS ScopedUnicodeString::allocate(size_t numOfBytes, POOL_TYPE type, ULONG tag)
{
Memory::freeUnicodeString(&mUniStr, mTag);
mPoolType = type;
mTag = tag;
return Memory::allocateUnicodeString(&mUniStr, numOfBytes, type, tag);
}
VOID ScopedUnicodeString::release()
{
Memory::freeUnicodeString(&mUniStr, mTag);
}
} |
2b4839b031c204f9cea0060cf2c9bd05abe09a46 | 0348744c233b0e94f623b8ee7b662aea4faaf0ea | /zoos.cpp | a14c7aad150743e433b40c2a73e26c582c152d9b | [] | no_license | Shashank-Varnekar/Basic-Programming-Hackerearth | bbf495884cac38d111deeefae92f32b3bed9d791 | 42a179f08be38878057107bb46698bddf51b7434 | refs/heads/master | 2023-04-28T20:28:59.760056 | 2021-05-17T15:31:16 | 2021-05-17T15:31:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 278 | cpp | zoos.cpp | #include <iostream>
#include <cstdio>
using namespace std;
int main()
{
char str[20];
scanf("%s",str);
int i = 0, z = 0, o = 0;
for(i=0; i<20; i++)
{
if(str[i] == 'z')
z++;
if(str[i] == 'o')
o++;
}
if(2*z==o)
printf("Yes");
else
printf("No");
return 0;
}
|
5ca48bac5d23e8b461444f3f643004aed9c5bcee | 8f81b0fea52234080b97df67a64a2c3391f2161a | /LeetCode/601-700/P654_Maximum_Binary_Tree.cpp | ca0c2acad514357cc13e0b744a593b5cc8a4bfa6 | [] | no_license | jJayyyyyyy/OJ | ce676b8645717848325a208c087502faf2cf7d88 | 6d2874fdf27fadb5cbc10a333e1ea85e88002eef | refs/heads/master | 2022-09-30T18:02:08.414754 | 2020-01-17T12:33:33 | 2022-09-29T02:24:05 | 129,335,712 | 44 | 16 | null | null | null | null | UTF-8 | C++ | false | false | 1,510 | cpp | P654_Maximum_Binary_Tree.cpp | /*
https://leetcode.com/problems/maximum-binary-tree/description/
输入一个数组,用数组中的最大值作为根结点,并将数组分为两个子数组,递归地进行这一过程,构造最大树
类似于 中序+前序/后序 造树
同类题目 P654
*/
#include <iostream>
#include <vector>
using namespace std;
static int x=[](){
std::ios::sync_with_stdio(false);
cin.tie(NULL);
return 0;
}();
// 思路类似选择排序, 时间复杂度 O(n^2)
class Solution{
public:
TreeNode * constructMaximumBinaryTree(vector<int> & nums){
return makeTree(nums, 0, nums.size()-1);
}
TreeNode * makeTree( vector<int> & nums, int left, int right ){
if( left > right ){
return NULL;
}
// 遍历数组找出最大值
// 不是在 [0, len-1] 找最大值
// 而是在 [left, right] 找最大值
int maxIdx = left;
int maxVal = nums[maxIdx];
for( int i = left; i <= right; i++ ){
// 使用临时变量 tmpVal 减少一次访存
int tmpVal = nums[i];
if( tmpVal > maxVal ){
maxVal = tmpVal;
maxIdx = i;
}
}
// right = len-1
// [left, maxIdx-1], [maxIdx], [maxIdx+1, right];
TreeNode * root = new TreeNode(maxVal);
root->left = makeTree(nums, left, maxIdx-1);
root->right = makeTree(nums, maxIdx+1, right);
return root;
}
};
int main(){
vector<int> v;
v.push_back(3);
v.push_back(2);
v.push_back(1);
v.push_back(6);
v.push_back(0);
v.push_back(5);
Solution s;
TreeNode * root = s.constructMaximumBinaryTree(v);
return 0;
}
|
ba7fce13fb1465277c7c81a2fa522b8538315c2a | 3a2ee16a24aa136413d633ebd8163f7c0494d4dd | /smon_native/native/smon_native/include/smon/mon/win/win_util.h | 4687335ae53a86b3e3eb5b03ede316928df31869 | [] | no_license | yamoe/smon | 1bd0976d31843e19d268aed42ca4d887108587d9 | 429203e7444aa12bc3e2783b881b8d8382770d83 | refs/heads/master | 2021-08-15T04:39:54.550078 | 2017-11-17T10:41:24 | 2017-11-17T10:41:24 | 111,080,880 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 795 | h | win_util.h | #pragma once
class WinUtil {
public:
static std::vector<std::string> drives()
{
std::vector<std::string> drives;
DWORD len = ::GetLogicalDriveStringsA(0UL, nullptr);
if (len == 0) return drives;
std::string str(len, 0x00);
::GetLogicalDriveStringsA(len, &str[0]);
for (int i = 0; i < str.size() / 4; ++i) {
drives.push_back(std::string(1, str[i * 4])); // C
}
return drives;
}
static void disk_usage(const std::string& drive, uint64_t& total, uint64_t& use)
{
std::string disk_path = drive + ":\\"; // C:\\
ULARGE_INTEGER a = { 0, }, t = { 0, }, f = { 0, };
GetDiskFreeSpaceExA(disk_path.c_str(), &a, &t, &f);
total = static_cast<uint64_t>(t.QuadPart);
use = static_cast<uint64_t>(t.QuadPart - f.QuadPart);
}
}; |
b34775286d1a9897faf20be5ee5359efa07a639c | 647279d2a3f43217a1ae830f07301357b3a24b68 | /src/cpp/Statistics.h | b3bd9f5ffe5a6aa6ea660ae5b6b578757409cf2f | [
"Apache-2.0"
] | permissive | aflorio81/Amazon-MIT-RoutingChallenge | 7e16244a7cf920f713da97c3613172b849e2904b | cbacc7b62a41b81c3e4b9ffde0f8dea0f81d3f5a | refs/heads/main | 2023-08-18T10:53:24.337175 | 2021-10-06T15:14:30 | 2021-10-06T15:14:30 | 397,329,177 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 689 | h | Statistics.h | #ifndef statistics_h
#define statistics_h
#include <iostream>
#include <limits>
#include <vector>
class Statistics {
public:
template<typename T>
static void basicStats(const std::vector<T>& vals) {
// min, max and avg
T minn=std::numeric_limits<T>::max();
T maxn=0;
T sum=0;
for (T val : vals) {
minn=std::min(minn, val);
maxn=std::max(maxn, val);
sum+=val;
}
std::cout<<"min: "<<minn<<std::endl;
std::cout<<"max: "<<maxn<<std::endl;
std::cout<<"avg: "<<(1.0*sum)/vals.size()<<std::endl;
}
};
#endif
|
57741dd1b947c7859e03143e7f8e2d0c8346a1ea | e37d0e2adfceac661fbd844912d22c25d91f3cc0 | /CPP-Programming-Language/chapter21-classlevels/ex25.cpp | 1ed2c07d050bbbe930c7f118635c825dfe2fb955 | [] | no_license | mikechen66/CPP-Programming | 7638927918f59302264f40bbca4ffbfe17398ec6 | c49d6d197cad3735d60351434192938c95f8abe7 | refs/heads/main | 2023-07-11T20:27:12.236223 | 2021-08-26T08:50:37 | 2021-08-26T08:50:37 | 384,588,683 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,107 | cpp | ex25.cpp | #include <iostream>
#include <locale>
#include <sstream>
int main(int argc, char** argv) {
using namespace std;
locale loc;
if (argc > 1) {
// use "locale -a" to find valid locales for your system
// e.g.: en_US.utf8
// default is usually "C"
loc = locale(argv[1]);
}
string s;
tm t;
t.tm_year = 2012;
t.tm_mday = 31;
t.tm_mon = 1;
cout << "Enter a date (e.g. ";
const time_put<char>& tmput = use_facet<time_put<char> >(loc);
tmput.put(ostreambuf_iterator<char>(cout), cout, ' ', &t, 'x', 0);
cout << "): ";
const time_get<char>& tmget = use_facet<time_get<char> >(loc);
ios::iostate state;
tmget.get_date(istreambuf_iterator<char>(cin), istreambuf_iterator<char>(), cin, state, &t);
if (state != ios::goodbit)
cout << "error parsing date" << endl;
else {
cout << "You entered: ";
tmput.put(ostreambuf_iterator<char>(cout), cout, ' ', &t, 'x', 0);
cout << endl;
}
}
/* Output */
/*
$g++ -o main *.cpp
$main
Enter a date (e.g. 02/31/12): error parsing date
*/ |
3e4e7fe820b0f5fa1b5e40cd7c7aba4db9009a5f | 3c761ddfeadde07c39f033b12457fe490df6339f | /br_moneyhub4.0/Security/BankDrv/DriverFrame.cpp | 40a4a4fb11b090953dd0d427241a380f440a5081 | [] | no_license | 3660628/chtmoneyhub | d8fe22cef017d7a12b4c582667b6484af01032d2 | 7861d387a49edfe395379c1450df18cb1b8658f2 | refs/heads/master | 2021-01-02T09:20:08.263263 | 2012-01-11T08:32:20 | 2012-01-11T08:32:20 | 33,034,456 | 2 | 1 | null | null | null | null | GB18030 | C++ | false | false | 8,927 | cpp | DriverFrame.cpp | /**
*-----------------------------------------------------------*
* 版权所有: (c), 2010 - 2999, 北京融信恒通科技有限公司
* 文件名: DriverFrame.cpp
* 说明: 驱动框架。
* 版本号: 1.0.0
*
* 版本历史:
* 版本号 日期 作者 说明
* 1.0.0 2010.07.03 曹家鑫
*-----------------------------------------------------------*
*/
#include "ntddk.h"
#include "ServiceTable.h"
#include "MapViewOfSection.h"
#include "../common/DriverDefine.h"
#include "ProcessFilter.h"
#include "SecuModule.h"
#include "SecuHash.h"
#include "HardCode.h"
#include "FilterCache.h"
#include "utils/comm.h"
#include "writeFileForTest.h"
//////////////////////////////////////////////////////////////////////////
#define DEVICE_NAME L"\\Device\\MoneyHubPrt"
#define DOS_NAME L"\\DosDevices\\MoneyHubPrt"
//////////////////////////////////////////////////////////////////////////
extern LONG g_HookCounter;
ULONG g_tmpB=0; //add by bh
__int64 g_globalTime=0;
void DriverUnload(PDRIVER_OBJECT DriverObject);
//////////////////////////////////////////////////////////////////////////
NTSTATUS DispatchCreate(PDEVICE_OBJECT DriverObject, PIRP IRP)
{
IRP->IoStatus.Status = 0;
IRP->IoStatus.Information = 0;
IoCompleteRequest(IRP, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
NTSTATUS DispatchClose(PDEVICE_OBJECT DriverObject, PIRP IRP)
{
IRP->IoStatus.Status = 0;
IRP->IoStatus.Information = 0;
IoCompleteRequest(IRP, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
NTSTATUS DispatchDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP IRP)
{
KdPrint(("==>DriverDeviceControl\n"));
NTSTATUS ntStatus = STATUS_UNSUCCESSFUL;
ULONG tmpLen=0;
PIO_STACK_LOCATION pIoStackIrp = IoGetCurrentIrpStackLocation(IRP);
switch (pIoStackIrp->Parameters.DeviceIoControl.IoControlCode)
{
case IOCTL_SET_PROTECT_PID:
KdPrint(("IOCTL_SET_PROTECT_PID\n"));
{
unsigned char pUnPack[256];
int unPackLength;
unPackLength=DownloadUnPack((unsigned char *)IRP->AssociatedIrp.SystemBuffer,pIoStackIrp->Parameters.DeviceIoControl.InputBufferLength,pUnPack);
if (unPackLength>0)
{
PPID_INFO pInputBuffer = (PPID_INFO)pUnPack;
int iStringLength = unPackLength;
if(iStringLength != sizeof(PID_INFO)) // The PID should contain exactly 1 member.
break;
__int64 elapsedTime = __rdtsc() - pInputBuffer->currentTime;
KdPrint(("IOCTL_SET_PROTECT_PID elapsed time: %I64d.\n", elapsedTime));
if((elapsedTime > COMMUNICATE_TIME_LIMIT)||(elapsedTime <=COMMUNICATE_TIME_DOWN))
{
KdPrint(("IOCTL_SET_PROTECT_PID exceeds time limit.\n"));
} else {
// 加入进程 ID
AddProtectPID(pInputBuffer->PID[0]);
}
ntStatus = STATUS_SUCCESS;
}
}
break;
case IOCTL_GET_PROTECT_PIDS:
KdPrint(("IOCTL_GET_PROTECT_PIDS\n"));
if (IRP->MdlAddress)
{
PPID_INFO pUserBuffer = (PPID_INFO)MmGetSystemAddressForMdlSafe(IRP->MdlAddress, NormalPagePriority);
ULONG OutputLength = pIoStackIrp->Parameters.DeviceIoControl.OutputBufferLength;
ULONG PIDLength = OutputLength - sizeof(PID_INFO) + sizeof(UINT32);//1025*sizeof(unsigned int),last one for another
// add by bh
PPID_INFO tmpBuf=(PPID_INFO)ExAllocatePoolWithTag(PagedPool,OutputLength-sizeof(UINT32),'bnak');
if(!tmpBuf)
return ntStatus;
///judge safe
KdPrint(("entry check hook safe!\n"));
if(checkHookSafe())
{
KdPrint((" safe!\n"));
tmpBuf->count = GetPIDs(tmpBuf->PID, PIDLength / sizeof(UINT32));
tmpBuf->currentTime = __rdtsc();
ULONG bufLength=sizeof(PID_INFO)+tmpBuf->count*sizeof(UINT32);
tmpLen = UploadPack((PUCHAR)tmpBuf , bufLength , (PUCHAR)pUserBuffer);
}
else
{
KdPrint( (" unfalse\n"));
RtlZeroMemory(tmpBuf,OutputLength-sizeof(UINT32));
tmpLen=0;
}
///
//pUserBuffer->count = GetPIDs(pUserBuffer->PID, PIDLength / sizeof(UINT32));
//pUserBuffer->currentTime = __rdtsc();
ExFreePoolWithTag(tmpBuf,'bnak');
///// end
ntStatus = STATUS_SUCCESS;
}
break;
case IOCTL_SET_SECU_PATHS:
KdPrint(("IOCTL_SET_SECU_PATHS\n"));
{
/////////////////add by bh
if(!g_tmpB)
setStartTime();
////////////////end
/*PUCHAR pInputBuffer = (PUCHAR)IRP->AssociatedIrp.SystemBuffer;
int iStringLength = pIoStackIrp->Parameters.DeviceIoControl.InputBufferLength;
ClearSecurePaths();
ULONG index = 0;
while(index < iStringLength)
{
ULONG length = *(PULONG)((ULONG)pInputBuffer + index);
index += 4;
if(index + length >= iStringLength)
break;
AddSecurePath((WCHAR*)((ULONG)pInputBuffer + index), length);
index += length * 2 + 2;
}*/
ntStatus = STATUS_SUCCESS;
}
break;
case IOCTL_SET_SECU_MD5:
KdPrint(("IOCTL_SET_SECU_MD5\n"));
{
PUCHAR pInputBuffer;
int iStringLength = pIoStackIrp->Parameters.DeviceIoControl.InputBufferLength;
unsigned char * pUnPack=(UCHAR *)ExAllocatePoolWithTag(PagedPool,iStringLength,'knab');
int unPackLength;
unPackLength=DownloadUnPack((unsigned char *)IRP->AssociatedIrp.SystemBuffer,pIoStackIrp->Parameters.DeviceIoControl.InputBufferLength,pUnPack);
//add by bh
//iStringLength=*((ULONG*)pUnPack );
RtlCopyBytes((PVOID)&iStringLength,(PVOID)pUnPack,sizeof(ULONG) );
pInputBuffer=pUnPack+sizeof(ULONG);
//if(!g_globalTime)
//g_globalTime=*((__int64 *)(pInputBuffer+iStringLength) );
RtlCopyBytes((PVOID)&g_globalTime,(PVOID)(pInputBuffer+iStringLength),8 );
__int64 elapseTime=__rdtsc()-g_globalTime;
if( (elapseTime<COMMUNICATE_TIME_LIMIT) && (elapseTime>=COMMUNICATE_TIME_DOWN) )
{
KdPrint( ("entry elapse check! ") );
if (unPackLength>0)
{KdPrint( ("entry length check! ") );
ClearHash();
for(int i = 0; i <= iStringLength - HASH_SIZE; i += HASH_SIZE)
AddSecureHash(pInputBuffer + i);
ntStatus = STATUS_SUCCESS;
}
}
ExFreePoolWithTag(pUnPack,'knab');
//
}
break;
case IOCTL_SET_UP_UNLOAD:
KdPrint(("IOCTL_SET_UP_UNLOAD\n"));
DeviceObject->DriverObject->DriverUnload = DriverUnload;
ntStatus = STATUS_SUCCESS;
break;
}
IRP->IoStatus.Status = 0;
IRP->IoStatus.Information = tmpLen ;
IoCompleteRequest(IRP, IO_NO_INCREMENT);
KdPrint(("<==DriverDeviceControl\n"));
return ntStatus;
}
void DriverUnload(PDRIVER_OBJECT DriverObject)
{
DbgPrint("==> DrvUnload\n");
UNICODE_STRING DeviceName, DosDeviceName;
PDEVICE_OBJECT DeviceObject = NULL;
// Unhook NtMapViewOfSection
UnHookNtMapViewOfSection();
// 等待所有函数退出
while(g_HookCounter)
{
LARGE_INTEGER interval;
interval.QuadPart = -10 * 1000 * 1000;
KeDelayExecutionThread(KernelMode, FALSE, &interval);
}
// 取消进程回调
PsSetCreateProcessNotifyRoutine(OnProcessQuit, TRUE);
RtlInitUnicodeString(&DeviceName, DEVICE_NAME);
RtlInitUnicodeString(&DosDeviceName, DOS_NAME);
// 删除 Symbolic Link
if (STATUS_SUCCESS != IoDeleteSymbolicLink(&DosDeviceName)) {
KdPrint(("[E] Failed: IoDeleteSymbolicLink\n"));
}
// 删除 Device
::IoDeleteDevice(DriverObject->DeviceObject);
DbgPrint("<== DrvUnload\n");
}
BOOLEAN DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
DbgPrint("==> Driver Entry\n");
NTSTATUS status = STATUS_SUCCESS;
UNICODE_STRING DeviceName, DosDeviceName;
PDEVICE_OBJECT DeviceObject = NULL;
RtlInitUnicodeString(&DeviceName, DEVICE_NAME);
RtlInitUnicodeString(&DosDeviceName, DOS_NAME);
// 创建 Device Object
status = IoCreateDevice(DriverObject, 0, &DeviceName, FILE_DEVICE_UNKNOWN,
FILE_DEVICE_SECURE_OPEN, FALSE, &DeviceObject);
if(!NT_SUCCESS(status))
return STATUS_UNSUCCESSFUL;
// 创建 SymbolicLink
IoCreateSymbolicLink(&DosDeviceName, &DeviceName);
DriverObject->MajorFunction[IRP_MJ_CREATE] = DispatchCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = DispatchClose;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DispatchDeviceControl;
// 初始化硬编码操作,如果失败则拒绝加载驱动
if(InitHardCode() == false)
{
KdPrint(("System Version Unrecognized\n"));
return STATUS_UNSUCCESSFUL;
}
// 注册进程回调函数
PsSetCreateProcessNotifyRoutine(OnProcessQuit, FALSE);
// Hook NtMapViewOfSection
HookNtMapViewOfSection();
//DriverObject->DriverUnload = DriverUnload;
DriverObject->Flags |= DO_BUFFERED_IO;
DriverObject->Flags &= (~DO_DEVICE_INITIALIZING);
DbgPrint("<== Driver Entry\n");
return STATUS_SUCCESS;
} |
723cbe52eb2ee744a4758cdd43806161ff75ad5c | bf7d993e0286740d76b8472ce0b4954fb0f87927 | /Arduino/ESP_conf.ino | 85e3497a16328b12d4c1dccc98348cb0e24f20be | [] | no_license | Gezele14/Proyecto2-Arqui | a1215c88c1a9002b6009bbfed6d589c5217f6835 | ef0e713aadb6657d085a3a023531b4212be58b81 | refs/heads/master | 2022-12-12T19:59:44.507750 | 2019-11-19T05:08:13 | 2019-11-19T05:08:13 | 218,405,700 | 0 | 0 | null | 2022-12-06T14:55:42 | 2019-10-29T23:53:46 | JavaScript | UTF-8 | C++ | false | false | 3,783 | ino | ESP_conf.ino |
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
//Credenciales para la red
int contconecxion = 0;
const char *ssid = "Gerardoz";
const char *pass = "gera1234";
//Calculo de delay para la conexion con MQTT
unsigned long prevmillis = 0;
//Credenciales para la conexion con MQTT
char SERVER[50] = "soldier.cloudmqtt.com";
int SERVERPORT = 12885;
String USERNAME = "Mesa1";
char PASSWORD[50] = "Mesa1rest";
//Data del borker al que conectarse
char ESTADO[50];
char PLACA[50];
//Variables del dato que se enviara a CloudMQTT
char valueEstado[20];
String strtemp = "";
//Pins de estado
int pin1 = 4;
int pin2 = 5;
int val = 16;
//------------------------Conexion a Wifi--------------------------------
WiFiClient wifi;
PubSubClient client(wifi);
//----------------------------Callback-----------------------------------
void callback(char *topic, byte *payload, unsigned int lenght)
{
char PAYLOAD[5] = "";
Serial.print("Mensaje Recibido: ");
Serial.print(topic);
for (int i = 0; i < lenght; i++)
{
PAYLOAD[i] = (char)payload[i];
}
Serial.print(PAYLOAD);
}
//----------------------------Reconnect-----------------------------------
void reconnect()
{
uint8_t retries = 3;
//loop hasta conectarse
Serial.print("Intentando conectarse a MQTT");
while (!client.connected())
{
Serial.print(".");
String clientid = "ESP8266Client-";
//Crea un id de cliente al azar
clientid += String(random(0xffff), HEX);
//Attemp to connect
USERNAME.toCharArray(PLACA, 50);
if (client.connect("", PLACA, PASSWORD))
{
Serial.println("Conectado");
}
else
{
Serial.print("fallo, rc=");
Serial.print(client.state());
Serial.println("intenta nuevamente en 5segundos");
delay(5000);
}
retries--;
if (retries == 0)
{
while (1)
;
}
}
}
void setup()
{
//setup pins
pinMode(pin1, INPUT);
pinMode(pin2, INPUT);
pinMode(val, INPUT);
// put your setup code here, to run once:
Serial.begin(9600);
//conexion wifi
WiFi.begin(ssid, pass);
Serial.print("Conectando a wifi");
while (WiFi.status() != WL_CONNECTED and contconecxion < 50)
{
++contconecxion;
delay(500);
Serial.print(".");
}
client.setServer(SERVER, SERVERPORT);
client.setCallback(callback);
String estado = USERNAME + "/" + "estado";
estado.toCharArray(ESTADO, 50);
}
void loop()
{
// put your main code here, to run repeatedly:
if (!(bool)client.connected())
{
reconnect();
}
client.loop();
unsigned long currentmillis = millis();
if (currentmillis - prevmillis >= 1000)
{
prevmillis = currentmillis;
if(digitalRead(pin1) == LOW && digitalRead(pin2) == LOW && digitalRead(val) == HIGH){
strtemp = "Azul";
strtemp.toCharArray(valueEstado, 20);
client.publish(ESTADO, valueEstado);
}else if(digitalRead(pin1) == LOW && digitalRead(pin2) == HIGH && digitalRead(val) == HIGH){
strtemp = "Rojo";
strtemp.toCharArray(valueEstado, 20);
client.publish(ESTADO, valueEstado);
}else if(digitalRead(pin1) == HIGH && digitalRead(pin2) == LOW && digitalRead(val) == HIGH){
strtemp = "Verde";
strtemp.toCharArray(valueEstado, 20);
client.publish(ESTADO, valueEstado);
}else if(digitalRead(pin1) == HIGH && digitalRead(pin2) == HIGH && digitalRead(val) == HIGH){
strtemp = "Vacio";
strtemp.toCharArray(valueEstado, 20);
client.publish(ESTADO, valueEstado);
}
}
}
|
610a7f7a8914e79bce0c8f00c65899c4ce822118 | ac3f1fbbef5756519a9a858ec8852f43eaac5b65 | /xml_locations_map.h | 7f7f4d7ad67baaa88e7cf843a74fd95f276cfcb6 | [] | no_license | adir-ch/Lonely-planet | 3e6c3c427afd456d9a3bfa0a6e2b5be8c848f1f1 | b317f13d4cf57b4b661660cb67c432f45e4160c1 | refs/heads/master | 2016-09-05T10:52:19.096308 | 2014-04-09T06:22:27 | 2014-04-09T06:22:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 868 | h | xml_locations_map.h | #ifndef __XML_LOCATIONS_MAP_H_INCL__
#define __XML_LOCATIONS_MAP_H_INCL__
#include <pugixml.hpp>
#include "locations_map.h"
/**
* TODO: Add class description
*
* @author adir
*/
class XMLLocationsMap : public LocationsMap, pugi::xml_tree_walker {
public:
// Constructor
XMLLocationsMap();
// Destructor
virtual ~XMLLocationsMap();
virtual bool initLocationsMap(); // will init the location map
bool loadXMLLocationsMap(const std::string& XMLFileName);
virtual bool for_each(pugi::xml_node& node); // xml tree traversal
private:
pugi::xml_document m_locationsMapXml;
};
// Constructor implementation
inline XMLLocationsMap::XMLLocationsMap() : LocationsMap() {
}
// Destructor implementation
inline XMLLocationsMap::~XMLLocationsMap() {
}
#endif // __XML_LOCATIONS_MAP_H_INCL__
|
fcf366ce0d2c579197c00a0ff4122fb39e4a808e | 1da3e9574175754b9201f3a31714f5031c027778 | /LearnOpenGL/utility/Mesh.h | b01a2d8ddbe0a1ef05b7f3bd785cea9bd943b9d4 | [] | no_license | Floating-light/Games101 | df98d92d706dc7c0eda3d9f77d425d13f8e7ee39 | 9a878dcdcbf163a72c00eccb6d8f7ffe8b73dd60 | refs/heads/master | 2023-07-04T03:03:36.561018 | 2021-07-22T12:59:38 | 2021-07-22T12:59:38 | 257,591,290 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,105 | h | Mesh.h | #pragma once
#include "CoreType.h"
#include <string>
#include <vector>
#include <memory>
#include "Material.h"
#include "Shaders/Shader.h"
struct BVertex
{
Vector3D Position;
Vector3D Normal;
Vector2D TexCoords;
};
struct BTexture
{
unsigned int id;
std::string type;
std::string path; // store path of texture to compare with other textures
};
extern std::vector<BTexture> textures_loaded;
class Material;
class RMesh
{
public:
std::vector<BVertex> vertices;
std::vector<unsigned int> indices;
std::vector<BTexture> textures;
// constructor
RMesh(std::vector<BVertex> vertices, std::vector<unsigned int> indices,
std::vector<BTexture> textures, EShaderType shaderType = EShaderType::Default);
// Draw this mesh
/**
* Draw this mesh, Bind all textures to shader,
*/
void Draw(Shader& shader);
void Draw(std::shared_ptr<Material>& mat);
std::shared_ptr<Material> GetMaterial() { return MyMaterial; }
private:
// render data
unsigned int VAO, VBO, EBO;
std::shared_ptr<Material> MyMaterial;
/**
* Called in Constructor, Setup VAO, VBO, EBO
*/
void SetupMesh();
}; |
ac9d9f5ff64ede107fe75fd036edd9dd6127e66b | 61b90ba8c153c11ed3d1465a33c33e282ff3841c | /app/Intro.h | ebbb0c8e8d00fe93acfeca94bb2569e28d67f97a | [
"Apache-2.0"
] | permissive | Rexagon/cybr | a3784a80a6fda0aad7d3b66974a4c185a4006a8c | bcffe1192cf3d4bf25c4ff0b6324e5bcc024dfa5 | refs/heads/master | 2021-01-01T17:59:26.271628 | 2017-07-31T18:50:46 | 2017-07-31T18:50:46 | 74,701,506 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 354 | h | Intro.h | #pragma once
#include <memory>
#include "State.h"
#include <SFML/Graphics.hpp>
class Intro : public State
{
public:
Intro();
~Intro();
void init() override;
void close() override;
void update(const float dt) override;
void draw(const float dt) override;
private:
std::unique_ptr<sf::Sprite> m_logo;
float m_alpha;
}; |
bea3c0c5aeda7c478dab728d927d0173acba7a5d | 9f520bcbde8a70e14d5870fd9a88c0989a8fcd61 | /pitzDaily/397/pa | c2eb052451c160b4aed435340158cf0ebacfed93 | [] | no_license | asAmrita/adjoinShapOptimization | 6d47c89fb14d090941da706bd7c39004f515cfea | 079cbec87529be37f81cca3ea8b28c50b9ceb8c5 | refs/heads/master | 2020-08-06T21:32:45.429939 | 2019-10-06T09:58:20 | 2019-10-06T09:58:20 | 213,144,901 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 104,794 | pa | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "397";
object pa;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField nonuniform List<scalar>
6400
(
-0.125927189894
-0.125928643483
-0.125932704067
-0.125940517202
-0.125951859218
-0.125966624509
-0.125984868846
-0.126007314651
-0.126034264332
-0.126066106854
-0.126106254955
-0.126156598309
-0.126215375678
-0.126282769969
-0.126360182065
-0.126449287024
-0.126550993312
-0.126665237732
-0.126791212137
-0.126925982401
-0.127065741307
-0.127210925637
-0.127365893092
-0.127535668697
-0.127723869567
-0.12793076822
-0.128154227707
-0.128392813919
-0.128646797445
-0.128917241272
-0.129205148167
-0.12950978986
-0.1298269809
-0.130152465231
-0.130484885732
-0.130821679106
-0.131162649354
-0.131514396601
-0.131876340274
-0.132239469838
-0.1326051883
-0.132987554784
-0.133394542005
-0.133819210981
-0.134252806376
-0.134689958183
-0.135126567204
-0.135560076562
-0.135988256422
-0.136409395405
-0.136822674344
-0.137223584383
-0.137604408666
-0.137953538518
-0.138270818977
-0.138566179633
-0.13883603086
-0.139066671165
-0.139252476083
-0.139403126959
-0.13952471042
-0.139620054843
-0.1396863156
-0.139742906725
-0.139820539555
-0.139938861919
-0.140089163303
-0.140238765377
-0.140363585713
-0.140461748124
-0.140539478308
-0.140603731197
-0.140659019509
-0.140704842207
-0.14074296207
-0.140773964155
-0.140798122324
-0.14081321406
-0.140822472013
-0.140826309118
-0.125925085143
-0.125926622445
-0.125930244413
-0.125937884382
-0.125950105781
-0.125965736641
-0.125984244187
-0.126005699516
-0.126031514012
-0.126063301345
-0.126103201235
-0.126152748214
-0.126211581924
-0.126279470033
-0.126356916226
-0.126445008261
-0.126546138358
-0.126660693977
-0.126787519028
-0.126922833818
-0.127061207012
-0.12720471004
-0.127358989526
-0.127528348487
-0.127716567648
-0.127923865139
-0.12814726049
-0.128385996036
-0.128640465807
-0.128911233757
-0.129198776954
-0.129503369792
-0.129821169963
-0.130146361811
-0.130478742614
-0.130815548979
-0.131155905145
-0.131507796091
-0.131870493987
-0.132233514313
-0.132596440784
-0.132977689806
-0.133388439518
-0.133815849165
-0.134250497782
-0.134688867394
-0.135126616974
-0.135561609316
-0.135990977597
-0.136411034027
-0.136820920623
-0.137222083678
-0.137610910993
-0.137962945924
-0.138281880423
-0.138581994356
-0.138849042031
-0.13907425846
-0.139260137112
-0.139410431256
-0.139527627928
-0.139623702533
-0.139693918852
-0.139753486167
-0.139833080946
-0.139951889053
-0.140104130501
-0.140253196776
-0.140376527531
-0.140473755633
-0.14055070103
-0.1406144595
-0.14066957741
-0.140715302205
-0.140752168676
-0.140781365226
-0.140803081895
-0.140817089647
-0.140825729383
-0.140828558589
-0.12591919886
-0.125921743346
-0.125924893507
-0.12593185725
-0.125943650213
-0.125961169474
-0.125981351241
-0.126002038718
-0.126026312292
-0.126057160858
-0.126096445885
-0.126145376912
-0.126204012976
-0.126271990837
-0.126349151219
-0.126434637353
-0.1265337619
-0.126651578219
-0.126780305896
-0.126914633189
-0.127050028852
-0.127189154472
-0.127341864255
-0.127512502486
-0.127700745093
-0.127907118837
-0.128130824916
-0.128370363419
-0.128625384416
-0.128896494912
-0.129183946573
-0.129488545524
-0.129807652045
-0.130131627492
-0.130461862621
-0.130800230433
-0.131139813757
-0.131489444104
-0.131852426776
-0.132217542608
-0.132586171176
-0.132971060592
-0.133379216511
-0.133804500558
-0.134239090061
-0.134678147657
-0.135117816372
-0.135555146234
-0.135987239997
-0.136411318619
-0.136825619916
-0.137227764103
-0.137610980222
-0.137966524462
-0.138296553905
-0.138598530241
-0.138862135121
-0.139085571642
-0.139270949586
-0.139421399552
-0.139541740338
-0.139637688017
-0.139709765597
-0.139776681972
-0.139864857289
-0.139988523107
-0.140135316034
-0.140279091479
-0.140401853999
-0.140499227093
-0.14057615954
-0.14063906819
-0.140691032706
-0.140732963966
-0.140767196139
-0.140793814542
-0.140812492264
-0.140824442043
-0.140831662348
-0.140834144055
-0.125911075589
-0.125913605273
-0.125916064275
-0.125922416331
-0.125932686128
-0.125949891108
-0.125975761153
-0.125996338711
-0.126018622534
-0.126047878634
-0.126086199939
-0.126134577297
-0.126193044238
-0.12626031206
-0.126336817165
-0.126425000161
-0.126526685586
-0.126642312133
-0.126765605821
-0.126891710621
-0.127023211119
-0.127164106353
-0.127317772686
-0.127487852871
-0.127676022996
-0.127882615436
-0.12810686094
-0.12834714536
-0.128602943512
-0.128874381222
-0.129162506953
-0.129467309311
-0.129786364886
-0.130112817844
-0.130439499848
-0.130773229628
-0.131115799557
-0.131464234969
-0.131822517201
-0.132189574869
-0.132565037583
-0.132954989708
-0.133363932721
-0.133788909556
-0.134224156042
-0.134664832094
-0.13510699545
-0.135547401752
-0.135983074327
-0.136411212283
-0.136829230538
-0.137233715402
-0.137619264963
-0.137980388322
-0.138314697447
-0.138616950067
-0.138880301241
-0.13910337073
-0.139288604895
-0.139439903189
-0.139562358211
-0.139661363814
-0.139742810777
-0.139823554278
-0.139917530268
-0.140036593114
-0.140180860403
-0.140323038817
-0.140444817368
-0.140541263457
-0.140615487121
-0.140673077342
-0.140719313457
-0.140758696094
-0.140790955853
-0.140813672238
-0.140827880017
-0.140837605053
-0.140844063592
-0.14084666535
-0.125898448249
-0.125898725581
-0.125901756024
-0.125908154482
-0.125919387794
-0.125935124015
-0.125958237807
-0.125981184832
-0.126004893048
-0.126034295474
-0.126071768895
-0.126119656589
-0.126178052856
-0.126247939982
-0.126328510239
-0.126416707866
-0.12651408944
-0.126621108442
-0.126736393096
-0.126859607168
-0.126991069412
-0.127131822761
-0.127285411352
-0.127455461884
-0.127643541741
-0.127850327525
-0.128074849297
-0.128315972826
-0.128572652927
-0.128845113455
-0.129133467757
-0.129439981677
-0.129761907488
-0.130084119501
-0.130408597666
-0.130739354506
-0.131077042477
-0.131425349742
-0.131784996625
-0.132155132451
-0.132535922709
-0.13293057105
-0.133341725854
-0.133767837187
-0.134204687706
-0.134647820456
-0.135093257286
-0.135537579421
-0.135977718256
-0.13641074765
-0.136833607625
-0.137242515621
-0.137632696254
-0.137999277216
-0.138337638727
-0.138641562159
-0.138905751921
-0.139129639424
-0.139316222226
-0.13947013247
-0.139596983658
-0.13970306499
-0.13979709451
-0.139890498961
-0.139987188477
-0.140104825187
-0.140245907556
-0.140385362868
-0.140505127043
-0.140598444355
-0.140666664722
-0.140717533434
-0.140760950844
-0.140798965033
-0.140826544276
-0.140843504078
-0.140853778699
-0.140862144926
-0.140866472612
-0.140867537696
-0.125875017904
-0.125874725625
-0.12588008152
-0.12588648889
-0.125898547971
-0.125915107233
-0.125936380357
-0.125959579425
-0.125985249719
-0.126015476391
-0.12605167294
-0.126099317448
-0.126162064498
-0.126235943204
-0.126315430658
-0.126399626907
-0.126490548948
-0.12659111991
-0.126702423506
-0.126823266536
-0.126952224355
-0.127091681957
-0.127245075043
-0.127415249497
-0.127603419295
-0.127809744398
-0.128034846089
-0.128276605333
-0.128534648848
-0.128808167499
-0.129098381903
-0.129405107028
-0.129724589968
-0.130049513047
-0.130368519374
-0.130692231424
-0.131028074544
-0.13137738368
-0.131739352302
-0.132113057291
-0.132498659735
-0.132897954426
-0.133312409214
-0.133741002155
-0.134180533353
-0.134627023279
-0.13507657716
-0.135525707312
-0.135971293088
-0.13641030992
-0.136839451593
-0.137254751073
-0.137651471412
-0.138024320295
-0.138367395258
-0.138674398805
-0.138941272575
-0.139168293266
-0.139358873408
-0.139518056575
-0.13965182185
-0.139767448626
-0.139876182683
-0.139977148506
-0.140076931771
-0.140197262041
-0.140338116651
-0.140473167294
-0.140587046681
-0.140672570588
-0.140732614631
-0.14077975174
-0.140822599892
-0.140855453357
-0.140875438927
-0.140885702989
-0.140892250765
-0.140896144862
-0.140896626735
-0.140896493053
-0.12583929483
-0.125841793164
-0.125850980042
-0.12586053636
-0.125870214971
-0.125886666928
-0.125908989891
-0.125932632145
-0.125959605089
-0.125990696848
-0.126028685633
-0.126076964977
-0.126142901358
-0.126215711522
-0.126291847798
-0.126370651966
-0.126456858779
-0.126554920124
-0.126664013915
-0.126780318408
-0.126906008319
-0.127044417609
-0.127197214833
-0.127366725062
-0.127554685129
-0.127762336413
-0.127986075841
-0.128228732847
-0.128488334747
-0.128765461604
-0.129056678288
-0.129361550863
-0.129679829997
-0.129997804727
-0.130313774328
-0.130634657683
-0.130970064769
-0.131320877164
-0.131685532128
-0.132062911975
-0.132453107586
-0.132857153605
-0.133275749478
-0.133708002158
-0.134151317474
-0.134602146096
-0.135056761266
-0.135511723494
-0.135963935779
-0.136410337688
-0.136847470753
-0.137271139541
-0.137676249907
-0.138056821116
-0.138406283065
-0.13871871304
-0.138991151415
-0.139224519947
-0.139422318632
-0.139589296949
-0.139731878362
-0.139858881857
-0.139977529348
-0.140085209521
-0.140198365838
-0.14032208595
-0.140460695304
-0.140587200757
-0.140689929014
-0.140765365131
-0.140820413505
-0.140867533425
-0.140906326658
-0.140929686859
-0.140939835067
-0.140941899462
-0.140941867886
-0.140937975657
-0.140932496188
-0.140930121182
-0.125797528952
-0.125802659896
-0.125813253327
-0.125827257867
-0.125837564167
-0.12585446559
-0.125875754572
-0.125900125545
-0.125928829474
-0.125957973247
-0.125999395978
-0.126053157825
-0.126117071837
-0.126187076633
-0.126258412781
-0.126331971223
-0.126416401055
-0.126513625706
-0.126618316454
-0.126730038466
-0.126852670605
-0.126989501291
-0.127141429714
-0.127311009874
-0.127499276843
-0.127706465239
-0.127931679657
-0.128170801187
-0.128434410075
-0.128716777116
-0.129007133107
-0.129305833636
-0.129620361753
-0.129933355678
-0.130244778489
-0.13056662545
-0.130903323138
-0.131255813827
-0.131623141257
-0.132004241109
-0.132399017587
-0.132808033988
-0.133231495919
-0.133668454388
-0.134116638552
-0.134572847565
-0.13503358887
-0.135495580608
-0.135955831966
-0.136411296407
-0.136858389305
-0.137292608279
-0.137708320327
-0.138098886209
-0.138457473919
-0.138778768304
-0.139060616365
-0.139304020684
-0.139511501838
-0.139686828562
-0.139837072688
-0.139972140511
-0.140099334209
-0.140222891141
-0.140347966442
-0.140479881781
-0.140612472095
-0.140727912521
-0.140818566917
-0.140886083768
-0.140939483479
-0.14098471683
-0.141013794573
-0.141024350074
-0.141021394094
-0.141011704397
-0.140998742628
-0.140983885764
-0.140970205629
-0.14096351781
-0.125752072239
-0.12575882463
-0.125769433721
-0.125780546732
-0.125794123212
-0.125815311755
-0.125835937414
-0.125860441646
-0.125892247842
-0.125923342288
-0.125961719072
-0.126019072873
-0.126083271528
-0.126149039241
-0.12621610624
-0.126288304412
-0.126370412663
-0.126464243498
-0.126564627621
-0.126672971503
-0.126792726875
-0.126926885404
-0.127076421009
-0.127244765942
-0.127436742054
-0.127641946141
-0.127868113207
-0.128111414378
-0.128372574928
-0.128652967904
-0.128945009764
-0.129246805269
-0.129547275252
-0.129852904255
-0.130164959835
-0.130488748477
-0.130827303255
-0.131181711021
-0.131551712928
-0.131936568866
-0.132336048297
-0.132750344501
-0.133179321825
-0.133621929324
-0.134076042689
-0.134538729568
-0.135006791554
-0.135477208628
-0.135947165312
-0.136413668539
-0.136873020754
-0.137320380078
-0.137749552044
-0.138153372761
-0.138525008294
-0.13885963637
-0.139155322125
-0.139411884584
-0.139629648046
-0.139811455907
-0.139966951406
-0.140109803353
-0.140249065781
-0.140387436091
-0.140524175252
-0.140668449994
-0.140803159509
-0.140902508067
-0.140980769914
-0.14104279268
-0.141095086598
-0.141133682737
-0.141149147143
-0.141143050254
-0.141121603044
-0.141092501586
-0.141059959757
-0.141029481596
-0.141005505123
-0.140992958952
-0.125702366146
-0.125710244781
-0.125722407993
-0.125732716246
-0.125747154001
-0.125768197881
-0.125788967304
-0.125812812083
-0.125843023823
-0.125881841632
-0.125921210003
-0.125977120184
-0.126040407154
-0.126102654092
-0.126165135805
-0.126237211282
-0.126319349136
-0.126408160259
-0.12650336077
-0.1266083817
-0.12672601114
-0.126857958583
-0.127005039409
-0.127169259867
-0.127362962933
-0.127572262082
-0.12779081927
-0.128037652578
-0.128298932945
-0.128580734928
-0.128871617674
-0.129168266787
-0.12946463896
-0.1297634041
-0.130074927616
-0.130400723472
-0.130741456509
-0.13109804767
-0.131470778732
-0.131859396863
-0.132263728388
-0.132683679561
-0.133118802298
-0.133567921282
-0.134028995239
-0.134499320782
-0.134976033426
-0.135456469195
-0.135938068552
-0.136417929185
-0.13689227446
-0.137355962376
-0.137802323208
-0.138223843877
-0.138613690422
-0.138967090673
-0.139280843954
-0.139551759654
-0.139777601607
-0.139963581582
-0.140125049931
-0.140279410623
-0.140433434871
-0.140585103421
-0.14073339623
-0.140879712704
-0.141012279262
-0.141117719686
-0.141184334024
-0.141241178515
-0.141290894734
-0.14132006591
-0.141319433716
-0.141291308643
-0.141242537471
-0.141183269313
-0.141123824429
-0.141071563623
-0.141033939638
-0.141014122527
-0.125646414961
-0.12565391838
-0.125666718167
-0.125679266025
-0.125697674956
-0.125714943904
-0.125735040082
-0.125759072886
-0.125783875648
-0.125825511842
-0.125870436482
-0.125925259337
-0.125987161899
-0.126048074514
-0.126108392399
-0.126178212155
-0.126259010406
-0.126343851714
-0.126434484198
-0.126535295617
-0.126650256189
-0.126780975702
-0.12692895083
-0.127089553447
-0.127275134259
-0.127491605177
-0.127712595248
-0.127954956493
-0.128214511915
-0.12848604349
-0.12878035142
-0.129075201025
-0.129366773749
-0.12966311596
-0.129974822524
-0.13030230013
-0.13064524465
-0.131004271034
-0.131379872398
-0.131772244034
-0.132181523443
-0.132607495308
-0.133049378786
-0.133505822523
-0.133974848913
-0.134454012119
-0.134940841664
-0.135433103348
-0.135928559102
-0.136424477658
-0.136917078422
-0.137401042318
-0.137869423749
-0.138314513021
-0.138729263241
-0.139107463839
-0.139441675775
-0.139723845463
-0.139955378114
-0.140148418999
-0.140322209028
-0.140493955164
-0.14066469436
-0.14082723359
-0.140978796451
-0.141117486351
-0.141242778271
-0.141357245677
-0.141428114098
-0.14148644708
-0.141534491652
-0.141556009541
-0.141537216069
-0.141478248242
-0.141387429162
-0.141283551998
-0.141187479459
-0.141104001449
-0.141047625536
-0.141018209343
-0.125582734599
-0.125588464248
-0.125597613141
-0.125614043634
-0.125637338097
-0.125653527149
-0.125673202171
-0.12569896944
-0.125721674379
-0.125759581839
-0.125808243203
-0.125862993729
-0.125922843937
-0.12598306457
-0.126045366569
-0.12611353058
-0.12619071254
-0.126271306167
-0.126357987722
-0.126454339623
-0.126564311248
-0.126690854023
-0.126842412026
-0.127008196453
-0.127184933178
-0.127396859896
-0.127621501401
-0.127856026769
-0.12812063195
-0.128392603946
-0.128675395919
-0.128962242139
-0.129251194031
-0.12955039653
-0.129863667629
-0.130192773354
-0.130537953579
-0.130899676891
-0.131278452394
-0.131674651533
-0.132088863296
-0.132521121672
-0.132970360574
-0.133434895621
-0.133912805666
-0.13440200415
-0.134900518226
-0.135406598655
-0.135918410337
-0.136433493469
-0.136948213275
-0.137457290915
-0.137953895971
-0.138430372738
-0.138878522146
-0.139287213672
-0.139638731351
-0.139925928974
-0.140168115899
-0.140381625326
-0.140580308963
-0.140775251574
-0.140964322739
-0.141135068767
-0.141283323636
-0.141408082822
-0.141516583934
-0.141615686384
-0.141706571143
-0.141776103507
-0.141842672808
-0.141866102891
-0.141828660671
-0.14172402968
-0.141564128796
-0.141388924864
-0.141244545605
-0.141113098627
-0.141033756131
-0.140991833133
-0.125511296642
-0.125515329142
-0.125519389957
-0.125537763354
-0.125560341625
-0.125579504974
-0.125600291273
-0.125627795072
-0.1256528892
-0.125688306272
-0.125737098006
-0.125790826462
-0.125848035622
-0.125905054992
-0.125969697372
-0.126039946861
-0.126113743498
-0.126190219393
-0.126273314423
-0.12636583771
-0.126470282901
-0.126589431054
-0.126736988294
-0.126913683876
-0.127090818923
-0.127289130097
-0.127518389966
-0.127751963874
-0.128004417812
-0.128276367687
-0.128556043902
-0.128838142042
-0.12912391246
-0.129424531309
-0.129739988629
-0.130071183715
-0.130418732489
-0.130783241142
-0.131165578963
-0.131566080757
-0.131985347173
-0.132423923114
-0.132880893642
-0.133354214575
-0.133841867182
-0.134342235288
-0.134854007377
-0.135376026672
-0.135906919265
-0.136444668356
-0.136985977615
-0.137526032637
-0.138058818854
-0.138577030975
-0.139069340294
-0.139512036
-0.139870735856
-0.140155631012
-0.14042771957
-0.140691621461
-0.140930198603
-0.141148145094
-0.141357566326
-0.141536142674
-0.14166978581
-0.141757582599
-0.141826607415
-0.141895229438
-0.141978120698
-0.142065470825
-0.142192972992
-0.142255188303
-0.142202885469
-0.142033707411
-0.141766675157
-0.141478905481
-0.141288443075
-0.141073509563
-0.140976400769
-0.140917930497
-0.125432809989
-0.125437332884
-0.125443885286
-0.125455814027
-0.12547442408
-0.12549515074
-0.125517387212
-0.125544837786
-0.12557476446
-0.125609041095
-0.125657054261
-0.125709317507
-0.1257642112
-0.125818167641
-0.125880132045
-0.125952299748
-0.126025300716
-0.12609942164
-0.126179472225
-0.126268575599
-0.126368495256
-0.126480623571
-0.126620137928
-0.126799675848
-0.126984489216
-0.12717453173
-0.127400895368
-0.127637079851
-0.127879208218
-0.128143764894
-0.128415199666
-0.128692871225
-0.128981940028
-0.129284992923
-0.129602728858
-0.12993628194
-0.130286715543
-0.130654356053
-0.13104020408
-0.131445357339
-0.131870282155
-0.132315427848
-0.13278024871
-0.133262718519
-0.133760764579
-0.13427326323
-0.134799763723
-0.135339784279
-0.135892537929
-0.13645671157
-0.137029678534
-0.137607659207
-0.138186564857
-0.138760190282
-0.139310248385
-0.139789514144
-0.140137455837
-0.140410636358
-0.140768374893
-0.141200187379
-0.141521877209
-0.141737876651
-0.141966884965
-0.142147956333
-0.142236882284
-0.142289437554
-0.142373782465
-0.142453404645
-0.142526503
-0.142608276686
-0.143011816368
-0.143200468637
-0.143113880835
-0.142792672423
-0.142216722424
-0.141520328414
-0.141314087142
-0.140921790291
-0.140858803839
-0.140772014677
-0.125345508394
-0.125350539705
-0.125361686318
-0.125367534581
-0.125381866743
-0.125402349636
-0.125425419407
-0.125453725412
-0.125489450358
-0.125521731763
-0.125568076015
-0.125618810661
-0.125671905565
-0.125724395642
-0.12578363537
-0.125854521347
-0.125926268605
-0.125998706481
-0.126076137625
-0.126161757149
-0.126257673589
-0.126364800668
-0.126494009943
-0.12666654326
-0.126862717466
-0.127052068172
-0.127264389256
-0.127507647549
-0.127752052936
-0.127998530567
-0.128260180399
-0.128535117779
-0.12882517236
-0.12913036326
-0.129450667251
-0.129786996015
-0.130140389058
-0.130511769347
-0.130901770064
-0.131311616998
-0.131742542912
-0.132194834462
-0.132667780102
-0.133159447126
-0.133668025265
-0.134193204307
-0.134735501055
-0.135295252103
-0.135872353393
-0.136466631581
-0.137076738399
-0.137700714235
-0.138337441471
-0.138982965648
-0.139608050878
-0.140144698084
-0.140512874124
-0.140672935652
-0.141198233938
-0.141254537856
-0.14103906608
-0.140782441506
-0.14055727498
-0.140318031862
-0.140085992917
-0.139841572357
-0.139576294997
-0.139374183384
-0.139320905157
-0.139372535154
-0.139415822831
-0.139673769456
-0.139919596262
-0.139961441453
-0.140035361648
-0.140926567032
-0.141756292152
-0.140564624613
-0.140691673511
-0.140521865349
-0.125247701043
-0.125252134117
-0.125261642435
-0.125267858802
-0.125280073943
-0.125300406549
-0.125323167268
-0.125349968167
-0.125390361871
-0.125424755902
-0.125469427649
-0.125518977485
-0.125571020699
-0.125623295851
-0.125680603823
-0.125748603434
-0.125818059696
-0.125888677081
-0.125963502751
-0.126045548237
-0.126137078792
-0.126239803668
-0.126360897972
-0.126522609651
-0.126721808468
-0.126918581818
-0.127117338339
-0.127348435658
-0.127596372131
-0.127841393491
-0.128094193965
-0.128364398468
-0.128653762887
-0.128960433019
-0.129283163514
-0.129622163332
-0.129978840757
-0.130354074865
-0.130748879396
-0.131164111243
-0.13160130073
-0.13206119871
-0.132542813108
-0.133043658565
-0.13356212142
-0.134099451165
-0.134658013145
-0.13523864841
-0.135841247985
-0.136468156786
-0.137121485935
-0.137800577752
-0.138506585486
-0.139236717206
-0.139950201024
-0.1406991393
-0.1404899067
-0.140222050675
-0.140091094305
-0.140019170719
-0.139652753751
-0.138989780778
-0.138113649897
-0.137089113824
-0.135996169737
-0.134898729352
-0.133864931115
-0.133011786127
-0.132473576913
-0.132312999977
-0.13247784205
-0.133001597512
-0.13376755446
-0.134628433542
-0.135545943318
-0.136305930321
-0.137110364554
-0.138622679261
-0.140823582628
-0.140090057866
-0.12514084783
-0.125144603484
-0.12515375439
-0.125159266895
-0.125170860683
-0.125190302612
-0.125212241406
-0.125235704335
-0.125274515129
-0.125314225447
-0.125359529925
-0.125408581942
-0.125460362991
-0.125514263487
-0.125569448044
-0.125634240748
-0.125700966695
-0.125769649792
-0.125841681413
-0.125920028344
-0.126006859665
-0.126104339804
-0.126218252999
-0.126367914361
-0.126560024834
-0.126768488023
-0.126964684278
-0.12717941535
-0.127415748657
-0.127657578085
-0.127906823621
-0.128176229447
-0.128465414849
-0.128773206345
-0.129098496725
-0.129440765947
-0.12980081191
-0.130180328876
-0.13058028404
-0.131001688146
-0.131445847136
-0.131913661192
-0.132404405191
-0.132914775432
-0.133442207545
-0.133990168971
-0.134563890767
-0.135163972735
-0.135789663427
-0.136450421064
-0.137154082966
-0.137898836251
-0.138677482562
-0.139462930982
-0.140240468895
-0.14008075974
-0.139777064438
-0.139310548209
-0.138708868614
-0.138105186332
-0.137303659401
-0.13618558175
-0.134788348898
-0.133185887105
-0.131481234451
-0.129770898223
-0.128152632294
-0.126736790589
-0.12564878484
-0.124998353798
-0.124820092019
-0.125086861021
-0.125730808095
-0.126676603771
-0.127932039069
-0.129608435784
-0.131920504009
-0.134874820893
-0.137583962864
-0.139677862884
-0.12502642936
-0.125029151302
-0.125035292356
-0.125041426799
-0.125054750307
-0.125073152119
-0.125094843647
-0.125116061251
-0.125151981223
-0.125193333637
-0.125238592747
-0.125286638381
-0.125337178493
-0.125393613194
-0.125448071046
-0.125509660174
-0.125573676058
-0.125640905522
-0.125710176894
-0.125784764987
-0.125866693323
-0.125958234206
-0.126064835142
-0.126202917443
-0.12638387688
-0.126594984601
-0.126799683132
-0.127004156756
-0.127225074513
-0.127456502218
-0.127701343536
-0.127968875856
-0.128257192496
-0.128565725509
-0.128893769147
-0.129239918151
-0.129604529675
-0.129988851958
-0.130394840745
-0.130823119965
-0.131275004089
-0.131751954226
-0.132252974861
-0.132773553414
-0.133307280444
-0.133858769287
-0.134442175096
-0.135060228787
-0.135703763117
-0.136395325807
-0.137157539281
-0.137982027119
-0.138856883315
-0.139555352136
-0.1392289179
-0.138845952112
-0.138483748291
-0.137771489549
-0.136804106988
-0.135656761018
-0.134292255675
-0.132705948406
-0.130941935082
-0.129056965004
-0.127128602555
-0.125229043846
-0.123425005029
-0.121777417353
-0.120353326605
-0.119243356535
-0.118549980565
-0.118276963058
-0.118409481551
-0.118928959765
-0.119942790706
-0.121788553245
-0.124675689819
-0.128176485592
-0.132664198416
-0.142202415578
-0.124906258998
-0.124908054133
-0.124910705573
-0.124917875963
-0.124932405559
-0.124949446749
-0.124970362357
-0.124991563409
-0.125023141458
-0.125063582861
-0.125107435404
-0.125153508501
-0.125201114389
-0.125256272244
-0.125313068189
-0.125372715814
-0.125434074764
-0.125499700148
-0.125567259363
-0.125638625492
-0.125715880734
-0.125800782644
-0.125899810742
-0.126026438564
-0.126192596838
-0.126393880591
-0.126605648732
-0.126809011064
-0.127019474389
-0.127241743238
-0.127478364536
-0.12774136083
-0.128028583384
-0.128335889678
-0.128666619892
-0.129017208638
-0.129386436826
-0.129776809828
-0.130190181031
-0.13062736896
-0.131088624991
-0.131575390459
-0.132087165315
-0.132619712636
-0.133165547063
-0.133724347444
-0.134304496747
-0.134905610984
-0.135536896401
-0.136256874939
-0.137092481306
-0.138029114195
-0.138843373129
-0.138166774308
-0.137543665514
-0.137245509108
-0.136559187243
-0.13546604681
-0.134080621252
-0.13244965243
-0.130597632021
-0.128573776283
-0.126422357072
-0.124176838739
-0.12187597767
-0.119560338744
-0.117276167875
-0.115074203503
-0.113016957101
-0.111199384799
-0.109747133524
-0.108706476137
-0.108032699867
-0.10771216665
-0.107905345793
-0.109120013322
-0.111710828783
-0.114635932684
-0.116412226804
-0.119869219779
-0.124781138668
-0.124782477724
-0.124783672628
-0.124792092091
-0.124805441464
-0.124819956356
-0.12483776564
-0.124859692267
-0.124886645552
-0.124924787497
-0.124966528445
-0.12501022237
-0.125054979257
-0.125105900489
-0.125163867356
-0.125222810335
-0.125281956334
-0.12534487199
-0.125410643646
-0.125479672098
-0.125553217359
-0.125631311385
-0.125722239442
-0.125837755096
-0.125988599499
-0.126175038501
-0.126381470746
-0.126585671624
-0.12678735869
-0.127001037332
-0.127233815934
-0.127488898968
-0.12777214313
-0.128079534258
-0.128413572414
-0.128769181209
-0.129143868365
-0.129541159615
-0.12996308607
-0.130410820234
-0.13088436352
-0.131384318659
-0.131912472445
-0.132466480716
-0.133033986884
-0.133597143769
-0.13415303262
-0.134707919107
-0.135274543656
-0.136004539983
-0.136941668028
-0.137978754978
-0.136871494689
-0.135971430478
-0.135682513166
-0.135085695303
-0.133937352907
-0.132383466384
-0.130524973444
-0.128414510974
-0.126088314786
-0.123586057914
-0.120932654416
-0.118144595589
-0.115244328515
-0.112264826984
-0.10925198408
-0.106259462936
-0.103345897093
-0.100583403781
-0.0980622493083
-0.0958296563527
-0.0937431942762
-0.0916655622303
-0.0896906579955
-0.0884272256323
-0.0882069585302
-0.0856162487648
-0.0722772138229
-0.0546103723281
-0.124650016476
-0.124651128254
-0.124652062936
-0.124661976984
-0.12467360733
-0.124685142716
-0.124698800525
-0.124720214944
-0.124741486113
-0.124776488362
-0.124815908208
-0.12485702057
-0.124899216548
-0.124946769145
-0.125002740947
-0.12506049175
-0.125117747258
-0.125177592886
-0.125239975797
-0.125306298008
-0.125376831931
-0.125448527521
-0.125530399227
-0.125634928067
-0.125770850614
-0.125940563045
-0.126136417896
-0.126337585755
-0.126539897654
-0.126742562087
-0.126967851703
-0.127217049013
-0.127492924033
-0.127792962583
-0.128126083627
-0.128489753691
-0.128872775409
-0.129279142587
-0.129710666982
-0.130170130058
-0.130659180189
-0.131178482526
-0.131733206346
-0.132320626707
-0.132912310713
-0.133480697937
-0.134009588031
-0.13450148512
-0.134891838164
-0.135562741959
-0.136894252472
-0.135429907335
-0.13421024656
-0.133877585743
-0.133378511375
-0.13227277559
-0.130618343065
-0.128562971175
-0.126197867316
-0.123577777759
-0.120737603384
-0.117703766182
-0.114491254679
-0.11111469569
-0.107597191076
-0.103971470996
-0.100276574318
-0.0965492920389
-0.0928159415323
-0.0890927759207
-0.0853967132597
-0.081717918844
-0.0778332588311
-0.0733857886363
-0.0683004886986
-0.063046730716
-0.057285706304
-0.0444716224355
-0.00905931717935
0.0431079531906
-0.124510093766
-0.124510936959
-0.124512595955
-0.12452415413
-0.124534209
-0.124543000916
-0.124553739862
-0.124572522091
-0.124587754396
-0.124618711041
-0.124655384716
-0.124693547904
-0.124732854491
-0.124776797253
-0.124829314134
-0.124885005087
-0.124940946386
-0.124997316152
-0.125055047542
-0.125117443766
-0.12518463467
-0.1252506519
-0.125322228425
-0.125415500274
-0.12553717915
-0.125689000139
-0.125869601
-0.126059014337
-0.126260904506
-0.126462704877
-0.126677379699
-0.126914231081
-0.127184523743
-0.12748445598
-0.12780982751
-0.128173604316
-0.128566141484
-0.128983579887
-0.129428757634
-0.129902619555
-0.130409092385
-0.130956209017
-0.131552246721
-0.132182968123
-0.132807533489
-0.133403097696
-0.133927291783
-0.134344807227
-0.13411806772
-0.135290749242
-0.133989011901
-0.132475389163
-0.132016002264
-0.131557896843
-0.130522104787
-0.128845858917
-0.126649263124
-0.124064509798
-0.121175305349
-0.118034588966
-0.114677651126
-0.111130423805
-0.10741183121
-0.103541751425
-0.0995435686911
-0.0954410419449
-0.0912519675449
-0.086979983189
-0.0826063513293
-0.0780821767666
-0.0733214466846
-0.0681869689527
-0.0624423436085
-0.0555897693087
-0.04739802474
-0.0380691897037
-0.0260185712158
-0.00202824385575
0.0503149629014
0.117025249053
-0.124357504434
-0.124358076552
-0.124360415071
-0.124373347162
-0.124381453862
-0.124389091828
-0.124397684677
-0.124412273785
-0.124423146555
-0.124450844144
-0.124484535677
-0.124519303482
-0.124555222846
-0.124594875977
-0.124642606909
-0.124694516642
-0.124749446768
-0.124802061507
-0.124854695146
-0.124911986817
-0.124973988153
-0.125035702595
-0.125096807813
-0.125177293593
-0.125285336853
-0.125419553151
-0.125582253026
-0.125755315449
-0.125944477116
-0.12614806488
-0.126361670655
-0.126587830968
-0.126839544855
-0.127132653337
-0.12746108373
-0.127823269254
-0.128221235534
-0.12864913489
-0.129108509108
-0.129600979613
-0.130132091155
-0.130717389932
-0.131363728434
-0.132044527584
-0.13273460877
-0.133451447535
-0.134097130809
-0.135014462824
-0.133868690369
-0.13252305065
-0.131186416539
-0.130356498717
-0.129859581077
-0.12883696057
-0.127167371658
-0.124880490554
-0.122115637729
-0.118994078135
-0.115595590902
-0.111973930848
-0.108168186808
-0.104208578468
-0.100118039155
-0.0959145471129
-0.0916091655816
-0.0872011862855
-0.08267206881
-0.0779802149158
-0.0730567339567
-0.0677949866286
-0.0620245505984
-0.0554841752727
-0.0478446867552
-0.0387280296437
-0.0278777219031
-0.0151228143992
0.00225880199196
0.0343029939918
0.0929060055591
0.154712131249
-0.124189202032
-0.124190434682
-0.1241926987
-0.124203895308
-0.124211641251
-0.124220631867
-0.124228651662
-0.124240327516
-0.124250852075
-0.124273135183
-0.124302930723
-0.124333827662
-0.124365888666
-0.124400623599
-0.124442458008
-0.124488166092
-0.124538572001
-0.124588336096
-0.124637129005
-0.124689004905
-0.12474347606
-0.124801684308
-0.124857336149
-0.124920808082
-0.12501456543
-0.125131446664
-0.12527493064
-0.125430519354
-0.125601389329
-0.125796728111
-0.126009581174
-0.126236054649
-0.126473424935
-0.126746910843
-0.127066452781
-0.127429880203
-0.127833648203
-0.12827303338
-0.128745805453
-0.129258754273
-0.129823243313
-0.130454595487
-0.131148734607
-0.131888113742
-0.132684634008
-0.133646560779
-0.134345540092
-0.133753257042
-0.132652597362
-0.130927565029
-0.129516011885
-0.128553624372
-0.127453265754
-0.125724732382
-0.123370893674
-0.120455016096
-0.117127024519
-0.113498279551
-0.109647335466
-0.105628854325
-0.10148245012
-0.0972351512736
-0.09290103486
-0.0884803710791
-0.0839570183136
-0.079295268769
-0.0744367502729
-0.0692992396873
-0.0637772734941
-0.0577329163781
-0.0509562440088
-0.0431094394871
-0.0337613186556
-0.0226143717627
-0.00953849653836
0.00602123066695
0.0275885842308
0.0645595609559
0.123654841366
0.177616027264
-0.124008141308
-0.124010694835
-0.12401224969
-0.124018920329
-0.124027948644
-0.124038239846
-0.124046863653
-0.124057919779
-0.12407028735
-0.124085916891
-0.124110444178
-0.124136810448
-0.124164618411
-0.12419405807
-0.124229591912
-0.124268543713
-0.12431074864
-0.124356871369
-0.12440262881
-0.124448972358
-0.124495450327
-0.124550627392
-0.12460504377
-0.124658349617
-0.124730528907
-0.124827027946
-0.124949791468
-0.125086231414
-0.125235711164
-0.125414422967
-0.125617993612
-0.125844684026
-0.126076926678
-0.126333279893
-0.126633467321
-0.126986267175
-0.127391957224
-0.127844128418
-0.128334118489
-0.128873161621
-0.129477140634
-0.130153781274
-0.130888658181
-0.131689715199
-0.132624248949
-0.134360412389
-0.133270503118
-0.132407334485
-0.131209337531
-0.12956998598
-0.128002543862
-0.126530875515
-0.124680694321
-0.122208437595
-0.119164395283
-0.115645812442
-0.111801468989
-0.107733661379
-0.103517691688
-0.0992035041215
-0.0948222823912
-0.0903866217177
-0.0858902747852
-0.0813080206897
-0.0765956338115
-0.0716898030976
-0.0665073551859
-0.0609449990159
-0.0548798348407
-0.0481588474393
-0.0405529898631
-0.0316862100258
-0.0210612279839
-0.00832589625795
0.00654139957263
0.0242305462222
0.0485821506541
0.0879003540676
0.145106680084
0.19270990461
-0.123821593384
-0.123823975787
-0.123824186574
-0.123826029095
-0.12383496845
-0.123844295432
-0.123852363357
-0.123861575804
-0.123873607702
-0.123886241858
-0.123906290612
-0.123927940058
-0.123951215563
-0.123975035638
-0.124004121269
-0.124036642376
-0.124071381199
-0.124112028454
-0.124153688492
-0.124195619635
-0.124237849947
-0.124287858275
-0.12433654087
-0.124386739846
-0.124444988152
-0.124520518742
-0.124614849273
-0.124726928487
-0.124851751181
-0.125008231849
-0.125192722404
-0.125405647521
-0.125637994659
-0.125883674001
-0.126167870546
-0.126500443602
-0.126894780841
-0.127352737892
-0.127865607765
-0.128437843405
-0.1290860706
-0.129802242204
-0.130555277332
-0.131330836598
-0.132062518519
-0.132471512137
-0.131946347922
-0.130760432533
-0.129629552593
-0.127861143703
-0.126048554907
-0.124013779684
-0.121441506807
-0.118263017385
-0.114584202263
-0.110534081058
-0.106254891438
-0.101840139504
-0.0973564121809
-0.0928413593954
-0.0883096111139
-0.0837530846995
-0.0791428628179
-0.0744313519559
-0.0695545635732
-0.0644331028372
-0.0589708266228
-0.0530524862079
-0.0465415830477
-0.0392688478951
-0.0309891807327
-0.021316687745
-0.0097499132177
0.00408733985284
0.0202849102475
0.0395591719903
0.0655872494443
0.105431269708
0.159660429676
0.202151293481
-0.123632548015
-0.123633700974
-0.123631976538
-0.123631658403
-0.1236368084
-0.123642719433
-0.123648485141
-0.123654095469
-0.12366360849
-0.123674174035
-0.123690437247
-0.123707195687
-0.123725571738
-0.123743292148
-0.123765528322
-0.123791128867
-0.123818432162
-0.123852842066
-0.123889110385
-0.123926484736
-0.123966844975
-0.124009247817
-0.124050662375
-0.124089885844
-0.124139075361
-0.124201396547
-0.124273357548
-0.124355062767
-0.124452448803
-0.124582443823
-0.124742486364
-0.124929119671
-0.1251456161
-0.125380566718
-0.125650529014
-0.125967835617
-0.126344844462
-0.12679837683
-0.127333391929
-0.127947446806
-0.128647860842
-0.129413617263
-0.130201743761
-0.130979940626
-0.131185423923
-0.130525886777
-0.129638814401
-0.129019375736
-0.12780646777
-0.125783824399
-0.123599560568
-0.120962749117
-0.117718094967
-0.11391045115
-0.109690975878
-0.105207772736
-0.100593354968
-0.0959301603373
-0.0912701718432
-0.0866331659508
-0.0820134653471
-0.0773820180952
-0.072690567942
-0.0678752647615
-0.0628594074693
-0.0575536912234
-0.0518535272089
-0.0456352937309
-0.0387533357066
-0.0310299527707
-0.022219323638
-0.0119549911568
0.000222181818652
0.0146567139635
0.0314599396599
0.051348048399
0.0777051396047
0.116508481952
0.167211574225
0.20569064032
-0.123438640607
-0.123440094012
-0.123435910821
-0.123435777273
-0.123435499073
-0.123436724201
-0.123438763313
-0.123440166992
-0.123445820126
-0.123451846957
-0.123463923001
-0.123475192168
-0.123487686241
-0.123498810243
-0.123513940522
-0.123531371353
-0.123550035565
-0.12357754353
-0.123606947762
-0.123636631939
-0.123671341721
-0.123704007678
-0.123738482893
-0.123770274818
-0.123802713234
-0.123850627267
-0.123910590854
-0.12396722426
-0.124037333356
-0.124135926073
-0.124270393886
-0.124431851162
-0.124620546925
-0.124831730796
-0.125076629912
-0.125374074086
-0.125731883068
-0.126176556132
-0.126729932912
-0.127391867025
-0.12815450807
-0.128993283981
-0.129889890005
-0.131212167063
-0.129991284431
-0.129028673999
-0.128088346572
-0.127421249795
-0.125771077715
-0.123393607042
-0.120707650443
-0.117436079338
-0.113569373062
-0.109220753736
-0.104565819509
-0.0997550547187
-0.0949058961976
-0.0900850558212
-0.0853253182559
-0.0806260977079
-0.0759615749589
-0.0712847552373
-0.0665329923311
-0.0616318499059
-0.0564972868889
-0.0510349881552
-0.0451371160021
-0.0386784244109
-0.0315133887434
-0.0234679275035
-0.0143096425984
-0.00370436406139
0.00875924794581
0.0233906604625
0.0402827176225
0.0600134749377
0.0854637923151
0.121871470288
0.168698657999
0.204232525474
-0.123236274386
-0.123237502213
-0.123233235478
-0.123232196496
-0.123229035492
-0.12322642249
-0.123224274218
-0.123221179426
-0.12322163809
-0.12322133082
-0.123228187047
-0.12323332103
-0.123238339228
-0.123242654473
-0.123250828924
-0.12325928133
-0.123268272715
-0.123286384453
-0.123307105353
-0.123326267709
-0.123351154171
-0.123373852357
-0.1233972559
-0.123425470618
-0.123449376117
-0.123483539229
-0.123527482055
-0.123570130056
-0.123609163711
-0.123671334075
-0.123771947608
-0.123907017735
-0.124068055513
-0.124251952844
-0.124462268832
-0.124726100351
-0.125052743232
-0.125478696808
-0.126043896744
-0.126749437783
-0.127558729139
-0.12837988109
-0.129181374404
-0.129120460569
-0.128773710506
-0.127413315846
-0.126876474976
-0.125740868494
-0.123524396224
-0.120680239651
-0.117400344223
-0.113501282874
-0.109077566995
-0.104281129405
-0.0992939175324
-0.0942549885895
-0.0892608595664
-0.0843578819101
-0.0795572760481
-0.0748384432996
-0.0701581809296
-0.0654560422762
-0.0606600966081
-0.0556902247738
-0.0504593684671
-0.0448720795302
-0.0388209572664
-0.0321826468467
-0.0248148287617
-0.0165494202087
-0.00716882218719
0.00363076428666
0.0162231900788
0.0309003328541
0.0477384588018
0.0671256994651
0.0913544138946
0.124977328414
0.167919687266
0.201069642912
-0.123025685352
-0.123025239611
-0.123022843596
-0.123020422418
-0.123016053829
-0.123010882066
-0.123004779876
-0.122997239234
-0.122991912242
-0.122984306435
-0.122984768169
-0.122983510532
-0.12298003012
-0.122976224254
-0.122977742272
-0.122977424033
-0.122976815807
-0.122981843418
-0.122989889045
-0.122997250543
-0.123009593272
-0.123023647034
-0.123040648834
-0.12305921657
-0.123077864417
-0.123096653058
-0.123124591822
-0.123157211553
-0.123169899568
-0.123195306663
-0.123250872782
-0.123348006019
-0.123477699756
-0.123637615048
-0.123812897218
-0.124028516536
-0.124308831022
-0.124696883499
-0.125263329014
-0.126013873549
-0.126894345366
-0.127837185973
-0.129147805357
-0.127741128565
-0.126974145878
-0.125925264107
-0.125500136883
-0.123733636705
-0.120975659205
-0.11759431995
-0.113697013899
-0.109219371693
-0.104321116911
-0.0991733448024
-0.0939503121863
-0.0887705216833
-0.0837055239376
-0.078778702676
-0.0739797747942
-0.0692704224091
-0.0645938992669
-0.0598807502624
-0.0550539459492
-0.0500311926862
-0.0447252180107
-0.0390417635996
-0.0328759490094
-0.0261083385006
-0.0186020953978
-0.0101981047718
-0.000697260393993
0.010170707858
0.0227416980418
0.037292735627
0.0538901993345
0.0727587830617
0.0956866629714
0.126683403781
0.166199075641
0.197363598049
-0.122810459507
-0.1228091302
-0.122806469045
-0.122802635417
-0.122797098889
-0.122789815154
-0.122779983134
-0.122768227828
-0.122757495924
-0.122742753962
-0.122735593693
-0.122727598109
-0.122715817321
-0.122702176446
-0.122695788187
-0.122686343143
-0.122675936947
-0.122666407442
-0.122658357339
-0.122651642396
-0.122650696935
-0.122649847461
-0.122660050805
-0.122667899982
-0.122676269692
-0.122682348871
-0.122695915225
-0.122718209211
-0.122721725426
-0.122713588458
-0.122725143428
-0.122770168651
-0.122855883285
-0.122975983426
-0.123125192063
-0.123291867896
-0.123508570279
-0.123822148366
-0.124364626225
-0.125124789325
-0.126009954492
-0.127090660047
-0.129147885194
-0.126479504636
-0.12475299931
-0.124497682595
-0.123762656167
-0.121350496554
-0.118066496729
-0.114116731414
-0.109633146129
-0.104651934256
-0.0993713117192
-0.0939667051583
-0.0885941709486
-0.0833464004885
-0.078268279859
-0.0733600589212
-0.0685919250431
-0.0639111359591
-0.0592513047998
-0.0545377145489
-0.0496913723653
-0.0446302897942
-0.0392690148311
-0.0335164017125
-0.0272722020159
-0.0204234693298
-0.0128421057665
-0.00438178782094
0.00513469669336
0.0159423967734
0.0283384579948
0.0425820913575
0.0587302131148
0.0768796922937
0.0984256682767
0.126981159237
0.163517493307
0.193079729632
-0.122592099848
-0.122590027292
-0.122585847395
-0.122580942882
-0.122573539868
-0.122563606304
-0.122549947614
-0.122533624775
-0.122518882133
-0.122499723157
-0.122482386916
-0.122466678114
-0.122447060301
-0.122425047086
-0.122406625211
-0.122386045691
-0.122364832567
-0.122340757706
-0.122316640044
-0.122292620943
-0.122277046262
-0.122259688084
-0.122249353048
-0.122240648657
-0.122236146035
-0.1222347206
-0.122236581693
-0.122251565271
-0.122258581143
-0.122226405013
-0.122201590855
-0.122197498239
-0.122226934605
-0.122286137409
-0.122386832853
-0.122515023263
-0.122668638633
-0.12287204008
-0.123312464281
-0.124031958206
-0.124783561042
-0.125470687332
-0.124549720629
-0.123817610439
-0.12220297337
-0.122990711796
-0.121617682593
-0.118621746639
-0.114793248539
-0.110275617279
-0.10526395496
-0.0998639473348
-0.094292862436
-0.0887175964368
-0.0832688126939
-0.078010928616
-0.0729624400328
-0.0681021462631
-0.0633837774156
-0.0587437290261
-0.0541094835412
-0.0494040634265
-0.0445489158591
-0.0394643314169
-0.0340685101383
-0.0282753660521
-0.0219915037476
-0.0151130181401
-0.00752335668694
0.000908492252551
0.0103369408934
0.0209635547413
0.0330492024285
0.0468345888016
0.0623687528969
0.0796516207413
0.0997704890257
0.126037151435
0.15992253274
0.188163596728
-0.122371576997
-0.122368856643
-0.122363326792
-0.122357463372
-0.122347083821
-0.122333286995
-0.122315785124
-0.122294498035
-0.122274915325
-0.122252099709
-0.122224017019
-0.122200276921
-0.122172530813
-0.122142982283
-0.122109998861
-0.122076398433
-0.122042580764
-0.122003555578
-0.121964750204
-0.121924747883
-0.12188952697
-0.121855224107
-0.121819696172
-0.121788103746
-0.121764380013
-0.121744620523
-0.121734022064
-0.121737737636
-0.121750421782
-0.121724858153
-0.121667810657
-0.1216237314
-0.121592209402
-0.121596480265
-0.121626763169
-0.121694455458
-0.121788477272
-0.121902846484
-0.12211359876
-0.122820772995
-0.123721934464
-0.125145668895
-0.122266942958
-0.120577681017
-0.120173478113
-0.121296185614
-0.119103223242
-0.115577642958
-0.111179642519
-0.106123362505
-0.100652597697
-0.0949186824526
-0.0891417102405
-0.0834696131305
-0.0780035080578
-0.0727791399788
-0.0677903285614
-0.0629971872131
-0.0583404436809
-0.053749019128
-0.0491472557396
-0.0444583366812
-0.0396061124856
-0.0345148934143
-0.0291082749646
-0.0233071092629
-0.0170268764906
-0.0101748230616
-0.00264799766677
0.00566778121954
0.0149042132135
0.0252318209803
0.0368784565345
0.0500679315682
0.0648469935681
0.0811487330395
0.0998201940228
0.123935737303
0.155438065619
0.182583699097
-0.12214990611
-0.122146634359
-0.122141658124
-0.122133943916
-0.122119168848
-0.12210086307
-0.122079460202
-0.122053549336
-0.122025974887
-0.121996970152
-0.121960248787
-0.121927955067
-0.121890898119
-0.121851181421
-0.121804328433
-0.121757336625
-0.121707878473
-0.121653383982
-0.121600190948
-0.121544681358
-0.121485537949
-0.121428704641
-0.12136907664
-0.121314883859
-0.121263928588
-0.121216258419
-0.121181793133
-0.121161824962
-0.121160986034
-0.121161568025
-0.121104909632
-0.121019432268
-0.120941478402
-0.120884014698
-0.120848887518
-0.120844434431
-0.120873312531
-0.120934555692
-0.121011018869
-0.121395562482
-0.122306008566
-0.124659578225
-0.120508200503
-0.117780071742
-0.118752781336
-0.119353564533
-0.116306405088
-0.112245861027
-0.107263985937
-0.101716923902
-0.0958588826478
-0.0898712711758
-0.0839622371413
-0.0782536786307
-0.0728155162752
-0.0676559867829
-0.062746907116
-0.0580329519253
-0.0534452478454
-0.0489082587678
-0.0443456950736
-0.039682905397
-0.0348478404795
-0.0297704248413
-0.0243812958322
-0.0186099870074
-0.0123826546387
-0.00561947171751
0.00176730560205
0.00987400625201
0.0188100405341
0.0287174202751
0.0397947617221
0.0522526119411
0.0661432243025
0.0813599542383
0.0985667194217
0.120658095893
0.150034391209
0.17631556391
-0.121927873792
-0.121924491175
-0.121919815999
-0.121908397635
-0.121889407978
-0.121867166942
-0.121841745046
-0.121811205972
-0.12177552579
-0.121738602245
-0.121693297976
-0.121650829695
-0.121603689164
-0.121550956599
-0.121490634688
-0.121430767387
-0.121364037627
-0.121291834571
-0.121222189118
-0.121146788318
-0.121064564576
-0.120983664175
-0.120896999989
-0.120818038573
-0.12073502767
-0.120658040434
-0.120586324859
-0.12052659211
-0.120486807258
-0.120472906064
-0.120451109041
-0.120367409547
-0.120265432642
-0.12015148417
-0.120059510711
-0.119995410242
-0.11996569849
-0.119970494171
-0.120004851849
-0.120038173828
-0.120072775086
-0.118782404913
-0.117503531046
-0.114993461519
-0.117485882777
-0.117074428811
-0.113274814126
-0.108644570549
-0.103090322896
-0.097109117725
-0.0909341644462
-0.0847654594695
-0.0787863518465
-0.0730889908637
-0.0677122426247
-0.0626391039884
-0.0578225735936
-0.0531952202904
-0.0486816922539
-0.0442045974737
-0.0396891077989
-0.0350644263697
-0.030264078819
-0.0252250160621
-0.0198863410664
-0.0141876901879
-0.00806723329964
-0.00145921888405
0.00570807682035
0.0135129569238
0.0220434966824
0.0314155034817
0.041801316443
0.0534009631681
0.0662770410682
0.0803001448995
0.0959960291221
0.116150247862
0.143651505594
0.169330410165
-0.121705262164
-0.121701478754
-0.121692450894
-0.121678444568
-0.121657516634
-0.121632162503
-0.121602529314
-0.121566692843
-0.121524501921
-0.121479284686
-0.121426661275
-0.121371696659
-0.121314289202
-0.12124816862
-0.121174344007
-0.121100556126
-0.121017392744
-0.120927574892
-0.120836062811
-0.12073710489
-0.120630169557
-0.120524840168
-0.120410897538
-0.120296862947
-0.120179504664
-0.12006778962
-0.119951983236
-0.119844606179
-0.119751438628
-0.119678866854
-0.119636517339
-0.119596429127
-0.119500242476
-0.119383487694
-0.11926334304
-0.119153428673
-0.119064886647
-0.119013400558
-0.11902359539
-0.119041396576
-0.119251268885
-0.1165653212
-0.114502804311
-0.113127653501
-0.116138191446
-0.114453885426
-0.11001550757
-0.104784751557
-0.0986995442666
-0.0923442228867
-0.0859194041082
-0.0796330540555
-0.0736343999257
-0.0679848447724
-0.0626935520475
-0.0577212179964
-0.0530053553382
-0.0484696028833
-0.0440348961583
-0.0396241991575
-0.0351659006058
-0.0305944849942
-0.0258503128863
-0.0208785549497
-0.0156279556542
-0.0100494092073
-0.00409421900137
0.00228820538572
0.00915253617192
0.0165582251346
0.0245716703358
0.033282719604
0.0428383334795
0.0534309578831
0.0651414865547
0.077833450665
0.0919294598193
0.110194007322
0.136111666223
0.16155054062
-0.121483226656
-0.121478360383
-0.121465470356
-0.121449529064
-0.121426741918
-0.12139764032
-0.121362753218
-0.121321034464
-0.121272243707
-0.121219409765
-0.121160378956
-0.121092609989
-0.121024848473
-0.120946865033
-0.120861189585
-0.120769399404
-0.12066994088
-0.120562597881
-0.1204455079
-0.120322962138
-0.120191293993
-0.12005520942
-0.119911154804
-0.119756377711
-0.119601244144
-0.11944188689
-0.119280819117
-0.119121323371
-0.118966590616
-0.118825553341
-0.118703805388
-0.118617003233
-0.118531851318
-0.118430850524
-0.118288880965
-0.118126108241
-0.117953377038
-0.117814882267
-0.117779294823
-0.117942737388
-0.119617443174
-0.11506992295
-0.111587643904
-0.111887991393
-0.114546250083
-0.111567266792
-0.10653675721
-0.100685807708
-0.0941275025154
-0.0874569797053
-0.0808447328147
-0.0744947085105
-0.0685169106278
-0.0629427931957
-0.057753982018
-0.0528921244947
-0.0482824701467
-0.0438426121045
-0.0394921494902
-0.0351562491674
-0.0307679570059
-0.0262682051857
-0.0216052132715
-0.0167333430949
-0.0116119520467
-0.00620417862584
-0.000475440867785
0.00560877857375
0.012085447173
0.0189952178861
0.02638412839
0.0343186322114
0.0429234941658
0.0523887397663
0.0628238623786
0.0740914864362
0.0864924347313
0.102794161579
0.127314309521
0.153005036473
-0.121263940508
-0.121258477794
-0.121245912323
-0.121226484033
-0.121199566042
-0.121165378462
-0.121124476369
-0.121076802296
-0.121021425389
-0.120960584412
-0.120893733354
-0.120815153306
-0.120735203785
-0.120646667828
-0.120547780417
-0.120436305543
-0.120320187459
-0.12019222825
-0.120050644331
-0.119904768864
-0.119746809876
-0.119574739731
-0.119395769982
-0.119200955848
-0.11900371729
-0.118792468018
-0.11858124647
-0.11836037723
-0.118138172507
-0.117921366989
-0.117712671126
-0.117513610596
-0.117331895478
-0.11715164089
-0.116938699288
-0.116678960177
-0.116373223424
-0.116029908825
-0.115694423581
-0.115558955947
-0.118546944378
-0.112200406822
-0.108073302563
-0.110803319352
-0.112571818057
-0.108444882815
-0.102835249782
-0.0963718533275
-0.0894037348972
-0.0824732828073
-0.0757301686249
-0.0693614455587
-0.0634365741083
-0.0579587227277
-0.0528846551519
-0.0481402462783
-0.0436414577697
-0.0393023781138
-0.035043282843
-0.0307930764473
-0.026490652013
-0.0220843564452
-0.0175311288986
-0.0127953535878
-0.00784784610609
-0.00266483585413
0.0027733558377
0.00848451051503
0.0144874119225
0.020803698128
0.0274589746989
0.0344950326559
0.0420088081283
0.050177142478
0.0591310799339
0.0687320188852
0.0791259258981
0.0930684871916
0.116223386707
0.143532096176
-0.121047983244
-0.121041783802
-0.121028688081
-0.121006168077
-0.120974479733
-0.120935774561
-0.120889690901
-0.120836539117
-0.120775138366
-0.120705911829
-0.120630017222
-0.120543568131
-0.120448408236
-0.120348073375
-0.120233479231
-0.120105659875
-0.119970557179
-0.119821029397
-0.119657581449
-0.119483920537
-0.119295711122
-0.119088929893
-0.118872685988
-0.118638839046
-0.118392188664
-0.118132058494
-0.117858638878
-0.117570773558
-0.117278045997
-0.116976910085
-0.116675163724
-0.116366492633
-0.11606030616
-0.115744552142
-0.115408722455
-0.115015338082
-0.114518657388
-0.113815506871
-0.112706727119
-0.110975824622
-0.107432438202
-0.10766589517
-0.104316274468
-0.109711606881
-0.110130228321
-0.105085838333
-0.0989002600583
-0.0918639032897
-0.0845491186454
-0.0774103930576
-0.0705866480772
-0.0642364129567
-0.0583901497939
-0.0530246672449
-0.0480748070763
-0.0434537703991
-0.039070892975
-0.0348389501197
-0.0306805665348
-0.026529630418
-0.0223318179487
-0.0180436250794
-0.0136313401622
-0.00906997001783
-0.00434240583453
0.000561398382404
0.00564560090646
0.0109106529321
0.0163565462754
0.0219853972563
0.0278024952941
0.0338261656418
0.0401268046024
0.0468688749065
0.0542174978017
0.0620902382598
0.0705682364902
0.0823389957095
0.104265679464
0.134171528442
-0.120835755259
-0.120828193562
-0.120811829715
-0.120785652331
-0.120751687676
-0.120710018905
-0.120659799149
-0.120601440414
-0.120533740561
-0.120456332405
-0.12037128987
-0.120277072728
-0.120167653279
-0.12005276493
-0.119924376786
-0.119781385212
-0.119623929127
-0.119454541925
-0.119268530328
-0.119063480153
-0.118845134238
-0.118605233402
-0.118348603412
-0.118073608046
-0.11777284701
-0.117460832176
-0.117121847611
-0.116768921989
-0.116397934603
-0.116009827714
-0.115614611557
-0.115205968481
-0.11479074532
-0.114361561023
-0.113910967103
-0.113417909468
-0.112817023236
-0.111985022395
-0.110647855555
-0.108231712472
-0.106881775717
-0.105759937077
-0.10320631353
-0.108916034653
-0.107382790072
-0.101537319618
-0.0947382593706
-0.0871810723377
-0.0795761857968
-0.0722772942635
-0.06541714023
-0.0591165478847
-0.0533701568456
-0.0481303130198
-0.043312966378
-0.0388214525179
-0.0345608273986
-0.0304444176977
-0.026398579912
-0.0223631929379
-0.0182914605417
-0.0141486190844
-0.00991085554028
-0.00556440286609
-0.00110494026047
0.0034630674921
0.0081275408682
0.012871154386
0.0176751469028
0.0225229743617
0.0274019054649
0.0323106781302
0.0372949220005
0.042493242924
0.048056936882
0.0538921821228
0.0599990272862
0.0687645173297
0.0862469999397
0.10932660281
-0.120628993013
-0.120620119741
-0.120600557387
-0.120570248357
-0.120535229319
-0.120490778227
-0.120436462673
-0.120372596616
-0.120298218857
-0.120213302565
-0.120119265905
-0.120014963634
-0.119896769094
-0.119764997399
-0.119622676463
-0.119463216031
-0.119285263183
-0.119094168516
-0.118883264109
-0.118650429531
-0.11840062684
-0.118126756999
-0.117825511188
-0.117504140676
-0.117156285666
-0.116785574886
-0.116385423461
-0.11595950936
-0.115508659227
-0.115037855079
-0.114546521026
-0.114037886229
-0.11352020472
-0.112991618943
-0.112460315379
-0.111924644113
-0.111376348442
-0.110801922713
-0.110142020754
-0.110133984918
-0.107042989111
-0.10399960555
-0.103067019381
-0.107987489321
-0.104444633026
-0.0978334541436
-0.0903630023388
-0.0823373034267
-0.0744894323449
-0.0670752725758
-0.0602179213495
-0.0539941389762
-0.048366352475
-0.0432642422165
-0.0385878644512
-0.0342331880583
-0.0301030508198
-0.0261129137605
-0.0221940055309
-0.0182930050391
-0.0143712230566
-0.0104030919218
-0.00637512897985
-0.00228527045824
0.00185750057053
0.00603377611647
0.0102150819238
0.0143664934448
0.018450580706
0.0224309484511
0.0262723429983
0.0299422009557
0.0334329210515
0.0367915282832
0.0400267402949
0.0428565590455
0.0451081198208
0.0488302212994
0.0574255567035
0.0603515105235
-0.120429191962
-0.12041983686
-0.120399577859
-0.120368152718
-0.120329136637
-0.120280622183
-0.120221661166
-0.120151971823
-0.120071395579
-0.119979577533
-0.119876343841
-0.119761852329
-0.119634625524
-0.119488571518
-0.119329072525
-0.119153843966
-0.118958004501
-0.118741235566
-0.118506847578
-0.118247532458
-0.117962220722
-0.117653661561
-0.117313418627
-0.116946870813
-0.116549984077
-0.116116553857
-0.115651143779
-0.115150225916
-0.11461946512
-0.11405642565
-0.113465763259
-0.112856833119
-0.11223231038
-0.111602766152
-0.110993574935
-0.110425254475
-0.10993286636
-0.109579569441
-0.109415870287
-0.11064138392
-0.105769923854
-0.101226794792
-0.102579379455
-0.106395304069
-0.101193417037
-0.0938925625097
-0.0857536198124
-0.0773270938501
-0.0692824464114
-0.061798000846
-0.0549799212044
-0.0488583574711
-0.043367096197
-0.0384150042063
-0.0338891735162
-0.0296804403655
-0.0256912605061
-0.021840584599
-0.0180654703142
-0.0143200636308
-0.0105742694606
-0.00681215098912
-0.00303108289003
0.000758537343306
0.00453331981675
0.0082573409777
0.0118834226995
0.0153552830242
0.0186100472421
0.0215792155856
0.0241848402813
0.0263327248009
0.027915897111
0.0288199406779
0.0288369960696
0.0274785047238
0.0242553798609
0.0196444483644
0.0127990104329
-0.00351341073229
-0.120237239219
-0.12022767053
-0.120207055978
-0.120176658347
-0.120132833638
-0.120080459037
-0.120016941998
-0.119941769305
-0.119855268608
-0.119756026814
-0.119643860235
-0.119519114312
-0.119380041508
-0.119223172788
-0.119046947541
-0.118855263973
-0.118640869826
-0.118403397507
-0.118144138522
-0.117856430508
-0.117541247016
-0.117198127748
-0.1168196634
-0.116405201129
-0.115953803033
-0.115463086068
-0.114929189471
-0.11435377195
-0.11373219168
-0.113072847218
-0.112382774216
-0.111655908158
-0.110903401493
-0.110150131463
-0.109433779889
-0.108788686721
-0.10827621291
-0.108002062368
-0.107980103775
-0.109671150413
-0.10255883835
-0.0970151541415
-0.101301732284
-0.103942147296
-0.0974857264808
-0.089595868693
-0.0808632146912
-0.0721248731788
-0.0639382081065
-0.0564327058702
-0.0496904990625
-0.0436969068022
-0.0383606873555
-0.0335720924126
-0.0292081398181
-0.0251565942692
-0.021321205139
-0.0176256090137
-0.0140135382706
-0.0104472224723
-0.00690568721097
-0.00338324641086
0.000110933796767
0.00355253044656
0.00690158128066
0.0101026514518
0.0130859393998
0.0157689758929
0.018057958048
0.0198473623896
0.0210168095877
0.0214268196619
0.0209180505956
0.0193099544657
0.0163739423031
0.0117965596392
0.0052735903918
-0.00344076707603
-0.0152304442166
-0.0285768568255
-0.120054962715
-0.120044830402
-0.12002269475
-0.119992070633
-0.11994689266
-0.11989131398
-0.119823452892
-0.119743104303
-0.119650331728
-0.119543843792
-0.119423839436
-0.119288718859
-0.11913828504
-0.118969699918
-0.1187808222
-0.11857075495
-0.118339066066
-0.118083229045
-0.117797470772
-0.11748441789
-0.117141744072
-0.116761261908
-0.11634360734
-0.11588365917
-0.115380350158
-0.114829703664
-0.114228121446
-0.113572158107
-0.112860177864
-0.112105227737
-0.111293118467
-0.110423540769
-0.109519104827
-0.108609701302
-0.107729355481
-0.106931433531
-0.106304795163
-0.105992351088
-0.105904399207
-0.107950445386
-0.0981457600756
-0.0918225121447
-0.0993171328921
-0.100666628192
-0.0932703090023
-0.0848752323299
-0.0756558385783
-0.0667024377425
-0.0584369880755
-0.0509644161627
-0.0443363343702
-0.0384980253289
-0.0333367766313
-0.0287268866912
-0.024538167681
-0.0206572808799
-0.0169908466678
-0.0134682951053
-0.0100408552142
-0.00667952039732
-0.00337316346349
-0.000127367879959
0.00303532471576
0.00607433022815
0.00893006052952
0.0115241499199
0.0137612506601
0.0155320954382
0.0167169139733
0.0171884667773
0.0168167326017
0.0154798226419
0.0130751167209
0.00951023176635
0.00470702886724
-0.00126947911686
-0.00814123106936
-0.0160251655244
-0.0254915823714
-0.0352522553523
-0.119883944652
-0.119873304871
-0.119850580465
-0.119818246515
-0.119773418135
-0.119713922252
-0.119641542185
-0.119555945119
-0.119456852417
-0.119344026536
-0.1192163273
-0.11907296543
-0.118912336706
-0.118731710066
-0.118530496259
-0.118305442613
-0.118056460649
-0.117779770426
-0.117472380542
-0.117133533574
-0.116761135671
-0.116347911533
-0.115891721217
-0.115387955643
-0.114832588536
-0.114222362925
-0.113553077082
-0.112817064694
-0.112019314759
-0.111151068484
-0.1102015282
-0.109179561258
-0.108093621191
-0.106971190267
-0.105841831966
-0.104775489843
-0.103902693885
-0.103423446849
-0.103325808221
-0.106177936043
-0.0931606885736
-0.0861769146038
-0.0967773824413
-0.0966499724019
-0.0885546218253
-0.0797150810923
-0.0701193874882
-0.0610427443004
-0.0527650891928
-0.0453814278422
-0.0389069007445
-0.0332526763028
-0.0282877710963
-0.0238735254053
-0.019875332482
-0.0161806625373
-0.0127005248856
-0.00937122982079
-0.00615239107453
-0.00302463041243
1.22583500628e-05
0.00293986306398
0.00571999936885
0.00829291438129
0.0105764600738
0.0124677103243
0.013847606428
0.0145886222007
0.0145647008431
0.0136618708038
0.011791167472
0.00891291145076
0.00506476398535
0.000335825588075
-0.00519594861453
-0.0112667588897
-0.0170552591918
-0.0223698789936
-0.0294958627336
-0.0305959222595
-0.119723111626
-0.119712081162
-0.119689347222
-0.119654214316
-0.119607835275
-0.119546019595
-0.119470404347
-0.119380152326
-0.119275559063
-0.119156791859
-0.119022194693
-0.118871467648
-0.118701318584
-0.11851108904
-0.118297953088
-0.118061133409
-0.117795861677
-0.117500591986
-0.11717148807
-0.116808757165
-0.116408218251
-0.115963236354
-0.115470578391
-0.114925246103
-0.114320241743
-0.113653830739
-0.112917402484
-0.112106877695
-0.111210285652
-0.110220049813
-0.109126518027
-0.107923085449
-0.106613618719
-0.105211825864
-0.103731500286
-0.102246639216
-0.100892056864
-0.0999077414707
-0.0997398193061
-0.105607057353
-0.0879927937048
-0.0805403384632
-0.0936487944868
-0.0919197790063
-0.0833524811908
-0.0741197894516
-0.0642569471748
-0.055142009339
-0.0469187078855
-0.0396790265971
-0.0333972330982
-0.0279563927379
-0.0232100154702
-0.0190096148119
-0.0152187853253
-0.0117276579614
-0.00845310889654
-0.0053394510984
-0.00235571648804
0.000506703148609
0.00323559918029
0.00579765887419
0.00813639816819
0.0101702124776
0.011793089646
0.0128798736615
0.0132964711113
0.0129146096461
0.0116301411245
0.00938122738685
0.00616201811756
0.00204123012639
-0.00279969357935
-0.00807931488263
-0.0136103503839
-0.0193886120231
-0.0248205356586
-0.0280828565455
-0.0280316187384
-0.0299016007549
-0.119570835391
-0.119559099425
-0.119535200129
-0.119497529768
-0.119448846133
-0.119387223405
-0.119309752037
-0.119215637508
-0.119106586803
-0.118982213115
-0.118841850231
-0.118683660491
-0.11850681929
-0.118307936814
-0.11808542518
-0.117836973523
-0.117558663287
-0.117246788241
-0.11689871176
-0.116512709992
-0.116086789925
-0.115613937044
-0.115087107168
-0.114501555239
-0.113853051328
-0.113132208558
-0.112331291367
-0.111437969523
-0.110438357675
-0.109319905886
-0.108066865525
-0.106671848572
-0.105120737788
-0.1033911035
-0.101480137626
-0.0994068447212
-0.0971078026607
-0.0946512145587
-0.0918950184311
-0.0943370737814
-0.085077834473
-0.0751946018675
-0.0895084782263
-0.0864453011828
-0.0776615158302
-0.068093590639
-0.0580800404087
-0.0490080203138
-0.040904432659
-0.0338609810684
-0.0278093305703
-0.0226103237622
-0.0181044790897
-0.0141366237803
-0.0105709553441
-0.00730203987531
-0.00425406733723
-0.0013805509843
0.00133883069955
0.00390046703044
0.00627786289473
0.00842043504773
0.0102508908182
0.011664313993
0.0125325299449
0.0127157075298
0.0120805071136
0.0105224716232
0.00799041080389
0.00450860194726
0.000184593340177
-0.00480156149221
-0.0101801596837
-0.0155411212001
-0.0205472448182
-0.0254942637071
-0.0303748922178
-0.0334793182409
-0.030811214177
-0.030762590136
-0.11942825112
-0.119415558581
-0.119389930853
-0.119351535693
-0.119301217296
-0.119238380348
-0.119159029424
-0.119062241423
-0.118950115988
-0.11882177021
-0.118676511636
-0.118512952882
-0.118329855235
-0.118124190505
-0.117895053353
-0.117636898624
-0.11734654659
-0.117020820264
-0.116657332835
-0.116251366971
-0.115800691646
-0.115301966807
-0.114746525782
-0.114125538863
-0.113434968968
-0.112662089244
-0.111794948977
-0.110820484979
-0.109723986819
-0.108484892633
-0.107094636505
-0.105517293918
-0.1037128916
-0.101645469367
-0.0992931714156
-0.0965249802364
-0.093123147376
-0.0888863081453
-0.0814687885221
-0.0890746616644
-0.0885159277992
-0.0695648297921
-0.08425386199
-0.0804211713235
-0.0714915311561
-0.0616561146165
-0.0516141837723
-0.0426614350145
-0.0347397650788
-0.0279400332788
-0.0221525239614
-0.0172214905695
-0.0129768877593
-0.00925990790592
-0.00593750804978
-0.00291037153208
-0.000111420165518
0.00249533746341
0.00491814539223
0.00713945761454
0.00911639978588
0.0107788198165
0.0120269820475
0.0127336017448
0.0127545272216
0.0119491814554
0.0102078593237
0.0074798965553
0.00379698519047
-0.000710164129775
-0.0058110982787
-0.0112210339751
-0.0166599383666
-0.0217567166423
-0.0259747285745
-0.0295319151916
-0.0340830044792
-0.0324851572186
-0.0314481615537
-0.0311492086888
-0.11929783418
-0.11928436926
-0.119257851228
-0.119219110321
-0.119167417999
-0.119102158362
-0.1190206494
-0.118922739806
-0.118808481598
-0.118677362456
-0.118528232599
-0.118360737896
-0.118172074528
-0.117961427246
-0.117725367536
-0.117461683408
-0.117162961462
-0.116824764574
-0.116447413894
-0.116026545925
-0.115555912925
-0.115032503435
-0.114451482218
-0.113802604458
-0.113071967651
-0.112249790612
-0.111325164535
-0.110285614058
-0.109106984592
-0.107774152237
-0.106248614721
-0.104488485706
-0.102460682637
-0.100123080847
-0.097387128639
-0.094089275718
-0.0900616217618
-0.0851112674123
-0.0775398375923
-0.0869265272462
-0.0820577892908
-0.0563976287612
-0.0778954187787
-0.0738024254877
-0.0648223735419
-0.0548592853505
-0.044905659118
-0.0361386599534
-0.0284538966836
-0.0219378255331
-0.0164430972573
-0.0118023675105
-0.00783732688728
-0.00438834843348
-0.00132703103194
0.00143826028471
0.00396448360025
0.00627574942098
0.0083666293558
0.0102037858044
0.0117259366139
0.0128416861058
0.0134290023645
0.0133427840769
0.0124346026033
0.0105831083433
0.00772885069967
0.00390386353257
-0.000755298483566
-0.00601132802895
-0.0115321415647
-0.0169321895674
-0.0219368263286
-0.0264861002839
-0.0302974005984
-0.032511823318
-0.0323584313976
-0.0319935449622
-0.0314248560255
-0.0311699959454
-0.119180771119
-0.119167133212
-0.119140568958
-0.119101314881
-0.119048868661
-0.118982008274
-0.118899399998
-0.118800649082
-0.118684240755
-0.118550709095
-0.118398797025
-0.11822721637
-0.118034901173
-0.117819825932
-0.117579643675
-0.117309589813
-0.117004696552
-0.116660317649
-0.116271922791
-0.115837968859
-0.115353893988
-0.114811836798
-0.114207569429
-0.113531475129
-0.112771097545
-0.11190891532
-0.110940854982
-0.109847169335
-0.108602047727
-0.107173612154
-0.105529300758
-0.103647936301
-0.101471199725
-0.0989354284854
-0.0959386613522
-0.0923753352062
-0.0882274884505
-0.083815589538
-0.0800179262721
-0.0884402425847
-0.063411356481
-0.0427400093116
-0.0713958748941
-0.0663378311679
-0.0576986376976
-0.0477889010893
-0.0380198211443
-0.0294917564207
-0.0220868676068
-0.0158838036957
-0.0107031632899
-0.00636988994838
-0.00269940611984
0.000466329538812
0.00324951876742
0.00573269317249
0.00796135003241
0.00994627181211
0.0116666921038
0.01307167727
0.0140799333767
0.0145783456348
0.0144252618204
0.0134665076381
0.0115664363902
0.00864741389936
0.00472703201867
-5.7096452098e-05
-0.0054496030346
-0.011117298365
-0.0166839345134
-0.0217206316255
-0.0259256034629
-0.0296246154389
-0.033095003434
-0.0350848209377
-0.0326771433768
-0.0317767984658
-0.0312114752631
-0.0309626480809
-0.11907675871
-0.119063761443
-0.119037484498
-0.11899819804
-0.118945468052
-0.118878432206
-0.118795798995
-0.118696291797
-0.118578585159
-0.118443055836
-0.118289014246
-0.118114977027
-0.11791950041
-0.11770133168
-0.117456799675
-0.117182028915
-0.116873938292
-0.116526204652
-0.116133378684
-0.115690701689
-0.115193547593
-0.114639372779
-0.114019345045
-0.113320039835
-0.112533834806
-0.111645882063
-0.110642501456
-0.109504201472
-0.108198864731
-0.106702840038
-0.105009478117
-0.103055888956
-0.10077236752
-0.0980884995448
-0.0948850362867
-0.0910319825021
-0.0864602657995
-0.0810243161997
-0.0755198505729
-0.0818761391072
-0.0694890148531
-0.0377559630765
-0.0657929197256
-0.0586862383926
-0.0504820449452
-0.0405973047932
-0.031048746939
-0.0227870325593
-0.0156866125642
-0.00981270270237
-0.0049586523919
-0.000943891997809
0.00242095135346
0.00529050480395
0.00777956514754
0.00996031397353
0.01186551205
0.0134911696218
0.0147995707638
0.0157206647264
0.0161523334887
0.0159610441529
0.0149914673384
0.0130938450601
0.0101676410951
0.00620724513038
0.0013323547692
-0.00420367764432
-0.0100323179672
-0.015743733613
-0.0209927850715
-0.0254563102976
-0.0287742199756
-0.0313413821059
-0.0347664054704
-0.0332572228241
-0.0319981398506
-0.0312336715095
-0.030777482416
-0.0305713144616
-0.118986459496
-0.118974252709
-0.11894844873
-0.118909515674
-0.11885702433
-0.118790294971
-0.118708703904
-0.118609820826
-0.118491995781
-0.11835520425
-0.118199772547
-0.118024311065
-0.117827061166
-0.11760670553
-0.117359093028
-0.117081463349
-0.116772258218
-0.116423876211
-0.116027609732
-0.115584685372
-0.115083114941
-0.114515950881
-0.113882163174
-0.11317004544
-0.112366199617
-0.111459310817
-0.110431316841
-0.109257267673
-0.107918936185
-0.106413073227
-0.104690899303
-0.102689920892
-0.100364938185
-0.097627190061
-0.0943476743501
-0.0903334053899
-0.0853226347174
-0.0776633343658
-0.0768198282537
-0.0796256270532
-0.0653126608303
-0.0261006136996
-0.0598651159757
-0.0513502831067
-0.043459373479
-0.0334426015821
-0.0241010058071
-0.0160976070481
-0.00930372198498
-0.00376078795376
0.000763441175087
0.0044548890091
0.00750699279596
0.0100697821674
0.0122497954942
0.0141077863344
0.0156625906364
0.0168940665902
0.0177461409515
0.0181286529218
0.0179190532974
0.0169671261436
0.01511388126
0.0122323898739
0.0082830001235
0.00336003025535
-0.00229613039873
-0.00832505472305
-0.0142810980484
-0.0196943705129
-0.0242620138021
-0.028014331428
-0.0309822920658
-0.0327452842139
-0.0325873985607
-0.0319356705126
-0.0311341869795
-0.0305655033682
-0.0302166642619
-0.0300538920827
-0.118910552969
-0.118898514209
-0.118873214472
-0.118834825954
-0.118783060804
-0.118717447218
-0.118637050418
-0.118540059978
-0.118424157964
-0.118287948198
-0.118131889365
-0.117955703545
-0.117757818059
-0.117535882594
-0.117288142439
-0.117011077436
-0.116701093274
-0.116352400134
-0.115958548212
-0.115515113653
-0.115013846916
-0.114443918456
-0.113800777081
-0.113079759691
-0.112269687113
-0.111352117293
-0.110307240085
-0.109121778341
-0.107788557873
-0.10627895522
-0.104548783794
-0.102566985692
-0.100283412325
-0.0976348180247
-0.0945311600286
-0.0909124918938
-0.086663382066
-0.0816493096137
-0.0787692267308
-0.0844787454514
-0.0258422505189
-0.00631770495599
-0.0526857098309
-0.0436088538698
-0.0364744140187
-0.0263754048739
-0.0172536975394
-0.00948380204302
-0.0029828784584
0.00223895611512
0.00643813571034
0.00980692295986
0.0125426525162
0.0147901375333
0.0166470676029
0.0181618416288
0.0193382810205
0.0201388824324
0.0204882037347
0.0202758170078
0.0193607535721
0.0175827932702
0.0147936449655
0.0109117557249
0.0059846852252
0.000229925522793
-0.00597839534795
-0.0121882749997
-0.017946454119
-0.0227966730168
-0.0264617246613
-0.0294263039819
-0.032354508239
-0.0342343327479
-0.0319984311089
-0.030991719379
-0.0302908156726
-0.0298394115649
-0.029569060167
-0.0294406116469
-0.11884846966
-0.11883623466
-0.118811404678
-0.11877375683
-0.118723103746
-0.118658979497
-0.11858064715
-0.11848633427
-0.118373995903
-0.118241174232
-0.118086069088
-0.117909894868
-0.11771230598
-0.117491052624
-0.117243768771
-0.116968639752
-0.11666021421
-0.116313417909
-0.115923499
-0.115484905714
-0.1149878838
-0.114418159414
-0.113773668497
-0.113051798427
-0.112241585081
-0.111324803692
-0.110279766118
-0.109101345027
-0.107776605718
-0.10627738044
-0.104579304677
-0.10265459692
-0.100481243046
-0.0980264244985
-0.0952806228668
-0.0922851779901
-0.0891461974694
-0.0860606380982
-0.0844419604791
-0.0923333228769
-0.0152949000157
-0.000209738340404
-0.0477403216759
-0.0360270914423
-0.0296908004386
-0.0194650065038
-0.0105556052964
-0.00298468525364
0.00324387674359
0.00816127589457
0.0120453287942
0.0150958148405
0.0175139451085
0.0194389765623
0.0209592847161
0.0221100636618
0.0228791355386
0.0232106567931
0.0230093289085
0.0221452758937
0.0204629466109
0.0178020932796
0.0140442649581
0.00918021218633
0.00337109745722
-0.00302722602534
-0.00950621718265
-0.0155428637912
-0.0207724836733
-0.0249373391649
-0.0277671370977
-0.0298842111502
-0.0329998116307
-0.0318054392105
-0.0306509063719
-0.0298788504291
-0.0293529646325
-0.029018823497
-0.0288187334719
-0.0287076765304
-0.118799084555
-0.118786937865
-0.118762683153
-0.118726122906
-0.118677040803
-0.118614980386
-0.118539315663
-0.118448657279
-0.118340612261
-0.118212872545
-0.118062348598
-0.117887703612
-0.117691374324
-0.117471959653
-0.117227056787
-0.116953774054
-0.116649453014
-0.116308012155
-0.115924255306
-0.115491919017
-0.115000490566
-0.114439291355
-0.113800770654
-0.113084688229
-0.112281575762
-0.111371686879
-0.110340607849
-0.109176943231
-0.107869146989
-0.106402819144
-0.104759607775
-0.102927767803
-0.100898867659
-0.0986785245615
-0.0963085430836
-0.0938845364629
-0.0915938490563
-0.0898343257879
-0.0883982702159
-0.0992242417635
-0.0166434763376
-0.00224771743689
-0.0454807058661
-0.0298099058817
-0.0236263782342
-0.0128764123184
-0.00406707988185
0.00337038030016
0.00935614501128
0.013989997637
0.0175712200481
0.0203094758026
0.0224098898465
0.024005904838
0.0251760735422
0.0259415489257
0.0262732712565
0.0260964252125
0.0252961280323
0.023725284257
0.0212201829527
0.0176350107711
0.0129059574975
0.00712608519382
0.000591495903117
-0.00620736348926
-0.0126591759956
-0.0181963190869
-0.0225805183533
-0.0260605849338
-0.0288444821872
-0.0305563232363
-0.0304122295891
-0.0299612856943
-0.0292479741328
-0.0287045692926
-0.0283308252199
-0.0280948055219
-0.0279512441172
-0.0278679083843
-0.118761878419
-0.118750169809
-0.118726835229
-0.118691818566
-0.118644826098
-0.118585421509
-0.118512917782
-0.118426399752
-0.118323264309
-0.118201092122
-0.118057722473
-0.117889323287
-0.117696029623
-0.117479225238
-0.117237687654
-0.116968777802
-0.11666866237
-0.116334434306
-0.115959053422
-0.11553527632
-0.1150545318
-0.114504657706
-0.113880029985
-0.113174997997
-0.112382715957
-0.111490227579
-0.110478473836
-0.109337690129
-0.108061512574
-0.106640717502
-0.10506353694
-0.103326993717
-0.101449738302
-0.0994523209053
-0.0973937616917
-0.0953967611295
-0.0936725638099
-0.0926402701035
-0.0919503482136
-0.102147579839
-0.0166958808498
-0.0027134338321
-0.0430631509015
-0.0244670551719
-0.0181865992935
-0.00661748903456
0.0021931749423
0.00957067171769
0.0153459455197
0.0197179361597
0.0230084526325
0.0254404439169
0.0272229254133
0.0284831890113
0.0292893161182
0.0296475431326
0.02951118646
0.0287862690475
0.0273395024149
0.02501027538
0.0216355309548
0.0171019616891
0.0114286470844
0.00483971677189
-0.00222285770228
-0.0091527265595
-0.0152842539065
-0.0200529653606
-0.0233459876981
-0.0261610752455
-0.0295572654575
-0.0316018245524
-0.0295118039959
-0.0285613676785
-0.0279084405556
-0.0274827472474
-0.0272203644601
-0.0270642067444
-0.0269657038435
-0.0269206679244
-0.118736913712
-0.118725848504
-0.118703882691
-0.118670776103
-0.118626205983
-0.118569800243
-0.118500881332
-0.118418583676
-0.118321199765
-0.118205338422
-0.118068986108
-0.117909785663
-0.117725226254
-0.117513999601
-0.11727682907
-0.11701305211
-0.11671954128
-0.116392210995
-0.116027131082
-0.115615663273
-0.11514836258
-0.114615636304
-0.114006925925
-0.113318472928
-0.112544940332
-0.11167203467
-0.110687144363
-0.109578707852
-0.108340621523
-0.106969935851
-0.105461256248
-0.103821832328
-0.102071439909
-0.10023953366
-0.0983895308251
-0.0966546890481
-0.0952008861856
-0.0943307765328
-0.0936669123899
-0.102081431703
-0.0129560745934
0.000714188633342
-0.0391368467358
-0.019007104435
-0.0128238569617
-0.000483879344063
0.00829858124722
0.0156443238711
0.0212229658345
0.0253474717589
0.0283557277538
0.0304855605747
0.0319488011858
0.0328658523236
0.033293387188
0.0332217728638
0.0325860988648
0.0312735318906
0.0291345818102
0.0260007183867
0.0217218605675
0.0162410019123
0.00969598653761
0.00247670915265
-0.00482513882284
-0.0115254314229
-0.0169646160717
-0.0207393325517
-0.0230581492389
-0.0253526609461
-0.0299963564217
-0.0286582655601
-0.0276189690717
-0.0269167345962
-0.026444750342
-0.0261426105946
-0.025966974843
-0.0258779480255
-0.0258072752177
-0.0257853183981
-0.118724299214
-0.118713969371
-0.118693453685
-0.118662284256
-0.118620246303
-0.118567007629
-0.118501963919
-0.118424249544
-0.118332867939
-0.118224665365
-0.118095732733
-0.117944420386
-0.117772126723
-0.117573689649
-0.117344464097
-0.117087525551
-0.116801009829
-0.116483226413
-0.116128321368
-0.115731038611
-0.115281142006
-0.114767705067
-0.11418098596
-0.11351345508
-0.112762955635
-0.111918523535
-0.110963511303
-0.109890791731
-0.108696366221
-0.107378531252
-0.105933704301
-0.104371625007
-0.102719025828
-0.100995719583
-0.0992686083745
-0.0976436766155
-0.0962370578392
-0.0952295843515
-0.0941737916639
-0.1007952007
-0.00735497994471
0.00630758758047
-0.0342242854627
-0.0131367820494
-0.00722131978492
0.00570042028789
0.0143462337993
0.0216397631108
0.0270090590825
0.030888150056
0.0336163531918
0.0354450635962
0.0365861000967
0.037151528053
0.0371852925082
0.0366608724006
0.0354948018756
0.0335564395281
0.0306837372519
0.0267084594314
0.021510281986
0.0151163585184
0.00781808975731
0.000198589742274
-0.00702957298594
-0.0132421368167
-0.0179266557259
-0.0209826530309
-0.0235347804801
-0.0258339618467
-0.0255402734688
-0.0259424128723
-0.0255544619294
-0.025154518069
-0.0248457423371
-0.0246353130076
-0.0244996763733
-0.0244379526452
-0.024390750345
-0.0243565374273
-0.118722890975
-0.118713160145
-0.118693901399
-0.118664709999
-0.118625334431
-0.118575458427
-0.118514576241
-0.118441890677
-0.118356370338
-0.118256602368
-0.118138701025
-0.117997677244
-0.117833199947
-0.117646970012
-0.117433900727
-0.117190326219
-0.116913958959
-0.116606657945
-0.116264462432
-0.115881505285
-0.115451346614
-0.114961549409
-0.114398918758
-0.11375808236
-0.113036453873
-0.112221870327
-0.111302932806
-0.110270350221
-0.109119870584
-0.107851710989
-0.106462530459
-0.104963087723
-0.10336454982
-0.101700953285
-0.100025781124
-0.0984059550256
-0.0969159862938
-0.0956441049774
-0.094230009008
-0.0996154531827
-0.001535993534
0.0124162900286
-0.029119527852
-0.00705547045996
-0.00141946931506
0.0119526505275
0.0203755352566
0.0275863422875
0.0327215868264
0.0363496077177
0.0387950106949
0.0403209975719
0.0411354483511
0.041340140645
0.0409646466757
0.0399645182658
0.0382376987648
0.0356374635456
0.0319938753947
0.0271490517626
0.0210334736283
0.0137894876164
0.00588908132205
-0.00187148448974
-0.00867343253535
-0.0141568688637
-0.0182786193401
-0.0207772910824
-0.0228420050975
-0.0270794305603
-0.0246599648201
-0.0241265954731
-0.0236819889208
-0.0233579016009
-0.0231230713347
-0.0229544495365
-0.0228297144106
-0.0227476296127
-0.0227133442354
-0.0226553092246
-0.118731527891
-0.118722150904
-0.118704041182
-0.118676790316
-0.118640135186
-0.11859380411
-0.118537395014
-0.11847019516
-0.118391223167
-0.118299330474
-0.11819271035
-0.118066806631
-0.117915415289
-0.117738283069
-0.117538228141
-0.117312134882
-0.117054403797
-0.116763046035
-0.116435595246
-0.116069229894
-0.115658906637
-0.115194289608
-0.114661179901
-0.114050994275
-0.113362009837
-0.11258449678
-0.111702877412
-0.110711758441
-0.109607530846
-0.108385503086
-0.107038674096
-0.105574502174
-0.104012015568
-0.102368805665
-0.100686808108
-0.0990168435168
-0.0973964582194
-0.0958512718574
-0.0942377014722
-0.0989430721078
0.00396403364501
0.0183997735829
-0.0241675792673
-0.000964504957229
0.00443267741825
0.018203309553
0.0263685135058
0.0334816966791
0.0383632923291
0.0417354057288
0.0438943922014
0.0451154405717
0.0455986110222
0.0454334994058
0.044633593901
0.0431356186153
0.0408194052506
0.0375250381025
0.0330813440739
0.0273544163797
0.020355165456
0.0123823341174
0.00410189285168
-0.00349968756103
-0.00947043148527
-0.0137550755353
-0.0174697395854
-0.0210365330444
-0.0229535583633
-0.0220654839075
-0.022252335837
-0.0219815413564
-0.0216913375529
-0.0214545972225
-0.0212756191752
-0.0211397188541
-0.0210339744455
-0.0209477373239
-0.0209084489203
-0.0208756083764
-0.118748919157
-0.118740092929
-0.118723127632
-0.118697820123
-0.118663957047
-0.118621330133
-0.118569635905
-0.118508279699
-0.118436382143
-0.118352825304
-0.118256324432
-0.118144639159
-0.1180126493
-0.117852879489
-0.117664654161
-0.117452745963
-0.117214260373
-0.116944863457
-0.116640322086
-0.116296100683
-0.11590677449
-0.115467230263
-0.114967226163
-0.114392888807
-0.113740598625
-0.113001031254
-0.112162804982
-0.111216570403
-0.110156919038
-0.108975439276
-0.107660071969
-0.106218681411
-0.104673104962
-0.10302633745
-0.101309922231
-0.0995593660086
-0.097794399176
-0.0960134326574
-0.0943612956755
-0.0986716683956
0.00914067482291
0.0241588203761
-0.0193930128108
0.0050695230238
0.0102414824529
0.0243917563473
0.0322925306996
0.0393074906012
0.0439260510062
0.0470427597483
0.0489141824015
0.0498296536476
0.0499779823243
0.0494351226917
0.0481969433965
0.0461807453752
0.0432493190148
0.0392335807152
0.033969189067
0.02736052253
0.0195303743147
0.010980202104
0.00257752385697
-0.00457095543666
-0.00934679222929
-0.0118106964348
-0.0150214759692
-0.0208879623093
-0.0240591598398
-0.0211572361838
-0.0203963528455
-0.019937199718
-0.0196510169477
-0.0194570540754
-0.0193196481277
-0.0192174250287
-0.0191385900124
-0.0190707336094
-0.0190350627283
-0.0190266789015
-0.118773238107
-0.11876553797
-0.118750135212
-0.118727155013
-0.118696379174
-0.118657721179
-0.118610900139
-0.118555548832
-0.118490968164
-0.118416164391
-0.118329883934
-0.118230670552
-0.11811563841
-0.117978781971
-0.117813124636
-0.11761751069
-0.117396500445
-0.117148292396
-0.116868928736
-0.116553062166
-0.116193706797
-0.115783529795
-0.115316957504
-0.114782431108
-0.114171412836
-0.11347546312
-0.112682124033
-0.111784641355
-0.110770074402
-0.109619682754
-0.108334346988
-0.106918382948
-0.105367831756
-0.103699256177
-0.101935346807
-0.100090480044
-0.0981946762088
-0.0962352155535
-0.0945310302266
-0.0987755867371
0.0140433898152
0.0297081625726
-0.0147466107492
0.0110444386987
0.0159734061602
0.0304903926637
0.038124798495
0.0450458810745
0.0493991083319
0.0522659706832
0.0538522247878
0.0544643355074
0.0542765668324
0.0533501799223
0.0516620897298
0.0491099129044
0.0455410655431
0.0407827275361
0.0346887904769
0.027223028171
0.0186660276347
0.0097988456747
0.00174969403354
-0.00436960716811
-0.00762621320841
-0.00821234954915
-0.0110486663335
-0.0213718586079
-0.0190940403827
-0.0183729325529
-0.017929845009
-0.0176543446016
-0.0174676645919
-0.0173423889353
-0.0172548319308
-0.0171912730719
-0.0171428431838
-0.0170946158629
-0.0170757214054
-0.0170821285074
-0.118803238207
-0.118796938464
-0.118783745796
-0.118763457978
-0.118736255824
-0.118702076205
-0.118660553021
-0.118611373563
-0.118554182332
-0.118488290224
-0.118412573636
-0.118325616072
-0.118225750548
-0.118108829585
-0.117968736032
-0.117799397698
-0.117601426195
-0.117376135902
-0.117122694841
-0.116836494838
-0.116511236212
-0.116138335716
-0.115710449553
-0.115219376567
-0.114654884032
-0.114007169002
-0.113266034271
-0.112417623279
-0.111443801747
-0.110333757113
-0.109080634913
-0.107677934746
-0.106122421818
-0.104418806445
-0.102589747926
-0.100659916058
-0.0986591669646
-0.0965487071002
-0.0947467483603
-0.0991390678367
0.0187120358883
0.0350500946165
-0.010194863079
0.0169628193202
0.0216157571158
0.0364878875473
0.0438515870393
0.0506837417203
0.0547731043997
0.0573991531688
0.0587060356886
0.0590203523286
0.0584983619874
0.0571858414716
0.0550396250691
0.0519379320541
0.0477155357094
0.0422034442759
0.0352895656552
0.0270251433001
0.0178924059453
0.00897411208747
0.00159751668625
-0.00339167548166
-0.00616356898694
-0.0079249277437
-0.0103318530723
-0.0118123658325
-0.0145136808125
-0.0151018732613
-0.0152361351526
-0.0152253723705
-0.0151767101595
-0.015134873611
-0.015103102748
-0.0150806057308
-0.0150664358667
-0.0150457100509
-0.0150439848873
-0.0150566555176
-0.118838598414
-0.118833404586
-0.118822639139
-0.118805092708
-0.11878164117
-0.118752306024
-0.118716741594
-0.118674462959
-0.118625084539
-0.118568207837
-0.118503267036
-0.118429015196
-0.118343939694
-0.118246281345
-0.118130696728
-0.117990030363
-0.117820280662
-0.11762502322
-0.117402255067
-0.117147395568
-0.116858786991
-0.116528162673
-0.116146063537
-0.115703121251
-0.115190963827
-0.114599675498
-0.113913508378
-0.113118570248
-0.112195608995
-0.111128587137
-0.109908172517
-0.108518760017
-0.106951219551
-0.105205647443
-0.103304840708
-0.101297739599
-0.0992079404429
-0.0970531700881
-0.094998298311
-0.0997759919583
0.0231577940763
0.04016647874
-0.00571269660381
0.0228218740002
0.0271563781679
0.0423739058311
0.0494607916496
0.0562098585661
0.0600395979447
0.0624366969853
0.0634733442477
0.0634991175566
0.0626485882278
0.0609513814365
0.0583431627507
0.054683312669
0.049797122543
0.0435271598358
0.03581017338
0.026810628574
0.017245477431
0.00845664200759
0.00179264817226
-0.00226913557948
-0.00497216273599
-0.00899132893549
-0.0118128852187
-0.010917469162
-0.0119756228733
-0.01246099985
-0.012706759711
-0.0128185386107
-0.0128698093409
-0.0129013821272
-0.0129243223121
-0.0129421548904
-0.012956493272
-0.012971572066
-0.0129924805295
-0.0130128957895
-0.118878037873
-0.118873740917
-0.118865104286
-0.118850490211
-0.118830970242
-0.118806721615
-0.118777431212
-0.118742679398
-0.118701977048
-0.118654802629
-0.11860079929
-0.118539442598
-0.118469595888
-0.118389705523
-0.118297750585
-0.118187965795
-0.118051113228
-0.117887782012
-0.117700770996
-0.117485110129
-0.117238042731
-0.116951305886
-0.116619753257
-0.116233811888
-0.11578252047
-0.115251073164
-0.114630298521
-0.113898712868
-0.11303108615
-0.112016315984
-0.110833705072
-0.109460356173
-0.107875775169
-0.106083896032
-0.104111557844
-0.10200297623
-0.099804915329
-0.0976328064258
-0.0960945428849
-0.0999143350334
0.0274820006858
0.0450645523807
-0.00124080331201
0.0286184359372
0.0325805039724
0.0481347702708
0.0549382206893
0.0616121243092
0.065189465027
0.0673725534606
0.0681517931901
0.0679024799682
0.0667336964076
0.0646583719996
0.0615899732131
0.0573700651663
0.051818856661
0.0448006294064
0.0363190866689
0.0266845907319
0.0169019194715
0.0085516277011
0.00279818932348
-0.000464412849163
-0.00268355084505
-0.00648632889618
-0.0135405909858
-0.0101240129876
-0.00998856148837
-0.0101245927239
-0.0103216581477
-0.0104870521489
-0.0106103508677
-0.0107103114347
-0.0107929520655
-0.0108602601266
-0.0109120210484
-0.0109591772228
-0.0109925824376
-0.0110076457054
-0.118920108331
-0.118916581286
-0.118909852605
-0.118898420293
-0.118883016383
-0.118864032775
-0.118841215241
-0.118814211034
-0.11878260214
-0.118745933422
-0.118703651164
-0.118655456385
-0.11860080784
-0.118538892145
-0.11846810914
-0.118386010892
-0.11828720693
-0.118163133305
-0.118014045212
-0.117842672215
-0.117643218607
-0.117409836009
-0.117134942131
-0.11681328447
-0.116428690856
-0.115969831031
-0.115422555108
-0.114763739509
-0.113969638514
-0.113017308442
-0.111877426416
-0.110524688114
-0.108933582301
-0.107096414076
-0.105023165419
-0.102732335591
-0.100296802243
-0.0977365851428
-0.0973179598833
-0.0986179256288
0.0316754355766
0.049842675846
0.00327195795351
0.0343312964055
0.0378678592545
0.0537527692992
0.0602668660884
0.0668764374797
0.0702119007067
0.0721994279198
0.0727383182379
0.0722322705738
0.0707610808531
0.0683205086443
0.0648007499773
0.0600265990525
0.0538178061589
0.0460709866195
0.0368731299743
0.0267079419701
0.0169255372961
0.00934697912048
0.00485621729381
0.00229131563734
-0.00200809256058
-0.00705484703295
-0.00635229454043
-0.0070877692246
-0.00740012375647
-0.00769219552804
-0.00796426479516
-0.00820967364814
-0.0084166261332
-0.00859234731704
-0.00874168754581
-0.00886575315496
-0.00896573847668
-0.00903929087256
-0.00907789544269
-0.00907657224583
-0.118963516014
-0.118960705956
-0.11895596309
-0.118947923719
-0.118936661182
-0.118923062318
-0.118906848268
-0.118887692169
-0.118865255108
-0.118839205065
-0.118809214801
-0.118774926933
-0.118736009797
-0.11869205457
-0.118642329867
-0.11858584128
-0.118521059052
-0.118441493369
-0.118340213501
-0.118217733761
-0.118071209213
-0.11789896225
-0.117692853071
-0.117441463943
-0.117131397001
-0.116757003905
-0.116300502007
-0.115730037642
-0.115019484839
-0.114142699096
-0.113069369115
-0.111754581992
-0.110166086108
-0.108278752366
-0.106077754379
-0.103553864628
-0.100721996568
-0.0972195103803
-0.0975883057623
-0.0984670530772
0.0368550587504
0.0547015914145
0.00784888134488
0.0399230906591
0.0429931471525
0.059206179065
0.0654268677808
0.0719864532327
0.0750938765391
0.0769081347071
0.0772283897244
0.0764896166491
0.0747385002326
0.0719533262202
0.0680000100948
0.0626881579221
0.0558434619653
0.0474125500974
0.0376000452782
0.027125262947
0.0178158436246
0.0117883744619
0.00924425197499
0.00792327840408
0.00300941141259
-0.00964965262412
-0.00510405733612
-0.00480571367655
-0.00494000273595
-0.00527702706895
-0.00563860194184
-0.00597829018793
-0.00628656847102
-0.00654769435425
-0.00676731830173
-0.00694701491297
-0.0070893996541
-0.00718779050498
-0.00724670819882
-0.00725835655661
-0.119007384354
-0.119005197478
-0.119002481649
-0.118997662313
-0.118990638348
-0.118982622822
-0.118973179168
-0.118961923255
-0.118948579692
-0.118933000021
-0.118915121378
-0.118894901661
-0.118872296384
-0.118847068903
-0.118819166067
-0.118788630166
-0.118754931154
-0.118716345231
-0.118668027644
-0.118603453644
-0.118519465378
-0.118415362286
-0.118283350995
-0.118109992227
-0.117892326246
-0.117615839424
-0.11725944701
-0.116796011869
-0.116195335969
-0.115421845978
-0.114429289263
-0.113176150933
-0.11161968798
-0.109709220601
-0.107405624313
-0.104688022891
-0.101528391522
-0.0972890764778
-0.097731959429
-0.0988210137303
0.0404796448656
0.0590176934629
0.0122889170635
0.0453051836841
0.047919541099
0.0644684512327
0.0703957686663
0.0769232416273
0.0798196279757
0.081486661386
0.0816151073357
0.0806740026903
0.0786734150757
0.0755737524275
0.0712158098132
0.0653957644503
0.0579515366047
0.0488981179201
0.0385989945598
0.028055605997
0.0195928571353
0.0156914420924
0.0152748336568
0.0111040424983
0.00229891925583
0.00236230631693
-0.000511921895356
-0.0014370883891
-0.00213945274459
-0.00274958626106
-0.00330321026384
-0.0037852780404
-0.0042109539319
-0.00456705210383
-0.00486143378502
-0.00509953009405
-0.00528499106
-0.00540682213819
-0.00549110570949
-0.00553120771897
-0.119050348284
-0.119048998277
-0.119048012274
-0.119045814671
-0.119043580017
-0.119041433316
-0.119038826268
-0.119035224861
-0.11903049939
-0.119024814174
-0.119018487115
-0.119011909182
-0.119005498287
-0.11899965223
-0.118994947243
-0.118992257099
-0.118991852436
-0.118992443837
-0.118992158072
-0.118986590281
-0.118972012246
-0.118944266125
-0.118893523549
-0.118814238717
-0.11870345226
-0.118540474063
-0.118307514422
-0.117974560676
-0.117505012091
-0.116859584627
-0.115991288368
-0.11484153558
-0.113351427564
-0.111449524077
-0.109115658304
-0.106325721336
-0.10311702057
-0.0994056732609
-0.0978581354262
-0.101696196671
0.0430991308516
0.0629294245834
0.0164154680986
0.0503925063702
0.0526077098999
0.0695107825206
0.0751488768404
0.0816655167067
0.0843697641828
0.0859194195579
0.0858877601258
0.0847819049091
0.0825712559365
0.0791984693298
0.0744778453648
0.0681945831893
0.0602059266001
0.0506155166243
0.0400175458294
0.0298641440376
0.0229588194752
0.021626491021
0.0243076937706
0.0191511270264
-0.00234774103385
0.003520666175
0.00268138757055
0.00168225813456
0.000681364923679
-0.00019997287349
-0.000967979816082
-0.00162801835549
-0.00218198243619
-0.00263898470675
-0.0030101764354
-0.00330615986652
-0.00353143603089
-0.00368731320244
-0.00379825055524
-0.00386168415922
-0.119090367686
-0.119090422008
-0.119090638597
-0.11909080185
-0.119093153219
-0.119095856585
-0.119098550046
-0.119100789287
-0.119102995339
-0.119105956779
-0.119110534319
-0.119117666551
-0.119128383066
-0.119143802725
-0.11916531957
-0.119194109645
-0.119229751128
-0.119271023478
-0.119316539242
-0.119365676188
-0.119419395949
-0.119471191401
-0.119514246888
-0.119546189139
-0.119558545994
-0.119530519552
-0.119439351194
-0.119258887778
-0.11895593026
-0.118478073251
-0.117781685964
-0.116795843745
-0.115421926603
-0.113581227346
-0.111235705241
-0.108376434402
-0.105040050933
-0.101158235523
-0.0987260636982
-0.103565962862
0.0460009654468
0.0667091936468
0.0202524864082
0.0552061992654
0.057049635169
0.0743120075384
0.0796631054509
0.0861880639004
0.0887203311087
0.0901844734836
0.0900302501426
0.0888046903954
0.0864346031627
0.0828436095445
0.0778189260078
0.0711367005974
0.062684791709
0.0526750857892
0.0419737547067
0.0326333299308
0.0278433881489
0.0276323442229
0.0273611457507
0.0219618049312
0.0174514789714
0.00994608037509
0.0070272714321
0.00507728164124
0.00358547410079
0.0023535092236
0.00134438544013
0.000494926422657
-0.000201326564901
-0.000765145210116
-0.00121440908777
-0.00156664567601
-0.00182826003802
-0.00202430562631
-0.00215826355442
-0.00223912060007
-0.119125259978
-0.119127027268
-0.119128276458
-0.119130255491
-0.119135520414
-0.119141961563
-0.119148324688
-0.119154959045
-0.119163273225
-0.119174711414
-0.119190624728
-0.119212471155
-0.119241847051
-0.119280337167
-0.119329673165
-0.119390659573
-0.119462193791
-0.119544688399
-0.119639424926
-0.119748321105
-0.119870343082
-0.120002272889
-0.120143700483
-0.120293532511
-0.120440308315
-0.120562367289
-0.120632858511
-0.120638678699
-0.120544946905
-0.120306494391
-0.119853848399
-0.119089312395
-0.117888473008
-0.116177282495
-0.113854898138
-0.110905403344
-0.107339772415
-0.103096634037
-0.0998374216154
-0.105225427595
0.0491700236699
0.070489797774
0.0239337397251
0.0598230195515
0.0612567554397
0.0788624779186
0.0839140109941
0.0904645155848
0.0928401547262
0.0942546547894
0.094017935866
0.0927267839111
0.090258039629
0.086519916432
0.0812684922875
0.074272864466
0.0654570281239
0.0551573772297
0.0444799246574
0.0359852632187
0.0334514089381
0.0344220950177
0.027786282574
0.0168411031705
0.0159852253042
0.0132054048169
0.0104633168213
0.00821699722838
0.00638021584166
0.00485456987935
0.00358757249098
0.00255063561599
0.00170492595218
0.00102681193816
0.000496038573782
8.73277069238e-05
-0.000215904847684
-0.000442380298744
-0.00059245148334
-0.000676786462931
-0.119155258048
-0.119158131657
-0.119160885285
-0.119164861221
-0.119172179485
-0.119181259686
-0.119189935225
-0.119200699448
-0.119215663328
-0.119236633147
-0.119265153135
-0.119303102592
-0.119352423916
-0.119414438424
-0.119490828699
-0.119582241136
-0.119689195692
-0.119814245093
-0.119960871227
-0.120131307114
-0.120324285198
-0.120540733992
-0.120782348993
-0.121049310468
-0.121331252323
-0.121611479308
-0.1218738607
-0.122113759912
-0.122295661627
-0.12236383319
-0.122225228558
-0.121757455385
-0.120840848007
-0.11933817363
-0.117095553649
-0.114049068309
-0.110174566034
-0.105391056105
-0.101172363916
-0.106814673794
0.0523746552851
0.0742174019315
0.0275233002747
0.0642941367389
0.0652447979347
0.0831461941991
0.0878783476074
0.0944520104914
0.0966901655993
0.0980851859237
0.0978164318694
0.096519622492
0.0940309599419
0.0902349768684
0.084861978426
0.0776671503321
0.0686151609562
0.0581976954083
0.0478588338128
0.0405770530503
0.0403379500878
0.0444197015726
0.0368704255997
0.00994466829074
0.0175607353923
0.0160807596503
0.0137091909383
0.0112370965522
0.00905066255006
0.00723181690187
0.00572345463187
0.00449322388529
0.00349670717973
0.00270119289795
0.0020874761873
0.00161969398189
0.00126990720245
0.00101646673939
0.000848726411446
0.000765387024697
-0.119182882871
-0.119185898197
-0.119190252468
-0.119197554585
-0.119205976884
-0.119214211562
-0.119224735849
-0.119240512399
-0.119263471328
-0.119295759443
-0.119338672397
-0.119394007095
-0.119463045128
-0.119547218907
-0.119648727019
-0.119769089848
-0.119911142954
-0.120078920859
-0.120276556859
-0.120506735098
-0.120771422612
-0.121073997634
-0.121418348563
-0.121807060063
-0.122234378391
-0.122690189816
-0.123172173664
-0.123679358881
-0.124183418841
-0.124625744276
-0.124904954762
-0.124873729577
-0.124382378768
-0.123210452185
-0.121133362853
-0.118019303423
-0.113790930922
-0.108401708438
-0.102751941202
-0.108448531181
0.0556361402583
0.0778327162934
0.0310441397205
0.0686076709931
0.0689703939637
0.0871425580749
0.0914985366301
0.0981170146379
0.100211289255
0.101636452522
0.101372496117
0.100146092932
0.0977162755963
0.0939747954769
0.0886086079942
0.0813821246645
0.072294544638
0.0620081373279
0.0524337348493
0.0471164130618
0.0478281743479
0.0479729418608
0.0405626188931
0.0342877257926
0.0254291300626
0.0210455736887
0.0174398525591
0.0143421978902
0.0116832060653
0.00948571843796
0.00770911627773
0.00628144853202
0.00513733464956
0.00422403854274
0.00351616989498
0.00298316339719
0.00259151237227
0.00231722152729
0.00213070253323
0.00204899379852
-0.11920918615
-0.11921108216
-0.11921583599
-0.119223334875
-0.119230568684
-0.11923960797
-0.119254613903
-0.119278036618
-0.119311579944
-0.119356458841
-0.119413222309
-0.119483604774
-0.11956927027
-0.119672934561
-0.119797526301
-0.119946198345
-0.120123041065
-0.120332930933
-0.120580778421
-0.120870254016
-0.121205889654
-0.121594172177
-0.122043108115
-0.122557862181
-0.123138660342
-0.123784500379
-0.124507636268
-0.125312331354
-0.126186362957
-0.12708395843
-0.127888155187
-0.128446055762
-0.128591182557
-0.127953601968
-0.126200682635
-0.123091567663
-0.118470946989
-0.112163580238
-0.105062140113
-0.109827256846
0.0589419322167
0.0815557001967
0.0346017649551
0.0728000180291
0.0724776762008
0.0907724154859
0.0947547832755
0.101339351051
0.103346991602
0.104795355444
0.104626806957
0.103527446879
0.10128721178
0.0977285996547
0.092560231288
0.0855124101054
0.0766616014039
0.066736444197
0.0579820290381
0.0550279958315
0.0576390738929
0.0492951071304
0.0344143839594
0.0327726981676
0.0290793334139
0.0250145814253
0.0210177939212
0.0173515575837
0.0142188876305
0.0116196684453
0.00953287404603
0.00788657792797
0.00659269776102
0.00557170650757
0.00477493718241
0.00417270736206
0.00373449873651
0.00344370853363
0.00324242534995
0.00315431438725
-0.119231031667
-0.119231856041
-0.119235957541
-0.119241941952
-0.119249181521
-0.119262689463
-0.119285274576
-0.119317725223
-0.119360543398
-0.119414658378
-0.119482056023
-0.119565063719
-0.119666190433
-0.119788585237
-0.119935947468
-0.120112724792
-0.120323762015
-0.120574155285
-0.120869087686
-0.121214345473
-0.121618014459
-0.122089632632
-0.122639374723
-0.123276416637
-0.124011056418
-0.124857276445
-0.125837001034
-0.126972058847
-0.128272306613
-0.129696157291
-0.131137026475
-0.13247819146
-0.133507829341
-0.133696759887
-0.132584876198
-0.129666710293
-0.124730873629
-0.11739871194
-0.107934504299
-0.111069816169
0.0629839892859
0.0853847508804
0.0382140791537
0.0767438927266
0.075529637583
0.094025707176
0.0974541537993
0.104149568381
0.10597112333
0.107574303573
0.1074701689
0.106618479067
0.104609140516
0.101392434838
0.0965769068827
0.0899883304569
0.0817580582585
0.0728625673578
0.0656588784601
0.0658949122674
0.0739806229805
0.0637370777828
0.0258396421591
0.0357092972532
0.0329697324676
0.0289735007947
0.0245883226993
0.0203243497906
0.0166161634492
0.0135907838247
0.0111764531825
0.00929113434941
0.00783741513614
0.00670912279536
0.00584011085686
0.00518604272099
0.00470358457085
0.00438434604612
0.00417515780755
0.00406507955343
-0.119247244827
-0.119247971337
-0.119251827503
-0.119257495344
-0.119266919409
-0.119286809342
-0.119315759837
-0.119353898218
-0.119403149001
-0.119465325277
-0.119542670109
-0.119637808288
-0.119753774303
-0.119894244675
-0.120063877261
-0.120267375222
-0.120508339289
-0.120792447133
-0.121127802731
-0.121523545579
-0.121989810146
-0.122537982033
-0.123180859783
-0.123934548155
-0.124821044713
-0.125867824151
-0.127109426348
-0.128590137174
-0.130346586606
-0.132364679014
-0.134585286193
-0.136928199117
-0.139112222029
-0.140496007331
-0.140519008021
-0.138271602103
-0.133311979647
-0.124956306007
-0.112359405572
-0.111715663694
0.0670839207595
0.0905960895488
0.0421183197295
0.0806750647776
0.078651598334
0.0965229955962
0.0998447092602
0.10602324714
0.108123961278
0.109532064955
0.109877721604
0.109151348625
0.107724580427
0.104939608219
0.10090062896
0.0950823052799
0.0880291595697
0.0808125472809
0.0764387703931
0.0782368208305
0.0815456567897
0.070931821448
0.059325001543
0.0466224793719
0.0393957297957
0.0334897554796
0.028171576017
0.0232443594408
0.0188810497107
0.0153669437544
0.012618025257
0.0104888651876
0.00886966228367
0.00763462205424
0.00668953317619
0.00598867843799
0.00547996882375
0.00513421703359
0.00491299086915
0.00478563411417
-0.119259879067
-0.119261264626
-0.119264362138
-0.119270107391
-0.119282645512
-0.119307345677
-0.119340250954
-0.119383422559
-0.11943879482
-0.119508475777
-0.119595006632
-0.119701384809
-0.119831084416
-0.119988280709
-0.120177205463
-0.120400872892
-0.120663779882
-0.120975171498
-0.121345779337
-0.121786225777
-0.122307942389
-0.122923824837
-0.123648901575
-0.124506343822
-0.125531911354
-0.126766852442
-0.128258704857
-0.130076035853
-0.132294003428
-0.134960509297
-0.138067285889
-0.141614361215
-0.145254882274
-0.148231687726
-0.149981252219
-0.149161825707
-0.145176489014
-0.135542834243
-0.120319479428
-0.112307810465
0.0770398960751
0.0951714834247
0.0453606210603
0.0840681394202
0.0799781268904
0.0989438126243
0.100721900868
0.107952315611
0.109225246309
0.111452879235
0.111469639176
0.111422196792
0.110057338228
0.108022869442
0.104542802157
0.0999791484611
0.0944934201542
0.0900429663374
0.0903397349503
0.0980795315004
0.0892461740799
0.0631760197553
0.0587833229344
0.0510282989988
0.0437945876099
0.0372633302398
0.0313033301883
0.0258552352023
0.0209330287117
0.0169099672964
0.0138313075056
0.0114744510312
0.00969476783061
0.00836147143523
0.00734771713036
0.00659082628456
0.00605087028226
0.00568958358732
0.00546779681541
0.00536227865483
-0.119267663273
-0.119269191286
-0.119272569248
-0.119280157932
-0.119295600278
-0.119322839071
-0.119359035476
-0.119406688198
-0.119467490585
-0.119543776417
-0.119638227233
-0.119754186207
-0.119895496895
-0.120065805303
-0.120268176286
-0.120505843008
-0.12078511557
-0.121118027
-0.121517504334
-0.121994569162
-0.122561962772
-0.123233930547
-0.124024673688
-0.124962743027
-0.126102624174
-0.127500845672
-0.129210353621
-0.131320800454
-0.133980051695
-0.137296248174
-0.141340100964
-0.146231624689
-0.151563907173
-0.156395780889
-0.160798862996
-0.161125949382
-0.16286051318
-0.151008538012
-0.134305545159
-0.111251552021
0.0905658778092
0.102018559692
0.0496448242533
0.0901273510531
0.0819099465544
0.100897188632
0.100905911574
0.10825438881
0.10911783328
0.11175586365
0.112016072346
0.112689427633
0.112063945003
0.111227751897
0.109197940693
0.106635875374
0.103728935624
0.102225296991
0.108236379713
0.129363337745
0.11571626382
0.0501383390284
0.0601865790956
0.0547288135052
0.0475588414815
0.0404648555376
0.0339172515685
0.0279929729574
0.0226266926151
0.0181597413131
0.0147855795672
0.0122385696028
0.0103226145186
0.00889528757875
0.00783041112128
0.00703763102196
0.00646867424544
0.00609087839302
0.00587021022244
0.00578867387408
-0.119271479404
-0.119273011013
-0.119278379175
-0.119288225975
-0.119304448367
-0.119333034624
-0.119371640544
-0.119423309391
-0.119488600577
-0.119569726321
-0.119669514742
-0.11979208269
-0.119941453699
-0.120121109482
-0.120333790111
-0.120581022577
-0.120870067803
-0.121217505542
-0.121637318676
-0.12213994104
-0.122741286715
-0.123453443183
-0.124280521621
-0.12526409076
-0.126487283367
-0.128014240228
-0.129893932709
-0.13223320323
-0.135228485302
-0.139103694243
-0.144037759673
-0.15024006747
-0.15732928452
-0.163774757891
-0.166894390727
-0.170994436157
-0.170212352125
-0.171955979585
-0.172065960921
-0.120053812117
0.159992804551
0.075999036216
0.0536792290323
0.0994972696323
0.0653400238987
0.116297008293
0.0856086380964
0.121288899169
0.0992008734905
0.1210792124
0.106383803237
0.118852695173
0.109051541644
0.115427908872
0.108271222363
0.111619976496
0.10791064028
0.117449456664
0.125341920156
0.164433116948
0.150435162671
0.1104647347
0.0699295567653
0.0614988407662
0.0515321056378
0.043201411369
0.0359310104007
0.0295426915217
0.0238412596789
0.0190369666076
0.0154364452688
0.0127752556446
0.0107642534183
0.00925886525635
0.00814783817935
0.00733094314837
0.00674434314528
0.00635252194224
0.00611897008201
0.00602689508076
-0.119272921818
-0.119274937215
-0.119282860276
-0.119294000799
-0.119310719839
-0.119335941219
-0.119375009083
-0.119430226828
-0.11949763548
-0.119580536909
-0.119683051922
-0.119809982017
-0.119965791375
-0.120153541574
-0.120373769777
-0.120623793727
-0.120912277715
-0.121263273758
-0.121694028855
-0.122210796911
-0.12282701884
-0.123555006183
-0.124404447538
-0.125418984637
-0.126685229087
-0.128280696633
-0.13025572327
-0.132723235471
-0.135924634516
-0.140174275841
-0.145720813664
-0.152998527323
-0.162606377852
-0.166173943279
-0.172020378299
-0.173133997603
-0.175430235397
-0.174035941646
-0.175852933904
-0.189901646468
0.229667484182
0.0300860924683
0.0915760972809
0.127588951243
0.0569499838254
0.141190660891
0.0643868679523
0.135301187877
0.0801967021359
0.128721490526
0.0945562979066
0.125817666803
0.106531022292
0.127333122133
0.117646577699
0.134337070117
0.12989864024
0.150134412246
0.139305145023
0.180624477904
0.105504226392
0.065263811944
0.0676794515862
0.0673453350835
0.0541119787912
0.0448614326134
0.0370739253543
0.0303832003418
0.0244788586974
0.0194757229899
0.0157470022755
0.0130435717411
0.0109946836239
0.00944512547972
0.00830191595924
0.00747086027725
0.00687852208343
0.00647804592211
0.00622604509792
0.00612134369532
)
;
boundaryField
{
frontAndBack
{
type empty;
}
upperWall
{
type zeroGradient;
}
lowerWall
{
type zeroGradient;
}
inlet
{
type zeroGradient;
}
outlet
{
type adjointOutletPressurePower;
value nonuniform List<scalar>
20
(
0.0235385513662
0.105978547275
0.144095989607
0.16834213308
0.184794362621
0.195199285041
0.199623768291
0.199078342841
0.196574239445
0.193359522091
0.189498422786
0.184961018325
0.179719515705
0.17374322158
0.166988736296
0.15933125236
0.150698666763
0.141084047735
0.132059417475
0.10291174148
)
;
}
}
// ************************************************************************* //
| |
d5c218041e5bd80c45e4c52eba0ccdc2027d18fe | dea5814556734b95426f09cd2f9cc381ef5abd6b | /includes/protocol/Phy.h | 5d0632f8bc588dde0ddcbe2766bb22922dc07787 | [] | no_license | hamliao/SimulationStack | a0b73a662de5c06093fc5ac8f6b660563bdbc891 | 65b2991f48e781e99909c0939722d60bb0adc003 | refs/heads/master | 2020-03-18T23:27:59.654559 | 2018-06-05T10:57:21 | 2018-06-05T10:57:21 | 135,404,517 | 0 | 0 | null | 2018-06-01T01:30:01 | 2018-05-30T07:23:37 | C++ | UTF-8 | C++ | false | false | 112 | h | Phy.h | #pragma once
#include "Protocol.h"
class Phy : public Protocol
{
public:
explicit Phy():Protocol(PHY){}
};
|
782fc003233ebaabd27be366a21398827f43ca46 | 3f90ad82a713208ac2dfc750168947a8a37b87a2 | /Lab06/prj/src/AdvancedStopwatch.cpp | ed15e85df4e023fc5aa02d7b02092923317d9021 | [] | no_license | 218685/PAMSI | d91082a8c572197ffc92b7f0acdeb87c4f930036 | ef6c34bfeebd2de6cd656a3e067b94829718a595 | refs/heads/master | 2021-01-17T07:11:35.381506 | 2016-05-29T22:05:22 | 2016-05-29T22:05:22 | 52,258,283 | 0 | 2 | null | 2016-02-23T12:59:46 | 2016-02-22T08:24:00 | null | UTF-8 | C++ | false | false | 2,343 | cpp | AdvancedStopwatch.cpp | #include "AdvancedStopwatch.hh"
using namespace std;
AdvancedStopwatch::AdvancedStopwatch(){
ElapsedTimes = new double [MAX_LAPS];
for(int i=0; i<MAX_LAPS; ++i)
ElapsedTimes[i] = 0;
FileBuffer = new double [BUFOR];
for(int i=0; i<BUFOR; ++i)
FileBuffer[i] = 0;
}
AdvancedStopwatch::~AdvancedStopwatch(){
if(ElapsedTimes!=NULL)
delete [] ElapsedTimes;
ElapsedTimes = NULL;
if(FileBuffer!=NULL)
delete [] FileBuffer;
FileBuffer = NULL;
}
bool AdvancedStopwatch::SaveElapsedTime(double rekord){
for(int i=0; i<MAX_LAPS; ++i)
if(ElapsedTimes[i] == 0){
ElapsedTimes[i] = rekord;
++Rozmiar();
return true;
}
return false;
}
double AdvancedStopwatch::SeriesAverage(){
double average = 0;
int sum = 0;
for(int i=0; i<MAX_LAPS && ElapsedTimes[i] != 0; ++i){
average += ElapsedTimes[i];
sum++;
}
average = average/sum;
return average;
}
bool AdvancedStopwatch::SaveAverageTimeToBuffer(double rekord){
for(int i=0; i<BUFOR; ++i)
if(FileBuffer[i] == 0){
FileBuffer[i] = rekord;
return true;
}
return false;
}
void AdvancedStopwatch::PrintElapsedTimes(){
for(int i=0; i<MAX_LAPS && ElapsedTimes[i] != 0; ++i)
cout << ElapsedTimes[i] <<'\t';
cout << endl;
}
void AdvancedStopwatch::CleanElapsedTimes(){
for(int i=0; i<MAX_LAPS && ElapsedTimes[i] != 0; ++i)
ElapsedTimes[i] = 0;
Rozmiar() = 0;
}
void AdvancedStopwatch::CleanFileBuffer(){
for(int i=0; i<BUFOR; ++i)
FileBuffer[i] = 0;
}
bool AdvancedStopwatch::DumpFileBuffer(string nazwaPliku){
ofstream output;
output.open(nazwaPliku.c_str(),ios::app);
if( output.good() ){
for (int i=0; i < BUFOR; ++i)
if( FileBuffer[i] != 0 )
output << fixed << FileBuffer[i] <<'\t'<< endl;
output.close();
return true;
}
else{
cerr << "* Błąd: Nie można zapisać do pliku!" << endl;
output.close();
return false;
}
}
bool AdvancedStopwatch::DumpToFile(string nazwaPliku, double rekord){
ofstream output;
output.open(nazwaPliku.c_str(),ios::app);
if( output.good() ){
output << fixed << setprecision(6) << rekord <<'\t'<< endl;
output.close();
return true;
}
else{
cerr << "* Błąd: Nie można zapisać do pliku!" << endl;
output.close();
return false;
}
}
|
23ada3b4f57bdff9a41841e5a93772d8c9b98a2e | 27e9d5d6737c11a96ddba1eb43c2f68991f1532f | /rcbasic_edit/help_menu.cpp | cd2c5744ee5d0661fadd28b9cf20037056c21c2f | [
"Zlib"
] | permissive | n00b87/RCBASIC3 | b7abaf91c247e5ed8adcd9568c1d1e6193b82e83 | b311d53e9ec464ee95688dd29dec0cc8011765ff | refs/heads/master | 2023-04-02T02:08:51.758823 | 2023-02-25T17:01:28 | 2023-02-25T17:01:28 | 69,504,118 | 26 | 4 | NOASSERTION | 2023-02-25T17:01:29 | 2016-09-28T21:11:36 | C++ | UTF-8 | C++ | false | false | 1,218 | cpp | help_menu.cpp | #include "rcbasic_edit_frame.h"
void rcbasic_edit_frame::onDocMenuSelect( wxCommandEvent& event )
{
wxString editor_path_str = wxStandardPaths::Get().GetExecutablePath();
wxFileName editor_path(editor_path_str);
editor_path.SetFullName(_(""));
wxString cwd = wxGetCwd();
wxSetWorkingDirectory(editor_path.GetFullPath());
wxLaunchDefaultBrowser(RCBasic_Documentation_Link);
wxSetWorkingDirectory(cwd);
}
void rcbasic_edit_frame::onEditorManualMenuSelect( wxCommandEvent& event )
{
wxString editor_path_str = wxStandardPaths::Get().GetExecutablePath();
wxFileName editor_path(editor_path_str);
editor_path.SetFullName(_(""));
wxString cwd = wxGetCwd();
wxSetWorkingDirectory(editor_path.GetFullPath());
wxLaunchDefaultBrowser(Studio_Documentation_Link);
wxSetWorkingDirectory(cwd);
}
void rcbasic_edit_frame::onAboutMenuSelect( wxCommandEvent& event )
{
wxString msg = _("RCBASIC Studio [Version]\nCopyright (C) 2022 Rodney Cunningham ( aka n00b )\n\nFor latest release, updates, and info go to \nhttp://www.rcbasic.com\n\nAnd the forum at \nhttp://rcbasic.freeforums.net");
msg.Replace(_("[Version]"), RCBasic_Studio_Version);
wxMessageBox(msg);
}
|
0e4a0880987301713b6c5cd7724756e050480c70 | ce023bd6088d310f1509385ba3346933582ba376 | /src/tables.cc | c42f4c4c0bb52fe48454f7a4869a973f11cfaf1c | [] | no_license | lsst-dm/fe55 | 816f9fa1d7e5f14ea32cee3a1a7a8865be87bd88 | 6b4dc64df057ad45fc88accf2ba10d72a5b1e1f2 | refs/heads/main | 2023-08-09T07:19:30.377424 | 2023-07-10T00:47:54 | 2023-07-10T00:47:54 | 37,222,495 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,567 | cc | tables.cc | /*
* rv_ev2pcf.c -- Convert evlist to basic calibration file
*
* Author: gbc@space.mit.edu 17 Oct 1992
*
* The primary calibration file is a QDP file giving a
* histogram of the number of events of each Astro-D
* grade, preceeded by QDP/PLT plotting commands. A
* header giving the experimental source parameters
* is also included in the form of QDP comment lines.
*
* Modified for new SIS grades gbc 02 Dec 1992
* Modified for Reset correction gbc 19 Mar 1993
*/
#include <limits>
#include <algorithm>
#include "lsst/rasmussen/tables.h"
/*
* Initialize the histogram tables. Each entry of the table needs
* to know which counter to increment, which histogram to increment
* and which extra pixels should be included in the summed pha,
* which only occurs for the L, Q and Other grades.
*/
HistogramTable::HistogramTable(int event, int split,
RESET_STYLES sty, double rst, const int filter,
calctype do_what) :
histo(ndarray::allocate(ndarray::makeVector(8, MAXADU))),
_event(event), _split(split), _filter(filter), _do_what(do_what), _efile(""), _sty(sty), _rst(rst)
{
static
const int extra[][4] = { {4,4,4,4},
{0,4,4,4}, {2,4,4,4}, {6,4,4,4}, {8,4,4,4},
{0,2,4,4}, {0,6,4,4}, {6,8,4,4}, {8,2,4,4},
{0,2,6,8} };
static
const unsigned char emask[] = { 0x00,
0x0a,0x12,0x48,0x50,
0x1a,0x4a,0x58,0x52,
0x5a };
const unsigned char sngle[] = { 0x00 }; /* 0 */
const unsigned char splus[] = { 0x01,0x04,0x20,0x80,0x05,0x21,0x81, /* 1 */
0x24,0x84,0xa0,0x25,0x85,0xa4,0xa1,0xa5 };
const unsigned char pvert[] = { 0x02,0x40,0x22,0x82,0x41,0x44,0x45,0xa2 }; /* 2 */
const unsigned char pleft[] = { 0x08,0x0c,0x88,0x8c }; /* 3 */
const unsigned char prght[] = { 0x10,0x30,0x11,0x31 }; /* 4 */
/*
* const unsigned char phorz[] = { 0x08,0x10,0x0c,0x88,0x30,0x11,0x8c,0x31 };
*/
const unsigned char pplus[] = { 0x03,0x06,0x09,0x28,0x60,0xc0,0x90,0x14, /* 5 */
0x83,0x26,0x89,0x2c,0x64,0xc1,0x91,0x34,
0x23,0x86,0x0d,0xa8,0x61,0xc4,0xb0,0x15,
0xa3,0xa6,0x8d,0xac,0x65,0xc5,0xb1,0x35 };
/*
* const unsigned char elish[] = { 0x12,0x32,0x50,0x51,0x48,0x4c,0x0a,0x8a };
* const unsigned char squar[] = { 0x16,0xd0,0x68,0x0b,0x36,0xd1,0x6c,0x8b };
*/
const unsigned char elnsq[] = { 0x12,0x32,0x50,0x51,0x48,0x4c,0x0a,0x8a, /* 6 */
0x16,0xd0,0x68,0x0b,0x36,0xd1,0x6c,0x8b };
#if 0 // not actually needed as an array
const unsigned char other[NMAP] = { all of the rest }; /* 7 */
#endif
/* initialize everything in sight */
nsngle = nsplus = npvert = npleft = nprght = npplus =
nelnsq = nother = ntotal = noobnd = nbevth = 0;
ev_min = MAXADU; xav = 0; yav = 0;
min_adu = MAXADU; max_adu = 0;
min_2ct = MAXADU; max_2ct = 0;
xn = yn = std::numeric_limits<int>::max();
xx = yx = 0;
std::fill(&histo[0][0], &histo[0][0] + 8*MAXADU, 0);
/* load the sngle events into table GRADE 0 */
for (int i = 0; i < sizeof(sngle); i++) {
look_up *t = table + sngle[i];
t->grade = lsst::rasmussen::Event::SINGLE;
t->type = &nsngle;
t->hist = histo[0];
t->extr = extra[0];
}
/* load the splus events into table GRADE 1 */
for (int i = 0; i < sizeof(splus); i++) {
look_up *t = table + splus[i];
t->grade = lsst::rasmussen::Event::SINGLE_P_CORNER;
t->type = &nsplus;
t->hist = histo[1];
t->extr = extra[0];
}
/* load the pvert events into table GRADE 2 */
for (int i = 0; i < sizeof(pvert); i++) {
look_up *t = table + pvert[i];
t->grade = lsst::rasmussen::Event::VERTICAL_SPLIT;
t->type = &npvert;
t->hist = histo[2];
t->extr = extra[0];
}
/* load the pleft events into table GRADE 3 */
for (int i = 0; i < sizeof(pleft); i++) {
look_up *t = table + pleft[i];
t->grade = lsst::rasmussen::Event::LEFT_SPLIT;
t->type = &npleft;
t->hist = histo[3];
t->extr = extra[0];
}
/* load the prght events into table GRADE 4 */
for (int i = 0; i < sizeof(prght); i++) {
look_up *t = table + prght[i];
t->grade = lsst::rasmussen::Event::RIGHT_SPLIT;
t->type = &nprght;
t->hist = histo[4];
t->extr = extra[0];
}
/* load the pplus events into table GRADE 5 */
for (int i = 0; i < sizeof(pplus); i++) {
look_up *t = table + pplus[i];
t->grade = lsst::rasmussen::Event::SINGLE_SIDED_P_CORNER;
t->type = &npplus;
t->hist = histo[5];
t->extr = extra[0];
}
/* load the elnsq events into table GRADE 6 */
for (int i = 0; i < sizeof(elnsq); i++) {
look_up *t = table + elnsq[i];
t->grade = lsst::rasmussen::Event::ELL_SQUARE_P_CORNER;
t->type = &nelnsq;
t->hist = histo[6];
t->extr = extra[0];
for (int b = (0x5a & elnsq[i]), j = 0; j < sizeof(emask); j++)
if (b == emask[j]) {
t->extr = extra[j];
break;
}
}
/* load the other events into table GRADE 7 */
for (int i = 0; i < NMAP; i++) {
look_up *t = table + i;
if (t->type) continue; /* already loaded */
t->grade = lsst::rasmussen::Event::OTHER;
t->type = ¬her;
t->hist = histo[7];
t->extr = extra[0];
/*
* In this version, included corners are
* ignored in all of the grade 7 events.
*
for (b = 0x5a & (unsigned char)i, j = 0;
j < sizeof(emask); j++)
if (b == emask[j]) {
t->extr = extra[j];
break;
}
*/
}
}
const int HistogramTable::MAXADU = 4096;
/*
* Insert the reset clock correction
*/
void
HistogramTable::applyResetClockCorrection(short phe[9]) const
{
switch (_sty) {
case T6:
phe[7] -= phe[6]*_rst;
phe[4] -= phe[3]*_rst;
phe[1] -= phe[0]*_rst; // fall through
case T3:
phe[8] -= phe[7]*_rst;
phe[2] -= phe[1]*_rst; // fall through
case T1:
phe[5] -= phe[4]*_rst;
break;
case TNONE:
break;
}
}
/*********************************************************************************************************/
/*
* Accumulate the num events in the tables
*/
bool
HistogramTable::process_event(lsst::rasmussen::Event *ev
)
{
/*
* Get some gross event parameters
*/
if (ev->data[4] < ev_min) ev_min = ev->data[4];
if (ev->data[4] < _event) {
nbevth++;
ev->grade = lsst::rasmussen::Event::UNKNOWN; // We don't know map yet.
return false;
}
/*
* Classify that event, setting its grade etc.
*/
const int map = classify(ev);
/*
* grade is identified. check with _filter to see whether to pass it on or not.
*/
if (ev->grade == lsst::rasmussen::Event::UNKNOWN ||
((1 << static_cast<int>(ev->grade)) & _filter) == 0x0) {
return false;
}
/*
* Accumulate statistics and various bounds
*/
if (ev->sum >= MAXADU) { noobnd++; return false; }
if (ev->sum > max_adu) max_adu = ev->sum;
if (ev->sum < min_adu) min_adu = ev->sum;
if (ev->x < xn) xn = ev->x;
if (ev->x > xx) xx = ev->x;
if (ev->y < yn) yn = ev->y;
if (ev->y > yx) yx = ev->y;
xav += ev->x;
yav += ev->y;
ntotal++;
look_up *const ent = &table[map];
*ent->type += 1;
const int hsum = ent->hist[static_cast<int>(ev->sum)]++;
if (hsum > 2) {
if (ev->sum > max_2ct) max_2ct = ev->sum;
if (ev->sum < min_2ct) min_2ct = ev->sum;
}
return true;
}
int
HistogramTable::classify(lsst::rasmussen::Event *ev) const
{
short phe[9];
std::copy(ev->data, ev->data + 9, phe);
applyResetClockCorrection(phe);
/*
* Characterize event & accumulate most of pha
*/
unsigned char map = 0;
ev->p9 = 0;
ev->sum = 0;
for (int j = 0; j < 9; j++) {
const short phj = phe[j];
switch (_do_what) {
case P_9:
ev->p9 += phj;
break;
case P_1357:
if (j == 1 || j == 3 || j == 5 || j == 7 || j == 4) ev->p9 += phj;
break;
case P_17:
if (j == 1 || j == 7 || j == 4) ev->p9 += phj;
break;
case P_35:
if (j == 3 || j == 5 || j == 4) ev->p9 += phj;
break;
case P_LIST:
break;
}
if (phj < _split && j != 4) {
phe[j] = 0;
continue;
}
switch (j) {
case 0: map |= 0x01; ; break;
case 1: map |= 0x02; ev->sum += phj; break;
case 2: map |= 0x04; ; break;
case 3: map |= 0x08; ev->sum += phj; break;
case 4: ev->sum += phj; break;
case 5: map |= 0x10; ev->sum += phj; break;
case 6: map |= 0x20; ; break;
case 7: map |= 0x40; ev->sum += phj; break;
case 8: map |= 0x80; ; break;
}
}
ev->grade = table[map].grade;
/*
* Finish pha with extra pixels of L, Q, and O events
*/
const look_up *const ent = &table[map];
const int *xtr = ent->extr;
for (int j = 0; xtr[j] != 4 && j < 4; j++) ev->sum += phe[xtr[j]];
return map;
}
/*
* For diagnostic purposes, dump the grade table in CLASSIFY format.
*/
void
HistogramTable::dump_table() const
{
for (int i = 0; i != NMAP; ++i) {
(void)fprintf(stderr, "%d,", table[i].grade);
if (i%16 == 15) (void)fprintf(stderr, "\n");
}
}
/*
* Dump the basic calibration file header
*/
void
HistogramTable::dump_head(FILE *fd,
const char *sfile, int total)
{
char line[NAMLEN], *c;
(void)fprintf(fd, "!\n");
(void)fprintf(fd, "! QDP Basic Calibration File\n");
(void)fprintf(fd, "!\n");
(void)fprintf(fd, "! Working_dir = %s\n", getcwd((char *)0, NAMLEN));
(void)fprintf(fd, "! Source_file = %s\n", sfile ? sfile : "unknown");
(void)fprintf(fd, "! Event_thresh = %d\n", _event);
(void)fprintf(fd, "! Split_thresh = %d\n", _split);
//(void)fprintf(fd, "! Total_frames = %d\n", cnt);
(void)fprintf(fd, "! Total_events = %d\n", ntotal);
(void)fprintf(fd, "! Total_pixels = %d\n", (xx - xn)*(yx - yn));
(void)fprintf(fd, "!\n");
(void)fprintf(fd, "! Events_below = %d\n", nbevth);
(void)fprintf(fd, "! Events_above = %d\n", noobnd);
{
char buff[40];
if (total < 0) {
strcpy(buff, "unknown");
} else {
sprintf(buff, "%d", total);
}
(void)fprintf(fd, "! Events_input = %s\n", buff);
}
(void)fprintf(fd, "! PH4_minimum = %d\n", ev_min);
(void)fprintf(fd, "! PHS_minimum = %d\n", min_adu);
(void)fprintf(fd, "! PHS_Maximum = %d\n", max_adu);
(void)fprintf(fd, "! X_Minimum = %d\n", xn);
(void)fprintf(fd, "! X_Average = %d\n", xav/(ntotal ? ntotal : 1));
(void)fprintf(fd, "! X_Maximum = %d\n", xx);
(void)fprintf(fd, "! Y_Minimum = %d\n", yn);
(void)fprintf(fd, "! Y_Average = %d\n", yav/(ntotal ? ntotal : 1));
(void)fprintf(fd, "! Y_Maximum = %d\n", yx);
(void)fprintf(fd, "!\n");
(void)fprintf(fd, "! Exclusive grades -- corrected L+Q.\n");
(void)fprintf(fd, "!\n");
if (!sfile || strcmp(sfile, "unknown") == 0) {
return;
}
FILE * const fp = fopen(sfile, "r");
if (fp == NULL) return;
(void)fprintf(fd, "!\n");
(void)fprintf(fd, "! Experimental parameters\n");
(void)fprintf(fd, "!\n");
while (fgets(line, NAMLEN-1, fp)) {
if (line[0] == '#') continue;
(void)fprintf(fd, "! %s", line);
if (!strncmp(line, "evlist = ", 10)) {
(void)strcpy(_efile, &line[10]);
for (c = _efile; *c; c++)
if (*c == '\t') *c = ' ';
}
}
(void)fclose(fp);
}
/*
* Dump the QDP header histogram table
*/
void
HistogramTable::dump_hist(FILE *fd,
const char *sfile) const
{
(void)fprintf(fd, "!\n");
(void)fprintf(fd, "! QDP Header follows\n");
(void)fprintf(fd, "!\n");
(void)fprintf(fd, "lab top Event = %d Split = %d Source = %s\n",
_event, _split, sfile ? sfile : "unknown");
if (_efile[0]) (void)fprintf(fd, "lab file %s", _efile);
(void)fprintf(fd, "lab g1 Pulse Height (ADU)\n");
(void)fprintf(fd, "lab rot\n");
(void)fprintf(fd, "lab g2 N(S)\nlab g3 N(S+)\n");
(void)fprintf(fd, "lab g4 N(Pv)\nlab g5 N(Pl)\n");
(void)fprintf(fd, "lab g6 N(Pr)\nlab g7 N(P+)\n");
(void)fprintf(fd, "lab g8 N(L+Q)\nlab g9 N(O)\n");
(void)fprintf(fd, "csize 0.75\n");
const int EXTADU = 8;
const int tmp_min_2ct = (min_2ct < EXTADU) ? 0 : min_2ct - EXTADU;
const int tmp_max_2ct = (max_2ct >= MAXADU - EXTADU) ? MAXADU : max_2ct + 1 + EXTADU;
(void)fprintf(fd, "res x %d %d\n", tmp_min_2ct, tmp_max_2ct);
(void)fprintf(fd, "res y2 1\nres y3 1\n");
(void)fprintf(fd, "res y4 1\nres y5 1\n");
(void)fprintf(fd, "res y6 1\nres y7 1\n");
(void)fprintf(fd, "res y8 1\nres y9 1\n");
(void)fprintf(fd, "error y sq 2 3 4 5 6 7 8 9\n");
(void)fprintf(fd, "log y on\n");
(void)fprintf(fd, "plot vert\n");
(void)fprintf(fd, "!\n");
(void)fprintf(fd, "! Histogram data follows\n");
(void)fprintf(fd, "!\n");
(void)fprintf(fd, "! PHA\tS\tS+\tPv\tPl\tPr\tP+\tL+Q\tO\n");
(void)fprintf(fd, "! TOT\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n",
nsngle,nsplus,npvert,npleft,nprght,npplus,nelnsq,nother);
(void)fprintf(fd, "!\n");
int tmp_min_adu = (min_adu < EXTADU) ? 0 : min_adu - EXTADU;
int tmp_max_adu = (max_adu >= MAXADU-EXTADU) ? MAXADU : max_adu + 1 + EXTADU;
for (int i = tmp_min_adu; i < tmp_max_adu; i++) {
(void)fprintf(fd, "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", i,
histo[0][i], histo[1][i], histo[2][i], histo[3][i],
histo[4][i], histo[5][i], histo[6][i], histo[7][i]);
}
}
|
cb6c92d55047e8d4850ec9fedf554972e18efc59 | 2086617f3eccf7c769add24179dab1c116644882 | /ModuloAdministracion.cpp | 1094cee8d3ec73fac6388dda6a1c3c9247eb220a | [] | no_license | Elias99garcia/Trabajo-integrador-segundo-cuatrimestre | ae26b737609f679d767e4ac0ca92d7eab018f80e | f8f1ff9a351b06deecc3d47f31b16ed4e09e49c2 | refs/heads/main | 2023-01-30T17:12:09.632041 | 2020-12-17T00:31:47 | 2020-12-17T00:31:47 | 316,785,545 | 0 | 1 | null | null | null | null | ISO-8859-1 | C++ | false | false | 8,185 | cpp | ModuloAdministracion.cpp | /*
Módulo Administración:
La gerencia del centro veterinario es la encargada de realizar el alta de los veterinarios que trabajan
en la institución, así como también de los empleados que realizan la registración de los turnos y mascotas.
Es el área encargada desea visualizar las atenciones realizadas por los profesionales según las en el
mes.
Para incentivar a los veterinarios, la gerencia otorga un bono mensual al profesional que haya
registrado la mayor cantidad de turnos en ese periodo.
*/
#include <stdio.h>
#include <stdlib.h>
#include<iostream>
#include <string.h>
using namespace std;
//----- EstructuraS -----//
struct fecha
{
int dia;
int mes;
int anio;
};
struct fecha2
{
int dia2;
int mes2;
int anio2;
};
struct RegVeterinario
{
int nombreVeterinario;
char ApeNomb[40];
fecha fec;
};
struct RegAyudante
{
int nombreAyudante;
char ApeNombA[40];
fecha2 fec;
};
//----- Prototipos de funciones-----//
int menuPrincipal();
void mensaje(char const *cadena);
void registrarDatos(FILE *veterinario);
bool DatosAyudante(FILE *veterinario);
void listadoVeterinario(FILE *veterinario);
void listadoAyudante(FILE *veterinario);
int main(){
system ("color f9");
int N=0, nroLic=0, nOp = 0;
int nroOp = 0;
FILE *ArchVeterinario;
ArchVeterinario = fopen("veterinario.dat","w+b");
if(ArchVeterinario == NULL)
{// Evalua, Si hubo error, muestra mensaje y termina.
system("CLS");
mensaje("Ocurrio un error en la apertura del Archivo");
exit(1);
}
do
{
nOp = menuPrincipal();
switch(nOp)
{
case 1:
registrarDatos(ArchVeterinario);
break;
case 2:
bool band;
band = DatosAyudante(ArchVeterinario);
if(band)
ArchVeterinario = fopen("veterinario.dat","r+b"); //Se abre de nuevo el archivo, porque
break; //Fue cerrado en el borrado físico.
case 3:
listadoVeterinario(ArchVeterinario);
listadoAyudante(ArchVeterinario);
break;
case 4:
system("CLS");
mensaje("F i n d e l P r o g r a m a");
break;
default:
system("CLS");
mensaje("Ha ingresado un numero no valido");
break;
} //Fin del switch().
}while(nOp != 4); //Fin del Ciclo Do
}
//--------------Desarollo de las funciones--------------//
//-----MENU PRINCIPAL-----//
int menuPrincipal(){
int opc=0;
system("CLS");
cout<<"\t---------------------------------------------------------\n";
cout<<"\t M O D U L O A D M I N I S T R A C I O N \n";
cout<<"\t---------------------------------------------------------\n";
cout<<"\t-- (1) Introduzca DATOS DEL VETERINARIO\n";
cout<<"\t---------------------------------------------------------\n";
cout<<"\t-- (2) Introduca DATOS del AYUDANTE\n";
cout<<"\t---------------------------------------------------------\n";
cout<<"\t-- (3) ATENCION POR VETERINARIOS\n";
cout<<"\t---------------------------------------------------------\n";
cout<<"\t-- (4) S A L I R del S I S T E M A \n";
cout<<"\t---------------------------------------------------------\n\n";
cout<<" Seleccione Opcion: ";
scanf("%d", &opc);
return opc;
}
void registrarDatos(FILE *veterinario)
{
RegVeterinario reg;
int nroReg=0;
char continua='N';
do{
system("CLS");
cout<<"\t------------------------------------------\n";
cout<<"\t M O D U L O A D M I N I S T R A C I O N \n";
cout<<"\t------------------------------------------\n\n";
cout<<"\n\t Introduzca el numero del veterinario a REGISTRAR: ";
cin>>reg.nombreVeterinario;
_flushall();
printf("\n\t Apellido y Nombre: "); gets(reg.ApeNomb);
cout<<"\n\t ----Fecha de nacimiento---- \n";
cout<<"\n\t Dia: ";
cin>>reg.fec.dia;
cout<<"\n\t Mes: ";
cin>>reg.fec.mes;
cout<<"\n\t Anio: ";
cin>>reg.fec.anio;
fwrite(®, sizeof(RegVeterinario), 1, veterinario); //Graba el registro lógico.
_flushall();
cout<<"\n\n¿Quiere continuar ingresando VETERINARIOS? (S/N): ";
scanf("%c", &continua);
}while(continua == 'S' || continua == 's');
system("CLS");
mensaje("Fin de la carga"); //Muestra el mensaje.
} //Fin de la función registrarTaxis.
/*------------------------------------------------*/
bool DatosAyudante(FILE *veterinario)
{
RegAyudante reg;
int nroReg=0;
char continua='N';
do{
system("CLS");
cout<<"\t------------------------------------------\n";
cout<<"\t M O D U L O A D M I N I S T R A C I O N \n";
cout<<"\t------------------------------------------\n\n";
printf("\n\tApellido y Nombre del ayudante: "); scanf("%d",®.nombreAyudante);
_flushall();
cout<<"\n\t ----Fecha de nacimiento---- \n";
cout<<"\n\t Dia: ";
cin>>reg.fec.dia2;
cout<<"\n\t Mes: ";
cin>>reg.fec.mes2;
cout<<"\n\t Anio: ";
cin>>reg.fec.anio2;
fwrite(®, sizeof(RegAyudante), 1, veterinario); //Graba el registro lógico.
_flushall();
cout<<"\n\n¿Quiere continuar ingresando Ayudantes? (S/N): ";
cin>>continua;
}while(continua == 'S' || continua == 's');
system("CLS");
mensaje("Fin de la carga");
}
//----------Funcion para listar DATOS----------//
void listadoVeterinario(FILE *veterinario){
RegVeterinario reg;
//----- Titulo del listado -----//
system("CLS");
cout<<"\t---------------------------------------------------------\n";
cout<<"\t LISTA DE VETERINARIOS\n";
cout<<"\t---------------------------------------------------------\n\n";
cout<<"\tNum de VET";
cout<<" Nombre";
cout<<"\t Fecha de NAC."<<endl;
cout<<"\t---------------------------------------------------------\n\n";
rewind(veterinario);
fread(®, sizeof(reg), 1, veterinario);
if (feof(veterinario)){
system("CLS");
mensaje("El Archivo esta vacio\n No se ENCONTRO INFORMACION.");
}
else{
while(!feof(veterinario)){ //Repite hasta el último registro.
printf("\t %d ", reg.nombreVeterinario);
printf("\t %s ", reg.ApeNomb );
printf("\t %d/%d/%d ", reg.fec.dia, reg.fec.mes, reg.fec.anio);
printf("\n");
fread(®, sizeof(RegVeterinario), 1, veterinario);
}
}
mensaje("(HAGA CLICK O ENTER PARA PASAR A LA VENTANA DEL AYUDANTE)");
}
void mensaje(char const *cadena){
cout<<"\n\n\n---------------------------------------------------------\n";
cout<<"\n %s "<<cadena;
cout<<"\n\n---------------------------------------------------------*\n\n\t";
system("PAUSE");
}
void listadoAyudante(FILE *veterinario){
RegAyudante reg;
system("CLS");
cout<<"\t---------------------------------------------------------\n";
cout<<"\t LISTA DE AYUDANTES\n";
cout<<"\t---------------------------------------------------------\n\n";
cout<<"\tNombre";
cout<<"\t Fecha de NAC."<<endl;
cout<<"\t---------------------------------------------------------\n\n";
rewind(veterinario);
fread(®, sizeof(reg), 1, veterinario);
if (feof(veterinario)){
system("CLS");
mensaje("El Archivo esta vacio\n No se ENCONTRO INFORMACION.");
}
else{
while(!feof(veterinario)){ //Repite hasta el último registro.
printf("\t %d ", reg.nombreAyudante);
printf("\t %d/%d/%d ", reg.fec.dia2, reg.fec.mes2, reg.fec.anio2);
printf("\n");
fread(®, sizeof(RegAyudante), 1, veterinario);
}
}
mensaje("\t\t\t\tMODULO DE ADMINISTRACION ");
}
|
5411014acfd9a769cd9ad5f3087da51b225d6df5 | ee86d6079aeba223684e421efcb68d565e503b23 | /LibVertexPerfect/LibVertexPerfect/Graphics/Shaders/ShaderProgram.cpp | f4676aea5c0bed4fcc6b90985e153e5b03a0799d | [
"MIT"
] | permissive | Caresilabs/LibVertexPerfect | e0448531338303c715d9522a8a7197a29beed904 | a1b20582204de88bb24c37e56096c8788b18d55b | refs/heads/master | 2021-01-23T05:29:18.829076 | 2017-05-02T18:23:44 | 2017-05-02T18:23:44 | 86,308,563 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,818 | cpp | ShaderProgram.cpp | #include "stdafx.h"
#include "ShaderProgram.h"
#include <D3D11.h>
#include <d3dCompiler.h>
#include <fstream>
#include "../DXGraphics.h"
ShaderProgram::ShaderProgram() {
DeviceContext = static_cast<DXGraphics*>(LVP::Graphics)->DeviceContext;
}
void ShaderProgram::Begin( Camera & camera ) {
//set topology
DeviceContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST ); /// D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST
//set vertex description
DeviceContext->IASetInputLayout( InputLayout );
//set shaders
DeviceContext->VSSetShader( VertexShader, nullptr, 0 );
DeviceContext->HSSetShader( nullptr, nullptr, 0 );
DeviceContext->DSSetShader( nullptr, nullptr, 0 );
DeviceContext->GSSetShader( nullptr, nullptr, 0 );
DeviceContext->PSSetShader( PixelShader, nullptr, 0 );
for ( auto& buffer : CBuffers ) {
switch ( buffer.second.Type ) {
case ShaderType::VERTEX:
DeviceContext->VSSetConstantBuffers( buffer.first, 1, &buffer.second.Buffer );
break;
case ShaderType::FRAGMENT:
DeviceContext->PSSetConstantBuffers( buffer.first, 1, &buffer.second.Buffer );
break;
default:
break;
}
}
}
void ShaderProgram::End() {
//DeviceContext->Flush();
}
ShaderProgram::~ShaderProgram() {
for ( auto& buffer : CBuffers ) {
SAFE_RELEASE( buffer.second.Buffer );
}
SAFE_RELEASE( InputLayout );
SAFE_RELEASE( VertexShader );
SAFE_RELEASE( PixelShader );
}
bool ShaderProgram::CompileShader( const char * shaderFile, const char * pEntrypoint, const char * pTarget, D3D10_SHADER_MACRO * pDefines, ID3DBlob ** pCompiledShader ) {
DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS |
D3DCOMPILE_IEEE_STRICTNESS;
std::string shader_code;
std::ifstream in( shaderFile, std::ios::in | std::ios::binary );
std::string e = strerror( errno );
if ( in ) {
in.seekg( 0, std::ios::end );
shader_code.resize( (UINT)in.tellg() );
in.seekg( 0, std::ios::beg );
in.read( &shader_code[0], shader_code.size() );
in.close();
}
ID3DBlob* pErrorBlob = nullptr;
HRESULT hr = D3DCompile(
shader_code.data(),
shader_code.size(),
nullptr,
pDefines,
nullptr,
pEntrypoint,
pTarget,
dwShaderFlags,
0,
pCompiledShader,
&pErrorBlob );
if ( pErrorBlob ) {
// output error message
OutputDebugStringA( (char*)pErrorBlob->GetBufferPointer() );
#ifdef USECONSOLE
printf( "%s\n", (char*)pErrorBlob->GetBufferPointer() );
#endif
SAFE_RELEASE( pErrorBlob );
}
return *pCompiledShader != nullptr;
}
void ShaderProgram::Compile( const ShaderConfig& config ) {
auto Device = static_cast<DXGraphics*>(LVP::Graphics)->Device;
// Vertex shader
ID3DBlob* pVertexShader = nullptr;
if ( CompileShader( config.VertexFilePath, config.VertexEntrypoint, config.VertexTarget, nullptr, &pVertexShader ) ) {
if ( Device->CreateVertexShader(
pVertexShader->GetBufferPointer(),
pVertexShader->GetBufferSize(),
nullptr,
&VertexShader ) == S_OK ) {
Device->CreateInputLayout(
config.InputElements,
config.InputSize, //ARRAYSIZE( inputDesc ),
pVertexShader->GetBufferPointer(),
pVertexShader->GetBufferSize(),
&InputLayout );
}
SAFE_RELEASE( pVertexShader );
} else {
MessageBoxA( nullptr, "Failed to create vertex shader (check Output window for more info)", 0, 0 );
}
// Pixel shader
ID3DBlob* pPixelShader = nullptr;
if ( CompileShader( config.PixelFilePath, config.PixelEntrypoint, config.PixelTarget, nullptr, &pPixelShader ) ) {
Device->CreatePixelShader(
pPixelShader->GetBufferPointer(),
pPixelShader->GetBufferSize(),
nullptr,
&PixelShader );
SAFE_RELEASE( pPixelShader );
} else {
MessageBoxA( nullptr, "Failed to create pixel shader (check Output window for more info)", 0, 0 );
}
}
void ShaderProgram::FlushCBuffer( int index ) {
DeviceContext->Unmap( CBuffers[index].Buffer, 0 );
}
|
16e551ba015c93c787d1f095a74cbd7f67ecdcfa | 2f8bf12144551bc7d8087a6320990c4621741f3d | /src/library/vm/vm_aux.cpp | d40c420d4c0e168654b5fb53c5a774a6e6d7611a | [
"Apache-2.0"
] | permissive | jesse-michael-han/lean4 | eb63a12960e69823749edceb4f23fd33fa2253ce | fa16920a6a7700cabc567aa629ce4ae2478a2f40 | refs/heads/master | 2020-05-20T00:50:10.594835 | 2019-05-06T21:24:20 | 2019-05-06T21:24:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 877 | cpp | vm_aux.cpp | /*
Copyright (c) 2016 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#include <string>
#include <iostream>
#include "util/timeit.h"
#include "library/trace.h"
#include "library/vm/vm.h"
#include "library/vm/vm_string.h"
#include "library/vm/vm_option.h"
#include "library/vm/vm_nat.h"
namespace lean {
vm_obj vm_sorry() {
auto & s = get_vm_state();
throw exception(sstream() << s.call_stack_fn(s.call_stack_size() - 1)
<< ": trying to evaluate sorry");
}
vm_obj vm_undefined_core(vm_obj const &, vm_obj const & message) {
throw exception(to_string(message));
}
void initialize_vm_aux() {
DECLARE_VM_BUILTIN("sorry", vm_sorry);
DECLARE_VM_BUILTIN("undefined_core", vm_undefined_core);
}
void finalize_vm_aux() {
}
}
|
696d0379eef5e469885db027a5ad1bd9ae335378 | 4f3f01ca4a864dbe0ad19667db42c7a3ed8c80c0 | /PBR/Core/Light.cpp | 99c1928067c0caa76b145ce4033be54220f7fd13 | [
"MIT"
] | permissive | bbtarzan12/Mesh-Viewer | 07f30c753bd16fd0847a0010468e4cb3b7afca87 | 6e802348887760ae5062653e849d23cb176fd98a | refs/heads/master | 2021-01-04T17:46:38.431398 | 2020-02-25T11:55:34 | 2020-02-25T11:55:34 | 240,689,297 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 535 | cpp | Light.cpp | #include "Light.h"
#include "Material.h"
#include <string>
Light::Light(const glm::vec3& position, const glm::vec3& color, const float power)
:position(position), color(color), power(power)
{
}
void Light::Draw(const std::shared_ptr<Material> material, int index /*= 0*/) const
{
std::string indexString = std::to_string(index);
material->SetVec3("lights[" + indexString + "].position", position);
material->SetVec3("lights[" + indexString + "].color", color);
material->SetFloat("lights[" + indexString + "].power", power);
}
|
54e2370db9dc9511e416797506f048c3b9107170 | c0a9417b6ee96ec4df39b9f95165be0f53a0b2b8 | /Engine/System/Codes/Timer_Mgr.cpp | 41dd47ab37a32125b4b861adda11039f3ae598a7 | [] | no_license | SeungyulOh/Bryan_Project | e84641bf178125c8bbcb43a955c03eb48fe42efb | aaef5e0d0ccb9248b8a226b1ca8e70e982d491e7 | refs/heads/master | 2021-01-20T01:33:00.055580 | 2017-04-25T02:33:00 | 2017-04-25T02:33:00 | 89,294,250 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,235 | cpp | Timer_Mgr.cpp | #include "Timer_Mgr.h"
using namespace Engine;
IMPLEMENT_SINGLETON(CTimer_Mgr)
Engine::CTimer_Mgr::CTimer_Mgr()
{
}
Engine::CTimer_Mgr::~CTimer_Mgr()
{
}
HRESULT Engine::CTimer_Mgr::Ready_TimerMgr(const _tchar* pTagTimer)
{
CTimer* pTimer = Find_Timer(pTagTimer);
if(pTimer != NULL)
return E_FAIL;
pTimer = CTimer::Create();
m_mapTimer.insert(MAPTIMER::value_type(pTagTimer,pTimer));
return S_OK;
}
void Engine::CTimer_Mgr::SetUp_TimeDelta(const _tchar* pTagTimer)
{
CTimer* pTimer = Find_Timer(pTagTimer);
if(pTimer == NULL)
return;
pTimer->SetUp_TimeDelta();
}
void Engine::CTimer_Mgr::Free(void)
{
for_each(m_mapTimer.begin(),m_mapTimer.end(),CRelease_Pair());
m_mapTimer.clear();
}
Engine::CTimer* Engine::CTimer_Mgr::Find_Timer(const _tchar* pTagTimer)
{
CTagFinder TagFinder(pTagTimer);
MAPTIMER::iterator iter = find_if(m_mapTimer.begin(),m_mapTimer.end(),TagFinder);
if(iter == m_mapTimer.end())
return NULL;
return iter->second;
}
_float Engine::CTimer_Mgr::Get_TimeDelta(const _tchar* pTagTimer)
{
MAPTIMER::iterator iter = find_if(m_mapTimer.begin(),m_mapTimer.end(),CTagFinder(pTagTimer));
if(iter == m_mapTimer.end())
return 0.f;
return iter->second->Get_TimeDelta();
}
|
d311bc83f67701bbdd8e42e9894287627a5bda75 | c80df697c0b66cd58a039c928574926bd6161a36 | /runtime/vm/field_table.cc | 19f43c8fee72bdbb8d9f0f367abcc5bd5e970df3 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-unknown"
] | permissive | dart-lang/sdk | d4e50700dfc54b33c0a7a09fab1aa9623ebc84e5 | b25873f11c68772408f6a4aea5f5c961f31ac9f7 | refs/heads/master | 2023-08-31T11:13:09.400940 | 2023-08-31T09:10:57 | 2023-08-31T09:10:57 | 35,726,310 | 10,701 | 2,079 | BSD-3-Clause | 2023-09-14T10:34:15 | 2015-05-16T14:14:58 | Dart | UTF-8 | C++ | false | false | 4,626 | cc | field_table.cc | // Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/field_table.h"
#include "platform/atomic.h"
#include "vm/flags.h"
#include "vm/growable_array.h"
#include "vm/heap/heap.h"
#include "vm/object.h"
#include "vm/object_graph.h"
#include "vm/object_store.h"
#include "vm/raw_object.h"
#include "vm/visitor.h"
namespace dart {
FieldTable::~FieldTable() {
FreeOldTables();
delete old_tables_; // Allocated in FieldTable::FieldTable()
free(table_); // Allocated in FieldTable::Grow()
}
bool FieldTable::IsReadyToUse() const {
DEBUG_ASSERT(
IsolateGroup::Current()->IsReloading() ||
IsolateGroup::Current()->program_lock()->IsCurrentThreadReader());
return is_ready_to_use_;
}
void FieldTable::MarkReadyToUse() {
// The isolate will mark it's field table ready-to-use upon initialization of
// the isolate. Only after it was marked as ready-to-use will it participate
// in new static field registrations.
//
// By requiring a read lock here we ensure no other thread is is registering a
// new static field at this moment (it would need exclusive writer lock).
DEBUG_ASSERT(
IsolateGroup::Current()->program_lock()->IsCurrentThreadReader());
ASSERT(!is_ready_to_use_);
is_ready_to_use_ = true;
}
void FieldTable::FreeOldTables() {
while (old_tables_->length() > 0) {
free(old_tables_->RemoveLast());
}
}
intptr_t FieldTable::FieldOffsetFor(intptr_t field_id) {
return field_id * sizeof(ObjectPtr); // NOLINT
}
bool FieldTable::Register(const Field& field, intptr_t expected_field_id) {
DEBUG_ASSERT(
IsolateGroup::Current()->program_lock()->IsCurrentThreadWriter());
ASSERT(is_ready_to_use_);
if (free_head_ < 0) {
bool grown_backing_store = false;
if (top_ == capacity_) {
const intptr_t new_capacity = capacity_ + kCapacityIncrement;
Grow(new_capacity);
grown_backing_store = true;
}
ASSERT(top_ < capacity_);
ASSERT(expected_field_id == -1 || expected_field_id == top_);
field.set_field_id(top_);
table_[top_] = Object::sentinel().ptr();
++top_;
return grown_backing_store;
}
// Reuse existing free element. This is "slow path" that should only be
// triggered after hot reload.
intptr_t reused_free = free_head_;
free_head_ = Smi::Value(Smi::RawCast(table_[free_head_]));
field.set_field_id(reused_free);
table_[reused_free] = Object::sentinel().ptr();
return false;
}
void FieldTable::Free(intptr_t field_id) {
table_[field_id] = Smi::New(free_head_);
free_head_ = field_id;
}
void FieldTable::AllocateIndex(intptr_t index) {
if (index >= capacity_) {
const intptr_t new_capacity = index + kCapacityIncrement;
Grow(new_capacity);
}
ASSERT(table_[index] == ObjectPtr());
if (index >= top_) {
top_ = index + 1;
}
}
void FieldTable::Grow(intptr_t new_capacity) {
ASSERT(new_capacity > capacity_);
auto old_table = table_;
auto new_table = static_cast<ObjectPtr*>(
malloc(new_capacity * sizeof(ObjectPtr))); // NOLINT
intptr_t i;
for (i = 0; i < top_; i++) {
new_table[i] = old_table[i];
}
for (; i < new_capacity; i++) {
new_table[i] = ObjectPtr();
}
capacity_ = new_capacity;
old_tables_->Add(old_table);
// Ensure that new_table_ is populated before it is published
// via store to table_.
reinterpret_cast<AcqRelAtomic<ObjectPtr*>*>(&table_)->store(new_table);
if (isolate_ != nullptr && isolate_->mutator_thread() != nullptr) {
isolate_->mutator_thread()->field_table_values_ = table_;
}
}
FieldTable* FieldTable::Clone(Isolate* for_isolate) {
DEBUG_ASSERT(
IsolateGroup::Current()->program_lock()->IsCurrentThreadReader());
FieldTable* clone = new FieldTable(for_isolate);
auto new_table =
static_cast<ObjectPtr*>(malloc(capacity_ * sizeof(ObjectPtr))); // NOLINT
memmove(new_table, table_, capacity_ * sizeof(ObjectPtr));
ASSERT(clone->table_ == nullptr);
clone->table_ = new_table;
clone->capacity_ = capacity_;
clone->top_ = top_;
clone->free_head_ = free_head_;
return clone;
}
void FieldTable::VisitObjectPointers(ObjectPointerVisitor* visitor) {
// GC might try to visit field table before it's isolate done setting it up.
if (table_ == nullptr) {
return;
}
ASSERT(visitor != nullptr);
visitor->set_gc_root_type("static fields table");
visitor->VisitPointers(&table_[0], &table_[top_ - 1]);
visitor->clear_gc_root_type();
}
} // namespace dart
|
490c7ae02d4df03900eba2b20ac33f209c69192e | ddb5e989f6ede26ece931af750757bc3ef48aada | /source/LowScoreDistribution.h | 64f3350cba4386f498ee6638b9d4213b1898702f | [
"MIT"
] | permissive | mmore500/tag-olympics | 5d64344a8ce29f8d1244ec08cb873a895e305b40 | a0f00aa534bfd7811ebc94a10749ecbbbcaeb007 | refs/heads/master | 2022-09-27T21:02:56.259757 | 2022-09-22T04:58:57 | 2022-09-22T04:58:57 | 194,933,684 | 0 | 0 | MIT | 2020-09-03T11:14:18 | 2019-07-02T20:55:02 | Python | UTF-8 | C++ | false | false | 1,373 | h | LowScoreDistribution.h | #pragma once
#include <iostream>
#include <limits>
#include "tools/MatchBin.h"
#include "tools/matchbin_utils.h"
#include "tools/Random.h"
#include "config/ArgManager.h"
#include "data/DataFile.h"
#include "tools/string_utils.h"
#include "tools/keyname_utils.h"
#include "Config.h"
#include "Metrics.h"
void LowScoreDistribution(const Metrics::collection_t &metrics, const Config &cfg) {
emp::Random rand(cfg.SEED());
size_t s;
std::string name;
double score;
emp::DataFile df(emp::keyname::pack({
{"bitweight", emp::to_string(cfg.LSD_BITWEIGHT())},
{"title", cfg.LSD_TITLE()},
{"seed", emp::to_string(cfg.SEED())},
// {"_emp_hash=", STRINGIFY(EMPIRICAL_HASH_)},
// {"_source_hash=", STRINGIFY(DISHTINY_HASH_)},
{"ext", ".csv"}
}));
df.AddVar(s, "Sample");
df.AddVar(name, "Metric");
df.AddVar(score, "Match Score");
df.PrintHeaderKeys();
for(s = 0; s < cfg.LSD_NSAMPLES(); ++s) {
emp::BitSet<Config::BS_WIDTH()> bs_a(rand, cfg.LSD_BITWEIGHT());
emp::BitSet<Config::BS_WIDTH()> bs_b(rand, cfg.LSD_BITWEIGHT());
for (const auto & mptr : metrics) {
const auto & metric = *mptr;
// filter out non-interesting data
if (metric.name().find("Inverse") != std::string::npos) continue;
name = metric.name() + " Distance";
score = metric(bs_a, bs_b);
df.Update();
}
}
}
|
05afaa2f0aeeb6196915845139a5e1678e921936 | 88ae8695987ada722184307301e221e1ba3cc2fa | /third_party/dawn/src/tint/ast/transform/clamp_frag_depth_test.cc | 7a0ac9f6019c3edc79195230ee1135ce4768fbf4 | [
"BSD-3-Clause",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later"
] | permissive | iridium-browser/iridium-browser | 71d9c5ff76e014e6900b825f67389ab0ccd01329 | 5ee297f53dc7f8e70183031cff62f37b0f19d25f | refs/heads/master | 2023-08-03T16:44:16.844552 | 2023-07-20T15:17:00 | 2023-07-23T16:09:30 | 220,016,632 | 341 | 40 | BSD-3-Clause | 2021-08-13T13:54:45 | 2019-11-06T14:32:31 | null | UTF-8 | C++ | false | false | 8,201 | cc | clamp_frag_depth_test.cc | // Copyright 2021 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/tint/ast/transform/clamp_frag_depth.h"
#include "src/tint/ast/transform/test_helper.h"
namespace tint::ast::transform {
namespace {
using ClampFragDepthTest = TransformTest;
TEST_F(ClampFragDepthTest, ShouldRunEmptyModule) {
auto* src = R"()";
EXPECT_FALSE(ShouldRun<ClampFragDepth>(src));
}
TEST_F(ClampFragDepthTest, ShouldRunNoFragmentShader) {
auto* src = R"(
fn f() -> f32 {
return 0.0;
}
@compute @workgroup_size(1) fn cs() {
}
@vertex fn vs() -> @builtin(position) vec4<f32> {
return vec4<f32>();
}
)";
EXPECT_FALSE(ShouldRun<ClampFragDepth>(src));
}
TEST_F(ClampFragDepthTest, ShouldRunFragmentShaderNoReturnType) {
auto* src = R"(
@fragment fn main() {
}
)";
EXPECT_FALSE(ShouldRun<ClampFragDepth>(src));
}
TEST_F(ClampFragDepthTest, ShouldRunFragmentShaderNoFragDepth) {
auto* src = R"(
@fragment fn main() -> @location(0) f32 {
return 0.0;
}
struct S {
@location(0) a : f32,
@builtin(sample_mask) b : u32,
}
@fragment fn main2() -> S {
return S();
}
)";
EXPECT_FALSE(ShouldRun<ClampFragDepth>(src));
}
TEST_F(ClampFragDepthTest, ShouldRunFragDepthAsDirectReturn) {
auto* src = R"(
@fragment fn main() -> @builtin(frag_depth) f32 {
return 0.0;
}
)";
EXPECT_TRUE(ShouldRun<ClampFragDepth>(src));
}
TEST_F(ClampFragDepthTest, ShouldRunFragDepthInStruct) {
auto* src = R"(
struct S {
@location(0) a : f32,
@builtin(frag_depth) b : f32,
@location(1) c : f32,
}
@fragment fn main() -> S {
return S();
}
)";
EXPECT_TRUE(ShouldRun<ClampFragDepth>(src));
}
TEST_F(ClampFragDepthTest, SingleReturnOfFragDepth) {
auto* src = R"(
@fragment fn main() -> @builtin(frag_depth) f32 {
return 0.0;
}
)";
auto* expect = R"(
enable chromium_experimental_push_constant;
struct FragDepthClampArgs {
min : f32,
max : f32,
}
var<push_constant> frag_depth_clamp_args : FragDepthClampArgs;
fn clamp_frag_depth(v : f32) -> f32 {
return clamp(v, frag_depth_clamp_args.min, frag_depth_clamp_args.max);
}
@fragment
fn main() -> @builtin(frag_depth) f32 {
return clamp_frag_depth(0.0);
}
)";
auto got = Run<ClampFragDepth>(src);
EXPECT_EQ(expect, str(got));
}
TEST_F(ClampFragDepthTest, MultipleReturnOfFragDepth) {
auto* src = R"(
@fragment fn main() -> @builtin(frag_depth) f32 {
if (false) {
return 1.0;
}
return 0.0;
}
)";
auto* expect = R"(
enable chromium_experimental_push_constant;
struct FragDepthClampArgs {
min : f32,
max : f32,
}
var<push_constant> frag_depth_clamp_args : FragDepthClampArgs;
fn clamp_frag_depth(v : f32) -> f32 {
return clamp(v, frag_depth_clamp_args.min, frag_depth_clamp_args.max);
}
@fragment
fn main() -> @builtin(frag_depth) f32 {
if (false) {
return clamp_frag_depth(1.0);
}
return clamp_frag_depth(0.0);
}
)";
auto got = Run<ClampFragDepth>(src);
EXPECT_EQ(expect, str(got));
}
TEST_F(ClampFragDepthTest, OtherFunctionWithoutFragDepth) {
auto* src = R"(
@fragment fn main() -> @builtin(frag_depth) f32 {
return 0.0;
}
@fragment fn other() -> @location(0) f32 {
return 0.0;
}
)";
auto* expect = R"(
enable chromium_experimental_push_constant;
struct FragDepthClampArgs {
min : f32,
max : f32,
}
var<push_constant> frag_depth_clamp_args : FragDepthClampArgs;
fn clamp_frag_depth(v : f32) -> f32 {
return clamp(v, frag_depth_clamp_args.min, frag_depth_clamp_args.max);
}
@fragment
fn main() -> @builtin(frag_depth) f32 {
return clamp_frag_depth(0.0);
}
@fragment
fn other() -> @location(0) f32 {
return 0.0;
}
)";
auto got = Run<ClampFragDepth>(src);
EXPECT_EQ(expect, str(got));
}
TEST_F(ClampFragDepthTest, SimpleReturnOfStruct) {
auto* src = R"(
struct S {
@builtin(frag_depth) frag_depth : f32,
}
@fragment fn main() -> S {
return S(0.0);
}
)";
auto* expect = R"(
enable chromium_experimental_push_constant;
struct FragDepthClampArgs {
min : f32,
max : f32,
}
var<push_constant> frag_depth_clamp_args : FragDepthClampArgs;
fn clamp_frag_depth(v : f32) -> f32 {
return clamp(v, frag_depth_clamp_args.min, frag_depth_clamp_args.max);
}
struct S {
@builtin(frag_depth)
frag_depth : f32,
}
fn clamp_frag_depth_S(s : S) -> S {
return S(clamp_frag_depth(s.frag_depth));
}
@fragment
fn main() -> S {
return clamp_frag_depth_S(S(0.0));
}
)";
auto got = Run<ClampFragDepth>(src);
EXPECT_EQ(expect, str(got));
}
TEST_F(ClampFragDepthTest, MixOfFunctionReturningStruct) {
auto* src = R"(
struct S {
@builtin(frag_depth) frag_depth : f32,
}
struct S2 {
@builtin(frag_depth) frag_depth : f32,
}
@fragment fn returnS() -> S {
return S(0.0);
}
@fragment fn againReturnS() -> S {
return S(0.0);
}
@fragment fn returnS2() -> S2 {
return S2(0.0);
}
)";
// clamp_frag_depth_S is emitted only once.
// S2 gets its own clamping function.
auto* expect = R"(
enable chromium_experimental_push_constant;
struct FragDepthClampArgs {
min : f32,
max : f32,
}
var<push_constant> frag_depth_clamp_args : FragDepthClampArgs;
fn clamp_frag_depth(v : f32) -> f32 {
return clamp(v, frag_depth_clamp_args.min, frag_depth_clamp_args.max);
}
struct S {
@builtin(frag_depth)
frag_depth : f32,
}
struct S2 {
@builtin(frag_depth)
frag_depth : f32,
}
fn clamp_frag_depth_S(s : S) -> S {
return S(clamp_frag_depth(s.frag_depth));
}
@fragment
fn returnS() -> S {
return clamp_frag_depth_S(S(0.0));
}
@fragment
fn againReturnS() -> S {
return clamp_frag_depth_S(S(0.0));
}
fn clamp_frag_depth_S2(s : S2) -> S2 {
return S2(clamp_frag_depth(s.frag_depth));
}
@fragment
fn returnS2() -> S2 {
return clamp_frag_depth_S2(S2(0.0));
}
)";
auto got = Run<ClampFragDepth>(src);
EXPECT_EQ(expect, str(got));
}
TEST_F(ClampFragDepthTest, ComplexIOStruct) {
auto* src = R"(
struct S {
@location(0) blou : vec4<f32>,
@location(1) bi : vec4<f32>,
@builtin(frag_depth) frag_depth : f32,
@location(2) boul : i32,
@builtin(sample_mask) ga : u32,
}
@fragment fn main() -> S {
return S(vec4<f32>(), vec4<f32>(), 0.0, 1, 0u);
}
)";
auto* expect = R"(
enable chromium_experimental_push_constant;
struct FragDepthClampArgs {
min : f32,
max : f32,
}
var<push_constant> frag_depth_clamp_args : FragDepthClampArgs;
fn clamp_frag_depth(v : f32) -> f32 {
return clamp(v, frag_depth_clamp_args.min, frag_depth_clamp_args.max);
}
struct S {
@location(0)
blou : vec4<f32>,
@location(1)
bi : vec4<f32>,
@builtin(frag_depth)
frag_depth : f32,
@location(2)
boul : i32,
@builtin(sample_mask)
ga : u32,
}
fn clamp_frag_depth_S(s : S) -> S {
return S(s.blou, s.bi, clamp_frag_depth(s.frag_depth), s.boul, s.ga);
}
@fragment
fn main() -> S {
return clamp_frag_depth_S(S(vec4<f32>(), vec4<f32>(), 0.0, 1, 0u));
}
)";
auto got = Run<ClampFragDepth>(src);
EXPECT_EQ(expect, str(got));
}
} // namespace
} // namespace tint::ast::transform
|
3ec5f14ac110a39ad91145370c2d1fcc296a2aa0 | 4848ec1bc21916f8dc0493cbf38dbea97c497755 | /src/common/measurement_conversion/src/measurement_conversion.cpp | f4ef2dcf0a502c33cbab23bf0b3069b5e7c5290f | [
"Apache-2.0"
] | permissive | zsyxs0926/AutowareAuto | c2bcf5b739b2f299ba6e35e0171fa2a98ab9663a | 0334d959a2fd905672c3b9738b23d919bffce602 | refs/heads/master | 2023-06-06T11:28:44.866526 | 2021-06-15T15:17:50 | 2021-06-24T15:09:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,654 | cpp | measurement_conversion.cpp | // Copyright 2021 Apex.AI, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/// \copyright Copyright 2021 Apex.AI, Inc.
/// All rights reserved.
#include <measurement_conversion/measurement_conversion.hpp>
#include <common/types.hpp>
#include <measurement_conversion/eigen_utils.hpp>
#include <tf2_eigen/tf2_eigen.h>
namespace
{
using autoware::common::types::float32_t;
using autoware::common::types::float64_t;
constexpr auto kCovarianceMatrixRows = 6U;
constexpr auto kCovarianceMatrixRowsRelativePos = 3U;
constexpr auto kIndexX = 0U;
constexpr auto kIndexXY = 1U;
constexpr auto kIndexY = kCovarianceMatrixRows + 1U;
constexpr auto kIndexYX = kCovarianceMatrixRows;
constexpr auto kIndexXRelativePos = 0U;
constexpr auto kIndexXYRelativePos = 1U;
constexpr auto kIndexYRelativePos = kCovarianceMatrixRowsRelativePos + 1U;
constexpr auto kIndexYXRelativePos = kCovarianceMatrixRowsRelativePos;
constexpr auto kCovarianceMatrixRowsSquared = kCovarianceMatrixRows * kCovarianceMatrixRows;
static_assert(
std::tuple_size<
geometry_msgs::msg::PoseWithCovariance::_covariance_type>::value ==
kCovarianceMatrixRowsSquared, "We expect the covariance matrix to have 36 entries.");
// TODO(#789 autoware_auto_msgs) add a static assert once the RelativePosition message covariance is
// represented by an std::array.
/// Convert the ROS timestamp to chrono time point.
std::chrono::system_clock::time_point to_time_point(const rclcpp::Time & time)
{
return std::chrono::system_clock::time_point{std::chrono::nanoseconds{time.nanoseconds()}};
}
} // namespace
namespace autoware
{
namespace common
{
namespace state_estimation
{
template<>
Measurement2dSpeed64 message_to_measurement(
const geometry_msgs::msg::TwistWithCovariance & msg)
{
Eigen::Vector2d mean{msg.twist.linear.x, msg.twist.linear.y};
Eigen::Matrix2d covariance;
covariance <<
msg.covariance[kIndexX], msg.covariance[kIndexXY],
msg.covariance[kIndexYX], msg.covariance[kIndexY];
return Measurement2dSpeed64{
mean,
covariance};
}
template<>
Measurement2dPose64 message_to_measurement(
const geometry_msgs::msg::PoseWithCovariance & msg)
{
Eigen::Vector2d mean{msg.pose.position.x, msg.pose.position.y};
Eigen::Matrix2d covariance;
covariance <<
msg.covariance[kIndexX], msg.covariance[kIndexXY],
msg.covariance[kIndexYX], msg.covariance[kIndexY];
return Measurement2dPose64{
mean,
covariance};
}
template<>
StampedMeasurement2dSpeed64 message_to_measurement(
const geometry_msgs::msg::TwistWithCovarianceStamped & msg)
{
return StampedMeasurement2dSpeed64{
to_time_point(msg.header.stamp),
message_to_measurement<Measurement2dSpeed64>(msg.twist)
};
}
template<>
StampedMeasurement2dPose64 message_to_measurement(
const geometry_msgs::msg::PoseWithCovarianceStamped & msg)
{
return StampedMeasurement2dPose64{
to_time_point(msg.header.stamp),
message_to_measurement<Measurement2dPose64>(msg.pose)
};
}
template<>
StampedMeasurement2dPose64 message_to_measurement(
const autoware_auto_msgs::msg::RelativePositionWithCovarianceStamped & msg)
{
Eigen::Vector2d mean{msg.position.x, msg.position.y};
Eigen::Matrix2d covariance;
covariance <<
msg.covariance[kIndexXRelativePos], msg.covariance[kIndexXYRelativePos],
msg.covariance[kIndexYXRelativePos], msg.covariance[kIndexYRelativePos];
return StampedMeasurement2dPose64{
to_time_point(msg.header.stamp),
Measurement2dPose64{mean, covariance}};
}
template<>
StampedMeasurement2dPoseAndSpeed64 message_to_measurement(
const nav_msgs::msg::Odometry & msg)
{
Eigen::Isometry3d tf__msg_frame_id__msg_child_frame_id;
tf2::fromMsg(msg.pose.pose, tf__msg_frame_id__msg_child_frame_id);
const Eigen::Matrix2d rx__msg_frame_id__msg_child_frame_id = downscale_isometry<2>(
tf__msg_frame_id__msg_child_frame_id).rotation();
const Eigen::Vector2d pos_state {
msg.pose.pose.position.x,
msg.pose.pose.position.y,
};
const Eigen::Vector2d speed_in_child_frame{
msg.twist.twist.linear.x,
msg.twist.twist.linear.y,
};
const Eigen::Vector2d speed{rx__msg_frame_id__msg_child_frame_id * speed_in_child_frame};
Eigen::Matrix4d covariance{Eigen::Matrix4d::Zero()};
covariance.topLeftCorner(2, 2) <<
msg.pose.covariance[kIndexX], msg.pose.covariance[kIndexXY],
msg.pose.covariance[kIndexYX], msg.pose.covariance[kIndexY];
covariance.bottomRightCorner(2, 2) <<
msg.twist.covariance[kIndexX], msg.twist.covariance[kIndexXY],
msg.twist.covariance[kIndexYX], msg.twist.covariance[kIndexY];
// Rotate the speed covariance as the speed is now in frame_id frame and not in child_frame_id.
covariance.bottomRightCorner(2, 2) =
rx__msg_frame_id__msg_child_frame_id *
covariance.bottomRightCorner(2, 2) *
rx__msg_frame_id__msg_child_frame_id.transpose();
const Eigen::Vector4d mean = (Eigen::Vector4d{} << pos_state, speed).finished();
return StampedMeasurement2dPoseAndSpeed64{
to_time_point(msg.header.stamp),
Measurement2dPoseAndSpeed64{mean, covariance}};
}
} // namespace state_estimation
} // namespace common
} // namespace autoware
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.