hexsha
stringlengths 40
40
| size
int64 7
1.05M
| ext
stringclasses 13
values | lang
stringclasses 1
value | max_stars_repo_path
stringlengths 4
269
| max_stars_repo_name
stringlengths 5
109
| max_stars_repo_head_hexsha
stringlengths 40
40
| max_stars_repo_licenses
sequencelengths 1
9
| max_stars_count
int64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 4
269
| max_issues_repo_name
stringlengths 5
116
| max_issues_repo_head_hexsha
stringlengths 40
40
| max_issues_repo_licenses
sequencelengths 1
9
| max_issues_count
int64 1
48.5k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 4
269
| max_forks_repo_name
stringlengths 5
116
| max_forks_repo_head_hexsha
stringlengths 40
40
| max_forks_repo_licenses
sequencelengths 1
9
| max_forks_count
int64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 7
1.05M
| avg_line_length
float64 1.21
330k
| max_line_length
int64 6
990k
| alphanum_fraction
float64 0.01
0.99
| author_id
stringlengths 2
40
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3b88994e9f2bba31d5310cd887f4d29babc32da0 | 2,239 | cpp | C++ | libraries/MySensors/core/MyTransportRFM95.cpp | kaniick/Growtek-Controller | 9826776fa1c6f835c84f62dac84e1848509d9e76 | [
"MIT"
] | null | null | null | libraries/MySensors/core/MyTransportRFM95.cpp | kaniick/Growtek-Controller | 9826776fa1c6f835c84f62dac84e1848509d9e76 | [
"MIT"
] | null | null | null | libraries/MySensors/core/MyTransportRFM95.cpp | kaniick/Growtek-Controller | 9826776fa1c6f835c84f62dac84e1848509d9e76 | [
"MIT"
] | null | null | null | /*
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <[email protected]>
* Copyright (C) 2013-2016 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*/
#include "MyConfig.h"
#include "MyTransport.h"
#include "drivers/RFM95/RFM95.h"
bool transportInit(void)
{
const bool result = RFM95_initialise(MY_RFM95_FREQUENCY);
#if !defined(MY_GATEWAY_FEATURE) && !defined(MY_RFM95_ATC_MODE_DISABLED)
// only enable ATC mode nodes
RFM95_ATCmode(true, MY_RFM95_ATC_TARGET_RSSI);
#endif
return result;
}
void transportSetAddress(const uint8_t address)
{
RFM95_setAddress(address);
}
uint8_t transportGetAddress(void)
{
return RFM95_getAddress();
}
bool transportSend(const uint8_t to, const void* data, const uint8_t len)
{
return RFM95_sendWithRetry(to, data, len);
}
bool transportAvailable(void)
{
return RFM95_available();
}
bool transportSanityCheck(void)
{
return RFM95_sanityCheck();
}
uint8_t transportReceive(void* data)
{
return RFM95_recv((uint8_t*)data);
}
void transportPowerDown(void)
{
(void)RFM95_sleep();
}
// experimental
// **********************************************
int16_t transportGetReceivingSignalStrength(void)
{
return RFM95_getReceivingRSSI();
}
int16_t transportGetSendingSignalStrength(void)
{
return RFM95_getSendingRSSI();
}
int8_t transportGetReceivingSNR(void)
{
return RFM95_getReceivingSNR();
}
int8_t transportGetSendingSNR(void)
{
return RFM95_getSendingSNR();
}
uint8_t transportGetTxPower(void)
{
return RFM95_getTxPowerPercent();
}
// **********************************************
| 24.075269 | 82 | 0.742742 | kaniick |
3b8b4dd936642a50874ddf4d96dcf5027ed46148 | 443 | cpp | C++ | src/helped/stdafx.cpp | ptitSeb/freespace2 | 500ee249f7033aac9b389436b1737a404277259c | [
"Linux-OpenIB"
] | 1 | 2020-07-14T07:29:18.000Z | 2020-07-14T07:29:18.000Z | src/helped/stdafx.cpp | ptitSeb/freespace2 | 500ee249f7033aac9b389436b1737a404277259c | [
"Linux-OpenIB"
] | 2 | 2019-01-01T22:35:56.000Z | 2022-03-14T07:34:00.000Z | src/helped/stdafx.cpp | ptitSeb/freespace2 | 500ee249f7033aac9b389436b1737a404277259c | [
"Linux-OpenIB"
] | 2 | 2021-03-07T11:40:42.000Z | 2021-12-26T21:40:39.000Z | /*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on
* the source.
*/
// stdafx.cpp : source file that includes just the standard includes
// HelpEd.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
| 26.058824 | 78 | 0.733634 | ptitSeb |
3b8f3e6c815e4d483f03628723a32b0e543bfb76 | 1,434 | hpp | C++ | Code/Foundation/SpatialPartition/SpatialPartitionStandard.hpp | WelderUpdates/WelderEngineRevamp | 1c665239566e9c7156926852f7952948d9286d7d | [
"MIT"
] | 3 | 2022-02-11T10:34:33.000Z | 2022-02-24T17:44:17.000Z | Code/Foundation/SpatialPartition/SpatialPartitionStandard.hpp | WelderUpdates/WelderEngineRevamp | 1c665239566e9c7156926852f7952948d9286d7d | [
"MIT"
] | null | null | null | Code/Foundation/SpatialPartition/SpatialPartitionStandard.hpp | WelderUpdates/WelderEngineRevamp | 1c665239566e9c7156926852f7952948d9286d7d | [
"MIT"
] | null | null | null | // MIT Licensed (see LICENSE.md).
#pragma once
// Standard includes
#include "Foundation/Geometry/GeometryStandard.hpp"
#include "Foundation/Serialization/SerializationStandard.hpp"
namespace Zero
{
// SpatialPartition library
class ZeroNoImportExport SpatialPartitionLibrary : public Zilch::StaticLibrary
{
public:
ZilchDeclareStaticLibraryInternals(SpatialPartitionLibrary, "ZeroEngine");
static void Initialize();
static void Shutdown();
};
} // namespace Zero
// Project includes
#include "BroadPhaseProxy.hpp"
#include "ProxyCast.hpp"
#include "BroadPhase.hpp"
#include "SimpleCastCallbacks.hpp"
#include "BroadPhaseRanges.hpp"
#include "BaseDynamicAabbTreeBroadPhase.hpp"
#include "DynamicTreeHelpers.hpp"
#include "BaseDynamicAabbTree.hpp"
#include "AvlDynamicAabbTree.hpp"
#include "DynamicAabbTree.hpp"
#include "DynamicAabbTreeBroadPhase.hpp"
#include "AvlDynamicAabbTreeBroadPhase.hpp"
#include "BaseNSquared.hpp"
#include "NSquared.hpp"
#include "NSquaredBroadPhase.hpp"
#include "BoundingBox.hpp"
#include "BoundingBoxBroadPhase.hpp"
#include "BoundingSphere.hpp"
#include "BoundingSphereBroadPhase.hpp"
#include "SapContainers.hpp"
#include "Sap.hpp"
#include "SapBroadPhase.hpp"
#include "AabbTreeNode.hpp"
#include "AabbTreeMethods.hpp"
#include "StaticAabbTree.hpp"
#include "StaticAabbTreeBroadPhase.hpp"
#include "BroadPhasePackage.hpp"
#include "BroadPhaseCreator.hpp"
#include "BroadPhaseTracker.hpp"
| 27.056604 | 78 | 0.806137 | WelderUpdates |
3b8ff879cc0962061baa0750af07664605e96750 | 1,299 | cpp | C++ | src/Sova/Graphics/Color.cpp | connorcarpenter/sova | 3b640bea83c7fe1013196977c39a27e7cd4947ec | [
"MIT"
] | null | null | null | src/Sova/Graphics/Color.cpp | connorcarpenter/sova | 3b640bea83c7fe1013196977c39a27e7cd4947ec | [
"MIT"
] | null | null | null | src/Sova/Graphics/Color.cpp | connorcarpenter/sova | 3b640bea83c7fe1013196977c39a27e7cd4947ec | [
"MIT"
] | null | null | null | //
// Created by connor on 7/29/18.
//
#include "Color.h"
namespace Sova
{
Color::Color(int red, int green, int blue)
{
this->red = red;
this->green = green;
this->blue = blue;
}
Color Color::Red = Color(255, 0, 0);
Color Color::Green = Color(0, 255, 0);
Color Color::Blue = Color(0, 0, 255);
Color Color::Yellow = Color(255, 255, 0);
Color Color::White = Color(255, 255, 255);
Color Color::Black = Color(0, 0, 0);
Color Color::LightGray = Color(192, 192, 192);
Color Color::Gray = Color(128, 128, 128);
Color Color::DarkGray = Color(64, 64, 64);
Color Color::Brown = Color(128, 64, 0);
bool Color::operator==(const Color &other) const
{
return (this->red == other.red && this->blue == other.blue && this->green == other.green);
}
bool Color::operator!=(const Color &other) const
{
return (this->red != other.red || this->blue != other.blue || this->green != other.green);
}
Color Color::MixColors(Color color1, Color color2) {
int red = (color1.red*color2.red) / 255;
int blue = (color1.blue*color2.blue) / 255;
int green = (color1.green*color2.green) / 255;
return Color(red,
blue,
green);
}
} | 28.866667 | 98 | 0.558122 | connorcarpenter |
3b9114112533cdb7840fca15584b7e577a4cdc07 | 4,115 | cpp | C++ | src/zaurus/zinfones.cpp | jay-kumogata/InfoNES | 045dd572123753cd53bbbcd387b70a66d0a8562c | [
"Apache-2.0"
] | 6 | 2019-05-10T02:09:55.000Z | 2021-09-16T09:10:14.000Z | src/zaurus/zinfones.cpp | b004004/InfoNES-1 | 045dd572123753cd53bbbcd387b70a66d0a8562c | [
"Apache-2.0"
] | null | null | null | src/zaurus/zinfones.cpp | b004004/InfoNES-1 | 045dd572123753cd53bbbcd387b70a66d0a8562c | [
"Apache-2.0"
] | 1 | 2019-05-10T16:02:51.000Z | 2019-05-10T16:02:51.000Z | /*===================================================================*/
/* */
/* zinfones.cpp : A Qt-specific class implementation */
/* */
/* 2004/06/26 InfoNES Project */
/* */
/*===================================================================*/
/*-------------------------------------------------------------------*/
/* Include files */
/*-------------------------------------------------------------------*/
#include "zinfones.h"
/*-------------------------------------------------------------------*/
/* Constructor */
/*-------------------------------------------------------------------*/
zinfones::zinfones( WORD *wf )
{
/* FrameBuffer */
QDirectPainter dq( this );
pFb = (WORD *)dq.frameBuffer();
pWf = wf;
dx = dy = 0;
/* To center */
#if 0
/* 1.5 magnification */
setGeometry(320 - ( NES_DISP_WIDTH * 3 / 4 ), \
240 - ( NES_DISP_HEIGHT * 3 / 4 ), \
NES_DISP_WIDTH * 3 / 2, NES_DISP_HEIGHT * 3 / 2);
#else
setGeometry(320 - ( NES_DISP_WIDTH / 2 ), \
240 - ( NES_DISP_HEIGHT / 2 ), \
NES_DISP_WIDTH, NES_DISP_HEIGHT);
#endif
}
/* Repaint */
void zinfones::paintEvent( QPaintEvent * e )
{
/* To center */
#if 0
/* 1.5 magnification */
setGeometry(320 - ( NES_DISP_WIDTH * 3 / 4 ), \
240 - ( NES_DISP_HEIGHT * 3 / 4 ), \
NES_DISP_WIDTH * 3 / 2, NES_DISP_HEIGHT * 3 / 2);
#else
setGeometry(320 - ( NES_DISP_WIDTH / 2 ), \
240 - ( NES_DISP_HEIGHT / 2 ), \
NES_DISP_WIDTH, NES_DISP_HEIGHT);
#endif
}
/* Load Frame */
void zinfones::loadFrame()
{
/* If not active, doesn't draw */
if ( !isActiveWindow() )
return;
/* Draw a screen */
for ( register unsigned int x = 0; x < NES_DISP_WIDTH; x++ )
{
for ( register unsigned int y = 0; y < NES_DISP_HEIGHT; y++ )
{
/* Exchange 15-bit to 16-bit */
register WORD wColor = pWf[ ( y << 8 ) + x ];
wColor = ((wColor& 0x7fe0)<<1)|(wColor&0x001f);
#if 0
/* 1.5 magnification */
register int p = (((x+x+x)>>1)+dx) * 480 - (((y+y+y)>>1)+dy);
pFb[ p ] = wColor;
if (y&1) pFb[ p- 1 ] = wColor;
if (x&1) pFb[ p+480 ] = wColor;
if ((x&1)&&(y&1)) pFb[ p+479 ] = wColor;
#else
/* 1 magnification */
pFb[ (x + dx) * 480 - (y + dy) ] = wColor;
#endif
}
}
}
/* Key press */
void zinfones::keyPressEvent( QKeyEvent *e )
{
switch ( e->key() )
{
case Key_Right:
dwKeyPad1 |= (1<<7);
break;
case Key_Left:
dwKeyPad1 |= (1<<6);
break;
case Key_Down:
dwKeyPad1 |= (1<<5);
break;
case Key_Up:
dwKeyPad1 |= (1<<4);
break;
case Key_S:
dwKeyPad1 |= (1<<3);
break;
case Key_A:
dwKeyPad1 |= (1<<2);
break;
case Key_Z:
dwKeyPad1 |= (1<<1);
break;
case Key_X:
dwKeyPad1 |= (1<<0);
break;
/* extra */
case Key_C:
PPU_UpDown_Clip = ( PPU_UpDown_Clip ? 0 : 1);
break;
case Key_M:
APU_Mute = ( APU_Mute ? 0 : 1 );
break;
case Key_D:
FrameSkip = (FrameSkip == 0 ? 0 : FrameSkip - 1);
break;
case Key_U:
FrameSkip++;
break;
}
}
/* Key release */
void zinfones::keyReleaseEvent( QKeyEvent *e )
{
switch ( e->key() )
{
case Key_Right:
dwKeyPad1 &= ~(1<<7);
break;
case Key_Left:
dwKeyPad1 &= ~(1<<6);
break;
case Key_Down:
dwKeyPad1 &= ~(1<<5);
break;
case Key_Up:
dwKeyPad1 &= ~(1<<4);
break;
case Key_S:
dwKeyPad1 &= ~(1<<3);
break;
case Key_A:
dwKeyPad1 &= ~(1<<2);
break;
case Key_Z:
dwKeyPad1 &= ~(1<<1);
break;
case Key_X:
dwKeyPad1 &= ~(1<<0);
break;
}
}
/* Move */
void zinfones::moveEvent( QMoveEvent *e )
{
dx = e->pos().x();
dy = e->pos().y();
}
/* End of zinfones.cpp */
| 23.786127 | 71 | 0.425516 | jay-kumogata |
3b9348c67b2dbb10e9cb75758561c81519fc0cb8 | 1,830 | hh | C++ | unittests/libtests/bc/TestTimeDependent.hh | joegeisz/pylith | f74060b7b19d7e90abf8597bbe9250c96593c0ad | [
"MIT"
] | 1 | 2021-09-09T06:24:11.000Z | 2021-09-09T06:24:11.000Z | unittests/libtests/bc/TestTimeDependent.hh | joegeisz/pylith | f74060b7b19d7e90abf8597bbe9250c96593c0ad | [
"MIT"
] | null | null | null | unittests/libtests/bc/TestTimeDependent.hh | joegeisz/pylith | f74060b7b19d7e90abf8597bbe9250c96593c0ad | [
"MIT"
] | null | null | null | // -*- C++ -*-
//
// ----------------------------------------------------------------------
//
// Brad T. Aagaard, U.S. Geological Survey
// Charles A. Williams, GNS Science
// Matthew G. Knepley, University of Chicago
//
// This code was developed as part of the Computational Infrastructure
// for Geodynamics (http://geodynamics.org).
//
// Copyright (c) 2010-2017 University of California, Davis
//
// See COPYING for license information.
//
// ----------------------------------------------------------------------
//
/**
* @file unittests/libtests/bc/TestTimeDependent.hh
*
* @brief C++ TestTimeDependent object.
*
* C++ unit testing for TimeDependent.
*/
#if !defined(pylith_bc_testtimedependent_hh)
#define pylith_bc_testtimedependent_hh
#include <cppunit/extensions/HelperMacros.h>
/// Namespace for pylith package
namespace pylith {
namespace bc {
class TestTimeDependent;
} // bc
} // pylith
/// C++ unit testing for PointForce.
class pylith::bc::TestTimeDependent : public CppUnit::TestFixture
{ // class TestTimeDependent
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestTimeDependent );
CPPUNIT_TEST( testDBInitial );
CPPUNIT_TEST( testDBRate );
CPPUNIT_TEST( testDBChange );
CPPUNIT_TEST( testDBTimeHistory );
CPPUNIT_TEST( testVerifyConfiguration );
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
/// Test dbInitial().
void testDBInitial(void);
/// Test dbRate().
void testDBRate(void);
/// Test dbChange().
void testDBChange(void);
/// Test dbTimeHistory().
void testDBTimeHistory(void);
/// Test verifyConfiguration().
void testVerifyConfiguration(void);
}; // class TestTimeDependent
#endif // pylith_bc_pointforce_hh
// End of file
| 23.461538 | 73 | 0.615301 | joegeisz |
3b94feda02b7dff6720c3999e539581fdf424e62 | 33,509 | cpp | C++ | Blizzlike/Trinity/Scripts/Dungeons/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp | 499453466/Lua-Other | 43fd2b72405faf3f2074fd2a2706ef115d16faa6 | [
"Unlicense"
] | 2 | 2015-06-23T16:26:32.000Z | 2019-06-27T07:45:59.000Z | Blizzlike/Trinity/Scripts/Dungeons/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp | Eduardo-Silla/Lua-Other | db610f946dbcaf81b3de9801f758e11a7bf2753f | [
"Unlicense"
] | null | null | null | Blizzlike/Trinity/Scripts/Dungeons/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp | Eduardo-Silla/Lua-Other | db610f946dbcaf81b3de9801f758e11a7bf2753f | [
"Unlicense"
] | 3 | 2015-01-10T18:22:59.000Z | 2021-04-27T21:28:28.000Z | /*
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2006-2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* ScriptData
SDName: Boss_Lady_Vashj
SD%Complete: 99
SDComment: Missing blizzlike Shield Generators coords
SDCategory: Coilfang Resevoir, Serpent Shrine Cavern
EndScriptData */
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "serpent_shrine.h"
#include "Spell.h"
#define SAY_INTRO -1548042
#define SAY_AGGRO1 -1548043
#define SAY_AGGRO2 -1548044
#define SAY_AGGRO3 -1548045
#define SAY_AGGRO4 -1548046
#define SAY_PHASE1 -1548047
#define SAY_PHASE2 -1548048
#define SAY_PHASE3 -1548049
#define SAY_BOWSHOT1 -1548050
#define SAY_BOWSHOT2 -1548051
#define SAY_SLAY1 -1548052
#define SAY_SLAY2 -1548053
#define SAY_SLAY3 -1548054
#define SAY_DEATH -1548055
#define SPELL_SURGE 38044
#define SPELL_MULTI_SHOT 38310
#define SPELL_SHOCK_BLAST 38509
#define SPELL_ENTANGLE 38316
#define SPELL_STATIC_CHARGE_TRIGGER 38280
#define SPELL_FORKED_LIGHTNING 40088
#define SPELL_SHOOT 40873
#define SPELL_POISON_BOLT 40095
#define SPELL_TOXIC_SPORES 38575
#define SPELL_MAGIC_BARRIER 38112
#define MIDDLE_X 30.134f
#define MIDDLE_Y -923.65f
#define MIDDLE_Z 42.9f
#define SPOREBAT_X 30.977156f
#define SPOREBAT_Y -925.297761f
#define SPOREBAT_Z 77.176567f
#define SPOREBAT_O 5.223932f
#define SHIED_GENERATOR_CHANNEL 19870
#define ENCHANTED_ELEMENTAL 21958
#define TAINTED_ELEMENTAL 22009
#define COILFANG_STRIDER 22056
#define COILFANG_ELITE 22055
#define TOXIC_SPOREBAT 22140
#define TOXIC_SPORES_TRIGGER 22207
#define TEXT_NOT_INITIALIZED "Instance script not initialized"
#define TEXT_ALREADY_DEACTIVATED "Already deactivated"
float ElementPos[8][4] =
{
{8.3f, -835.3f, 21.9f, 5.0f},
{53.4f, -835.3f, 21.9f, 4.5f},
{96.0f, -861.9f, 21.8f, 4.0f},
{96.0f, -986.4f, 21.4f, 2.5f},
{54.4f, -1010.6f, 22, 1.8f},
{9.8f, -1012, 21.7f, 1.4f},
{-35.0f, -987.6f, 21.5f, 0.8f},
{-58.9f, -901.6f, 21.5f, 6.0f}
};
float ElementWPPos[8][3] =
{
{71.700752f, -883.905884f, 41.097168f},
{45.039848f, -868.022827f, 41.097015f},
{14.585141f, -867.894470f, 41.097061f},
{-25.415508f, -906.737732f, 41.097061f},
{-11.801594f, -963.405884f, 41.097067f},
{14.556657f, -979.051514f, 41.097137f},
{43.466549f, -979.406677f, 41.097027f},
{69.945908f, -964.663940f, 41.097054f}
};
float SporebatWPPos[8][3] =
{
{31.6f, -896.3f, 59.1f},
{9.1f, -913.9f, 56.0f},
{5.2f, -934.4f, 52.4f},
{20.7f, -946.9f, 49.7f},
{41.0f, -941.9f, 51.0f},
{47.7f, -927.3f, 55.0f},
{42.2f, -912.4f, 51.7f},
{27.0f, -905.9f, 50.0f}
};
float CoilfangElitePos[3][4] =
{
{28.84f, -923.28f, 42.9f, 6.0f},
{31.183281f, -953.502625f, 41.523602f, 1.640957f},
{58.895180f, -923.124268f, 41.545307f, 3.152848f}
};
float CoilfangStriderPos[3][4] =
{
{66.427010f, -948.778503f, 41.262245f, 2.584220f},
{7.513962f, -959.538208f, 41.300422f, 1.034629f},
{-12.843201f, -907.798401f, 41.239620f, 6.087094f}
};
float ShieldGeneratorChannelPos[4][4] =
{
{49.6262f, -902.181f, 43.0975f, 3.95683f},
{10.988f, -901.616f, 42.5371f, 5.4373f},
{10.3859f, -944.036f, 42.5446f, 0.779888f},
{49.3126f, -943.398f, 42.5501f, 2.40174f}
};
class boss_lady_vashj : public CreatureScript
{
public:
boss_lady_vashj() : CreatureScript("boss_lady_vashj") { }
CreatureAI* GetAI(Creature* creature) const
{
return new boss_lady_vashjAI (creature);
}
struct boss_lady_vashjAI : public ScriptedAI
{
boss_lady_vashjAI (Creature* creature) : ScriptedAI(creature)
{
instance = creature->GetInstanceScript();
Intro = false;
JustCreated = true;
creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); // set it only once on Creature create (no need do intro if wiped)
}
InstanceScript* instance;
uint64 ShieldGeneratorChannel[4];
uint32 AggroTimer;
uint32 ShockBlastTimer;
uint32 EntangleTimer;
uint32 StaticChargeTimer;
uint32 ForkedLightningTimer;
uint32 CheckTimer;
uint32 EnchantedElementalTimer;
uint32 TaintedElementalTimer;
uint32 CoilfangEliteTimer;
uint32 CoilfangStriderTimer;
uint32 SummonSporebatTimer;
uint32 SummonSporebatStaticTimer;
uint8 EnchantedElementalPos;
uint8 Phase;
bool Entangle;
bool Intro;
bool CanAttack;
bool JustCreated;
void Reset()
{
AggroTimer = 19000;
ShockBlastTimer = 1+rand()%60000;
EntangleTimer = 30000;
StaticChargeTimer = 10000+rand()%15000;
ForkedLightningTimer = 2000;
CheckTimer = 15000;
EnchantedElementalTimer = 5000;
TaintedElementalTimer = 50000;
CoilfangEliteTimer = 45000+rand()%5000;
CoilfangStriderTimer = 60000+rand()%10000;
SummonSporebatTimer = 10000;
SummonSporebatStaticTimer = 30000;
EnchantedElementalPos = 0;
Phase = 0;
Entangle = false;
if (JustCreated)
{
CanAttack = false;
JustCreated = false;
} else CanAttack = true;
for (uint8 i = 0; i < 4; ++i)
if (Unit* remo = Unit::GetUnit(*me, ShieldGeneratorChannel[i]))
remo->setDeathState(JUST_DIED);
if (instance)
instance->SetData(DATA_LADYVASHJEVENT, NOT_STARTED);
ShieldGeneratorChannel[0] = 0;
ShieldGeneratorChannel[1] = 0;
ShieldGeneratorChannel[2] = 0;
ShieldGeneratorChannel[3] = 0;
me->SetCorpseDelay(1000*60*60);
}
// Called when a tainted elemental dies
void EventTaintedElementalDeath()
{
// the next will spawn 50 seconds after the previous one's death
if (TaintedElementalTimer > 50000)
TaintedElementalTimer = 50000;
}
void KilledUnit(Unit* /*victim*/)
{
DoScriptText(RAND(SAY_SLAY1, SAY_SLAY2, SAY_SLAY3), me);
}
void JustDied(Unit* /*killer*/)
{
DoScriptText(SAY_DEATH, me);
if (instance)
instance->SetData(DATA_LADYVASHJEVENT, DONE);
}
void StartEvent()
{
DoScriptText(RAND(SAY_AGGRO1, SAY_AGGRO2, SAY_AGGRO3, SAY_AGGRO4), me);
Phase = 1;
if (instance)
instance->SetData(DATA_LADYVASHJEVENT, IN_PROGRESS);
}
void EnterCombat(Unit* who)
{
if (instance)
{
// remove old tainted cores to prevent cheating in phase 2
Map* map = me->GetMap();
Map::PlayerList const &PlayerList = map->GetPlayers();
for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
if (Player* player = itr->getSource())
player->DestroyItemCount(31088, 1, true);
}
StartEvent(); // this is EnterCombat(), so were are 100% in combat, start the event
if (Phase != 2)
AttackStart(who);
}
void MoveInLineOfSight(Unit* who)
{
if (!Intro)
{
Intro = true;
DoScriptText(SAY_INTRO, me);
}
if (!CanAttack)
return;
if (!who || me->getVictim())
return;
if (me->canCreatureAttack(who))
{
float attackRadius = me->GetAttackDistance(who);
if (me->IsWithinDistInMap(who, attackRadius) && me->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && me->IsWithinLOSInMap(who))
{
if (!me->isInCombat()) // AttackStart() sets UNIT_FLAG_IN_COMBAT, so this msut be before attacking
StartEvent();
if (Phase != 2)
AttackStart(who);
}
}
}
void CastShootOrMultishot()
{
switch (urand(0, 1))
{
case 0:
// Shoot
// Used in Phases 1 and 3 after Entangle or while having nobody in melee range. A shot that hits her target for 4097-5543 Physical damage.
DoCast(me->getVictim(), SPELL_SHOOT);
break;
case 1:
// Multishot
// Used in Phases 1 and 3 after Entangle or while having nobody in melee range. A shot that hits 1 person and 4 people around him for 6475-7525 physical damage.
DoCast(me->getVictim(), SPELL_MULTI_SHOT);
break;
}
if (rand()%3)
{
DoScriptText(RAND(SAY_BOWSHOT1, SAY_BOWSHOT2), me);
}
}
void UpdateAI(const uint32 diff)
{
if (!CanAttack && Intro)
{
if (AggroTimer <= diff)
{
CanAttack = true;
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
AggroTimer=19000;
}
else
{
AggroTimer-=diff;
return;
}
}
// to prevent abuses during phase 2
if (Phase == 2 && !me->getVictim() && me->isInCombat())
{
EnterEvadeMode();
return;
}
// Return since we have no target
if (!UpdateVictim())
return;
if (Phase == 1 || Phase == 3)
{
// ShockBlastTimer
if (ShockBlastTimer <= diff)
{
// Shock Burst
// Randomly used in Phases 1 and 3 on Vashj's target, it's a Shock spell doing 8325-9675 nature damage and stunning the target for 5 seconds, during which she will not attack her target but switch to the next person on the aggro list.
DoCast(me->getVictim(), SPELL_SHOCK_BLAST);
me->TauntApply(me->getVictim());
ShockBlastTimer = 1000+rand()%14000; // random cooldown
} else ShockBlastTimer -= diff;
// StaticChargeTimer
if (StaticChargeTimer <= diff)
{
// Static Charge
// Used on random people (only 1 person at any given time) in Phases 1 and 3, it's a debuff doing 2775 to 3225 Nature damage to the target and everybody in about 5 yards around it, every 1 seconds for 30 seconds. It can be removed by Cloak of Shadows, Iceblock, Divine Shield, etc, but not by Cleanse or Dispel Magic.
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 200, true);
if (target && !target->HasAura(SPELL_STATIC_CHARGE_TRIGGER))
DoCast(target, SPELL_STATIC_CHARGE_TRIGGER); // cast Static Charge every 2 seconds for 20 seconds
StaticChargeTimer = 10000+rand()%20000;
} else StaticChargeTimer -= diff;
// EntangleTimer
if (EntangleTimer <= diff)
{
if (!Entangle)
{
// Entangle
// Used in Phases 1 and 3, it casts Entangling Roots on everybody in a 15 yard radius of Vashj, immobilzing them for 10 seconds and dealing 500 damage every 2 seconds. It's not a magic effect so it cannot be dispelled, but is removed by various buffs such as Cloak of Shadows or Blessing of Freedom.
DoCast(me->getVictim(), SPELL_ENTANGLE);
Entangle = true;
EntangleTimer = 10000;
}
else
{
CastShootOrMultishot();
Entangle = false;
EntangleTimer = 20000+rand()%5000;
}
} else EntangleTimer -= diff;
// Phase 1
if (Phase == 1)
{
// Start phase 2
if (HealthBelowPct(70))
{
// Phase 2 begins when Vashj hits 70%. She will run to the middle of her platform and surround herself in a shield making her invulerable.
Phase = 2;
me->GetMotionMaster()->Clear();
DoTeleportTo(MIDDLE_X, MIDDLE_Y, MIDDLE_Z);
for (uint8 i = 0; i < 4; ++i)
if (Creature* creature = me->SummonCreature(SHIED_GENERATOR_CHANNEL, ShieldGeneratorChannelPos[i][0], ShieldGeneratorChannelPos[i][1], ShieldGeneratorChannelPos[i][2], ShieldGeneratorChannelPos[i][3], TEMPSUMMON_CORPSE_DESPAWN, 0))
ShieldGeneratorChannel[i] = creature->GetGUID();
DoScriptText(SAY_PHASE2, me);
}
}
// Phase 3
else
{
// SummonSporebatTimer
if (SummonSporebatTimer <= diff)
{
if (Creature* sporebat = me->SummonCreature(TOXIC_SPOREBAT, SPOREBAT_X, SPOREBAT_Y, SPOREBAT_Z, SPOREBAT_O, TEMPSUMMON_CORPSE_DESPAWN, 0))
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
sporebat->AI()->AttackStart(target);
// summon sporebats faster and faster
if (SummonSporebatStaticTimer > 1000)
SummonSporebatStaticTimer -= 1000;
SummonSporebatTimer = SummonSporebatStaticTimer;
if (SummonSporebatTimer < 5000)
SummonSporebatTimer = 5000;
} else SummonSporebatTimer -= diff;
}
// Melee attack
DoMeleeAttackIfReady();
// CheckTimer - used to check if somebody is in melee range
if (CheckTimer <= diff)
{
bool inMeleeRange = false;
std::list<HostileReference*> t_list = me->getThreatManager().getThreatList();
for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
{
Unit* target = Unit::GetUnit(*me, (*itr)->getUnitGuid());
if (target && target->IsWithinDistInMap(me, 5)) // if in melee range
{
inMeleeRange = true;
break;
}
}
// if nobody is in melee range
if (!inMeleeRange)
CastShootOrMultishot();
CheckTimer = 5000;
} else CheckTimer -= diff;
}
// Phase 2
else
{
// ForkedLightningTimer
if (ForkedLightningTimer <= diff)
{
// Forked Lightning
// Used constantly in Phase 2, it shoots out completely randomly targeted bolts of lightning which hit everybody in a roughtly 60 degree cone in front of Vashj for 2313-2687 nature damage.
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0);
if (!target)
target = me->getVictim();
DoCast(target, SPELL_FORKED_LIGHTNING);
ForkedLightningTimer = 2000+rand()%6000;
} else ForkedLightningTimer -= diff;
// EnchantedElementalTimer
if (EnchantedElementalTimer <= diff)
{
me->SummonCreature(ENCHANTED_ELEMENTAL, ElementPos[EnchantedElementalPos][0], ElementPos[EnchantedElementalPos][1], ElementPos[EnchantedElementalPos][2], ElementPos[EnchantedElementalPos][3], TEMPSUMMON_CORPSE_DESPAWN, 0);
if (EnchantedElementalPos == 7)
EnchantedElementalPos = 0;
else
++EnchantedElementalPos;
EnchantedElementalTimer = 10000+rand()%5000;
} else EnchantedElementalTimer -= diff;
// TaintedElementalTimer
if (TaintedElementalTimer <= diff)
{
uint32 pos = rand()%8;
me->SummonCreature(TAINTED_ELEMENTAL, ElementPos[pos][0], ElementPos[pos][1], ElementPos[pos][2], ElementPos[pos][3], TEMPSUMMON_DEAD_DESPAWN, 0);
TaintedElementalTimer = 120000;
} else TaintedElementalTimer -= diff;
// CoilfangEliteTimer
if (CoilfangEliteTimer <= diff)
{
uint32 pos = rand()%3;
Creature* coilfangElite = me->SummonCreature(COILFANG_ELITE, CoilfangElitePos[pos][0], CoilfangElitePos[pos][1], CoilfangElitePos[pos][2], CoilfangElitePos[pos][3], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
if (coilfangElite)
{
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
coilfangElite->AI()->AttackStart(target);
else if (me->getVictim())
coilfangElite->AI()->AttackStart(me->getVictim());
}
CoilfangEliteTimer = 45000+rand()%5000;
} else CoilfangEliteTimer -= diff;
// CoilfangStriderTimer
if (CoilfangStriderTimer <= diff)
{
uint32 pos = rand()%3;
if (Creature* CoilfangStrider = me->SummonCreature(COILFANG_STRIDER, CoilfangStriderPos[pos][0], CoilfangStriderPos[pos][1], CoilfangStriderPos[pos][2], CoilfangStriderPos[pos][3], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000))
{
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
CoilfangStrider->AI()->AttackStart(target);
else if (me->getVictim())
CoilfangStrider->AI()->AttackStart(me->getVictim());
}
CoilfangStriderTimer = 60000+rand()%10000;
} else CoilfangStriderTimer -= diff;
// CheckTimer
if (CheckTimer <= diff)
{
// Start Phase 3
if (instance && instance->GetData(DATA_CANSTARTPHASE3))
{
// set life 50%
me->SetHealth(me->CountPctFromMaxHealth(50));
me->RemoveAurasDueToSpell(SPELL_MAGIC_BARRIER);
DoScriptText(SAY_PHASE3, me);
Phase = 3;
// return to the tank
me->GetMotionMaster()->MoveChase(me->getVictim());
}
CheckTimer = 1000;
} else CheckTimer -= diff;
}
}
};
};
// Enchanted Elemental
// If one of them reaches Vashj he will increase her damage done by 5%.
class mob_enchanted_elemental : public CreatureScript
{
public:
mob_enchanted_elemental() : CreatureScript("mob_enchanted_elemental") { }
CreatureAI* GetAI(Creature* creature) const
{
return new mob_enchanted_elementalAI (creature);
}
struct mob_enchanted_elementalAI : public ScriptedAI
{
mob_enchanted_elementalAI(Creature* creature) : ScriptedAI(creature)
{
instance = creature->GetInstanceScript();
}
InstanceScript* instance;
uint32 Move;
uint32 Phase;
float X, Y, Z;
uint64 VashjGUID;
void Reset()
{
me->SetSpeed(MOVE_WALK, 0.6f); // walk
me->SetSpeed(MOVE_RUN, 0.6f); // run
Move = 0;
Phase = 1;
VashjGUID = 0;
X = ElementWPPos[0][0];
Y = ElementWPPos[0][1];
Z = ElementWPPos[0][2];
//search for nearest waypoint (up on stairs)
for (uint32 i = 1; i < 8; ++i)
{
if (me->GetDistance(ElementWPPos[i][0], ElementWPPos[i][1], ElementWPPos[i][2]) < me->GetDistance(X, Y, Z))
{
X = ElementWPPos[i][0];
Y = ElementWPPos[i][1];
Z = ElementWPPos[i][2];
}
}
if (instance)
VashjGUID = instance->GetData64(DATA_LADYVASHJ);
}
void EnterCombat(Unit* /*who*/) {}
void MoveInLineOfSight(Unit* /*who*/) {}
void UpdateAI(const uint32 diff)
{
if (!instance)
return;
if (!VashjGUID)
return;
if (Move <= diff)
{
me->SetWalk(true);
if (Phase == 1)
me->GetMotionMaster()->MovePoint(0, X, Y, Z);
if (Phase == 1 && me->IsWithinDist3d(X, Y, Z, 0.1f))
Phase = 2;
if (Phase == 2)
{
me->GetMotionMaster()->MovePoint(0, MIDDLE_X, MIDDLE_Y, MIDDLE_Z);
Phase = 3;
}
if (Phase == 3)
{
me->GetMotionMaster()->MovePoint(0, MIDDLE_X, MIDDLE_Y, MIDDLE_Z);
if (me->IsWithinDist3d(MIDDLE_X, MIDDLE_Y, MIDDLE_Z, 3))
DoCast(me, SPELL_SURGE);
}
if (Creature* vashj = Unit::GetCreature(*me, VashjGUID))
if (!vashj->isInCombat() || CAST_AI(boss_lady_vashj::boss_lady_vashjAI, vashj->AI())->Phase != 2 || vashj->isDead())
me->Kill(me);
Move = 1000;
} else Move -= diff;
}
};
};
// Tainted Elemental
// This mob has 7, 900 life, doesn't move, and shoots Poison Bolts at one person anywhere in the area, doing 3, 000 nature damage and placing a posion doing 2, 000 damage every 2 seconds. He will switch targets often, or sometimes just hang on a single player, but there is nothing you can do about it except heal the damage and kill the Tainted Elemental
class mob_tainted_elemental : public CreatureScript
{
public:
mob_tainted_elemental() : CreatureScript("mob_tainted_elemental") { }
CreatureAI* GetAI(Creature* creature) const
{
return new mob_tainted_elementalAI (creature);
}
struct mob_tainted_elementalAI : public ScriptedAI
{
mob_tainted_elementalAI(Creature* creature) : ScriptedAI(creature)
{
instance = creature->GetInstanceScript();
}
InstanceScript* instance;
uint32 PoisonBoltTimer;
uint32 DespawnTimer;
void Reset()
{
PoisonBoltTimer = 5000+rand()%5000;
DespawnTimer = 30000;
}
void JustDied(Unit* /*killer*/)
{
if (instance)
if (Creature* vashj = Unit::GetCreature((*me), instance->GetData64(DATA_LADYVASHJ)))
CAST_AI(boss_lady_vashj::boss_lady_vashjAI, vashj->AI())->EventTaintedElementalDeath();
}
void EnterCombat(Unit* who)
{
me->AddThreat(who, 0.1f);
}
void UpdateAI(const uint32 diff)
{
// PoisonBoltTimer
if (PoisonBoltTimer <= diff)
{
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0);
if (target && target->IsWithinDistInMap(me, 30))
DoCast(target, SPELL_POISON_BOLT);
PoisonBoltTimer = 5000+rand()%5000;
} else PoisonBoltTimer -= diff;
// DespawnTimer
if (DespawnTimer <= diff)
{
// call Unsummon()
me->setDeathState(DEAD);
// to prevent crashes
DespawnTimer = 1000;
} else DespawnTimer -= diff;
}
};
};
//Toxic Sporebat
//Toxic Spores: Used in Phase 3 by the Spore Bats, it creates a contaminated green patch of ground, dealing about 2775-3225 nature damage every second to anyone who stands in it.
class mob_toxic_sporebat : public CreatureScript
{
public:
mob_toxic_sporebat() : CreatureScript("mob_toxic_sporebat") { }
CreatureAI* GetAI(Creature* creature) const
{
return new mob_toxic_sporebatAI (creature);
}
struct mob_toxic_sporebatAI : public ScriptedAI
{
mob_toxic_sporebatAI(Creature* creature) : ScriptedAI(creature)
{
instance = creature->GetInstanceScript();
EnterEvadeMode();
}
InstanceScript* instance;
uint32 MovementTimer;
uint32 ToxicSporeTimer;
uint32 BoltTimer;
uint32 CheckTimer;
void Reset()
{
me->SetDisableGravity(true);
me->setFaction(14);
MovementTimer = 0;
ToxicSporeTimer = 5000;
BoltTimer = 5500;
CheckTimer = 1000;
}
void MoveInLineOfSight(Unit* /*who*/)
{
}
void MovementInform(uint32 type, uint32 id)
{
if (type != POINT_MOTION_TYPE)
return;
if (id == 1)
MovementTimer = 0;
}
void UpdateAI (const uint32 diff)
{
// Random movement
if (MovementTimer <= diff)
{
uint32 rndpos = rand()%8;
me->GetMotionMaster()->MovePoint(1, SporebatWPPos[rndpos][0], SporebatWPPos[rndpos][1], SporebatWPPos[rndpos][2]);
MovementTimer = 6000;
} else MovementTimer -= diff;
// toxic spores
if (BoltTimer <= diff)
{
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
{
if (Creature* trig = me->SummonCreature(TOXIC_SPORES_TRIGGER, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 30000))
{
trig->setFaction(14);
trig->CastSpell(trig, SPELL_TOXIC_SPORES, true);
}
}
BoltTimer = 10000+rand()%5000;
}
else BoltTimer -= diff;
// CheckTimer
if (CheckTimer <= diff)
{
if (instance)
{
// check if vashj is death
Unit* Vashj = Unit::GetUnit(*me, instance->GetData64(DATA_LADYVASHJ));
if (!Vashj || (Vashj && !Vashj->isAlive()) || (Vashj && CAST_AI(boss_lady_vashj::boss_lady_vashjAI, CAST_CRE(Vashj)->AI())->Phase != 3))
{
// remove
me->setDeathState(DEAD);
me->RemoveCorpse();
me->setFaction(35);
}
}
CheckTimer = 1000;
} else CheckTimer -= diff;
}
};
};
class mob_shield_generator_channel : public CreatureScript
{
public:
mob_shield_generator_channel() : CreatureScript("mob_shield_generator_channel") { }
CreatureAI* GetAI(Creature* creature) const
{
return new mob_shield_generator_channelAI (creature);
}
struct mob_shield_generator_channelAI : public ScriptedAI
{
mob_shield_generator_channelAI(Creature* creature) : ScriptedAI(creature)
{
instance = creature->GetInstanceScript();
}
InstanceScript* instance;
uint32 CheckTimer;
bool Casted;
void Reset()
{
CheckTimer = 0;
Casted = false;
me->SetDisplayId(11686); // invisible
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
}
void MoveInLineOfSight(Unit* /*who*/) {}
void UpdateAI (const uint32 diff)
{
if (!instance)
return;
if (CheckTimer <= diff)
{
Unit* vashj = Unit::GetUnit(*me, instance->GetData64(DATA_LADYVASHJ));
if (vashj && vashj->isAlive())
{
// start visual channel
if (!Casted || !vashj->HasAura(SPELL_MAGIC_BARRIER))
{
DoCast(vashj, SPELL_MAGIC_BARRIER, true);
Casted = true;
}
}
CheckTimer = 1000;
} else CheckTimer -= diff;
}
};
};
class item_tainted_core : public ItemScript
{
public:
item_tainted_core() : ItemScript("item_tainted_core") { }
bool OnUse(Player* player, Item* /*item*/, SpellCastTargets const& targets)
{
InstanceScript* instance = player->GetInstanceScript();
if (!instance)
{
player->GetSession()->SendNotification(TEXT_NOT_INITIALIZED);
return true;
}
Creature* vashj = Unit::GetCreature((*player), instance->GetData64(DATA_LADYVASHJ));
if (vashj && (CAST_AI(boss_lady_vashj::boss_lady_vashjAI, vashj->AI())->Phase == 2))
{
if (GameObject* gObj = targets.GetGOTarget())
{
uint32 identifier;
uint8 channelIdentifier;
switch (gObj->GetEntry())
{
case 185052:
identifier = DATA_SHIELDGENERATOR1;
channelIdentifier = 0;
break;
case 185053:
identifier = DATA_SHIELDGENERATOR2;
channelIdentifier = 1;
break;
case 185051:
identifier = DATA_SHIELDGENERATOR3;
channelIdentifier = 2;
break;
case 185054:
identifier = DATA_SHIELDGENERATOR4;
channelIdentifier = 3;
break;
default:
return true;
}
if (instance->GetData(identifier))
{
player->GetSession()->SendNotification(TEXT_ALREADY_DEACTIVATED);
return true;
}
// get and remove channel
if (Unit* channel = Unit::GetCreature(*vashj, CAST_AI(boss_lady_vashj::boss_lady_vashjAI, vashj->AI())->ShieldGeneratorChannel[channelIdentifier]))
channel->setDeathState(JUST_DIED); // call Unsummon()
instance->SetData(identifier, 1);
// remove this item
player->DestroyItemCount(31088, 1, true);
return true;
}
else if (targets.GetUnitTarget()->GetTypeId() == TYPEID_UNIT)
return false;
else if (targets.GetUnitTarget()->GetTypeId() == TYPEID_PLAYER)
{
player->DestroyItemCount(31088, 1, true);
player->CastSpell(targets.GetUnitTarget(), 38134, true);
return true;
}
}
return true;
}
};
void AddSC_boss_lady_vashj()
{
new boss_lady_vashj();
new mob_enchanted_elemental();
new mob_tainted_elemental();
new mob_toxic_sporebat();
new mob_shield_generator_channel();
new item_tainted_core();
}
| 35.534464 | 355 | 0.520756 | 499453466 |
3b962e4338ccd3f5d92c68775b21a40475ae4513 | 292 | cpp | C++ | server/src/coverage/Coverage.cpp | PolyProgrammist/UTBotCpp | 4886622f21c92e3b73daa553008e541be9d82f21 | [
"Apache-2.0"
] | null | null | null | server/src/coverage/Coverage.cpp | PolyProgrammist/UTBotCpp | 4886622f21c92e3b73daa553008e541be9d82f21 | [
"Apache-2.0"
] | null | null | null | server/src/coverage/Coverage.cpp | PolyProgrammist/UTBotCpp | 4886622f21c92e3b73daa553008e541be9d82f21 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) Huawei Technologies Co., Ltd. 2012-2021. All rights reserved.
*/
#include "Coverage.h"
int Coverage::TestStatusMap::getNumberOfTests() {
int cnt = 0;
for (auto const &[fileName, testsStatus] : *this) {
cnt += testsStatus.size();
}
return cnt;
}
| 20.857143 | 78 | 0.626712 | PolyProgrammist |
3b973b9b15b5571661f88bb58dd8bcfb355ad1e9 | 709 | cpp | C++ | jp.atcoder/abc021/abc021_c/11693515.cpp | kagemeka/atcoder-submissions | 91d8ad37411ea2ec582b10ba41b1e3cae01d4d6e | [
"MIT"
] | 1 | 2022-02-09T03:06:25.000Z | 2022-02-09T03:06:25.000Z | jp.atcoder/abc021/abc021_c/11693515.cpp | kagemeka/atcoder-submissions | 91d8ad37411ea2ec582b10ba41b1e3cae01d4d6e | [
"MIT"
] | 1 | 2022-02-05T22:53:18.000Z | 2022-02-09T01:29:30.000Z | jp.atcoder/abc021/abc021_c/11693515.cpp | kagemeka/atcoder-submissions | 91d8ad37411ea2ec582b10ba41b1e3cae01d4d6e | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
int MOD = 1e9 + 7;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, a, b, m;
cin >> n >> a >> b >> m;
a--; b--;
vector<vector<int>> graph(n, vector<int>(n, 0));
for (int i = 0; i < m; i++) {
int x, y;
cin >> x >> y;
x--; y--;
graph[x][y] = 1;
graph[y][x] = 1;
}
vector<long long> paths(n, 0);
paths[a] = 1;
while (!paths[b]) {
vector<long long> nxt(n, 0);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
nxt[i] += graph[i][j] * paths[j];
nxt[i] %= MOD;
}
}
paths = nxt;
}
cout << paths[b] << '\n';
return 0;
}
| 19.694444 | 51 | 0.4189 | kagemeka |
3b9762bea0ab3c3b8887b4092b09f9ae47991d52 | 26,165 | cc | C++ | plugin/plugin.cc | abique/vst-bridge | 2fd29f806c4a54e3f97367974a3d48b9eabb10f7 | [
"MIT"
] | 235 | 2015-02-14T03:02:13.000Z | 2022-03-30T04:46:40.000Z | plugin/plugin.cc | abique/vst-bridge | 2fd29f806c4a54e3f97367974a3d48b9eabb10f7 | [
"MIT"
] | 9 | 2015-11-04T18:17:49.000Z | 2020-12-01T14:40:04.000Z | plugin/plugin.cc | abique/vst-bridge | 2fd29f806c4a54e3f97367974a3d48b9eabb10f7 | [
"MIT"
] | 16 | 2015-06-12T20:10:00.000Z | 2020-12-01T14:37:29.000Z | #include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <limits.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <pthread.h>
#include <signal.h>
#include <list>
#include <X11/Xlib.h>
#define __cdecl
#include "../config.h"
#include "../common/common.h"
const char g_plugin_path[PATH_MAX] = VST_BRIDGE_TPL_DLL;
const char g_host_path[PATH_MAX] = VST_BRIDGE_TPL_HOST;
const char g_plugin_wineprefix[PATH_MAX] = VST_BRIDGE_TPL_WINEPREFIX;
#ifdef DEBUG
# define LOG(Args...) \
do { \
fprintf(g_log ? : stderr, "P: " Args); \
fflush(g_log ? : stderr); \
} while (0)
#else
# define LOG(Args...) do { ; } while (0)
#endif
#define CRIT(Args...) \
do { \
fprintf(g_log ? : stderr, "[CRIT] P: " Args); \
fflush(g_log ? : stderr); \
} while (0)
#include "../vstsdk2.4/pluginterfaces/vst2.x/aeffectx.h"
static FILE *g_log = NULL;
struct vst_bridge_effect {
vst_bridge_effect()
: socket(-1),
child(-1),
next_tag(0),
chunk(NULL)
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&lock, &attr);
pthread_mutexattr_destroy(&attr);
memset(&e, 0, sizeof (e));
}
~vst_bridge_effect()
{
if (socket >= 0)
close(socket);
free(chunk);
pthread_mutex_destroy(&lock);
int st;
waitpid(child, &st, 0);
if (display)
XCloseDisplay(display);
}
struct AEffect e;
int socket;
pid_t child;
uint32_t next_tag;
audioMasterCallback audio_master;
void *chunk;
pthread_mutex_t lock;
ERect rect;
bool close_flag;
std::list<vst_bridge_request> pending;
Display *display;
bool show_window;
};
void copy_plugin_data(struct vst_bridge_effect *vbe,
struct vst_bridge_request *rq)
{
vbe->e.numPrograms = rq->plugin_data.numPrograms;
vbe->e.numParams = rq->plugin_data.numParams;
vbe->e.numInputs = rq->plugin_data.numInputs;
vbe->e.numOutputs = rq->plugin_data.numOutputs;
vbe->e.flags = rq->plugin_data.flags;
vbe->e.initialDelay = rq->plugin_data.initialDelay;
vbe->e.uniqueID = rq->plugin_data.uniqueID;
vbe->e.version = rq->plugin_data.version;
if (!rq->plugin_data.hasSetParameter)
vbe->e.setParameter = NULL;
if (!rq->plugin_data.hasGetParameter)
vbe->e.getParameter = NULL;
if (!rq->plugin_data.hasProcessReplacing)
vbe->e.processReplacing = NULL;
if (!rq->plugin_data.hasProcessDoubleReplacing)
vbe->e.processDoubleReplacing = NULL;
}
void vst_bridge_handle_audio_master(struct vst_bridge_effect *vbe,
struct vst_bridge_request *rq)
{
LOG("audio_master(%s, %d, %d, %f) <= tag %d\n",
vst_bridge_audio_master_opcode_name[rq->amrq.opcode],
rq->amrq.index, rq->amrq.value, rq->amrq.opt, rq->tag);
switch (rq->amrq.opcode) {
// no additional data
case audioMasterAutomate:
case audioMasterVersion:
case audioMasterCurrentId:
case audioMasterIdle:
case __audioMasterPinConnectedDeprecated:
case audioMasterIOChanged:
case audioMasterSizeWindow:
case audioMasterGetSampleRate:
case audioMasterGetBlockSize:
case audioMasterGetInputLatency:
case audioMasterGetOutputLatency:
case audioMasterGetCurrentProcessLevel:
case audioMasterGetAutomationState:
case __audioMasterWantMidiDeprecated:
case __audioMasterNeedIdleDeprecated:
case audioMasterCanDo:
case audioMasterGetVendorVersion:
case audioMasterBeginEdit:
case audioMasterEndEdit:
case audioMasterUpdateDisplay:
case __audioMasterTempoAtDeprecated:
rq->amrq.value = vbe->audio_master(&vbe->e, rq->amrq.opcode, rq->amrq.index,
rq->amrq.value, rq->amrq.data, rq->amrq.opt);
write(vbe->socket, rq, VST_BRIDGE_AMRQ_LEN(0));
break;
case audioMasterGetProductString:
case audioMasterGetVendorString:
rq->amrq.value = vbe->audio_master(&vbe->e, rq->amrq.opcode, rq->amrq.index,
rq->amrq.value, rq->amrq.data, rq->amrq.opt);
write(vbe->socket, rq, VST_BRIDGE_AMRQ_LEN(strlen((const char *)rq->amrq.data) + 1));
break;
case audioMasterProcessEvents: {
struct vst_bridge_midi_events *mes = (struct vst_bridge_midi_events *)rq->amrq.data;
struct VstEvents *ves = (struct VstEvents *)malloc(sizeof (*ves) + mes->nb * sizeof (void*));
ves->numEvents = mes->nb;
ves->reserved = 0;
struct vst_bridge_midi_event *me = mes->events;
for (size_t i = 0; i < mes->nb; ++i) {
ves->events[i] = (VstEvent*)me;
me = (struct vst_bridge_midi_event *)(me->data + me->byteSize);
}
rq->amrq.value = vbe->audio_master(&vbe->e, rq->amrq.opcode, rq->amrq.index,
rq->amrq.value, ves, rq->amrq.opt);
free(ves);
write(vbe->socket, rq, ((uint8_t*)me) - ((uint8_t*)rq));
break;
}
case audioMasterGetTime: {
VstTimeInfo *time_info = (VstTimeInfo *)vbe->audio_master(
&vbe->e, rq->amrq.opcode, rq->amrq.index, rq->amrq.value, rq->amrq.data,
rq->amrq.opt);
if (!time_info)
rq->amrq.value = 0;
else {
rq->amrq.value = 1;
memcpy(rq->amrq.data, time_info, sizeof (*time_info));
}
write(vbe->socket, rq, VST_BRIDGE_AMRQ_LEN(sizeof (*time_info)));
break;
}
default:
CRIT(" !!!!!!! audio master callback (unhandled): op: %d,"
" index: %d, value: %ld, opt: %f\n",
rq->amrq.opcode, rq->amrq.index, rq->amrq.value, rq->amrq.opt);
break;
}
}
bool vst_bridge_wait_response(struct vst_bridge_effect *vbe,
struct vst_bridge_request *rq,
uint32_t tag)
{
ssize_t len;
while (true) {
std::list<vst_bridge_request>::iterator it;
for (it = vbe->pending.begin(); it != vbe->pending.end(); ++it) {
if (it->tag != tag)
continue;
*rq = *it; // XXX could be optimized?
vbe->pending.erase(it);
return true;
}
LOG(" <=== Waiting for tag %d\n", tag);
len = ::read(vbe->socket, rq, sizeof (*rq));
if (len <= 0)
return false;
assert(len >= VST_BRIDGE_RQ_LEN);
LOG(" ===> Got tag %d\n", rq->tag);
if (rq->tag == tag)
return true;
// handle request
if (rq->cmd == VST_BRIDGE_CMD_AUDIO_MASTER_CALLBACK) {
vst_bridge_handle_audio_master(vbe, rq);
continue;
} else if (rq->cmd == VST_BRIDGE_CMD_PLUGIN_DATA) {
copy_plugin_data(vbe, rq);
continue;
}
vbe->pending.push_back(*rq);
}
}
void vst_bridge_show_window(struct vst_bridge_effect *vbe)
{
struct vst_bridge_request rq;
if (vbe->show_window) {
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_SHOW_WINDOW;
vbe->next_tag += 2;
vbe->show_window = false;
write(vbe->socket, &rq, VST_BRIDGE_RQ_LEN);
vst_bridge_wait_response(vbe, &rq, rq.tag);
}
}
void vst_bridge_call_process(AEffect* effect,
float** inputs,
float** outputs,
VstInt32 sampleFrames)
{
struct vst_bridge_effect *vbe = container_of(effect, struct vst_bridge_effect, e);
struct vst_bridge_request rq;
pthread_mutex_lock(&vbe->lock);
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_PROCESS;
rq.frames.nframes = sampleFrames;
vbe->next_tag += 2;
for (int i = 0; i < vbe->e.numInputs; ++i)
memcpy(rq.frames.frames + i * sampleFrames, inputs[i],
sizeof (float) * sampleFrames);
write(vbe->socket, &rq, VST_BRIDGE_FRAMES_LEN(vbe->e.numInputs * sampleFrames));
vst_bridge_wait_response(vbe, &rq, rq.tag);
for (int i = 0; i < vbe->e.numOutputs; ++i)
memcpy(outputs[i], rq.frames.frames + i * sampleFrames,
sizeof (float) * sampleFrames);
pthread_mutex_unlock(&vbe->lock);
}
void vst_bridge_call_process_double(AEffect* effect,
double** inputs,
double** outputs,
VstInt32 sampleFrames)
{
struct vst_bridge_effect *vbe = container_of(effect, struct vst_bridge_effect, e);
struct vst_bridge_request rq;
pthread_mutex_lock(&vbe->lock);
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_PROCESS_DOUBLE;
rq.framesd.nframes = sampleFrames;
vbe->next_tag += 2;
for (int i = 0; i < vbe->e.numInputs; ++i)
memcpy(rq.framesd.frames + i * sampleFrames, inputs[i],
sizeof (double) * sampleFrames);
write(vbe->socket, &rq, VST_BRIDGE_FRAMES_DOUBLE_LEN(vbe->e.numInputs * sampleFrames));
vst_bridge_wait_response(vbe, &rq, rq.tag);
for (int i = 0; i < vbe->e.numOutputs; ++i)
memcpy(outputs[i], rq.framesd.frames + i * sampleFrames,
sizeof (double) * sampleFrames);
pthread_mutex_unlock(&vbe->lock);
}
float vst_bridge_call_get_parameter(AEffect* effect,
VstInt32 index)
{
struct vst_bridge_effect *vbe = container_of(effect, struct vst_bridge_effect, e);
struct vst_bridge_request rq;
pthread_mutex_lock(&vbe->lock);
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_GET_PARAMETER;
rq.param.index = index;
vbe->next_tag += 2;
write(vbe->socket, &rq, VST_BRIDGE_PARAM_LEN);
vst_bridge_wait_response(vbe, &rq, rq.tag);
pthread_mutex_unlock(&vbe->lock);
return rq.param.value;
}
void vst_bridge_call_set_parameter(AEffect* effect,
VstInt32 index,
float parameter)
{
struct vst_bridge_effect *vbe = container_of(effect, struct vst_bridge_effect, e);
struct vst_bridge_request rq;
pthread_mutex_lock(&vbe->lock);
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_SET_PARAMETER;
rq.param.index = index;
rq.param.value = parameter;
vbe->next_tag += 2;
write(vbe->socket, &rq, VST_BRIDGE_PARAM_LEN);
pthread_mutex_unlock(&vbe->lock);
}
VstIntPtr vst_bridge_call_effect_dispatcher2(AEffect* effect,
VstInt32 opcode,
VstInt32 index,
VstIntPtr value,
void* ptr,
float opt)
{
struct vst_bridge_effect *vbe = container_of(effect, struct vst_bridge_effect, e);
struct vst_bridge_request rq;
ssize_t len;
LOG("[%p] effect_dispatcher(%s, %d, %d, %p, %f) => next_tag: %d\n",
pthread_self(), vst_bridge_effect_opcode_name[opcode], index, value,
ptr, opt, vbe->next_tag);
switch (opcode) {
case effSetBlockSize:
case effSetProgram:
case effSetSampleRate:
case effEditIdle:
case effGetProgram:
case __effIdleDeprecated:
case effSetTotalSampleToProcess:
case effStartProcess:
case effStopProcess:
case effSetPanLaw:
case effSetProcessPrecision:
case effGetNumMidiInputChannels:
case effGetNumMidiOutputChannels:
case effEditClose:
case effCanBeAutomated:
case effGetTailSize:
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_EFFECT_DISPATCHER;
rq.erq.opcode = opcode;
rq.erq.index = index;
rq.erq.value = value;
rq.erq.opt = opt;
vbe->next_tag += 2;
write(vbe->socket, &rq, VST_BRIDGE_ERQ_LEN(0));
vst_bridge_wait_response(vbe, &rq, rq.tag);
return rq.amrq.value;
case effGetOutputProperties:
case effGetInputProperties:
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_EFFECT_DISPATCHER;
rq.erq.opcode = opcode;
rq.erq.index = index;
rq.erq.value = value;
rq.erq.opt = opt;
vbe->next_tag += 2;
write(vbe->socket, &rq, VST_BRIDGE_ERQ_LEN(0));
vst_bridge_wait_response(vbe, &rq, rq.tag);
memcpy(ptr, rq.erq.data, sizeof (VstPinProperties));
return rq.erq.value;
case effBeginLoadBank:
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_EFFECT_DISPATCHER;
rq.erq.opcode = opcode;
rq.erq.index = index;
rq.erq.value = value;
rq.erq.opt = opt;
vbe->next_tag += 2;
write(vbe->socket, &rq, VST_BRIDGE_ERQ_LEN(sizeof (VstPatchChunkInfo)));
vst_bridge_wait_response(vbe, &rq, rq.tag);
return rq.erq.value;
case effOpen:
case effGetPlugCategory:
case effGetVstVersion:
case effGetVendorVersion:
case effMainsChanged:
case effBeginSetProgram:
case effEndSetProgram:
case __effConnectOutputDeprecated:
case __effConnectInputDeprecated:
case effSetEditKnobMode:
case effEditKeyUp:
case effEditKeyDown:
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_EFFECT_DISPATCHER;
rq.erq.opcode = opcode;
rq.erq.index = index;
rq.erq.value = value;
rq.erq.opt = opt;
vbe->next_tag += 2;
write(vbe->socket, &rq, sizeof (rq));
vst_bridge_wait_response(vbe, &rq, rq.tag);
return rq.amrq.value;
case effClose:
// quit
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_EFFECT_DISPATCHER;
rq.erq.opcode = opcode;
rq.erq.index = index;
rq.erq.value = value;
rq.erq.opt = opt;
vbe->next_tag += 2;
write(vbe->socket, &rq, VST_BRIDGE_ERQ_LEN(0));
vbe->close_flag = true;
return 0;
case effEditOpen: {
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_EFFECT_DISPATCHER;
rq.erq.opcode = opcode;
rq.erq.index = index;
rq.erq.value = value;
rq.erq.opt = opt;
vbe->next_tag += 2;
write(vbe->socket, &rq, VST_BRIDGE_ERQ_LEN(0));
vst_bridge_wait_response(vbe, &rq, rq.tag);
Window parent = (Window)ptr;
Window child = (Window)rq.erq.index;
if (!vbe->display)
vbe->display = XOpenDisplay(NULL);
XReparentWindow(vbe->display, child, parent, 0, 0);
#if 0
XEvent ev;
memset(&ev, 0, sizeof (ev));
ev.xclient.type = ClientMessage;
ev.xclient.window = child;
ev.xclient.message_type = XInternAtom(vbe->display, "_XEMBED", false);
ev.xclient.format = 32;
ev.xclient.data.l[0] = CurrentTime;
ev.xclient.data.l[1] = XEMBED_EMBEDDED_NOTIFY;
ev.xclient.data.l[3] = parent;
XSendEvent(vbe->display, child, false, NoEventMask, &ev);
#endif
XSync(vbe->display, false);
XFlush(vbe->display);
vbe->show_window = true;
vst_bridge_show_window(vbe);
return rq.erq.value;
}
case effEditGetRect: {
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_EFFECT_DISPATCHER;
rq.erq.opcode = opcode;
rq.erq.index = index;
rq.erq.value = value;
rq.erq.opt = opt;
vbe->next_tag += 2;
write(vbe->socket, &rq, VST_BRIDGE_ERQ_LEN(0));
vst_bridge_wait_response(vbe, &rq, rq.tag);
memcpy(&vbe->rect, rq.erq.data, sizeof (vbe->rect));
ERect **r = (ERect **)ptr;
*r = &vbe->rect;
return rq.erq.value;
}
case effSetProgramName:
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_EFFECT_DISPATCHER;
rq.erq.opcode = opcode;
rq.erq.index = index;
rq.erq.value = value;
rq.erq.opt = opt;
vbe->next_tag += 2;
strcpy((char*)rq.erq.data, (const char *)ptr);
write(vbe->socket, &rq, VST_BRIDGE_ERQ_LEN(strlen((const char *)ptr) + 1));
if (!vst_bridge_wait_response(vbe, &rq, rq.tag))
return 0;
return rq.amrq.value;
case effGetMidiKeyName:
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_EFFECT_DISPATCHER;
rq.erq.opcode = opcode;
rq.erq.index = index;
rq.erq.value = value;
rq.erq.opt = opt;
vbe->next_tag += 2;
memcpy(rq.erq.data, ptr, sizeof (MidiKeyName));
write(vbe->socket, &rq, VST_BRIDGE_ERQ_LEN(sizeof (MidiKeyName)));
if (!vst_bridge_wait_response(vbe, &rq, rq.tag))
return 0;
memcpy(ptr, rq.erq.data, sizeof (MidiKeyName));
return rq.erq.value;
case effGetProgramName:
case effGetParamLabel:
case effGetParamDisplay:
case effGetParamName:
case effGetEffectName:
case effGetVendorString:
case effGetProductString:
case effGetProgramNameIndexed:
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_EFFECT_DISPATCHER;
rq.erq.opcode = opcode;
rq.erq.index = index;
rq.erq.value = value;
rq.erq.opt = opt;
vbe->next_tag += 2;
write(vbe->socket, &rq, VST_BRIDGE_ERQ_LEN(0));
if (!vst_bridge_wait_response(vbe, &rq, rq.tag))
return 0;
strcpy((char*)ptr, (const char *)rq.erq.data);
LOG("Got string: %s\n", (char *)ptr);
return rq.amrq.value;
case effCanDo:
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_EFFECT_DISPATCHER;
rq.erq.opcode = opcode;
rq.erq.index = index;
rq.erq.value = value;
rq.erq.opt = opt;
vbe->next_tag += 2;
strcpy((char*)rq.erq.data, (const char *)ptr);
write(vbe->socket, &rq, sizeof (rq));
if (!vst_bridge_wait_response(vbe, &rq, rq.tag))
return 0;
return rq.erq.value;
case effGetParameterProperties:
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_EFFECT_DISPATCHER;
rq.erq.opcode = opcode;
rq.erq.index = index;
rq.erq.value = value;
rq.erq.opt = opt;
vbe->next_tag += 2;
write(vbe->socket, &rq, VST_BRIDGE_ERQ_LEN(0));
if (!vst_bridge_wait_response(vbe, &rq, rq.tag))
return 0;
if (ptr && rq.amrq.value)
memcpy(ptr, rq.erq.data, sizeof (VstParameterProperties));
return rq.amrq.value;
case effGetChunk: {
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_EFFECT_DISPATCHER;
rq.erq.opcode = opcode;
rq.erq.index = index;
rq.erq.value = value;
rq.erq.opt = opt;
vbe->next_tag += 2;
write(vbe->socket, &rq, sizeof (rq));
if (!vst_bridge_wait_response(vbe, &rq, rq.tag))
return 0;
void *chunk = realloc(vbe->chunk, rq.erq.value);
if (!chunk)
return 0;
vbe->chunk = chunk;
for (size_t off = 0; rq.erq.value > 0; ) {
size_t can_read = MIN(VST_BRIDGE_CHUNK_SIZE, rq.erq.value - off);
memcpy(static_cast<uint8_t *>(vbe->chunk) + off, rq.erq.data, can_read);
off += can_read;
if (off == static_cast<size_t>(rq.erq.value))
break;
if (!vst_bridge_wait_response(vbe, &rq, rq.tag))
return 0;
}
*((void **)ptr) = chunk;
return rq.erq.value;
}
case effSetChunk: {
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_EFFECT_DISPATCHER;
rq.erq.opcode = opcode;
rq.erq.index = index;
rq.erq.value = value;
rq.erq.opt = opt;
vbe->next_tag += 2;
for (size_t off = 0; off < static_cast<size_t>(value); ) {
size_t can_write = MIN(VST_BRIDGE_CHUNK_SIZE, value - off);
memcpy(rq.erq.data, static_cast<uint8_t *>(ptr) + off, can_write);
write(vbe->socket, &rq, VST_BRIDGE_ERQ_LEN(can_write));
off += can_write;
}
vst_bridge_wait_response(vbe, &rq, rq.tag);
return rq.erq.value;
}
case effSetSpeakerArrangement: {
struct VstSpeakerArrangement *ar = (struct VstSpeakerArrangement *)value;
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_EFFECT_DISPATCHER;
rq.erq.opcode = opcode;
rq.erq.index = index;
rq.erq.value = value;
rq.erq.opt = opt;
vbe->next_tag += 2;
size_t len = 8 + ar->numChannels * sizeof (ar->speakers[0]);
memcpy(rq.erq.data, ptr, len);
write(vbe->socket, &rq, VST_BRIDGE_ERQ_LEN(len));
if (!vst_bridge_wait_response(vbe, &rq, rq.tag))
return 0;
memcpy(ptr, rq.erq.data, 8 + ar->numChannels * sizeof (ar->speakers[0]));
return rq.amrq.value;
}
case effProcessEvents: {
// compute the size
struct VstEvents *evs = (struct VstEvents *)ptr;
struct vst_bridge_midi_events *mes = (struct vst_bridge_midi_events *)rq.erq.data;
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_EFFECT_DISPATCHER;
rq.erq.opcode = opcode;
rq.erq.index = index;
rq.erq.value = value;
rq.erq.opt = opt;
vbe->next_tag += 2;
mes->nb = evs->numEvents;
struct vst_bridge_midi_event *me = mes->events;
for (int i = 0; i < evs->numEvents; ++i) {
memcpy(me, evs->events[i], sizeof (*me) + evs->events[i]->byteSize);
me = (struct vst_bridge_midi_event *)(me->data + me->byteSize);
}
write(vbe->socket, &rq, VST_BRIDGE_ERQ_LEN(((uint8_t *)me) - rq.erq.data));
if (!vst_bridge_wait_response(vbe, &rq, rq.tag))
return 0;
return rq.amrq.value;
}
case effVendorSpecific: {
switch (index) {
case effGetParamDisplay:
rq.tag = vbe->next_tag;
rq.cmd = VST_BRIDGE_CMD_EFFECT_DISPATCHER;
rq.erq.opcode = opcode;
rq.erq.index = index;
rq.erq.value = value;
rq.erq.opt = opt;
vbe->next_tag += 2;
write(vbe->socket, &rq, VST_BRIDGE_ERQ_LEN(0));
if (!vst_bridge_wait_response(vbe, &rq, rq.tag))
return 0;
strcpy((char*)ptr, (const char *)rq.erq.data);
LOG("Got string: %s\n", (char *)ptr);
return rq.amrq.value;
default:
// fall through
break;
}
}
default:
CRIT("[%p] !!!!!!!!!! UNHANDLED effect_dispatcher(%s, %d, %d, %p, %f)\n",
pthread_self(), vst_bridge_effect_opcode_name[opcode], index, value,
ptr);
return 0;
}
}
VstIntPtr vst_bridge_call_effect_dispatcher(AEffect* effect,
VstInt32 opcode,
VstInt32 index,
VstIntPtr value,
void* ptr,
float opt)
{
struct vst_bridge_effect *vbe = container_of(effect, struct vst_bridge_effect, e);
pthread_mutex_lock(&vbe->lock);
VstIntPtr ret = vst_bridge_call_effect_dispatcher2(
effect, opcode, index, value, ptr, opt);
pthread_mutex_unlock(&vbe->lock);
if (!vbe->close_flag)
return ret;
delete vbe;
return ret;
}
bool vst_bridge_call_plugin_main(struct vst_bridge_effect *vbe)
{
struct vst_bridge_request rq;
rq.tag = 0;
rq.cmd = VST_BRIDGE_CMD_PLUGIN_MAIN;
if (write(vbe->socket, &rq, sizeof (rq)) != sizeof (rq))
return false;
while (true) {
ssize_t rbytes = read(vbe->socket, &rq, sizeof (rq));
if (rbytes <= 0)
return false;
LOG("cmd: %d, tag: %d, bytes: %d\n", rq.cmd, rq.tag, rbytes);
switch (rq.cmd) {
case VST_BRIDGE_CMD_PLUGIN_DATA:
copy_plugin_data(vbe, &rq);
break;
case VST_BRIDGE_CMD_PLUGIN_MAIN:
copy_plugin_data(vbe, &rq);
return true;
case VST_BRIDGE_CMD_AUDIO_MASTER_CALLBACK:
vst_bridge_handle_audio_master(vbe, &rq);
break;
default:
LOG("UNEXPECTED COMMAND: %d\n", rq.cmd);
break;
}
}
}
extern "C" {
AEffect* VSTPluginMain(audioMasterCallback audio_master);
AEffect* VSTPluginMain2(audioMasterCallback audio_master) asm ("main");
}
AEffect* VSTPluginMain2(audioMasterCallback audio_master)
{
return VSTPluginMain(audio_master);
}
AEffect* VSTPluginMain(audioMasterCallback audio_master)
{
struct vst_bridge_effect *vbe = NULL;
int fds[2];
if (!g_log) {
#ifdef DEBUG
char path[128];
snprintf(path, sizeof (path), "/tmp/vst-bridge-plugin.%d.log", getpid());
g_log = fopen(path, "w+");
#else
g_log = stdout;
#endif
}
// allocate the context
vbe = new vst_bridge_effect;
if (!vbe)
goto failed;
// XXX move to the class description
vbe->audio_master = audio_master;
vbe->e.user = NULL;
vbe->e.magic = kEffectMagic;
vbe->e.dispatcher = vst_bridge_call_effect_dispatcher;
vbe->e.setParameter = vst_bridge_call_set_parameter;
vbe->e.getParameter = vst_bridge_call_get_parameter;
vbe->e.processReplacing = vst_bridge_call_process;
vbe->e.processDoubleReplacing = vst_bridge_call_process_double;
vbe->close_flag = false;
vbe->show_window = false;
vbe->display = NULL;
// initialize sockets
if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, fds))
goto failed_sockets;
vbe->socket = fds[0];
// fork
vbe->child = fork();
if (vbe->child == -1)
goto failed_fork;
if (!vbe->child) {
// in the child
// A hack to cheat GCC optimisation. If we'd simply compare
// g_plugin_wineprefix to VST_BRIDGE_TPL_WINEPREFIX, the
// whole if(strcmp(...)) {} will disappear in the assembly.
char *local_plugin_wineprefix = strdup(g_plugin_wineprefix);
if (strcmp(local_plugin_wineprefix, VST_BRIDGE_TPL_WINEPREFIX) != 0)
setenv("WINEPREFIX", local_plugin_wineprefix, 1); // Should we really override an existing var?
free(local_plugin_wineprefix);
char buff[8];
close(fds[0]);
snprintf(buff, sizeof (buff), "%d", fds[1]);
execl("/bin/sh", "/bin/sh", g_host_path, g_plugin_path, buff, NULL);
CRIT("Failed to spawn child process: /bin/sh %s %s %s\n", g_host_path, g_plugin_path, buff);
exit(1);
}
// in the father
close(fds[1]);
// forward plugin main
if (!vst_bridge_call_plugin_main(vbe)) {
close(vbe->socket);
delete vbe;
return NULL;
}
LOG(" => PluginMain done!\n");
// Return the VST AEffect structure
return &vbe->e;
failed_fork:
close(fds[0]);
close(fds[1]);
failed_sockets:
failed:
delete vbe;
return NULL;
}
| 29.971363 | 101 | 0.610587 | abique |
3b97f16d567a84132aa5436e779ecbccf7fe2e2d | 3,357 | cpp | C++ | src/Linear/EqualConstrOptimize.cpp | alibabach/deformabletracker | 1ef5631f7d91488da27abd83b468e2668670ad9d | [
"BSD-2-Clause-FreeBSD"
] | 29 | 2015-09-07T17:51:22.000Z | 2022-01-14T08:48:11.000Z | src/Linear/EqualConstrOptimize.cpp | alibabach/deformabletracker | 1ef5631f7d91488da27abd83b468e2668670ad9d | [
"BSD-2-Clause-FreeBSD"
] | 1 | 2017-12-07T07:58:19.000Z | 2017-12-07T09:26:39.000Z | src/Linear/EqualConstrOptimize.cpp | alibabach/deformabletracker | 1ef5631f7d91488da27abd83b468e2668670ad9d | [
"BSD-2-Clause-FreeBSD"
] | 5 | 2016-08-10T05:16:18.000Z | 2020-12-30T20:13:31.000Z | //////////////////////////////////////////////////////////////////////////
// Author : Ngo Tien Dat
// Email : [email protected]
// Organization : EPFL
// Purpose : Solve generic EQUALITY constrained optimization problem
// Date : 30 March 2012
//////////////////////////////////////////////////////////////////////////
#include "EqualConstrOptimize.h"
using namespace arma;
vec EqualConstrOptimize::OptimizeNullSpace(const vec& xInit, Function& objtFunction, Function& cstrFunction)
{
vec x = xInit; // Variables to be found
for (int i = 0; i < nIters; i++)
{
// Update x step by step
EqualConstrOptimize::takeAStepNullSpace( x, objtFunction, cstrFunction );
}
return x;
}
vec EqualConstrOptimize::OptimizeLagrange(const vec& xInit, Function& objtFunction, Function& cstrFunction)
{
vec x = xInit; // Variables to be found
for (int i = 0; i < nIters; i++)
{
// Update x step by step
EqualConstrOptimize::takeAStepLagrange( x, objtFunction, cstrFunction );
}
return x;
}
void EqualConstrOptimize::takeAStepLagrange(vec& x, Function& objtFunction, Function& cstrFunction)
{
// Evaluate functions
objtFunction.Evaluate(x);
cstrFunction.Evaluate(x);
const vec& F = objtFunction.GetF(); // Function value
const mat& J = objtFunction.GetJ(); // Jacobian. F and J are reference to function.J and function.F
// We only need to GetF() and GetJ() once
const vec& C = cstrFunction.GetF(); // Function value of constraints
const mat& A = cstrFunction.GetJ(); // Jacobian of constraints
// Find dx
int m = A.n_rows;
int n = A.n_cols;
double lambda = 1e-6;
// Calculate some terms
mat t1 = join_rows(J.t()*J, A.t()); // t1 = [J'*J A'] // TODO: CAN improve here by precomputed J'*J
mat t2 = join_rows(A, zeros(m,m)); // t2 = [A zeros(m,m)]
mat t3 = join_cols(t1, t2); // t3 = [t1; t2]
mat t4 = join_cols(J.t()*F, C); // t4 = [J'*F C]
vec dXLambda = -LinearAlgebraUtils::LeastSquareSolve(t3, t4, lambda); // Compute: -t3 \ t4
vec dX = dXLambda.subvec(0, n-1);
// Update x
x = x + dX;
}
void EqualConstrOptimize::takeAStepNullSpace(vec& x, Function& objtFunction, Function& cstrFunction)
{
// Evaluate functions
objtFunction.Evaluate(x);
cstrFunction.Evaluate(x);
const vec& F = objtFunction.GetF(); // Function value
const mat& J = objtFunction.GetJ(); // Jacobian. F and J are reference to function.J and function.F
// We only need to GetF() and GetJ() once
const vec& C = cstrFunction.GetF(); // Function value of constraints
const mat& A = cstrFunction.GetJ(); // Jacobian of constraints
// Find dx
int n = A.n_cols;
double lambda = 1e-6;
// Compute pseudo inverse and projector
mat pinvA = LinearAlgebraUtils::PseudoInverse(A, lambda);
mat Proj = eye(n, n) - pinvA * A;
// Compute projection increment
vec dX = -pinvA * C;
// Compute objective function increment
mat JP = J * Proj;
mat FJdX = F + J * dX;
vec dZ = LinearAlgebraUtils::LeastSquareSolve(JP, FJdX, lambda);
dX = dX - Proj * dZ;
// Update x
x = x + dX;
// dX.t().print("dX:");
}
| 30.798165 | 113 | 0.583855 | alibabach |
3b98ff0957863265a00e6cb4c3e060a38294ca65 | 13,936 | cc | C++ | lib/sanitizer_common/sanitizer_procmaps_mac.cc | hfinkel/compiler-rt-bgq | 5c116694a5ed7267288d9ea5723b6a651321d271 | [
"MIT"
] | null | null | null | lib/sanitizer_common/sanitizer_procmaps_mac.cc | hfinkel/compiler-rt-bgq | 5c116694a5ed7267288d9ea5723b6a651321d271 | [
"MIT"
] | null | null | null | lib/sanitizer_common/sanitizer_procmaps_mac.cc | hfinkel/compiler-rt-bgq | 5c116694a5ed7267288d9ea5723b6a651321d271 | [
"MIT"
] | null | null | null | //===-- sanitizer_procmaps_mac.cc -----------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Information about the process mappings (Mac-specific parts).
//===----------------------------------------------------------------------===//
#include "sanitizer_platform.h"
#if SANITIZER_MAC
#include "sanitizer_common.h"
#include "sanitizer_placement_new.h"
#include "sanitizer_procmaps.h"
#include <mach-o/dyld.h>
#include <mach-o/loader.h>
#include <mach/mach.h>
// These are not available in older macOS SDKs.
#ifndef CPU_SUBTYPE_X86_64_H
#define CPU_SUBTYPE_X86_64_H ((cpu_subtype_t)8) /* Haswell */
#endif
#ifndef CPU_SUBTYPE_ARM_V7S
#define CPU_SUBTYPE_ARM_V7S ((cpu_subtype_t)11) /* Swift */
#endif
#ifndef CPU_SUBTYPE_ARM_V7K
#define CPU_SUBTYPE_ARM_V7K ((cpu_subtype_t)12)
#endif
#ifndef CPU_TYPE_ARM64
#define CPU_TYPE_ARM64 (CPU_TYPE_ARM | CPU_ARCH_ABI64)
#endif
namespace __sanitizer {
// Contains information used to iterate through sections.
struct MemoryMappedSegmentData {
char name[kMaxSegName];
uptr nsects;
char *current_load_cmd_addr;
u32 lc_type;
uptr base_virt_addr;
uptr addr_mask;
};
template <typename Section>
static void NextSectionLoad(LoadedModule *module, MemoryMappedSegmentData *data,
bool isWritable) {
const Section *sc = (const Section *)data->current_load_cmd_addr;
data->current_load_cmd_addr += sizeof(Section);
uptr sec_start = (sc->addr & data->addr_mask) + data->base_virt_addr;
uptr sec_end = sec_start + sc->size;
module->addAddressRange(sec_start, sec_end, /*executable=*/false, isWritable,
sc->sectname);
}
void MemoryMappedSegment::AddAddressRanges(LoadedModule *module) {
// Don't iterate over sections when the caller hasn't set up the
// data pointer, when there are no sections, or when the segment
// is executable. Avoid iterating over executable sections because
// it will confuse libignore, and because the extra granularity
// of information is not needed by any sanitizers.
if (!data_ || !data_->nsects || IsExecutable()) {
module->addAddressRange(start, end, IsExecutable(), IsWritable(),
data_ ? data_->name : nullptr);
return;
}
do {
if (data_->lc_type == LC_SEGMENT) {
NextSectionLoad<struct section>(module, data_, IsWritable());
#ifdef MH_MAGIC_64
} else if (data_->lc_type == LC_SEGMENT_64) {
NextSectionLoad<struct section_64>(module, data_, IsWritable());
#endif
}
} while (--data_->nsects);
}
MemoryMappingLayout::MemoryMappingLayout(bool cache_enabled) {
Reset();
}
MemoryMappingLayout::~MemoryMappingLayout() {
}
// More information about Mach-O headers can be found in mach-o/loader.h
// Each Mach-O image has a header (mach_header or mach_header_64) starting with
// a magic number, and a list of linker load commands directly following the
// header.
// A load command is at least two 32-bit words: the command type and the
// command size in bytes. We're interested only in segment load commands
// (LC_SEGMENT and LC_SEGMENT_64), which tell that a part of the file is mapped
// into the task's address space.
// The |vmaddr|, |vmsize| and |fileoff| fields of segment_command or
// segment_command_64 correspond to the memory address, memory size and the
// file offset of the current memory segment.
// Because these fields are taken from the images as is, one needs to add
// _dyld_get_image_vmaddr_slide() to get the actual addresses at runtime.
void MemoryMappingLayout::Reset() {
// Count down from the top.
// TODO(glider): as per man 3 dyld, iterating over the headers with
// _dyld_image_count is thread-unsafe. We need to register callbacks for
// adding and removing images which will invalidate the MemoryMappingLayout
// state.
data_.current_image = _dyld_image_count();
data_.current_load_cmd_count = -1;
data_.current_load_cmd_addr = 0;
data_.current_magic = 0;
data_.current_filetype = 0;
data_.current_arch = kModuleArchUnknown;
internal_memset(data_.current_uuid, 0, kModuleUUIDSize);
}
// The dyld load address should be unchanged throughout process execution,
// and it is expensive to compute once many libraries have been loaded,
// so cache it here and do not reset.
static mach_header *dyld_hdr = 0;
static const char kDyldPath[] = "/usr/lib/dyld";
static const int kDyldImageIdx = -1;
// static
void MemoryMappingLayout::CacheMemoryMappings() {
// No-op on Mac for now.
}
void MemoryMappingLayout::LoadFromCache() {
// No-op on Mac for now.
}
// _dyld_get_image_header() and related APIs don't report dyld itself.
// We work around this by manually recursing through the memory map
// until we hit a Mach header matching dyld instead. These recurse
// calls are expensive, but the first memory map generation occurs
// early in the process, when dyld is one of the only images loaded,
// so it will be hit after only a few iterations.
static mach_header *get_dyld_image_header() {
mach_port_name_t port;
if (task_for_pid(mach_task_self(), internal_getpid(), &port) !=
KERN_SUCCESS) {
return nullptr;
}
unsigned depth = 1;
vm_size_t size = 0;
vm_address_t address = 0;
kern_return_t err = KERN_SUCCESS;
mach_msg_type_number_t count = VM_REGION_SUBMAP_INFO_COUNT_64;
while (true) {
struct vm_region_submap_info_64 info;
err = vm_region_recurse_64(port, &address, &size, &depth,
(vm_region_info_t)&info, &count);
if (err != KERN_SUCCESS) return nullptr;
if (size >= sizeof(mach_header) && info.protection & kProtectionRead) {
mach_header *hdr = (mach_header *)address;
if ((hdr->magic == MH_MAGIC || hdr->magic == MH_MAGIC_64) &&
hdr->filetype == MH_DYLINKER) {
return hdr;
}
}
address += size;
}
}
const mach_header *get_dyld_hdr() {
if (!dyld_hdr) dyld_hdr = get_dyld_image_header();
return dyld_hdr;
}
// Next and NextSegmentLoad were inspired by base/sysinfo.cc in
// Google Perftools, https://github.com/gperftools/gperftools.
// NextSegmentLoad scans the current image for the next segment load command
// and returns the start and end addresses and file offset of the corresponding
// segment.
// Note that the segment addresses are not necessarily sorted.
template <u32 kLCSegment, typename SegmentCommand>
static bool NextSegmentLoad(MemoryMappedSegment *segment,
MemoryMappedSegmentData *seg_data, MemoryMappingLayoutData &layout_data) {
const char *lc = layout_data.current_load_cmd_addr;
layout_data.current_load_cmd_addr += ((const load_command *)lc)->cmdsize;
if (((const load_command *)lc)->cmd == kLCSegment) {
const SegmentCommand* sc = (const SegmentCommand *)lc;
uptr base_virt_addr, addr_mask;
if (layout_data.current_image == kDyldImageIdx) {
base_virt_addr = (uptr)get_dyld_hdr();
// vmaddr is masked with 0xfffff because on macOS versions < 10.12,
// it contains an absolute address rather than an offset for dyld.
// To make matters even more complicated, this absolute address
// isn't actually the absolute segment address, but the offset portion
// of the address is accurate when combined with the dyld base address,
// and the mask will give just this offset.
addr_mask = 0xfffff;
} else {
base_virt_addr =
(uptr)_dyld_get_image_vmaddr_slide(layout_data.current_image);
addr_mask = ~0;
}
segment->start = (sc->vmaddr & addr_mask) + base_virt_addr;
segment->end = segment->start + sc->vmsize;
// Most callers don't need section information, so only fill this struct
// when required.
if (seg_data) {
seg_data->nsects = sc->nsects;
seg_data->current_load_cmd_addr =
(char *)lc + sizeof(SegmentCommand);
seg_data->lc_type = kLCSegment;
seg_data->base_virt_addr = base_virt_addr;
seg_data->addr_mask = addr_mask;
internal_strncpy(seg_data->name, sc->segname,
ARRAY_SIZE(seg_data->name));
}
// Return the initial protection.
segment->protection = sc->initprot;
segment->offset = (layout_data.current_filetype ==
/*MH_EXECUTE*/ 0x2)
? sc->vmaddr
: sc->fileoff;
if (segment->filename) {
const char *src = (layout_data.current_image == kDyldImageIdx)
? kDyldPath
: _dyld_get_image_name(layout_data.current_image);
internal_strncpy(segment->filename, src, segment->filename_size);
}
segment->arch = layout_data.current_arch;
internal_memcpy(segment->uuid, layout_data.current_uuid, kModuleUUIDSize);
return true;
}
return false;
}
ModuleArch ModuleArchFromCpuType(cpu_type_t cputype, cpu_subtype_t cpusubtype) {
cpusubtype = cpusubtype & ~CPU_SUBTYPE_MASK;
switch (cputype) {
case CPU_TYPE_I386:
return kModuleArchI386;
case CPU_TYPE_X86_64:
if (cpusubtype == CPU_SUBTYPE_X86_64_ALL) return kModuleArchX86_64;
if (cpusubtype == CPU_SUBTYPE_X86_64_H) return kModuleArchX86_64H;
CHECK(0 && "Invalid subtype of x86_64");
return kModuleArchUnknown;
case CPU_TYPE_ARM:
if (cpusubtype == CPU_SUBTYPE_ARM_V6) return kModuleArchARMV6;
if (cpusubtype == CPU_SUBTYPE_ARM_V7) return kModuleArchARMV7;
if (cpusubtype == CPU_SUBTYPE_ARM_V7S) return kModuleArchARMV7S;
if (cpusubtype == CPU_SUBTYPE_ARM_V7K) return kModuleArchARMV7K;
CHECK(0 && "Invalid subtype of ARM");
return kModuleArchUnknown;
case CPU_TYPE_ARM64:
return kModuleArchARM64;
default:
CHECK(0 && "Invalid CPU type");
return kModuleArchUnknown;
}
}
static const load_command *NextCommand(const load_command *lc) {
return (const load_command *)((char *)lc + lc->cmdsize);
}
static void FindUUID(const load_command *first_lc, u8 *uuid_output) {
for (const load_command *lc = first_lc; lc->cmd != 0; lc = NextCommand(lc)) {
if (lc->cmd != LC_UUID) continue;
const uuid_command *uuid_lc = (const uuid_command *)lc;
const uint8_t *uuid = &uuid_lc->uuid[0];
internal_memcpy(uuid_output, uuid, kModuleUUIDSize);
return;
}
}
static bool IsModuleInstrumented(const load_command *first_lc) {
for (const load_command *lc = first_lc; lc->cmd != 0; lc = NextCommand(lc)) {
if (lc->cmd != LC_LOAD_DYLIB) continue;
const dylib_command *dylib_lc = (const dylib_command *)lc;
uint32_t dylib_name_offset = dylib_lc->dylib.name.offset;
const char *dylib_name = ((const char *)dylib_lc) + dylib_name_offset;
dylib_name = StripModuleName(dylib_name);
if (dylib_name != 0 && (internal_strstr(dylib_name, "libclang_rt."))) {
return true;
}
}
return false;
}
bool MemoryMappingLayout::Next(MemoryMappedSegment *segment) {
for (; data_.current_image >= kDyldImageIdx; data_.current_image--) {
const mach_header *hdr = (data_.current_image == kDyldImageIdx)
? get_dyld_hdr()
: _dyld_get_image_header(data_.current_image);
if (!hdr) continue;
if (data_.current_load_cmd_count < 0) {
// Set up for this image;
data_.current_load_cmd_count = hdr->ncmds;
data_.current_magic = hdr->magic;
data_.current_filetype = hdr->filetype;
data_.current_arch = ModuleArchFromCpuType(hdr->cputype, hdr->cpusubtype);
switch (data_.current_magic) {
#ifdef MH_MAGIC_64
case MH_MAGIC_64: {
data_.current_load_cmd_addr = (char *)hdr + sizeof(mach_header_64);
break;
}
#endif
case MH_MAGIC: {
data_.current_load_cmd_addr = (char *)hdr + sizeof(mach_header);
break;
}
default: {
continue;
}
}
FindUUID((const load_command *)data_.current_load_cmd_addr,
data_.current_uuid);
data_.current_instrumented = IsModuleInstrumented(
(const load_command *)data_.current_load_cmd_addr);
}
for (; data_.current_load_cmd_count >= 0; data_.current_load_cmd_count--) {
switch (data_.current_magic) {
// data_.current_magic may be only one of MH_MAGIC, MH_MAGIC_64.
#ifdef MH_MAGIC_64
case MH_MAGIC_64: {
if (NextSegmentLoad<LC_SEGMENT_64, struct segment_command_64>(
segment, segment->data_, data_))
return true;
break;
}
#endif
case MH_MAGIC: {
if (NextSegmentLoad<LC_SEGMENT, struct segment_command>(
segment, segment->data_, data_))
return true;
break;
}
}
}
// If we get here, no more load_cmd's in this image talk about
// segments. Go on to the next image.
}
return false;
}
void MemoryMappingLayout::DumpListOfModules(
InternalMmapVectorNoCtor<LoadedModule> *modules) {
Reset();
InternalScopedString module_name(kMaxPathLength);
MemoryMappedSegment segment(module_name.data(), kMaxPathLength);
MemoryMappedSegmentData data;
segment.data_ = &data;
while (Next(&segment)) {
if (segment.filename[0] == '\0') continue;
LoadedModule *cur_module = nullptr;
if (!modules->empty() &&
0 == internal_strcmp(segment.filename, modules->back().full_name())) {
cur_module = &modules->back();
} else {
modules->push_back(LoadedModule());
cur_module = &modules->back();
cur_module->set(segment.filename, segment.start, segment.arch,
segment.uuid, data_.current_instrumented);
}
segment.AddAddressRanges(cur_module);
}
}
} // namespace __sanitizer
#endif // SANITIZER_MAC
| 36.577428 | 80 | 0.67975 | hfinkel |
3b9c73b53ebe56aca4b24d1c603bae36c5ce69af | 6,495 | cpp | C++ | src/Data.cpp | IgnacioCofre/proyecto_tesis | e26b3fa1a7aba443fda64abfc2dc0208241088d9 | [
"MIT"
] | 1 | 2022-03-04T19:10:22.000Z | 2022-03-04T19:10:22.000Z | src/Data.cpp | IgnacioCofre/proyecto_tesis | e26b3fa1a7aba443fda64abfc2dc0208241088d9 | [
"MIT"
] | null | null | null | src/Data.cpp | IgnacioCofre/proyecto_tesis | e26b3fa1a7aba443fda64abfc2dc0208241088d9 | [
"MIT"
] | null | null | null | #include "../includes/data.h"
void Data::read_input_file(const char * input_path)
{
FILE * pFile;
pFile = fopen (input_path,"r");
//lectura del archivo
if(!pFile)
{
std::cerr << "Problem while reading instance" << std::endl;
exit(EXIT_FAILURE);
}
//numero de articulos
if(fscanf(pFile, "%d", &number_articles) != 1)
{
std::cerr << "Problem while reading number of articles" << std::endl;
exit(EXIT_FAILURE);
}
//matriz de similaridad
for (int _ = 0; _ < number_articles; _++)
{
std::vector <int> new_row(number_articles);
for(int i = 0; i < number_articles; i++)
{
if(fscanf(pFile, "%d", &new_row[i]) != 1){
std::cerr << "Problem while reading similarity matrix" << std::endl;
exit(EXIT_FAILURE);
}
}
similarity_matrix.push_back(new_row);
}
//numero de tipo de sesiones
if(fscanf(pFile, "%d", &number_type_sessions) != 1)
{
std::cerr << "Problem while reading session number" << std::endl;
exit(EXIT_FAILURE);
}
//informacio del tipo de sesiones
for(int i = 0; i<number_type_sessions; i++)
{
int input_per_session = 3;
std::vector<int> new_session_data(input_per_session);
if(fscanf(pFile, "%d %d %d", &new_session_data[0],&new_session_data[1],&new_session_data[2])!= input_per_session)
{
std::cerr << "Problem while reading session tipe data" << std::endl;
exit(EXIT_FAILURE);
}
}
//numero de dias
if(fscanf(pFile, "%d", &number_days) != 1)
{
std::cerr << "Problem while reading number days" << std::endl;
exit(EXIT_FAILURE);
}
for(int day = 0; day<number_days; day++)
{
int number_blocks;
int number_sessions;
if(fscanf(pFile, "%d %d", &number_blocks, &number_sessions) != 2)
{
std::cerr << "Problem while reading session tipe data" << std::endl;
exit(EXIT_FAILURE);
}
std::vector<int> new_data_log = {number_blocks,number_sessions};
data_days.push_back(new_data_log);
std::vector<std::vector<int>> new_data_day(number_blocks);
for(int session = 0; session < number_sessions; session++)
{
int block;
int max_number_articles;
if(fscanf(pFile, "%d %d", &block, &max_number_articles) != 2)
{
std::cerr << "Problem while reading data block" << std::endl;
exit(EXIT_FAILURE);
}
new_data_day[block-1].push_back(max_number_articles);
//std::cout<<"si pasa esto 2"<<std::endl;
}
max_assign_per_session.push_back(new_data_day);
}
//numero de articulos y numero de topicos
int aux;
if(fscanf(pFile, "%d %d", &aux , &number_topics) != 2)
{
std::cerr << "Problem while reading number topics" << std::endl;
exit(EXIT_FAILURE);
}
//topicos por articulo
for(int i = 0; i < number_articles; i++)
{
int number_article_topics;
if(fscanf(pFile, "%d",&number_article_topics) != 1)
{
std::cerr << "Problem while reading number of topics per article" << std::endl;
exit(EXIT_FAILURE);
}
number_topics_articles.push_back(number_article_topics);
std::vector<int> topics_article(number_article_topics);
for(int j = 0; j<number_article_topics; j++)
{
if(fscanf(pFile, "%d",&topics_article[j]) != 1){
std::cerr << "Problem while reading topics per article" << std::endl;
exit(EXIT_FAILURE);
}
}
articles_topics.push_back(topics_article);
}
//numero de articulos y numero de autores
int aux2;
if(fscanf(pFile, "%d %d", &aux2 , &number_authors) != 2)
{
std::cerr << "Problem while reading number authors" << std::endl;
exit(EXIT_FAILURE);
}
//autores por articulo
for(int i = 0; i < number_articles; i++)
{
int new_number_article_authors;
if(fscanf(pFile, "%d",&new_number_article_authors) != 1)
{
std::cerr << "Problem while reading number of authors per article" << std::endl;
exit(EXIT_FAILURE);
}
number_articles_authors.push_back(new_number_article_authors);
std::vector<int> new_articles_authors(new_number_article_authors);
for(int j = 0; j<new_number_article_authors; j++)
{
if(fscanf(pFile, "%d",&new_articles_authors[j]) != 1){
std::cerr << "Problem while reading author per article" << std::endl;
exit(EXIT_FAILURE);
}
}
articles_authors.push_back(new_articles_authors);
}
fclose(pFile);
}
int Data::get_similarity(int id_article_1, int id_article_2)
{
if((id_article_1 <number_articles) & (id_article_2<number_articles))
{
return similarity_matrix[id_article_1][id_article_2];
}
std::cerr << "Problem while reading number of article" << std::endl;
exit(EXIT_FAILURE);
}
void Data::show_data()
{
std::cout << number_articles << std::endl;
for(int i = 0; i<number_articles; i++)
{
for(int j = 0; j<number_articles; j++)
{
std::cout << similarity_matrix[i][j] << " ";
}
std::cout << std::endl;
}
std::cout << number_type_sessions << std::endl;
std::cout << number_days << std::endl;
std::cout << number_topics << std::endl;
std::cout << number_authors << std::endl;
std::cout<< "max_assign_per_session"<<std::endl;
int number_days = max_assign_per_session.size();
for(int day=0; day<number_days; day++)
{
int number_blocks = max_assign_per_session[day].size();
for(int block=0; block<number_blocks; block++)
{
int number_sessions = max_assign_per_session[day][block].size();
for(int session=0; session<number_sessions; session++)
{
int max_session = max_assign_per_session[day][block][session];
std::cout<<day<<","<<block<<","<<session<<","<<max_session<<std::endl;
}
}
}
}
int Data::get_number_days()
{
return number_days;
}
int Data::get_number_articles()
{
return number_articles;
}
| 29.522727 | 121 | 0.570285 | IgnacioCofre |
3b9cfda324df3847fa21884757a5432c49bcc3b3 | 1,459 | hpp | C++ | src/lib/storage/chunk.hpp | lawben/DYOD_WS1718_Sprint1 | 3b70ac6603fe108cfe76cc81fed763c5d3c7cd84 | [
"MIT"
] | null | null | null | src/lib/storage/chunk.hpp | lawben/DYOD_WS1718_Sprint1 | 3b70ac6603fe108cfe76cc81fed763c5d3c7cd84 | [
"MIT"
] | null | null | null | src/lib/storage/chunk.hpp | lawben/DYOD_WS1718_Sprint1 | 3b70ac6603fe108cfe76cc81fed763c5d3c7cd84 | [
"MIT"
] | null | null | null | #pragma once
// the linter wants this to be above everything else
#include <shared_mutex>
#include <atomic>
#include <memory>
#include <string>
#include <vector>
#include "all_type_variant.hpp"
#include "types.hpp"
namespace opossum {
class BaseIndex;
class BaseColumn;
// A chunk is a horizontal partition of a table.
// It stores the data column by column.
//
// Find more information about this in our wiki: https://github.com/hyrise/zweirise/wiki/chunk-concept
class Chunk : private Noncopyable {
public:
Chunk() = default;
// we need to explicitly set the move constructor to default when
// we overwrite the copy constructor
Chunk(Chunk&&) = default;
Chunk& operator=(Chunk&&) = default;
// adds a column to the "right" of the chunk
void add_column(std::shared_ptr<BaseColumn> column);
// returns the number of columns (cannot exceed ColumnID (uint16_t))
uint16_t col_count() const;
// returns the number of rows (cannot exceed ChunkOffset (uint32_t))
uint32_t size() const;
// adds a new row, given as a list of values, to the chunk
// note this is slow and not thread-safe and should be used for testing purposes only
void append(const std::vector<AllTypeVariant>& values);
// Returns the column at a given position
std::shared_ptr<BaseColumn> get_column(ColumnID column_id) const;
protected:
// Implementation goes here
std::vector<std::shared_ptr<BaseColumn>> _columns;
};
} // namespace opossum
| 27.018519 | 102 | 0.732008 | lawben |
3ba0e30c39e4243ec34c08e80036d27eee070040 | 10,174 | cpp | C++ | src/scripts/scripts/eastern_kingdoms/zulgurub/boss_jindo.cpp | Subv/diamondcore | e11891587736b6308e554f71cb56e8df1a1812ad | [
"OpenSSL"
] | 1 | 2018-01-17T08:11:17.000Z | 2018-01-17T08:11:17.000Z | src/scripts/scripts/eastern_kingdoms/zulgurub/boss_jindo.cpp | Subv/diamondcore | e11891587736b6308e554f71cb56e8df1a1812ad | [
"OpenSSL"
] | null | null | null | src/scripts/scripts/eastern_kingdoms/zulgurub/boss_jindo.cpp | Subv/diamondcore | e11891587736b6308e554f71cb56e8df1a1812ad | [
"OpenSSL"
] | null | null | null | /* Copyright (C) 2006 - 2010 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* ScriptData
SDName: Boss_Jin'do the Hexxer
SD%Complete: 85
SDComment: Mind Control not working because of core bug. Shades visible for all.
SDCategory: Zul'Gurub
EndScriptData */
#include "precompiled.h"
#include "zulgurub.h"
#define SAY_AGGRO -1309014
#define SPELL_BRAINWASHTOTEM 24262
#define SPELL_POWERFULLHEALINGWARD 24309 //We will not use this spell. We will summon a totem by script cause the spell totems will not cast.
#define SPELL_HEX 24053
#define SPELL_DELUSIONSOFJINDO 24306
#define SPELL_SHADEOFJINDO 24308 //We will not use this spell. We will summon a shade by script.
//Healing Ward Spell
#define SPELL_HEAL 38588 //Totems are not working right. Right heal spell ID is 24311 but this spell is not casting...
//Shade of Jindo Spell
#define SPELL_SHADOWSHOCK 19460
#define SPELL_INVISIBLE 24699
struct boss_jindoAI : public ScriptedAI
{
boss_jindoAI(Creature* pCreature) : ScriptedAI(pCreature)
{
m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData();
Reset();
}
ScriptedInstance* m_pInstance;
uint32 BrainWashTotem_Timer;
uint32 HealingWard_Timer;
uint32 Hex_Timer;
uint32 Delusions_Timer;
uint32 Teleport_Timer;
void Reset()
{
BrainWashTotem_Timer = 20000;
HealingWard_Timer = 16000;
Hex_Timer = 8000;
Delusions_Timer = 10000;
Teleport_Timer = 5000;
}
void Aggro(Unit *who)
{
DoScriptText(SAY_AGGRO, m_creature);
}
void UpdateAI(const uint32 diff)
{
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;
//BrainWashTotem_Timer
if (BrainWashTotem_Timer < diff)
{
DoCastSpellIfCan(m_creature, SPELL_BRAINWASHTOTEM);
BrainWashTotem_Timer = urand(18000, 26000);
}else BrainWashTotem_Timer -= diff;
//HealingWard_Timer
if (HealingWard_Timer < diff)
{
//DoCastSpellIfCan(m_creature, SPELL_POWERFULLHEALINGWARD);
m_creature->SummonCreature(14987, m_creature->GetPositionX()+3, m_creature->GetPositionY()-2, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,30000);
HealingWard_Timer = urand(14000, 20000);
}else HealingWard_Timer -= diff;
//Hex_Timer
if (Hex_Timer < diff)
{
DoCastSpellIfCan(m_creature->getVictim(), SPELL_HEX);
if (m_creature->getThreatManager().getThreat(m_creature->getVictim()))
m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-80);
Hex_Timer = urand(12000, 20000);
}else Hex_Timer -= diff;
//Casting the delusion curse with a shade. So shade will attack the same target with the curse.
if (Delusions_Timer < diff)
{
if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
{
DoCastSpellIfCan(target, SPELL_DELUSIONSOFJINDO);
Creature *Shade = m_creature->SummonCreature(14986, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
if (Shade)
Shade->AI()->AttackStart(target);
}
Delusions_Timer = urand(4000, 12000);
}else Delusions_Timer -= diff;
//Teleporting a random gamer and spawning 9 skeletons that will attack this gamer
if (Teleport_Timer < diff)
{
Unit* target = NULL;
target = SelectUnit(SELECT_TARGET_RANDOM,0);
if (target && target->GetTypeId() == TYPEID_PLAYER)
{
DoTeleportPlayer(target, -11583.7783f, -1249.4278f, 77.5471f, 4.745f);
if (m_creature->getThreatManager().getThreat(m_creature->getVictim()))
m_creature->getThreatManager().modifyThreatPercent(target,-100);
Creature *Skeletons;
Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()+2, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
if (Skeletons)
Skeletons->AI()->AttackStart(target);
Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()-2, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
if (Skeletons)
Skeletons->AI()->AttackStart(target);
Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()+4, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
if (Skeletons)
Skeletons->AI()->AttackStart(target);
Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()-4, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
if (Skeletons)
Skeletons->AI()->AttackStart(target);
Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()+2, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
if (Skeletons)
Skeletons->AI()->AttackStart(target);
Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()-2, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
if (Skeletons)
Skeletons->AI()->AttackStart(target);
Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()+4, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
if (Skeletons)
Skeletons->AI()->AttackStart(target);
Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()-4, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
if (Skeletons)
Skeletons->AI()->AttackStart(target);
Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()+3, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
if (Skeletons)
Skeletons->AI()->AttackStart(target);
}
Teleport_Timer = urand(15000, 23000);
}else Teleport_Timer -= diff;
DoMeleeAttackIfReady();
}
};
//Healing Ward
struct mob_healing_wardAI : public ScriptedAI
{
mob_healing_wardAI(Creature* pCreature) : ScriptedAI(pCreature)
{
m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData();
Reset();
}
ScriptedInstance* m_pInstance;
uint32 Heal_Timer;
void Reset()
{
Heal_Timer = 2000;
}
void UpdateAI (const uint32 diff)
{
//Heal_Timer
if (Heal_Timer < diff)
{
if (m_pInstance)
{
if (Unit *pJindo = m_pInstance->instance->GetCreature(m_pInstance->GetData64(DATA_JINDO)))
{
if (pJindo->isAlive())
DoCastSpellIfCan(pJindo, SPELL_HEAL);
}
}
Heal_Timer = 3000;
}else Heal_Timer -= diff;
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;
DoMeleeAttackIfReady();
}
};
//Shade of Jindo
struct mob_shade_of_jindoAI : public ScriptedAI
{
mob_shade_of_jindoAI(Creature* pCreature) : ScriptedAI(pCreature)
{
m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData();
Reset();
}
ScriptedInstance* m_pInstance;
uint32 ShadowShock_Timer;
void Reset()
{
ShadowShock_Timer = 1000;
m_creature->CastSpell(m_creature, SPELL_INVISIBLE,true);
}
void UpdateAI (const uint32 diff)
{
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;
//ShadowShock_Timer
if (ShadowShock_Timer < diff)
{
DoCastSpellIfCan(m_creature->getVictim(), SPELL_SHADOWSHOCK);
ShadowShock_Timer = 2000;
}else ShadowShock_Timer -= diff;
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI_boss_jindo(Creature* pCreature)
{
return new boss_jindoAI(pCreature);
}
CreatureAI* GetAI_mob_healing_ward(Creature* pCreature)
{
return new mob_healing_wardAI(pCreature);
}
CreatureAI* GetAI_mob_shade_of_jindo(Creature* pCreature)
{
return new mob_shade_of_jindoAI(pCreature);
}
void AddSC_boss_jindo()
{
Script *newscript;
newscript = new Script;
newscript->Name = "boss_jindo";
newscript->GetAI = &GetAI_boss_jindo;
newscript->RegisterSelf();
newscript = new Script;
newscript->Name = "mob_healing_ward";
newscript->GetAI = &GetAI_mob_healing_ward;
newscript->RegisterSelf();
newscript = new Script;
newscript->Name = "mob_shade_of_jindo";
newscript->GetAI = &GetAI_mob_shade_of_jindo;
newscript->RegisterSelf();
}
| 36.729242 | 190 | 0.637311 | Subv |
3ba56f4f1dddd083eaae7359df3c4759ba0e0d29 | 4,111 | cpp | C++ | src/org/apache/poi/ss/formula/UserDefinedFunction.cpp | pebble2015/cpoi | 6dcc0c5e13e3e722b4ef9fd0baffbf62bf71ead6 | [
"Apache-2.0"
] | null | null | null | src/org/apache/poi/ss/formula/UserDefinedFunction.cpp | pebble2015/cpoi | 6dcc0c5e13e3e722b4ef9fd0baffbf62bf71ead6 | [
"Apache-2.0"
] | null | null | null | src/org/apache/poi/ss/formula/UserDefinedFunction.cpp | pebble2015/cpoi | 6dcc0c5e13e3e722b4ef9fd0baffbf62bf71ead6 | [
"Apache-2.0"
] | null | null | null | // Generated from /POI/java/org/apache/poi/ss/formula/UserDefinedFunction.java
#include <org/apache/poi/ss/formula/UserDefinedFunction.hpp>
#include <java/lang/ArrayStoreException.hpp>
#include <java/lang/Class.hpp>
#include <java/lang/ClassCastException.hpp>
#include <java/lang/NullPointerException.hpp>
#include <java/lang/RuntimeException.hpp>
#include <java/lang/String.hpp>
#include <java/lang/StringBuilder.hpp>
#include <java/lang/System.hpp>
#include <org/apache/poi/ss/formula/OperationEvaluationContext.hpp>
#include <org/apache/poi/ss/formula/eval/FunctionNameEval.hpp>
#include <org/apache/poi/ss/formula/eval/NotImplementedFunctionException.hpp>
#include <org/apache/poi/ss/formula/eval/ValueEval.hpp>
#include <org/apache/poi/ss/formula/functions/FreeRefFunction.hpp>
#include <ObjectArray.hpp>
#include <SubArray.hpp>
template<typename ComponentType, typename... Bases> struct SubArray;
namespace poi
{
namespace ss
{
namespace formula
{
namespace eval
{
typedef ::SubArray< ::poi::ss::formula::eval::ValueEval, ::java::lang::ObjectArray > ValueEvalArray;
} // eval
} // formula
} // ss
} // poi
template<typename T, typename U>
static T java_cast(U* u)
{
if(!u) return static_cast<T>(nullptr);
auto t = dynamic_cast<T>(u);
if(!t) throw new ::java::lang::ClassCastException();
return t;
}
template<typename T>
static T* npc(T* t)
{
if(!t) throw new ::java::lang::NullPointerException();
return t;
}
poi::ss::formula::UserDefinedFunction::UserDefinedFunction(const ::default_init_tag&)
: super(*static_cast< ::default_init_tag* >(0))
{
clinit();
}
poi::ss::formula::UserDefinedFunction::UserDefinedFunction()
: UserDefinedFunction(*static_cast< ::default_init_tag* >(0))
{
ctor();
}
poi::ss::formula::functions::FreeRefFunction*& poi::ss::formula::UserDefinedFunction::instance()
{
clinit();
return instance_;
}
poi::ss::formula::functions::FreeRefFunction* poi::ss::formula::UserDefinedFunction::instance_;
void poi::ss::formula::UserDefinedFunction::ctor()
{
super::ctor();
}
poi::ss::formula::eval::ValueEval* poi::ss::formula::UserDefinedFunction::evaluate(::poi::ss::formula::eval::ValueEvalArray* args, OperationEvaluationContext* ec)
{
auto nIncomingArgs = npc(args)->length;
if(nIncomingArgs < 1) {
throw new ::java::lang::RuntimeException(u"function name argument missing"_j);
}
auto nameArg = (*args)[int32_t(0)];
::java::lang::String* functionName;
if(dynamic_cast< ::poi::ss::formula::eval::FunctionNameEval* >(nameArg) != nullptr) {
functionName = npc((java_cast< ::poi::ss::formula::eval::FunctionNameEval* >(nameArg)))->getFunctionName();
} else {
throw new ::java::lang::RuntimeException(::java::lang::StringBuilder().append(u"First argument should be a NameEval, but got ("_j)->append(npc(npc(nameArg)->getClass())->getName())
->append(u")"_j)->toString());
}
auto targetFunc = npc(ec)->findUserDefinedFunction(functionName);
if(targetFunc == nullptr) {
throw new ::poi::ss::formula::eval::NotImplementedFunctionException(functionName);
}
auto nOutGoingArgs = nIncomingArgs - int32_t(1);
auto outGoingArgs = new ::poi::ss::formula::eval::ValueEvalArray(nOutGoingArgs);
::java::lang::System::arraycopy(args, 1, outGoingArgs, 0, nOutGoingArgs);
return npc(targetFunc)->evaluate(outGoingArgs, ec);
}
extern java::lang::Class *class_(const char16_t *c, int n);
java::lang::Class* poi::ss::formula::UserDefinedFunction::class_()
{
static ::java::lang::Class* c = ::class_(u"org.apache.poi.ss.formula.UserDefinedFunction", 45);
return c;
}
void poi::ss::formula::UserDefinedFunction::clinit()
{
super::clinit();
static bool in_cl_init = false;
struct clinit_ {
clinit_() {
in_cl_init = true;
instance_ = new UserDefinedFunction();
}
};
if(!in_cl_init) {
static clinit_ clinit_instance;
}
}
java::lang::Class* poi::ss::formula::UserDefinedFunction::getClass0()
{
return class_();
}
| 32.117188 | 188 | 0.689856 | pebble2015 |
3ba5a1fe2d80001dd4ac49930452d6a544ebf7b4 | 1,453 | cpp | C++ | trunk/src/bls/BlsServerSelector.cpp | almondyoung/Bull-Live-Server | b2ad5ad0968318c2821f63adedbc83286a6d7c22 | [
"BSD-2-Clause"
] | 141 | 2015-01-07T15:54:55.000Z | 2021-09-21T13:56:30.000Z | trunk/src/bls/BlsServerSelector.cpp | mol310/Bull-Live-Server | b2ad5ad0968318c2821f63adedbc83286a6d7c22 | [
"BSD-2-Clause"
] | 5 | 2015-03-02T09:22:26.000Z | 2018-10-18T08:13:50.000Z | trunk/src/bls/BlsServerSelector.cpp | mol310/Bull-Live-Server | b2ad5ad0968318c2821f63adedbc83286a6d7c22 | [
"BSD-2-Clause"
] | 84 | 2015-01-15T07:04:25.000Z | 2020-08-09T16:14:58.000Z | #include "BlsServerSelector.hpp"
#include <MStringList>
#include "BlsConf.hpp"
BlsServerSelector::BlsServerSelector()
{
m_conhash = conhash_init(NULL);
}
BlsServerSelector::~BlsServerSelector()
{
conhash_fini(m_conhash);
}
BlsServerSelector *BlsServerSelector::instance()
{
static BlsServerSelector *ss = NULL;
if (!ss) {
ss = new BlsServerSelector;
ss->init();
}
return ss;
}
void BlsServerSelector::addServer(const MString &host, muint16 port)
{
node_s *node = new node_s;
// ip:port
MString info = host;
info.append(":");
info.append(MString::number(port));
conhash_set_node(node, info.c_str(), 4800);
conhash_add_node(m_conhash, node);
m_nodes.push_back(node);
}
void BlsServerSelector::removeServer(const MString &host, muint16 port)
{
}
muint16 BlsServerSelector::lookUp(const MString &info)
{
const node_s *node = conhash_lookup(m_conhash, info.c_str());
if(node) {
MStringList ip_port = MString(node->iden).split(":");
return (muint16)ip_port.at(1).toInt();
}
return -1;
}
void BlsServerSelector::init()
{
vector<BlsHostInfo> back_source_infos = BlsConf::instance()->getBackSourceInfo();
for (unsigned int i = 0; i < back_source_infos.size(); ++i) {
BlsHostInfo &info = back_source_infos.at(i);
addServer(info.addr, info.port);
}
}
| 21.686567 | 86 | 0.636614 | almondyoung |
3bacd0b6c5523beea6a162f135dcc168f2f462d6 | 46,095 | cpp | C++ | src/Meta_Auto_Code.cpp | ciyam/ciyam | f25d25145caca7e75de11ba0a3dac818254eb61a | [
"MIT"
] | 15 | 2015-02-22T19:45:05.000Z | 2020-04-12T01:50:57.000Z | src/Meta_Auto_Code.cpp | ciyam/ciyam | f25d25145caca7e75de11ba0a3dac818254eb61a | [
"MIT"
] | 1 | 2017-04-15T15:58:43.000Z | 2017-04-15T15:58:43.000Z | src/Meta_Auto_Code.cpp | ciyam/ciyam | f25d25145caca7e75de11ba0a3dac818254eb61a | [
"MIT"
] | 14 | 2016-11-06T18:20:06.000Z | 2021-06-27T13:01:50.000Z | // Copyright (c) 2012-2021 CIYAM Developers
//
// Distributed under the MIT/X11 software license, please refer to the file license.txt
// in the root project directory or http://www.opensource.org/licenses/mit-license.php.
#ifdef PRECOMPILE_H
# include "precompile.h"
#endif
#pragma hdrstop
#ifndef HAS_PRECOMPILED_STD_HEADERS
# include <cstring>
# include <fstream>
# include <iostream>
# include <algorithm>
# include <stdexcept>
#endif
#define CIYAM_BASE_LIB
#define MODULE_META_IMPL
// [<start macros>]
// [<finish macros>]
#include "Meta_Auto_Code.h"
#include "ciyam_base.h"
#include "ciyam_common.h"
#include "class_domains.h"
#include "module_strings.h"
#include "ciyam_constants.h"
#include "ciyam_variables.h"
#include "class_utilities.h"
#include "command_handler.h"
#include "module_interface.h"
// [<start includes>]
// [<finish includes>]
using namespace std;
// [<start namespaces>]
// [<finish namespaces>]
inline int system( const string& cmd ) { return exec_system( cmd ); }
namespace
{
template< typename T > inline void sanity_check( const T& t ) { }
inline void sanity_check( const string& s )
{
if( s.length( ) > c_max_string_length_limit )
throw runtime_error( "unexpected max string length limit exceeded with: " + s );
}
#include "Meta_Auto_Code.cmh"
const int32_t c_version = 1;
const char* const c_field_id_Exhausted = "125103";
const char* const c_field_id_Mask = "125101";
const char* const c_field_id_Next = "125102";
const char* const c_field_name_Exhausted = "Exhausted";
const char* const c_field_name_Mask = "Mask";
const char* const c_field_name_Next = "Next";
const char* const c_field_display_name_Exhausted = "field_auto_code_exhausted";
const char* const c_field_display_name_Mask = "field_auto_code_mask";
const char* const c_field_display_name_Next = "field_auto_code_next";
const int c_num_fields = 3;
const char* const c_all_sorted_field_ids[ ] =
{
"125101",
"125102",
"125103"
};
const char* const c_all_sorted_field_names[ ] =
{
"Exhausted",
"Mask",
"Next"
};
inline bool compare( const char* p_s1, const char* p_s2 ) { return strcmp( p_s1, p_s2 ) < 0; }
inline bool has_field( const string& field )
{
return binary_search( c_all_sorted_field_ids, c_all_sorted_field_ids + c_num_fields, field.c_str( ), compare )
|| binary_search( c_all_sorted_field_names, c_all_sorted_field_names + c_num_fields, field.c_str( ), compare );
}
const int c_num_encrypted_fields = 0;
bool is_encrypted_field( const string& ) { static bool false_value( false ); return false_value; }
const int c_num_transient_fields = 0;
bool is_transient_field( const string& ) { static bool false_value( false ); return false_value; }
const char* const c_procedure_id_Increment = "125410";
domain_string_max_size< 30 > g_Mask_domain;
domain_string_max_size< 30 > g_Next_domain;
string g_order_field_name;
string g_owner_field_name;
string g_state_names_variable;
set< string > g_derivations;
set< string > g_file_field_ids;
set< string > g_file_field_names;
typedef map< string, Meta_Auto_Code* > external_aliases_container;
typedef external_aliases_container::const_iterator external_aliases_const_iterator;
typedef external_aliases_container::value_type external_aliases_value_type;
typedef map< size_t, Meta_Auto_Code* > external_aliases_lookup_container;
typedef external_aliases_lookup_container::const_iterator external_aliases_lookup_const_iterator;
external_aliases_container g_external_aliases;
external_aliases_lookup_container g_external_aliases_lookup;
struct validate_formatter
{
validate_formatter( ) : num( 0 ) { }
string get( const string& name ) { return masks[ name ]; }
void set( const string& name, const string& mask )
{
masks.insert( make_pair( name, mask ) );
}
int num;
map< string, string > masks;
};
inline validation_error_value_type
construct_validation_error( int& num, const string& field_name, const string& error_message )
{
return validation_error_value_type(
construct_key_from_int( "", ++num, 4 ) + ':' + field_name, error_message );
}
bool g_default_Exhausted = bool( 0 );
string g_default_Mask = string( );
string g_default_Next = string( );
// [<start anonymous>]
// [<finish anonymous>]
}
registration< Meta_Auto_Code > Auto_Code_registration( get_class_registry( ), "125100" );
class Meta_Auto_Code_command_functor;
class Meta_Auto_Code_command_handler : public command_handler
{
friend class Meta_Auto_Code_command_functor;
public:
Meta_Auto_Code_command_handler( ) : p_Meta_Auto_Code( 0 ) { }
void set_Meta_Auto_Code( Meta_Auto_Code* p_new_Meta_Auto_Code ) { p_Meta_Auto_Code = p_new_Meta_Auto_Code; }
void handle_unknown_command( const string& command, const string& cmd_and_args )
{
throw runtime_error( "unknown command '" + command + "'" );
}
void handle_invalid_command( const command_parser& parser, const string& cmd_and_args )
{
throw runtime_error( "invalid command usage '" + cmd_and_args + "'" );
}
private:
Meta_Auto_Code* p_Meta_Auto_Code;
protected:
string retval;
};
class Meta_Auto_Code_command_functor : public command_functor
{
public:
Meta_Auto_Code_command_functor( Meta_Auto_Code_command_handler& handler )
: command_functor( handler ),
cmd_handler( handler )
{
}
void operator ( )( const string& command, const parameter_info& parameters );
private:
Meta_Auto_Code_command_handler& cmd_handler;
};
command_functor* Meta_Auto_Code_command_functor_factory( const string& /*name*/, command_handler& handler )
{
return new Meta_Auto_Code_command_functor( dynamic_cast< Meta_Auto_Code_command_handler& >( handler ) );
}
void Meta_Auto_Code_command_functor::operator ( )( const string& command, const parameter_info& parameters )
{
if( command == c_cmd_Meta_Auto_Code_key )
{
bool want_fixed( has_parm_val( parameters, c_cmd_Meta_Auto_Code_key_fixed ) );
if( !want_fixed )
cmd_handler.retval = cmd_handler.p_Meta_Auto_Code->get_key( );
else
cmd_handler.retval = cmd_handler.p_Meta_Auto_Code->get_fixed_key( );
}
else if( command == c_cmd_Meta_Auto_Code_ver )
{
string ver_rev( to_string( cmd_handler.p_Meta_Auto_Code->get_version( ) ) );
ver_rev += "." + to_string( cmd_handler.p_Meta_Auto_Code->get_revision( ) );
cmd_handler.retval = ver_rev;
}
else if( command == c_cmd_Meta_Auto_Code_get )
{
string field_name( get_parm_val( parameters, c_cmd_Meta_Auto_Code_get_field_name ) );
bool handled = false;
if( field_name.empty( ) )
throw runtime_error( "field name must not be empty for getter call" );
if( !handled && field_name == c_field_id_Exhausted || field_name == c_field_name_Exhausted )
{
handled = true;
string_getter< bool >( cmd_handler.p_Meta_Auto_Code->Exhausted( ), cmd_handler.retval );
}
if( !handled && field_name == c_field_id_Mask || field_name == c_field_name_Mask )
{
handled = true;
string_getter< string >( cmd_handler.p_Meta_Auto_Code->Mask( ), cmd_handler.retval );
}
if( !handled && field_name == c_field_id_Next || field_name == c_field_name_Next )
{
handled = true;
string_getter< string >( cmd_handler.p_Meta_Auto_Code->Next( ), cmd_handler.retval );
}
if( !handled )
throw runtime_error( "unknown field name '" + field_name + "' for getter call" );
}
else if( command == c_cmd_Meta_Auto_Code_set )
{
string field_name( get_parm_val( parameters, c_cmd_Meta_Auto_Code_set_field_name ) );
string field_value( get_parm_val( parameters, c_cmd_Meta_Auto_Code_set_field_value ) );
bool handled = false;
if( field_name.empty( ) )
throw runtime_error( "field name must not be empty for setter call" );
if( !handled && field_name == c_field_id_Exhausted || field_name == c_field_name_Exhausted )
{
handled = true;
func_string_setter< Meta_Auto_Code, bool >(
*cmd_handler.p_Meta_Auto_Code, &Meta_Auto_Code::Exhausted, field_value );
}
if( !handled && field_name == c_field_id_Mask || field_name == c_field_name_Mask )
{
handled = true;
func_string_setter< Meta_Auto_Code, string >(
*cmd_handler.p_Meta_Auto_Code, &Meta_Auto_Code::Mask, field_value );
}
if( !handled && field_name == c_field_id_Next || field_name == c_field_name_Next )
{
handled = true;
func_string_setter< Meta_Auto_Code, string >(
*cmd_handler.p_Meta_Auto_Code, &Meta_Auto_Code::Next, field_value );
}
if( !handled )
throw runtime_error( "unknown field name '" + field_name + "' for setter call" );
cmd_handler.retval = c_okay;
}
else if( command == c_cmd_Meta_Auto_Code_cmd )
{
string field_name( get_parm_val( parameters, c_cmd_Meta_Auto_Code_cmd_field_name ) );
string cmd_and_args( get_parm_val( parameters, c_cmd_Meta_Auto_Code_cmd_cmd_and_args ) );
cmd_handler.retval.erase( );
if( field_name.empty( ) )
throw runtime_error( "field name must not be empty for command call" );
else
throw runtime_error( "unknown field name '" + field_name + "' for command call" );
}
else if( command == c_cmd_Meta_Auto_Code_Increment )
{
string Next_Value;
cmd_handler.p_Meta_Auto_Code->Increment( Next_Value );
cmd_handler.retval.erase( );
append_value( cmd_handler.retval, Next_Value );
}
}
struct Meta_Auto_Code::impl : public Meta_Auto_Code_command_handler
{
impl( Meta_Auto_Code& o )
:
cp_obj( &o ),
total_child_relationships( 0 )
{
p_obj = &o;
set_Meta_Auto_Code( &o );
add_commands( 0, Meta_Auto_Code_command_functor_factory,
ARRAY_PTR_AND_SIZE( Meta_Auto_Code_command_definitions ) );
}
Meta_Auto_Code& get_obj( ) const
{
return *cp_obj;
}
bool impl_Exhausted( ) const { return lazy_fetch( p_obj ), v_Exhausted; }
void impl_Exhausted( bool Exhausted ) { v_Exhausted = Exhausted; }
const string& impl_Mask( ) const { return lazy_fetch( p_obj ), v_Mask; }
void impl_Mask( const string& Mask ) { sanity_check( Mask ); v_Mask = Mask; }
const string& impl_Next( ) const { return lazy_fetch( p_obj ), v_Next; }
void impl_Next( const string& Next ) { sanity_check( Next ); v_Next = Next; }
void impl_Increment( string& Next_Value );
string get_field_value( int field ) const;
void set_field_value( int field, const string& value );
void set_field_default( int field );
bool is_field_default( int field ) const;
uint64_t get_state( ) const;
string get_state_names( ) const;
const string& execute( const string& cmd_and_args );
void clear_foreign_key( const string& field );
void set_foreign_key_value( const string& field, const string& value );
const string& get_foreign_key_value( const string& field );
void get_foreign_key_values( foreign_key_data_container& foreign_key_values ) const;
void add_extra_fixed_info( vector< pair< string, string > >& fixed_info ) const;
void add_extra_paging_info( vector< pair< string, string > >& paging_info ) const;
void clear( );
bool value_will_be_provided( const string& field_name );
void validate( uint64_t state, bool is_internal, validation_error_container* p_validation_errors );
void validate_set_fields( set< string >& fields_set, validation_error_container* p_validation_errors );
void after_fetch( );
void finalise_fetch( bool skip_set_original );
void at_create( );
void post_init( );
void to_store( bool is_create, bool is_internal );
void for_store( bool is_create, bool is_internal );
void after_store( bool is_create, bool is_internal );
bool can_destroy( bool is_internal );
void for_destroy( bool is_internal );
void after_destroy( bool is_internal );
void set_default_values( );
bool is_filtered( ) const;
void get_required_transients( ) const;
Meta_Auto_Code* p_obj;
class_pointer< Meta_Auto_Code > cp_obj;
mutable set< string > required_transients;
// [<start members>]
// [<finish members>]
size_t total_child_relationships;
bool v_Exhausted;
string v_Mask;
string v_Next;
};
void Meta_Auto_Code::impl::impl_Increment( string& Next_Value )
{
uint64_t state = p_obj->get_state( );
( void )state;
// [(start for_auto_code)] 600295
get_obj( ).op_update( );
if( !get_obj( ).Exhausted( ) )
{
string mask( get_obj( ).Mask( ) );
if( is_null( get_obj( ).Next( ) ) )
{
string str;
for( size_t i = 0; i < mask.size( ); i++ )
{
if( mask[ i ] == '?' )
str += 'A';
else if( mask[ i ] == '#' )
str += '0';
else
str += mask[ i ];
}
get_obj( ).Next( str );
}
Next_Value = get_obj( ).Next( );
if( mask.size( ) != get_obj( ).Next( ).size( ) )
{
get_obj( ).op_cancel( );
throw runtime_error( "unexpected mask/next size mismatch" );
}
bool finished = false;
string str( get_obj( ).Next( ) );
for( size_t i = mask.size( ); i > 0; i-- )
{
if( mask[ i - 1 ] == '?' )
{
if( str[ i - 1 ] == 'Z' )
str[ i - 1 ] = 'A';
else
{
++str[ i - 1 ];
finished = true;
}
}
else if( mask[ i - 1 ] == '#' )
{
if( str[ i - 1 ] == '9' )
str[ i - 1 ] = '0';
else
{
++str[ i - 1 ];
finished = true;
}
}
if( finished )
{
get_obj( ).Next( str );
break;
}
}
if( !finished )
{
get_obj( ).Next( "" );
get_obj( ).Exhausted( true );
}
get_obj( ).op_apply( );
}
else
get_obj( ).op_cancel( );
// [(finish for_auto_code)] 600295
// [<start Increment_impl>]
// [<finish Increment_impl>]
}
string Meta_Auto_Code::impl::get_field_value( int field ) const
{
string retval;
switch( field )
{
case 0:
retval = to_string( impl_Exhausted( ) );
break;
case 1:
retval = to_string( impl_Mask( ) );
break;
case 2:
retval = to_string( impl_Next( ) );
break;
default:
throw runtime_error( "field #" + to_string( field ) + " is out of range in get field value" );
}
return retval;
}
void Meta_Auto_Code::impl::set_field_value( int field, const string& value )
{
switch( field )
{
case 0:
func_string_setter< Meta_Auto_Code::impl, bool >( *this, &Meta_Auto_Code::impl::impl_Exhausted, value );
break;
case 1:
func_string_setter< Meta_Auto_Code::impl, string >( *this, &Meta_Auto_Code::impl::impl_Mask, value );
break;
case 2:
func_string_setter< Meta_Auto_Code::impl, string >( *this, &Meta_Auto_Code::impl::impl_Next, value );
break;
default:
throw runtime_error( "field #" + to_string( field ) + " is out of range in set field value" );
}
}
void Meta_Auto_Code::impl::set_field_default( int field )
{
switch( field )
{
case 0:
impl_Exhausted( g_default_Exhausted );
break;
case 1:
impl_Mask( g_default_Mask );
break;
case 2:
impl_Next( g_default_Next );
break;
default:
throw runtime_error( "field #" + to_string( field ) + " is out of range in set field default" );
}
}
bool Meta_Auto_Code::impl::is_field_default( int field ) const
{
bool retval = false;
switch( field )
{
case 0:
retval = ( v_Exhausted == g_default_Exhausted );
break;
case 1:
retval = ( v_Mask == g_default_Mask );
break;
case 2:
retval = ( v_Next == g_default_Next );
break;
default:
throw runtime_error( "field #" + to_string( field ) + " is out of range in is_field_default" );
}
return retval;
}
uint64_t Meta_Auto_Code::impl::get_state( ) const
{
uint64_t state = 0;
// [<start get_state>]
// [<finish get_state>]
return state;
}
string Meta_Auto_Code::impl::get_state_names( ) const
{
string state_names;
uint64_t state = get_state( );
return state_names.empty( ) ? state_names : state_names.substr( 1 );
}
const string& Meta_Auto_Code::impl::execute( const string& cmd_and_args )
{
execute_command( cmd_and_args );
return retval;
}
void Meta_Auto_Code::impl::clear_foreign_key( const string& field )
{
if( field.empty( ) )
throw runtime_error( "unexpected empty field name/id" );
else
throw runtime_error( "unknown foreign key field '" + field + "'" );
}
void Meta_Auto_Code::impl::set_foreign_key_value( const string& field, const string& value )
{
if( field.empty( ) )
throw runtime_error( "unexpected empty field name/id for value: " + value );
else
throw runtime_error( "unknown foreign key field '" + field + "'" );
}
const string& Meta_Auto_Code::impl::get_foreign_key_value( const string& field )
{
if( field.empty( ) )
throw runtime_error( "unexpected empty field name/id" );
else
throw runtime_error( "unknown foreign key field '" + field + "'" );
}
void Meta_Auto_Code::impl::get_foreign_key_values( foreign_key_data_container& foreign_key_values ) const
{
( void )foreign_key_values;
}
void Meta_Auto_Code::impl::add_extra_fixed_info( vector< pair< string, string > >& fixed_info ) const
{
( void )fixed_info;
// [<start add_extra_fixed_info>]
// [<finish add_extra_fixed_info>]
}
void Meta_Auto_Code::impl::add_extra_paging_info( vector< pair< string, string > >& paging_info ) const
{
( void )paging_info;
// [<start add_extra_paging_info>]
// [<finish add_extra_paging_info>]
}
void Meta_Auto_Code::impl::clear( )
{
v_Exhausted = g_default_Exhausted;
v_Mask = g_default_Mask;
v_Next = g_default_Next;
}
bool Meta_Auto_Code::impl::value_will_be_provided( const string& field_name )
{
( void )field_name;
// [<start value_will_be_provided>]
// [<finish value_will_be_provided>]
return false;
}
void Meta_Auto_Code::impl::validate(
uint64_t state, bool is_internal, validation_error_container* p_validation_errors )
{
( void )state;
( void )is_internal;
if( !p_validation_errors )
throw runtime_error( "unexpected null validation_errors container" );
string error_message;
validate_formatter vf;
if( is_null( v_Mask ) && !value_will_be_provided( c_field_name_Mask ) )
p_validation_errors->insert( construct_validation_error( vf.num, c_field_name_Mask,
get_string_message( GS( c_str_field_must_not_be_empty ), make_pair(
c_str_parm_field_must_not_be_empty_field, get_module_string( c_field_display_name_Mask ) ) ) ) );
if( !is_null( v_Mask )
&& ( v_Mask != g_default_Mask
|| !value_will_be_provided( c_field_name_Mask ) )
&& !g_Mask_domain.is_valid( v_Mask, error_message = "" ) )
p_validation_errors->insert( construct_validation_error( vf.num, c_field_name_Mask,
get_module_string( c_field_display_name_Mask ) + " " + error_message ) );
if( !is_null( v_Next )
&& ( v_Next != g_default_Next
|| !value_will_be_provided( c_field_name_Next ) )
&& !g_Next_domain.is_valid( v_Next, error_message = "" ) )
p_validation_errors->insert( construct_validation_error( vf.num, c_field_name_Next,
get_module_string( c_field_display_name_Next ) + " " + error_message ) );
// [(start for_auto_code)] 600295
if( !get_obj( ).Next( ).empty( ) )
{
bool okay = true;
string next( get_obj( ).Next( ) );
string mask( get_obj( ).Mask( ) );
if( next.length( ) != mask.length( ) )
okay = false;
else
{
for( size_t i = 0; i < next.length( ); i++ )
{
if( next[ i ] != mask[ i ] )
{
if( mask[ i ] == '?' )
{
if( next[ i ] < 'A' || next[ i ] > 'Z' )
okay = false;
}
else if( mask[ i ] == '#' )
{
if( next[ i ] < '0' || next[ i ] > '9' )
okay = false;
}
else
okay = false;
}
if( !okay )
break;
}
}
if( !okay )
p_validation_errors->insert( validation_error_value_type( c_field_name_Next,
get_string_message( GS( c_str_field_mismatch ), make_pair(
c_str_parm_field_mismatch_field, get_module_string( c_field_display_name_Next ) ),
make_pair( c_str_parm_field_mismatch_field2, get_module_string( c_field_display_name_Mask ) ) ) ) );
}
// [(finish for_auto_code)] 600295
// [<start validate>]
// [<finish validate>]
}
void Meta_Auto_Code::impl::validate_set_fields(
set< string >& fields_set, validation_error_container* p_validation_errors )
{
( void )fields_set;
if( !p_validation_errors )
throw runtime_error( "unexpected null validation_errors container" );
string error_message;
validate_formatter vf;
if( !is_null( v_Mask )
&& ( fields_set.count( c_field_id_Mask ) || fields_set.count( c_field_name_Mask ) )
&& !g_Mask_domain.is_valid( v_Mask, error_message = "" ) )
p_validation_errors->insert( construct_validation_error( vf.num, c_field_name_Mask,
get_module_string( c_field_display_name_Mask ) + " " + error_message ) );
if( !is_null( v_Next )
&& ( fields_set.count( c_field_id_Next ) || fields_set.count( c_field_name_Next ) )
&& !g_Next_domain.is_valid( v_Next, error_message = "" ) )
p_validation_errors->insert( construct_validation_error( vf.num, c_field_name_Next,
get_module_string( c_field_display_name_Next ) + " " + error_message ) );
}
void Meta_Auto_Code::impl::after_fetch( )
{
if( !get_obj( ).get_is_iterating( ) || get_obj( ).get_is_starting_iteration( ) )
get_required_transients( );
post_init( );
uint64_t state = p_obj->get_state( );
( void )state;
// [<start after_fetch>]
// [<finish after_fetch>]
}
void Meta_Auto_Code::impl::finalise_fetch( bool skip_set_original )
{
if( !skip_set_original && !get_obj( ).get_key( ).empty( ) )
get_obj( ).set_new_original_values( );
uint64_t state = p_obj->get_state( );
( void )state;
// [<start finalise_fetch>]
// [<finish finalise_fetch>]
}
void Meta_Auto_Code::impl::at_create( )
{
// [<start at_create>]
// [<finish at_create>]
}
void Meta_Auto_Code::impl::post_init( )
{
uint64_t state = p_obj->get_state( );
( void )state;
// [<start post_init>]
// [<finish post_init>]
}
void Meta_Auto_Code::impl::to_store( bool is_create, bool is_internal )
{
( void )is_create;
( void )is_internal;
if( !get_obj( ).get_is_preparing( ) )
post_init( );
uint64_t state = p_obj->get_state( );
( void )state;
// [<start to_store>]
// [<finish to_store>]
}
void Meta_Auto_Code::impl::for_store( bool is_create, bool is_internal )
{
( void )is_create;
( void )is_internal;
uint64_t state = p_obj->get_state( );
( void )state;
// [<start for_store>]
// [<finish for_store>]
}
void Meta_Auto_Code::impl::after_store( bool is_create, bool is_internal )
{
( void )is_create;
( void )is_internal;
uint64_t state = p_obj->get_state( );
( void )state;
// [<start after_store>]
// [<finish after_store>]
}
bool Meta_Auto_Code::impl::can_destroy( bool is_internal )
{
uint64_t state = p_obj->get_state( );
bool retval = is_internal || !( state & c_state_undeletable );
// [<start can_destroy>]
// [<finish can_destroy>]
return retval;
}
void Meta_Auto_Code::impl::for_destroy( bool is_internal )
{
( void )is_internal;
uint64_t state = p_obj->get_state( );
( void )state;
// [<start for_destroy>]
// [<finish for_destroy>]
}
void Meta_Auto_Code::impl::after_destroy( bool is_internal )
{
( void )is_internal;
uint64_t state = p_obj->get_state( );
( void )state;
// [<start after_destroy>]
// [<finish after_destroy>]
}
void Meta_Auto_Code::impl::set_default_values( )
{
clear( );
}
bool Meta_Auto_Code::impl::is_filtered( ) const
{
uint64_t state = p_obj->get_state( );
( void )state;
// [<start is_filtered>]
// [<finish is_filtered>]
return false;
}
void Meta_Auto_Code::impl::get_required_transients( ) const
{
required_transients.clear( );
get_obj( ).add_required_transients( required_transients );
set< string > dependents( required_transients.begin( ), required_transients.end( ) );
p_obj->get_required_field_names( required_transients, true, &dependents );
int iterations = 0;
// NOTE: It is possible that due to "interdependent" required fields
// some required fields may not have been added in the first or even
// later calls to "get_required_field_names" so continue calling the
// function until no further field names have been added.
size_t num_required = required_transients.size( );
while( num_required )
{
p_obj->get_required_field_names( required_transients, true, &dependents );
if( required_transients.size( ) == num_required )
break;
if( ++iterations > 100 )
throw runtime_error( "unexpected excessive get_required_field_names( ) iterations in get_required_transients( )" );
num_required = required_transients.size( );
}
}
#undef MODULE_TRACE
#define MODULE_TRACE( x ) trace( x )
Meta_Auto_Code::Meta_Auto_Code( )
{
set_version( c_version );
p_impl = new impl( *this );
}
Meta_Auto_Code::~Meta_Auto_Code( )
{
cleanup( );
delete p_impl;
}
bool Meta_Auto_Code::Exhausted( ) const
{
return p_impl->impl_Exhausted( );
}
void Meta_Auto_Code::Exhausted( bool Exhausted )
{
p_impl->impl_Exhausted( Exhausted );
}
const string& Meta_Auto_Code::Mask( ) const
{
return p_impl->impl_Mask( );
}
void Meta_Auto_Code::Mask( const string& Mask )
{
p_impl->impl_Mask( Mask );
}
const string& Meta_Auto_Code::Next( ) const
{
return p_impl->impl_Next( );
}
void Meta_Auto_Code::Next( const string& Next )
{
p_impl->impl_Next( Next );
}
void Meta_Auto_Code::Increment( string& Next_Value )
{
p_impl->impl_Increment( Next_Value );
}
string Meta_Auto_Code::get_field_value( int field ) const
{
return p_impl->get_field_value( field );
}
void Meta_Auto_Code::set_field_value( int field, const string& value )
{
p_impl->set_field_value( field, value );
}
void Meta_Auto_Code::set_field_default( int field )
{
return set_field_default( ( field_id )( field + 1 ) );
}
void Meta_Auto_Code::set_field_default( field_id id )
{
p_impl->set_field_default( ( int )id - 1 );
}
void Meta_Auto_Code::set_field_default( const string& field )
{
p_impl->set_field_default( get_field_num( field ) );
}
bool Meta_Auto_Code::is_field_default( int field ) const
{
return is_field_default( ( field_id )( field + 1 ) );
}
bool Meta_Auto_Code::is_field_default( field_id id ) const
{
return p_impl->is_field_default( ( int )id - 1 );
}
bool Meta_Auto_Code::is_field_default( const string& field ) const
{
return p_impl->is_field_default( get_field_num( field ) );
}
bool Meta_Auto_Code::is_field_encrypted( int field ) const
{
return static_is_field_encrypted( ( field_id )( field + 1 ) );
}
bool Meta_Auto_Code::is_field_transient( int field ) const
{
return static_is_field_transient( ( field_id )( field + 1 ) );
}
string Meta_Auto_Code::get_field_id( int field ) const
{
return static_get_field_id( ( field_id )( field + 1 ) );
}
string Meta_Auto_Code::get_field_name( int field ) const
{
return static_get_field_name( ( field_id )( field + 1 ) );
}
int Meta_Auto_Code::get_field_num( const string& field ) const
{
int rc = static_get_field_num( field );
if( rc < 0 )
throw runtime_error( "unknown field name/id '" + field + "' in get_field_num( )" );
return rc;
}
bool Meta_Auto_Code::has_field_changed( const string& field ) const
{
return class_base::has_field_changed( get_field_num( field ) );
}
uint64_t Meta_Auto_Code::get_state( ) const
{
uint64_t state = 0;
state |= p_impl->get_state( );
return state;
}
const string& Meta_Auto_Code::execute( const string& cmd_and_args )
{
return p_impl->execute( cmd_and_args );
}
void Meta_Auto_Code::clear( )
{
p_impl->clear( );
}
void Meta_Auto_Code::validate( uint64_t state, bool is_internal )
{
p_impl->validate( state, is_internal, &validation_errors );
}
void Meta_Auto_Code::validate_set_fields( set< string >& fields_set )
{
p_impl->validate_set_fields( fields_set, &validation_errors );
}
void Meta_Auto_Code::after_fetch( )
{
p_impl->after_fetch( );
}
void Meta_Auto_Code::finalise_fetch( bool skip_set_original )
{
p_impl->finalise_fetch( skip_set_original );
}
void Meta_Auto_Code::at_create( )
{
p_impl->at_create( );
}
void Meta_Auto_Code::post_init( )
{
p_impl->post_init( );
}
void Meta_Auto_Code::to_store( bool is_create, bool is_internal )
{
p_impl->to_store( is_create, is_internal );
}
void Meta_Auto_Code::for_store( bool is_create, bool is_internal )
{
p_impl->for_store( is_create, is_internal );
}
void Meta_Auto_Code::after_store( bool is_create, bool is_internal )
{
p_impl->after_store( is_create, is_internal );
}
bool Meta_Auto_Code::can_destroy( bool is_internal )
{
return p_impl->can_destroy( is_internal );
}
void Meta_Auto_Code::for_destroy( bool is_internal )
{
p_impl->for_destroy( is_internal );
}
void Meta_Auto_Code::after_destroy( bool is_internal )
{
p_impl->after_destroy( is_internal );
}
void Meta_Auto_Code::set_default_values( )
{
p_impl->set_default_values( );
}
bool Meta_Auto_Code::is_filtered( ) const
{
return p_impl->is_filtered( );
}
const char* Meta_Auto_Code::get_field_id(
const string& name, bool* p_sql_numeric, string* p_type_name ) const
{
const char* p_id( 0 );
if( name.empty( ) )
throw runtime_error( "unexpected empty field name for get_field_id" );
else if( name == c_field_name_Exhausted )
{
p_id = c_field_id_Exhausted;
if( p_type_name )
*p_type_name = "bool";
if( p_sql_numeric )
*p_sql_numeric = true;
}
else if( name == c_field_name_Mask )
{
p_id = c_field_id_Mask;
if( p_type_name )
*p_type_name = "string";
if( p_sql_numeric )
*p_sql_numeric = false;
}
else if( name == c_field_name_Next )
{
p_id = c_field_id_Next;
if( p_type_name )
*p_type_name = "string";
if( p_sql_numeric )
*p_sql_numeric = false;
}
return p_id;
}
const char* Meta_Auto_Code::get_field_name(
const string& id, bool* p_sql_numeric, string* p_type_name ) const
{
const char* p_name( 0 );
if( id.empty( ) )
throw runtime_error( "unexpected empty field id for get_field_name" );
else if( id == c_field_id_Exhausted )
{
p_name = c_field_name_Exhausted;
if( p_type_name )
*p_type_name = "bool";
if( p_sql_numeric )
*p_sql_numeric = true;
}
else if( id == c_field_id_Mask )
{
p_name = c_field_name_Mask;
if( p_type_name )
*p_type_name = "string";
if( p_sql_numeric )
*p_sql_numeric = false;
}
else if( id == c_field_id_Next )
{
p_name = c_field_name_Next;
if( p_type_name )
*p_type_name = "string";
if( p_sql_numeric )
*p_sql_numeric = false;
}
return p_name;
}
string& Meta_Auto_Code::get_order_field_name( ) const
{
return g_order_field_name;
}
string& Meta_Auto_Code::get_owner_field_name( ) const
{
return g_owner_field_name;
}
bool Meta_Auto_Code::is_file_field( const string& id_or_name ) const
{
return g_file_field_ids.count( id_or_name ) || g_file_field_names.count( id_or_name );
}
void Meta_Auto_Code::get_file_field_names( vector< string >& file_field_names ) const
{
for( set< string >::const_iterator ci = g_file_field_names.begin( ); ci != g_file_field_names.end( ); ++ci )
file_field_names.push_back( *ci );
}
string Meta_Auto_Code::get_field_uom_symbol( const string& id_or_name ) const
{
string uom_symbol;
string name;
pair< string, string > next;
if( id_or_name.empty( ) )
throw runtime_error( "unexpected empty field id_or_name for get_field_uom_symbol" );
else if( id_or_name == c_field_id_Exhausted || id_or_name == c_field_name_Exhausted )
{
name = string( c_field_display_name_Exhausted );
get_module_string( c_field_display_name_Exhausted, &next );
}
else if( id_or_name == c_field_id_Mask || id_or_name == c_field_name_Mask )
{
name = string( c_field_display_name_Mask );
get_module_string( c_field_display_name_Mask, &next );
}
else if( id_or_name == c_field_id_Next || id_or_name == c_field_name_Next )
{
name = string( c_field_display_name_Next );
get_module_string( c_field_display_name_Next, &next );
}
// NOTE: It is being assumed here that the customised UOM symbol for a field (if it
// has one) will be in the module string that immediately follows that of its name.
if( next.first.find( name + "_(" ) == 0 )
uom_symbol = next.second;
return uom_symbol;
}
string Meta_Auto_Code::get_field_display_name( const string& id_or_name ) const
{
string display_name;
if( id_or_name.empty( ) )
throw runtime_error( "unexpected empty field id_or_name for get_field_display_name" );
else if( id_or_name == c_field_id_Exhausted || id_or_name == c_field_name_Exhausted )
display_name = get_module_string( c_field_display_name_Exhausted );
else if( id_or_name == c_field_id_Mask || id_or_name == c_field_name_Mask )
display_name = get_module_string( c_field_display_name_Mask );
else if( id_or_name == c_field_id_Next || id_or_name == c_field_name_Next )
display_name = get_module_string( c_field_display_name_Next );
return display_name;
}
void Meta_Auto_Code::clear_foreign_key( const string& field )
{
p_impl->clear_foreign_key( field );
}
void Meta_Auto_Code::set_foreign_key_value( const string& field, const string& value )
{
p_impl->set_foreign_key_value( field, value );
}
const string& Meta_Auto_Code::get_foreign_key_value( const string& field )
{
return p_impl->get_foreign_key_value( field );
}
void Meta_Auto_Code::get_foreign_key_values( foreign_key_data_container& foreign_key_values ) const
{
p_impl->get_foreign_key_values( foreign_key_values );
}
size_t Meta_Auto_Code::get_total_child_relationships( ) const
{
return p_impl->total_child_relationships;
}
void Meta_Auto_Code::set_total_child_relationships( size_t new_total_child_relationships ) const
{
p_impl->total_child_relationships = new_total_child_relationships;
}
size_t Meta_Auto_Code::get_num_foreign_key_children( bool is_internal ) const
{
size_t rc = 0;
if( !is_internal )
{
g_external_aliases_lookup.clear( );
for( external_aliases_const_iterator
eaci = g_external_aliases.begin( ), end = g_external_aliases.end( ); eaci != end; ++eaci )
{
size_t num_extra = eaci->second->get_num_foreign_key_children( true );
if( num_extra )
{
eaci->second->set_key( get_key( ) );
eaci->second->copy_all_field_values( *this );
g_external_aliases_lookup.insert( make_pair( rc, eaci->second ) );
rc += num_extra;
}
}
}
set_total_child_relationships( rc );
return rc;
}
class_base* Meta_Auto_Code::get_next_foreign_key_child(
size_t child_num, string& next_child_field, cascade_op op, bool is_internal )
{
class_base* p_class_base = 0;
( void )child_num;
( void )next_child_field;
( void )op;
return p_class_base;
}
void Meta_Auto_Code::add_extra_fixed_info( vector< pair< string, string > >& fixed_info ) const
{
p_impl->add_extra_fixed_info( fixed_info );
}
void Meta_Auto_Code::add_extra_paging_info( vector< pair< string, string > >& paging_info ) const
{
p_impl->add_extra_paging_info( paging_info );
}
string Meta_Auto_Code::get_class_id( ) const
{
return static_class_id( );
}
string Meta_Auto_Code::get_class_name( ) const
{
return static_class_name( );
}
string Meta_Auto_Code::get_plural_name( ) const
{
return static_plural_name( );
}
string Meta_Auto_Code::get_module_id( ) const
{
return static_module_id( );
}
string Meta_Auto_Code::get_module_name( ) const
{
return static_module_name( );
}
string Meta_Auto_Code::get_display_name( bool plural ) const
{
string key( plural ? "plural_" : "class_" );
key += "auto_code";
return get_module_string( key );
}
string Meta_Auto_Code::get_raw_variable( const std::string& name ) const
{
if( name == g_state_names_variable )
return p_impl->get_state_names( );
else
return class_base::get_raw_variable( name );
}
string Meta_Auto_Code::get_create_instance_info( ) const
{
return "";
}
string Meta_Auto_Code::get_update_instance_info( ) const
{
return "";
}
string Meta_Auto_Code::get_destroy_instance_info( ) const
{
return "";
}
string Meta_Auto_Code::get_execute_procedure_info( const string& procedure_id ) const
{
string retval;
if( procedure_id.empty( ) )
throw runtime_error( "unexpected empty procedure_id for get_execute_procedure_info" );
else if( procedure_id == "125410" ) // i.e. Increment
retval = "";
return retval;
}
bool Meta_Auto_Code::get_is_alias( ) const
{
return false;
}
void Meta_Auto_Code::get_alias_base_info( pair< string, string >& alias_base_info ) const
{
( void )alias_base_info;
}
void Meta_Auto_Code::get_base_class_info( vector< pair< string, string > >& base_class_info ) const
{
( void )base_class_info;
}
class_base& Meta_Auto_Code::get_or_create_graph_child( const string& context )
{
class_base* p_class_base( 0 );
string::size_type pos = context.find( '.' );
string sub_context( context.substr( 0, pos ) );
if( sub_context.empty( ) )
throw runtime_error( "unexpected empty sub-context" );
if( !p_class_base )
throw runtime_error( "unknown sub-context '" + sub_context + "'" );
if( pos != string::npos )
p_class_base = &p_class_base->get_or_create_graph_child( context.substr( pos + 1 ) );
return *p_class_base;
}
void Meta_Auto_Code::get_sql_column_names(
vector< string >& names, bool* p_done, const string* p_class_name ) const
{
if( p_done && *p_done )
return;
names.push_back( "C_Exhausted" );
names.push_back( "C_Mask" );
names.push_back( "C_Next" );
if( p_done && p_class_name && *p_class_name == static_class_name( ) )
*p_done = true;
}
void Meta_Auto_Code::get_sql_column_values(
vector< string >& values, bool* p_done, const string* p_class_name ) const
{
if( p_done && *p_done )
return;
values.push_back( to_string( Exhausted( ) ) );
values.push_back( sql_quote( to_string( Mask( ) ) ) );
values.push_back( sql_quote( to_string( Next( ) ) ) );
if( p_done && p_class_name && *p_class_name == static_class_name( ) )
*p_done = true;
}
void Meta_Auto_Code::get_required_field_names(
set< string >& names, bool use_transients, set< string >* p_dependents ) const
{
set< string > local_dependents;
set< string >& dependents( p_dependents ? *p_dependents : local_dependents );
get_always_required_field_names( names, use_transients, dependents );
// [<start get_required_field_names>]
// [<finish get_required_field_names>]
}
void Meta_Auto_Code::get_always_required_field_names(
set< string >& names, bool use_transients, set< string >& dependents ) const
{
( void )names;
( void )dependents;
( void )use_transients;
// [<start get_always_required_field_names>]
// [<finish get_always_required_field_names>]
}
void Meta_Auto_Code::get_transient_replacement_field_names( const string& name, vector< string >& names ) const
{
( void )name;
( void )names;
// [<start get_transient_replacement_field_names>]
// [<finish get_transient_replacement_field_names>]
}
void Meta_Auto_Code::do_generate_sql( generate_sql_type type,
vector< string >& sql_stmts, set< string >& tx_key_info, vector< string >* p_sql_undo_stmts ) const
{
generate_sql( static_class_name( ), type, sql_stmts, tx_key_info, p_sql_undo_stmts );
}
const char* Meta_Auto_Code::static_resolved_module_id( )
{
return static_module_id( );
}
const char* Meta_Auto_Code::static_resolved_module_name( )
{
return static_module_name( );
}
const char* Meta_Auto_Code::static_lock_class_id( )
{
return "125100";
}
const char* Meta_Auto_Code::static_check_class_name( )
{
return "Auto_Code";
}
const char* Meta_Auto_Code::static_persistence_extra( )
{
return "";
}
bool Meta_Auto_Code::static_has_derivations( )
{
return !g_derivations.empty( );
}
void Meta_Auto_Code::static_get_class_info( class_info_container& class_info )
{
class_info.push_back( "100.125100" );
}
void Meta_Auto_Code::static_get_field_info( field_info_container& all_field_info )
{
all_field_info.push_back( field_info( "125103", "Exhausted", "bool", false, "", "" ) );
all_field_info.push_back( field_info( "125101", "Mask", "string", false, "", "" ) );
all_field_info.push_back( field_info( "125102", "Next", "string", false, "", "" ) );
}
void Meta_Auto_Code::static_get_foreign_key_info( foreign_key_info_container& foreign_key_info )
{
( void )foreign_key_info;
}
int Meta_Auto_Code::static_get_num_fields( bool* p_done, const string* p_class_name )
{
if( p_done && p_class_name && *p_class_name == static_class_name( ) )
*p_done = true;
return c_num_fields;
}
bool Meta_Auto_Code::static_is_field_encrypted( field_id id )
{
return is_encrypted_field( static_get_field_id( id ) );
}
bool Meta_Auto_Code::static_is_field_transient( field_id id )
{
return is_transient_field( static_get_field_id( id ) );
}
const char* Meta_Auto_Code::static_get_field_id( field_id id )
{
const char* p_id = 0;
switch( id )
{
case 1:
p_id = "125103";
break;
case 2:
p_id = "125101";
break;
case 3:
p_id = "125102";
break;
}
if( !p_id )
throw runtime_error( "unknown field id #" + to_string( id ) + " for class Auto_Code" );
return p_id;
}
const char* Meta_Auto_Code::static_get_field_name( field_id id )
{
const char* p_id = 0;
switch( id )
{
case 1:
p_id = "Exhausted";
break;
case 2:
p_id = "Mask";
break;
case 3:
p_id = "Next";
break;
}
if( !p_id )
throw runtime_error( "unknown field id #" + to_string( id ) + " for class Auto_Code" );
return p_id;
}
int Meta_Auto_Code::static_get_field_num( const string& field )
{
int rc = 0;
if( field.empty( ) )
throw runtime_error( "unexpected empty field name/id for static_get_field_num( )" );
else if( field == c_field_id_Exhausted || field == c_field_name_Exhausted )
rc += 1;
else if( field == c_field_id_Mask || field == c_field_name_Mask )
rc += 2;
else if( field == c_field_id_Next || field == c_field_name_Next )
rc += 3;
return rc - 1;
}
procedure_info_container& Meta_Auto_Code::static_get_procedure_info( )
{
static bool initialised = false;
static procedure_info_container procedures;
if( !initialised )
{
initialised = true;
procedures.insert( make_pair( "125410", procedure_info( "Increment" ) ) );
}
return procedures;
}
string Meta_Auto_Code::static_get_sql_columns( )
{
string sql_columns;
sql_columns +=
"C_Key_ VARCHAR(75),"
"C_Ver_ SMALLINT UNSIGNED NOT NULL,"
"C_Rev_ BIGINT UNSIGNED NOT NULL,"
"C_Typ_ VARCHAR(24) NOT NULL,"
"C_Exhausted INTEGER NOT NULL,"
"C_Mask VARCHAR(200) NOT NULL,"
"C_Next VARCHAR(200) NOT NULL,"
"PRIMARY KEY(C_Key_)";
return sql_columns;
}
void Meta_Auto_Code::static_get_text_search_fields( vector< string >& fields )
{
( void )fields;
}
void Meta_Auto_Code::static_get_all_enum_pairs( vector< pair< string, string > >& pairs )
{
( void )pairs;
}
void Meta_Auto_Code::static_get_sql_indexes( vector< string >& indexes )
{
( void )indexes;
}
void Meta_Auto_Code::static_get_sql_unique_indexes( vector< string >& indexes )
{
( void )indexes;
}
void Meta_Auto_Code::static_insert_derivation( const string& module_and_class_id )
{
g_derivations.insert( module_and_class_id );
}
void Meta_Auto_Code::static_remove_derivation( const string& module_and_class_id )
{
if( g_derivations.count( module_and_class_id ) )
g_derivations.erase( module_and_class_id );
}
void Meta_Auto_Code::static_insert_external_alias( const string& module_and_class_id, Meta_Auto_Code* p_instance )
{
g_external_aliases.insert( external_aliases_value_type( module_and_class_id, p_instance ) );
}
void Meta_Auto_Code::static_remove_external_alias( const string& module_and_class_id )
{
if( g_external_aliases.count( module_and_class_id ) )
{
delete g_external_aliases[ module_and_class_id ];
g_external_aliases.erase( module_and_class_id );
}
}
void Meta_Auto_Code::static_class_init( const char* p_module_name )
{
if( !p_module_name )
throw runtime_error( "unexpected null module name pointer for init" );
g_state_names_variable = get_special_var_name( e_special_var_state_names );
// [<start static_class_init>]
// [<finish static_class_init>]
}
void Meta_Auto_Code::static_class_term( const char* p_module_name )
{
if( !p_module_name )
throw runtime_error( "unexpected null module name pointer for term" );
// [<start static_class_term>]
// [<finish static_class_term>]
}
| 25.910624 | 124 | 0.67708 | ciyam |
3bb205d82c7a90242d419db7e5da2db8fca07f7b | 420 | cpp | C++ | src/roq/samples/example-4/config.cpp | roq-trading/examples | 1e8ac9f5a960378ae4dc4d4a6b83f8daf6a65cba | [
"BSD-3-Clause"
] | null | null | null | src/roq/samples/example-4/config.cpp | roq-trading/examples | 1e8ac9f5a960378ae4dc4d4a6b83f8daf6a65cba | [
"BSD-3-Clause"
] | null | null | null | src/roq/samples/example-4/config.cpp | roq-trading/examples | 1e8ac9f5a960378ae4dc4d4a6b83f8daf6a65cba | [
"BSD-3-Clause"
] | null | null | null | /* Copyright (c) 2017-2022, Hans Erik Thrane */
#include "roq/samples/example-4/config.hpp"
#include "roq/samples/example-4/flags.hpp"
namespace roq {
namespace samples {
namespace example_4 {
void Config::dispatch(Handler &handler) const {
handler(client::Symbol{
.regex = Flags::symbols(),
.exchange = Flags::exchange(),
});
}
} // namespace example_4
} // namespace samples
} // namespace roq
| 20 | 47 | 0.678571 | roq-trading |
3bb4800991fff29b1a82a180d581df476a52d2f0 | 2,401 | cpp | C++ | geomFuncs.cpp | kamino410/CudaSift | 21d98443f919f877246aadde1d5e1c16fb7afa14 | [
"MIT"
] | null | null | null | geomFuncs.cpp | kamino410/CudaSift | 21d98443f919f877246aadde1d5e1c16fb7afa14 | [
"MIT"
] | null | null | null | geomFuncs.cpp | kamino410/CudaSift | 21d98443f919f877246aadde1d5e1c16fb7afa14 | [
"MIT"
] | null | null | null | #include <Eigen/Dense>
#include <cmath>
#include <iostream>
#include "cudaSift.h"
int ImproveHomography(SiftData &data, float *homography, int numLoops, float minScore,
float maxAmbiguity, float thresh) {
#ifdef MANAGEDMEM
SiftPoint *mpts = data.m_data;
#else
if (data.h_data == NULL) return 0;
SiftPoint *mpts = data.h_data;
#endif
float limit = thresh * thresh;
int numPts = data.numPts;
Eigen::MatrixXd M(8, 8);
Eigen::VectorXd A(8);
Eigen::VectorXd X(8);
Eigen::VectorXd Y(8);
for (int i = 0; i < 8; i++) A(i) = homography[i] / homography[8];
for (int loop = 0; loop < numLoops; loop++) {
M = Eigen::MatrixXd::Zero(8, 8);
X = Eigen::VectorXd::Zero(8);
for (int i = 0; i < numPts; i++) {
SiftPoint &pt = mpts[i];
if (pt.score < minScore || pt.ambiguity > maxAmbiguity) continue;
float den = A(6) * pt.xpos + A(7) * pt.ypos + 1.0f;
float dx = (A(0) * pt.xpos + A(1) * pt.ypos + A(2)) / den - pt.match_xpos;
float dy = (A(3) * pt.xpos + A(4) * pt.ypos + A(5)) / den - pt.match_ypos;
float err = dx * dx + dy * dy;
float wei = (err < limit ? 1.0f : 0.0f); // limit / (err + limit);
Y(0) = pt.xpos;
Y(1) = pt.ypos;
Y(2) = 1.0;
Y(3) = Y(4) = Y(5) = 0.0;
Y(6) = -pt.xpos * pt.match_xpos;
Y(7) = -pt.ypos * pt.match_xpos;
for (int c = 0; c < 8; c++)
for (int r = 0; r < 8; r++) M(r, c) += (Y(c) * Y(r) * wei);
X += (Y * pt.match_xpos * wei);
Y(0) = Y(1) = Y(2) = 0.0;
Y(3) = pt.xpos;
Y(4) = pt.ypos;
Y(5) = 1.0;
Y(6) = -pt.xpos * pt.match_ypos;
Y(7) = -pt.ypos * pt.match_ypos;
for (int c = 0; c < 8; c++)
for (int r = 0; r < 8; r++) M(r, c) += (Y(c) * Y(r) * wei);
X += (Y * pt.match_ypos * wei);
}
// cv::solve(M, X, A, cv::DECOMP_CHOLESKY);
A = M.colPivHouseholderQr().solve(X);
}
int numfit = 0;
for (int i = 0; i < numPts; i++) {
SiftPoint &pt = mpts[i];
float den = A(6) * pt.xpos + A(7) * pt.ypos + 1.0;
float dx = (A(0) * pt.xpos + A(1) * pt.ypos + A(2)) / den - pt.match_xpos;
float dy = (A(3) * pt.xpos + A(4) * pt.ypos + A(5)) / den - pt.match_ypos;
float err = dx * dx + dy * dy;
if (err < limit) numfit++;
pt.match_error = sqrt(err);
}
for (int i = 0; i < 8; i++) homography[i] = A(i);
homography[8] = 1.0f;
return numfit;
}
| 34.797101 | 86 | 0.512703 | kamino410 |
3bb8f845ec8bb4eff8981c1f6ee8a36d679cf795 | 6,242 | cpp | C++ | lib/Dialect/SV/Transforms/PrettifyVerilog.cpp | mwachs5/circt | bd7edb5c449921cb36939ebb5943e4fe73f72899 | [
"Apache-2.0"
] | null | null | null | lib/Dialect/SV/Transforms/PrettifyVerilog.cpp | mwachs5/circt | bd7edb5c449921cb36939ebb5943e4fe73f72899 | [
"Apache-2.0"
] | null | null | null | lib/Dialect/SV/Transforms/PrettifyVerilog.cpp | mwachs5/circt | bd7edb5c449921cb36939ebb5943e4fe73f72899 | [
"Apache-2.0"
] | null | null | null | //===- PrettifyVerilog.cpp - Transformations to improve Verilog quality ---===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This pass contains elective transformations that improve the quality of
// SystemVerilog generated by the ExportVerilog library. This pass is not
// compulsory: things that are required for ExportVerilog to be correct should
// be included as part of the ExportVerilog pass itself to make sure it is self
// contained.
//
//===----------------------------------------------------------------------===//
#include "PassDetail.h"
#include "circt/Dialect/Comb/CombOps.h"
#include "circt/Dialect/HW/HWOps.h"
#include "circt/Dialect/SV/SVPasses.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/Matchers.h"
using namespace circt;
//===----------------------------------------------------------------------===//
// PrettifyVerilogPass
//===----------------------------------------------------------------------===//
namespace {
struct PrettifyVerilogPass
: public sv::PrettifyVerilogBase<PrettifyVerilogPass> {
void runOnOperation() override;
private:
void prettifyUnaryOperator(Operation *op);
void sinkOpToUses(Operation *op);
bool anythingChanged;
};
} // end anonymous namespace
/// Return true if this is something that will get printed as a unary operator
/// by the Verilog printer.
static bool isVerilogUnaryOperator(Operation *op) {
if (isa<comb::ParityOp>(op))
return true;
if (auto xorOp = dyn_cast<comb::XorOp>(op))
return xorOp.isBinaryNot();
if (auto icmpOp = dyn_cast<comb::ICmpOp>(op))
return icmpOp.isEqualAllOnes() || icmpOp.isNotEqualZero();
return false;
}
/// Sink an operation into the same block where it is used. This will clone the
/// operation so it can be sunk into multiple blocks. If there are no more uses
/// in the current block, the op will be removed.
void PrettifyVerilogPass::sinkOpToUses(Operation *op) {
assert(mlir::MemoryEffectOpInterface::hasNoEffect(op) &&
"Op with side effects cannot be sunk to its uses.");
auto block = op->getBlock();
// This maps a block to the block local instance of the op.
SmallDenseMap<Block *, Value, 8> blockLocalValues;
for (auto &use : llvm::make_early_inc_range(op->getUses())) {
// If the current use is in the same block as the operation, there is
// nothing to do.
auto localBlock = use.getOwner()->getBlock();
if (block == localBlock)
continue;
// Find the block local clone of the operation. If there is not one already,
// the op will be cloned in to the block.
auto &localValue = blockLocalValues[localBlock];
if (!localValue) {
// Clone the operation and insert it to the beginning of the block.
localValue = OpBuilder::atBlockBegin(localBlock).clone(*op)->getResult(0);
}
// Replace the current use, removing it from the use list.
use.set(localValue);
anythingChanged = true;
}
// If this op is no longer used, drop it.
if (op->use_empty()) {
op->erase();
anythingChanged = true;
}
}
/// This is called on unary operators.
void PrettifyVerilogPass::prettifyUnaryOperator(Operation *op) {
// If this is a multiple use unary operator, duplicate it and move it into the
// block corresponding to the user. This avoids emitting a temporary just for
// a unary operator. Instead of:
//
// tmp1 = ^(thing+thing);
// = tmp1 + 42
//
// we get:
//
// tmp2 = thing+thing;
// = ^tmp2 + 42
//
// This is particularly helpful when the operand of the unary op has multiple
// uses as well.
if (op->use_empty() || op->hasOneUse())
return;
while (!op->hasOneUse()) {
OpOperand &use = *op->use_begin();
Operation *user = use.getOwner();
// Clone the operation and insert before this user.
auto *cloned = op->clone();
user->getBlock()->getOperations().insert(Block::iterator(user), cloned);
// Update user's operand to the new value.
use.set(cloned->getResult(0));
}
// There is exactly one user left, so move this before it.
Operation *user = *op->user_begin();
op->moveBefore(user);
anythingChanged = true;
}
/// Transform "a + -cst" ==> "a - cst" for prettier output.
static void rewriteAddWithNegativeConstant(comb::AddOp add,
hw::ConstantOp rhsCst) {
ImplicitLocOpBuilder builder(add.getLoc(), add);
// Get the positive constant.
auto negCst = builder.create<hw::ConstantOp>(-rhsCst.getValue());
auto sub = builder.create<comb::SubOp>(add.getOperand(0), negCst);
add.getResult().replaceAllUsesWith(sub);
add.erase();
if (rhsCst.use_empty())
rhsCst.erase();
}
void PrettifyVerilogPass::runOnOperation() {
// Keeps track if anything changed during this pass, used to determine if
// the analyses were preserved.
anythingChanged = false;
// Walk the operations in post-order, transforming any that are interesting.
getOperation()->walk([&](Operation *op) {
if (isVerilogUnaryOperator(op))
return prettifyUnaryOperator(op);
// Sink or duplicate constant ops into the same block as their use. This
// will allow the verilog emitter to inline constant expressions.
if (matchPattern(op, mlir::m_Constant()))
return sinkOpToUses(op);
// Sink "free" operations which make Verilog prettier.
if (isa<sv::ReadInOutOp>(op))
return sinkOpToUses(op);
// Turn a + -cst ==> a - cst
if (auto addOp = dyn_cast<comb::AddOp>(op))
if (auto cst = addOp.getOperand(1).getDefiningOp<hw::ConstantOp>())
if (addOp.getNumOperands() == 2 && cst.getValue().isNegative())
return rewriteAddWithNegativeConstant(addOp, cst);
});
// If we did not change anything in the graph mark all analysis as
// preserved.
if (!anythingChanged)
markAllAnalysesPreserved();
}
std::unique_ptr<Pass> circt::sv::createPrettifyVerilogPass() {
return std::make_unique<PrettifyVerilogPass>();
}
| 35.265537 | 80 | 0.652515 | mwachs5 |
3bba94a2dc61eae4b9c5ed9bb65bc515ea0ed1c7 | 1,953 | cpp | C++ | snippets/cpp/VS_Snippets_CLR_System/system.Array.Resize/CPP/System.Array.Resize.cpp | BohdanMosiyuk/samples | 59d435ba9e61e0fc19f5176c96b1cdbd53596142 | [
"CC-BY-4.0",
"MIT"
] | 2 | 2020-02-22T09:30:21.000Z | 2021-08-02T23:44:31.000Z | snippets/cpp/VS_Snippets_CLR_System/system.Array.Resize/CPP/System.Array.Resize.cpp | BohdanMosiyuk/samples | 59d435ba9e61e0fc19f5176c96b1cdbd53596142 | [
"CC-BY-4.0",
"MIT"
] | 555 | 2019-09-23T22:22:58.000Z | 2021-07-15T18:51:12.000Z | snippets/cpp/VS_Snippets_CLR_System/system.Array.Resize/CPP/System.Array.Resize.cpp | BohdanMosiyuk/samples | 59d435ba9e61e0fc19f5176c96b1cdbd53596142 | [
"CC-BY-4.0",
"MIT"
] | 3 | 2020-01-29T16:31:15.000Z | 2021-08-24T07:00:15.000Z |
// The following example shows how resizing affects the array.
// <Snippet1>
using namespace System;
static void PrintIndexAndValues(array<String^>^myArr)
{
for(int i = 0; i < myArr->Length; i++)
{
Console::WriteLine(L" [{0}] : {1}", i, myArr[i]);
}
Console::WriteLine();
}
int main()
{
// Create and initialize a new string array.
array<String^>^myArr = {L"The", L"quick", L"brown", L"fox",
L"jumps", L"over", L"the", L"lazy", L"dog"};
// Display the values of the array.
Console::WriteLine(
L"The string array initially contains the following values:");
PrintIndexAndValues(myArr);
// Resize the array to a bigger size (five elements larger).
Array::Resize(myArr, myArr->Length + 5);
// Display the values of the array.
Console::WriteLine(L"After resizing to a larger size, ");
Console::WriteLine(L"the string array contains the following values:");
PrintIndexAndValues(myArr);
// Resize the array to a smaller size (four elements).
Array::Resize(myArr, 4);
// Display the values of the array.
Console::WriteLine(L"After resizing to a smaller size, ");
Console::WriteLine(L"the string array contains the following values:");
PrintIndexAndValues(myArr);
return 1;
}
/*
This code produces the following output.
The string array initially contains the following values:
[0] : The
[1] : quick
[2] : brown
[3] : fox
[4] : jumps
[5] : over
[6] : the
[7] : lazy
[8] : dog
After resizing to a larger size,
the string array contains the following values:
[0] : The
[1] : quick
[2] : brown
[3] : fox
[4] : jumps
[5] : over
[6] : the
[7] : lazy
[8] : dog
[9] :
[10] :
[11] :
[12] :
[13] :
After resizing to a smaller size,
the string array contains the following values:
[0] : The
[1] : quick
[2] : brown
[3] : fox
*/
// </Snippet1>
| 23.25 | 75 | 0.605223 | BohdanMosiyuk |
3bc0b13dff18c8ab8d1ed82e90de4608b4e55925 | 13,346 | cpp | C++ | src/observation/observation.cpp | bburns/cppagent | c1891c631465ebc9b63a4b3c627727ca3da14ee8 | [
"Apache-2.0"
] | null | null | null | src/observation/observation.cpp | bburns/cppagent | c1891c631465ebc9b63a4b3c627727ca3da14ee8 | [
"Apache-2.0"
] | null | null | null | src/observation/observation.cpp | bburns/cppagent | c1891c631465ebc9b63a4b3c627727ca3da14ee8 | [
"Apache-2.0"
] | null | null | null | //
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "observation.hpp"
#include <mutex>
#include <regex>
#include "device_model/data_item/data_item.hpp"
#include "entity/factory.hpp"
#include "logging.hpp"
#ifdef _WINDOWS
#define strcasecmp stricmp
#define strncasecmp strnicmp
#define strtof strtod
#endif
using namespace std;
namespace mtconnect {
using namespace entity;
namespace observation {
FactoryPtr Observation::getFactory()
{
static FactoryPtr factory;
if (!factory)
{
factory = make_shared<Factory>(Requirements({{"dataItemId", true},
{"timestamp", TIMESTAMP, true},
{"sequence", false},
{"subType", false},
{"name", false},
{"compositionId", false}}),
[](const std::string &name, Properties &props) -> EntityPtr {
return make_shared<Observation>(name, props);
});
factory->registerFactory("Events:Message", Message::getFactory());
factory->registerFactory("Events:MessageDiscrete", Message::getFactory());
factory->registerFactory("Events:AssetChanged", AssetEvent::getFactory());
factory->registerFactory("Events:AssetRemoved", AssetEvent::getFactory());
factory->registerFactory("Events:Alarm", Alarm::getFactory());
// regex(".+TimeSeries$")
factory->registerFactory(
[](const std::string &name) { return ends_with(name, "TimeSeries"); },
Timeseries::getFactory());
factory->registerFactory([](const std::string &name) { return ends_with(name, "DataSet"); },
DataSetEvent::getFactory());
factory->registerFactory([](const std::string &name) { return ends_with(name, "Table"); },
TableEvent::getFactory());
factory->registerFactory(
[](const std::string &name) { return starts_with(name, "Condition:"); },
Condition::getFactory());
factory->registerFactory(
[](const std::string &name) {
return starts_with(name, "Samples:") && ends_with(name, ":3D");
},
ThreeSpaceSample::getFactory());
factory->registerFactory(
[](const std::string &name) { return starts_with(name, "Samples:"); },
Sample::getFactory());
factory->registerFactory(
[](const std::string &name) { return starts_with(name, "Events:"); },
Event::getFactory());
}
return factory;
}
ObservationPtr Observation::make(const DataItemPtr dataItem, const Properties &incompingProps,
const Timestamp ×tamp, entity::ErrorList &errors)
{
NAMED_SCOPE("Observation");
auto props = entity::Properties(incompingProps);
setProperties(dataItem, props);
props.insert_or_assign("timestamp", timestamp);
bool unavailable {false};
string level;
if (dataItem->isCondition())
{
auto l = props.find("level");
if (l != props.end())
{
level = std::get<string>(l->second);
if (iequals(level, "unavailable"))
unavailable = true;
props.erase(l);
}
else if (l == props.end())
{
unavailable = true;
}
}
else
{
// Check for unavailable
auto v = props.find("VALUE");
if (v != props.end() && holds_alternative<string>(v->second))
{
if (iequals(std::get<string>(v->second), "unavailable"))
{
unavailable = true;
props.erase(v);
}
}
else if (v == props.end())
{
unavailable = true;
}
}
string key = string(dataItem->getCategoryText()) + ":" + dataItem->getObservationName();
if (dataItem->isThreeSpace())
key += ":3D";
auto ent = getFactory()->create(key, props, errors);
if (!ent)
{
LOG(warning) << "Could not parse properties for data item: " << dataItem->getId();
for (auto &e : errors)
{
LOG(warning) << " Error: " << e->what();
}
throw EntityError("Invalid properties for data item");
}
auto obs = dynamic_pointer_cast<Observation>(ent);
obs->m_timestamp = timestamp;
obs->m_dataItem = dataItem;
if (unavailable)
obs->makeUnavailable();
if (!dataItem->isCondition())
obs->setEntityName();
else if (!unavailable)
dynamic_pointer_cast<Condition>(obs)->setLevel(level);
return obs;
}
FactoryPtr Event::getFactory()
{
static FactoryPtr factory;
if (!factory)
{
factory = make_shared<Factory>(*Observation::getFactory());
factory->setFunction([](const std::string &name, Properties &props) -> EntityPtr {
return make_shared<Event>(name, props);
});
factory->addRequirements(
Requirements {{"VALUE", false}, {"resetTriggered", USTRING, false}});
}
return factory;
}
FactoryPtr DataSetEvent::getFactory()
{
static FactoryPtr factory;
if (!factory)
{
factory = make_shared<Factory>(*Observation::getFactory());
factory->setFunction([](const std::string &name, Properties &props) -> EntityPtr {
auto ent = make_shared<DataSetEvent>(name, props);
auto v = ent->m_properties.find("VALUE");
if (v != ent->m_properties.end())
{
auto &ds = std::get<DataSet>(v->second);
ent->m_properties.insert_or_assign("count", int64_t(ds.size()));
}
return ent;
});
factory->addRequirements(Requirements {{"count", INTEGER, false},
{"VALUE", DATA_SET, false},
{"resetTriggered", USTRING, false}});
}
return factory;
}
FactoryPtr TableEvent::getFactory()
{
static FactoryPtr factory;
if (!factory)
{
factory = make_shared<Factory>(*DataSetEvent::getFactory());
factory->setFunction([](const std::string &name, Properties &props) -> EntityPtr {
auto ent = make_shared<TableEvent>(name, props);
auto v = ent->m_properties.find("VALUE");
if (v != ent->m_properties.end())
{
auto &ds = std::get<DataSet>(v->second);
ent->m_properties.insert_or_assign("count", int64_t(ds.size()));
}
return ent;
});
factory->addRequirements(Requirements {{"VALUE", TABLE, false}});
}
return factory;
}
FactoryPtr Sample::getFactory()
{
static FactoryPtr factory;
if (!factory)
{
factory = make_shared<Factory>(*Observation::getFactory());
factory->setFunction([](const std::string &name, Properties &props) -> EntityPtr {
return make_shared<Sample>(name, props);
});
factory->addRequirements(Requirements({{"sampleRate", DOUBLE, false},
{"resetTriggered", USTRING, false},
{"statistic", USTRING, false},
{"duration", DOUBLE, false},
{"VALUE", DOUBLE, false}}));
}
return factory;
}
FactoryPtr ThreeSpaceSample::getFactory()
{
static FactoryPtr factory;
if (!factory)
{
factory = make_shared<Factory>(*Sample::getFactory());
factory->setFunction([](const std::string &name, Properties &props) -> EntityPtr {
return make_shared<ThreeSpaceSample>(name, props);
});
factory->addRequirements(Requirements({{"VALUE", VECTOR, 3, false}}));
}
return factory;
}
FactoryPtr Timeseries::getFactory()
{
static FactoryPtr factory;
if (!factory)
{
factory = make_shared<Factory>(*Sample::getFactory());
factory->setFunction([](const std::string &name, Properties &props) -> EntityPtr {
auto ent = make_shared<Timeseries>(name, props);
auto v = ent->m_properties.find("VALUE");
if (v != ent->m_properties.end())
{
auto &ts = std::get<entity::Vector>(v->second);
ent->m_properties.insert_or_assign("sampleCount", int64_t(ts.size()));
}
return ent;
});
factory->addRequirements(
Requirements({{"sampleCount", INTEGER, false},
{"VALUE", VECTOR, 0, entity::Requirement::Infinite}}));
}
return factory;
}
FactoryPtr Condition::getFactory()
{
static FactoryPtr factory;
if (!factory)
{
factory = make_shared<Factory>(*Observation::getFactory());
factory->setFunction([](const std::string &name, Properties &props) -> EntityPtr {
auto cond = make_shared<Condition>(name, props);
if (cond)
{
auto code = cond->m_properties.find("nativeCode");
if (code != cond->m_properties.end())
cond->m_code = std::get<string>(code->second);
}
return cond;
});
factory->addRequirements(Requirements {{"type", USTRING, true},
{"nativeCode", false},
{"nativeSeverity", false},
{"qualifier", USTRING, false},
{"statistic", USTRING, false},
{"VALUE", false}});
}
return factory;
}
FactoryPtr AssetEvent::getFactory()
{
static FactoryPtr factory;
if (!factory)
{
factory = make_shared<Factory>(*Event::getFactory());
factory->setFunction([](const std::string &name, Properties &props) -> EntityPtr {
auto ent = make_shared<AssetEvent>(name, props);
if (!ent->hasProperty("assetType") && !ent->hasValue())
{
ent->setProperty("assetType", "UNAVAILABLE"s);
}
return ent;
});
factory->addRequirements(Requirements({{"assetType", false}}));
}
return factory;
}
FactoryPtr Message::getFactory()
{
static FactoryPtr factory;
if (!factory)
{
factory = make_shared<Factory>(*Event::getFactory());
factory->setFunction([](const std::string &name, Properties &props) -> EntityPtr {
return make_shared<Message>(name, props);
});
factory->addRequirements(Requirements({{"nativeCode", false}}));
}
return factory;
}
FactoryPtr Alarm::getFactory()
{
static FactoryPtr factory;
if (!factory)
{
factory = make_shared<Factory>(*Event::getFactory());
factory->setFunction([](const std::string &name, Properties &props) -> EntityPtr {
return make_shared<Alarm>(name, props);
});
factory->addRequirements(Requirements({{"code", false},
{"nativeCode", false},
{"state", USTRING, false},
{"severity", false}}));
}
return factory;
}
bool Condition::replace(ConditionPtr &old, ConditionPtr &_new)
{
if (!m_prev)
return false;
if (m_prev == old)
{
_new->m_prev = old->m_prev;
m_prev = _new;
return true;
}
return m_prev->replace(old, _new);
}
ConditionPtr Condition::deepCopy()
{
auto n = make_shared<Condition>(*this);
if (m_prev)
{
n->m_prev = m_prev->deepCopy();
}
return n;
}
ConditionPtr Condition::deepCopyAndRemove(ConditionPtr &old)
{
if (this->getptr() == old)
{
if (m_prev)
return m_prev->deepCopy();
else
return nullptr;
}
auto n = make_shared<Condition>(*this);
if (m_prev)
{
n->m_prev = m_prev->deepCopyAndRemove(old);
}
return n;
}
} // namespace observation
} // namespace mtconnect
| 33.199005 | 100 | 0.533119 | bburns |
3bc74862820321bf365db6840880b57b73d20018 | 4,635 | cpp | C++ | trikGui/communicationSettingsWidget.cpp | Ashatta/trikRuntime | 0e08a584b09c6319c7fb3020bcd0df3f27b976b3 | [
"Apache-2.0"
] | null | null | null | trikGui/communicationSettingsWidget.cpp | Ashatta/trikRuntime | 0e08a584b09c6319c7fb3020bcd0df3f27b976b3 | [
"Apache-2.0"
] | null | null | null | trikGui/communicationSettingsWidget.cpp | Ashatta/trikRuntime | 0e08a584b09c6319c7fb3020bcd0df3f27b976b3 | [
"Apache-2.0"
] | null | null | null | /* Copyright 2014 CyberTech Labs Ltd.
*
* 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 "communicationSettingsWidget.h"
#include <QtCore/QRegExp>
#include <QtGui/QKeyEvent>
using namespace trikGui;
CommunicationSettingsWidget::CommunicationSettingsWidget(trikControl::Brick &brick
, QWidget *parent)
: TrikGuiDialog(parent)
, mTitle(tr("<b>Comm settings</b>"))
, mSelectorsHelpLabel(tr("(Press 'Enter' to edit)"))
, mHullNumberLabel(tr("Hull number:"))
, mHullNumberSelector(brick.mailbox()->myHullNumber(), 2, 0, 35, this)
, mServerIpLabel(tr("Leader IP:"))
, mIpHelpLabel(tr("(last two numbers)"))
, mServerIpSelector(0, 6, 3, 25, this)
, mBrick(brick)
{
mConnectButton.setText(tr("Connect"));
mTitle.setAlignment(Qt::AlignCenter);
mHullNumberSelector.setFocus();
mLayout.addWidget(&mTitle);
mLayout.addWidget(&mSelectorsHelpLabel);
mLayout.addWidget(&mHullNumberLabel);
mLayout.addWidget(&mHullNumberSelector);
mLayout.addWidget(&mServerIpLabel);
mLayout.addWidget(&mIpHelpLabel);
mLayout.addWidget(&mServerIpSelector);
mLayout.addWidget(&mConnectButton);
QFont helpFont = mSelectorsHelpLabel.font();
helpFont.setPixelSize(helpFont.pixelSize() - 7);
mSelectorsHelpLabel.setFont(helpFont);
mIpHelpLabel.setFont(helpFont);
mSelectorsHelpLabel.setAlignment(Qt::AlignHCenter);
auto const hostAddressString = brick.mailbox()->serverIp().toString();
if (hostAddressString == QHostAddress().toString()) {
mServerIpSelector.setValue(0);
} else {
auto const parsedAddress = hostAddressString.split('.');
Q_ASSERT(parsedAddress.size() == 4);
auto hostAddress = parsedAddress[2].toInt() * 1000 + parsedAddress[3].toInt();
mServerIpSelector.setValue(hostAddress);
}
setLayout(&mLayout);
connect(&mConnectButton, SIGNAL(clicked()), this, SLOT(onConnectButtonClicked()));
connect(&mConnectButton, SIGNAL(upPressed()), this, SLOT(focusUp()));
connect(&mConnectButton, SIGNAL(downPressed()), this, SLOT(focusDown()));
connect(&mHullNumberSelector, SIGNAL(valueChanged(int)), this, SLOT(onHullNumberChanged(int)));
connect(&mHullNumberSelector, SIGNAL(upPressed()), this, SLOT(focusUp()));
connect(&mHullNumberSelector, SIGNAL(downPressed()), this, SLOT(focusDown()));
connect(&mServerIpSelector, SIGNAL(upPressed()), this, SLOT(focusUp()));
connect(&mServerIpSelector, SIGNAL(downPressed()), this, SLOT(focusDown()));
}
QString CommunicationSettingsWidget::menuEntry()
{
return QString(tr("Comm settings"));
}
void CommunicationSettingsWidget::renewFocus()
{
}
void CommunicationSettingsWidget::keyPressEvent(QKeyEvent *event)
{
switch (event->key()) {
case Qt::Key_Up: {
focusUp();
event->accept();
break;
}
case Qt::Key_Down: {
focusDown();
event->accept();
break;
}
case Qt::Key_Return: {
mConnectButton.animateClick();
event->accept();
break;
}
default: {
TrikGuiDialog::keyPressEvent(event);
}
}
}
void CommunicationSettingsWidget::onConnectButtonClicked()
{
QStringList result = mBrick.mailbox()->myIp().toString().split('.');
if (result.size() != 4) {
/// @todo Properly notify user that the robot is not connected.
return;
}
QString const ipSelectorValue = QString("%1").arg(mServerIpSelector.value(), 6, 10, QChar('0'));
QString const thirdPart = ipSelectorValue.left(3).replace(QRegExp("^0+"), "");
QString const fourthPart = ipSelectorValue.mid(3).replace(QRegExp("^0+"), "");
result[2] = thirdPart;
result[3] = fourthPart;
mBrick.mailbox()->connect(result.join("."));
}
void CommunicationSettingsWidget::onHullNumberChanged(int newHullNumber)
{
mBrick.mailbox()->setHullNumber(newHullNumber);
}
void CommunicationSettingsWidget::focusUp()
{
if (mHullNumberSelector.hasFocusInside()) {
mConnectButton.setFocus();
} else if (mServerIpSelector.hasFocusInside()) {
mHullNumberSelector.setFocus();
} else {
mServerIpSelector.setFocus();
}
}
void CommunicationSettingsWidget::focusDown()
{
if (mHullNumberSelector.hasFocusInside()) {
mServerIpSelector.setFocus();
} else if (mServerIpSelector.hasFocusInside()) {
mConnectButton.setFocus();
} else {
mHullNumberSelector.setFocus();
}
}
| 29.903226 | 97 | 0.736354 | Ashatta |
3bc8fd2fcb17303a91a2b78a0cedcf683c6b408d | 21,693 | cpp | C++ | src/ConEmuHk/ConEmuHooks.cpp | laurent22/ConEmu | 52d4f91692e3ef9ec35d78e29d03e53f035c9e57 | [
"BSD-2-Clause"
] | 2 | 2017-09-17T12:09:16.000Z | 2021-05-15T21:36:47.000Z | src/ConEmuHk/ConEmuHooks.cpp | laurent22/ConEmu | 52d4f91692e3ef9ec35d78e29d03e53f035c9e57 | [
"BSD-2-Clause"
] | null | null | null | src/ConEmuHk/ConEmuHooks.cpp | laurent22/ConEmu | 52d4f91692e3ef9ec35d78e29d03e53f035c9e57 | [
"BSD-2-Clause"
] | null | null | null |
/*
Copyright (c) 2009-2015 Maximus5
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the authors may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''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 AUTHOR 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.
*/
#define HIDE_USE_EXCEPTION_INFO
#define HOOKS_VIRTUAL_ALLOC
#ifdef _DEBUG
#define REPORT_VIRTUAL_ALLOC
#else
#undef REPORT_VIRTUAL_ALLOC
#endif
#ifdef _DEBUG
#define DefTermMsg(s) //MessageBox(NULL, s, L"ConEmuHk", MB_SYSTEMMODAL)
#else
#define DefTermMsg(s) //MessageBox(NULL, s, L"ConEmuHk", MB_SYSTEMMODAL)
#endif
#ifdef _DEBUG
//#define PRE_PEEK_CONSOLE_INPUT
#undef PRE_PEEK_CONSOLE_INPUT
#else
#undef PRE_PEEK_CONSOLE_INPUT
#endif
#define DROP_SETCP_ON_WIN2K3R2
//#define SHOWDEBUGSTR -- специально отключено, CONEMU_MINIMAL, OutputDebugString могут нарушать работу процессов
#undef SHOWCREATEPROCESSTICK
#undef SHOWCREATEBUFFERINFO
#ifdef _DEBUG
#define SHOWCREATEPROCESSTICK
// #define SHOWCREATEBUFFERINFO
#define DUMP_VIM_SETCURSORPOS
#endif
#ifdef _DEBUG
//#define TRAP_ON_MOUSE_0x0
#undef TRAP_ON_MOUSE_0x0
#undef LOG_GETANCESTOR
#else
#undef TRAP_ON_MOUSE_0x0
#undef LOG_GETANCESTOR
#endif
// Иначе не определяется GetConsoleAliases (хотя он должен быть доступен в Win2k)
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0501
// Declare function ID variables
#define DECLARE_CONEMU_HOOK_FUNCTION_ID
#include <windows.h>
#include <WinError.h>
#include <WinNT.h>
#include <TCHAR.h>
#include <Tlhelp32.h>
#include <shlwapi.h>
#include "../common/common.hpp"
#include "../common/ConEmuCheck.h"
#include "SetHook.h"
#include "../common/execute.h"
#include "DefTermHk.h"
#include "ShellProcessor.h"
#include "GuiAttach.h"
#include "Ansi.h"
#include "MainThread.h"
#include "../common/CmdLine.h"
#include "../common/ConsoleAnnotation.h"
#include "../common/ConsoleRead.h"
#include "../common/HkFunc.h"
#include "../common/UnicodeChars.h"
#include "../common/WConsole.h"
#include "../common/WThreads.h"
#include "hkCmdExe.h"
#include "hkConsole.h"
#include "hkConsoleInput.h"
#include "hkConsoleOutput.h"
#include "hkDialog.h"
#include "hkEnvironment.h"
#include "hkFarExe.h"
#include "hkGDI.h"
#include "hkKernel.h"
#include "hkLibrary.h"
#include "hkMessages.h"
#include "hkProcess.h"
#include "hkStdIO.h"
#include "hkWindow.h"
#include "hlpProcess.h"
#ifdef _DEBUG
//#define DEBUG_CON_TITLE
#undef DEBUG_CON_TITLE
#ifdef DEBUG_CON_TITLE
CEStr* gpLastSetConTitle = NULL;
#endif
#else
#undef DEBUG_CON_TITLE
#endif
/* Forward declarations */
BOOL IsVisibleRectLocked(COORD& crLocked);
#undef isPressed
#define isPressed(inp) ((GetKeyState(inp) & 0x8000) == 0x8000)
#ifdef _DEBUG
#define DebugString(x) //OutputDebugString(x)
#else
#define DebugString(x) //OutputDebugString(x)
#endif
/* ************ Globals for SetHook ************ */
extern HWND ghConWnd; // RealConsole
extern HWND ghConEmuWnd; // Root! ConEmu window
extern HWND ghConEmuWndDC; // ConEmu DC window
extern DWORD gnGuiPID;
extern HANDLE ghCurrentOutBuffer;
/* ************ Globals for SetHook ************ */
/* ************ Globals for Far Hooks ************ */
HookModeFar gFarMode = {sizeof(HookModeFar)};
bool gbIsFarProcess = false;
InQueue gInQueue = {};
HANDLE ghConsoleCursorChanged = NULL;
/* ************ Globals for Far Hooks ************ */
/* ************ Globals for cmd.exe/clink ************ */
bool gbIsCmdProcess = false;
static bool IsInteractive();
//size_t gcchLastWriteConsoleMax = 0;
//wchar_t *gpszLastWriteConsole = NULL;
//HMODULE ghClinkDll = NULL;
//call_readline_t gpfnClinkReadLine = NULL;
int gnCmdInitialized = 0; // 0 - Not already, 1 - OK, -1 - Fail
bool gbAllowClinkUsage = false;
bool gbAllowUncPaths = false;
bool gbCurDirChanged = false;
/* ************ Globals for cmd.exe/clink ************ */
/* ************ Globals for powershell ************ */
bool gbIsPowerShellProcess = false;
bool gbPowerShellMonitorProgress = false;
WORD gnConsolePopupColors = 0x003E;
int gnPowerShellProgressValue = -1;
void CheckPowershellProgressPresence();
void CheckPowerShellProgress(HANDLE hConsoleOutput,const CHAR_INFO *lpBuffer,COORD dwBufferSize,COORD dwBufferCoord,PSMALL_RECT lpWriteRegion);
/* ************ Globals for powershell ************ */
/* ************ Globals for Node.JS ************ */
bool gbIsNodeJSProcess = false;
/* ************ Globals for Node.JS ************ */
/* ************ Globals for cygwin/msys ************ */
bool gbIsBashProcess = false;
bool gbIsSshProcess = false;
bool gbIsLessProcess = false;
/* ************ Globals for cygwin/msys ************ */
/* ************ Globals for ViM ************ */
bool gbIsVimProcess = false;
bool gbIsVimAnsi = false;
/* ************ Globals for ViM ************ */
/* ************ Globals for Plink ************ */
bool gbIsPlinkProcess = false;
/* ************ Globals for ViM ************ */
/* ************ Globals for MinTTY ************ */
bool gbIsMinTtyProcess;
/* ************ Globals for ViM ************ */
/* ************ Globals for HIEW32.EXE ************ */
bool gbIsHiewProcess = false;
/* ************ Globals for HIEW32.EXE ************ */
/* ************ Globals for DosBox.EXE ************ */
bool gbDosBoxProcess = false;
/* ************ Globals for DosBox.EXE ************ */
/* ************ Don't show VirtualAlloc errors ************ */
bool gbSkipVirtualAllocErr = false;
/* ************ Don't show VirtualAlloc errors ************ */
/* ************ Hooking time functions ************ */
DWORD gnTimeEnvVarLastCheck = 0;
wchar_t gszTimeEnvVarSave[32] = L"";
/* ************ Hooking time functions ************ */
struct ReadConsoleInfo gReadConsoleInfo = {};
// Service functions
//typedef DWORD (WINAPI* GetProcessId_t)(HANDLE Process);
GetProcessId_t gfGetProcessId = NULL;
void __stdcall SetFarHookMode(struct HookModeFar *apFarMode)
{
if (!apFarMode)
{
gFarMode.bFarHookMode = FALSE;
}
else if (apFarMode->cbSize != sizeof(HookModeFar))
{
_ASSERTE(apFarMode->cbSize == sizeof(HookModeFar));
/*
gFarMode.bFarHookMode = FALSE;
wchar_t szTitle[64], szText[255];
msprintf(szTitle, SKIPLEN(countof(szTitle)) L"ConEmuHk, PID=%u", GetCurrentProcessId());
msprintf(szText, SKIPLEN(countof(szText)) L"SetFarHookMode recieved invalid sizeof = %u\nRequired = %u", apFarMode->cbSize, (DWORD)sizeof(HookModeFar));
Message BoxW(NULL, szText, szTitle, MB_ICONSTOP|MB_SYSTEMMODAL);
*/
}
else
{
// При запуске Ctrl+Shift+W - фар как-то криво инитится... Ctrl+O не работает
#ifdef _DEBUG
char szInfo[100]; msprintf(szInfo, countof(szInfo), "SetFarHookMode. FarHookMode=%u, LongConsoleOutput=%u\n", apFarMode->bFarHookMode, apFarMode->bLongConsoleOutput);
OutputDebugStringA(szInfo);
#endif
memmove(&gFarMode, apFarMode, sizeof(gFarMode));
}
}
bool InitHooksLibrary()
{
#ifdef _DEBUG
extern HookItem *gpHooks;
extern size_t gnHookedFuncs;
// Must be placed on top
_ASSERTE(gpHooks && gnHookedFuncs==0 && gpHooks[0].NewAddress==NULL);
#endif
HLOG1("InitHooksLibrary",0);
bool lbRc = false;
HookItem HooksLib1[] =
{
/* ************************ */
HOOK_ITEM_BY_NAME(LoadLibraryA, kernel32),
HOOK_ITEM_BY_NAME(LoadLibraryExA, kernel32),
HOOK_ITEM_BY_NAME(LoadLibraryExW, kernel32),
HOOK_ITEM_BY_NAME(FreeLibrary, kernel32),
/* ************************ */
{0}
};
HookItem HooksLib2[] =
{
/* ************************ */
HOOK_ITEM_BY_NAME(LoadLibraryW, kernel32),
/* ************************ */
{0}
};
// Need to hook All LoadLibrary### if the work isn't done by LdrRegisterDllNotification
if (gnLdrDllNotificationUsed != ldr_FullSupport)
{
if (InitHooks(HooksLib1) < 0)
goto wrap;
}
// Also LoadLibraryW, it handles "ExtendedConsole.dll" loading in Far 32/64
if (gbIsFarProcess || (gnLdrDllNotificationUsed != ldr_FullSupport))
{
if (InitHooks(HooksLib2) < 0)
goto wrap;
}
lbRc = true;
wrap:
HLOGEND1();
return lbRc;
}
bool InitHooksKernel()
{
HLOG1("InitHooksKernel",0);
bool lbRc = false;
HookItem HooksKernel[] =
{
/* ************************ */
HOOK_ITEM_BY_NAME(OpenFileMappingW, kernel32),
HOOK_ITEM_BY_NAME(MapViewOfFile, kernel32),
HOOK_ITEM_BY_NAME(UnmapViewOfFile, kernel32),
/* ************************ */
HOOK_ITEM_BY_NAME(SetEnvironmentVariableA, kernel32),
HOOK_ITEM_BY_NAME(SetEnvironmentVariableW, kernel32),
HOOK_ITEM_BY_NAME(GetEnvironmentVariableA, kernel32),
HOOK_ITEM_BY_NAME(GetEnvironmentVariableW, kernel32),
#if 0
HOOK_ITEM_BY_NAME(GetEnvironmentStringsA, kernel32),
#endif
HOOK_ITEM_BY_NAME(GetEnvironmentStringsW, kernel32),
/* ************************ */
HOOK_ITEM_BY_NAME(GetSystemTime, kernel32),
HOOK_ITEM_BY_NAME(GetLocalTime, kernel32),
HOOK_ITEM_BY_NAME(GetSystemTimeAsFileTime, kernel32),
/* ************************ */
{0}
};
if (InitHooks(HooksKernel) < 0)
goto wrap;
#if 0
// Проверка, как реагирует на дубли
HooksCommon[1].NewAddress = NULL;
_ASSERTEX(FALSE && "Testing");
InitHooks(HooksCommon);
#endif
lbRc = true;
wrap:
HLOGEND1();
return lbRc;
}
bool InitHooksDebugging()
{
#if !defined(_DEBUG)
return true;
#else
HLOG1("InitHooksDebugging",0);
bool lbRc = false;
HookItem HooksDbg[] =
{
/* ************************ */
HOOK_ITEM_BY_NAME(CreateNamedPipeW, kernel32),
HOOK_ITEM_BY_NAME(VirtualAlloc, kernel32),
#if 0
HOOK_ITEM_BY_NAME(VirtualProtect, kernel32),
#endif
HOOK_ITEM_BY_NAME(SetUnhandledExceptionFilter, kernel32),
/* ************************ */
#ifdef HOOK_ERROR_PROC
HOOK_ITEM_BY_NAME(GetLastError, kernel32),
HOOK_ITEM_BY_NAME(SetLastError, kernel32), // eSetLastError
#endif
/* ************************ */
{0}
};
if (InitHooks(HooksDbg) < 0)
goto wrap;
lbRc = true;
wrap:
HLOGEND1();
return lbRc;
#endif // _DEBUG
}
// Console, ANSI, Read/Write, etc.
bool InitHooksConsole()
{
HLOG1("InitHooksConsole",0);
bool lbRc = false;
HookItem HooksConsole[] =
{
/* ************************ */
HOOK_ITEM_BY_NAME(CreateFileW, kernel32),
HOOK_ITEM_BY_NAME(WriteFile, kernel32),
HOOK_ITEM_BY_NAME(ReadFile, kernel32),
HOOK_ITEM_BY_NAME(CloseHandle, kernel32),
/* ************************ */
HOOK_ITEM_BY_NAME(GetConsoleWindow, kernel32),
HOOK_ITEM_BY_NAME(GetConsoleMode, kernel32),
HOOK_ITEM_BY_NAME(SetConsoleMode, kernel32),
HOOK_ITEM_BY_NAME(SetConsoleTitleA, kernel32),
HOOK_ITEM_BY_NAME(SetConsoleTitleW, kernel32),
HOOK_ITEM_BY_NAME(GetConsoleAliasesW, kernel32),
HOOK_ITEM_BY_NAME(AllocConsole, kernel32),
HOOK_ITEM_BY_NAME(FreeConsole, kernel32),
HOOK_ITEM_BY_NAME(SetConsoleKeyShortcuts, kernel32),
/* ************************ */
HOOK_ITEM_BY_NAME(SetConsoleTextAttribute, kernel32),
HOOK_ITEM_BY_NAME(WriteConsoleOutputW, kernel32),
HOOK_ITEM_BY_NAME(WriteConsoleOutputA, kernel32),
HOOK_ITEM_BY_NAME(ReadConsoleW, kernel32),
HOOK_ITEM_BY_NAME(ReadConsoleA, kernel32),
HOOK_ITEM_BY_NAME(PeekConsoleInputW, kernel32),
HOOK_ITEM_BY_NAME(PeekConsoleInputA, kernel32),
HOOK_ITEM_BY_NAME(ReadConsoleInputW, kernel32),
HOOK_ITEM_BY_NAME(ReadConsoleInputA, kernel32),
HOOK_ITEM_BY_NAME(WriteConsoleInputA, kernel32),
HOOK_ITEM_BY_NAME(WriteConsoleInputW, kernel32),
HOOK_ITEM_BY_NAME(WriteConsoleA, kernel32),
HOOK_ITEM_BY_NAME(WriteConsoleW, kernel32),
HOOK_ITEM_BY_NAME(ScrollConsoleScreenBufferA, kernel32),
HOOK_ITEM_BY_NAME(ScrollConsoleScreenBufferW, kernel32),
HOOK_ITEM_BY_NAME(WriteConsoleOutputCharacterA, kernel32),
HOOK_ITEM_BY_NAME(WriteConsoleOutputCharacterW, kernel32),
/* Others console functions */
HOOK_ITEM_BY_NAME(GetNumberOfConsoleInputEvents, kernel32),
HOOK_ITEM_BY_NAME(FlushConsoleInputBuffer, kernel32),
HOOK_ITEM_BY_NAME(CreateConsoleScreenBuffer, kernel32),
HOOK_ITEM_BY_NAME(SetConsoleActiveScreenBuffer, kernel32),
HOOK_ITEM_BY_NAME(SetConsoleWindowInfo, kernel32),
HOOK_ITEM_BY_NAME(SetConsoleScreenBufferSize, kernel32),
HOOK_ITEM_BY_NAME(SetCurrentConsoleFontEx, kernel32),
HOOK_ITEM_BY_NAME(SetConsoleScreenBufferInfoEx, kernel32),
HOOK_ITEM_BY_NAME(GetLargestConsoleWindowSize, kernel32),
HOOK_ITEM_BY_NAME(SetConsoleCursorPosition, kernel32),
HOOK_ITEM_BY_NAME(SetConsoleCursorInfo, kernel32),
/* ************************ */
HOOK_ITEM_BY_NAME(GetCurrentConsoleFont, kernel32),
HOOK_ITEM_BY_NAME(GetConsoleFontSize, kernel32),
/* ************************ */
// https://conemu.github.io/en/MicrosoftBugs.html#chcp_hung
HOOK_ITEM_BY_NAME(SetConsoleCP, kernel32),
HOOK_ITEM_BY_NAME(SetConsoleOutputCP, kernel32),
/* ************************ */
{0}
};
if (InitHooks(HooksConsole) < 0)
goto wrap;
lbRc = true;
wrap:
HLOGEND1();
return lbRc;
}
bool InitHooksExecutor()
{
HLOG1("InitHooksExecutor",0);
bool lbRc = false;
HookItem HooksCommon[] =
{
/* ************************ */
HOOK_ITEM_BY_LIBR(ExitProcess, kernel32, 0, ghKernel32), // Hook the kernel32.dll, not kernelbase.dll
HOOK_ITEM_BY_NAME(TerminateProcess, kernel32),
/* ************************ */
HOOK_ITEM_BY_NAME(CreateThread, kernel32),
HOOK_ITEM_BY_NAME(SetThreadContext, kernel32),
HOOK_ITEM_BY_NAME(TerminateThread, kernel32),
/* ************************ */
HOOK_ITEM_BY_NAME(CreateProcessA, kernel32),
HOOK_ITEM_BY_NAME(CreateProcessW, kernel32),
/* ************************ */
HOOK_ITEM_BY_NAME(SetCurrentDirectoryA, kernel32),
HOOK_ITEM_BY_NAME(SetCurrentDirectoryW, kernel32),
/* ************************ */
HOOK_ITEM_BY_NAME(ShellExecuteExA, shell32),
HOOK_ITEM_BY_NAME(ShellExecuteExW, shell32),
HOOK_ITEM_BY_NAME(ShellExecuteA, shell32),
HOOK_ITEM_BY_NAME(ShellExecuteW, shell32),
/* ************************ */
// OnWinExec/WinExec is used in DefTerm only
/* ************************ */
{0}
};
if (InitHooks(HooksCommon) < 0)
goto wrap;
lbRc = true;
wrap:
HLOGEND1();
return lbRc;
}
// user32 & gdi32
bool InitHooksUser32()
{
HLOG1("InitHooksUser32",0);
bool lbRc = false;
HookItem HooksUserGdi[] =
{
/* ************************ */
HOOK_ITEM_BY_NAME(TrackPopupMenu, user32),
HOOK_ITEM_BY_NAME(TrackPopupMenuEx, user32),
HOOK_ITEM_BY_NAME(FlashWindow, user32),
HOOK_ITEM_BY_NAME(FlashWindowEx, user32),
HOOK_ITEM_BY_NAME(SetForegroundWindow, user32),
HOOK_ITEM_BY_NAME(GetForegroundWindow, user32),
HOOK_ITEM_BY_NAME(GetWindowRect, user32),
HOOK_ITEM_BY_NAME(ScreenToClient, user32),
/* ************************ */
//HOOK_ITEM_BY_NAME(CreateWindowA, user32), -- there is not such export
//HOOK_ITEM_BY_NAME(CreateWindowW, user32), -- there is not such export
HOOK_ITEM_BY_NAME(CreateWindowExA, user32),
HOOK_ITEM_BY_NAME(CreateWindowExW, user32),
HOOK_ITEM_BY_NAME(ShowCursor, user32),
HOOK_ITEM_BY_NAME(ShowWindow, user32),
HOOK_ITEM_BY_NAME(SetFocus, user32),
HOOK_ITEM_BY_NAME(SetParent, user32),
HOOK_ITEM_BY_NAME(GetParent, user32),
HOOK_ITEM_BY_NAME(GetWindow, user32),
HOOK_ITEM_BY_NAME(GetAncestor, user32),
HOOK_ITEM_BY_NAME(GetClassNameA, user32),
HOOK_ITEM_BY_NAME(GetClassNameW, user32),
HOOK_ITEM_BY_NAME(GetActiveWindow, user32),
HOOK_ITEM_BY_NAME(MoveWindow, user32),
HOOK_ITEM_BY_NAME(SetWindowPos, user32),
HOOK_ITEM_BY_NAME(SetWindowLongA, user32),
HOOK_ITEM_BY_NAME(SetWindowLongW, user32),
#ifdef WIN64
HOOK_ITEM_BY_NAME(SetWindowLongPtrA, user32),
HOOK_ITEM_BY_NAME(SetWindowLongPtrW, user32),
#endif
HOOK_ITEM_BY_NAME(GetWindowTextLengthA, user32),
HOOK_ITEM_BY_NAME(GetWindowTextLengthW, user32),
HOOK_ITEM_BY_NAME(GetWindowTextA, user32),
HOOK_ITEM_BY_NAME(GetWindowTextW, user32),
//
HOOK_ITEM_BY_NAME(GetWindowPlacement, user32),
HOOK_ITEM_BY_NAME(SetWindowPlacement, user32),
HOOK_ITEM_BY_NAME(mouse_event, user32),
HOOK_ITEM_BY_NAME(SendInput, user32),
HOOK_ITEM_BY_NAME(PostMessageA, user32),
HOOK_ITEM_BY_NAME(PostMessageW, user32),
HOOK_ITEM_BY_NAME(SendMessageA, user32),
HOOK_ITEM_BY_NAME(SendMessageW, user32),
HOOK_ITEM_BY_NAME(GetMessageA, user32),
HOOK_ITEM_BY_NAME(GetMessageW, user32),
HOOK_ITEM_BY_NAME(PeekMessageA, user32),
HOOK_ITEM_BY_NAME(PeekMessageW, user32),
HOOK_ITEM_BY_NAME(CreateDialogParamA, user32),
HOOK_ITEM_BY_NAME(CreateDialogParamW, user32),
HOOK_ITEM_BY_NAME(CreateDialogIndirectParamA, user32),
HOOK_ITEM_BY_NAME(CreateDialogIndirectParamW, user32),
HOOK_ITEM_BY_NAME(DialogBoxIndirectParamAorW, user32),
HOOK_ITEM_BY_NAME(SetMenu, user32),
HOOK_ITEM_BY_NAME(GetDC, user32),
HOOK_ITEM_BY_NAME(GetDCEx, user32),
HOOK_ITEM_BY_NAME(ReleaseDC, user32),
/* ************************ */
/* ************************ */
HOOK_ITEM_BY_NAME(StretchDIBits, gdi32),
HOOK_ITEM_BY_NAME(BitBlt, gdi32),
HOOK_ITEM_BY_NAME(StretchBlt, gdi32),
/* ************************ */
{0}
};
if (InitHooks(HooksUserGdi) < 0)
goto wrap;
lbRc = true;
wrap:
HLOGEND1();
return lbRc;
}
bool InitHooksFarExe()
{
HLOG1("InitHooksFarExe",0);
bool lbRc = false;
// Проверить, фар ли это? Если нет - можно не ставить HooksFarOnly
bool lbIsFar = false;
wchar_t* pszExe = (wchar_t*)calloc(MAX_PATH+1,sizeof(wchar_t));
if (pszExe)
{
if (GetModuleFileName(NULL, pszExe, MAX_PATH))
{
if (IsFarExe(pszExe))
lbIsFar = true;
}
free(pszExe);
}
HookItem HooksFarOnly[] =
{
/* ************************ */
HOOK_ITEM_BY_NAME(CompareStringW, kernel32),
/* ************************ */
{0}
};
if (lbIsFar)
{
if (InitHooks(HooksFarOnly) < 0)
goto wrap;
}
lbRc = true;
wrap:
HLOGEND1();
return lbRc;
}
bool InitHooksCmdExe()
{
if (!gbIsCmdProcess)
return true;
HLOG1("InitHooksCmdExe",0);
bool lbRc = false;
HookItem HooksCmdOnly[] =
{
// Vista and below: AdvApi32.dll
// **NB** In WinXP this module is not linked statically
HOOK_ITEM_BY_NAME(RegQueryValueExW, IsWin7() ? kernel32 : advapi32),
{0, 0, 0}
};
if (InitHooks(HooksCmdOnly) < 0)
goto wrap;
lbRc = true;
wrap:
HLOGEND1();
return lbRc;
}
/* ************************ */
/* Default Terminal support */
/* ************************ */
bool InitHooksDefTerm()
{
HLOG1("InitHooksDefTerm",0);
bool lbRc = false;
// These functions are required for seizing console and behave as Default Terminal
HookItem HooksCommon[] =
{
HOOK_ITEM_BY_NAME(CreateProcessW, kernel32),
// Need to "hook" OnCreateProcessA because it is used in "OnWinExec"
HOOK_ITEM_BY_NAME(CreateProcessA, kernel32),
// Used in some programs, Issue 853
HOOK_ITEM_BY_NAME(WinExec, kernel32),
// Need for hook "Run as administrator"
HOOK_ITEM_BY_NAME(ShellExecuteExW, shell32),
{0}
};
HookItem HooksCmdLine[] =
{
// Issue 1125: "Run as administrator" too. Must be last export
HOOK_ITEM_BY_ORDN(ShellExecCmdLine, shell32, 265),
{0}
};
HookItem HooksVshost[] =
{
// Issue 1312: .Net applications runs in "*.vshost.exe" helper GUI apllication when debugging
HOOK_ITEM_BY_NAME(AllocConsole, kernel32), // Only for "*.vshost.exe"?
HOOK_ITEM_BY_NAME(ShowWindow, user32),
/* ************************ */
{0}
};
// Required in VisualStudio and CodeBlocks (gdb) debuggers
// Don't restrict to them, other Dev Envs may behave in similar way
HookItem HooksDevStudio[] =
{
HOOK_ITEM_BY_NAME(ResumeThread, kernel32),
/* ************************ */
{0}
};
// Required for hooking in OS
// bool check
if (!InitHooksLibrary())
goto wrap;
// Start our functions
if (InitHooks(HooksCommon) < 0)
goto wrap;
// Windows 7. There is new undocumented function "ShellExecCmdLine" used by Explorer
if (IsWin7())
{
if (InitHooks(HooksCmdLine) < 0)
goto wrap;
}
// "*.vshost.exe" uses special helper
if (gbIsNetVsHost)
{
if (InitHooks(HooksVshost) < 0)
goto wrap;
}
// Required in VisualStudio and CodeBlocks (gdb) debuggers
// Don't restrict to them, other Dev Envs may behave in similar way
{
if (InitHooks(HooksDevStudio) < 0)
goto wrap;
}
lbRc = true;
wrap:
HLOGEND1();
return lbRc;
}
/* ******************* */
/* Console or ChildGui */
/* ******************* */
bool InitHooksCommon()
{
if (!InitHooksLibrary())
return false;
if (!InitHooksKernel())
return false;
if (!InitHooksExecutor())
return false;
if (!InitHooksDebugging())
return false;
if (!InitHooksConsole())
return false;
if (!InitHooksUser32())
return false;
if (!InitHooksFarExe())
return false;
if (!InitHooksCmdExe())
return false;
return true;
}
| 27.424779 | 168 | 0.688148 | laurent22 |
3bca06fcf5cf6419e432aa0018eea2606cf89fdf | 4,556 | cc | C++ | cpp/core_v2/internal/mediums/ble_advertisement_header.cc | jdapena/nearby-connections | ae277748ce068ef1730d5104002d4324fc4ed89e | [
"Apache-2.0"
] | null | null | null | cpp/core_v2/internal/mediums/ble_advertisement_header.cc | jdapena/nearby-connections | ae277748ce068ef1730d5104002d4324fc4ed89e | [
"Apache-2.0"
] | null | null | null | cpp/core_v2/internal/mediums/ble_advertisement_header.cc | jdapena/nearby-connections | ae277748ce068ef1730d5104002d4324fc4ed89e | [
"Apache-2.0"
] | null | null | null | // Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://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 "core_v2/internal/mediums/ble_advertisement_header.h"
#include <inttypes.h>
#include "platform_v2/base/base64_utils.h"
#include "platform_v2/base/base_input_stream.h"
#include "platform_v2/public/logging.h"
#include "absl/strings/str_cat.h"
namespace location {
namespace nearby {
namespace connections {
namespace mediums {
BleAdvertisementHeader::BleAdvertisementHeader(
Version version, int num_slots, const ByteArray &service_id_bloom_filter,
const ByteArray &advertisement_hash) {
if (version != Version::kV2 || num_slots <= 0 ||
service_id_bloom_filter.size() != kServiceIdBloomFilterLength ||
advertisement_hash.size() != kAdvertisementHashLength) {
return;
}
version_ = version;
num_slots_ = num_slots;
service_id_bloom_filter_ = service_id_bloom_filter;
advertisement_hash_ = advertisement_hash;
}
BleAdvertisementHeader::BleAdvertisementHeader(
const std::string &ble_advertisement_header_string) {
ByteArray ble_advertisement_header_bytes =
Base64Utils::Decode(ble_advertisement_header_string);
if (ble_advertisement_header_bytes.Empty()) {
NEARBY_LOG(
ERROR,
"Cannot deserialize BLEAdvertisementHeader: failed Base64 decoding");
return;
}
if (ble_advertisement_header_bytes.size() < kMinAdvertisementHeaderLength) {
NEARBY_LOG(ERROR,
"Cannot deserialize BleAdvertisementHeader: expecting min %u "
"raw bytes, got %" PRIu64 " instead",
kMinAdvertisementHeaderLength,
ble_advertisement_header_bytes.size());
return;
}
BaseInputStream base_input_stream{ble_advertisement_header_bytes};
// The first 1 byte is supposed to be the version and number of slots.
auto version_and_pcp_byte = static_cast<char>(base_input_stream.ReadUint8());
// The upper 3 bits are supposed to be the version.
version_ =
static_cast<Version>((version_and_pcp_byte & kVersionBitmask) >> 5);
if (version_ != Version::kV2) {
NEARBY_LOG(
ERROR,
"Cannot deserialize BleAdvertisementHeader: unsupported Version %d",
version_);
return;
}
// The lower 5 bits are supposed to be the number of slots.
num_slots_ = static_cast<int>(version_and_pcp_byte & kNumSlotsBitmask);
if (num_slots_ <= 0) {
version_ = Version::kUndefined;
return;
}
// The next 10 bytes are supposed to be the service_id_bloom_filter.
service_id_bloom_filter_ =
base_input_stream.ReadBytes(kServiceIdBloomFilterLength);
// The next 4 bytes are supposed to be the advertisement_hash.
advertisement_hash_ = base_input_stream.ReadBytes(kAdvertisementHashLength);
}
BleAdvertisementHeader::operator std::string() const {
if (!IsValid()) {
return "";
}
// The first 3 bits are the Version.
char version_and_num_slots_byte =
(static_cast<char>(version_) << 5) & kVersionBitmask;
// The next 5 bits are the number of slots.
version_and_num_slots_byte |=
static_cast<char>(num_slots_) & kNumSlotsBitmask;
// clang-format off
std::string out = absl::StrCat(std::string(1, version_and_num_slots_byte),
std::string(service_id_bloom_filter_),
std::string(advertisement_hash_));
// clang-format on
return Base64Utils::Encode(ByteArray(std::move(out)));
}
bool BleAdvertisementHeader::operator<(
const BleAdvertisementHeader &rhs) const {
if (this->GetVersion() != rhs.GetVersion()) {
return this->GetVersion() < rhs.GetVersion();
}
if (this->GetNumSlots() != rhs.GetNumSlots()) {
return this->GetNumSlots() < rhs.GetNumSlots();
}
if (this->GetServiceIdBloomFilter() != rhs.GetServiceIdBloomFilter()) {
return this->GetServiceIdBloomFilter() < rhs.GetServiceIdBloomFilter();
}
return this->GetAdvertisementHash() < rhs.GetAdvertisementHash();
}
} // namespace mediums
} // namespace connections
} // namespace nearby
} // namespace location
| 34.515152 | 79 | 0.719271 | jdapena |
3bcc4adc2efc1263228ba2988b6d48d1e7455e17 | 2,698 | cpp | C++ | Test/GacUISrc/Host/Main.cpp | vczh2/GacUI | ce100ec13357bbf03ed3d2040c48d6b2b2fefd2f | [
"RSA-MD"
] | 2 | 2018-10-17T16:00:01.000Z | 2018-11-20T07:53:20.000Z | Test/GacUISrc/Host/Main.cpp | vczh2/GacUI | ce100ec13357bbf03ed3d2040c48d6b2b2fefd2f | [
"RSA-MD"
] | null | null | null | Test/GacUISrc/Host/Main.cpp | vczh2/GacUI | ce100ec13357bbf03ed3d2040c48d6b2b2fefd2f | [
"RSA-MD"
] | null | null | null | #pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#include "ResourceCompiler.h"
#include <Windows.h>
using namespace vl;
using namespace vl::collections;
using namespace vl::stream;
using namespace vl::reflection::description;
//#define GUI_GRAPHICS_RENDERER_GDI
#define GUI_GRAPHICS_RENDERER_DIRECT2D
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int CmdShow)
{
#ifdef GUI_GRAPHICS_RENDERER_GDI
int result=SetupWindowsGDIRenderer();
#endif
#ifdef GUI_GRAPHICS_RENDERER_DIRECT2D
int result = SetupWindowsDirect2DRenderer();
#endif
#if VCZH_CHECK_MEMORY_LEAKS
_CrtDumpMemoryLeaks();
#endif
return result;
}
extern void UnitTestInGuiMain();
namespace autocomplete_grammar
{
extern void InstallTextBox(GuiMultilineTextBox* textBox);
}
void GuiMain_GrammarIntellisense()
{
GuiWindow window(theme::ThemeName::Window);
window.GetContainerComposition()->SetPreferredMinSize(Size(600, 480));
{
auto textBox = new GuiMultilineTextBox(theme::ThemeName::MultilineTextBox);
autocomplete_grammar::InstallTextBox(textBox);
textBox->GetBoundsComposition()->SetAlignmentToParent(Margin(5, 5, 5, 5));
window.AddChild(textBox);
}
window.ForceCalculateSizeImmediately();
window.MoveToScreenCenter();
GetApplication()->Run(&window);
}
#ifndef VCZH_DEBUG_NO_REFLECTION
void OpenMainWindow()
{
{
auto theme = UnboxValue<Ptr<ThemeTemplates>>(Value::Create(L"darkskin::Theme"));
RegisterTheme(theme);
}
{
auto window = UnboxValue<GuiWindow*>(Value::Create(L"demo::MainWindow"));
window->ForceCalculateSizeImmediately();
window->MoveToScreenCenter();
GetApplication()->Run(window);
delete window;
}
}
#endif
void GuiMain()
{
UnitTestInGuiMain();
#ifndef VCZH_DEBUG_NO_REFLECTION
{
FileStream fileStream(L"Reflection.txt", FileStream::WriteOnly);
BomEncoder encoder(BomEncoder::Utf16);
EncoderStream encoderStream(fileStream, encoder);
StreamWriter writer(encoderStream);
LogTypeManager(writer);
}
#define BINARY_FOLDER L"../TestCppCodegen/"
#define SOURCE_FOLDER L"../TestCppCodegen/Source/"
List<WString> dependencies;
//LoadResource(CompileResources(L"DarkSkin", dependencies, LR"(Resources/DarkSkin/Resource.xml)", BINARY_FOLDER, SOURCE_FOLDER, true));
LoadResource(L"../TestCppCodegen/DarkSkin.UI.bin");
//LoadResource(CompileResources(L"Demo", dependencies, LR"(Resources/FullControlTest/Resource.xml)", BINARY_FOLDER, SOURCE_FOLDER, false));
LoadResource(L"../TestCppCodegen/Demo.UI.bin");
#undef BINARY_FOLDER
#undef SOURCE_FOLDER
OpenMainWindow();
#endif
} | 28.104167 | 194 | 0.780949 | vczh2 |
3bcc6b1d91e70743d472aec3c1b17757bbc6ec7d | 513 | cpp | C++ | src/1000/1766.cpp14.cpp | upple/BOJ | e6dbf9fd17fa2b458c6a781d803123b14c18e6f1 | [
"MIT"
] | 8 | 2018-04-12T15:54:09.000Z | 2020-06-05T07:41:15.000Z | src/1000/1766.cpp14.cpp | upple/BOJ | e6dbf9fd17fa2b458c6a781d803123b14c18e6f1 | [
"MIT"
] | null | null | null | src/1000/1766.cpp14.cpp | upple/BOJ | e6dbf9fd17fa2b458c6a781d803123b14c18e6f1 | [
"MIT"
] | null | null | null | #include <iostream>
#include <vector>
#include <queue>
using namespace std;
vector<int> adj[32001];
int in[32001];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
while (m--)
{
int a, b;
cin >> a >> b;
adj[a].push_back(b);
in[b]++;
}
priority_queue<int> pq;
for (int i = 1; i <= n; i++)
if (!in[i]) pq.push(-i);
while (pq.size())
{
int cur = -pq.top();
cout << cur << " ";
pq.pop();
for (int i : adj[cur])
{
if (!--in[i]) pq.push(-i);
}
}
} | 13.864865 | 30 | 0.518519 | upple |
3bd3f042753983a4a7e0c1e84bc860dd9a4250e5 | 1,775 | hpp | C++ | soccer/vision/ball/WorldBall.hpp | kasohrab/robocup-software | 73c92878baf960844b5a4b34c72804093f1ea459 | [
"Apache-2.0"
] | null | null | null | soccer/vision/ball/WorldBall.hpp | kasohrab/robocup-software | 73c92878baf960844b5a4b34c72804093f1ea459 | [
"Apache-2.0"
] | null | null | null | soccer/vision/ball/WorldBall.hpp | kasohrab/robocup-software | 73c92878baf960844b5a4b34c72804093f1ea459 | [
"Apache-2.0"
] | null | null | null | #pragma once
#include <list>
#include <Geometry2d/Point.hpp>
#include <Configuration.hpp>
#include <Utils.hpp>
#include "KalmanBall.hpp"
class KalmanBall;
/**
* Best estimate of the true ball position using the kalman balls from each camera
*/
class WorldBall {
public:
/**
* Creates an invalid world ball
* Used to make some of the code cleaner
*/
WorldBall();
/**
* Creates a valid world ball from a list of kalman balls through special averaging
*
* @param calcTime Current iteration time
* @param kalmanBalls List of best kalman ball from every camera
*/
WorldBall(RJ::Time calcTime, const std::list<KalmanBall>& kalmanBalls);
/**
* @return If the ball actually represents a real ball
*/
bool getIsValid() const;
/**
* @return The best estimated position of the ball
*/
Geometry2d::Point getPos() const;
/**
* @return The best estimated velocity of the ball
*/
Geometry2d::Point getVel() const;
/**
* @return The average position covariance of the filter
*/
double getPosCov() const;
/**
* @return The average velocity covariance of the filter
*/
double getVelCov() const;
/**
* @return List of all the building kalman balls for this world ball
*/
const std::list<KalmanBall>& getBallComponents() const;
/**
* @return Time of creation for this world ball
*/
RJ::Time getTime() const;
static void createConfiguration(Configuration* cfg);
private:
bool isValid;
Geometry2d::Point pos;
Geometry2d::Point vel;
double posCov{};
double velCov{};
std::list<KalmanBall> ballComponents;
RJ::Time time;
static ConfigDouble* ball_merger_power;
}; | 22.468354 | 87 | 0.646197 | kasohrab |
3bdaf9930bd44b4a075a7de7d1cd7fe437a8b538 | 10,080 | hpp | C++ | include/carve/geom3d.hpp | pcamarillor/Exploratory3D | 10705d201376b98bdf8f19fca398a3bf341807c9 | [
"MIT"
] | null | null | null | include/carve/geom3d.hpp | pcamarillor/Exploratory3D | 10705d201376b98bdf8f19fca398a3bf341807c9 | [
"MIT"
] | null | null | null | include/carve/geom3d.hpp | pcamarillor/Exploratory3D | 10705d201376b98bdf8f19fca398a3bf341807c9 | [
"MIT"
] | null | null | null | // Begin License:
// Copyright (C) 2006-2008 Tobias Sargeant ([email protected]).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of the GNU General Public
// License version 2.0 as published by the Free Software Foundation
// and appearing in the file LICENSE.GPL2 included in the packaging of
// this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/geom.hpp>
#include <math.h>
#include <carve/math_constants.hpp>
#include <vector>
#include <list>
#include <map>
#if defined(CARVE_DEBUG)
# include <iostream>
#endif
namespace carve {
namespace geom3d {
typedef carve::geom::plane<3> Plane;
typedef carve::geom::ray<3> Ray;
typedef carve::geom::linesegment<3> LineSegment;
typedef carve::geom::vector<3> Vector;
template<typename iter_t, typename adapt_t>
bool fitPlane(iter_t begin, iter_t end, adapt_t adapt, Plane &plane) {
Vector centroid;
carve::geom::centroid(begin, end, adapt, centroid);
iter_t i;
Vector n = Vector::ZERO();
Vector v, z;
Vector p1, p2, p3, c1, c2;
if (begin == end) return false;
i = begin;
p1 = c1 = adapt(*i++); if (i == end) return false;
p2 = c2 = adapt(*i++); if (i == end) return false;
#if defined(CARVE_DEBUG)
size_t N = 2;
#endif
while (i != end) {
p3 = adapt(*i++);
v = cross(p3 - p2, p1 - p2);
if (v.v[largestAxis(v)]) v.negate();
n += v;
p1 = p2; p2 = p3;
#if defined(CARVE_DEBUG)
++N;
#endif
}
p1 = p2; p2 = p3; p3 = c1;
v = cross(p3 - p2, p1 - p2);
if (v.v[largestAxis(v)]) v.negate();
n += v;
p1 = p2; p2 = p3; p3 = c2;
v = cross(p3 - p2, p1 - p2);
if (v.v[largestAxis(v)]) v.negate();
n += v;
n.normalize();
plane.N = n;
plane.d = -dot(n, centroid);
#if defined(CARVE_DEBUG)
if (N > 3) {
std::cerr << "N = " << N << " fitted distance:";
for (i = begin; i != end; ++i) {
Vector p = adapt(*i);
std::cerr << " {" << p << "} " << distance(plane, p);
}
std::cerr << std::endl;
}
#endif
return true;
}
bool planeIntersection(const Plane &a, const Plane &b, Ray &r);
IntersectionClass rayPlaneIntersection(const Plane &p,
const Vector &v1,
const Vector &v2,
Vector &v,
double &t);
IntersectionClass lineSegmentPlaneIntersection(const Plane &p,
const LineSegment &line,
Vector &v);
RayIntersectionClass rayRayIntersection(const Ray &r1,
const Ray &r2,
Vector &v1,
Vector &v2,
double &mu1,
double &mu2);
// test whether point d is above, below or on the plane formed by the triangle a,b,c.
// return: +ve = d is below a,b,c
// -ve = d is above a,b,c
// 0 = d is on a,b,c
static inline double orient3d(const carve::geom3d::Vector &a,
const carve::geom3d::Vector &b,
const carve::geom3d::Vector &c,
const carve::geom3d::Vector &d) {
return dotcross((a - d), (b - d), (c - d));
}
// Volume of a tetrahedron described by 4 points. Will be
// positive if the anticlockwise normal of a,b,c is oriented out
// of the tetrahedron.
//
// see: http://mathworld.wolfram.com/Tetrahedron.html
inline double tetrahedronVolume(const Vector &a,
const Vector &b,
const Vector &c,
const Vector &d) {
return dotcross((a - d), (b - d), (c - d)) / 6.0;
}
/**
* \brief Determine whether p is internal to the wedge defined by
* the area between the planes defined by a,b,c and a,b,d
* angle abc, where ab is the apex of the angle.
*
* @param[in] a
* @param[in] b
* @param[in] c
* @param[in] d
* @param[in] p
*
* @return true, if p is contained in the wedge defined by the
* area between the planes defined by a,b,c and
* a,b,d. If the wedge is reflex, p is considered to
* be contained if it lies on either plane. Acute
* wdges do not contain p if p lies on either
* plane. This is so that internalToWedge(a,b,c,d,p) =
* !internalToWedge(a,b,d,c,p)
*/
inline bool internalToWedge(const Vector &a,
const Vector &b,
const Vector &c,
const Vector &d,
const Vector &p) {
bool reflex = (c < d) ?
orient3d(a, b, c, d) >= 0.0 :
orient3d(a, b, d, c) < 0.0;
double d1 = orient3d(a, b, c, p);
double d2 = orient3d(a, b, d, p);
if (reflex) {
// above a,b,c or below a,b,d (or coplanar with either)
return d1 <= 0.0 || d2 >= 0.0;
} else {
// above a,b,c and below a,b,d
return d1 < 0.0 && d2 > 0.0;
}
}
/**
* \brief Determine the ordering relationship of a and b, when
* rotating around direction, starting from base.
*
* @param[in] adirection
* @param[in] base
* @param[in] a
* @param[in] b
*
* @return
* * -1, if a is ordered before b around, rotating about direction.
* * 0, if a and b are equal in angle.
* * +1, if a is ordered after b around, rotating about direction.
*/
inline int compareAngles(const Vector &direction, const Vector &base, const Vector &a, const Vector &b) {
double d1 = carve::geom3d::orient3d(carve::geom::VECTOR(0,0,0), direction, a, b);
double d2 = carve::geom3d::orient3d(carve::geom::VECTOR(0,0,0), direction, base, a);
double d3 = carve::geom3d::orient3d(carve::geom::VECTOR(0,0,0), direction, base, b);
// CASE: a and b are coplanar wrt. direction.
if (d1 == 0.0) {
// a and b point in the same direction.
if (dot(a, b) > 0.0) {
// Neither is less than the other.
return 0;
}
// a and b point in opposite directions.
double d2 = carve::geom3d::orient3d(carve::geom::VECTOR(0,0,0), direction, base, a);
// * if d2 < 0.0, a is above plane(direction, base) and is less
// than b.
// * if d2 == 0.0 a is coplanar with plane(direction, base) and is
// less than b if it points in the same direction as base.
// * if d2 > 0.0, a is below plane(direction, base) and is greater
// than b.
if (d2 == 0.0) { return dot(a, base) > 0.0 ? -1 : +1; }
if (d3 == 0.0) { return dot(b, base) > 0.0 ? +1 : -1; }
if (d2 < 0.0 && d3 > 0.0) return -1;
if (d2 > 0.0 && d3 < 0.0) return +1;
// both a and b are to one side of plane(direction, base) -
// rounding error (if a and b are truly coplanar with
// direction, one should be above, and one should be below any
// other plane that is not itself coplanar with
// plane(direction, a|b) - which would imply d2 and d3 == 0.0).
// If both are below plane(direction, base) then the one that
// points in the same direction as base is greater.
// If both are above plane(direction, base) then the one that
// points in the same direction as base is lesser.
if (d2 > 0.0) { return dot(a, base) > 0.0 ? +1 : -1; }
else { return dot(a, base) > 0.0 ? -1 : +1; }
}
// CASE: a and b are not coplanar wrt. direction
if (d2 < 0.0) {
// if a is above plane(direction,base), then a is less than b if
// b is below plane(direction,base) or b is above plane(direction,a)
return (d3 > 0.0 || d1 < 0.0) ? -1 : +1;
} else if (d2 == 0.0) {
// if a is on plane(direction,base) then a is less than b if a
// points in the same direction as base, or b is below
// plane(direction,base)
return (dot(a, base) > 0.0 || d3 > 0.0) ? -1 : +1;
} else {
// if a is below plane(direction,base), then a is less than b if b
// is below plane(direction,base) and b is above plane(direction,a)
return (d3 > 0.0 && d1 < 0.0) ? -1 : +1;
}
}
// The anticlockwise angle from vector "from" to vector "to", oriented around the vector "orient".
static inline double antiClockwiseAngle(const Vector &from, const Vector &to, const Vector &orient) {
double dp = dot(from, to);
Vector cp = cross(from, to);
if (cp.isZero()) {
if (dp < 0) {
return M_PI;
} else {
return 0.0;
}
} else {
if (dot(cp, orient) > 0.0) {
return acos(dp);
} else {
return M_TWOPI - acos(dp);
}
}
}
static inline double antiClockwiseOrdering(const Vector &from, const Vector &to, const Vector &orient) {
double dp = dot(from, to);
Vector cp = cross(from, to);
if (cp.isZero()) {
if (dp < 0) {
return 2.0;
} else {
return 0.0;
}
} else {
if (dot(cp, orient) > 0.0) {
// 1..-1 -> 0..2
return 1.0 - dp;
} else {
// -1..1 -> 2..4
return dp + 1.0;
}
}
}
}
}
| 33.488372 | 109 | 0.511012 | pcamarillor |
3bde235f8494aed1d59fd97c3f6a0f09f7083cf8 | 5,250 | cpp | C++ | fpdfsdk/pwl/cpwl_special_button_embeddertest.cpp | yanxijian/pdfium | aba53245bf116a1d908f851a93236b500988a1ee | [
"Apache-2.0"
] | null | null | null | fpdfsdk/pwl/cpwl_special_button_embeddertest.cpp | yanxijian/pdfium | aba53245bf116a1d908f851a93236b500988a1ee | [
"Apache-2.0"
] | null | null | null | fpdfsdk/pwl/cpwl_special_button_embeddertest.cpp | yanxijian/pdfium | aba53245bf116a1d908f851a93236b500988a1ee | [
"Apache-2.0"
] | null | null | null | // Copyright 2020 PDFium 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 "fpdfsdk/cpdfsdk_annot.h"
#include "fpdfsdk/cpdfsdk_annotiterator.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_helpers.h"
#include "fpdfsdk/formfiller/cffl_formfield.h"
#include "fpdfsdk/pwl/cpwl_special_button.h"
#include "fpdfsdk/pwl/cpwl_wnd.h"
#include "testing/embedder_test.h"
class CPWLSpecialButtonEmbedderTest : public EmbedderTest {
protected:
void SetUp() override {
EmbedderTest::SetUp();
CreateAndInitializeFormPDF();
}
void TearDown() override {
UnloadPage(page_);
EmbedderTest::TearDown();
}
void CreateAndInitializeFormPDF() {
ASSERT_TRUE(OpenDocument("click_form.pdf"));
page_ = LoadPage(0);
ASSERT_TRUE(page_);
formfill_env_ = CPDFSDKFormFillEnvironmentFromFPDFFormHandle(form_handle());
CPDFSDK_AnnotIterator it(formfill_env_->GetPageViewAtIndex(0),
{CPDF_Annot::Subtype::WIDGET});
// Read only check box.
annot_readonly_checkbox_ = it.GetFirstAnnot();
ASSERT_TRUE(annot_readonly_checkbox_);
ASSERT_EQ(CPDF_Annot::Subtype::WIDGET,
annot_readonly_checkbox_->GetAnnotSubtype());
// Check box.
annot_checkbox_ = it.GetNextAnnot(annot_readonly_checkbox_);
ASSERT_TRUE(annot_checkbox_);
ASSERT_EQ(CPDF_Annot::Subtype::WIDGET, annot_checkbox_->GetAnnotSubtype());
// Read only radio button.
annot_readonly_radiobutton_ = it.GetNextAnnot(annot_checkbox_);
ASSERT_TRUE(annot_readonly_radiobutton_);
ASSERT_EQ(CPDF_Annot::Subtype::WIDGET,
annot_readonly_radiobutton_->GetAnnotSubtype());
// Tabbing three times from read only radio button to unselected normal
// radio button.
annot_radiobutton_ = annot_readonly_radiobutton_;
ASSERT_TRUE(annot_radiobutton_);
for (int i = 0; i < 3; i++) {
annot_radiobutton_ = it.GetNextAnnot(annot_radiobutton_);
ASSERT_TRUE(annot_radiobutton_);
}
ASSERT_EQ(CPDF_Annot::Subtype::WIDGET,
annot_radiobutton_->GetAnnotSubtype());
}
void FormFillerAndWindowSetup(CPDFSDK_Annot* annot) {
CFFL_InteractiveFormFiller* interactive_formfiller =
formfill_env_->GetInteractiveFormFiller();
{
ObservedPtr<CPDFSDK_Annot> observed(annot);
EXPECT_TRUE(interactive_formfiller->OnSetFocus(&observed, {}));
}
form_filler_ = interactive_formfiller->GetFormFieldForTesting(annot);
ASSERT_TRUE(form_filler_);
window_ = form_filler_->CreateOrUpdatePWLWindow(
formfill_env_->GetPageViewAtIndex(0));
ASSERT_TRUE(window_);
}
CPDFSDK_Annot* GetCPDFSDKAnnotCheckBox() const { return annot_checkbox_; }
CPDFSDK_Annot* GetCPDFSDKAnnotReadOnlyCheckBox() const {
return annot_readonly_checkbox_;
}
CPDFSDK_Annot* GetCPDFSDKAnnotRadioButton() const {
return annot_radiobutton_;
}
CPDFSDK_Annot* GetCPDFSDKAnnotReadOnlyRadioButton() const {
return annot_readonly_radiobutton_;
}
CPDFSDK_FormFillEnvironment* GetCPDFSDKFormFillEnv() const {
return formfill_env_;
}
CPWL_Wnd* GetWindow() const { return window_; }
private:
FPDF_PAGE page_;
CFFL_FormField* form_filler_;
CPDFSDK_Annot* annot_checkbox_;
CPDFSDK_Annot* annot_readonly_checkbox_;
CPDFSDK_Annot* annot_radiobutton_;
CPDFSDK_Annot* annot_readonly_radiobutton_;
CPDFSDK_FormFillEnvironment* formfill_env_;
CPWL_Wnd* window_;
};
TEST_F(CPWLSpecialButtonEmbedderTest, EnterOnReadOnlyCheckBox) {
FormFillerAndWindowSetup(GetCPDFSDKAnnotReadOnlyCheckBox());
CPWL_CheckBox* check_box = static_cast<CPWL_CheckBox*>(GetWindow());
EXPECT_TRUE(check_box->IsChecked());
EXPECT_TRUE(GetCPDFSDKFormFillEnv()->GetInteractiveFormFiller()->OnChar(
GetCPDFSDKAnnotReadOnlyCheckBox(), '\r', {}));
EXPECT_TRUE(check_box->IsChecked());
}
TEST_F(CPWLSpecialButtonEmbedderTest, EnterOnCheckBox) {
FormFillerAndWindowSetup(GetCPDFSDKAnnotCheckBox());
CPWL_CheckBox* check_box = static_cast<CPWL_CheckBox*>(GetWindow());
EXPECT_TRUE(GetCPDFSDKFormFillEnv()->GetInteractiveFormFiller()->OnChar(
GetCPDFSDKAnnotCheckBox(), '\r', {}));
EXPECT_TRUE(check_box->IsChecked());
EXPECT_TRUE(GetCPDFSDKFormFillEnv()->GetInteractiveFormFiller()->OnChar(
GetCPDFSDKAnnotCheckBox(), '\r', {}));
EXPECT_FALSE(check_box->IsChecked());
}
TEST_F(CPWLSpecialButtonEmbedderTest, EnterOnReadOnlyRadioButton) {
FormFillerAndWindowSetup(GetCPDFSDKAnnotReadOnlyRadioButton());
CPWL_RadioButton* radio_button = static_cast<CPWL_RadioButton*>(GetWindow());
EXPECT_FALSE(radio_button->IsChecked());
EXPECT_TRUE(GetCPDFSDKFormFillEnv()->GetInteractiveFormFiller()->OnChar(
GetCPDFSDKAnnotReadOnlyRadioButton(), '\r', {}));
EXPECT_FALSE(radio_button->IsChecked());
}
TEST_F(CPWLSpecialButtonEmbedderTest, EnterOnRadioButton) {
FormFillerAndWindowSetup(GetCPDFSDKAnnotRadioButton());
CPWL_RadioButton* radio_button = static_cast<CPWL_RadioButton*>(GetWindow());
EXPECT_TRUE(GetCPDFSDKFormFillEnv()->GetInteractiveFormFiller()->OnChar(
GetCPDFSDKAnnotRadioButton(), '\r', {}));
EXPECT_TRUE(radio_button->IsChecked());
}
| 36.206897 | 80 | 0.75619 | yanxijian |
3be654dbed3a219240983d86e1b0df8402c0e874 | 755 | cpp | C++ | Array/Swap kth elements.cpp | DY-2001/DSA | 0f1f7a19304a2e5cfef690bf51a22bbc73eef4bc | [
"MIT"
] | null | null | null | Array/Swap kth elements.cpp | DY-2001/DSA | 0f1f7a19304a2e5cfef690bf51a22bbc73eef4bc | [
"MIT"
] | null | null | null | Array/Swap kth elements.cpp | DY-2001/DSA | 0f1f7a19304a2e5cfef690bf51a22bbc73eef4bc | [
"MIT"
] | null | null | null | // { Driver Code Starts
#include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
//User function template for C++
class Solution{
public:
// swap k'th element from beginning and end
void swapKth(int *arr, int n, int k) {
int temp = arr[k - 1];
arr[k - 1] = arr[n - k];
arr[n - k] = temp;
}
};
// { Driver Code Starts.
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
Solution ob;
ob.swapKth(arr, n, k);
for (int i = 0; i < n; i++) {
cout << arr[i] << " ";
}
cout << "\n";
}
return 0;
}
// } Driver Code Ends
| 17.97619 | 44 | 0.445033 | DY-2001 |
3be8104e00c237408d7d0ebd2ddfbecaece37333 | 3,731 | cpp | C++ | src/valueiterator.cpp | DigDeeply/PHP-CPP | 778561e1739a4a7ef20e85b713b4790e6be225d3 | [
"Apache-2.0"
] | 1 | 2020-04-07T03:26:48.000Z | 2020-04-07T03:26:48.000Z | src/valueiterator.cpp | DigDeeply/PHP-CPP | 778561e1739a4a7ef20e85b713b4790e6be225d3 | [
"Apache-2.0"
] | null | null | null | src/valueiterator.cpp | DigDeeply/PHP-CPP | 778561e1739a4a7ef20e85b713b4790e6be225d3 | [
"Apache-2.0"
] | null | null | null | /**
* ValueIterator.cpp
*
* Implementation of the value iterator
*
* @author Emiel Bruijntjes <[email protected]>
* @copyright 2014 Copernica BV
*/
#include "includes.h"
/**
* Set up namespace
*/
namespace Php {
/**
* Constructor
* @param hashtable The hashtable to iterate over
* @param first Should it start at the first position?
*/
ValueIterator::ValueIterator(HashTable *hashtable, bool first) : _table(hashtable)
{
// reset the hash pointer to the internal position
if (hashtable && first)
{
// move to first position
zend_hash_internal_pointer_reset_ex(_table, &_position);
// read current data
read();
}
else
{
// start with invalid data
invalidate();
}
}
/**
* Increment position
* @return ValueIterator
*/
ValueIterator &ValueIterator::operator++()
{
// leap out if already on an invalid pos (behind the last pos)
if (!_position) return *this;
// move the iterator forward
if (zend_hash_move_forward_ex(_table, &_position) == SUCCESS)
{
// read current key and value
return read();
}
else
{
// invalidate current position
return invalidate();
}
}
/**
* Decrement position
* @return ValueIterator
*/
ValueIterator &ValueIterator::operator--()
{
// leap out if we're not even iterating over a hash table
if (!_table) return *this;
// if position is invalid, it is one position behind the last position
if (!_position)
{
// move to last position
zend_hash_internal_pointer_end_ex(_table, &_position);
}
else if (zend_hash_move_backwards_ex(_table, &_position) == FAILURE)
{
// invalidate current position
return invalidate();
}
// read current key and value
return read();
}
/**
* Read current key and value
* @return ValueIterator
*/
ValueIterator &ValueIterator::read()
{
// zval to read the current key in
Value key;
#if PHP_VERSION_ID >= 50500
// read in the current key
zend_hash_get_current_key_zval_ex(_table, key._val, &_position);
// if the key is set to NULL, it means that the object is not at a valid position
if (key.isNull()) return invalidate();
#else
// php 5.3 and php 5.4 need a different implementation because the function
// zend_hash_get_current_key_zval_ex is missing in php 5.3, declare variables
// we need for storing the key in
char *string_key;
unsigned int str_len;
unsigned long num_key;
// get the current key
int type = zend_hash_get_current_key_ex(_table, &string_key, &str_len, &num_key, 0, &_position);
// if key is not found, the iterator is at an invalid position
if (type == HASH_KEY_NON_EXISTANT) return invalidate();
// numeric keys are the easiest ones
if (type == HASH_KEY_IS_LONG) key = (int64_t)num_key;
else key = string_key;
#endif
// iterator is at a valid position, go fetch the data
// this is the variable we need for fetching the data
zval **value;
// retrieve data
zend_hash_get_current_data_ex(_table, (void **) &value, &_position);
// we can now update the current data
_current = std::make_pair<Value,Value>(std::move(key), *value);
// done
return *this;
}
/**
* Invalidate the iterator
* @return ValueIterator
*/
ValueIterator &ValueIterator::invalidate()
{
// forget current position
_position = nullptr;
// make the data a pair of null ptrs
_current = std::make_pair<Value,Value>(nullptr,nullptr);
// done
return *this;
}
/**
* End namespace
*/
}
| 23.465409 | 100 | 0.639239 | DigDeeply |
3be811d10636d0b1cd7c379dcbe6cbea7201c4f6 | 3,123 | cc | C++ | PacSim/PacWriteParticles.cc | brownd1978/FastSim | 05f590d72d8e7f71856fd833114a38b84fc7fd48 | [
"Apache-2.0"
] | null | null | null | PacSim/PacWriteParticles.cc | brownd1978/FastSim | 05f590d72d8e7f71856fd833114a38b84fc7fd48 | [
"Apache-2.0"
] | null | null | null | PacSim/PacWriteParticles.cc | brownd1978/FastSim | 05f590d72d8e7f71856fd833114a38b84fc7fd48 | [
"Apache-2.0"
] | null | null | null | //--------------------------------------------------------------------------
// Name:
// PacWriteParticles
// Environment:
//------------------------------------------------------------------------
#include "BaBar/BaBar.hh"
#include "CLHEP/Random/RandFlat.h"
#include "PacSim/PacWriteParticles.hh"
#include "PacSim/PacSimTrack.hh"
#include "PacSim/PacSimHit.hh"
#include "PacEnv/PacConfig.hh"
#include <cassert>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
PacWriteParticles::PacWriteParticles() :_nevtwrote(0),_nparwrote(0),_particles("TParticle",10000),
_evtnum(0),_nsum(1),_npar(0){
// get config information
_evtwt = gconfig.getfloat("ParticleOutput.weight",1.0);
_fileName = gconfig.getcstr("ParticleOutput.filename","FastSimOutput.root");
_treeName = gconfig.getcstr("ParticleOutput.treename","Particles");
_statuscode = gconfig.getint("ParticleOutput.statuscode",100);
_active = gconfig.getbool("ParticleOutput.active",false);
_verbose = gconfig.getbool("ParticleOutput.verbose",false);
_writeempty = gconfig.getbool("ParticleOutput.writeempty",false);
// setup the output file and its tree and branches
if(_active){
_output = new TFile(_fileName,"RECREATE");
_tree = new TTree(_treeName,_treeName);
_tree->Branch("EvtNr",&_evtnum);
_tree->Branch("EvtW",&_evtwt);
_tree->Branch("NEvt",&_nsum);
_tree->Branch("NPar",&_npar);
_tree->Branch("Particles",&_particles);
}
}
PacWriteParticles::~PacWriteParticles()
{
// close the output
if(_active && _output != 0){
_output->cd();
_tree->Write();
_output->Write();
_output->Close();
delete _output; _output=0;
std::cout << "PacWriteParticles wrote " << _nevtwrote << " events, "
<< _nparwrote << " particles to file " << _fileName << std::endl;
}
}
void
PacWriteParticles::writeParticle(const PacSimHit& pshit){
if(_active){
// create the particle memory with placement new!!
TParticle* part = new(_particles[_npar++]) TParticle();
// fill particle properties
part->SetPdgCode(pshit.pdt()->pdgId());
double mass = pshit.pdt()->mass();
// take the momentum before the effect of this hit
const Hep3Vector& mom = pshit.momentumIn();
double energy = sqrt(mass*mass+mom.mag2());
part->SetMomentum(mom.x(),mom.y(),mom.z(), energy);
HepPoint pt = pshit.position();
// shift position a tiny bit to the negative to make sure we can find the intersections
Hep3Vector momdir = mom.unit();
static const double backstep(-1.0e-3); // 10 microns
pt += momdir*backstep;
part->SetProductionVertex(pt.x(),pt.y(),pt.z(),pshit.time());
part->SetWeight(1.0); // all particles have same weight
part->SetStatusCode(_statuscode);
if(_verbose) cout << "Wrote particle # " << _npar
<< " type " << pshit.pdt()->name()
<< " mom " << mom.mag() << endl;
}
}
void
PacWriteParticles::fillTree() {
if(_active && (_writeempty || _particles.GetEntriesFast() > 0) ){
_tree->Fill();
_nparwrote += _particles.GetEntriesFast();
_particles.Clear();
_nevtwrote++;
_nsum = 0;
_npar = 0;
}
}
| 33.945652 | 99 | 0.645213 | brownd1978 |
3bec06a2e34702ce170896e0419e65c856b250b1 | 5,769 | cpp | C++ | inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/scatter_update/scatter_elements_update_kernel_ref.cpp | Jacob272727/openvino | 9106eab30b8f449c139e5fb5d2ff260e651f9496 | [
"Apache-2.0"
] | 1 | 2021-04-06T03:32:12.000Z | 2021-04-06T03:32:12.000Z | inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/scatter_update/scatter_elements_update_kernel_ref.cpp | Jacob272727/openvino | 9106eab30b8f449c139e5fb5d2ff260e651f9496 | [
"Apache-2.0"
] | 28 | 2021-09-24T09:29:02.000Z | 2022-03-28T13:20:46.000Z | inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/scatter_update/scatter_elements_update_kernel_ref.cpp | jayabs2020/openvino | 67a82a040faaf66f109035acf7de6e4b7568bc08 | [
"Apache-2.0"
] | 1 | 2020-08-30T11:48:03.000Z | 2020-08-30T11:48:03.000Z | // Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "scatter_elements_update_kernel_ref.h"
#include "kernel_selector_utils.h"
#include <string>
#include <vector>
namespace kernel_selector {
static size_t GetScatterElementsUpdateChannelIndex(const scatter_elements_update_params& params) {
Tensor::DataChannelName name = Tensor::DataChannelName::X;
const size_t input_size = params.inputs[0].GetDims().size();
switch (params.axis) {
case ScatterUpdateAxis::X:
return input_size - 1;
case ScatterUpdateAxis::Y:
return input_size - 2;
case ScatterUpdateAxis::Z:
return input_size - 3;
case ScatterUpdateAxis::W:
return 2;
case ScatterUpdateAxis::FEATURE:
return 1;
case ScatterUpdateAxis::BATCH:
return 0;
default:
break;
}
return DataTensor::Channelndex(params.output.GetLayout(), name);
}
ParamsKey ScatterElementsUpdateKernelRef::GetSupportedKey() const {
ParamsKey k;
k.EnableInputDataType(Datatype::F16);
k.EnableInputDataType(Datatype::F32);
k.EnableInputDataType(Datatype::INT32);
k.EnableOutputDataType(Datatype::F16);
k.EnableOutputDataType(Datatype::F32);
k.EnableOutputDataType(Datatype::INT32);
k.EnableOutputDataType(Datatype::INT8);
k.EnableOutputDataType(Datatype::UINT8);
k.EnableInputLayout(DataLayout::bfyx);
k.EnableOutputLayout(DataLayout::bfyx);
k.EnableInputLayout(DataLayout::bfzyx);
k.EnableOutputLayout(DataLayout::bfzyx);
k.EnableInputLayout(DataLayout::bfwzyx);
k.EnableOutputLayout(DataLayout::bfwzyx);
k.EnableTensorOffset();
k.EnableTensorPitches();
k.EnableBatching();
k.EnableDifferentTypes();
return k;
}
static inline std::string GetOrderString(std::vector<std::string>& order) {
std::string order_str = order[0];
for (size_t i = 1; i < order.size(); i++)
order_str += ", " + order[i];
return order_str;
}
static inline std::vector<std::string> GetDefaultOrder(size_t size) {
std::vector<std::string> default_order;
if (size <= 4) {
default_order = {"b", "f", "y", "x"};
} else if (size == 5) {
default_order = {"b", "f", "z", "y", "x"};
} else if (size == 6) {
default_order = {"b", "f", "w", "z", "y", "x"};
}
return default_order;
}
CommonDispatchData ScatterElementsUpdateKernelRef::SetDefault(const scatter_elements_update_params& params, const optional_params&, bool is_second) const {
CommonDispatchData dispatchData;
const auto& output = params.output;
const auto& indices = params.inputs[1];
const auto& scope = is_second ? indices : output;
switch (params.inputs[0].GetLayout()) {
case DataLayout::bfyx:
dispatchData.gws = {scope.X().v, scope.Y().v, scope.Feature().v * scope.Batch().v};
break;
case DataLayout::bfzyx:
dispatchData.gws = {scope.X().v * scope.Y().v, scope.Z().v, scope.Feature().v * scope.Batch().v};
break;
case DataLayout::bfwzyx:
dispatchData.gws = {scope.X().v * scope.Y().v, scope.Z().v * scope.W().v, scope.Feature().v * scope.Batch().v};
break;
default:
throw std::invalid_argument("Unsupported data layout for scatter elements update primitive");
break;
}
dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo);
return dispatchData;
}
JitConstants ScatterElementsUpdateKernelRef::GetJitConstants(const scatter_elements_update_params& params) const {
JitConstants jit = MakeBaseParamsJitConstants(params);
jit.AddConstant(MakeJitConstant("AXIS_VALUE", GetScatterElementsUpdateChannelIndex(params)));
if (!params.fused_ops.empty()) {
FusedOpsConfiguration conf1 = { "_FIRST_KERNEL", GetDefaultOrder(params.output.GetDims().size()), "val", params.inputs[0].GetDType() };
FusedOpsConfiguration conf2 = { "_SECOND_KERNEL", GetDefaultOrder(params.output.GetDims().size()), "val", params.inputs[0].GetDType() };
jit.Merge(MakeFusedOpsJitConstants(params, {conf1, conf2}));
}
return jit;
}
bool ScatterElementsUpdateKernelRef::Validate(const Params& p, const optional_params& o) const {
if (p.GetType() != KernelType:: SCATTER_ELEMENTS_UPDATE || o.GetType() != KernelType::SCATTER_ELEMENTS_UPDATE) {
return false;
}
const scatter_elements_update_params& params = static_cast<const scatter_elements_update_params&>(p);
for (auto& fused_op : params.fused_ops) {
if (!IsFusedPrimitiveSupported(fused_op))
return false;
}
return true;
}
KernelsData ScatterElementsUpdateKernelRef::GetKernelsData(const Params& params, const optional_params& options) const {
if (!Validate(params, options)) {
return {};
}
KernelData kd = KernelData::Default<scatter_elements_update_params>(params, 2);
scatter_elements_update_params& newParams = *static_cast<scatter_elements_update_params*>(kd.params.get());
auto cldnn_jit = GetJitConstants(newParams);
for (int i = 0; i < 2; i++) {
auto dispatchData = SetDefault(newParams, options, (i == 1));
auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options);
if (i == 1) {
cldnn_jit.AddConstant(MakeJitConstant("IS_SECOND_ITER", "true"));
}
std::string jit = CreateJit(kernelName, cldnn_jit, entry_point);
clKernelData& kernel = kd.kernels[i];
FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point, "", false, false, 3, GetFusedPrimitiveInputsCount(params));
}
return {kd};
}
} // namespace kernel_selector
| 35.392638 | 155 | 0.67724 | Jacob272727 |
3beed0fdcde3cbd0758ff7a723aa7d76df513359 | 6,166 | cc | C++ | riegeli/ordered_varint/ordered_varint_reading.cc | micahcc/riegeli | d8cc64857253037d4f022e860b7b86cbe7d4b8d8 | [
"Apache-2.0"
] | null | null | null | riegeli/ordered_varint/ordered_varint_reading.cc | micahcc/riegeli | d8cc64857253037d4f022e860b7b86cbe7d4b8d8 | [
"Apache-2.0"
] | null | null | null | riegeli/ordered_varint/ordered_varint_reading.cc | micahcc/riegeli | d8cc64857253037d4f022e860b7b86cbe7d4b8d8 | [
"Apache-2.0"
] | null | null | null | // Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "riegeli/ordered_varint/ordered_varint_reading.h"
#include <stdint.h>
#include "absl/base/optimization.h"
#include "absl/types/optional.h"
#include "riegeli/base/base.h"
#include "riegeli/bytes/reader.h"
#include "riegeli/endian/endian_reading.h"
namespace riegeli {
namespace internal {
absl::optional<uint32_t> ReadOrderedVarint32Slow(Reader& src) {
RIEGELI_ASSERT_GT(src.available(), 0u)
<< "Failed precondition of ReadOrderedVarint32Slow(): no data available";
const uint8_t first_byte = static_cast<uint8_t>(*src.cursor());
RIEGELI_ASSERT_GE(first_byte, 0x80)
<< "Failed precondition of ReadOrderedVarint32Slow(): length is 1";
if (first_byte < 0xc0) {
if (ABSL_PREDICT_FALSE(!src.Pull(2))) return absl::nullopt;
const uint32_t value =
ReadBigEndian16(src.cursor()) & ~(uint16_t{0x80} << 8);
if (ABSL_PREDICT_FALSE(value < uint32_t{1} << 7)) {
return absl::nullopt;
}
src.move_cursor(2);
return value;
} else if (first_byte < 0xe0) {
if (ABSL_PREDICT_FALSE(!src.Pull(3))) return absl::nullopt;
const uint32_t value =
(static_cast<uint32_t>(static_cast<uint8_t>(src.cursor()[0]) &
~uint8_t{0xc0})
<< (2 * 8)) |
ReadBigEndian16(src.cursor() + 1);
if (ABSL_PREDICT_FALSE(value < uint32_t{1} << (2 * 7))) {
return absl::nullopt;
}
src.move_cursor(3);
return value;
} else if (first_byte < 0xf0) {
if (ABSL_PREDICT_FALSE(!src.Pull(4))) return absl::nullopt;
const uint32_t value =
ReadBigEndian32(src.cursor()) & ~(uint32_t{0xe0} << (3 * 8));
if (ABSL_PREDICT_FALSE(value < uint32_t{1} << (3 * 7))) {
return absl::nullopt;
}
src.move_cursor(4);
return value;
} else {
if (ABSL_PREDICT_FALSE(first_byte > 0xf0)) return absl::nullopt;
if (ABSL_PREDICT_FALSE(!src.Pull(5))) return absl::nullopt;
const uint32_t value = ReadBigEndian32(src.cursor() + 1);
if (ABSL_PREDICT_FALSE(value < uint32_t{1} << (4 * 7))) {
return absl::nullopt;
}
src.move_cursor(5);
return value;
}
}
absl::optional<uint64_t> ReadOrderedVarint64Slow(Reader& src) {
RIEGELI_ASSERT_GT(src.available(), 0u)
<< "Failed precondition of ReadOrderedVarint64Slow(): no data available";
const uint8_t first_byte = static_cast<uint8_t>(*src.cursor());
RIEGELI_ASSERT_GE(first_byte, 0x80)
<< "Failed precondition of ReadOrderedVarint64Slow(): length is 1";
if (first_byte < 0xc0) {
if (ABSL_PREDICT_FALSE(!src.Pull(2))) return absl::nullopt;
const uint32_t value =
ReadBigEndian16(src.cursor()) & ~(uint16_t{0x80} << 8);
if (ABSL_PREDICT_FALSE(value < uint32_t{1} << 7)) {
return absl::nullopt;
}
src.move_cursor(2);
return value;
} else if (first_byte < 0xe0) {
if (ABSL_PREDICT_FALSE(!src.Pull(3))) return absl::nullopt;
const uint32_t value =
(static_cast<uint32_t>(static_cast<uint8_t>(src.cursor()[0]) &
~uint8_t{0xc0})
<< (2 * 8)) |
ReadBigEndian16(src.cursor() + 1);
if (ABSL_PREDICT_FALSE(value < uint32_t{1} << (2 * 7))) {
return absl::nullopt;
}
src.move_cursor(3);
return value;
} else if (first_byte < 0xf0) {
if (ABSL_PREDICT_FALSE(!src.Pull(4))) return absl::nullopt;
const uint32_t value =
ReadBigEndian32(src.cursor()) & ~(uint32_t{0xe0} << (3 * 8));
if (ABSL_PREDICT_FALSE(value < uint32_t{1} << (3 * 7))) {
return absl::nullopt;
}
src.move_cursor(4);
return value;
} else if (first_byte < 0xf8) {
if (ABSL_PREDICT_FALSE(!src.Pull(5))) return absl::nullopt;
const uint64_t value =
(static_cast<uint64_t>(static_cast<uint8_t>(src.cursor()[0]) &
~uint8_t{0xf0})
<< (4 * 8)) |
ReadBigEndian32(src.cursor() + 1);
if (ABSL_PREDICT_FALSE(value < uint64_t{1} << (4 * 7))) {
return absl::nullopt;
}
src.move_cursor(5);
return value;
} else if (first_byte < 0xfc) {
if (ABSL_PREDICT_FALSE(!src.Pull(6))) return absl::nullopt;
const uint64_t value =
(static_cast<uint64_t>(ReadBigEndian16(src.cursor()) &
~(uint16_t{0xf8} << 8))
<< (4 * 8)) |
ReadBigEndian32(src.cursor() + 2);
if (ABSL_PREDICT_FALSE(value < uint64_t{1} << (5 * 7))) {
return absl::nullopt;
}
src.move_cursor(6);
return value;
} else if (first_byte < 0xfe) {
if (ABSL_PREDICT_FALSE(!src.Pull(7))) return absl::nullopt;
const uint64_t value =
(static_cast<uint64_t>(ReadBigEndian32(src.cursor()) &
~(uint32_t{0xfc} << (3 * 8)))
<< (3 * 8)) |
ReadBigEndian32(src.cursor() + 3);
if (ABSL_PREDICT_FALSE(value < uint64_t{1} << (6 * 7))) {
return absl::nullopt;
}
src.move_cursor(7);
return value;
} else if (first_byte < 0xff) {
if (ABSL_PREDICT_FALSE(!src.Pull(8))) return absl::nullopt;
const uint64_t value =
ReadBigEndian64(src.cursor()) & ~(uint64_t{0xfe} << (7 * 8));
if (ABSL_PREDICT_FALSE(value < uint64_t{1} << (7 * 7))) {
return absl::nullopt;
}
src.move_cursor(8);
return value;
} else {
if (ABSL_PREDICT_FALSE(!src.Pull(9))) return absl::nullopt;
const uint64_t value = ReadBigEndian64(src.cursor() + 1);
if (ABSL_PREDICT_FALSE(value < uint64_t{1} << (8 * 7))) {
return absl::nullopt;
}
src.move_cursor(9);
return value;
}
}
} // namespace internal
} // namespace riegeli
| 36.270588 | 79 | 0.626825 | micahcc |
3bf223f358c795d103332bf214017cdb5cecbdca | 21,858 | cpp | C++ | src/runtime_src/core/pcie/tools/cloud-daemon/azure/azure.cpp | subeeshm-xilinx/XRT | f2f551a815dcd135132f974205401ca0982f9a3b | [
"Apache-2.0"
] | 359 | 2018-10-05T03:05:08.000Z | 2022-03-31T06:28:16.000Z | src/runtime_src/core/pcie/tools/cloud-daemon/azure/azure.cpp | kbhardwa-xilinx/XRT | 9cadec73f5211577c7d5c408a4a7fee0eed23b70 | [
"Apache-2.0"
] | 5,832 | 2018-10-02T22:43:29.000Z | 2022-03-31T22:28:05.000Z | src/runtime_src/core/pcie/tools/cloud-daemon/azure/azure.cpp | kbhardwa-xilinx/XRT | 9cadec73f5211577c7d5c408a4a7fee0eed23b70 | [
"Apache-2.0"
] | 442 | 2018-10-02T23:06:29.000Z | 2022-03-21T08:34:44.000Z | /*
* Partial Copyright (C) 2019-2021 Xilinx, Inc
*
* Microsoft provides sample code how RESTful APIs are being called
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may
* not use this file except in compliance with the License. A copy of the
* License is located at
*
* http://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 <errno.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <syslog.h>
#include <openssl/sha.h>
#include <curl/curl.h>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <stdlib.h>
#include <thread>
#include <vector>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <exception>
#include <regex>
#include <future>
#include "xclbin.h"
#include "azure.h"
/*
* Functions each plugin needs to provide
*/
extern "C" {
int init(mpd_plugin_callbacks *cbs);
void fini(void *mpc_cookie);
}
/*
* This is the default Azure cloud wireserver IP.
* Users debugging with a standalone server needs to edit /etc/mpd.conf to
* specify its own IP, with format, eg
* restip = 1.1.1.1
*/
static std::string restip_endpoint = "168.63.129.16";
/*
* Maintain the serialNumber of cards.
* This is required since during reset, the sysfs entry is not available
*/
static std::vector<std::string> fpga_serial_number;
/*
* Init function of the plugin that is used to hook the required functions.
* The cookie is used by fini (see below). Can be NULL if not required.
*/
int init(mpd_plugin_callbacks *cbs)
{
int ret = 1;
auto total = pcidev::get_dev_total();
if (total == 0) {
syslog(LOG_INFO, "azure: no device found");
return ret;
}
if (cbs)
{
// init curl
int curlInit = curl_global_init(CURL_GLOBAL_ALL);
if (curlInit != 0)
syslog(LOG_ERR, "mpd cannot initalize curl: %d", curlInit);
std::string private_ip = AzureDev::get_wireserver_ip();
if (!private_ip.empty())
restip_endpoint = private_ip;
syslog(LOG_INFO, "azure restserver ip: %s\n", restip_endpoint.c_str());
fpga_serial_number = AzureDev::get_serial_number();
// hook functions
cbs->mpc_cookie = NULL;
cbs->get_remote_msd_fd = get_remote_msd_fd;
cbs->mb_req.load_xclbin = azureLoadXclBin;
cbs->mb_req.hot_reset = azureHotReset;
ret = 0;
}
syslog(LOG_INFO, "azure mpd plugin init called: %d\n", ret);
return ret;
}
/*
* Fini function of the plugin
*/
void fini(void *mpc_cookie)
{
syslog(LOG_INFO, "azure mpd plugin fini called\n");
}
/*
* callback function that is used to setup communication channel
* we are going to handle mailbox ourself, no comm channel is required.
* so just return -1 to the fd
* Input:
* index: index of the user PF
* Output:
* fd: socket handle of the communication channel
* Return value:
* 0: success
* 1: failure
*/
int get_remote_msd_fd(size_t index, int* fd)
{
*fd = -1;
return 0;
}
/*
* callback function that is used to handle MAILBOX_REQ_LOAD_XCLBIN msg
*
* Input:
* index: index of the FPGA device
* xclbin: the fake xclbin file
* Output:
* resp: int as response msg
* Return value:
* 0: success
* others: error code
*/
int azureLoadXclBin(size_t index, const axlf *xclbin, int *resp)
{
AzureDev d(index);
struct timeval tvStartLoadXclBin, tvEndLoadXclBin;
gettimeofday(&tvStartLoadXclBin, NULL);
*resp = d.azureLoadXclBin(xclbin);
gettimeofday(&tvEndLoadXclBin, NULL);
double loadxclTime = (tvEndLoadXclBin.tv_sec - tvStartLoadXclBin.tv_sec) * 1000.0;
loadxclTime += (tvEndLoadXclBin.tv_usec - tvStartLoadXclBin.tv_usec) / 1000.0;
std::cout << "time LoadXclBin (" << index << ") = " << (loadxclTime/1000) << std::endl;
return 0;
}
/*
* Reset requires the mailbox msg return before the real reset
* happens. So we run user special reset in async thread.
*/
std::future<void> nouse; //so far we don't care the return value of reset
static void azureHotResetAsync(size_t index)
{
AzureDev d(index);
struct timeval tvStartReset, tvEndReset;
gettimeofday(&tvStartReset, NULL);
d.azureHotReset();
gettimeofday(&tvEndReset, NULL);
double resetTime = (tvEndReset.tv_sec - tvStartReset.tv_sec) * 1000.0;
resetTime += (tvEndReset.tv_usec - tvStartReset.tv_usec) / 1000.0;
std::cout << "time HotReset (" << index << ") = " << (resetTime/1000) << std::endl;
}
/*
* callback function that is used to handle MAILBOX_REQ_HOT_RESET msg
*
* Input:
* index: index of the FPGA device
* Output:
* resp: int as response msg
* Return value:
* 0: success
* others: error code
*/
int azureHotReset(size_t index, int *resp)
{
/*
* Tell xocl don't try to restore anything since we are going
* to do hotplug in wireserver
* If we can't get S/N of the card, we are not even going to issue the reset
* to wireserver since this makes no sense and even hangs the instance.
* Empty S/N may happen in this scenario,
* 1. vm boots and is ready before the mgmt side is ready
* 2. 'xbutil reset' tries to reset the card immediately after mgmt is ready
* in this case, there is no chance for mpd to get S/N info. so we just fails
* the reset
*/
if (fpga_serial_number.at(index).empty()) {
*resp = -E_EMPTY_SN;
} else {
*resp = -ESHUTDOWN;
nouse = std::async(std::launch::async, &azureHotResetAsync, index);
}
return 0;
}
//azure specific parts
static size_t read_callback(void *contents, size_t size, size_t nmemb, void *userp)
{
int ret = 0;
struct write_unit *unit = static_cast<struct write_unit *>(userp);
std::string output;
size_t isize = unit->sizeleft;
if (!isize)
return ret;
ret = (isize < size * nmemb ? isize : size * nmemb);
memcpy(contents, unit->uptr, ret);
unit->uptr += ret;
unit->sizeleft -= ret;
return ret;
}
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
int AzureDev::azureLoadXclBin(const xclBin *buffer)
{
char *xclbininmemory = reinterpret_cast<char*> (const_cast<xclBin*> (buffer));
if (memcmp(xclbininmemory, "xclbin2", 8) != 0)
return -1;
std::string fpgaSerialNumber;
get_fpga_serialNo(fpgaSerialNumber);
if (fpgaSerialNumber.empty())
return -E_EMPTY_SN;
std::cout << "LoadXclBin FPGA serial No: " << fpgaSerialNumber << std::endl;
// check if the xclbin is valid
if (xclbin::get_axlf_section(buffer, BITSTREAM) != nullptr) {
std::cout << "xclbin is invalid, please provide azure xclbin" << std::endl;
return -E_INVALID_XCLBIN;
}
int index = 0;
std::string imageSHA;
std::vector<std::string> chunks;
size_t size = buffer->m_header.m_length;
std::cout << "xclbin file size (" << fpgaSerialNumber << "): " << size << std::endl;
// Generate SHA256 for the kernel and
// separate in segments ready to upload
int res = Sha256AndSplit(std::string(xclbininmemory, size), chunks, imageSHA);
if (res) {
std::cout << "xclbin split failed!" << std::endl;
return -E_SPLIT;
}
std::cout << "xclbin file sha256 (" << fpgaSerialNumber << "): " << imageSHA << std::endl;
struct timeval tvStartUpload, tvEndUpload;
std::cout << "Start upload segment (" << fpgaSerialNumber << ")" << std::endl;
gettimeofday(&tvStartUpload, NULL);
for (auto &chunk: chunks) {
if (goingTimeout())
return -E_REST_TIMEOUT;
//upload each segment individually
std::cout << "upload segment (" << fpgaSerialNumber << "): " << index << " size: " << chunk.size() << std::endl;
if (UploadToWireServer(
restip_endpoint,
"machine/plugins/?comp=FpgaController&type=SendImageSegment",
fpgaSerialNumber,
chunk,
index,
chunks.size(),
imageSHA))
return -E_UPLOAD;
index++;
}
gettimeofday(&tvEndUpload, NULL);
std::cout << "Done upload segment (" << fpgaSerialNumber << ")" << std::endl;
double uploadTime = (tvEndUpload.tv_sec - tvStartUpload.tv_sec) * 1000.0;
uploadTime += (tvEndUpload.tv_usec - tvStartUpload.tv_usec) / 1000.0;
std::cout << "time upload segment (" << fpgaSerialNumber << ") = " << (uploadTime/1000) << std::endl;
//start the re-image process
int retryCounter = 0;
int sleepDelayStartReimagin[] = {1500, 1500, 1000, 1000, 1500, 1500, 1000, 1000, 1500, 1500, 1000, 1000, 1500, 1500, 1000, 1000};
std::string delim = ":";
std::string ret, key, value;
struct timeval tvStartReimage, tvEndReimage;
std::cout << "Start reimage process (" << fpgaSerialNumber << ")" << std::endl;
gettimeofday(&tvStartReimage, NULL);
do {
if (goingTimeout())
return -E_REST_TIMEOUT;
ret = REST_Get(
restip_endpoint,
"machine/plugins/?comp=FpgaController&type=StartReimaging",
fpgaSerialNumber
);
if (splitLine(ret, key, value, delim) != 0 ||
key.compare("StartReimaging") != 0 ||
value.compare("0") != 0) {
msleep(sleepDelayStartReimagin[retryCounter]);
retryCounter++;
if (retryCounter >= upload_retry) {
std::cout << "Timeout trying to start reimging (" << fpgaSerialNumber << ")..." << std::endl;
return -E_START_REIMAGE;
}
} else {
retryCounter = 0;
}
} while (retryCounter > 0);
gettimeofday(&tvEndReimage, NULL);
std::cout << "Done start reimage (" << fpgaSerialNumber << ")" << std::endl;
double reimageTime = (tvEndReimage.tv_sec - tvStartReimage.tv_sec) * 1000.0;
reimageTime += (tvEndReimage.tv_usec - tvStartReimage.tv_usec) / 1000.0;
std::cout << "time start reimage (" << fpgaSerialNumber << ") = " << (reimageTime/1000) << std::endl;
// reconfig takes 8-10 secs as min, per measure, waiting 8000
msleep(8000);
//check the re-image status
int sleepDelayReimageStatus[] = {3000, 2000, 2000 , 1500, 1500, 1500, 1000, 1000, 1500, 1500, 1000, 1000, 1500, 1500, 1000, 1000};
struct timeval tvStartStatus, tvEndStatus;
std::cout << "Start reimage Status (" << fpgaSerialNumber << ")" << std::endl;
gettimeofday(&tvStartStatus, NULL);
int wait = 0;
do {
if (goingTimeout())
return -E_REST_TIMEOUT;
ret = REST_Get(
restip_endpoint,
"machine/plugins/?comp=FpgaController&type=GetReimagingStatus",
fpgaSerialNumber
);
if (splitLine(ret, key, value, delim) != 0 ||
key.compare("GetReimagingStatus") != 0) {
std::cout << "Retrying GetReimagingStatus ... " << std::endl;
msleep(sleepDelayReimageStatus[wait%15]);
wait++;
continue;
} else if (value.compare("3") != 0) {
msleep(sleepDelayReimageStatus[wait%15]);
wait++;
continue;
} else {
std::cout << "reimaging return status (" << fpgaSerialNumber << "): " << value << " within " << wait << "s" << std::endl;
gettimeofday(&tvEndStatus, NULL);
std::cout << "Done reimage status (" << fpgaSerialNumber << ")" << std::endl;
double statusTime = (tvEndStatus.tv_sec - tvStartStatus.tv_sec) * 1000.0;
statusTime += (tvEndStatus.tv_usec - tvStartStatus.tv_usec) / 1000.0;
std::cout << "time reimage status (" << fpgaSerialNumber << ") = " << (statusTime/1000) << std::endl;
return 0;
}
} while (wait < rest_timeout);
std::cout << "Timeout GetImageStatus (" << fpgaSerialNumber << ")..." << std::endl;
return -E_GET_REIMAGE_STATUS;
}
int AzureDev::azureHotReset()
{
std::string fpgaSerialNumber;
get_fpga_serialNo(fpgaSerialNumber);
std::cout << "HotReset FPGA serial No: " << fpgaSerialNumber << std::endl;
//start the reset process
std::string delim = ":";
std::string ret, key, value;
int wait = 0;
do {
ret = REST_Get(
restip_endpoint,
"machine/plugins/?comp=FpgaController&type=Reset",
fpgaSerialNumber
);
syslog(LOG_INFO, "obtained ret = %s from reset call", ret.c_str());
if (splitLine(ret, key, value, delim) != 0 ||
key.compare("Reset") != 0 ||
value.compare("0") != 0) {
syslog(LOG_INFO, "wasn't expected response...%s", ret.c_str());
sleep(1);
wait++;
continue;
}
break;
} while (wait < reset_retry);
if (value.compare("0") != 0)
return -E_RESET;
// poll wireserver for response TBD
//check the response
syslog(LOG_INFO, "poll for reset status...");
wait = 0;
do {
ret = REST_Get(
restip_endpoint,
"machine/plugins/?comp=FpgaController&type=GetResetStatus",
fpgaSerialNumber
);
syslog(LOG_INFO, "obtained ret = %s from get reset status call", ret.c_str());
if (splitLine(ret, key, value, delim) != 0 ||
key.compare("GetResetStatus") != 0 ||
value.compare("2") != 0) {
sleep(1);
wait++;
continue;
} else {
std::cout << "get reset status return status: " << value << " within " << wait << "s" << std::endl;
return 0;
}
} while (wait < rest_timeout);
return -E_GET_RESET_STATUS;
}
AzureDev::~AzureDev()
{
}
AzureDev::AzureDev(size_t index) : index(index)
{
dev = pcidev::get_dev(index, true);
gettimeofday(&start, NULL);
}
//private methods
//REST operations using libcurl (-lcurl)
int AzureDev::UploadToWireServer(
const std::string &ip,
const std::string &endpoint,
const std::string &target,
const std::string &data,
int index,
int total,
const std::string &hash)
{
CURL *curl;
CURLcode res;
struct write_unit unit;
uint8_t retryCounter = 0;
uint8_t maxRetryCounter = 15;
int sleepDelay[] = {1500, 1500, 1000, 1000, 1500, 1500, 1000, 1000, 1500, 1500, 1000, 1000, 1500, 1500, 1000, 1000};
long responseCode=0;
unit.uptr = data.c_str();
unit.sizeleft = data.size();
curl = curl_easy_init();
if (curl) {
std::stringstream urlStream;
urlStream << "http://" << ip << "/" << endpoint << "&chipid=" << target;
curl_easy_setopt(curl, CURLOPT_URL, urlStream.str().c_str());
curl_easy_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_READDATA, &unit);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
// HTTP header section
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: octet-stream");
std::stringstream headerLength;
headerLength << "Content-Length: " << data.size();
headers = curl_slist_append(headers, headerLength.str().c_str());
std::stringstream headerChunk;
headerChunk << "x-azr-chunk: " << index;
headers = curl_slist_append(headers, headerChunk.str().c_str());
std::stringstream headerTotal;
headerTotal << "x-azr-total: " << total;
headers = curl_slist_append(headers, headerTotal.str().c_str());
std::stringstream headerHash;
headerHash << "x-azr-hash: " << hash;
headers = curl_slist_append(headers, headerHash.str().c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
do {
responseCode=0;
res = curl_easy_perform(curl);
if (res != CURLE_OK) {
std::cout << "curl_easy_perform() failed: " << curl_easy_strerror(res) << std::endl;
retryCounter++;
if (retryCounter < maxRetryCounter) {
std::cout << "Retrying an upload (" << target << ") ..." << retryCounter << std::endl;
msleep(sleepDelay[retryCounter-1]);
} else {
std::cout << "Max number of retries reached upload (" << target << ")... givin up1" << std::endl;
curl_easy_cleanup(curl);
return 1;
}
} else {
// check the return code
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &responseCode);
std::cout << "DebugUpload: status code (" << target << ") " << responseCode << std::endl;
if (responseCode >= 400) {
// error range
res = CURLE_HTTP_RETURNED_ERROR;
retryCounter++;
if (retryCounter < maxRetryCounter) {
std::cout << "Retrying an upload after http error (" << target << ")..." << retryCounter << std::endl;
msleep(sleepDelay[retryCounter-1]);
} else {
std::cout << "Max number of retries reached upload (" << target << ")... givin up!" << std::endl;
curl_easy_cleanup(curl);
return 1;
}
} //if (responseCode >= 400)
} //if (res != CURLE_OK)
} while (res != CURLE_OK);
// cleanup
curl_easy_cleanup(curl);
std::cout << "Upload segment (" << target << ") " << index + 1 << " of " << total << std::endl;
} else {
std::cout << "Failed init (" << target << ")..." << std::endl;
} //if (curl)
return 0;
}
std::string AzureDev::REST_Get(
const std::string &ip,
const std::string &endpoint,
const std::string &target
)
{
CURL *curl;
CURLcode res;
std::string readbuff = "";
long responseCode = 0;
curl = curl_easy_init();
if (curl) {
std::stringstream urlStream;
urlStream << "http://" << ip << "/" << endpoint << "&chipid=" << target;
curl_easy_setopt(curl, CURLOPT_URL, urlStream.str().c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readbuff);
//curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
if (res != CURLE_OK)
std::cout << "curl_easy_perform() failed: " << curl_easy_strerror(res) << std::endl;
// check the return code
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &responseCode);
std::cout << "DebugRestGET: (" << target << ") status code " << responseCode << std::endl;
std::string printstring(readbuff);
if (printstring.length() > 80)
printstring.resize(80);
std::cout << "String RestGET returned (" << target << "): " << printstring << std::endl;
curl_easy_cleanup(curl);
//TODO: add code to interpret readbuff to see whether reimage succeeds.
}
return readbuff;
}
// use -lcrypto for SHA operations
int AzureDev::Sha256AndSplit(
const std::string &input,
std::vector<std::string> &output,
std::string &sha)
{
// Initialize openssl
SHA256_CTX context;
if (!SHA256_Init(&context)) {
std::cerr << "Unable to initiate SHA256" << std::endl;
return 1;
}
unsigned pos = 0;
while (pos < input.size()) {
std::string segment = input.substr(pos, transfer_segment_size);
if(!SHA256_Update(&context, segment.c_str(), segment.size()))
{
std::cerr << "Unable to Update SHA256 buffer" << std::endl;
return 1;
}
output.push_back(segment);
pos += transfer_segment_size;
}
// Get Final SHA
unsigned char result[SHA256_DIGEST_LENGTH];
if(!SHA256_Final(result, &context)) {
std::cerr << "Error finalizing SHA256 calculation" << std::endl;
return 1;
}
// Convert the byte array into a string
std::stringstream shastr;
shastr << std::hex << std::setfill('0');
for (auto &byte: result)
shastr << std::setw(2) << (int)byte;
sha = shastr.str();
return 0;
}
void AzureDev::get_fpga_serialNo(std::string &fpgaSerialNo)
{
std::string errmsg;
dev->sysfs_get("xmc", "serial_num", errmsg, fpgaSerialNo);
//fpgaSerialNo = "1281002AT024";
if (fpgaSerialNo.empty())
fpgaSerialNo = fpga_serial_number.at(index);
else if (fpga_serial_number.at(index).empty())
//save the serial in case the already saved is empty
fpga_serial_number.at(index) = fpgaSerialNo;
if (!errmsg.empty() || fpgaSerialNo.empty()) {
std::cerr << "get_fpga_serialNo warning(" << dev->sysfs_name << ")";
std::cerr << " sysfs errmsg: " << errmsg;
std::cerr << " serialNumber: " << fpga_serial_number.at(index);
std::cerr << std::endl;
}
}
void AzureDev::msleep(long msecs)
{
struct timespec ts;
ts.tv_sec = msecs / 1000;
ts.tv_nsec = (msecs % 1000) * 1000000;
nanosleep(&ts, NULL);
}
int AzureDev::goingTimeout()
{
struct timeval now;
gettimeofday(&now, NULL);
if (now.tv_sec - start.tv_sec > timeout_threshold)
return 1;
else
return 0;
}
| 33.783617 | 134 | 0.598957 | subeeshm-xilinx |
3bf3d4c5643ab1b27900d8db7c414af4c3cfb2c3 | 7,093 | cc | C++ | oss-internship-2020/libarchive/ld_preload_example/sapi_minitar.cc | Masud2017/sandboxed-api | 753eacd3142127c8bd493bc0e81242c4d3cd2f33 | [
"Apache-2.0"
] | 1,562 | 2019-03-07T10:02:53.000Z | 2022-03-31T17:43:05.000Z | oss-internship-2020/libarchive/ld_preload_example/sapi_minitar.cc | Masud2017/sandboxed-api | 753eacd3142127c8bd493bc0e81242c4d3cd2f33 | [
"Apache-2.0"
] | 70 | 2019-03-19T01:02:49.000Z | 2022-03-30T17:26:53.000Z | oss-internship-2020/libarchive/ld_preload_example/sapi_minitar.cc | Masud2017/sandboxed-api | 753eacd3142127c8bd493bc0e81242c4d3cd2f33 | [
"Apache-2.0"
] | 181 | 2019-03-18T19:41:30.000Z | 2022-03-29T13:08:26.000Z | // Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "sapi_minitar.h" // NOLINT(build/include)
#include <dlfcn.h>
#include <iostream>
#include <memory>
#include "libarchive_sapi.sapi.h" // NOLINT(build/include)
#include "sandbox.h" // NOLINT(build/include)
#include "sandboxed_api/var_array.h"
#include "sandboxed_api/var_ptr.h"
SapiLibarchiveSandboxExtract* sandbox_extract;
LibarchiveApi* api;
char* c_str_tmp = nullptr;
typedef void (*real_extract)(const char*, int, int, int);
void extract(const char* filename, int do_extract, int flags, int verbose) {
// Here we initialize the sandbox and other objects.
std::string tmp_dir;
if (do_extract) {
tmp_dir = CreateTempDirAtCWD().value();
}
std::string filename_absolute = MakeAbsolutePathAtCWD(filename);
// Initialize sandbox and api objects.
sandbox_extract =
new SapiLibarchiveSandboxExtract(filename_absolute, do_extract, tmp_dir);
CHECK(sandbox_extract->Init().ok()) << "Error during sandbox initialization";
api = new LibarchiveApi(sandbox_extract);
// After everything is set up, call the original function (next symbol).
// TODO getting the mangled name of the function at runtime does not work
// as intended. At the moment just use the symbol directly.
const char* y = "_Z7extractPKciii";
void* x = dlsym(RTLD_NEXT, y);
CHECK(x != nullptr) << "dlsym call could not find function symbol";
((real_extract)x)(filename_absolute.c_str(), do_extract, flags, verbose);
// clean up
if (c_str_tmp != nullptr) {
delete[] c_str_tmp;
}
// This is the last function called so we can delete the temporary directory
// here
if (do_extract) {
sandbox2::file_util::fileops::DeleteRecursively(tmp_dir);
}
delete api;
delete sandbox_extract;
}
archive* archive_read_new() {
archive* ret = api->archive_read_new().value();
CHECK(ret != nullptr) << "Failed to create archive";
return ret;
}
archive* archive_write_disk_new() {
archive* ret = api->archive_write_disk_new().value();
CHECK(ret != nullptr) << "Failed to create archive";
return ret;
}
int archive_write_disk_set_options(archive* ext, int flags) {
sapi::v::RemotePtr ext_ptr(ext);
return api->archive_write_disk_set_options(&ext_ptr, flags).value();
}
int archive_read_support_filter_bzip2(archive* a) {
sapi::v::RemotePtr a_ptr(a);
return api->archive_read_support_filter_bzip2(&a_ptr).value();
}
int archive_read_support_filter_gzip(archive* a) {
sapi::v::RemotePtr a_ptr(a);
return api->archive_read_support_filter_gzip(&a_ptr).value();
}
int archive_read_support_filter_compress(archive* a) {
sapi::v::RemotePtr a_ptr(a);
return api->archive_read_support_filter_compress(&a_ptr).value();
}
int archive_read_support_format_tar(archive* a) {
sapi::v::RemotePtr a_ptr(a);
return api->archive_read_support_format_tar(&a_ptr).value();
}
int archive_read_support_format_cpio(archive* a) {
sapi::v::RemotePtr a_ptr(a);
return api->archive_read_support_format_cpio(&a_ptr).value();
}
int archive_write_disk_set_standard_lookup(archive* ext) {
sapi::v::RemotePtr ext_ptr(ext);
return api->archive_write_disk_set_standard_lookup(&ext_ptr).value();
}
int archive_read_open_filename(archive* a, const char* _filename,
size_t _block_size) {
sapi::v::RemotePtr a_ptr(a);
return api
->archive_read_open_filename(
&a_ptr, sapi::v::ConstCStr(_filename).PtrBefore(), _block_size)
.value();
}
int archive_read_next_header(archive* a, archive_entry** entry) {
sapi::v::IntBase<archive_entry*> entry_ptr_tmp(0);
sapi::v::RemotePtr a_ptr(a);
int rc =
api->archive_read_next_header(&a_ptr, entry_ptr_tmp.PtrAfter()).value();
*entry = entry_ptr_tmp.GetValue();
return rc;
}
// In the following two functions we need to transfer a string from the
// sandboxed process to the client process. However, this string would
// go out of scope after this function so we use a global char * to make
// sure it does not get automatically deleted before it is used.
const char* archive_error_string(archive* a) {
sapi::v::RemotePtr a_ptr(a);
char* str = api->archive_error_string(&a_ptr).value();
CHECK(str != nullptr) << "Could not get error message";
std::string str_tmp =
sandbox_extract->GetCString(sapi::v::RemotePtr(str)).value();
if (c_str_tmp != nullptr) {
delete[] c_str_tmp;
}
c_str_tmp = new char[str_tmp.length() + 1];
strcpy(c_str_tmp, str_tmp.c_str()); // NOLINT(runtime/printf)
return c_str_tmp;
}
const char* archive_entry_pathname(archive_entry* entry) {
sapi::v::RemotePtr entry_ptr(entry);
char* str = api->archive_entry_pathname(&entry_ptr).value();
CHECK(str != nullptr) << "Could not get pathname";
std::string str_tmp =
sandbox_extract->GetCString(sapi::v::RemotePtr(str)).value();
if (c_str_tmp != nullptr) {
delete[] c_str_tmp;
}
c_str_tmp = new char[str_tmp.length() + 1];
strcpy(c_str_tmp, str_tmp.c_str()); // NOLINT(runtime/printf)
return c_str_tmp;
}
int archive_read_close(archive* a) {
sapi::v::RemotePtr a_ptr(a);
return api->archive_read_close(&a_ptr).value();
}
int archive_read_free(archive* a) {
sapi::v::RemotePtr a_ptr(a);
return api->archive_read_free(&a_ptr).value();
}
int archive_write_close(archive* a) {
sapi::v::RemotePtr a_ptr(a);
return api->archive_write_close(&a_ptr).value();
}
int archive_write_free(archive* a) {
sapi::v::RemotePtr a_ptr(a);
return api->archive_write_free(&a_ptr).value();
}
int archive_write_header(archive* a, archive_entry* entry) {
sapi::v::RemotePtr a_ptr(a), entry_ptr(entry);
return api->archive_write_header(&a_ptr, &entry_ptr).value();
}
int archive_read_data_block(archive* a, const void** buff, size_t* size,
la_int64_t* offset) {
sapi::v::IntBase<archive_entry*> buff_ptr_tmp(0);
sapi::v::ULLong size_tmp;
sapi::v::SLLong offset_tmp;
sapi::v::RemotePtr a_ptr(a);
int rv =
api->archive_read_data_block(&a_ptr, buff_ptr_tmp.PtrAfter(),
size_tmp.PtrAfter(), offset_tmp.PtrAfter())
.value();
*buff = buff_ptr_tmp.GetValue();
*size = size_tmp.GetValue();
*offset = offset_tmp.GetValue();
return rv;
}
la_ssize_t archive_write_data_block(archive* a, const void* buff, size_t s,
la_int64_t o) {
sapi::v::RemotePtr buff_ptr((void*)(buff));
sapi::v::RemotePtr a_ptr(a);
return api->archive_write_data_block(&a_ptr, &buff_ptr, s, o).value();
}
| 30.83913 | 79 | 0.706894 | Masud2017 |
0ec333d88d8ca89a5a47a2c7c339fc85387a464e | 182 | cpp | C++ | src/file_system/file_system__check_filename.cpp | violador/catalyst | 40d5c1dd04269a0764a9804711354a474bc43c15 | [
"Unlicense"
] | null | null | null | src/file_system/file_system__check_filename.cpp | violador/catalyst | 40d5c1dd04269a0764a9804711354a474bc43c15 | [
"Unlicense"
] | null | null | null | src/file_system/file_system__check_filename.cpp | violador/catalyst | 40d5c1dd04269a0764a9804711354a474bc43c15 | [
"Unlicense"
] | null | null | null | //
//
//
inline bool check_filename(const std::string &given_filename)
{
switch(given_filename == "")
{
case false: return false; break;
case true: return true; break;
}
};
| 15.166667 | 61 | 0.659341 | violador |
0ec3c653dab53860641ed1c5c71b385a30762af6 | 968 | cpp | C++ | cpp/src/kauvir/kcm-runtime-eval/kcm-env/kcm-env.cpp | Mosaic-DigammaDB/HandbookPragmatics | 55399bb16362f90e26626704f8563fd6d7c0a1f9 | [
"BSL-1.0"
] | 1 | 2019-04-15T08:44:13.000Z | 2019-04-15T08:44:13.000Z | cpp/src/kauvir/kcm-runtime-eval/kcm-env/kcm-env.cpp | Mosaic-DigammaDB/HandbookPragmatics | 55399bb16362f90e26626704f8563fd6d7c0a1f9 | [
"BSL-1.0"
] | null | null | null | cpp/src/kauvir/kcm-runtime-eval/kcm-env/kcm-env.cpp | Mosaic-DigammaDB/HandbookPragmatics | 55399bb16362f90e26626704f8563fd6d7c0a1f9 | [
"BSL-1.0"
] | null | null | null |
// Copyright Nathaniel Christen 2019.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "kcm-env.h"
#include "kcm-scopes/kcm-scope-system.h"
#include <QDebug>
KCM_Env::KCM_Env(Kauvir_Code_Model* kcm)
: scopes_(nullptr), kcm_(kcm), report_channel_group_fn_(nullptr),
kph_gen_fn_(nullptr)
{
}
void KCM_Env::report_channel_group(KCM_Channel_Group* kcg)
{
if(report_channel_group_fn_)
{
report_channel_group_fn_(kcm_, kcg);
}
}
void KCM_Env::kph_gen(KCM_Channel_Group* kcg, QString subs, QString fn,
QString* text, QMap<QString, QString> docus)
{
if(kph_gen_fn_)
{
kph_gen_fn_(kcm_, kcg, subs, fn, text, docus);
}
}
void KCM_Env::kph_gen(KCM_Channel_Group* kcg, QString fn,
QString* text, QMap<QString, QString> docus)
{
if(kph_gen_fn_)
{
kph_gen_fn_(kcm_, kcg, QString(), fn, text, docus);
}
}
| 21.043478 | 71 | 0.708678 | Mosaic-DigammaDB |
0ecb2863661e1ad57141ae94b59af8810513463c | 10,832 | cc | C++ | tests/utils/test_rsync.cc | pmarguinaud/eckit | 7df4be9a1cd8f4561de6d41b73d37838d78f13ea | [
"Apache-2.0"
] | null | null | null | tests/utils/test_rsync.cc | pmarguinaud/eckit | 7df4be9a1cd8f4561de6d41b73d37838d78f13ea | [
"Apache-2.0"
] | 14 | 2019-09-30T19:24:29.000Z | 2020-10-15T16:02:11.000Z | tests/utils/test_rsync.cc | pmarguinaud/eckit | 7df4be9a1cd8f4561de6d41b73d37838d78f13ea | [
"Apache-2.0"
] | 2 | 2019-10-17T13:52:08.000Z | 2019-11-25T14:53:52.000Z | /*
* (C) Copyright 2020- ECMWF.
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
* In applying this licence, ECMWF does not waive the privileges and immunities
* granted to it by virtue of its status as an intergovernmental organisation nor
* does it submit to any jurisdiction.
*/
#include <fstream>
#include <memory>
#include <string>
#include <librsync.h>
#include "eckit/config/LibEcKit.h"
#include "eckit/exception/Exceptions.h"
#include "eckit/filesystem/LocalPathName.h"
#include "eckit/filesystem/PathName.h"
#include "eckit/filesystem/TmpFile.h"
#include "eckit/io/DataHandle.h"
#include "eckit/io/MemoryHandle.h"
#include "eckit/io/StdFile.h"
#include "eckit/log/Log.h"
#include "eckit/utils/Rsync.h"
#include "eckit/testing/Test.h"
using namespace eckit;
using namespace eckit::testing;
namespace eckit {
namespace test {
static void remove_dir_recursive(const PathName& dir) {
if (not dir.exists())
return;
ASSERT(dir.isDir());
std::vector<PathName> files;
std::vector<PathName> dirs;
dir.childrenRecursive(files, dirs);
for (const auto& file : files) {
file.unlink();
}
for (auto d = dirs.rbegin(); d != dirs.rend(); ++d) {
d->rmdir();
}
dir.rmdir();
}
static bool same_contents(const PathName& left, const PathName& right) {
std::unique_ptr<DataHandle> lhs(left.fileHandle());
std::unique_ptr<DataHandle> rhs(right.fileHandle());
return rhs->compare(*lhs);
}
static bool same_dir(const PathName& left, const PathName& right) {
std::vector<PathName> lfiles;
std::vector<PathName> ldirs;
left.childrenRecursive(lfiles, ldirs);
Log::debug<LibEcKit>() << "left files " << lfiles << std::endl;
Log::debug<LibEcKit>() << "left dirs " << ldirs << std::endl;
std::vector<PathName> rfiles;
std::vector<PathName> rdirs;
right.childrenRecursive(rfiles, rdirs);
Log::debug<LibEcKit>() << "right files " << rfiles << std::endl;
Log::debug<LibEcKit>() << "right dirs " << rdirs << std::endl;
if (rfiles.size() != lfiles.size() or rdirs.size() != ldirs.size())
return false;
// compare files
{
std::vector<PathName>::const_iterator riter = rfiles.begin();
std::vector<PathName>::const_iterator liter = lfiles.begin();
for (; riter != rfiles.end(); ++riter, ++liter) {
LocalPathName rhs = LocalPathName(*riter).relativePath(right.localPath());
LocalPathName lhs = LocalPathName(*liter).relativePath(left.localPath());
Log::debug<LibEcKit>() << "comparing files " << lhs << " to " << rhs << std::endl;
if (rhs != lhs)
return false;
if (not same_contents(*liter, *riter))
return false;
}
}
// compare dirs
{
std::vector<PathName>::const_iterator riter = rdirs.begin();
std::vector<PathName>::const_iterator liter = ldirs.begin();
for (; riter != rdirs.end(); ++riter, ++liter) {
LocalPathName rhs = LocalPathName(*riter).relativePath(right.localPath());
LocalPathName lhs = LocalPathName(*liter).relativePath(left.localPath());
Log::debug<LibEcKit>() << "comparing dirs " << lhs << " to " << rhs << std::endl;
if (rhs != lhs)
return false;
}
}
return true;
}
static void fill(const PathName& path, const std::string& msg) {
std::ofstream ofs(path.localPath());
ofs << msg << std::endl;
}
CASE("File sync") {
Rsync rsync;
PathName source = PathName::unique(PathName(LocalPathName::cwd()) / "test");
PathName target = PathName::unique(PathName(LocalPathName::cwd()) / "test");
SECTION("File sync to inexistent target") {
fill(source, "The quick brown fox jumps over the lazy dog");
EXPECT_NO_THROW(rsync.syncData(source, target));
EXPECT(same_contents(source, target));
}
SECTION("File sync from empty file ") {
source.touch();
fill(target, "The quick brown fox jumps over the lazy dog");
EXPECT_NO_THROW(rsync.syncData(source, target));
EXPECT(same_contents(source, target));
}
SECTION("File sync to existing empty file") {
fill(source, "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.");
target.touch();
EXPECT_NO_THROW(rsync.syncData(source, target));
EXPECT(same_contents(source, target));
}
SECTION("Delta in the begining") {
fill(source,
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was "
"born and I will give you a complete account of the system...");
fill(target,
"He should complain to you how all this mistaken idea of denouncing pleasure and praising pain was "
"born and I will give you a complete account of the system...");
EXPECT_NO_THROW(rsync.syncData(source, target));
EXPECT(same_contents(source, target));
}
SECTION("Delta in the middle") {
fill(source,
"One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed "
"into a horrible vermin.");
fill(target, "One morning transformed in his bed into a horrible vermin.");
EXPECT_NO_THROW(rsync.syncData(source, target));
EXPECT(same_contents(source, target));
}
SECTION("Delta at the end") {
fill(source, "The quick brown fox jumps over the lazy dog.");
fill(target, "The quick brown fox jumps over the curious duck.");
EXPECT_NO_THROW(rsync.syncData(source, target));
EXPECT(same_contents(source, target));
}
SECTION("Source file doesnt exist") {
// no source
fill(target, "The quick brown fox jumps over the curious duck.");
EXPECT_THROWS_AS(rsync.syncData(source, target), eckit::CantOpenFile);
}
if (source.exists())
source.unlink();
if (target.exists())
target.unlink();
}
CASE("Directory sync") {
Rsync rsync;
// fill in source dirctory
PathName source = PathName::unique(PathName(LocalPathName::cwd()) / "rsync" / "source");
source.mkdir();
PathName d1 = source / "dir1";
d1.mkdir();
PathName d2 = source / "dir2";
d2.mkdir();
PathName d23 = d2 / "dir23";
d23.mkdir();
PathName target = PathName::unique(PathName(LocalPathName::cwd()) / "rsync" / "target");
SECTION("Sync empty dirs") {
EXPECT_NO_THROW(rsync.syncRecursive(source, target));
EXPECT(same_dir(source, target));
}
SECTION("Sync full dirs") {
PathName f1d1 = d1 / "f1"; fill(f1d1, "F1D1");
PathName f2d1 = d1 / "f2"; fill(f2d1, "F2D1");
PathName f3d1 = d1 / "f3"; fill(f3d1, "F3D1");
PathName f1d2 = d2 / "f1"; fill(f1d2, "F1D2");
PathName f2d2 = d2 / "f2"; fill(f2d2, "F2D2");
PathName f1d23 = d23 / "f1"; fill(f1d23, "F1D23");
PathName d234 = d23 / "dir234";
d234.mkdir();
PathName d12 = d1 / "dir12";
d12.mkdir();
EXPECT_NO_THROW(rsync.syncRecursive(source, target));
EXPECT(same_dir(source, target));
}
SECTION("Sync dirs with update") {
PathName f1d1 = d1 / "f1"; fill(f1d1, "F1D1bis");
EXPECT_NO_THROW(rsync.syncRecursive(source, target));
EXPECT(same_dir(source, target));
}
remove_dir_recursive(target);
remove_dir_recursive(source);
}
CASE("DataHandle operations") {
Rsync rsync;
PathName source = PathName::unique(PathName(LocalPathName::cwd()) / "test");
PathName target = PathName::unique(PathName(LocalPathName::cwd()) / "test");
PathName signature = PathName::unique(PathName(LocalPathName::cwd()) / "test");
PathName delta = PathName::unique(PathName(LocalPathName::cwd()) / "test");
PathName patched = PathName::unique(PathName(LocalPathName::cwd()) / "test");
fill(source,
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was "
"born and I will give you a complete account of the system...");
fill(target,
"He should complain to you how all this mistaken idea of denouncing pleasure and praising pain was "
"born and I will give you a complete account of the system...");
{
AutoStdFile tgt(target);
AutoStdFile sig(signature, "w");
ASSERT(rs_sig_file(tgt, sig, RS_DEFAULT_BLOCK_LEN, 0, RS_RK_BLAKE2_SIG_MAGIC, nullptr) == RS_DONE);
}
{
AutoStdFile sigf(signature);
rs_signature_t* sig;
ASSERT(rs_loadsig_file(sigf, &sig, nullptr) == RS_DONE);
ASSERT(rs_build_hash_table(sig) == RS_DONE);
AutoStdFile src(source);
AutoStdFile dlt(delta, "w");
ASSERT(rs_delta_file(sig, src, dlt, nullptr) == RS_DONE);
}
{
AutoStdFile tgt(target);
AutoStdFile dlt(delta);
AutoStdFile patch(patched, "w");
ASSERT(rs_patch_file(tgt, dlt, patch, nullptr) == RS_DONE);
}
SECTION("Compute signature") {
std::unique_ptr<DataHandle> in(target.fileHandle());
in->openForRead();
MemoryHandle out;
out.openForWrite(0);
EXPECT_NO_THROW(rsync.computeSignature(*in, out));
std::unique_ptr<DataHandle> ref(signature.fileHandle());
EXPECT(ref->compare(out));
}
SECTION("Compute delta") {
std::unique_ptr<DataHandle> in(source.fileHandle());
in->openForRead();
std::unique_ptr<DataHandle> sig(signature.fileHandle());
sig->openForRead();
MemoryHandle out;
out.openForWrite(0);
EXPECT_NO_THROW(rsync.computeDelta(*sig, *in, out));
std::unique_ptr<DataHandle> ref(delta.fileHandle());
EXPECT(ref->compare(out));
}
SECTION("Update data") {
std::unique_ptr<DataHandle> in(target.fileHandle());
in->openForRead();
std::unique_ptr<DataHandle> dlt(delta.fileHandle());
dlt->openForRead();
MemoryHandle out;
out.openForWrite(0);
EXPECT_NO_THROW(rsync.updateData(*in, *dlt, out));
std::unique_ptr<DataHandle> ref(patched.fileHandle());
EXPECT(ref->compare(out));
}
if (source.exists())
source.unlink();
if (target.exists())
target.unlink();
if (signature.exists())
signature.unlink();
if (delta.exists())
delta.unlink();
if (patched.exists())
patched.unlink();
}
} // end namespace test
} // end namespace eckit
int main(int argc, char* argv[]) {
return run_tests(argc, argv);
}
| 30.860399 | 116 | 0.622692 | pmarguinaud |
0ecc2d628737cbf353fe4bf452b728e984ed017e | 1,045 | cpp | C++ | interface/src/ui/overlays/TextOverlay.cpp | overte-org/overte | 95ebe6bab0d5ff9707971f19051177110e274b3d | [
"Apache-2.0"
] | 4 | 2022-02-04T05:20:36.000Z | 2022-02-22T11:40:28.000Z | interface/src/ui/overlays/TextOverlay.cpp | overte-org/overte | 95ebe6bab0d5ff9707971f19051177110e274b3d | [
"Apache-2.0"
] | 38 | 2022-01-18T21:55:11.000Z | 2022-03-30T21:34:23.000Z | interface/src/ui/overlays/TextOverlay.cpp | overte-org/overte | 95ebe6bab0d5ff9707971f19051177110e274b3d | [
"Apache-2.0"
] | 7 | 2022-01-20T00:49:35.000Z | 2022-03-24T21:41:00.000Z | //
// TextOverlay.cpp
// interface/src/ui/overlays
//
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "TextOverlay.h"
#include <QQuickItem>
#include <QFontMetrics>
#include "FontFamilies.h"
QString const TextOverlay::TYPE = "text";
QUrl const TextOverlay::URL(QString("hifi/overlays/TextOverlay.qml"));
TextOverlay::TextOverlay() : QmlOverlay(URL) { }
TextOverlay::TextOverlay(const TextOverlay* textOverlay)
: QmlOverlay(URL, textOverlay) {
}
TextOverlay* TextOverlay::createClone() const {
return new TextOverlay(this);
}
QSizeF TextOverlay::textSize(const QString& text) const {
int lines = 1;
foreach(QChar c, text) {
if (c == QChar('\n')) {
++lines;
}
}
QFont font(ROBOTO_FONT_FAMILY);
font.setPixelSize(18);
QFontMetrics fm(font);
QSizeF result = QSizeF(fm.horizontalAdvance(text), 18 * lines);
return result;
} | 24.302326 | 88 | 0.683254 | overte-org |
0ecff1e2703d5aac30651261e1e3fcf7354e8ede | 10,979 | cpp | C++ | Nacro/SDK/FN_InfoEntry_functions.cpp | Milxnor/Nacro | eebabf662bbce6d5af41820ea0342d3567a0aecc | [
"BSD-2-Clause"
] | 11 | 2021-08-08T23:25:10.000Z | 2022-02-19T23:07:22.000Z | Nacro/SDK/FN_InfoEntry_functions.cpp | Milxnor/Nacro | eebabf662bbce6d5af41820ea0342d3567a0aecc | [
"BSD-2-Clause"
] | 1 | 2021-08-11T18:40:26.000Z | 2021-08-11T18:40:26.000Z | Nacro/SDK/FN_InfoEntry_functions.cpp | Milxnor/Nacro | eebabf662bbce6d5af41820ea0342d3567a0aecc | [
"BSD-2-Clause"
] | 8 | 2021-08-09T13:51:54.000Z | 2022-01-26T20:33:37.000Z | // Fortnite (1.8) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "../SDK.hpp"
namespace SDK
{
//---------------------------------------------------------------------------
//Functions
//---------------------------------------------------------------------------
// Function InfoEntry.InfoEntry_C.DoesItemHaveChildren
// (Event, Public, HasOutParms, BlueprintCallable, BlueprintEvent, BlueprintPure, Const)
// Parameters:
// int ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
int UInfoEntry_C::DoesItemHaveChildren()
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.DoesItemHaveChildren");
UInfoEntry_C_DoesItemHaveChildren_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
return params.ReturnValue;
}
// Function InfoEntry.InfoEntry_C.GetIndentLevel
// (Event, Public, HasOutParms, BlueprintCallable, BlueprintEvent, BlueprintPure, Const)
// Parameters:
// int ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
int UInfoEntry_C::GetIndentLevel()
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.GetIndentLevel");
UInfoEntry_C_GetIndentLevel_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
return params.ReturnValue;
}
// Function InfoEntry.InfoEntry_C.IsItemExpanded
// (Event, Public, HasOutParms, BlueprintCallable, BlueprintEvent, BlueprintPure, Const)
// Parameters:
// bool ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
bool UInfoEntry_C::IsItemExpanded()
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.IsItemExpanded");
UInfoEntry_C_IsItemExpanded_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
return params.ReturnValue;
}
// Function InfoEntry.InfoEntry_C.GetData
// (Event, Public, HasOutParms, BlueprintCallable, BlueprintEvent, BlueprintPure, Const)
// Parameters:
// class UObject* ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
class UObject* UInfoEntry_C::GetData()
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.GetData");
UInfoEntry_C_GetData_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
return params.ReturnValue;
}
// Function InfoEntry.InfoEntry_C.OnAcquireFromPool
// (Event, Protected, BlueprintEvent)
void UInfoEntry_C::OnAcquireFromPool()
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.OnAcquireFromPool");
UInfoEntry_C_OnAcquireFromPool_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function InfoEntry.InfoEntry_C.OnReleaseToPool
// (Event, Protected, BlueprintEvent)
void UInfoEntry_C::OnReleaseToPool()
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.OnReleaseToPool");
UInfoEntry_C_OnReleaseToPool_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function InfoEntry.InfoEntry_C.Private_OnExpanderArrowShiftClicked
// (Event, Public, BlueprintCallable, BlueprintEvent)
void UInfoEntry_C::Private_OnExpanderArrowShiftClicked()
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.Private_OnExpanderArrowShiftClicked");
UInfoEntry_C_Private_OnExpanderArrowShiftClicked_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function InfoEntry.InfoEntry_C.RegisterOnClicked
// (Event, Public, HasOutParms, BlueprintCallable, BlueprintEvent)
// Parameters:
// struct FScriptDelegate Callback (ConstParm, Parm, OutParm, ZeroConstructor, ReferenceParm)
void UInfoEntry_C::RegisterOnClicked(const struct FScriptDelegate& Callback)
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.RegisterOnClicked");
UInfoEntry_C_RegisterOnClicked_Params params;
params.Callback = Callback;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function InfoEntry.InfoEntry_C.SetExpanded
// (Event, Public, BlueprintCallable, BlueprintEvent)
// Parameters:
// bool bExpanded (Parm, ZeroConstructor, IsPlainOldData)
void UInfoEntry_C::SetExpanded(bool bExpanded)
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.SetExpanded");
UInfoEntry_C_SetExpanded_Params params;
params.bExpanded = bExpanded;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function InfoEntry.InfoEntry_C.SetIndexInList
// (Event, Public, BlueprintCallable, BlueprintEvent)
// Parameters:
// int InIndexInList (Parm, ZeroConstructor, IsPlainOldData)
void UInfoEntry_C::SetIndexInList(int InIndexInList)
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.SetIndexInList");
UInfoEntry_C_SetIndexInList_Params params;
params.InIndexInList = InIndexInList;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function InfoEntry.InfoEntry_C.SetSelected
// (Event, Public, BlueprintCallable, BlueprintEvent)
// Parameters:
// bool bSelected (Parm, ZeroConstructor, IsPlainOldData)
void UInfoEntry_C::SetSelected(bool bSelected)
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.SetSelected");
UInfoEntry_C_SetSelected_Params params;
params.bSelected = bSelected;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function InfoEntry.InfoEntry_C.ToggleExpansion
// (Event, Public, BlueprintCallable, BlueprintEvent)
void UInfoEntry_C::ToggleExpansion()
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.ToggleExpansion");
UInfoEntry_C_ToggleExpansion_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function InfoEntry.InfoEntry_C.Reset
// (Event, Public, BlueprintCallable, BlueprintEvent)
void UInfoEntry_C::Reset()
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.Reset");
UInfoEntry_C_Reset_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function InfoEntry.InfoEntry_C.Construct
// (BlueprintCosmetic, Event, Public, BlueprintEvent)
void UInfoEntry_C::Construct()
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.Construct");
UInfoEntry_C_Construct_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function InfoEntry.InfoEntry_C.SetData
// (Event, Public, BlueprintCallable, BlueprintEvent)
// Parameters:
// class UObject* InData (Parm, ZeroConstructor, IsPlainOldData)
// class UCommonListView* OwningList (Parm, ZeroConstructor, IsPlainOldData)
void UInfoEntry_C::SetData(class UObject* InData, class UCommonListView* OwningList)
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.SetData");
UInfoEntry_C_SetData_Params params;
params.InData = InData;
params.OwningList = OwningList;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function InfoEntry.InfoEntry_C.BndEvt__IconTextButton_K2Node_ComponentBoundEvent_34_CommonButtonClicked__DelegateSignature
// (BlueprintEvent)
// Parameters:
// class UCommonButton* Button (Parm, ZeroConstructor, IsPlainOldData)
void UInfoEntry_C::BndEvt__IconTextButton_K2Node_ComponentBoundEvent_34_CommonButtonClicked__DelegateSignature(class UCommonButton* Button)
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.BndEvt__IconTextButton_K2Node_ComponentBoundEvent_34_CommonButtonClicked__DelegateSignature");
UInfoEntry_C_BndEvt__IconTextButton_K2Node_ComponentBoundEvent_34_CommonButtonClicked__DelegateSignature_Params params;
params.Button = Button;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function InfoEntry.InfoEntry_C.BndEvt__IconTextButton_K2Node_ComponentBoundEvent_61_CommonButtonClicked__DelegateSignature
// (BlueprintEvent)
// Parameters:
// class UCommonButton* Button (Parm, ZeroConstructor, IsPlainOldData)
void UInfoEntry_C::BndEvt__IconTextButton_K2Node_ComponentBoundEvent_61_CommonButtonClicked__DelegateSignature(class UCommonButton* Button)
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.BndEvt__IconTextButton_K2Node_ComponentBoundEvent_61_CommonButtonClicked__DelegateSignature");
UInfoEntry_C_BndEvt__IconTextButton_K2Node_ComponentBoundEvent_61_CommonButtonClicked__DelegateSignature_Params params;
params.Button = Button;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function InfoEntry.InfoEntry_C.ExecuteUbergraph_InfoEntry
// ()
// Parameters:
// int EntryPoint (Parm, ZeroConstructor, IsPlainOldData)
void UInfoEntry_C::ExecuteUbergraph_InfoEntry(int EntryPoint)
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.ExecuteUbergraph_InfoEntry");
UInfoEntry_C_ExecuteUbergraph_InfoEntry_Params params;
params.EntryPoint = EntryPoint;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function InfoEntry.InfoEntry_C.Entry Selected__DelegateSignature
// (Public, Delegate, BlueprintCallable, BlueprintEvent)
// Parameters:
// class UFortItemDefinition* Entry_Item_Definition (Parm, ZeroConstructor, IsPlainOldData)
void UInfoEntry_C::Entry_Selected__DelegateSignature(class UFortItemDefinition* Entry_Item_Definition)
{
static auto fn = UObject::FindObject<UFunction>("Function InfoEntry.InfoEntry_C.Entry Selected__DelegateSignature");
UInfoEntry_C_Entry_Selected__DelegateSignature_Params params;
params.Entry_Item_Definition = Entry_Item_Definition;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| 28.296392 | 175 | 0.747245 | Milxnor |
0ed1ffdf868cf267101c359387e152933808e825 | 5,076 | cpp | C++ | Core/Graphics/Window.cpp | ShuboshaKuro/SimpleGameEngine | 01da061fe931ec0ade898b82baa93c591eacbb43 | [
"MIT"
] | null | null | null | Core/Graphics/Window.cpp | ShuboshaKuro/SimpleGameEngine | 01da061fe931ec0ade898b82baa93c591eacbb43 | [
"MIT"
] | null | null | null | Core/Graphics/Window.cpp | ShuboshaKuro/SimpleGameEngine | 01da061fe931ec0ade898b82baa93c591eacbb43 | [
"MIT"
] | null | null | null | #include "Window.hpp"
namespace Core {
namespace Graphics {
void error_callback(GLint, const GLchar*);
void windowResize_callback(GLFWwindow*, GLint, GLint);
Window::Window(const GLchar* title, GLint width, GLint height, glm::vec4 clearColor)
: title(title), width(width), height(height), clearColor(clearColor) {
if (!init()) {
ERROR("Failed to init Window!");
glfwTerminate();
}
}
Window::~Window() {
glfwTerminate();
delete waterFBO;
}
void Window::update(Terrain::WorldTree* wt, Terrain::Skybox* skybox, Camera*& camera) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Terrain::Chunk* currentChunk = wt->getCurrentChunk();
view = camera->updateCamera(currentChunk);
vec3 cameraPosition = camera->getCameraPosition();
GLdouble currentTime = glfwGetTime();
frames++;
if (currentTime - lastTime >= 1.0) {
DEBUG_F("%d Frames/sec\n", frames);
frames = 0; lastTime += 1.0;
}
// Draw Skybox
skybox->getSkyboxBlock()->draw(cameraPosition, view, projection, camera);
wt->checkAndLoad();
#if 0
float distAsWaterMirror = 2 * (cameraPosition.y - (-CHUNK_SIZE_Y + WATERLEVEL));
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, waterFBO->getReflectionTexture());
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, waterFBO->getRefractionTexture());
glEnable(GL_CLIP_PLANE0);
waterFBO->bindReflectionFBO();
camera->getCameraPosition().y -= distAsWaterMirror;
for (int i = 0; i < WORLDSIZE; i++)
for (int j = 0; j < WORLDSIZE; j++)
wt->getChunks()[i][j]->draw(projection, view, vec4(0, -1, 0, -(CHUNK_SIZE_Y - WATERLEVEL)), WATERLEVEL, 0, camera, Terrain::TerrainType::LAND);
camera->getCameraPosition().y += distAsWaterMirror;
waterFBO->unbindFBO();
waterFBO->bindRefractionFBO();
for (int i = 0; i < WORLDSIZE; i++)
for (int j = 0; j < WORLDSIZE; j++)
wt->getChunks()[i][j]->draw(projection, view, vec4(0, 1, 0, -(CHUNK_SIZE_Y - WATERLEVEL)), 0, CHUNK_SIZE_Y - WATERLEVEL, camera, Terrain::TerrainType::LAND);
waterFBO->unbindFBO();
glDisable(GL_CLIP_PLANE0);
wt->getContext()->getTexture()->bind(GL_TEXTURE_2D, 0);
#endif
// Draw Chunks
for (int i = 0; i < WORLDSIZE; i++)
for (int j = 0; j < WORLDSIZE; j++)
wt->getChunks()[i][j]->draw(projection, view, vec4(0), 0, 0, camera, Terrain::TerrainType::LAND);
for (int i = 0; i < WORLDSIZE; i++)
for (int j = 0; j < WORLDSIZE; j++)
wt->getChunks()[i][j]->draw(projection, view, vec4(0), 0, 0, camera, Terrain::TerrainType::WATER);
glfwSwapBuffers(window);
glfwPollEvents();
}
GLboolean Window::closed() const {
return glfwWindowShouldClose(window);
}
void Window::setButtonCallback(GLFWmousebuttonfun func) {
glfwSetMouseButtonCallback(window, func);
}
void Window::setKeyCallback(GLFWkeyfun func) {
glfwSetKeyCallback(window, func);
}
GLboolean Window::init() {
// Initializes GLFW
if (!glfwInit()) {
ERROR("Failed to initialize GLFW\n");
return GL_FALSE;
}
// Error-Handling
glfwSetErrorCallback(error_callback);
// GLFW-Settings
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Creates GLFW-Window
window = glfwCreateWindow(width, height, title, NULL, NULL);
// Checks if GLFW-Window was successfully created
if (!window) {
glfwTerminate();
ERROR("Failed to create window\n");
return GL_FALSE;
}
// sets context
glfwMakeContextCurrent(window);
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
// Initializes glew
glewExperimental = GL_TRUE;
if (glewInit() != GLEW_OK) {
ERROR("Failed to initialize GLEW\n");
return GL_FALSE;
}
INFO(glfwGetVersionString());
INFO(glGetString(GL_VERSION));
glClearColor(clearColor.x, clearColor.y, clearColor.z, clearColor.w);
glfwSetWindowUserPointer(window, this);
glfwSetWindowSizeCallback(window, windowResize_callback);
glFrontFace(GL_CCW);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glfwSwapInterval(0);
// Initializes shader
Shader::init();
// Enables Depth-Testing
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
//glShadeModel(GL_FLAT);
// Sets projectionmatrix
projection = perspective(radians(45.0f), 4.0f / 3.0f, 0.1f, 140.0f);
lastTime = glfwGetTime();
waterFBO = new WaterFBO;
return GL_TRUE;
}
void error_callback(int error, const GLchar* description) {
ERROR(description);
}
void windowResize_callback(GLFWwindow* window, GLint width, GLint height) {
// Gets pointer to the GLFW-Window
Window* _window = (Window*)glfwGetWindowUserPointer(window);
_window->setWidth(width);
_window->setHeight(height);
DEBUG(_window->getWidth());
DEBUG(_window->getHeight());
}
}
} | 29.34104 | 162 | 0.685973 | ShuboshaKuro |
0ed33a9f1cce268d4e58bd03fb3ff57a284df8de | 302 | cpp | C++ | engine/softbreeze/math/vector4.cpp | ffskyfan/softbreeze | 18996a4146eb73b2823381430763b8886dead87b | [
"MIT"
] | null | null | null | engine/softbreeze/math/vector4.cpp | ffskyfan/softbreeze | 18996a4146eb73b2823381430763b8886dead87b | [
"MIT"
] | null | null | null | engine/softbreeze/math/vector4.cpp | ffskyfan/softbreeze | 18996a4146eb73b2823381430763b8886dead87b | [
"MIT"
] | null | null | null |
#include "../softbreeze.h"
#include "vector4.h"
softbreeze_namespace_beg
void Vector4::Lerp( const Vector4 &v1, const Vector4 &v2, const float l )
{
if(l <= 0.0f) {
(*this) = v1;
} else if (l >=1.0){
(*this) = v2;
} else {
(*this) = v1 + l*( v2 - v1 );
}
}
softbreeze_namespace_end
| 12.08 | 73 | 0.586093 | ffskyfan |
0ed3ba57cc0b0b9dd74e50d948fd037bb19f81bf | 3,563 | cpp | C++ | test/bench_hom_nand.cpp | watagashi0619/TFHE | 392c06812edd3ccfa56099fbacb8428fbc1fc277 | [
"MIT"
] | 3 | 2021-08-11T05:36:05.000Z | 2021-12-29T06:26:30.000Z | test/bench_hom_nand.cpp | watagashi0619/TFHE | 392c06812edd3ccfa56099fbacb8428fbc1fc277 | [
"MIT"
] | 1 | 2021-09-13T12:53:43.000Z | 2021-09-19T04:12:41.000Z | test/bench_hom_nand.cpp | watagashi0619/TFHE | 392c06812edd3ccfa56099fbacb8428fbc1fc277 | [
"MIT"
] | null | null | null | #include <array>
#include <cassert>
#include <chrono>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <random>
#include "bootstrapping_key.hpp"
#include "gatebootstrapping.hpp"
#include "hom_nand.hpp"
#include "identity_key_switching.hpp"
#include "key.hpp"
#include "key_switching_key.hpp"
#include "params.hpp"
#include "tlwe.hpp"
#include "util.hpp"
using namespace TFHE;
// benchmark test
void bench_hom_nand() {
std::chrono::system_clock::time_point startup_time, finish_time;
startup_time = std::chrono::system_clock::now();
time_t t = std::chrono::system_clock::to_time_t(startup_time);
tm* lt = std::localtime(&t);
constexpr size_t round_iter = 25;
constexpr size_t patterns = 4;
constexpr size_t iter_count = round_iter * patterns;
std::ofstream ofs("bench_hom_nand.log");
std::cout.rdbuf(ofs.rdbuf());
std::cout << "Hom NAND benchmark test: " << iter_count << " iterations" << std::endl;
std::cout << "This is the measurement time for Hom NAND calculation only." << std::endl;
std::cout << "startup: " << std::put_time(lt, "%c") << std::endl;
std::cout << "============================================================" << std::endl;
std::cout << "iter_count\ta|b|HOM_NAND(a,b)\telapsed[ms]" << std::endl;
std::array<double, iter_count> elapseds;
for(size_t i = 0; i < iter_count; i++) {
// secret key
secret_key skey;
// bootstrapping key (note: require a lot of memory)
std::unique_ptr<bootstrapping_key> bkey;
bkey = std::make_unique<bootstrapping_key>(skey);
// key switching key (note: require a lot of memory)
std::unique_ptr<key_switching_key> ks;
ks = std::make_unique<key_switching_key>(skey);
// set messages
bool a = 1 & ((i / round_iter) >> 1);
bool b = 1 & ((i / round_iter) >> 0);
// input tlwe_lvl0
tlwe_lvl0 tlwe_a = tlwe_lvl0::encrypt_binary(skey, a);
tlwe_lvl0 tlwe_b = tlwe_lvl0::encrypt_binary(skey, b);
std::chrono::system_clock::time_point start, end;
// timer start
start = std::chrono::system_clock::now();
// hom nand
tlwe_lvl0 res = hom_nand(tlwe_a, tlwe_b, *bkey, *ks);
// timer stop
end = std::chrono::system_clock::now();
elapseds[i] = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
// show result
assert((tlwe_a.decrypt_binary(skey) & tlwe_b.decrypt_binary(skey)) != res.decrypt_binary(skey));
std::cout << std::setfill('0') << std::right << std::setw(3) << i + 1 << "\t";
std::cout << tlwe_a.decrypt_binary(skey) << "|" << tlwe_b.decrypt_binary(skey) << "|" << res.decrypt_binary(skey) << "\t" << elapseds[i] << std::endl;
}
double mean = 0;
for(size_t i = 0; i < iter_count; i++) {
mean += elapseds[i];
}
mean /= iter_count;
double std = 0;
for(size_t i = 0; i < iter_count; i++) {
std += (elapseds[i] - mean) * (elapseds[i] - mean);
}
std /= iter_count;
std = sqrt(std);
std::cout << "============================================================" << std::endl;
std::cout << "mean: " << mean << "[ms]" << std::endl;
std::cout << "std: " << std << "[ms]" << std::endl;
finish_time = std::chrono::system_clock::now();
t = std::chrono::system_clock::to_time_t(finish_time);
lt = std::localtime(&t);
std::cout << "finish: " << std::put_time(lt, "%c") << std::endl;
}
int main() {
bench_hom_nand();
}
| 34.592233 | 158 | 0.584339 | watagashi0619 |
0ed5f4e8d5016aab53b838e80e4ff252f81c4c1a | 4,214 | cpp | C++ | packages/ECS/source/common/component/CComponentFactoryManager.cpp | jesuslou/LouEngine | 873585baa603b6ee1032af9a6d3648a4c8bb19c8 | [
"Zlib"
] | null | null | null | packages/ECS/source/common/component/CComponentFactoryManager.cpp | jesuslou/LouEngine | 873585baa603b6ee1032af9a6d3648a4c8bb19c8 | [
"Zlib"
] | null | null | null | packages/ECS/source/common/component/CComponentFactoryManager.cpp | jesuslou/LouEngine | 873585baa603b6ee1032af9a6d3648a4c8bb19c8 | [
"Zlib"
] | null | null | null | ////////////////////////////////////////////////////////////
//
// LouEngine - Multiplatform Game Engine Project
// Copyright (C) 2016-2017 Jesus Lou ([email protected])
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#pragma once
#include <component/CComponentFactoryManager.h>
#include <cassert>
CComponent* CComponentFactoryManager::CreateComponent(CStrID componentNameId)
{
IComponentFactory* factory = GetFactoryByName(componentNameId);
if (factory)
{
return factory->CreateComponent();
}
return nullptr;
}
CComponent* CComponentFactoryManager::CloneComponent(CComponent* component, int componentIdx)
{
IComponentFactory* factory = GetFactoryByIndex(componentIdx);
if (factory)
{
return factory->CloneComponent(component);
}
return nullptr;
}
void CComponentFactoryManager::CloneComponents(std::vector<CComponent*>& src, std::vector<CComponent*>& dst)
{
assert(src.size() == dst.size());
for (std::size_t i = 0; i < src.size(); ++i)
{
dst[i] = CloneComponent(src[i], i);
}
}
CComponent* CComponentFactoryManager::AddComponent(CStrID componentNameId, std::vector<CComponent*>& components)
{
int factoryIdx = GetFactoryIndexByName(componentNameId);
if (factoryIdx >= 0)
{
IComponentFactory* factory = GetFactoryByIndex(factoryIdx);
if (factory && components[factoryIdx] == nullptr)
{
components[factoryIdx] = factory->CreateComponent();
return components[factoryIdx];
}
}
return nullptr;
}
CComponent* CComponentFactoryManager::Get(std::size_t componentTypeIdx, int index, int version)
{
if (componentTypeIdx < m_factories.size())
{
IComponentFactory* factory = m_factories[componentTypeIdx].m_address;
if (factory)
{
return factory->GetByIdxAndVersion(index, version);
}
}
return nullptr;
}
CHandle CComponentFactoryManager::SetHandleInfoFromComponent(CComponent* component)
{
CHandle handle;
for (std::size_t i = 0; i < m_factories.size(); ++i)
{
if (m_factories[i].m_address->SetHandleInfoFromComponent(component, handle))
{
handle.m_componentIdx = i;
}
}
return handle;
}
int CComponentFactoryManager::GetPositionForElement(CComponent* component)
{
for (std::size_t i = 0; i < m_factories.size(); ++i)
{
int pos = m_factories[i].m_address->GetComponentPosition(component);
if (pos >= 0)
{
return pos;
}
}
return -1;
}
bool CComponentFactoryManager::DestroyComponent(CComponent** component)
{
for (std::size_t i = 0; i < m_factories.size(); ++i)
{
(*component)->Destroy();
if (m_factories[i].m_address->DestroyComponent(*component))
{
*component = nullptr;
return true;
}
}
return false;
}
IComponentFactory* CComponentFactoryManager::GetFactoryByName(CStrID nameId)
{
for (SFactoryData& data : m_factories)
{
if (data.m_nameId == nameId)
{
return data.m_address;
}
}
return nullptr;
}
IComponentFactory* CComponentFactoryManager::GetFactoryByIndex(std::size_t idx)
{
if (idx < m_factories.size())
{
return m_factories[idx].m_address;
}
return nullptr;
}
int CComponentFactoryManager::GetFactoryIndexByName(CStrID nameId)
{
for (std::size_t i = 0; i < m_factories.size(); ++i)
{
if (m_factories[i].m_nameId == nameId)
{
return i;
}
}
return -1;
}
void CComponentFactoryManager::Update(float dt)
{
for (SFactoryData& data : m_factories)
{
data.m_address->Update(dt);
}
}
| 25.083333 | 112 | 0.707167 | jesuslou |
0ed76ca7d0e793847a03e7387ea87dc4909408c5 | 25,892 | hpp | C++ | src/min_distance.hpp | ruolin/vg | fddf5a0e3172cfc50eb6f8a561dfbe3dbbbaec04 | [
"MIT"
] | 740 | 2016-02-23T02:31:10.000Z | 2022-03-31T20:51:36.000Z | src/min_distance.hpp | ruolin/vg | fddf5a0e3172cfc50eb6f8a561dfbe3dbbbaec04 | [
"MIT"
] | 2,455 | 2016-02-24T08:17:45.000Z | 2022-03-31T20:19:41.000Z | src/min_distance.hpp | ruolin/vg | fddf5a0e3172cfc50eb6f8a561dfbe3dbbbaec04 | [
"MIT"
] | 169 | 2016-03-03T15:41:33.000Z | 2022-03-31T04:01:53.000Z | #ifndef VG_MIN_DISTANCE_HPP_INCLUDED
#define VG_MIN_DISTANCE_HPP_INCLUDED
#include <unordered_set>
#include <jansson.h>
#include "snarls.hpp"
#include "hash_map.hpp"
#include "bdsg/hash_graph.hpp"
using namespace sdsl;
namespace vg {
/**
* The distance index. Stores minimum distances among nodes in each
* netgraph and chain. Used for calculation of the minimum distance between
* two positions and for a maximum distance estimation. The maximum distance
* estimation is at least as large as the maximum distance between two
* positions up to a specified cap
*/
class MinimumDistanceIndex {
public:
///Constructor for the distance index.
///Cap is the distance up to which the maximum distance will give a
///reliable bound - if there is a path with length greater than cap,
///then the maximum distance will be at least cap
///If the cap is set to 0 (default), then the maximum distance index is not
///included
MinimumDistanceIndex (const HandleGraph* graph, const SnarlManager* snarl_manager,
int64_t cap = 0);
//Constructor to load index from serialization
MinimumDistanceIndex (istream& in);
//Default constructor; load() must be called next.
MinimumDistanceIndex ();
//Serialize object into out
void serialize(ostream& out) const;
//Load serialized object from in. Does not rely on the internal graph or
//snarl manager pointers.
void load(istream& in);
//Get the length of the given node
int64_t node_length(id_t id) const;
///Get the minimum distance between two positions
/// Distance includes only one of the positions. The distance from a
/// position to itself would be 1
///If there is no path between the two positions then the distance is -1
int64_t min_distance( pos_t pos1, pos_t pos2) const;
///Get a maximum distance bound between the positions, ignoring direction
///Returns a positive value even if the two nodes are unreachable
int64_t max_distance(pos_t pos1, pos_t pos2) const;
///Get the start node (id and orientation pointing into the snarl) of the
//snarl that this point into and a bool is_trivial_snarl
//Returns <0, false, false> if this doesn't point into a snarl
tuple<id_t, bool, bool> into_which_snarl(id_t node_id, bool reverse) const;
//Given an alignment to a graph and a range, find the set of nodes in the
//graph for which the minimum distance from the position to any position
//in the node is within the given distance range
//If look_forward is true, then start from the start of the path forward,
//otherwise start from the end going backward
void subgraph_in_range(const Path& path, const HandleGraph* super_graph, int64_t min_distance, int64_t max_distance,
std::unordered_set<id_t>& sub_graph, bool look_forward);
//Given a position, return distances that can be stored by a minimizer
//
//If the position is on a boundary node of a top level chain, then return true, and
//a unique identifier for the connected component that the node is on and
//the offset of the position in the root chain - the minimum distance from the beginning of the chain to
//the position
//The second bool will be false and the remaining size_t's will be 0
//
//If the position is on a child node of a top-level simple bubble (bubble has no children and nodes connect only to boundaries)
//return false, 0, 0, true, and the rank of the bubble in its chain, the length of the start
//node of the snarl, the length of the end node (relative to a fd traversal of the chain), and
//the length of the node
//
//If the position is not on a root node (that is, a boundary node of a snarl in a root chain), returns
//false and MIPayload::NO_VALUE for all values
tuple<bool, size_t, size_t, bool, size_t, size_t, size_t, size_t, bool> get_minimizer_distances (pos_t pos);
//What is the length of the top level chain that this node belongs to?
int64_t top_level_chain_length(id_t node_id);
size_t get_connected_component(id_t node_id);
///Helper function to find the minimum value that is not -1
static int64_t min_pos(vector<int64_t> vals);
///Helper function to find the minimum value that is not -1
static int64_t min_pos(int64_t x, int64_t y) {
return static_cast<int64_t>(std::min(static_cast<uint64_t>(x), static_cast<uint64_t>(y)));
}
///Write snarls out to stout
void write_snarls_to_json();
///print the distance index for debugging
void print_self() const;
// Prints the number of nodes in each snarl netgraph and number of snarls in each chain
void print_snarl_stats();
protected:
/** Index for calculating minimum distances among nodes in a snarl
* Stores minimum distances between nodes in the netgraph of a snarl
* Also keeps track of the parent of the snarl
*/
class SnarlIndex {
public:
///Constructor for the snarl index
///if inChain is true, parent_id and rev_in_parent are for the chain
/// chain the snarl participates in. otherwise, for the parent snarl
SnarlIndex(id_t parent_id, bool rev_in_parent,
id_t id_in_parent, id_t end_id, bool is_unary_snarl, size_t depth,
size_t num_nodes, bool in_chain);
//Construct an empty SnarlIndex. Must call load after construction to populate it
SnarlIndex();
//Load data from serialization
void load(istream& in, bool include_component);
///Serialize the snarl
void serialize(ostream& out) const;
///Distance between start and end, not including the lengths of
///the two nodes
///start and end are the ranks of the node+direction, given by
///primary_snarls and secondary_snarl
///Only works for nodes heading their chains (which represent the
///chains), or snarl boundaries.
///Rank 0 is the start node and rank num_nodes*2-1 is the end node,
/// both pointing into the snarl
int64_t snarl_distance(size_t start, size_t end) const {
return int64_t(distances[index(start, end)]) - 1;
}
///Length of a node in the netgraph of the snarl
///If it is a node, then the length of the node. If it is a snarl or
///chain, then the shortest distance between the boundaries
/// i is the rank of the node in the snarl
int64_t node_length(size_t i) const {
return distances[i / 2] - 1;
}
///Total length of the snarl-shortest distance from start to end
///including the lengths of boundary nodes
int64_t snarl_length() const;
///Given distances from a position to either end of a node, find the
///shortest distance from that position to the start and end
///nodes of the snarl
///rank is in the forward direction, but checks both forward and reverse
pair<int64_t, int64_t> dist_to_ends(size_t rank,
int64_t distL, int64_t distR) const;
///For use during construction,
///add the distance from start to end to the index
void insert_distance(size_t start, size_t end, int64_t dist);
bool is_trivial_snarl() const;
void print_self() const;
json_t* snarl_to_json();
protected:
/// Store the distance between every pair nodes, not including the
/// lengths of the nodes.
/// The lengths of each of the nodes are stored as the first n entries
/// Distances stored are 1 greater than actual distances
/// -1 (stored as 0) indicates no path
/// For child snarls that are unary or only connected to one node
/// in the snarl, distances between that node leaving the snarl
/// and any other node is -1
int_vector<> distances;
///True if this snarl is in a chain
bool in_chain;
/// id of the parent snarl or chain of this snarl
///0 if this is a top level snarl with no chain
id_t parent_id;
bool rev_in_parent;
///id of this snarl in the parent. If the parent is a chain, then
///the id of the boundary node that occurs first in the order of
///the chain
id_t id_in_parent;
//id of the boundary node opposite id_in_parent
id_t end_id;
///Number of nodes in the snarl
size_t num_nodes;
///Depth in the snarl tree - 0 for root
size_t depth;
///True if this snarl is a unary snarl
///Since the start and end node are the same, the last ranking
///node is no longer the end node if this is true
bool is_unary_snarl;
///True if all children are nodes (not snarls or chains) and for every child node,
//there are only edges to the boundary nodes
bool is_simple_snarl;
///The maximum width of the snarl - the maximum of all minimum distance paths from each node to
//both ends of the snarl
int64_t max_width;
///The index into distances for distance start->end
size_t index(size_t start, size_t end) const;
friend class MinimumDistanceIndex;
friend class SnarlSeedClusterer;
};
/**Stores distances between snarls in a chain*/
class ChainIndex {
public:
///Constructor for ChainIndex
/// loops is true if the chain loops - the start and end node are
/// the same
/// length is the number of snarls in the chain
ChainIndex(id_t parent_id, id_t id_in_parent, id_t end_id, bool rev_in_parent,
bool loops, size_t length);
//Constructor from vector of ints after serialization
ChainIndex();
//Load data from serialization
void load(istream& in);
///Serialize the chain
void serialize(ostream& out) const;
///Distance between two node sides in a chain.
///size_t values specify the nodes - rank of the node in the chain,
///bool specifies the direction the node is traversed i.e. if both
/// bools are false, then the distance is between the left side of
/// the start node traversing it forward to the left side of the
/// end node traversing forward. Orientation is relative to the
/// direction the chain is traversed in
int64_t chain_distance(pair<size_t, bool> start,
pair<size_t, bool> end, int64_t startLen,
int64_t endLen, bool check_loop=false) const;
//Length of entire chain
int64_t chain_length() const {
return prefix_sum[prefix_sum.size() - 1] - 1;
}
void print_self() const;
json_t* chain_to_json();
protected:
///Dist from start of chain to start of each boundary node of
///all snarls in the chain
///The first value should be 0 according to this scheme but it is
///the length of the first node in the chain. Similarly, an extra
///value is stored at the end of the vector that is the length of the
///entire chain
int_vector<> prefix_sum;
///For each boundary node of snarls in the chain, the distance
/// from the start of the node traversing forward to the end of
/// the same node traversing backwards -directions relative to the
/// direction the node is traversed in the chain
int_vector<> loop_fd;
///For each boundary node of snarls in the chain, the distance
/// from the end of the node traversing backward to the start of
/// the same node traversing forward
int_vector<> loop_rev;
/// id of parent snarl of the chain
///0 if top level chain
id_t parent_id;
bool rev_in_parent;
//Id of the start node of this chain
id_t id_in_parent;
//id of the end node in the chain
id_t end_id;
//True if the chain loops - if the start and end node are the same
bool is_looping_chain;
//Sum of all max widths of the snarls
int64_t max_width;
/// Helper function for chainDistance. Used to find the distance
/// in a looping chain by taking the extra loop
int64_t loop_distance(pair<size_t, bool> start,
pair<size_t, bool> end, int64_t startLen,
int64_t endLen) const;
friend class MinimumDistanceIndex;
friend class SnarlSeedClusterer;
};
///////// Data members of overall distance index
///vector of all SnarlIndex objects
vector<SnarlIndex> snarl_indexes;
///vector of all ChainIndex objects
vector< ChainIndex> chain_indexes;
//Each connected component of the graph gets a unique identifier
//Identifiers start at 1, 0 indicates that it is not in a component
//Assigns each node to its connected component
sdsl::int_vector<> node_to_component;
//TODO: These could be one vector but they're small enough it probably doesn't matter
sdsl::int_vector<> component_to_chain_length;
sdsl::int_vector<> component_to_chain_index;
//Each of the ints in these vectors are offset by 1: 0 is stored as 1, etc.
//This is so that we can store -1 as 0 instead of int max
///Vector of length max node id - min node id
///For each node, stores the index into snarlIndexes for the primary snarl
///containing the node
///A primary snarl is the snarl that contains this node as an actual node,
///as opposed to a node representing a snarl or chain
sdsl::int_vector<> primary_snarl_assignments;
///For each node, stores the rank of the node in the snarlIndex
/// indicated by primary_snarl_assignments
/// Rank refers to the index into the SnarlIndex's distance matrix that
/// represents a particular node
///The rank stored is always for the fd direction, rev direction
/// is the index + 1.
///The first and last rank will always be the inward facing start and
/// end nodes
/// If the start node is traversed backwards to enter the snarl, then the
/// rank 0 will represent the start node in reverse. The rank stored in this
/// vector will be 1, representing the start node forward
sdsl::int_vector<> primary_snarl_ranks;
///Similar to primary snarls, stores snarl index of secondary snarl
///each node belongs to, if any.
///Secondary snarl can be a node that represents a snarl/chain in the
///netgraph of the parent snarl or a node that participates in multiple
///snarls in a chain. The primary snarl will always
///be the snarl that occurs first in the chain
sdsl::int_vector<> secondary_snarl_assignments;
///Stores the ranks of nodes in secondary snarls
sdsl::int_vector<> secondary_snarl_ranks;
///For each node, stores 1 if the node is in a secondary snarl and 0
///otherwise. Use rank to find which index into secondary_snarls
///a node's secondary snarl is at
sdsl::bit_vector has_secondary_snarl_bv;
sdsl::rank_support_v<1> has_secondary_snarl;
///For each node, store the index and rank for the chain that the node
///belongs to, if any
sdsl::int_vector<> chain_assignments;
sdsl::int_vector<> chain_ranks;
sdsl::bit_vector has_chain_bv;
sdsl::rank_support_v<1> has_chain;
id_t min_node_id; //minimum node id of the graph
id_t max_node_id; //maximum node id of the graph
///The total depth of the snarl tree, starting from 0
size_t tree_depth;
///True if we are including the maximum distance index
bool include_maximum;
//////Indexes for maximum distances
///For each node in the graph, store the minimum and maximum
///distances from a tip to the node
sdsl::int_vector<> min_distances;
sdsl::int_vector<> max_distances;
//Header for the serialized file
string file_header = "distance index version 2.2";
//TODO: version 2 (no .anything) doesn't include component but we'll still accept it
//version 2.1 doesn't include snarl index.is_simple_snarl and will break if we try to load it
bool include_component; //TODO: This is true for version 2.2 so it includes node_to_component, etc.
////// Private helper functions
///Helper function for constructor - populate the minimum distance index
///Given the top level snarls
//Returns the length of the chain
int64_t calculate_min_index(const HandleGraph* graph,
const SnarlManager* snarl_manager, const Chain* chain,
size_t parent_id, bool rev_in_parent,
bool trivial_chain, size_t depth, size_t component_num);
void populate_snarl_index(const HandleGraph* graph, const SnarlManager* snarl_manager, const NetGraph& ng,
const Snarl* snarl, bool snarl_rev_in_chain, size_t snarl_assignment,
hash_set<pair<id_t, bool>>& all_nodes, size_t depth, size_t component_num);
///Compute min_distances and max_distances, which store
/// distances needed for maximum distance calculation
///Only used if include_maximum is true
void calculate_max_index(const HandleGraph* graph, int64_t cap);
///Helper for subgraphInRange
///Given starting handles in the super graph and the distances to each handle (including the start position and
//the first position in the handle), add all nodes within the givendistance range to the subgraph
//Ignore all nodes in seen_nodes (nodes that are too close)
void add_nodes_in_range(const HandleGraph* super_graph, int64_t min_distance, int64_t max_distance,
std::unordered_set<id_t>& sub_graph, vector<tuple<handle_t, int64_t>>& start_nodes,
hash_set<pair<id_t, bool>>& seen_nodes);
///Helper function for distance calculation
///Returns the distance to the start of and end of a node/snarl in
//commonAncestor and the node id of the node in the common ancestor.
///The node in the common ancestor is a pair of <node id, rev>
/// commonAncestor is a pair of the node_id and true if it is a chain
///rev is false if the pos is the start pos ( if it must be traversed
///forward) and false if it is the end pos (if it must be reached in
///the direction of pos)
tuple<int64_t, int64_t, pair<id_t, bool>> dist_to_common_ancestor(
pair<size_t, bool> common_ancestor, pos_t& pos, bool rev) const;
/// Get the index into chain_indexes/rank in chain of node i.
/// Detects and throws an error if node i never got assigned to a snarl.
size_t get_primary_assignment(id_t i) const {
if (i - min_node_id > primary_snarl_assignments.size()) {
throw runtime_error("Node " + std::to_string(i) + " not in any snarl. Distance index does " +
"not match graph or was not generated from a snarl set including trivial snarls.");
}
auto stored = primary_snarl_assignments[i - min_node_id];
if (stored == 0) {
// Somebody asked for a node. It should be assigned to a snarl, but it isn't.
throw runtime_error("Node " + std::to_string(i) + " not in any snarl. Distance index does " +
"not match graph or was not generated from a snarl set including trivial snarls.");
}
return primary_snarl_assignments[i - min_node_id] - 1;
}
size_t get_primary_rank(id_t i) const {
return primary_snarl_ranks[i - min_node_id] - 1;
}
size_t get_chain_assignment(id_t i) const {
return chain_assignments[has_chain.rank(i - min_node_id)] - 1;
}
size_t get_chain_rank(id_t i) const {
return chain_ranks[has_chain.rank(i - min_node_id)] - 1;
}
size_t get_secondary_assignment(id_t i) const {
return secondary_snarl_assignments[has_secondary_snarl.rank(i - min_node_id)] - 1;
}
size_t get_secondary_rank(id_t i) const {
return secondary_snarl_ranks[has_secondary_snarl.rank(i - min_node_id)] - 1;
}
friend class SnarlIndex;
friend class ChainIndex;
friend class SnarlSeedClusterer;
};
/**
* The encoding of distances for positions in top-level chains or top-level simple bubbles.
* Either stores (chain id, chain offset) for a position on a top-level chain, or
* (snarl rank, node length, start length, end length) for a position on a simple bubble
* We store this information in the minimizer index.
*/
/*
Simple bubble:
8 bit | 1 | 24 | 10 | 10 | 10 | 1
--- | is rev | snarl rank in chain | start len | end len | node len | is_node
Top level chain
31 bit | 32 | 1
component id | offset | is_node
is_node is true if it is a top-level chain node, false if it is a simple bubble
*/
struct MIPayload {
typedef std::uint64_t code_type; // We assume that this fits into gbwtgraph::payload_type.
constexpr static code_type NO_CODE = std::numeric_limits<code_type>::max();
constexpr static size_t NO_VALUE = std::numeric_limits<size_t>::max(); // From offset_in_root_chain().
constexpr static size_t NODE_LEN_OFFSET = 1;
constexpr static size_t END_LEN_OFFSET = 11;
constexpr static size_t START_LEN_OFFSET = 21;
constexpr static size_t RANK_OFFSET = 31;
constexpr static size_t REV_OFFSET = 55;
constexpr static size_t LENGTH_WIDTH = 10;
constexpr static size_t RANK_WIDTH = 24;
constexpr static code_type LENGTH_MASK = (static_cast<code_type>(1) << LENGTH_WIDTH) - 1;
constexpr static code_type RANK_MASK = (static_cast<code_type>(1) << RANK_WIDTH) - 1;
constexpr static size_t ID_OFFSET = 33;
constexpr static size_t ID_WIDTH = 31;
constexpr static size_t OFFSET_WIDTH = 32;
constexpr static code_type OFFSET_MASK = (static_cast<code_type>(1) << OFFSET_WIDTH) - 1;
static code_type encode(std::tuple<bool, size_t, size_t, bool, size_t, size_t, size_t, size_t, bool> chain_pos) {
bool is_top_level_node; size_t component; size_t offset; //Values for a top level chain
bool is_top_level_snarl; size_t snarl_rank; size_t node_length; size_t start_length; size_t end_length; bool is_rev;//values for a bubble
std::tie(is_top_level_node, component, offset, is_top_level_snarl, snarl_rank, start_length, end_length, node_length, is_rev) = chain_pos;
if (!is_top_level_node && ! is_top_level_snarl) {
return NO_CODE;
} else if (is_top_level_node) {
//Top level node in chain
if (component >= (static_cast<code_type>(1) << 31) - 1
|| offset >= static_cast<size_t>(OFFSET_MASK) ) {
//If the values are too large to be stored
return NO_CODE;
}
return (component << ID_OFFSET) | (offset << 1) | static_cast<code_type>(true);
} else {
//Top level simple bubble
if (snarl_rank >= static_cast<size_t>(RANK_MASK)
|| start_length >= static_cast<size_t>(LENGTH_MASK)
|| end_length >= static_cast<size_t>(LENGTH_MASK)
|| node_length >= static_cast<size_t>(LENGTH_MASK) ){
//If the values are too large to be stored
return NO_CODE;
}
return (static_cast<code_type>(is_rev) << REV_OFFSET) | (snarl_rank << RANK_OFFSET) | (start_length << START_LEN_OFFSET) | (end_length << END_LEN_OFFSET) | (node_length << NODE_LEN_OFFSET) ;
}
}
static std::tuple<bool, size_t, size_t, bool, size_t, size_t, size_t, size_t, bool> decode(code_type code) {
if (code == NO_CODE) {
return std::tuple<bool, size_t, size_t, bool, size_t, size_t, size_t, size_t, bool>(false, NO_VALUE, NO_VALUE, false, NO_VALUE, NO_VALUE, NO_VALUE, NO_VALUE, false);
} else if ((code & (static_cast<code_type>(1))) == (static_cast<code_type>(1))) {
//This is a top-level chain
return std::tuple<bool, size_t, size_t, bool, size_t, size_t, size_t, size_t, bool>
(true, code >> ID_OFFSET, code >> 1 & OFFSET_MASK, false, NO_VALUE, NO_VALUE, NO_VALUE, NO_VALUE, false);
} else {
//This is a top-level bubble
return std::tuple<bool, size_t, size_t, bool, size_t, size_t, size_t, size_t, bool>
(false, NO_VALUE, NO_VALUE, true,
code >> RANK_OFFSET & RANK_MASK,
code >> START_LEN_OFFSET & LENGTH_MASK,
code >> END_LEN_OFFSET & LENGTH_MASK,
code >> NODE_LEN_OFFSET & LENGTH_MASK,
code >> REV_OFFSET & static_cast<code_type>(1));
}
}
};
}
#endif
| 41.828756 | 202 | 0.641202 | ruolin |
0edd1a36d5423d636689af2472b67b28afbdcf85 | 1,918 | cpp | C++ | Level_3_HW/Section 2.3/Exercise 5/Exercise 5/main.cpp | ZhehaoLi9705/QuantNet_CPP | a889f4656e757842f4163b0cda7e098cc6ad1193 | [
"MIT"
] | null | null | null | Level_3_HW/Section 2.3/Exercise 5/Exercise 5/main.cpp | ZhehaoLi9705/QuantNet_CPP | a889f4656e757842f4163b0cda7e098cc6ad1193 | [
"MIT"
] | null | null | null | Level_3_HW/Section 2.3/Exercise 5/Exercise 5/main.cpp | ZhehaoLi9705/QuantNet_CPP | a889f4656e757842f4163b0cda7e098cc6ad1193 | [
"MIT"
] | null | null | null | //
// main.cpp
// Exercise 5
//
// Created by Zhehao Li on 2020/2/28.
// Copyright © 2020 Zhehao Li. All rights reserved.
//
// Test the structures and interfaces of class Line
#include "Point.hpp"
#include "Line.hpp"
#include <iostream>
#include <string>
using namespace std;
int main(int argc, const char * argv[]) {
// Create a Line object
Line l1; // Intialize with Default constructor
Point l1_pt1 = l1.StartPoint(); // Get the default start point (0,0) of l1
Point l1_pt2 = l1.EndPoint(); // Get the default end point (0,0) of l2
// Print the default start point and end point of line l1
cout << "Line start from " << l1_pt1.ToString() << " to " << l1_pt2.ToString() << endl;
// Create two new Point objects
Point pt1(3.0, 4.0); // Initialize with two values
Point pt2(6.0, 8.0);
// Reset the start point and end point of line l1
l1.StartPoint(pt1); // Set the points of line l1
l1.EndPoint(pt2);
// Print the description of line l1
cout << l1.ToString();
// Print the length of line l1
cout << "Length of l1: " << l1.Length() << endl;
return 0;
}
// Point:
// 1. Default constructor called twice -- start and end point of Object l1
// 2. Copy constructor called twice -- l1_pt1, l2_pt2 copy the start and end point of Object l1
// 3. Constructor with values called twice -- new points pt1, pt2 intialized with values
// 4. Destructor called six times
//
// Line:
// 1. Default constructor called once -- create Object l1
// 2. Destructor called once
| 36.188679 | 118 | 0.53024 | ZhehaoLi9705 |
0edf398ac451a526cdf23bb0b6b556ac935f420d | 2,831 | cpp | C++ | ros/pouco2000_ros_src/pouco2000_ros/node/release/controller.cpp | PouceHeure/pouco2000 | bebb0c30dd0849a4a19d4e614cf1f9169bca31c5 | [
"Apache-2.0"
] | 2 | 2020-02-27T18:12:30.000Z | 2020-03-22T14:20:18.000Z | ros/pouco2000_ros_src/pouco2000_ros/node/release/controller.cpp | PouceHeure/pouco2000 | bebb0c30dd0849a4a19d4e614cf1f9169bca31c5 | [
"Apache-2.0"
] | null | null | null | ros/pouco2000_ros_src/pouco2000_ros/node/release/controller.cpp | PouceHeure/pouco2000 | bebb0c30dd0849a4a19d4e614cf1f9169bca31c5 | [
"Apache-2.0"
] | null | null | null | #include "ros/ros.h"
#include "pouco2000_ros/pouco2000.hpp"
// keys param
#define KEY_PARAM_POTENTIOMETERS_CIRCLE "potentiometers/circle/"
#define KEY_PARAM_POTENTIOMETERS_SLIDER "potentiometers/slider/"
#define KEY_PARAM_RATE "~rate"
/**
* @brief load parameter converter from rosparam
*
* @param key the key where is define the param
* @param d_min default min value
* @param d_max default max value
* @param min result min value
* @param max result max value
*/
void load_parameter_converter(const std::string key,
const int d_min, const int d_max,
int& min, int& max){
XmlRpc::XmlRpcValue parameters;
if(ros::param::get(key,parameters)){
min = parameters["min"];
max = parameters["max"];
}else{
min = d_min;
max = d_max;
}
}
/**
* @brief load parameter rate from rosparam
* if a rate is given, the controller switch to the freq send mode
* by default the node publishs once it receives a message
*
* @param c
* @param key
*/
void load_parameter_rate(Controller& c,std::string key){
int rate;
if(ros::param::get(key,rate)){
c.set_sleep_rate(rate);
c.set_send_mode(SendMode::freq);
}
}
int main(int argc, char **argv){
ros::init(argc, argv, "controller_node");
ros::NodeHandle n;
// init convertissers
int circle_min; int circle_max;
int slider_min; int slider_max;
load_parameter_converter(KEY_PARAM_POTENTIOMETERS_CIRCLE,0,1024,circle_min,circle_max);
load_parameter_converter(KEY_PARAM_POTENTIOMETERS_SLIDER,0,1024,slider_min,slider_max);
ConvertisserPotentiometerToPercent convert_potetiomerters_circle(circle_min,circle_max);
ConvertisserPotentiometerToPercent convert_potetiomerters_slider(slider_min,slider_max);
// init controller
Controller controller;
// essential sets
load_parameter_rate(controller,KEY_PARAM_RATE);
controller.set_node_handle(n);
controller.set_pub_controller("controller");
controller.set_sub_buttons("buttons",callback_field::buttons);
// buttons
// switchs
controller.set_sub_switchs_onoff("switchs_onoff",callback_field::switchs_onoff);
controller.set_sub_switchs_modes("switchs_modes",callback_field::switchs_modes);
// potentiometers
auto callback_attach_convert_circle = boost::bind(&callback_field::potentiometers_circle,_1,_2,boost::ref(convert_potetiomerters_circle));
controller.set_sub_potentiometers_circle("potentiometers_circle",callback_attach_convert_circle);
auto callback_attach_convert_slider = boost::bind(&callback_field::potentiometers_slider,_1,_2,boost::ref(convert_potetiomerters_slider));
controller.set_sub_potentiometers_slider("potentiometers_slider",callback_attach_convert_slider);
// run controller, starting the communication with ros
controller.run();
return 0;
} | 35.3875 | 140 | 0.752738 | PouceHeure |
0ee8a1cbfa9b33742ac4673a05c1f15c6e912c1d | 1,147 | hpp | C++ | include/pastel/utility/tuple/meta/reverse.hpp | naoki-yoshioka/pastel | b443dcc6ae86ff3e94ec9c2e7085b5d6521214e8 | [
"MIT"
] | null | null | null | include/pastel/utility/tuple/meta/reverse.hpp | naoki-yoshioka/pastel | b443dcc6ae86ff3e94ec9c2e7085b5d6521214e8 | [
"MIT"
] | 24 | 2017-12-23T07:39:58.000Z | 2019-09-20T10:16:37.000Z | include/pastel/utility/tuple/meta/reverse.hpp | naoki-yoshioka/pastel | b443dcc6ae86ff3e94ec9c2e7085b5d6521214e8 | [
"MIT"
] | null | null | null | #ifndef PASTEL_UTILITY_TUPLE_META_REVERSE_HPP
# define PASTEL_UTILITY_TUPLE_META_REVERSE_HPP
# include <tuple>
namespace pastel
{
namespace utility
{
namespace tuple
{
namespace meta
{
namespace reverse_detail
{
template <typename Result, typename... Args>
struct reverse;
template <typename... ResultArgs, typename Type, typename... Args>
struct reverse<std::tuple<ResultArgs...>, Type, Args...>
: ::pastel::utility::tuple::meta::reverse_detail::reverse<std::tuple<Type, ResultArgs...>, Args...>
{ };
template <typename Result>
struct reverse<Result>
{ using type = Result; };
} // namespace reverse_detail
template <typename Tuple>
struct reverse;
template <typename... Args>
struct reverse<std::tuple<Args...>>
: ::pastel::utility::tuple::meta::reverse_detail::reverse<std::tuple<>, Args...>
{ };
} // namespace meta
} // namespace tuple
} // namespace utility
} // namespace pastel
#endif // PASTEL_UTILITY_TUPLE_META_REVERSE_HPP
| 24.934783 | 111 | 0.607672 | naoki-yoshioka |
0eecca916e257c0ad24d5f2602edad5423e0eb46 | 2,673 | cpp | C++ | aws-cpp-sdk-pinpoint-email/source/model/DkimAttributes.cpp | curiousjgeorge/aws-sdk-cpp | 09b65deba03cfbef9a1e5d5986aa4de71bc03cd8 | [
"Apache-2.0"
] | 2 | 2019-03-11T15:50:55.000Z | 2020-02-27T11:40:27.000Z | aws-cpp-sdk-pinpoint-email/source/model/DkimAttributes.cpp | curiousjgeorge/aws-sdk-cpp | 09b65deba03cfbef9a1e5d5986aa4de71bc03cd8 | [
"Apache-2.0"
] | null | null | null | aws-cpp-sdk-pinpoint-email/source/model/DkimAttributes.cpp | curiousjgeorge/aws-sdk-cpp | 09b65deba03cfbef9a1e5d5986aa4de71bc03cd8 | [
"Apache-2.0"
] | 1 | 2019-01-18T13:03:55.000Z | 2019-01-18T13:03:55.000Z | /*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#include <aws/pinpoint-email/model/DkimAttributes.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
namespace Aws
{
namespace PinpointEmail
{
namespace Model
{
DkimAttributes::DkimAttributes() :
m_signingEnabled(false),
m_signingEnabledHasBeenSet(false),
m_status(DkimStatus::NOT_SET),
m_statusHasBeenSet(false),
m_tokensHasBeenSet(false)
{
}
DkimAttributes::DkimAttributes(JsonView jsonValue) :
m_signingEnabled(false),
m_signingEnabledHasBeenSet(false),
m_status(DkimStatus::NOT_SET),
m_statusHasBeenSet(false),
m_tokensHasBeenSet(false)
{
*this = jsonValue;
}
DkimAttributes& DkimAttributes::operator =(JsonView jsonValue)
{
if(jsonValue.ValueExists("SigningEnabled"))
{
m_signingEnabled = jsonValue.GetBool("SigningEnabled");
m_signingEnabledHasBeenSet = true;
}
if(jsonValue.ValueExists("Status"))
{
m_status = DkimStatusMapper::GetDkimStatusForName(jsonValue.GetString("Status"));
m_statusHasBeenSet = true;
}
if(jsonValue.ValueExists("Tokens"))
{
Array<JsonView> tokensJsonList = jsonValue.GetArray("Tokens");
for(unsigned tokensIndex = 0; tokensIndex < tokensJsonList.GetLength(); ++tokensIndex)
{
m_tokens.push_back(tokensJsonList[tokensIndex].AsString());
}
m_tokensHasBeenSet = true;
}
return *this;
}
JsonValue DkimAttributes::Jsonize() const
{
JsonValue payload;
if(m_signingEnabledHasBeenSet)
{
payload.WithBool("SigningEnabled", m_signingEnabled);
}
if(m_statusHasBeenSet)
{
payload.WithString("Status", DkimStatusMapper::GetNameForDkimStatus(m_status));
}
if(m_tokensHasBeenSet)
{
Array<JsonValue> tokensJsonList(m_tokens.size());
for(unsigned tokensIndex = 0; tokensIndex < tokensJsonList.GetLength(); ++tokensIndex)
{
tokensJsonList[tokensIndex].AsString(m_tokens[tokensIndex]);
}
payload.WithArray("Tokens", std::move(tokensJsonList));
}
return payload;
}
} // namespace Model
} // namespace PinpointEmail
} // namespace Aws
| 24.081081 | 90 | 0.73251 | curiousjgeorge |
0ef15ee5779c3080ab69e50cc145601ebaa08180 | 5,722 | cpp | C++ | ODE/OpenDynamicsEngine/ode/src/collision_trimesh_disabled.cpp | N3X15/VoxelSim | 89baca47338deccd6615dcc51c0399d3472eaba4 | [
"BSD-3-Clause"
] | 4 | 2015-04-21T01:35:32.000Z | 2022-03-08T14:09:45.000Z | ODE/OpenDynamicsEngine/ode/src/collision_trimesh_disabled.cpp | N3X15/VoxelSim | 89baca47338deccd6615dcc51c0399d3472eaba4 | [
"BSD-3-Clause"
] | null | null | null | ODE/OpenDynamicsEngine/ode/src/collision_trimesh_disabled.cpp | N3X15/VoxelSim | 89baca47338deccd6615dcc51c0399d3472eaba4 | [
"BSD-3-Clause"
] | 5 | 2015-02-27T02:07:26.000Z | 2019-12-13T12:31:58.000Z | /*************************************************************************
* *
* Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. *
* All rights reserved. Email: [email protected] Web: www.q12.org *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
#include <ode/collision.h>
#include <ode/matrix.h>
#include "config.h"
#if !dTRIMESH_ENABLED
#include "collision_util.h"
#include "collision_trimesh_internal.h"
dxTriMesh::dxTriMesh(dSpaceID Space, dTriMeshDataID Data) : dxGeom(Space, 1){ type = dTriMeshClass; }
dxTriMesh::~dxTriMesh(){}
int dxTriMesh::AABBTest(dxGeom* g, dReal aabb[6]) { return 0; }
void dxTriMesh::computeAABB() { dSetZero (aabb,6); }
static dMatrix4 identity = {
REAL( 0.0 ), REAL( 0.0 ), REAL( 0.0 ), REAL( 0.0 ),
REAL( 0.0 ), REAL( 0.0 ), REAL( 0.0 ), REAL( 0.0 ),
REAL( 0.0 ), REAL( 0.0 ), REAL( 0.0 ), REAL( 0.0 ),
REAL( 0.0 ), REAL( 0.0 ), REAL( 0.0 ), REAL( 0.0 ) };
// Stub functions for trimesh calls
dTriMeshDataID dGeomTriMeshDataCreate(void) { return 0; }
void dGeomTriMeshDataDestroy(dTriMeshDataID g) {}
void dGeomTriMeshDataSet(dTriMeshDataID g, int data_id, void* in_data) {}
void* dGeomTriMeshDataGet(dTriMeshDataID g, int data_id) { return 0; }
ODE_API void dGeomTriMeshSetLastTransform( dGeomID g, dMatrix4 last_trans ) {}
ODE_API dReal* dGeomTriMeshGetLastTransform( dGeomID g ) { return identity; }
dGeomID dCreateTriMesh(dSpaceID space,
dTriMeshDataID Data,
dTriCallback* Callback,
dTriArrayCallback* ArrayCallback,
dTriRayCallback* RayCallback)
{
dxTriMesh* Geom = new dxTriMesh(space, Data);
Geom->Callback = Callback;
Geom->ArrayCallback = ArrayCallback;
Geom->RayCallback = RayCallback;
return Geom;
}
void dGeomTriMeshSetData(dGeomID g, dTriMeshDataID Data) {}
dTriMeshDataID dGeomTriMeshGetData(dGeomID g) { return 0; }
void dGeomTriMeshDataBuildSingle(dTriMeshDataID g,
const void* Vertices, int VertexStride, int VertexCount,
const void* Indices, int IndexCount, int TriStride) { }
void dGeomTriMeshDataBuildSingle1(dTriMeshDataID g,
const void* Vertices, int VertexStride, int VertexCount,
const void* Indices, int IndexCount, int TriStride,
const void* Normals) { }
void dGeomTriMeshDataBuildDouble(dTriMeshDataID g,
const void* Vertices, int VertexStride, int VertexCount,
const void* Indices, int IndexCount, int TriStride) { }
void dGeomTriMeshDataBuildDouble1(dTriMeshDataID g,
const void* Vertices, int VertexStride, int VertexCount,
const void* Indices, int IndexCount, int TriStride,
const void* Normals) { }
void dGeomTriMeshDataBuildSimple(dTriMeshDataID g,
const dReal* Vertices, int VertexCount,
const dTriIndex* Indices, int IndexCount) { }
void dGeomTriMeshDataBuildSimple1(dTriMeshDataID g,
const dReal* Vertices, int VertexCount,
const dTriIndex* Indices, int IndexCount,
const int* Normals) { }
void dGeomTriMeshDataPreprocess(dTriMeshDataID g) { }
void dGeomTriMeshDataGetBuffer(dTriMeshDataID g, unsigned char** buf, int* bufLen) { *buf = NULL; *bufLen=0; }
void dGeomTriMeshDataSetBuffer(dTriMeshDataID g, unsigned char* buf) {}
void dGeomTriMeshSetCallback(dGeomID g, dTriCallback* Callback) { }
dTriCallback* dGeomTriMeshGetCallback(dGeomID g) { return 0; }
void dGeomTriMeshSetArrayCallback(dGeomID g, dTriArrayCallback* ArrayCallback) { }
dTriArrayCallback* dGeomTriMeshGetArrayCallback(dGeomID g) { return 0; }
void dGeomTriMeshSetRayCallback(dGeomID g, dTriRayCallback* Callback) { }
dTriRayCallback* dGeomTriMeshGetRayCallback(dGeomID g) { return 0; }
void dGeomTriMeshEnableTC(dGeomID g, int geomClass, int enable) {}
int dGeomTriMeshIsTCEnabled(dGeomID g, int geomClass) { return 0; }
void dGeomTriMeshClearTCCache(dGeomID g) {}
dTriMeshDataID dGeomTriMeshGetTriMeshDataID(dGeomID g) { return 0; }
int dGeomTriMeshGetTriangleCount (dGeomID g) { return 0; }
void dGeomTriMeshDataUpdate(dTriMeshDataID g) {}
#endif // !dTRIMESH_ENABLED
| 45.055118 | 110 | 0.598916 | N3X15 |
0ef8611edba4ba58f06c62ace4488d643013af45 | 314 | cpp | C++ | regression/esbmc-cpp/inheritance/dynamic_cast4/main.cpp | shmarovfedor/esbmc | 3226a3d68b009d44b9535a993ac0f25e1a1fbedd | [
"BSD-3-Clause"
] | 143 | 2015-06-22T12:30:01.000Z | 2022-03-21T08:41:17.000Z | regression/esbmc-cpp/inheritance/dynamic_cast4/main.cpp | shmarovfedor/esbmc | 3226a3d68b009d44b9535a993ac0f25e1a1fbedd | [
"BSD-3-Clause"
] | 542 | 2017-06-02T13:46:26.000Z | 2022-03-31T16:35:17.000Z | regression/esbmc-cpp/inheritance/dynamic_cast4/main.cpp | shmarovfedor/esbmc | 3226a3d68b009d44b9535a993ac0f25e1a1fbedd | [
"BSD-3-Clause"
] | 81 | 2015-10-21T22:21:59.000Z | 2022-03-24T14:07:55.000Z | #include <iostream>
#include <cassert>
using namespace std;
struct A {
virtual ~A() { };
};
struct B : A { };
int main() {
B bobj;
A* ap = &bobj;
void * vp = dynamic_cast<void *>(ap);
cout << "Address of vp : " << vp << endl;
cout << "Address of bobj: " << &bobj << endl;
assert(vp == &bobj);
}
| 15.7 | 47 | 0.541401 | shmarovfedor |
0ef939bc01f8965510f512cae6384899f9be2704 | 197,382 | cxx | C++ | dune/xt/data/spherical_quadratures/octant_quadrature/data/order_37.cxx | dune-community/dune-xt-data | 32593bbcd52ed69b0a11963400a9173740089a75 | [
"BSD-2-Clause"
] | 1 | 2020-02-08T04:09:11.000Z | 2020-02-08T04:09:11.000Z | dune/xt/data/spherical_quadratures/octant_quadrature/data/order_37.cxx | dune-community/dune-xt-data | 32593bbcd52ed69b0a11963400a9173740089a75 | [
"BSD-2-Clause"
] | 40 | 2018-08-26T08:34:34.000Z | 2021-09-28T13:01:55.000Z | dune/xt/data/spherical_quadratures/octant_quadrature/data/order_37.cxx | dune-community/dune-xt-data | 32593bbcd52ed69b0a11963400a9173740089a75 | [
"BSD-2-Clause"
] | 1 | 2020-02-08T04:10:14.000Z | 2020-02-08T04:10:14.000Z | // This file is part of the dune-xt-data project:
// https://github.com/dune-community/dune-xt-data
// Copyright 2009-2018 dune-xt-data developers and contributors. All rights reserved.
// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
// or GPL-2.0+ (http://opensource.org/licenses/gpl-license)
// with "runtime exception" (http://www.dune-project.org/license.html)
// Authors:
// René Fritze (2018)
// Tobias Leibner (2018 - 2019)
#include "../octant_quadrature_data.hh"
namespace Dune::XT::Data {
template <>
std::vector<std::vector<std::vector<double>>> OctantQuadratureData<37>::get()
{
return {
{{0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501},
{0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118,
0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118,
0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748,
0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748,
0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751,
0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751,
0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324,
0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324,
0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026,
0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026,
0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646,
0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646,
0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094,
0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094,
0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761,
0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761,
0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837,
0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837,
0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289,
0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289,
0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081,
0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081,
0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418,
0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418,
0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549,
0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549,
0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153,
0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153,
0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954,
0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954,
0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917,
0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917,
0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005,
0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005,
0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183,
0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183,
0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415,
0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415,
0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665,
0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665,
0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896,
0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896,
0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074,
0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074,
1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016,
1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016,
1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613,
1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613,
1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193,
1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193,
1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753,
1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753,
1.229, 1.229, 1.229, 1.229, 1.229, 1.229, 1.229, 1.229, 1.229, 1.229,
1.229, 1.229, 1.229, 1.229, 1.229, 1.229, 1.229, 1.229, 1.229, 1.229,
1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28,
1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28,
1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279,
1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279,
1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724,
1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724,
1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132,
1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132,
1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499,
1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499,
1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822,
1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822,
1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098,
1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098,
1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325,
1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325,
1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55,
1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55,
1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623,
1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623,
1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692,
1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692},
{1.2879e-07, 1.5572e-06, 5.863e-06, 1.4322e-05, 2.7795e-05, 4.668e-05, 7.093e-05, 0.0001001, 0.00013345,
0.00016997, 0.00020853, 0.00024788, 0.00028676, 0.00032394, 0.00035823, 0.00038859, 0.00041406, 0.00043386,
0.00044741, 0.00045429, 2.9855e-07, 3.6099e-06, 1.3592e-05, 3.3203e-05, 6.4435e-05, 0.00010821, 0.00016443,
0.00023206, 0.00030936, 0.00039403, 0.00048341, 0.00057463, 0.00066477, 0.00075095, 0.00083047, 0.00090083,
0.00095987, 0.0010058, 0.0010372, 0.0010531, 4.6565e-07, 5.6303e-06, 2.1199e-05, 5.1785e-05, 0.0001005,
0.00016878, 0.00025646, 0.00036195, 0.00048251, 0.00061457, 0.00075397, 0.00089624, 0.0010368, 0.0011712,
0.0012953, 0.001405, 0.0014971, 0.0015687, 0.0016177, 0.0016426, 6.2827e-07, 7.5966e-06, 2.8602e-05,
6.9871e-05, 0.0001356, 0.00022773, 0.00034603, 0.00048836, 0.00065103, 0.0008292, 0.0010173, 0.0012093,
0.0013989, 0.0015803, 0.0017476, 0.0018957, 0.0020199, 0.0021166, 0.0021827, 0.0022162, 7.8497e-07,
9.4914e-06, 3.5736e-05, 8.7299e-05, 0.00016942, 0.00028452, 0.00043233, 0.00061016, 0.0008134, 0.001036,
0.001271, 0.0015109, 0.0017479, 0.0019745, 0.0021835, 0.0023685, 0.0025238, 0.0026445, 0.0027271,
0.002769, 9.3448e-07, 1.1299e-05, 4.2542e-05, 0.00010393, 0.00020168, 0.00033872, 0.00051467, 0.00072637,
0.00096832, 0.0012333, 0.0015131, 0.0017986, 0.0020808, 0.0023505, 0.0025994, 0.0028196, 0.0030044,
0.0031482, 0.0032465, 0.0032964, 1.0757e-06, 1.3007e-05, 4.8971e-05, 0.00011963, 0.00023216, 0.0003899,
0.00059245, 0.00083614, 0.0011147, 0.0014197, 0.0017418, 0.0020704, 0.0023952, 0.0027057, 0.0029922,
0.0032457, 0.0034585, 0.0036239, 0.0037371, 0.0037945, 1.2077e-06, 1.4603e-05, 5.4982e-05, 0.00013431,
0.00026066, 0.00043776, 0.00066517, 0.00093877, 0.0012515, 0.001594, 0.0019555, 0.0023246, 0.0026892,
0.0030378, 0.0033595, 0.0036441, 0.003883, 0.0040687, 0.0041958, 0.0042603, 1.3299e-06, 1.608e-05,
6.0543e-05, 0.0001479, 0.00028702, 0.00048203, 0.00073244, 0.0010337, 0.001378, 0.0017552, 0.0021533,
0.0025596, 0.0029612, 0.0033451, 0.0036992, 0.0040127, 0.0042757, 0.0044802, 0.0046201, 0.0046911,
1.4416e-06, 1.7431e-05, 6.5628e-05, 0.00016032, 0.00031113, 0.00052252, 0.00079396, 0.0011205, 0.0014938,
0.0019026, 0.0023342, 0.0027746, 0.0032099, 0.003626, 0.0040099, 0.0043497, 0.0046348, 0.0048565,
0.0050082, 0.0050851, 1.5425e-06, 1.865e-05, 7.0221e-05, 0.00017154, 0.0003329, 0.00055909, 0.00084952,
0.001199, 0.0015983, 0.0020358, 0.0024975, 0.0029688, 0.0034345, 0.0038798, 0.0042906, 0.0046541,
0.0049591, 0.0051964, 0.0053586, 0.005441, 1.6323e-06, 1.9736e-05, 7.4309e-05, 0.00018153, 0.00035229,
0.00059164, 0.00089899, 0.0012688, 0.0016914, 0.0021543, 0.0026429, 0.0031417, 0.0036345, 0.0041057,
0.0045404, 0.0049251, 0.0052479, 0.0054989, 0.0056706, 0.0057578, 1.7109e-06, 2.0687e-05, 7.7887e-05,
0.00019027, 0.00036925, 0.00062012, 0.00094227, 0.0013299, 0.0017728, 0.002258, 0.0027702, 0.0032929,
0.0038095, 0.0043034, 0.004759, 0.0051622, 0.0055006, 0.0057637, 0.0059437, 0.006035, 1.7782e-06,
2.15e-05, 8.0951e-05, 0.00019775, 0.00038377, 0.00064452, 0.00097934, 0.0013822, 0.0018426, 0.0023468,
0.0028792, 0.0034225, 0.0039593, 0.0044726, 0.0049462, 0.0053653, 0.0057169, 0.0059904, 0.0061775,
0.0062724, 1.8342e-06, 2.2177e-05, 8.35e-05, 0.00020398, 0.00039586, 0.00066482, 0.0010102, 0.0014257,
0.0019006, 0.0024208, 0.0029698, 0.0035303, 0.004084, 0.0046135, 0.005102, 0.0055343, 0.005897,
0.0061791, 0.006372, 0.00647, 1.8789e-06, 2.2718e-05, 8.5536e-05, 0.00020895, 0.00040551, 0.00068103,
0.0010348, 0.0014605, 0.0019469, 0.0024798, 0.0030423, 0.0036164, 0.0041836, 0.004726, 0.0052264,
0.0056692, 0.0060408, 0.0063298, 0.0065274, 0.0066277, 1.9124e-06, 2.3123e-05, 8.7061e-05, 0.00021268,
0.00041274, 0.00069317, 0.0010533, 0.0014865, 0.0019816, 0.002524, 0.0030965, 0.0036808, 0.0042582,
0.0048102, 0.0053195, 0.0057703, 0.0061485, 0.0064426, 0.0066438, 0.0067459, 1.9347e-06, 2.3393e-05,
8.8076e-05, 0.00021516, 0.00041755, 0.00070125, 0.0010655, 0.0015038, 0.0020047, 0.0025534, 0.0031326,
0.0037237, 0.0043078, 0.0048663, 0.0053816, 0.0058375, 0.0062201, 0.0065177, 0.0067212, 0.0068245,
1.9458e-06, 2.3527e-05, 8.8583e-05, 0.0002164, 0.00041996, 0.00070529, 0.0010717, 0.0015125, 0.0020163,
0.0025681, 0.0031506, 0.0037452, 0.0043326, 0.0048943, 0.0054126, 0.0058711, 0.006256, 0.0065552,
0.0067599, 0.0068638, 1.9458e-06, 2.3527e-05, 8.8583e-05, 0.0002164, 0.00041996, 0.00070529, 0.0010717,
0.0015125, 0.0020163, 0.0025681, 0.0031506, 0.0037452, 0.0043326, 0.0048943, 0.0054126, 0.0058711,
0.006256, 0.0065552, 0.0067599, 0.0068638, 1.9347e-06, 2.3393e-05, 8.8076e-05, 0.00021516, 0.00041755,
0.00070125, 0.0010655, 0.0015038, 0.0020047, 0.0025534, 0.0031326, 0.0037237, 0.0043078, 0.0048663,
0.0053816, 0.0058375, 0.0062201, 0.0065177, 0.0067212, 0.0068245, 1.9124e-06, 2.3123e-05, 8.7061e-05,
0.00021268, 0.00041274, 0.00069317, 0.0010533, 0.0014865, 0.0019816, 0.002524, 0.0030965, 0.0036808,
0.0042582, 0.0048102, 0.0053195, 0.0057703, 0.0061485, 0.0064426, 0.0066438, 0.0067459, 1.8789e-06,
2.2718e-05, 8.5536e-05, 0.00020895, 0.00040551, 0.00068103, 0.0010348, 0.0014605, 0.0019469, 0.0024798,
0.0030423, 0.0036164, 0.0041836, 0.004726, 0.0052264, 0.0056692, 0.0060408, 0.0063298, 0.0065274,
0.0066277, 1.8342e-06, 2.2177e-05, 8.35e-05, 0.00020398, 0.00039586, 0.00066482, 0.0010102, 0.0014257,
0.0019006, 0.0024208, 0.0029698, 0.0035303, 0.004084, 0.0046135, 0.005102, 0.0055343, 0.005897,
0.0061791, 0.006372, 0.00647, 1.7782e-06, 2.15e-05, 8.0951e-05, 0.00019775, 0.00038377, 0.00064452,
0.00097934, 0.0013822, 0.0018426, 0.0023468, 0.0028792, 0.0034225, 0.0039593, 0.0044726, 0.0049462,
0.0053653, 0.0057169, 0.0059904, 0.0061775, 0.0062724, 1.7109e-06, 2.0687e-05, 7.7887e-05, 0.00019027,
0.00036925, 0.00062012, 0.00094227, 0.0013299, 0.0017728, 0.002258, 0.0027702, 0.0032929, 0.0038095,
0.0043034, 0.004759, 0.0051622, 0.0055006, 0.0057637, 0.0059437, 0.006035, 1.6323e-06, 1.9736e-05,
7.4309e-05, 0.00018153, 0.00035229, 0.00059164, 0.00089899, 0.0012688, 0.0016914, 0.0021543, 0.0026429,
0.0031417, 0.0036345, 0.0041057, 0.0045404, 0.0049251, 0.0052479, 0.0054989, 0.0056706, 0.0057578,
1.5425e-06, 1.865e-05, 7.0221e-05, 0.00017154, 0.0003329, 0.00055909, 0.00084952, 0.001199, 0.0015983,
0.0020358, 0.0024975, 0.0029688, 0.0034345, 0.0038798, 0.0042906, 0.0046541, 0.0049591, 0.0051964,
0.0053586, 0.005441, 1.4416e-06, 1.7431e-05, 6.5628e-05, 0.00016032, 0.00031113, 0.00052252, 0.00079396,
0.0011205, 0.0014938, 0.0019026, 0.0023342, 0.0027746, 0.0032099, 0.003626, 0.0040099, 0.0043497,
0.0046348, 0.0048565, 0.0050082, 0.0050851, 1.3299e-06, 1.608e-05, 6.0543e-05, 0.0001479, 0.00028702,
0.00048203, 0.00073244, 0.0010337, 0.001378, 0.0017552, 0.0021533, 0.0025596, 0.0029612, 0.0033451,
0.0036992, 0.0040127, 0.0042757, 0.0044802, 0.0046201, 0.0046911, 1.2077e-06, 1.4603e-05, 5.4982e-05,
0.00013431, 0.00026066, 0.00043776, 0.00066517, 0.00093877, 0.0012515, 0.001594, 0.0019555, 0.0023246,
0.0026892, 0.0030378, 0.0033595, 0.0036441, 0.003883, 0.0040687, 0.0041958, 0.0042603, 1.0757e-06,
1.3007e-05, 4.8971e-05, 0.00011963, 0.00023216, 0.0003899, 0.00059245, 0.00083614, 0.0011147, 0.0014197,
0.0017418, 0.0020704, 0.0023952, 0.0027057, 0.0029922, 0.0032457, 0.0034585, 0.0036239, 0.0037371,
0.0037945, 9.3448e-07, 1.1299e-05, 4.2542e-05, 0.00010393, 0.00020168, 0.00033872, 0.00051467, 0.00072637,
0.00096832, 0.0012333, 0.0015131, 0.0017986, 0.0020808, 0.0023505, 0.0025994, 0.0028196, 0.0030044,
0.0031482, 0.0032465, 0.0032964, 7.8497e-07, 9.4914e-06, 3.5736e-05, 8.7299e-05, 0.00016942, 0.00028452,
0.00043233, 0.00061016, 0.0008134, 0.001036, 0.001271, 0.0015109, 0.0017479, 0.0019745, 0.0021835,
0.0023685, 0.0025238, 0.0026445, 0.0027271, 0.002769, 6.2827e-07, 7.5966e-06, 2.8602e-05, 6.9871e-05,
0.0001356, 0.00022773, 0.00034603, 0.00048836, 0.00065103, 0.0008292, 0.0010173, 0.0012093, 0.0013989,
0.0015803, 0.0017476, 0.0018957, 0.0020199, 0.0021166, 0.0021827, 0.0022162, 4.6565e-07, 5.6303e-06,
2.1199e-05, 5.1785e-05, 0.0001005, 0.00016878, 0.00025646, 0.00036195, 0.00048251, 0.00061457, 0.00075397,
0.00089624, 0.0010368, 0.0011712, 0.0012953, 0.001405, 0.0014971, 0.0015687, 0.0016177, 0.0016426,
2.9855e-07, 3.6099e-06, 1.3592e-05, 3.3203e-05, 6.4435e-05, 0.00010821, 0.00016443, 0.00023206, 0.00030936,
0.00039403, 0.00048341, 0.00057463, 0.00066477, 0.00075095, 0.00083047, 0.00090083, 0.00095987, 0.0010058,
0.0010372, 0.0010531, 1.2879e-07, 1.5572e-06, 5.863e-06, 1.4322e-05, 2.7795e-05, 4.668e-05, 7.093e-05,
0.0001001, 0.00013345, 0.00016997, 0.00020853, 0.00024788, 0.00028676, 0.00032394, 0.00035823, 0.00038859,
0.00041406, 0.00043386, 0.00044741, 0.00045429}},
{{0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501},
{1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724,
1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793,
1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5915, 1.5915,
1.5915, 1.5915, 1.5915, 1.5915, 1.5915, 1.5915, 1.5915, 1.5915, 1.5915, 1.5915, 1.5915, 1.5915, 1.5915, 1.5915,
1.5915, 1.5915, 1.5915, 1.5915, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091,
1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6318, 1.6318, 1.6318, 1.6318,
1.6318, 1.6318, 1.6318, 1.6318, 1.6318, 1.6318, 1.6318, 1.6318, 1.6318, 1.6318, 1.6318, 1.6318, 1.6318, 1.6318,
1.6318, 1.6318, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594,
1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917,
1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917,
1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284,
1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692,
1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.8137, 1.8137,
1.8137, 1.8137, 1.8137, 1.8137, 1.8137, 1.8137, 1.8137, 1.8137, 1.8137, 1.8137, 1.8137, 1.8137, 1.8137, 1.8137,
1.8137, 1.8137, 1.8137, 1.8137, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616,
1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.9126, 1.9126, 1.9126, 1.9126,
1.9126, 1.9126, 1.9126, 1.9126, 1.9126, 1.9126, 1.9126, 1.9126, 1.9126, 1.9126, 1.9126, 1.9126, 1.9126, 1.9126,
1.9126, 1.9126, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663,
1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223,
2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223,
2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803,
2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.14, 2.14, 2.14, 2.14, 2.14, 2.14, 2.14, 2.14,
2.14, 2.14, 2.14, 2.14, 2.14, 2.14, 2.14, 2.14, 2.14, 2.14, 2.14, 2.14, 2.2009, 2.2009,
2.2009, 2.2009, 2.2009, 2.2009, 2.2009, 2.2009, 2.2009, 2.2009, 2.2009, 2.2009, 2.2009, 2.2009, 2.2009, 2.2009,
2.2009, 2.2009, 2.2009, 2.2009, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626,
2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.3249, 2.3249, 2.3249, 2.3249,
2.3249, 2.3249, 2.3249, 2.3249, 2.3249, 2.3249, 2.3249, 2.3249, 2.3249, 2.3249, 2.3249, 2.3249, 2.3249, 2.3249,
2.3249, 2.3249, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874,
2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498,
2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498,
2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115,
2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724,
2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.6321, 2.6321,
2.6321, 2.6321, 2.6321, 2.6321, 2.6321, 2.6321, 2.6321, 2.6321, 2.6321, 2.6321, 2.6321, 2.6321, 2.6321, 2.6321,
2.6321, 2.6321, 2.6321, 2.6321, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901,
2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.7461, 2.7461, 2.7461, 2.7461,
2.7461, 2.7461, 2.7461, 2.7461, 2.7461, 2.7461, 2.7461, 2.7461, 2.7461, 2.7461, 2.7461, 2.7461, 2.7461, 2.7461,
2.7461, 2.7461, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998,
2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508,
2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508,
2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987,
2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432,
2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.984, 2.984,
2.984, 2.984, 2.984, 2.984, 2.984, 2.984, 2.984, 2.984, 2.984, 2.984, 2.984, 2.984, 2.984, 2.984,
2.984, 2.984, 2.984, 2.984, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207,
3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0529, 3.0529, 3.0529, 3.0529,
3.0529, 3.0529, 3.0529, 3.0529, 3.0529, 3.0529, 3.0529, 3.0529, 3.0529, 3.0529, 3.0529, 3.0529, 3.0529, 3.0529,
3.0529, 3.0529, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806,
3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033,
3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033,
3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208,
3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331,
3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.14, 3.14,
3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14,
3.14, 3.14, 3.14, 3.14},
{1.2879e-07, 1.5572e-06, 5.863e-06, 1.4322e-05, 2.7795e-05, 4.668e-05, 7.093e-05, 0.0001001, 0.00013345,
0.00016997, 0.00020853, 0.00024788, 0.00028676, 0.00032394, 0.00035823, 0.00038859, 0.00041406, 0.00043386,
0.00044741, 0.00045429, 2.9855e-07, 3.6099e-06, 1.3592e-05, 3.3203e-05, 6.4435e-05, 0.00010821, 0.00016443,
0.00023206, 0.00030936, 0.00039403, 0.00048341, 0.00057463, 0.00066477, 0.00075095, 0.00083047, 0.00090083,
0.00095987, 0.0010058, 0.0010372, 0.0010531, 4.6565e-07, 5.6303e-06, 2.1199e-05, 5.1785e-05, 0.0001005,
0.00016878, 0.00025646, 0.00036195, 0.00048251, 0.00061457, 0.00075397, 0.00089624, 0.0010368, 0.0011712,
0.0012953, 0.001405, 0.0014971, 0.0015687, 0.0016177, 0.0016426, 6.2827e-07, 7.5966e-06, 2.8602e-05,
6.9871e-05, 0.0001356, 0.00022773, 0.00034603, 0.00048836, 0.00065103, 0.0008292, 0.0010173, 0.0012093,
0.0013989, 0.0015803, 0.0017476, 0.0018957, 0.0020199, 0.0021166, 0.0021827, 0.0022162, 7.8497e-07,
9.4914e-06, 3.5736e-05, 8.7299e-05, 0.00016942, 0.00028452, 0.00043233, 0.00061016, 0.0008134, 0.001036,
0.001271, 0.0015109, 0.0017479, 0.0019745, 0.0021835, 0.0023685, 0.0025238, 0.0026445, 0.0027271,
0.002769, 9.3448e-07, 1.1299e-05, 4.2542e-05, 0.00010393, 0.00020168, 0.00033872, 0.00051467, 0.00072637,
0.00096832, 0.0012333, 0.0015131, 0.0017986, 0.0020808, 0.0023505, 0.0025994, 0.0028196, 0.0030044,
0.0031482, 0.0032465, 0.0032964, 1.0757e-06, 1.3007e-05, 4.8971e-05, 0.00011963, 0.00023216, 0.0003899,
0.00059245, 0.00083614, 0.0011147, 0.0014197, 0.0017418, 0.0020704, 0.0023952, 0.0027057, 0.0029922,
0.0032457, 0.0034585, 0.0036239, 0.0037371, 0.0037945, 1.2077e-06, 1.4603e-05, 5.4982e-05, 0.00013431,
0.00026066, 0.00043776, 0.00066517, 0.00093877, 0.0012515, 0.001594, 0.0019555, 0.0023246, 0.0026892,
0.0030378, 0.0033595, 0.0036441, 0.003883, 0.0040687, 0.0041958, 0.0042603, 1.3299e-06, 1.608e-05,
6.0543e-05, 0.0001479, 0.00028702, 0.00048203, 0.00073244, 0.0010337, 0.001378, 0.0017552, 0.0021533,
0.0025596, 0.0029612, 0.0033451, 0.0036992, 0.0040127, 0.0042757, 0.0044802, 0.0046201, 0.0046911,
1.4416e-06, 1.7431e-05, 6.5628e-05, 0.00016032, 0.00031113, 0.00052252, 0.00079396, 0.0011205, 0.0014938,
0.0019026, 0.0023342, 0.0027746, 0.0032099, 0.003626, 0.0040099, 0.0043497, 0.0046348, 0.0048565,
0.0050082, 0.0050851, 1.5425e-06, 1.865e-05, 7.0221e-05, 0.00017154, 0.0003329, 0.00055909, 0.00084952,
0.001199, 0.0015983, 0.0020358, 0.0024975, 0.0029688, 0.0034345, 0.0038798, 0.0042906, 0.0046541,
0.0049591, 0.0051964, 0.0053586, 0.005441, 1.6323e-06, 1.9736e-05, 7.4309e-05, 0.00018153, 0.00035229,
0.00059164, 0.00089899, 0.0012688, 0.0016914, 0.0021543, 0.0026429, 0.0031417, 0.0036345, 0.0041057,
0.0045404, 0.0049251, 0.0052479, 0.0054989, 0.0056706, 0.0057578, 1.7109e-06, 2.0687e-05, 7.7887e-05,
0.00019027, 0.00036925, 0.00062012, 0.00094227, 0.0013299, 0.0017728, 0.002258, 0.0027702, 0.0032929,
0.0038095, 0.0043034, 0.004759, 0.0051622, 0.0055006, 0.0057637, 0.0059437, 0.006035, 1.7782e-06,
2.15e-05, 8.0951e-05, 0.00019775, 0.00038377, 0.00064452, 0.00097934, 0.0013822, 0.0018426, 0.0023468,
0.0028792, 0.0034225, 0.0039593, 0.0044726, 0.0049462, 0.0053653, 0.0057169, 0.0059904, 0.0061775,
0.0062724, 1.8342e-06, 2.2177e-05, 8.35e-05, 0.00020398, 0.00039586, 0.00066482, 0.0010102, 0.0014257,
0.0019006, 0.0024208, 0.0029698, 0.0035303, 0.004084, 0.0046135, 0.005102, 0.0055343, 0.005897,
0.0061791, 0.006372, 0.00647, 1.8789e-06, 2.2718e-05, 8.5536e-05, 0.00020895, 0.00040551, 0.00068103,
0.0010348, 0.0014605, 0.0019469, 0.0024798, 0.0030423, 0.0036164, 0.0041836, 0.004726, 0.0052264,
0.0056692, 0.0060408, 0.0063298, 0.0065274, 0.0066277, 1.9124e-06, 2.3123e-05, 8.7061e-05, 0.00021268,
0.00041274, 0.00069317, 0.0010533, 0.0014865, 0.0019816, 0.002524, 0.0030965, 0.0036808, 0.0042582,
0.0048102, 0.0053195, 0.0057703, 0.0061485, 0.0064426, 0.0066438, 0.0067459, 1.9347e-06, 2.3393e-05,
8.8076e-05, 0.00021516, 0.00041755, 0.00070125, 0.0010655, 0.0015038, 0.0020047, 0.0025534, 0.0031326,
0.0037237, 0.0043078, 0.0048663, 0.0053816, 0.0058375, 0.0062201, 0.0065177, 0.0067212, 0.0068245,
1.9458e-06, 2.3527e-05, 8.8583e-05, 0.0002164, 0.00041996, 0.00070529, 0.0010717, 0.0015125, 0.0020163,
0.0025681, 0.0031506, 0.0037452, 0.0043326, 0.0048943, 0.0054126, 0.0058711, 0.006256, 0.0065552,
0.0067599, 0.0068638, 1.9458e-06, 2.3527e-05, 8.8583e-05, 0.0002164, 0.00041996, 0.00070529, 0.0010717,
0.0015125, 0.0020163, 0.0025681, 0.0031506, 0.0037452, 0.0043326, 0.0048943, 0.0054126, 0.0058711,
0.006256, 0.0065552, 0.0067599, 0.0068638, 1.9347e-06, 2.3393e-05, 8.8076e-05, 0.00021516, 0.00041755,
0.00070125, 0.0010655, 0.0015038, 0.0020047, 0.0025534, 0.0031326, 0.0037237, 0.0043078, 0.0048663,
0.0053816, 0.0058375, 0.0062201, 0.0065177, 0.0067212, 0.0068245, 1.9124e-06, 2.3123e-05, 8.7061e-05,
0.00021268, 0.00041274, 0.00069317, 0.0010533, 0.0014865, 0.0019816, 0.002524, 0.0030965, 0.0036808,
0.0042582, 0.0048102, 0.0053195, 0.0057703, 0.0061485, 0.0064426, 0.0066438, 0.0067459, 1.8789e-06,
2.2718e-05, 8.5536e-05, 0.00020895, 0.00040551, 0.00068103, 0.0010348, 0.0014605, 0.0019469, 0.0024798,
0.0030423, 0.0036164, 0.0041836, 0.004726, 0.0052264, 0.0056692, 0.0060408, 0.0063298, 0.0065274,
0.0066277, 1.8342e-06, 2.2177e-05, 8.35e-05, 0.00020398, 0.00039586, 0.00066482, 0.0010102, 0.0014257,
0.0019006, 0.0024208, 0.0029698, 0.0035303, 0.004084, 0.0046135, 0.005102, 0.0055343, 0.005897,
0.0061791, 0.006372, 0.00647, 1.7782e-06, 2.15e-05, 8.0951e-05, 0.00019775, 0.00038377, 0.00064452,
0.00097934, 0.0013822, 0.0018426, 0.0023468, 0.0028792, 0.0034225, 0.0039593, 0.0044726, 0.0049462,
0.0053653, 0.0057169, 0.0059904, 0.0061775, 0.0062724, 1.7109e-06, 2.0687e-05, 7.7887e-05, 0.00019027,
0.00036925, 0.00062012, 0.00094227, 0.0013299, 0.0017728, 0.002258, 0.0027702, 0.0032929, 0.0038095,
0.0043034, 0.004759, 0.0051622, 0.0055006, 0.0057637, 0.0059437, 0.006035, 1.6323e-06, 1.9736e-05,
7.4309e-05, 0.00018153, 0.00035229, 0.00059164, 0.00089899, 0.0012688, 0.0016914, 0.0021543, 0.0026429,
0.0031417, 0.0036345, 0.0041057, 0.0045404, 0.0049251, 0.0052479, 0.0054989, 0.0056706, 0.0057578,
1.5425e-06, 1.865e-05, 7.0221e-05, 0.00017154, 0.0003329, 0.00055909, 0.00084952, 0.001199, 0.0015983,
0.0020358, 0.0024975, 0.0029688, 0.0034345, 0.0038798, 0.0042906, 0.0046541, 0.0049591, 0.0051964,
0.0053586, 0.005441, 1.4416e-06, 1.7431e-05, 6.5628e-05, 0.00016032, 0.00031113, 0.00052252, 0.00079396,
0.0011205, 0.0014938, 0.0019026, 0.0023342, 0.0027746, 0.0032099, 0.003626, 0.0040099, 0.0043497,
0.0046348, 0.0048565, 0.0050082, 0.0050851, 1.3299e-06, 1.608e-05, 6.0543e-05, 0.0001479, 0.00028702,
0.00048203, 0.00073244, 0.0010337, 0.001378, 0.0017552, 0.0021533, 0.0025596, 0.0029612, 0.0033451,
0.0036992, 0.0040127, 0.0042757, 0.0044802, 0.0046201, 0.0046911, 1.2077e-06, 1.4603e-05, 5.4982e-05,
0.00013431, 0.00026066, 0.00043776, 0.00066517, 0.00093877, 0.0012515, 0.001594, 0.0019555, 0.0023246,
0.0026892, 0.0030378, 0.0033595, 0.0036441, 0.003883, 0.0040687, 0.0041958, 0.0042603, 1.0757e-06,
1.3007e-05, 4.8971e-05, 0.00011963, 0.00023216, 0.0003899, 0.00059245, 0.00083614, 0.0011147, 0.0014197,
0.0017418, 0.0020704, 0.0023952, 0.0027057, 0.0029922, 0.0032457, 0.0034585, 0.0036239, 0.0037371,
0.0037945, 9.3448e-07, 1.1299e-05, 4.2542e-05, 0.00010393, 0.00020168, 0.00033872, 0.00051467, 0.00072637,
0.00096832, 0.0012333, 0.0015131, 0.0017986, 0.0020808, 0.0023505, 0.0025994, 0.0028196, 0.0030044,
0.0031482, 0.0032465, 0.0032964, 7.8497e-07, 9.4914e-06, 3.5736e-05, 8.7299e-05, 0.00016942, 0.00028452,
0.00043233, 0.00061016, 0.0008134, 0.001036, 0.001271, 0.0015109, 0.0017479, 0.0019745, 0.0021835,
0.0023685, 0.0025238, 0.0026445, 0.0027271, 0.002769, 6.2827e-07, 7.5966e-06, 2.8602e-05, 6.9871e-05,
0.0001356, 0.00022773, 0.00034603, 0.00048836, 0.00065103, 0.0008292, 0.0010173, 0.0012093, 0.0013989,
0.0015803, 0.0017476, 0.0018957, 0.0020199, 0.0021166, 0.0021827, 0.0022162, 4.6565e-07, 5.6303e-06,
2.1199e-05, 5.1785e-05, 0.0001005, 0.00016878, 0.00025646, 0.00036195, 0.00048251, 0.00061457, 0.00075397,
0.00089624, 0.0010368, 0.0011712, 0.0012953, 0.001405, 0.0014971, 0.0015687, 0.0016177, 0.0016426,
2.9855e-07, 3.6099e-06, 1.3592e-05, 3.3203e-05, 6.4435e-05, 0.00010821, 0.00016443, 0.00023206, 0.00030936,
0.00039403, 0.00048341, 0.00057463, 0.00066477, 0.00075095, 0.00083047, 0.00090083, 0.00095987, 0.0010058,
0.0010372, 0.0010531, 1.2879e-07, 1.5572e-06, 5.863e-06, 1.4322e-05, 2.7795e-05, 4.668e-05, 7.093e-05,
0.0001001, 0.00013345, 0.00016997, 0.00020853, 0.00024788, 0.00028676, 0.00032394, 0.00035823, 0.00038859,
0.00041406, 0.00043386, 0.00044741, 0.00045429}},
{{0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501},
{3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432,
3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501,
3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1623, 3.1623,
3.1623, 3.1623, 3.1623, 3.1623, 3.1623, 3.1623, 3.1623, 3.1623, 3.1623, 3.1623, 3.1623, 3.1623, 3.1623, 3.1623,
3.1623, 3.1623, 3.1623, 3.1623, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799,
3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.2026, 3.2026, 3.2026, 3.2026,
3.2026, 3.2026, 3.2026, 3.2026, 3.2026, 3.2026, 3.2026, 3.2026, 3.2026, 3.2026, 3.2026, 3.2026, 3.2026, 3.2026,
3.2026, 3.2026, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302,
3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625,
3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625,
3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992,
3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.34, 3.34, 3.34, 3.34, 3.34, 3.34, 3.34, 3.34,
3.34, 3.34, 3.34, 3.34, 3.34, 3.34, 3.34, 3.34, 3.34, 3.34, 3.34, 3.34, 3.3845, 3.3845,
3.3845, 3.3845, 3.3845, 3.3845, 3.3845, 3.3845, 3.3845, 3.3845, 3.3845, 3.3845, 3.3845, 3.3845, 3.3845, 3.3845,
3.3845, 3.3845, 3.3845, 3.3845, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324,
3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4834, 3.4834, 3.4834, 3.4834,
3.4834, 3.4834, 3.4834, 3.4834, 3.4834, 3.4834, 3.4834, 3.4834, 3.4834, 3.4834, 3.4834, 3.4834, 3.4834, 3.4834,
3.4834, 3.4834, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371,
3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931,
3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931,
3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511,
3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108,
3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7716, 3.7716,
3.7716, 3.7716, 3.7716, 3.7716, 3.7716, 3.7716, 3.7716, 3.7716, 3.7716, 3.7716, 3.7716, 3.7716, 3.7716, 3.7716,
3.7716, 3.7716, 3.7716, 3.7716, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334,
3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8957, 3.8957, 3.8957, 3.8957,
3.8957, 3.8957, 3.8957, 3.8957, 3.8957, 3.8957, 3.8957, 3.8957, 3.8957, 3.8957, 3.8957, 3.8957, 3.8957, 3.8957,
3.8957, 3.8957, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582,
3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206,
4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206,
4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823,
4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432,
4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.2028, 4.2028,
4.2028, 4.2028, 4.2028, 4.2028, 4.2028, 4.2028, 4.2028, 4.2028, 4.2028, 4.2028, 4.2028, 4.2028, 4.2028, 4.2028,
4.2028, 4.2028, 4.2028, 4.2028, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609,
4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.3169, 4.3169, 4.3169, 4.3169,
4.3169, 4.3169, 4.3169, 4.3169, 4.3169, 4.3169, 4.3169, 4.3169, 4.3169, 4.3169, 4.3169, 4.3169, 4.3169, 4.3169,
4.3169, 4.3169, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706,
4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216,
4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216,
4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695,
4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.514, 4.514, 4.514, 4.514, 4.514, 4.514, 4.514, 4.514,
4.514, 4.514, 4.514, 4.514, 4.514, 4.514, 4.514, 4.514, 4.514, 4.514, 4.514, 4.514, 4.5548, 4.5548,
4.5548, 4.5548, 4.5548, 4.5548, 4.5548, 4.5548, 4.5548, 4.5548, 4.5548, 4.5548, 4.5548, 4.5548, 4.5548, 4.5548,
4.5548, 4.5548, 4.5548, 4.5548, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915,
4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.6237, 4.6237, 4.6237, 4.6237,
4.6237, 4.6237, 4.6237, 4.6237, 4.6237, 4.6237, 4.6237, 4.6237, 4.6237, 4.6237, 4.6237, 4.6237, 4.6237, 4.6237,
4.6237, 4.6237, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514,
4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741,
4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741,
4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916,
4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039,
4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7108, 4.7108,
4.7108, 4.7108, 4.7108, 4.7108, 4.7108, 4.7108, 4.7108, 4.7108, 4.7108, 4.7108, 4.7108, 4.7108, 4.7108, 4.7108,
4.7108, 4.7108, 4.7108, 4.7108},
{1.2879e-07, 1.5572e-06, 5.863e-06, 1.4322e-05, 2.7795e-05, 4.668e-05, 7.093e-05, 0.0001001, 0.00013345,
0.00016997, 0.00020853, 0.00024788, 0.00028676, 0.00032394, 0.00035823, 0.00038859, 0.00041406, 0.00043386,
0.00044741, 0.00045429, 2.9855e-07, 3.6099e-06, 1.3592e-05, 3.3203e-05, 6.4435e-05, 0.00010821, 0.00016443,
0.00023206, 0.00030936, 0.00039403, 0.00048341, 0.00057463, 0.00066477, 0.00075095, 0.00083047, 0.00090083,
0.00095987, 0.0010058, 0.0010372, 0.0010531, 4.6565e-07, 5.6303e-06, 2.1199e-05, 5.1785e-05, 0.0001005,
0.00016878, 0.00025646, 0.00036195, 0.00048251, 0.00061457, 0.00075397, 0.00089624, 0.0010368, 0.0011712,
0.0012953, 0.001405, 0.0014971, 0.0015687, 0.0016177, 0.0016426, 6.2827e-07, 7.5966e-06, 2.8602e-05,
6.9871e-05, 0.0001356, 0.00022773, 0.00034603, 0.00048836, 0.00065103, 0.0008292, 0.0010173, 0.0012093,
0.0013989, 0.0015803, 0.0017476, 0.0018957, 0.0020199, 0.0021166, 0.0021827, 0.0022162, 7.8497e-07,
9.4914e-06, 3.5736e-05, 8.7299e-05, 0.00016942, 0.00028452, 0.00043233, 0.00061016, 0.0008134, 0.001036,
0.001271, 0.0015109, 0.0017479, 0.0019745, 0.0021835, 0.0023685, 0.0025238, 0.0026445, 0.0027271,
0.002769, 9.3448e-07, 1.1299e-05, 4.2542e-05, 0.00010393, 0.00020168, 0.00033872, 0.00051467, 0.00072637,
0.00096832, 0.0012333, 0.0015131, 0.0017986, 0.0020808, 0.0023505, 0.0025994, 0.0028196, 0.0030044,
0.0031482, 0.0032465, 0.0032964, 1.0757e-06, 1.3007e-05, 4.8971e-05, 0.00011963, 0.00023216, 0.0003899,
0.00059245, 0.00083614, 0.0011147, 0.0014197, 0.0017418, 0.0020704, 0.0023952, 0.0027057, 0.0029922,
0.0032457, 0.0034585, 0.0036239, 0.0037371, 0.0037945, 1.2077e-06, 1.4603e-05, 5.4982e-05, 0.00013431,
0.00026066, 0.00043776, 0.00066517, 0.00093877, 0.0012515, 0.001594, 0.0019555, 0.0023246, 0.0026892,
0.0030378, 0.0033595, 0.0036441, 0.003883, 0.0040687, 0.0041958, 0.0042603, 1.3299e-06, 1.608e-05,
6.0543e-05, 0.0001479, 0.00028702, 0.00048203, 0.00073244, 0.0010337, 0.001378, 0.0017552, 0.0021533,
0.0025596, 0.0029612, 0.0033451, 0.0036992, 0.0040127, 0.0042757, 0.0044802, 0.0046201, 0.0046911,
1.4416e-06, 1.7431e-05, 6.5628e-05, 0.00016032, 0.00031113, 0.00052252, 0.00079396, 0.0011205, 0.0014938,
0.0019026, 0.0023342, 0.0027746, 0.0032099, 0.003626, 0.0040099, 0.0043497, 0.0046348, 0.0048565,
0.0050082, 0.0050851, 1.5425e-06, 1.865e-05, 7.0221e-05, 0.00017154, 0.0003329, 0.00055909, 0.00084952,
0.001199, 0.0015983, 0.0020358, 0.0024975, 0.0029688, 0.0034345, 0.0038798, 0.0042906, 0.0046541,
0.0049591, 0.0051964, 0.0053586, 0.005441, 1.6323e-06, 1.9736e-05, 7.4309e-05, 0.00018153, 0.00035229,
0.00059164, 0.00089899, 0.0012688, 0.0016914, 0.0021543, 0.0026429, 0.0031417, 0.0036345, 0.0041057,
0.0045404, 0.0049251, 0.0052479, 0.0054989, 0.0056706, 0.0057578, 1.7109e-06, 2.0687e-05, 7.7887e-05,
0.00019027, 0.00036925, 0.00062012, 0.00094227, 0.0013299, 0.0017728, 0.002258, 0.0027702, 0.0032929,
0.0038095, 0.0043034, 0.004759, 0.0051622, 0.0055006, 0.0057637, 0.0059437, 0.006035, 1.7782e-06,
2.15e-05, 8.0951e-05, 0.00019775, 0.00038377, 0.00064452, 0.00097934, 0.0013822, 0.0018426, 0.0023468,
0.0028792, 0.0034225, 0.0039593, 0.0044726, 0.0049462, 0.0053653, 0.0057169, 0.0059904, 0.0061775,
0.0062724, 1.8342e-06, 2.2177e-05, 8.35e-05, 0.00020398, 0.00039586, 0.00066482, 0.0010102, 0.0014257,
0.0019006, 0.0024208, 0.0029698, 0.0035303, 0.004084, 0.0046135, 0.005102, 0.0055343, 0.005897,
0.0061791, 0.006372, 0.00647, 1.8789e-06, 2.2718e-05, 8.5536e-05, 0.00020895, 0.00040551, 0.00068103,
0.0010348, 0.0014605, 0.0019469, 0.0024798, 0.0030423, 0.0036164, 0.0041836, 0.004726, 0.0052264,
0.0056692, 0.0060408, 0.0063298, 0.0065274, 0.0066277, 1.9124e-06, 2.3123e-05, 8.7061e-05, 0.00021268,
0.00041274, 0.00069317, 0.0010533, 0.0014865, 0.0019816, 0.002524, 0.0030965, 0.0036808, 0.0042582,
0.0048102, 0.0053195, 0.0057703, 0.0061485, 0.0064426, 0.0066438, 0.0067459, 1.9347e-06, 2.3393e-05,
8.8076e-05, 0.00021516, 0.00041755, 0.00070125, 0.0010655, 0.0015038, 0.0020047, 0.0025534, 0.0031326,
0.0037237, 0.0043078, 0.0048663, 0.0053816, 0.0058375, 0.0062201, 0.0065177, 0.0067212, 0.0068245,
1.9458e-06, 2.3527e-05, 8.8583e-05, 0.0002164, 0.00041996, 0.00070529, 0.0010717, 0.0015125, 0.0020163,
0.0025681, 0.0031506, 0.0037452, 0.0043326, 0.0048943, 0.0054126, 0.0058711, 0.006256, 0.0065552,
0.0067599, 0.0068638, 1.9458e-06, 2.3527e-05, 8.8583e-05, 0.0002164, 0.00041996, 0.00070529, 0.0010717,
0.0015125, 0.0020163, 0.0025681, 0.0031506, 0.0037452, 0.0043326, 0.0048943, 0.0054126, 0.0058711,
0.006256, 0.0065552, 0.0067599, 0.0068638, 1.9347e-06, 2.3393e-05, 8.8076e-05, 0.00021516, 0.00041755,
0.00070125, 0.0010655, 0.0015038, 0.0020047, 0.0025534, 0.0031326, 0.0037237, 0.0043078, 0.0048663,
0.0053816, 0.0058375, 0.0062201, 0.0065177, 0.0067212, 0.0068245, 1.9124e-06, 2.3123e-05, 8.7061e-05,
0.00021268, 0.00041274, 0.00069317, 0.0010533, 0.0014865, 0.0019816, 0.002524, 0.0030965, 0.0036808,
0.0042582, 0.0048102, 0.0053195, 0.0057703, 0.0061485, 0.0064426, 0.0066438, 0.0067459, 1.8789e-06,
2.2718e-05, 8.5536e-05, 0.00020895, 0.00040551, 0.00068103, 0.0010348, 0.0014605, 0.0019469, 0.0024798,
0.0030423, 0.0036164, 0.0041836, 0.004726, 0.0052264, 0.0056692, 0.0060408, 0.0063298, 0.0065274,
0.0066277, 1.8342e-06, 2.2177e-05, 8.35e-05, 0.00020398, 0.00039586, 0.00066482, 0.0010102, 0.0014257,
0.0019006, 0.0024208, 0.0029698, 0.0035303, 0.004084, 0.0046135, 0.005102, 0.0055343, 0.005897,
0.0061791, 0.006372, 0.00647, 1.7782e-06, 2.15e-05, 8.0951e-05, 0.00019775, 0.00038377, 0.00064452,
0.00097934, 0.0013822, 0.0018426, 0.0023468, 0.0028792, 0.0034225, 0.0039593, 0.0044726, 0.0049462,
0.0053653, 0.0057169, 0.0059904, 0.0061775, 0.0062724, 1.7109e-06, 2.0687e-05, 7.7887e-05, 0.00019027,
0.00036925, 0.00062012, 0.00094227, 0.0013299, 0.0017728, 0.002258, 0.0027702, 0.0032929, 0.0038095,
0.0043034, 0.004759, 0.0051622, 0.0055006, 0.0057637, 0.0059437, 0.006035, 1.6323e-06, 1.9736e-05,
7.4309e-05, 0.00018153, 0.00035229, 0.00059164, 0.00089899, 0.0012688, 0.0016914, 0.0021543, 0.0026429,
0.0031417, 0.0036345, 0.0041057, 0.0045404, 0.0049251, 0.0052479, 0.0054989, 0.0056706, 0.0057578,
1.5425e-06, 1.865e-05, 7.0221e-05, 0.00017154, 0.0003329, 0.00055909, 0.00084952, 0.001199, 0.0015983,
0.0020358, 0.0024975, 0.0029688, 0.0034345, 0.0038798, 0.0042906, 0.0046541, 0.0049591, 0.0051964,
0.0053586, 0.005441, 1.4416e-06, 1.7431e-05, 6.5628e-05, 0.00016032, 0.00031113, 0.00052252, 0.00079396,
0.0011205, 0.0014938, 0.0019026, 0.0023342, 0.0027746, 0.0032099, 0.003626, 0.0040099, 0.0043497,
0.0046348, 0.0048565, 0.0050082, 0.0050851, 1.3299e-06, 1.608e-05, 6.0543e-05, 0.0001479, 0.00028702,
0.00048203, 0.00073244, 0.0010337, 0.001378, 0.0017552, 0.0021533, 0.0025596, 0.0029612, 0.0033451,
0.0036992, 0.0040127, 0.0042757, 0.0044802, 0.0046201, 0.0046911, 1.2077e-06, 1.4603e-05, 5.4982e-05,
0.00013431, 0.00026066, 0.00043776, 0.00066517, 0.00093877, 0.0012515, 0.001594, 0.0019555, 0.0023246,
0.0026892, 0.0030378, 0.0033595, 0.0036441, 0.003883, 0.0040687, 0.0041958, 0.0042603, 1.0757e-06,
1.3007e-05, 4.8971e-05, 0.00011963, 0.00023216, 0.0003899, 0.00059245, 0.00083614, 0.0011147, 0.0014197,
0.0017418, 0.0020704, 0.0023952, 0.0027057, 0.0029922, 0.0032457, 0.0034585, 0.0036239, 0.0037371,
0.0037945, 9.3448e-07, 1.1299e-05, 4.2542e-05, 0.00010393, 0.00020168, 0.00033872, 0.00051467, 0.00072637,
0.00096832, 0.0012333, 0.0015131, 0.0017986, 0.0020808, 0.0023505, 0.0025994, 0.0028196, 0.0030044,
0.0031482, 0.0032465, 0.0032964, 7.8497e-07, 9.4914e-06, 3.5736e-05, 8.7299e-05, 0.00016942, 0.00028452,
0.00043233, 0.00061016, 0.0008134, 0.001036, 0.001271, 0.0015109, 0.0017479, 0.0019745, 0.0021835,
0.0023685, 0.0025238, 0.0026445, 0.0027271, 0.002769, 6.2827e-07, 7.5966e-06, 2.8602e-05, 6.9871e-05,
0.0001356, 0.00022773, 0.00034603, 0.00048836, 0.00065103, 0.0008292, 0.0010173, 0.0012093, 0.0013989,
0.0015803, 0.0017476, 0.0018957, 0.0020199, 0.0021166, 0.0021827, 0.0022162, 4.6565e-07, 5.6303e-06,
2.1199e-05, 5.1785e-05, 0.0001005, 0.00016878, 0.00025646, 0.00036195, 0.00048251, 0.00061457, 0.00075397,
0.00089624, 0.0010368, 0.0011712, 0.0012953, 0.001405, 0.0014971, 0.0015687, 0.0016177, 0.0016426,
2.9855e-07, 3.6099e-06, 1.3592e-05, 3.3203e-05, 6.4435e-05, 0.00010821, 0.00016443, 0.00023206, 0.00030936,
0.00039403, 0.00048341, 0.00057463, 0.00066477, 0.00075095, 0.00083047, 0.00090083, 0.00095987, 0.0010058,
0.0010372, 0.0010531, 1.2879e-07, 1.5572e-06, 5.863e-06, 1.4322e-05, 2.7795e-05, 4.668e-05, 7.093e-05,
0.0001001, 0.00013345, 0.00016997, 0.00020853, 0.00024788, 0.00028676, 0.00032394, 0.00035823, 0.00038859,
0.00041406, 0.00043386, 0.00044741, 0.00045429}},
{{0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807,
0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501,
0.99999, 0.99983, 0.99901, 0.99666, 0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231,
0.71763, 0.64373, 0.56116, 0.47075, 0.37358, 0.27091, 0.1642, 0.05501, 0.99999, 0.99983, 0.99901, 0.99666,
0.99167, 0.98278, 0.96866, 0.94807, 0.9199, 0.88325, 0.83751, 0.78231, 0.71763, 0.64373, 0.56116, 0.47075,
0.37358, 0.27091, 0.1642, 0.05501},
{4.714, 4.714, 4.714, 4.714, 4.714, 4.714, 4.714, 4.714, 4.714, 4.714, 4.714, 4.714, 4.714, 4.714,
4.714, 4.714, 4.714, 4.714, 4.714, 4.714, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209,
4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7331, 4.7331,
4.7331, 4.7331, 4.7331, 4.7331, 4.7331, 4.7331, 4.7331, 4.7331, 4.7331, 4.7331, 4.7331, 4.7331, 4.7331, 4.7331,
4.7331, 4.7331, 4.7331, 4.7331, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507,
4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7734, 4.7734, 4.7734, 4.7734,
4.7734, 4.7734, 4.7734, 4.7734, 4.7734, 4.7734, 4.7734, 4.7734, 4.7734, 4.7734, 4.7734, 4.7734, 4.7734, 4.7734,
4.7734, 4.7734, 4.801, 4.801, 4.801, 4.801, 4.801, 4.801, 4.801, 4.801, 4.801, 4.801, 4.801, 4.801,
4.801, 4.801, 4.801, 4.801, 4.801, 4.801, 4.801, 4.801, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333,
4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333,
4.87, 4.87, 4.87, 4.87, 4.87, 4.87, 4.87, 4.87, 4.87, 4.87, 4.87, 4.87, 4.87, 4.87,
4.87, 4.87, 4.87, 4.87, 4.87, 4.87, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108,
4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9553, 4.9553,
4.9553, 4.9553, 4.9553, 4.9553, 4.9553, 4.9553, 4.9553, 4.9553, 4.9553, 4.9553, 4.9553, 4.9553, 4.9553, 4.9553,
4.9553, 4.9553, 4.9553, 4.9553, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032,
5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0542, 5.0542, 5.0542, 5.0542,
5.0542, 5.0542, 5.0542, 5.0542, 5.0542, 5.0542, 5.0542, 5.0542, 5.0542, 5.0542, 5.0542, 5.0542, 5.0542, 5.0542,
5.0542, 5.0542, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079,
5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639,
5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639,
5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219,
5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816,
5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.3424, 5.3424,
5.3424, 5.3424, 5.3424, 5.3424, 5.3424, 5.3424, 5.3424, 5.3424, 5.3424, 5.3424, 5.3424, 5.3424, 5.3424, 5.3424,
5.3424, 5.3424, 5.3424, 5.3424, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042,
5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4665, 5.4665, 5.4665, 5.4665,
5.4665, 5.4665, 5.4665, 5.4665, 5.4665, 5.4665, 5.4665, 5.4665, 5.4665, 5.4665, 5.4665, 5.4665, 5.4665, 5.4665,
5.4665, 5.4665, 5.529, 5.529, 5.529, 5.529, 5.529, 5.529, 5.529, 5.529, 5.529, 5.529, 5.529, 5.529,
5.529, 5.529, 5.529, 5.529, 5.529, 5.529, 5.529, 5.529, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914,
5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914,
5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531,
5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.714, 5.714, 5.714, 5.714, 5.714, 5.714, 5.714, 5.714,
5.714, 5.714, 5.714, 5.714, 5.714, 5.714, 5.714, 5.714, 5.714, 5.714, 5.714, 5.714, 5.7736, 5.7736,
5.7736, 5.7736, 5.7736, 5.7736, 5.7736, 5.7736, 5.7736, 5.7736, 5.7736, 5.7736, 5.7736, 5.7736, 5.7736, 5.7736,
5.7736, 5.7736, 5.7736, 5.7736, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317,
5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8877, 5.8877, 5.8877, 5.8877,
5.8877, 5.8877, 5.8877, 5.8877, 5.8877, 5.8877, 5.8877, 5.8877, 5.8877, 5.8877, 5.8877, 5.8877, 5.8877, 5.8877,
5.8877, 5.8877, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414,
5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924,
5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924,
6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403,
6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848,
6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.1256, 6.1256,
6.1256, 6.1256, 6.1256, 6.1256, 6.1256, 6.1256, 6.1256, 6.1256, 6.1256, 6.1256, 6.1256, 6.1256, 6.1256, 6.1256,
6.1256, 6.1256, 6.1256, 6.1256, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622,
6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1945, 6.1945, 6.1945, 6.1945,
6.1945, 6.1945, 6.1945, 6.1945, 6.1945, 6.1945, 6.1945, 6.1945, 6.1945, 6.1945, 6.1945, 6.1945, 6.1945, 6.1945,
6.1945, 6.1945, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222,
6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449,
6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449,
6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624,
6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747,
6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2816, 6.2816,
6.2816, 6.2816, 6.2816, 6.2816, 6.2816, 6.2816, 6.2816, 6.2816, 6.2816, 6.2816, 6.2816, 6.2816, 6.2816, 6.2816,
6.2816, 6.2816, 6.2816, 6.2816},
{1.2879e-07, 1.5572e-06, 5.863e-06, 1.4322e-05, 2.7795e-05, 4.668e-05, 7.093e-05, 0.0001001, 0.00013345,
0.00016997, 0.00020853, 0.00024788, 0.00028676, 0.00032394, 0.00035823, 0.00038859, 0.00041406, 0.00043386,
0.00044741, 0.00045429, 2.9855e-07, 3.6099e-06, 1.3592e-05, 3.3203e-05, 6.4435e-05, 0.00010821, 0.00016443,
0.00023206, 0.00030936, 0.00039403, 0.00048341, 0.00057463, 0.00066477, 0.00075095, 0.00083047, 0.00090083,
0.00095987, 0.0010058, 0.0010372, 0.0010531, 4.6565e-07, 5.6303e-06, 2.1199e-05, 5.1785e-05, 0.0001005,
0.00016878, 0.00025646, 0.00036195, 0.00048251, 0.00061457, 0.00075397, 0.00089624, 0.0010368, 0.0011712,
0.0012953, 0.001405, 0.0014971, 0.0015687, 0.0016177, 0.0016426, 6.2827e-07, 7.5966e-06, 2.8602e-05,
6.9871e-05, 0.0001356, 0.00022773, 0.00034603, 0.00048836, 0.00065103, 0.0008292, 0.0010173, 0.0012093,
0.0013989, 0.0015803, 0.0017476, 0.0018957, 0.0020199, 0.0021166, 0.0021827, 0.0022162, 7.8497e-07,
9.4914e-06, 3.5736e-05, 8.7299e-05, 0.00016942, 0.00028452, 0.00043233, 0.00061016, 0.0008134, 0.001036,
0.001271, 0.0015109, 0.0017479, 0.0019745, 0.0021835, 0.0023685, 0.0025238, 0.0026445, 0.0027271,
0.002769, 9.3448e-07, 1.1299e-05, 4.2542e-05, 0.00010393, 0.00020168, 0.00033872, 0.00051467, 0.00072637,
0.00096832, 0.0012333, 0.0015131, 0.0017986, 0.0020808, 0.0023505, 0.0025994, 0.0028196, 0.0030044,
0.0031482, 0.0032465, 0.0032964, 1.0757e-06, 1.3007e-05, 4.8971e-05, 0.00011963, 0.00023216, 0.0003899,
0.00059245, 0.00083614, 0.0011147, 0.0014197, 0.0017418, 0.0020704, 0.0023952, 0.0027057, 0.0029922,
0.0032457, 0.0034585, 0.0036239, 0.0037371, 0.0037945, 1.2077e-06, 1.4603e-05, 5.4982e-05, 0.00013431,
0.00026066, 0.00043776, 0.00066517, 0.00093877, 0.0012515, 0.001594, 0.0019555, 0.0023246, 0.0026892,
0.0030378, 0.0033595, 0.0036441, 0.003883, 0.0040687, 0.0041958, 0.0042603, 1.3299e-06, 1.608e-05,
6.0543e-05, 0.0001479, 0.00028702, 0.00048203, 0.00073244, 0.0010337, 0.001378, 0.0017552, 0.0021533,
0.0025596, 0.0029612, 0.0033451, 0.0036992, 0.0040127, 0.0042757, 0.0044802, 0.0046201, 0.0046911,
1.4416e-06, 1.7431e-05, 6.5628e-05, 0.00016032, 0.00031113, 0.00052252, 0.00079396, 0.0011205, 0.0014938,
0.0019026, 0.0023342, 0.0027746, 0.0032099, 0.003626, 0.0040099, 0.0043497, 0.0046348, 0.0048565,
0.0050082, 0.0050851, 1.5425e-06, 1.865e-05, 7.0221e-05, 0.00017154, 0.0003329, 0.00055909, 0.00084952,
0.001199, 0.0015983, 0.0020358, 0.0024975, 0.0029688, 0.0034345, 0.0038798, 0.0042906, 0.0046541,
0.0049591, 0.0051964, 0.0053586, 0.005441, 1.6323e-06, 1.9736e-05, 7.4309e-05, 0.00018153, 0.00035229,
0.00059164, 0.00089899, 0.0012688, 0.0016914, 0.0021543, 0.0026429, 0.0031417, 0.0036345, 0.0041057,
0.0045404, 0.0049251, 0.0052479, 0.0054989, 0.0056706, 0.0057578, 1.7109e-06, 2.0687e-05, 7.7887e-05,
0.00019027, 0.00036925, 0.00062012, 0.00094227, 0.0013299, 0.0017728, 0.002258, 0.0027702, 0.0032929,
0.0038095, 0.0043034, 0.004759, 0.0051622, 0.0055006, 0.0057637, 0.0059437, 0.006035, 1.7782e-06,
2.15e-05, 8.0951e-05, 0.00019775, 0.00038377, 0.00064452, 0.00097934, 0.0013822, 0.0018426, 0.0023468,
0.0028792, 0.0034225, 0.0039593, 0.0044726, 0.0049462, 0.0053653, 0.0057169, 0.0059904, 0.0061775,
0.0062724, 1.8342e-06, 2.2177e-05, 8.35e-05, 0.00020398, 0.00039586, 0.00066482, 0.0010102, 0.0014257,
0.0019006, 0.0024208, 0.0029698, 0.0035303, 0.004084, 0.0046135, 0.005102, 0.0055343, 0.005897,
0.0061791, 0.006372, 0.00647, 1.8789e-06, 2.2718e-05, 8.5536e-05, 0.00020895, 0.00040551, 0.00068103,
0.0010348, 0.0014605, 0.0019469, 0.0024798, 0.0030423, 0.0036164, 0.0041836, 0.004726, 0.0052264,
0.0056692, 0.0060408, 0.0063298, 0.0065274, 0.0066277, 1.9124e-06, 2.3123e-05, 8.7061e-05, 0.00021268,
0.00041274, 0.00069317, 0.0010533, 0.0014865, 0.0019816, 0.002524, 0.0030965, 0.0036808, 0.0042582,
0.0048102, 0.0053195, 0.0057703, 0.0061485, 0.0064426, 0.0066438, 0.0067459, 1.9347e-06, 2.3393e-05,
8.8076e-05, 0.00021516, 0.00041755, 0.00070125, 0.0010655, 0.0015038, 0.0020047, 0.0025534, 0.0031326,
0.0037237, 0.0043078, 0.0048663, 0.0053816, 0.0058375, 0.0062201, 0.0065177, 0.0067212, 0.0068245,
1.9458e-06, 2.3527e-05, 8.8583e-05, 0.0002164, 0.00041996, 0.00070529, 0.0010717, 0.0015125, 0.0020163,
0.0025681, 0.0031506, 0.0037452, 0.0043326, 0.0048943, 0.0054126, 0.0058711, 0.006256, 0.0065552,
0.0067599, 0.0068638, 1.9458e-06, 2.3527e-05, 8.8583e-05, 0.0002164, 0.00041996, 0.00070529, 0.0010717,
0.0015125, 0.0020163, 0.0025681, 0.0031506, 0.0037452, 0.0043326, 0.0048943, 0.0054126, 0.0058711,
0.006256, 0.0065552, 0.0067599, 0.0068638, 1.9347e-06, 2.3393e-05, 8.8076e-05, 0.00021516, 0.00041755,
0.00070125, 0.0010655, 0.0015038, 0.0020047, 0.0025534, 0.0031326, 0.0037237, 0.0043078, 0.0048663,
0.0053816, 0.0058375, 0.0062201, 0.0065177, 0.0067212, 0.0068245, 1.9124e-06, 2.3123e-05, 8.7061e-05,
0.00021268, 0.00041274, 0.00069317, 0.0010533, 0.0014865, 0.0019816, 0.002524, 0.0030965, 0.0036808,
0.0042582, 0.0048102, 0.0053195, 0.0057703, 0.0061485, 0.0064426, 0.0066438, 0.0067459, 1.8789e-06,
2.2718e-05, 8.5536e-05, 0.00020895, 0.00040551, 0.00068103, 0.0010348, 0.0014605, 0.0019469, 0.0024798,
0.0030423, 0.0036164, 0.0041836, 0.004726, 0.0052264, 0.0056692, 0.0060408, 0.0063298, 0.0065274,
0.0066277, 1.8342e-06, 2.2177e-05, 8.35e-05, 0.00020398, 0.00039586, 0.00066482, 0.0010102, 0.0014257,
0.0019006, 0.0024208, 0.0029698, 0.0035303, 0.004084, 0.0046135, 0.005102, 0.0055343, 0.005897,
0.0061791, 0.006372, 0.00647, 1.7782e-06, 2.15e-05, 8.0951e-05, 0.00019775, 0.00038377, 0.00064452,
0.00097934, 0.0013822, 0.0018426, 0.0023468, 0.0028792, 0.0034225, 0.0039593, 0.0044726, 0.0049462,
0.0053653, 0.0057169, 0.0059904, 0.0061775, 0.0062724, 1.7109e-06, 2.0687e-05, 7.7887e-05, 0.00019027,
0.00036925, 0.00062012, 0.00094227, 0.0013299, 0.0017728, 0.002258, 0.0027702, 0.0032929, 0.0038095,
0.0043034, 0.004759, 0.0051622, 0.0055006, 0.0057637, 0.0059437, 0.006035, 1.6323e-06, 1.9736e-05,
7.4309e-05, 0.00018153, 0.00035229, 0.00059164, 0.00089899, 0.0012688, 0.0016914, 0.0021543, 0.0026429,
0.0031417, 0.0036345, 0.0041057, 0.0045404, 0.0049251, 0.0052479, 0.0054989, 0.0056706, 0.0057578,
1.5425e-06, 1.865e-05, 7.0221e-05, 0.00017154, 0.0003329, 0.00055909, 0.00084952, 0.001199, 0.0015983,
0.0020358, 0.0024975, 0.0029688, 0.0034345, 0.0038798, 0.0042906, 0.0046541, 0.0049591, 0.0051964,
0.0053586, 0.005441, 1.4416e-06, 1.7431e-05, 6.5628e-05, 0.00016032, 0.00031113, 0.00052252, 0.00079396,
0.0011205, 0.0014938, 0.0019026, 0.0023342, 0.0027746, 0.0032099, 0.003626, 0.0040099, 0.0043497,
0.0046348, 0.0048565, 0.0050082, 0.0050851, 1.3299e-06, 1.608e-05, 6.0543e-05, 0.0001479, 0.00028702,
0.00048203, 0.00073244, 0.0010337, 0.001378, 0.0017552, 0.0021533, 0.0025596, 0.0029612, 0.0033451,
0.0036992, 0.0040127, 0.0042757, 0.0044802, 0.0046201, 0.0046911, 1.2077e-06, 1.4603e-05, 5.4982e-05,
0.00013431, 0.00026066, 0.00043776, 0.00066517, 0.00093877, 0.0012515, 0.001594, 0.0019555, 0.0023246,
0.0026892, 0.0030378, 0.0033595, 0.0036441, 0.003883, 0.0040687, 0.0041958, 0.0042603, 1.0757e-06,
1.3007e-05, 4.8971e-05, 0.00011963, 0.00023216, 0.0003899, 0.00059245, 0.00083614, 0.0011147, 0.0014197,
0.0017418, 0.0020704, 0.0023952, 0.0027057, 0.0029922, 0.0032457, 0.0034585, 0.0036239, 0.0037371,
0.0037945, 9.3448e-07, 1.1299e-05, 4.2542e-05, 0.00010393, 0.00020168, 0.00033872, 0.00051467, 0.00072637,
0.00096832, 0.0012333, 0.0015131, 0.0017986, 0.0020808, 0.0023505, 0.0025994, 0.0028196, 0.0030044,
0.0031482, 0.0032465, 0.0032964, 7.8497e-07, 9.4914e-06, 3.5736e-05, 8.7299e-05, 0.00016942, 0.00028452,
0.00043233, 0.00061016, 0.0008134, 0.001036, 0.001271, 0.0015109, 0.0017479, 0.0019745, 0.0021835,
0.0023685, 0.0025238, 0.0026445, 0.0027271, 0.002769, 6.2827e-07, 7.5966e-06, 2.8602e-05, 6.9871e-05,
0.0001356, 0.00022773, 0.00034603, 0.00048836, 0.00065103, 0.0008292, 0.0010173, 0.0012093, 0.0013989,
0.0015803, 0.0017476, 0.0018957, 0.0020199, 0.0021166, 0.0021827, 0.0022162, 4.6565e-07, 5.6303e-06,
2.1199e-05, 5.1785e-05, 0.0001005, 0.00016878, 0.00025646, 0.00036195, 0.00048251, 0.00061457, 0.00075397,
0.00089624, 0.0010368, 0.0011712, 0.0012953, 0.001405, 0.0014971, 0.0015687, 0.0016177, 0.0016426,
2.9855e-07, 3.6099e-06, 1.3592e-05, 3.3203e-05, 6.4435e-05, 0.00010821, 0.00016443, 0.00023206, 0.00030936,
0.00039403, 0.00048341, 0.00057463, 0.00066477, 0.00075095, 0.00083047, 0.00090083, 0.00095987, 0.0010058,
0.0010372, 0.0010531, 1.2879e-07, 1.5572e-06, 5.863e-06, 1.4322e-05, 2.7795e-05, 4.668e-05, 7.093e-05,
0.0001001, 0.00013345, 0.00016997, 0.00020853, 0.00024788, 0.00028676, 0.00032394, 0.00035823, 0.00038859,
0.00041406, 0.00043386, 0.00044741, 0.00045429}},
{{-0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751,
-0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983,
-0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763,
-0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666,
-0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116,
-0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278,
-0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358,
-0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807,
-0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642,
-0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325,
-0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999,
-0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231,
-0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901,
-0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373,
-0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167,
-0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075,
-0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866,
-0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091,
-0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199,
-0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501,
-0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751,
-0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983,
-0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763,
-0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666,
-0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116,
-0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278,
-0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358,
-0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807,
-0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642,
-0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325,
-0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999,
-0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231,
-0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901,
-0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373,
-0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167,
-0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075,
-0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866,
-0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091,
-0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199,
-0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501,
-0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751,
-0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983,
-0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763,
-0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666,
-0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116,
-0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278,
-0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358,
-0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807,
-0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642,
-0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325,
-0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999,
-0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231,
-0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901,
-0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373,
-0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167,
-0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075,
-0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866,
-0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091,
-0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199,
-0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501,
-0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751,
-0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983,
-0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763,
-0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666,
-0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116,
-0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278,
-0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358,
-0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807,
-0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642,
-0.05501},
{0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118,
0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118, 0.0016118,
0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748,
0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748, 0.0084748,
0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751,
0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751, 0.020751,
0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324,
0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324, 0.038324,
0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026,
0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026, 0.061026,
0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646,
0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646, 0.088646,
0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094,
0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094, 0.12094,
0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761,
0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761, 0.15761,
0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837,
0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837, 0.19837,
0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289,
0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289, 0.24289,
0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081,
0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081, 0.29081,
0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418,
0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418, 0.3418,
0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549,
0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549, 0.39549,
0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153,
0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153, 0.45153,
0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954,
0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954, 0.50954,
0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917,
0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917, 0.56917,
0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005,
0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005, 0.63005,
0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183,
0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183, 0.69183,
0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415,
0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415, 0.75415,
0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665,
0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665, 0.81665,
0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896,
0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896, 0.87896,
0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074,
0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074, 0.94074,
1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016,
1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016, 1.0016,
1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613,
1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613, 1.0613,
1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193,
1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193, 1.1193,
1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753,
1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753, 1.1753,
1.229, 1.229, 1.229, 1.229, 1.229, 1.229, 1.229, 1.229, 1.229, 1.229,
1.229, 1.229, 1.229, 1.229, 1.229, 1.229, 1.229, 1.229, 1.229, 1.229,
1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28,
1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28,
1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279,
1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279, 1.3279,
1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724,
1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724, 1.3724,
1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132,
1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132, 1.4132,
1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499,
1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499, 1.4499,
1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822,
1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822, 1.4822,
1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098,
1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098, 1.5098,
1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325,
1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325, 1.5325,
1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55,
1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55,
1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623,
1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623, 1.5623,
1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692,
1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692, 1.5692},
{1.2879e-07, 1.5572e-06, 5.863e-06, 1.4322e-05, 2.7795e-05, 4.668e-05, 7.093e-05, 0.0001001, 0.00013345,
0.00016997, 0.00020853, 0.00024788, 0.00028676, 0.00032394, 0.00035823, 0.00038859, 0.00041406, 0.00043386,
0.00044741, 0.00045429, 2.9855e-07, 3.6099e-06, 1.3592e-05, 3.3203e-05, 6.4435e-05, 0.00010821, 0.00016443,
0.00023206, 0.00030936, 0.00039403, 0.00048341, 0.00057463, 0.00066477, 0.00075095, 0.00083047, 0.00090083,
0.00095987, 0.0010058, 0.0010372, 0.0010531, 4.6565e-07, 5.6303e-06, 2.1199e-05, 5.1785e-05, 0.0001005,
0.00016878, 0.00025646, 0.00036195, 0.00048251, 0.00061457, 0.00075397, 0.00089624, 0.0010368, 0.0011712,
0.0012953, 0.001405, 0.0014971, 0.0015687, 0.0016177, 0.0016426, 6.2827e-07, 7.5966e-06, 2.8602e-05,
6.9871e-05, 0.0001356, 0.00022773, 0.00034603, 0.00048836, 0.00065103, 0.0008292, 0.0010173, 0.0012093,
0.0013989, 0.0015803, 0.0017476, 0.0018957, 0.0020199, 0.0021166, 0.0021827, 0.0022162, 7.8497e-07,
9.4914e-06, 3.5736e-05, 8.7299e-05, 0.00016942, 0.00028452, 0.00043233, 0.00061016, 0.0008134, 0.001036,
0.001271, 0.0015109, 0.0017479, 0.0019745, 0.0021835, 0.0023685, 0.0025238, 0.0026445, 0.0027271,
0.002769, 9.3448e-07, 1.1299e-05, 4.2542e-05, 0.00010393, 0.00020168, 0.00033872, 0.00051467, 0.00072637,
0.00096832, 0.0012333, 0.0015131, 0.0017986, 0.0020808, 0.0023505, 0.0025994, 0.0028196, 0.0030044,
0.0031482, 0.0032465, 0.0032964, 1.0757e-06, 1.3007e-05, 4.8971e-05, 0.00011963, 0.00023216, 0.0003899,
0.00059245, 0.00083614, 0.0011147, 0.0014197, 0.0017418, 0.0020704, 0.0023952, 0.0027057, 0.0029922,
0.0032457, 0.0034585, 0.0036239, 0.0037371, 0.0037945, 1.2077e-06, 1.4603e-05, 5.4982e-05, 0.00013431,
0.00026066, 0.00043776, 0.00066517, 0.00093877, 0.0012515, 0.001594, 0.0019555, 0.0023246, 0.0026892,
0.0030378, 0.0033595, 0.0036441, 0.003883, 0.0040687, 0.0041958, 0.0042603, 1.3299e-06, 1.608e-05,
6.0543e-05, 0.0001479, 0.00028702, 0.00048203, 0.00073244, 0.0010337, 0.001378, 0.0017552, 0.0021533,
0.0025596, 0.0029612, 0.0033451, 0.0036992, 0.0040127, 0.0042757, 0.0044802, 0.0046201, 0.0046911,
1.4416e-06, 1.7431e-05, 6.5628e-05, 0.00016032, 0.00031113, 0.00052252, 0.00079396, 0.0011205, 0.0014938,
0.0019026, 0.0023342, 0.0027746, 0.0032099, 0.003626, 0.0040099, 0.0043497, 0.0046348, 0.0048565,
0.0050082, 0.0050851, 1.5425e-06, 1.865e-05, 7.0221e-05, 0.00017154, 0.0003329, 0.00055909, 0.00084952,
0.001199, 0.0015983, 0.0020358, 0.0024975, 0.0029688, 0.0034345, 0.0038798, 0.0042906, 0.0046541,
0.0049591, 0.0051964, 0.0053586, 0.005441, 1.6323e-06, 1.9736e-05, 7.4309e-05, 0.00018153, 0.00035229,
0.00059164, 0.00089899, 0.0012688, 0.0016914, 0.0021543, 0.0026429, 0.0031417, 0.0036345, 0.0041057,
0.0045404, 0.0049251, 0.0052479, 0.0054989, 0.0056706, 0.0057578, 1.7109e-06, 2.0687e-05, 7.7887e-05,
0.00019027, 0.00036925, 0.00062012, 0.00094227, 0.0013299, 0.0017728, 0.002258, 0.0027702, 0.0032929,
0.0038095, 0.0043034, 0.004759, 0.0051622, 0.0055006, 0.0057637, 0.0059437, 0.006035, 1.7782e-06,
2.15e-05, 8.0951e-05, 0.00019775, 0.00038377, 0.00064452, 0.00097934, 0.0013822, 0.0018426, 0.0023468,
0.0028792, 0.0034225, 0.0039593, 0.0044726, 0.0049462, 0.0053653, 0.0057169, 0.0059904, 0.0061775,
0.0062724, 1.8342e-06, 2.2177e-05, 8.35e-05, 0.00020398, 0.00039586, 0.00066482, 0.0010102, 0.0014257,
0.0019006, 0.0024208, 0.0029698, 0.0035303, 0.004084, 0.0046135, 0.005102, 0.0055343, 0.005897,
0.0061791, 0.006372, 0.00647, 1.8789e-06, 2.2718e-05, 8.5536e-05, 0.00020895, 0.00040551, 0.00068103,
0.0010348, 0.0014605, 0.0019469, 0.0024798, 0.0030423, 0.0036164, 0.0041836, 0.004726, 0.0052264,
0.0056692, 0.0060408, 0.0063298, 0.0065274, 0.0066277, 1.9124e-06, 2.3123e-05, 8.7061e-05, 0.00021268,
0.00041274, 0.00069317, 0.0010533, 0.0014865, 0.0019816, 0.002524, 0.0030965, 0.0036808, 0.0042582,
0.0048102, 0.0053195, 0.0057703, 0.0061485, 0.0064426, 0.0066438, 0.0067459, 1.9347e-06, 2.3393e-05,
8.8076e-05, 0.00021516, 0.00041755, 0.00070125, 0.0010655, 0.0015038, 0.0020047, 0.0025534, 0.0031326,
0.0037237, 0.0043078, 0.0048663, 0.0053816, 0.0058375, 0.0062201, 0.0065177, 0.0067212, 0.0068245,
1.9458e-06, 2.3527e-05, 8.8583e-05, 0.0002164, 0.00041996, 0.00070529, 0.0010717, 0.0015125, 0.0020163,
0.0025681, 0.0031506, 0.0037452, 0.0043326, 0.0048943, 0.0054126, 0.0058711, 0.006256, 0.0065552,
0.0067599, 0.0068638, 1.9458e-06, 2.3527e-05, 8.8583e-05, 0.0002164, 0.00041996, 0.00070529, 0.0010717,
0.0015125, 0.0020163, 0.0025681, 0.0031506, 0.0037452, 0.0043326, 0.0048943, 0.0054126, 0.0058711,
0.006256, 0.0065552, 0.0067599, 0.0068638, 1.9347e-06, 2.3393e-05, 8.8076e-05, 0.00021516, 0.00041755,
0.00070125, 0.0010655, 0.0015038, 0.0020047, 0.0025534, 0.0031326, 0.0037237, 0.0043078, 0.0048663,
0.0053816, 0.0058375, 0.0062201, 0.0065177, 0.0067212, 0.0068245, 1.9124e-06, 2.3123e-05, 8.7061e-05,
0.00021268, 0.00041274, 0.00069317, 0.0010533, 0.0014865, 0.0019816, 0.002524, 0.0030965, 0.0036808,
0.0042582, 0.0048102, 0.0053195, 0.0057703, 0.0061485, 0.0064426, 0.0066438, 0.0067459, 1.8789e-06,
2.2718e-05, 8.5536e-05, 0.00020895, 0.00040551, 0.00068103, 0.0010348, 0.0014605, 0.0019469, 0.0024798,
0.0030423, 0.0036164, 0.0041836, 0.004726, 0.0052264, 0.0056692, 0.0060408, 0.0063298, 0.0065274,
0.0066277, 1.8342e-06, 2.2177e-05, 8.35e-05, 0.00020398, 0.00039586, 0.00066482, 0.0010102, 0.0014257,
0.0019006, 0.0024208, 0.0029698, 0.0035303, 0.004084, 0.0046135, 0.005102, 0.0055343, 0.005897,
0.0061791, 0.006372, 0.00647, 1.7782e-06, 2.15e-05, 8.0951e-05, 0.00019775, 0.00038377, 0.00064452,
0.00097934, 0.0013822, 0.0018426, 0.0023468, 0.0028792, 0.0034225, 0.0039593, 0.0044726, 0.0049462,
0.0053653, 0.0057169, 0.0059904, 0.0061775, 0.0062724, 1.7109e-06, 2.0687e-05, 7.7887e-05, 0.00019027,
0.00036925, 0.00062012, 0.00094227, 0.0013299, 0.0017728, 0.002258, 0.0027702, 0.0032929, 0.0038095,
0.0043034, 0.004759, 0.0051622, 0.0055006, 0.0057637, 0.0059437, 0.006035, 1.6323e-06, 1.9736e-05,
7.4309e-05, 0.00018153, 0.00035229, 0.00059164, 0.00089899, 0.0012688, 0.0016914, 0.0021543, 0.0026429,
0.0031417, 0.0036345, 0.0041057, 0.0045404, 0.0049251, 0.0052479, 0.0054989, 0.0056706, 0.0057578,
1.5425e-06, 1.865e-05, 7.0221e-05, 0.00017154, 0.0003329, 0.00055909, 0.00084952, 0.001199, 0.0015983,
0.0020358, 0.0024975, 0.0029688, 0.0034345, 0.0038798, 0.0042906, 0.0046541, 0.0049591, 0.0051964,
0.0053586, 0.005441, 1.4416e-06, 1.7431e-05, 6.5628e-05, 0.00016032, 0.00031113, 0.00052252, 0.00079396,
0.0011205, 0.0014938, 0.0019026, 0.0023342, 0.0027746, 0.0032099, 0.003626, 0.0040099, 0.0043497,
0.0046348, 0.0048565, 0.0050082, 0.0050851, 1.3299e-06, 1.608e-05, 6.0543e-05, 0.0001479, 0.00028702,
0.00048203, 0.00073244, 0.0010337, 0.001378, 0.0017552, 0.0021533, 0.0025596, 0.0029612, 0.0033451,
0.0036992, 0.0040127, 0.0042757, 0.0044802, 0.0046201, 0.0046911, 1.2077e-06, 1.4603e-05, 5.4982e-05,
0.00013431, 0.00026066, 0.00043776, 0.00066517, 0.00093877, 0.0012515, 0.001594, 0.0019555, 0.0023246,
0.0026892, 0.0030378, 0.0033595, 0.0036441, 0.003883, 0.0040687, 0.0041958, 0.0042603, 1.0757e-06,
1.3007e-05, 4.8971e-05, 0.00011963, 0.00023216, 0.0003899, 0.00059245, 0.00083614, 0.0011147, 0.0014197,
0.0017418, 0.0020704, 0.0023952, 0.0027057, 0.0029922, 0.0032457, 0.0034585, 0.0036239, 0.0037371,
0.0037945, 9.3448e-07, 1.1299e-05, 4.2542e-05, 0.00010393, 0.00020168, 0.00033872, 0.00051467, 0.00072637,
0.00096832, 0.0012333, 0.0015131, 0.0017986, 0.0020808, 0.0023505, 0.0025994, 0.0028196, 0.0030044,
0.0031482, 0.0032465, 0.0032964, 7.8497e-07, 9.4914e-06, 3.5736e-05, 8.7299e-05, 0.00016942, 0.00028452,
0.00043233, 0.00061016, 0.0008134, 0.001036, 0.001271, 0.0015109, 0.0017479, 0.0019745, 0.0021835,
0.0023685, 0.0025238, 0.0026445, 0.0027271, 0.002769, 6.2827e-07, 7.5966e-06, 2.8602e-05, 6.9871e-05,
0.0001356, 0.00022773, 0.00034603, 0.00048836, 0.00065103, 0.0008292, 0.0010173, 0.0012093, 0.0013989,
0.0015803, 0.0017476, 0.0018957, 0.0020199, 0.0021166, 0.0021827, 0.0022162, 4.6565e-07, 5.6303e-06,
2.1199e-05, 5.1785e-05, 0.0001005, 0.00016878, 0.00025646, 0.00036195, 0.00048251, 0.00061457, 0.00075397,
0.00089624, 0.0010368, 0.0011712, 0.0012953, 0.001405, 0.0014971, 0.0015687, 0.0016177, 0.0016426,
2.9855e-07, 3.6099e-06, 1.3592e-05, 3.3203e-05, 6.4435e-05, 0.00010821, 0.00016443, 0.00023206, 0.00030936,
0.00039403, 0.00048341, 0.00057463, 0.00066477, 0.00075095, 0.00083047, 0.00090083, 0.00095987, 0.0010058,
0.0010372, 0.0010531, 1.2879e-07, 1.5572e-06, 5.863e-06, 1.4322e-05, 2.7795e-05, 4.668e-05, 7.093e-05,
0.0001001, 0.00013345, 0.00016997, 0.00020853, 0.00024788, 0.00028676, 0.00032394, 0.00035823, 0.00038859,
0.00041406, 0.00043386, 0.00044741, 0.00045429}},
{{-0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751,
-0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983,
-0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763,
-0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666,
-0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116,
-0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278,
-0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358,
-0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807,
-0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642,
-0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325,
-0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999,
-0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231,
-0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901,
-0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373,
-0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167,
-0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075,
-0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866,
-0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091,
-0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199,
-0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501,
-0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751,
-0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983,
-0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763,
-0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666,
-0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116,
-0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278,
-0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358,
-0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807,
-0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642,
-0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325,
-0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999,
-0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231,
-0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901,
-0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373,
-0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167,
-0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075,
-0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866,
-0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091,
-0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199,
-0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501,
-0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751,
-0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983,
-0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763,
-0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666,
-0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116,
-0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278,
-0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358,
-0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807,
-0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642,
-0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325,
-0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999,
-0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231,
-0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901,
-0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373,
-0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167,
-0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075,
-0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866,
-0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091,
-0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199,
-0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501,
-0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751,
-0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983,
-0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763,
-0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666,
-0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116,
-0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278,
-0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358,
-0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807,
-0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642,
-0.05501},
{1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724,
1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5724, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793,
1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5793, 1.5915, 1.5915,
1.5915, 1.5915, 1.5915, 1.5915, 1.5915, 1.5915, 1.5915, 1.5915, 1.5915, 1.5915, 1.5915, 1.5915, 1.5915, 1.5915,
1.5915, 1.5915, 1.5915, 1.5915, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091,
1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6091, 1.6318, 1.6318, 1.6318, 1.6318,
1.6318, 1.6318, 1.6318, 1.6318, 1.6318, 1.6318, 1.6318, 1.6318, 1.6318, 1.6318, 1.6318, 1.6318, 1.6318, 1.6318,
1.6318, 1.6318, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594,
1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6594, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917,
1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917, 1.6917,
1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284,
1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7284, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692,
1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.7692, 1.8137, 1.8137,
1.8137, 1.8137, 1.8137, 1.8137, 1.8137, 1.8137, 1.8137, 1.8137, 1.8137, 1.8137, 1.8137, 1.8137, 1.8137, 1.8137,
1.8137, 1.8137, 1.8137, 1.8137, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616,
1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.8616, 1.9126, 1.9126, 1.9126, 1.9126,
1.9126, 1.9126, 1.9126, 1.9126, 1.9126, 1.9126, 1.9126, 1.9126, 1.9126, 1.9126, 1.9126, 1.9126, 1.9126, 1.9126,
1.9126, 1.9126, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663,
1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 1.9663, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223,
2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223, 2.0223,
2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803,
2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.0803, 2.14, 2.14, 2.14, 2.14, 2.14, 2.14, 2.14, 2.14,
2.14, 2.14, 2.14, 2.14, 2.14, 2.14, 2.14, 2.14, 2.14, 2.14, 2.14, 2.14, 2.2009, 2.2009,
2.2009, 2.2009, 2.2009, 2.2009, 2.2009, 2.2009, 2.2009, 2.2009, 2.2009, 2.2009, 2.2009, 2.2009, 2.2009, 2.2009,
2.2009, 2.2009, 2.2009, 2.2009, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626,
2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.2626, 2.3249, 2.3249, 2.3249, 2.3249,
2.3249, 2.3249, 2.3249, 2.3249, 2.3249, 2.3249, 2.3249, 2.3249, 2.3249, 2.3249, 2.3249, 2.3249, 2.3249, 2.3249,
2.3249, 2.3249, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874,
2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.3874, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498,
2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498, 2.4498,
2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115,
2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5115, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724,
2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.5724, 2.6321, 2.6321,
2.6321, 2.6321, 2.6321, 2.6321, 2.6321, 2.6321, 2.6321, 2.6321, 2.6321, 2.6321, 2.6321, 2.6321, 2.6321, 2.6321,
2.6321, 2.6321, 2.6321, 2.6321, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901,
2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.6901, 2.7461, 2.7461, 2.7461, 2.7461,
2.7461, 2.7461, 2.7461, 2.7461, 2.7461, 2.7461, 2.7461, 2.7461, 2.7461, 2.7461, 2.7461, 2.7461, 2.7461, 2.7461,
2.7461, 2.7461, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998,
2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.7998, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508,
2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508, 2.8508,
2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987,
2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.8987, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432,
2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.9432, 2.984, 2.984,
2.984, 2.984, 2.984, 2.984, 2.984, 2.984, 2.984, 2.984, 2.984, 2.984, 2.984, 2.984, 2.984, 2.984,
2.984, 2.984, 2.984, 2.984, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207,
3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0207, 3.0529, 3.0529, 3.0529, 3.0529,
3.0529, 3.0529, 3.0529, 3.0529, 3.0529, 3.0529, 3.0529, 3.0529, 3.0529, 3.0529, 3.0529, 3.0529, 3.0529, 3.0529,
3.0529, 3.0529, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806,
3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.0806, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033,
3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033, 3.1033,
3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208,
3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1208, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331,
3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.1331, 3.14, 3.14,
3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14, 3.14,
3.14, 3.14, 3.14, 3.14},
{1.2879e-07, 1.5572e-06, 5.863e-06, 1.4322e-05, 2.7795e-05, 4.668e-05, 7.093e-05, 0.0001001, 0.00013345,
0.00016997, 0.00020853, 0.00024788, 0.00028676, 0.00032394, 0.00035823, 0.00038859, 0.00041406, 0.00043386,
0.00044741, 0.00045429, 2.9855e-07, 3.6099e-06, 1.3592e-05, 3.3203e-05, 6.4435e-05, 0.00010821, 0.00016443,
0.00023206, 0.00030936, 0.00039403, 0.00048341, 0.00057463, 0.00066477, 0.00075095, 0.00083047, 0.00090083,
0.00095987, 0.0010058, 0.0010372, 0.0010531, 4.6565e-07, 5.6303e-06, 2.1199e-05, 5.1785e-05, 0.0001005,
0.00016878, 0.00025646, 0.00036195, 0.00048251, 0.00061457, 0.00075397, 0.00089624, 0.0010368, 0.0011712,
0.0012953, 0.001405, 0.0014971, 0.0015687, 0.0016177, 0.0016426, 6.2827e-07, 7.5966e-06, 2.8602e-05,
6.9871e-05, 0.0001356, 0.00022773, 0.00034603, 0.00048836, 0.00065103, 0.0008292, 0.0010173, 0.0012093,
0.0013989, 0.0015803, 0.0017476, 0.0018957, 0.0020199, 0.0021166, 0.0021827, 0.0022162, 7.8497e-07,
9.4914e-06, 3.5736e-05, 8.7299e-05, 0.00016942, 0.00028452, 0.00043233, 0.00061016, 0.0008134, 0.001036,
0.001271, 0.0015109, 0.0017479, 0.0019745, 0.0021835, 0.0023685, 0.0025238, 0.0026445, 0.0027271,
0.002769, 9.3448e-07, 1.1299e-05, 4.2542e-05, 0.00010393, 0.00020168, 0.00033872, 0.00051467, 0.00072637,
0.00096832, 0.0012333, 0.0015131, 0.0017986, 0.0020808, 0.0023505, 0.0025994, 0.0028196, 0.0030044,
0.0031482, 0.0032465, 0.0032964, 1.0757e-06, 1.3007e-05, 4.8971e-05, 0.00011963, 0.00023216, 0.0003899,
0.00059245, 0.00083614, 0.0011147, 0.0014197, 0.0017418, 0.0020704, 0.0023952, 0.0027057, 0.0029922,
0.0032457, 0.0034585, 0.0036239, 0.0037371, 0.0037945, 1.2077e-06, 1.4603e-05, 5.4982e-05, 0.00013431,
0.00026066, 0.00043776, 0.00066517, 0.00093877, 0.0012515, 0.001594, 0.0019555, 0.0023246, 0.0026892,
0.0030378, 0.0033595, 0.0036441, 0.003883, 0.0040687, 0.0041958, 0.0042603, 1.3299e-06, 1.608e-05,
6.0543e-05, 0.0001479, 0.00028702, 0.00048203, 0.00073244, 0.0010337, 0.001378, 0.0017552, 0.0021533,
0.0025596, 0.0029612, 0.0033451, 0.0036992, 0.0040127, 0.0042757, 0.0044802, 0.0046201, 0.0046911,
1.4416e-06, 1.7431e-05, 6.5628e-05, 0.00016032, 0.00031113, 0.00052252, 0.00079396, 0.0011205, 0.0014938,
0.0019026, 0.0023342, 0.0027746, 0.0032099, 0.003626, 0.0040099, 0.0043497, 0.0046348, 0.0048565,
0.0050082, 0.0050851, 1.5425e-06, 1.865e-05, 7.0221e-05, 0.00017154, 0.0003329, 0.00055909, 0.00084952,
0.001199, 0.0015983, 0.0020358, 0.0024975, 0.0029688, 0.0034345, 0.0038798, 0.0042906, 0.0046541,
0.0049591, 0.0051964, 0.0053586, 0.005441, 1.6323e-06, 1.9736e-05, 7.4309e-05, 0.00018153, 0.00035229,
0.00059164, 0.00089899, 0.0012688, 0.0016914, 0.0021543, 0.0026429, 0.0031417, 0.0036345, 0.0041057,
0.0045404, 0.0049251, 0.0052479, 0.0054989, 0.0056706, 0.0057578, 1.7109e-06, 2.0687e-05, 7.7887e-05,
0.00019027, 0.00036925, 0.00062012, 0.00094227, 0.0013299, 0.0017728, 0.002258, 0.0027702, 0.0032929,
0.0038095, 0.0043034, 0.004759, 0.0051622, 0.0055006, 0.0057637, 0.0059437, 0.006035, 1.7782e-06,
2.15e-05, 8.0951e-05, 0.00019775, 0.00038377, 0.00064452, 0.00097934, 0.0013822, 0.0018426, 0.0023468,
0.0028792, 0.0034225, 0.0039593, 0.0044726, 0.0049462, 0.0053653, 0.0057169, 0.0059904, 0.0061775,
0.0062724, 1.8342e-06, 2.2177e-05, 8.35e-05, 0.00020398, 0.00039586, 0.00066482, 0.0010102, 0.0014257,
0.0019006, 0.0024208, 0.0029698, 0.0035303, 0.004084, 0.0046135, 0.005102, 0.0055343, 0.005897,
0.0061791, 0.006372, 0.00647, 1.8789e-06, 2.2718e-05, 8.5536e-05, 0.00020895, 0.00040551, 0.00068103,
0.0010348, 0.0014605, 0.0019469, 0.0024798, 0.0030423, 0.0036164, 0.0041836, 0.004726, 0.0052264,
0.0056692, 0.0060408, 0.0063298, 0.0065274, 0.0066277, 1.9124e-06, 2.3123e-05, 8.7061e-05, 0.00021268,
0.00041274, 0.00069317, 0.0010533, 0.0014865, 0.0019816, 0.002524, 0.0030965, 0.0036808, 0.0042582,
0.0048102, 0.0053195, 0.0057703, 0.0061485, 0.0064426, 0.0066438, 0.0067459, 1.9347e-06, 2.3393e-05,
8.8076e-05, 0.00021516, 0.00041755, 0.00070125, 0.0010655, 0.0015038, 0.0020047, 0.0025534, 0.0031326,
0.0037237, 0.0043078, 0.0048663, 0.0053816, 0.0058375, 0.0062201, 0.0065177, 0.0067212, 0.0068245,
1.9458e-06, 2.3527e-05, 8.8583e-05, 0.0002164, 0.00041996, 0.00070529, 0.0010717, 0.0015125, 0.0020163,
0.0025681, 0.0031506, 0.0037452, 0.0043326, 0.0048943, 0.0054126, 0.0058711, 0.006256, 0.0065552,
0.0067599, 0.0068638, 1.9458e-06, 2.3527e-05, 8.8583e-05, 0.0002164, 0.00041996, 0.00070529, 0.0010717,
0.0015125, 0.0020163, 0.0025681, 0.0031506, 0.0037452, 0.0043326, 0.0048943, 0.0054126, 0.0058711,
0.006256, 0.0065552, 0.0067599, 0.0068638, 1.9347e-06, 2.3393e-05, 8.8076e-05, 0.00021516, 0.00041755,
0.00070125, 0.0010655, 0.0015038, 0.0020047, 0.0025534, 0.0031326, 0.0037237, 0.0043078, 0.0048663,
0.0053816, 0.0058375, 0.0062201, 0.0065177, 0.0067212, 0.0068245, 1.9124e-06, 2.3123e-05, 8.7061e-05,
0.00021268, 0.00041274, 0.00069317, 0.0010533, 0.0014865, 0.0019816, 0.002524, 0.0030965, 0.0036808,
0.0042582, 0.0048102, 0.0053195, 0.0057703, 0.0061485, 0.0064426, 0.0066438, 0.0067459, 1.8789e-06,
2.2718e-05, 8.5536e-05, 0.00020895, 0.00040551, 0.00068103, 0.0010348, 0.0014605, 0.0019469, 0.0024798,
0.0030423, 0.0036164, 0.0041836, 0.004726, 0.0052264, 0.0056692, 0.0060408, 0.0063298, 0.0065274,
0.0066277, 1.8342e-06, 2.2177e-05, 8.35e-05, 0.00020398, 0.00039586, 0.00066482, 0.0010102, 0.0014257,
0.0019006, 0.0024208, 0.0029698, 0.0035303, 0.004084, 0.0046135, 0.005102, 0.0055343, 0.005897,
0.0061791, 0.006372, 0.00647, 1.7782e-06, 2.15e-05, 8.0951e-05, 0.00019775, 0.00038377, 0.00064452,
0.00097934, 0.0013822, 0.0018426, 0.0023468, 0.0028792, 0.0034225, 0.0039593, 0.0044726, 0.0049462,
0.0053653, 0.0057169, 0.0059904, 0.0061775, 0.0062724, 1.7109e-06, 2.0687e-05, 7.7887e-05, 0.00019027,
0.00036925, 0.00062012, 0.00094227, 0.0013299, 0.0017728, 0.002258, 0.0027702, 0.0032929, 0.0038095,
0.0043034, 0.004759, 0.0051622, 0.0055006, 0.0057637, 0.0059437, 0.006035, 1.6323e-06, 1.9736e-05,
7.4309e-05, 0.00018153, 0.00035229, 0.00059164, 0.00089899, 0.0012688, 0.0016914, 0.0021543, 0.0026429,
0.0031417, 0.0036345, 0.0041057, 0.0045404, 0.0049251, 0.0052479, 0.0054989, 0.0056706, 0.0057578,
1.5425e-06, 1.865e-05, 7.0221e-05, 0.00017154, 0.0003329, 0.00055909, 0.00084952, 0.001199, 0.0015983,
0.0020358, 0.0024975, 0.0029688, 0.0034345, 0.0038798, 0.0042906, 0.0046541, 0.0049591, 0.0051964,
0.0053586, 0.005441, 1.4416e-06, 1.7431e-05, 6.5628e-05, 0.00016032, 0.00031113, 0.00052252, 0.00079396,
0.0011205, 0.0014938, 0.0019026, 0.0023342, 0.0027746, 0.0032099, 0.003626, 0.0040099, 0.0043497,
0.0046348, 0.0048565, 0.0050082, 0.0050851, 1.3299e-06, 1.608e-05, 6.0543e-05, 0.0001479, 0.00028702,
0.00048203, 0.00073244, 0.0010337, 0.001378, 0.0017552, 0.0021533, 0.0025596, 0.0029612, 0.0033451,
0.0036992, 0.0040127, 0.0042757, 0.0044802, 0.0046201, 0.0046911, 1.2077e-06, 1.4603e-05, 5.4982e-05,
0.00013431, 0.00026066, 0.00043776, 0.00066517, 0.00093877, 0.0012515, 0.001594, 0.0019555, 0.0023246,
0.0026892, 0.0030378, 0.0033595, 0.0036441, 0.003883, 0.0040687, 0.0041958, 0.0042603, 1.0757e-06,
1.3007e-05, 4.8971e-05, 0.00011963, 0.00023216, 0.0003899, 0.00059245, 0.00083614, 0.0011147, 0.0014197,
0.0017418, 0.0020704, 0.0023952, 0.0027057, 0.0029922, 0.0032457, 0.0034585, 0.0036239, 0.0037371,
0.0037945, 9.3448e-07, 1.1299e-05, 4.2542e-05, 0.00010393, 0.00020168, 0.00033872, 0.00051467, 0.00072637,
0.00096832, 0.0012333, 0.0015131, 0.0017986, 0.0020808, 0.0023505, 0.0025994, 0.0028196, 0.0030044,
0.0031482, 0.0032465, 0.0032964, 7.8497e-07, 9.4914e-06, 3.5736e-05, 8.7299e-05, 0.00016942, 0.00028452,
0.00043233, 0.00061016, 0.0008134, 0.001036, 0.001271, 0.0015109, 0.0017479, 0.0019745, 0.0021835,
0.0023685, 0.0025238, 0.0026445, 0.0027271, 0.002769, 6.2827e-07, 7.5966e-06, 2.8602e-05, 6.9871e-05,
0.0001356, 0.00022773, 0.00034603, 0.00048836, 0.00065103, 0.0008292, 0.0010173, 0.0012093, 0.0013989,
0.0015803, 0.0017476, 0.0018957, 0.0020199, 0.0021166, 0.0021827, 0.0022162, 4.6565e-07, 5.6303e-06,
2.1199e-05, 5.1785e-05, 0.0001005, 0.00016878, 0.00025646, 0.00036195, 0.00048251, 0.00061457, 0.00075397,
0.00089624, 0.0010368, 0.0011712, 0.0012953, 0.001405, 0.0014971, 0.0015687, 0.0016177, 0.0016426,
2.9855e-07, 3.6099e-06, 1.3592e-05, 3.3203e-05, 6.4435e-05, 0.00010821, 0.00016443, 0.00023206, 0.00030936,
0.00039403, 0.00048341, 0.00057463, 0.00066477, 0.00075095, 0.00083047, 0.00090083, 0.00095987, 0.0010058,
0.0010372, 0.0010531, 1.2879e-07, 1.5572e-06, 5.863e-06, 1.4322e-05, 2.7795e-05, 4.668e-05, 7.093e-05,
0.0001001, 0.00013345, 0.00016997, 0.00020853, 0.00024788, 0.00028676, 0.00032394, 0.00035823, 0.00038859,
0.00041406, 0.00043386, 0.00044741, 0.00045429}},
{{-0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751,
-0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983,
-0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763,
-0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666,
-0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116,
-0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278,
-0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358,
-0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807,
-0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642,
-0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325,
-0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999,
-0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231,
-0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901,
-0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373,
-0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167,
-0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075,
-0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866,
-0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091,
-0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199,
-0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501,
-0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751,
-0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983,
-0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763,
-0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666,
-0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116,
-0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278,
-0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358,
-0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807,
-0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642,
-0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325,
-0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999,
-0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231,
-0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901,
-0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373,
-0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167,
-0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075,
-0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866,
-0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091,
-0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199,
-0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501,
-0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751,
-0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983,
-0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763,
-0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666,
-0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116,
-0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278,
-0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358,
-0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807,
-0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642,
-0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325,
-0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999,
-0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231,
-0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901,
-0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373,
-0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167,
-0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075,
-0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866,
-0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091,
-0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199,
-0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501,
-0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751,
-0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983,
-0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763,
-0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666,
-0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116,
-0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278,
-0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358,
-0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807,
-0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642,
-0.05501},
{3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432,
3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1432, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501,
3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1501, 3.1623, 3.1623,
3.1623, 3.1623, 3.1623, 3.1623, 3.1623, 3.1623, 3.1623, 3.1623, 3.1623, 3.1623, 3.1623, 3.1623, 3.1623, 3.1623,
3.1623, 3.1623, 3.1623, 3.1623, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799,
3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.1799, 3.2026, 3.2026, 3.2026, 3.2026,
3.2026, 3.2026, 3.2026, 3.2026, 3.2026, 3.2026, 3.2026, 3.2026, 3.2026, 3.2026, 3.2026, 3.2026, 3.2026, 3.2026,
3.2026, 3.2026, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302,
3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2302, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625,
3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625, 3.2625,
3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992,
3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.2992, 3.34, 3.34, 3.34, 3.34, 3.34, 3.34, 3.34, 3.34,
3.34, 3.34, 3.34, 3.34, 3.34, 3.34, 3.34, 3.34, 3.34, 3.34, 3.34, 3.34, 3.3845, 3.3845,
3.3845, 3.3845, 3.3845, 3.3845, 3.3845, 3.3845, 3.3845, 3.3845, 3.3845, 3.3845, 3.3845, 3.3845, 3.3845, 3.3845,
3.3845, 3.3845, 3.3845, 3.3845, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324,
3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4324, 3.4834, 3.4834, 3.4834, 3.4834,
3.4834, 3.4834, 3.4834, 3.4834, 3.4834, 3.4834, 3.4834, 3.4834, 3.4834, 3.4834, 3.4834, 3.4834, 3.4834, 3.4834,
3.4834, 3.4834, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371,
3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5371, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931,
3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931, 3.5931,
3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511,
3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.6511, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108,
3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7108, 3.7716, 3.7716,
3.7716, 3.7716, 3.7716, 3.7716, 3.7716, 3.7716, 3.7716, 3.7716, 3.7716, 3.7716, 3.7716, 3.7716, 3.7716, 3.7716,
3.7716, 3.7716, 3.7716, 3.7716, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334,
3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8334, 3.8957, 3.8957, 3.8957, 3.8957,
3.8957, 3.8957, 3.8957, 3.8957, 3.8957, 3.8957, 3.8957, 3.8957, 3.8957, 3.8957, 3.8957, 3.8957, 3.8957, 3.8957,
3.8957, 3.8957, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582,
3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 3.9582, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206,
4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206, 4.0206,
4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823,
4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.0823, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432,
4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.1432, 4.2028, 4.2028,
4.2028, 4.2028, 4.2028, 4.2028, 4.2028, 4.2028, 4.2028, 4.2028, 4.2028, 4.2028, 4.2028, 4.2028, 4.2028, 4.2028,
4.2028, 4.2028, 4.2028, 4.2028, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609,
4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.2609, 4.3169, 4.3169, 4.3169, 4.3169,
4.3169, 4.3169, 4.3169, 4.3169, 4.3169, 4.3169, 4.3169, 4.3169, 4.3169, 4.3169, 4.3169, 4.3169, 4.3169, 4.3169,
4.3169, 4.3169, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706,
4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.3706, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216,
4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216, 4.4216,
4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695,
4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.4695, 4.514, 4.514, 4.514, 4.514, 4.514, 4.514, 4.514, 4.514,
4.514, 4.514, 4.514, 4.514, 4.514, 4.514, 4.514, 4.514, 4.514, 4.514, 4.514, 4.514, 4.5548, 4.5548,
4.5548, 4.5548, 4.5548, 4.5548, 4.5548, 4.5548, 4.5548, 4.5548, 4.5548, 4.5548, 4.5548, 4.5548, 4.5548, 4.5548,
4.5548, 4.5548, 4.5548, 4.5548, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915,
4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.5915, 4.6237, 4.6237, 4.6237, 4.6237,
4.6237, 4.6237, 4.6237, 4.6237, 4.6237, 4.6237, 4.6237, 4.6237, 4.6237, 4.6237, 4.6237, 4.6237, 4.6237, 4.6237,
4.6237, 4.6237, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514,
4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6514, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741,
4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741, 4.6741,
4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916,
4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.6916, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039,
4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7039, 4.7108, 4.7108,
4.7108, 4.7108, 4.7108, 4.7108, 4.7108, 4.7108, 4.7108, 4.7108, 4.7108, 4.7108, 4.7108, 4.7108, 4.7108, 4.7108,
4.7108, 4.7108, 4.7108, 4.7108},
{1.2879e-07, 1.5572e-06, 5.863e-06, 1.4322e-05, 2.7795e-05, 4.668e-05, 7.093e-05, 0.0001001, 0.00013345,
0.00016997, 0.00020853, 0.00024788, 0.00028676, 0.00032394, 0.00035823, 0.00038859, 0.00041406, 0.00043386,
0.00044741, 0.00045429, 2.9855e-07, 3.6099e-06, 1.3592e-05, 3.3203e-05, 6.4435e-05, 0.00010821, 0.00016443,
0.00023206, 0.00030936, 0.00039403, 0.00048341, 0.00057463, 0.00066477, 0.00075095, 0.00083047, 0.00090083,
0.00095987, 0.0010058, 0.0010372, 0.0010531, 4.6565e-07, 5.6303e-06, 2.1199e-05, 5.1785e-05, 0.0001005,
0.00016878, 0.00025646, 0.00036195, 0.00048251, 0.00061457, 0.00075397, 0.00089624, 0.0010368, 0.0011712,
0.0012953, 0.001405, 0.0014971, 0.0015687, 0.0016177, 0.0016426, 6.2827e-07, 7.5966e-06, 2.8602e-05,
6.9871e-05, 0.0001356, 0.00022773, 0.00034603, 0.00048836, 0.00065103, 0.0008292, 0.0010173, 0.0012093,
0.0013989, 0.0015803, 0.0017476, 0.0018957, 0.0020199, 0.0021166, 0.0021827, 0.0022162, 7.8497e-07,
9.4914e-06, 3.5736e-05, 8.7299e-05, 0.00016942, 0.00028452, 0.00043233, 0.00061016, 0.0008134, 0.001036,
0.001271, 0.0015109, 0.0017479, 0.0019745, 0.0021835, 0.0023685, 0.0025238, 0.0026445, 0.0027271,
0.002769, 9.3448e-07, 1.1299e-05, 4.2542e-05, 0.00010393, 0.00020168, 0.00033872, 0.00051467, 0.00072637,
0.00096832, 0.0012333, 0.0015131, 0.0017986, 0.0020808, 0.0023505, 0.0025994, 0.0028196, 0.0030044,
0.0031482, 0.0032465, 0.0032964, 1.0757e-06, 1.3007e-05, 4.8971e-05, 0.00011963, 0.00023216, 0.0003899,
0.00059245, 0.00083614, 0.0011147, 0.0014197, 0.0017418, 0.0020704, 0.0023952, 0.0027057, 0.0029922,
0.0032457, 0.0034585, 0.0036239, 0.0037371, 0.0037945, 1.2077e-06, 1.4603e-05, 5.4982e-05, 0.00013431,
0.00026066, 0.00043776, 0.00066517, 0.00093877, 0.0012515, 0.001594, 0.0019555, 0.0023246, 0.0026892,
0.0030378, 0.0033595, 0.0036441, 0.003883, 0.0040687, 0.0041958, 0.0042603, 1.3299e-06, 1.608e-05,
6.0543e-05, 0.0001479, 0.00028702, 0.00048203, 0.00073244, 0.0010337, 0.001378, 0.0017552, 0.0021533,
0.0025596, 0.0029612, 0.0033451, 0.0036992, 0.0040127, 0.0042757, 0.0044802, 0.0046201, 0.0046911,
1.4416e-06, 1.7431e-05, 6.5628e-05, 0.00016032, 0.00031113, 0.00052252, 0.00079396, 0.0011205, 0.0014938,
0.0019026, 0.0023342, 0.0027746, 0.0032099, 0.003626, 0.0040099, 0.0043497, 0.0046348, 0.0048565,
0.0050082, 0.0050851, 1.5425e-06, 1.865e-05, 7.0221e-05, 0.00017154, 0.0003329, 0.00055909, 0.00084952,
0.001199, 0.0015983, 0.0020358, 0.0024975, 0.0029688, 0.0034345, 0.0038798, 0.0042906, 0.0046541,
0.0049591, 0.0051964, 0.0053586, 0.005441, 1.6323e-06, 1.9736e-05, 7.4309e-05, 0.00018153, 0.00035229,
0.00059164, 0.00089899, 0.0012688, 0.0016914, 0.0021543, 0.0026429, 0.0031417, 0.0036345, 0.0041057,
0.0045404, 0.0049251, 0.0052479, 0.0054989, 0.0056706, 0.0057578, 1.7109e-06, 2.0687e-05, 7.7887e-05,
0.00019027, 0.00036925, 0.00062012, 0.00094227, 0.0013299, 0.0017728, 0.002258, 0.0027702, 0.0032929,
0.0038095, 0.0043034, 0.004759, 0.0051622, 0.0055006, 0.0057637, 0.0059437, 0.006035, 1.7782e-06,
2.15e-05, 8.0951e-05, 0.00019775, 0.00038377, 0.00064452, 0.00097934, 0.0013822, 0.0018426, 0.0023468,
0.0028792, 0.0034225, 0.0039593, 0.0044726, 0.0049462, 0.0053653, 0.0057169, 0.0059904, 0.0061775,
0.0062724, 1.8342e-06, 2.2177e-05, 8.35e-05, 0.00020398, 0.00039586, 0.00066482, 0.0010102, 0.0014257,
0.0019006, 0.0024208, 0.0029698, 0.0035303, 0.004084, 0.0046135, 0.005102, 0.0055343, 0.005897,
0.0061791, 0.006372, 0.00647, 1.8789e-06, 2.2718e-05, 8.5536e-05, 0.00020895, 0.00040551, 0.00068103,
0.0010348, 0.0014605, 0.0019469, 0.0024798, 0.0030423, 0.0036164, 0.0041836, 0.004726, 0.0052264,
0.0056692, 0.0060408, 0.0063298, 0.0065274, 0.0066277, 1.9124e-06, 2.3123e-05, 8.7061e-05, 0.00021268,
0.00041274, 0.00069317, 0.0010533, 0.0014865, 0.0019816, 0.002524, 0.0030965, 0.0036808, 0.0042582,
0.0048102, 0.0053195, 0.0057703, 0.0061485, 0.0064426, 0.0066438, 0.0067459, 1.9347e-06, 2.3393e-05,
8.8076e-05, 0.00021516, 0.00041755, 0.00070125, 0.0010655, 0.0015038, 0.0020047, 0.0025534, 0.0031326,
0.0037237, 0.0043078, 0.0048663, 0.0053816, 0.0058375, 0.0062201, 0.0065177, 0.0067212, 0.0068245,
1.9458e-06, 2.3527e-05, 8.8583e-05, 0.0002164, 0.00041996, 0.00070529, 0.0010717, 0.0015125, 0.0020163,
0.0025681, 0.0031506, 0.0037452, 0.0043326, 0.0048943, 0.0054126, 0.0058711, 0.006256, 0.0065552,
0.0067599, 0.0068638, 1.9458e-06, 2.3527e-05, 8.8583e-05, 0.0002164, 0.00041996, 0.00070529, 0.0010717,
0.0015125, 0.0020163, 0.0025681, 0.0031506, 0.0037452, 0.0043326, 0.0048943, 0.0054126, 0.0058711,
0.006256, 0.0065552, 0.0067599, 0.0068638, 1.9347e-06, 2.3393e-05, 8.8076e-05, 0.00021516, 0.00041755,
0.00070125, 0.0010655, 0.0015038, 0.0020047, 0.0025534, 0.0031326, 0.0037237, 0.0043078, 0.0048663,
0.0053816, 0.0058375, 0.0062201, 0.0065177, 0.0067212, 0.0068245, 1.9124e-06, 2.3123e-05, 8.7061e-05,
0.00021268, 0.00041274, 0.00069317, 0.0010533, 0.0014865, 0.0019816, 0.002524, 0.0030965, 0.0036808,
0.0042582, 0.0048102, 0.0053195, 0.0057703, 0.0061485, 0.0064426, 0.0066438, 0.0067459, 1.8789e-06,
2.2718e-05, 8.5536e-05, 0.00020895, 0.00040551, 0.00068103, 0.0010348, 0.0014605, 0.0019469, 0.0024798,
0.0030423, 0.0036164, 0.0041836, 0.004726, 0.0052264, 0.0056692, 0.0060408, 0.0063298, 0.0065274,
0.0066277, 1.8342e-06, 2.2177e-05, 8.35e-05, 0.00020398, 0.00039586, 0.00066482, 0.0010102, 0.0014257,
0.0019006, 0.0024208, 0.0029698, 0.0035303, 0.004084, 0.0046135, 0.005102, 0.0055343, 0.005897,
0.0061791, 0.006372, 0.00647, 1.7782e-06, 2.15e-05, 8.0951e-05, 0.00019775, 0.00038377, 0.00064452,
0.00097934, 0.0013822, 0.0018426, 0.0023468, 0.0028792, 0.0034225, 0.0039593, 0.0044726, 0.0049462,
0.0053653, 0.0057169, 0.0059904, 0.0061775, 0.0062724, 1.7109e-06, 2.0687e-05, 7.7887e-05, 0.00019027,
0.00036925, 0.00062012, 0.00094227, 0.0013299, 0.0017728, 0.002258, 0.0027702, 0.0032929, 0.0038095,
0.0043034, 0.004759, 0.0051622, 0.0055006, 0.0057637, 0.0059437, 0.006035, 1.6323e-06, 1.9736e-05,
7.4309e-05, 0.00018153, 0.00035229, 0.00059164, 0.00089899, 0.0012688, 0.0016914, 0.0021543, 0.0026429,
0.0031417, 0.0036345, 0.0041057, 0.0045404, 0.0049251, 0.0052479, 0.0054989, 0.0056706, 0.0057578,
1.5425e-06, 1.865e-05, 7.0221e-05, 0.00017154, 0.0003329, 0.00055909, 0.00084952, 0.001199, 0.0015983,
0.0020358, 0.0024975, 0.0029688, 0.0034345, 0.0038798, 0.0042906, 0.0046541, 0.0049591, 0.0051964,
0.0053586, 0.005441, 1.4416e-06, 1.7431e-05, 6.5628e-05, 0.00016032, 0.00031113, 0.00052252, 0.00079396,
0.0011205, 0.0014938, 0.0019026, 0.0023342, 0.0027746, 0.0032099, 0.003626, 0.0040099, 0.0043497,
0.0046348, 0.0048565, 0.0050082, 0.0050851, 1.3299e-06, 1.608e-05, 6.0543e-05, 0.0001479, 0.00028702,
0.00048203, 0.00073244, 0.0010337, 0.001378, 0.0017552, 0.0021533, 0.0025596, 0.0029612, 0.0033451,
0.0036992, 0.0040127, 0.0042757, 0.0044802, 0.0046201, 0.0046911, 1.2077e-06, 1.4603e-05, 5.4982e-05,
0.00013431, 0.00026066, 0.00043776, 0.00066517, 0.00093877, 0.0012515, 0.001594, 0.0019555, 0.0023246,
0.0026892, 0.0030378, 0.0033595, 0.0036441, 0.003883, 0.0040687, 0.0041958, 0.0042603, 1.0757e-06,
1.3007e-05, 4.8971e-05, 0.00011963, 0.00023216, 0.0003899, 0.00059245, 0.00083614, 0.0011147, 0.0014197,
0.0017418, 0.0020704, 0.0023952, 0.0027057, 0.0029922, 0.0032457, 0.0034585, 0.0036239, 0.0037371,
0.0037945, 9.3448e-07, 1.1299e-05, 4.2542e-05, 0.00010393, 0.00020168, 0.00033872, 0.00051467, 0.00072637,
0.00096832, 0.0012333, 0.0015131, 0.0017986, 0.0020808, 0.0023505, 0.0025994, 0.0028196, 0.0030044,
0.0031482, 0.0032465, 0.0032964, 7.8497e-07, 9.4914e-06, 3.5736e-05, 8.7299e-05, 0.00016942, 0.00028452,
0.00043233, 0.00061016, 0.0008134, 0.001036, 0.001271, 0.0015109, 0.0017479, 0.0019745, 0.0021835,
0.0023685, 0.0025238, 0.0026445, 0.0027271, 0.002769, 6.2827e-07, 7.5966e-06, 2.8602e-05, 6.9871e-05,
0.0001356, 0.00022773, 0.00034603, 0.00048836, 0.00065103, 0.0008292, 0.0010173, 0.0012093, 0.0013989,
0.0015803, 0.0017476, 0.0018957, 0.0020199, 0.0021166, 0.0021827, 0.0022162, 4.6565e-07, 5.6303e-06,
2.1199e-05, 5.1785e-05, 0.0001005, 0.00016878, 0.00025646, 0.00036195, 0.00048251, 0.00061457, 0.00075397,
0.00089624, 0.0010368, 0.0011712, 0.0012953, 0.001405, 0.0014971, 0.0015687, 0.0016177, 0.0016426,
2.9855e-07, 3.6099e-06, 1.3592e-05, 3.3203e-05, 6.4435e-05, 0.00010821, 0.00016443, 0.00023206, 0.00030936,
0.00039403, 0.00048341, 0.00057463, 0.00066477, 0.00075095, 0.00083047, 0.00090083, 0.00095987, 0.0010058,
0.0010372, 0.0010531, 1.2879e-07, 1.5572e-06, 5.863e-06, 1.4322e-05, 2.7795e-05, 4.668e-05, 7.093e-05,
0.0001001, 0.00013345, 0.00016997, 0.00020853, 0.00024788, 0.00028676, 0.00032394, 0.00035823, 0.00038859,
0.00041406, 0.00043386, 0.00044741, 0.00045429}},
{{-0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751,
-0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983,
-0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763,
-0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666,
-0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116,
-0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278,
-0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358,
-0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807,
-0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642,
-0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325,
-0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999,
-0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231,
-0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901,
-0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373,
-0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167,
-0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075,
-0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866,
-0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091,
-0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199,
-0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501,
-0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751,
-0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983,
-0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763,
-0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666,
-0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116,
-0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278,
-0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358,
-0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807,
-0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642,
-0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325,
-0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999,
-0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231,
-0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901,
-0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373,
-0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167,
-0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075,
-0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866,
-0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091,
-0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199,
-0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501,
-0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751,
-0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983,
-0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763,
-0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666,
-0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116,
-0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278,
-0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358,
-0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807,
-0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642,
-0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325,
-0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999,
-0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231,
-0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901,
-0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373,
-0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167,
-0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075,
-0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866,
-0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091,
-0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199,
-0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501,
-0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751,
-0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983,
-0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763,
-0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666,
-0.99167, -0.98278, -0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116,
-0.47075, -0.37358, -0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278,
-0.96866, -0.94807, -0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358,
-0.27091, -0.1642, -0.05501, -0.99999, -0.99983, -0.99901, -0.99666, -0.99167, -0.98278, -0.96866, -0.94807,
-0.9199, -0.88325, -0.83751, -0.78231, -0.71763, -0.64373, -0.56116, -0.47075, -0.37358, -0.27091, -0.1642,
-0.05501},
{4.714, 4.714, 4.714, 4.714, 4.714, 4.714, 4.714, 4.714, 4.714, 4.714, 4.714, 4.714, 4.714, 4.714,
4.714, 4.714, 4.714, 4.714, 4.714, 4.714, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209,
4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7209, 4.7331, 4.7331,
4.7331, 4.7331, 4.7331, 4.7331, 4.7331, 4.7331, 4.7331, 4.7331, 4.7331, 4.7331, 4.7331, 4.7331, 4.7331, 4.7331,
4.7331, 4.7331, 4.7331, 4.7331, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507,
4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7507, 4.7734, 4.7734, 4.7734, 4.7734,
4.7734, 4.7734, 4.7734, 4.7734, 4.7734, 4.7734, 4.7734, 4.7734, 4.7734, 4.7734, 4.7734, 4.7734, 4.7734, 4.7734,
4.7734, 4.7734, 4.801, 4.801, 4.801, 4.801, 4.801, 4.801, 4.801, 4.801, 4.801, 4.801, 4.801, 4.801,
4.801, 4.801, 4.801, 4.801, 4.801, 4.801, 4.801, 4.801, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333,
4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333, 4.8333,
4.87, 4.87, 4.87, 4.87, 4.87, 4.87, 4.87, 4.87, 4.87, 4.87, 4.87, 4.87, 4.87, 4.87,
4.87, 4.87, 4.87, 4.87, 4.87, 4.87, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108,
4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9108, 4.9553, 4.9553,
4.9553, 4.9553, 4.9553, 4.9553, 4.9553, 4.9553, 4.9553, 4.9553, 4.9553, 4.9553, 4.9553, 4.9553, 4.9553, 4.9553,
4.9553, 4.9553, 4.9553, 4.9553, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032,
5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0032, 5.0542, 5.0542, 5.0542, 5.0542,
5.0542, 5.0542, 5.0542, 5.0542, 5.0542, 5.0542, 5.0542, 5.0542, 5.0542, 5.0542, 5.0542, 5.0542, 5.0542, 5.0542,
5.0542, 5.0542, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079,
5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1079, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639,
5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639, 5.1639,
5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219,
5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2219, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816,
5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.2816, 5.3424, 5.3424,
5.3424, 5.3424, 5.3424, 5.3424, 5.3424, 5.3424, 5.3424, 5.3424, 5.3424, 5.3424, 5.3424, 5.3424, 5.3424, 5.3424,
5.3424, 5.3424, 5.3424, 5.3424, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042,
5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4042, 5.4665, 5.4665, 5.4665, 5.4665,
5.4665, 5.4665, 5.4665, 5.4665, 5.4665, 5.4665, 5.4665, 5.4665, 5.4665, 5.4665, 5.4665, 5.4665, 5.4665, 5.4665,
5.4665, 5.4665, 5.529, 5.529, 5.529, 5.529, 5.529, 5.529, 5.529, 5.529, 5.529, 5.529, 5.529, 5.529,
5.529, 5.529, 5.529, 5.529, 5.529, 5.529, 5.529, 5.529, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914,
5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914, 5.5914,
5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531,
5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.6531, 5.714, 5.714, 5.714, 5.714, 5.714, 5.714, 5.714, 5.714,
5.714, 5.714, 5.714, 5.714, 5.714, 5.714, 5.714, 5.714, 5.714, 5.714, 5.714, 5.714, 5.7736, 5.7736,
5.7736, 5.7736, 5.7736, 5.7736, 5.7736, 5.7736, 5.7736, 5.7736, 5.7736, 5.7736, 5.7736, 5.7736, 5.7736, 5.7736,
5.7736, 5.7736, 5.7736, 5.7736, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317,
5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8317, 5.8877, 5.8877, 5.8877, 5.8877,
5.8877, 5.8877, 5.8877, 5.8877, 5.8877, 5.8877, 5.8877, 5.8877, 5.8877, 5.8877, 5.8877, 5.8877, 5.8877, 5.8877,
5.8877, 5.8877, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414,
5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9414, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924,
5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924, 5.9924,
6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403,
6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0403, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848,
6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.0848, 6.1256, 6.1256,
6.1256, 6.1256, 6.1256, 6.1256, 6.1256, 6.1256, 6.1256, 6.1256, 6.1256, 6.1256, 6.1256, 6.1256, 6.1256, 6.1256,
6.1256, 6.1256, 6.1256, 6.1256, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622,
6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1622, 6.1945, 6.1945, 6.1945, 6.1945,
6.1945, 6.1945, 6.1945, 6.1945, 6.1945, 6.1945, 6.1945, 6.1945, 6.1945, 6.1945, 6.1945, 6.1945, 6.1945, 6.1945,
6.1945, 6.1945, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222,
6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2222, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449,
6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449, 6.2449,
6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624,
6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2624, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747,
6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2747, 6.2816, 6.2816,
6.2816, 6.2816, 6.2816, 6.2816, 6.2816, 6.2816, 6.2816, 6.2816, 6.2816, 6.2816, 6.2816, 6.2816, 6.2816, 6.2816,
6.2816, 6.2816, 6.2816, 6.2816},
{1.2879e-07, 1.5572e-06, 5.863e-06, 1.4322e-05, 2.7795e-05, 4.668e-05, 7.093e-05, 0.0001001, 0.00013345,
0.00016997, 0.00020853, 0.00024788, 0.00028676, 0.00032394, 0.00035823, 0.00038859, 0.00041406, 0.00043386,
0.00044741, 0.00045429, 2.9855e-07, 3.6099e-06, 1.3592e-05, 3.3203e-05, 6.4435e-05, 0.00010821, 0.00016443,
0.00023206, 0.00030936, 0.00039403, 0.00048341, 0.00057463, 0.00066477, 0.00075095, 0.00083047, 0.00090083,
0.00095987, 0.0010058, 0.0010372, 0.0010531, 4.6565e-07, 5.6303e-06, 2.1199e-05, 5.1785e-05, 0.0001005,
0.00016878, 0.00025646, 0.00036195, 0.00048251, 0.00061457, 0.00075397, 0.00089624, 0.0010368, 0.0011712,
0.0012953, 0.001405, 0.0014971, 0.0015687, 0.0016177, 0.0016426, 6.2827e-07, 7.5966e-06, 2.8602e-05,
6.9871e-05, 0.0001356, 0.00022773, 0.00034603, 0.00048836, 0.00065103, 0.0008292, 0.0010173, 0.0012093,
0.0013989, 0.0015803, 0.0017476, 0.0018957, 0.0020199, 0.0021166, 0.0021827, 0.0022162, 7.8497e-07,
9.4914e-06, 3.5736e-05, 8.7299e-05, 0.00016942, 0.00028452, 0.00043233, 0.00061016, 0.0008134, 0.001036,
0.001271, 0.0015109, 0.0017479, 0.0019745, 0.0021835, 0.0023685, 0.0025238, 0.0026445, 0.0027271,
0.002769, 9.3448e-07, 1.1299e-05, 4.2542e-05, 0.00010393, 0.00020168, 0.00033872, 0.00051467, 0.00072637,
0.00096832, 0.0012333, 0.0015131, 0.0017986, 0.0020808, 0.0023505, 0.0025994, 0.0028196, 0.0030044,
0.0031482, 0.0032465, 0.0032964, 1.0757e-06, 1.3007e-05, 4.8971e-05, 0.00011963, 0.00023216, 0.0003899,
0.00059245, 0.00083614, 0.0011147, 0.0014197, 0.0017418, 0.0020704, 0.0023952, 0.0027057, 0.0029922,
0.0032457, 0.0034585, 0.0036239, 0.0037371, 0.0037945, 1.2077e-06, 1.4603e-05, 5.4982e-05, 0.00013431,
0.00026066, 0.00043776, 0.00066517, 0.00093877, 0.0012515, 0.001594, 0.0019555, 0.0023246, 0.0026892,
0.0030378, 0.0033595, 0.0036441, 0.003883, 0.0040687, 0.0041958, 0.0042603, 1.3299e-06, 1.608e-05,
6.0543e-05, 0.0001479, 0.00028702, 0.00048203, 0.00073244, 0.0010337, 0.001378, 0.0017552, 0.0021533,
0.0025596, 0.0029612, 0.0033451, 0.0036992, 0.0040127, 0.0042757, 0.0044802, 0.0046201, 0.0046911,
1.4416e-06, 1.7431e-05, 6.5628e-05, 0.00016032, 0.00031113, 0.00052252, 0.00079396, 0.0011205, 0.0014938,
0.0019026, 0.0023342, 0.0027746, 0.0032099, 0.003626, 0.0040099, 0.0043497, 0.0046348, 0.0048565,
0.0050082, 0.0050851, 1.5425e-06, 1.865e-05, 7.0221e-05, 0.00017154, 0.0003329, 0.00055909, 0.00084952,
0.001199, 0.0015983, 0.0020358, 0.0024975, 0.0029688, 0.0034345, 0.0038798, 0.0042906, 0.0046541,
0.0049591, 0.0051964, 0.0053586, 0.005441, 1.6323e-06, 1.9736e-05, 7.4309e-05, 0.00018153, 0.00035229,
0.00059164, 0.00089899, 0.0012688, 0.0016914, 0.0021543, 0.0026429, 0.0031417, 0.0036345, 0.0041057,
0.0045404, 0.0049251, 0.0052479, 0.0054989, 0.0056706, 0.0057578, 1.7109e-06, 2.0687e-05, 7.7887e-05,
0.00019027, 0.00036925, 0.00062012, 0.00094227, 0.0013299, 0.0017728, 0.002258, 0.0027702, 0.0032929,
0.0038095, 0.0043034, 0.004759, 0.0051622, 0.0055006, 0.0057637, 0.0059437, 0.006035, 1.7782e-06,
2.15e-05, 8.0951e-05, 0.00019775, 0.00038377, 0.00064452, 0.00097934, 0.0013822, 0.0018426, 0.0023468,
0.0028792, 0.0034225, 0.0039593, 0.0044726, 0.0049462, 0.0053653, 0.0057169, 0.0059904, 0.0061775,
0.0062724, 1.8342e-06, 2.2177e-05, 8.35e-05, 0.00020398, 0.00039586, 0.00066482, 0.0010102, 0.0014257,
0.0019006, 0.0024208, 0.0029698, 0.0035303, 0.004084, 0.0046135, 0.005102, 0.0055343, 0.005897,
0.0061791, 0.006372, 0.00647, 1.8789e-06, 2.2718e-05, 8.5536e-05, 0.00020895, 0.00040551, 0.00068103,
0.0010348, 0.0014605, 0.0019469, 0.0024798, 0.0030423, 0.0036164, 0.0041836, 0.004726, 0.0052264,
0.0056692, 0.0060408, 0.0063298, 0.0065274, 0.0066277, 1.9124e-06, 2.3123e-05, 8.7061e-05, 0.00021268,
0.00041274, 0.00069317, 0.0010533, 0.0014865, 0.0019816, 0.002524, 0.0030965, 0.0036808, 0.0042582,
0.0048102, 0.0053195, 0.0057703, 0.0061485, 0.0064426, 0.0066438, 0.0067459, 1.9347e-06, 2.3393e-05,
8.8076e-05, 0.00021516, 0.00041755, 0.00070125, 0.0010655, 0.0015038, 0.0020047, 0.0025534, 0.0031326,
0.0037237, 0.0043078, 0.0048663, 0.0053816, 0.0058375, 0.0062201, 0.0065177, 0.0067212, 0.0068245,
1.9458e-06, 2.3527e-05, 8.8583e-05, 0.0002164, 0.00041996, 0.00070529, 0.0010717, 0.0015125, 0.0020163,
0.0025681, 0.0031506, 0.0037452, 0.0043326, 0.0048943, 0.0054126, 0.0058711, 0.006256, 0.0065552,
0.0067599, 0.0068638, 1.9458e-06, 2.3527e-05, 8.8583e-05, 0.0002164, 0.00041996, 0.00070529, 0.0010717,
0.0015125, 0.0020163, 0.0025681, 0.0031506, 0.0037452, 0.0043326, 0.0048943, 0.0054126, 0.0058711,
0.006256, 0.0065552, 0.0067599, 0.0068638, 1.9347e-06, 2.3393e-05, 8.8076e-05, 0.00021516, 0.00041755,
0.00070125, 0.0010655, 0.0015038, 0.0020047, 0.0025534, 0.0031326, 0.0037237, 0.0043078, 0.0048663,
0.0053816, 0.0058375, 0.0062201, 0.0065177, 0.0067212, 0.0068245, 1.9124e-06, 2.3123e-05, 8.7061e-05,
0.00021268, 0.00041274, 0.00069317, 0.0010533, 0.0014865, 0.0019816, 0.002524, 0.0030965, 0.0036808,
0.0042582, 0.0048102, 0.0053195, 0.0057703, 0.0061485, 0.0064426, 0.0066438, 0.0067459, 1.8789e-06,
2.2718e-05, 8.5536e-05, 0.00020895, 0.00040551, 0.00068103, 0.0010348, 0.0014605, 0.0019469, 0.0024798,
0.0030423, 0.0036164, 0.0041836, 0.004726, 0.0052264, 0.0056692, 0.0060408, 0.0063298, 0.0065274,
0.0066277, 1.8342e-06, 2.2177e-05, 8.35e-05, 0.00020398, 0.00039586, 0.00066482, 0.0010102, 0.0014257,
0.0019006, 0.0024208, 0.0029698, 0.0035303, 0.004084, 0.0046135, 0.005102, 0.0055343, 0.005897,
0.0061791, 0.006372, 0.00647, 1.7782e-06, 2.15e-05, 8.0951e-05, 0.00019775, 0.00038377, 0.00064452,
0.00097934, 0.0013822, 0.0018426, 0.0023468, 0.0028792, 0.0034225, 0.0039593, 0.0044726, 0.0049462,
0.0053653, 0.0057169, 0.0059904, 0.0061775, 0.0062724, 1.7109e-06, 2.0687e-05, 7.7887e-05, 0.00019027,
0.00036925, 0.00062012, 0.00094227, 0.0013299, 0.0017728, 0.002258, 0.0027702, 0.0032929, 0.0038095,
0.0043034, 0.004759, 0.0051622, 0.0055006, 0.0057637, 0.0059437, 0.006035, 1.6323e-06, 1.9736e-05,
7.4309e-05, 0.00018153, 0.00035229, 0.00059164, 0.00089899, 0.0012688, 0.0016914, 0.0021543, 0.0026429,
0.0031417, 0.0036345, 0.0041057, 0.0045404, 0.0049251, 0.0052479, 0.0054989, 0.0056706, 0.0057578,
1.5425e-06, 1.865e-05, 7.0221e-05, 0.00017154, 0.0003329, 0.00055909, 0.00084952, 0.001199, 0.0015983,
0.0020358, 0.0024975, 0.0029688, 0.0034345, 0.0038798, 0.0042906, 0.0046541, 0.0049591, 0.0051964,
0.0053586, 0.005441, 1.4416e-06, 1.7431e-05, 6.5628e-05, 0.00016032, 0.00031113, 0.00052252, 0.00079396,
0.0011205, 0.0014938, 0.0019026, 0.0023342, 0.0027746, 0.0032099, 0.003626, 0.0040099, 0.0043497,
0.0046348, 0.0048565, 0.0050082, 0.0050851, 1.3299e-06, 1.608e-05, 6.0543e-05, 0.0001479, 0.00028702,
0.00048203, 0.00073244, 0.0010337, 0.001378, 0.0017552, 0.0021533, 0.0025596, 0.0029612, 0.0033451,
0.0036992, 0.0040127, 0.0042757, 0.0044802, 0.0046201, 0.0046911, 1.2077e-06, 1.4603e-05, 5.4982e-05,
0.00013431, 0.00026066, 0.00043776, 0.00066517, 0.00093877, 0.0012515, 0.001594, 0.0019555, 0.0023246,
0.0026892, 0.0030378, 0.0033595, 0.0036441, 0.003883, 0.0040687, 0.0041958, 0.0042603, 1.0757e-06,
1.3007e-05, 4.8971e-05, 0.00011963, 0.00023216, 0.0003899, 0.00059245, 0.00083614, 0.0011147, 0.0014197,
0.0017418, 0.0020704, 0.0023952, 0.0027057, 0.0029922, 0.0032457, 0.0034585, 0.0036239, 0.0037371,
0.0037945, 9.3448e-07, 1.1299e-05, 4.2542e-05, 0.00010393, 0.00020168, 0.00033872, 0.00051467, 0.00072637,
0.00096832, 0.0012333, 0.0015131, 0.0017986, 0.0020808, 0.0023505, 0.0025994, 0.0028196, 0.0030044,
0.0031482, 0.0032465, 0.0032964, 7.8497e-07, 9.4914e-06, 3.5736e-05, 8.7299e-05, 0.00016942, 0.00028452,
0.00043233, 0.00061016, 0.0008134, 0.001036, 0.001271, 0.0015109, 0.0017479, 0.0019745, 0.0021835,
0.0023685, 0.0025238, 0.0026445, 0.0027271, 0.002769, 6.2827e-07, 7.5966e-06, 2.8602e-05, 6.9871e-05,
0.0001356, 0.00022773, 0.00034603, 0.00048836, 0.00065103, 0.0008292, 0.0010173, 0.0012093, 0.0013989,
0.0015803, 0.0017476, 0.0018957, 0.0020199, 0.0021166, 0.0021827, 0.0022162, 4.6565e-07, 5.6303e-06,
2.1199e-05, 5.1785e-05, 0.0001005, 0.00016878, 0.00025646, 0.00036195, 0.00048251, 0.00061457, 0.00075397,
0.00089624, 0.0010368, 0.0011712, 0.0012953, 0.001405, 0.0014971, 0.0015687, 0.0016177, 0.0016426,
2.9855e-07, 3.6099e-06, 1.3592e-05, 3.3203e-05, 6.4435e-05, 0.00010821, 0.00016443, 0.00023206, 0.00030936,
0.00039403, 0.00048341, 0.00057463, 0.00066477, 0.00075095, 0.00083047, 0.00090083, 0.00095987, 0.0010058,
0.0010372, 0.0010531, 1.2879e-07, 1.5572e-06, 5.863e-06, 1.4322e-05, 2.7795e-05, 4.668e-05, 7.093e-05,
0.0001001, 0.00013345, 0.00016997, 0.00020853, 0.00024788, 0.00028676, 0.00032394, 0.00035823, 0.00038859,
0.00041406, 0.00043386, 0.00044741, 0.00045429}}};
}
} // namespace Dune::XT::Data
| 114.623693 | 119 | 0.591483 | dune-community |
0eff9c3a08e392e0cad6a583abb5695f47fde908 | 5,100 | hpp | C++ | src/algorithms/data_structures/bt/serialize_and_deserialize_bt.hpp | iamantony/CppNotes | 2707db6560ad80b0e5e286a04b2d46e5c0280b3f | [
"MIT"
] | 2 | 2020-07-31T14:13:56.000Z | 2021-02-03T09:51:43.000Z | src/algorithms/data_structures/bt/serialize_and_deserialize_bt.hpp | iamantony/CppNotes | 2707db6560ad80b0e5e286a04b2d46e5c0280b3f | [
"MIT"
] | 28 | 2015-09-22T07:38:21.000Z | 2018-10-02T11:00:58.000Z | src/algorithms/data_structures/bt/serialize_and_deserialize_bt.hpp | iamantony/CppNotes | 2707db6560ad80b0e5e286a04b2d46e5c0280b3f | [
"MIT"
] | 2 | 2018-10-11T14:10:50.000Z | 2021-02-27T08:53:50.000Z | #ifndef CPPNOTESMAIN_SERIALIZE_AND_DESERIALIZE_BT_HPP
#define CPPNOTESMAIN_SERIALIZE_AND_DESERIALIZE_BT_HPP
/*
https://leetcode.com/problems/serialize-and-deserialize-binary-tree/
Serialization is the process of converting a data structure or object into a sequence of bits so
that it can be stored in a file or memory buffer, or transmitted across a network connection link
to be reconstructed later in the same or another computer environment.
Design an algorithm to serialize and deserialize a binary tree. There is no restriction on how your
serialization/deserialization algorithm should work. You just need to ensure that a binary tree
can be serialized to a string and this string can be deserialized to the original tree structure.
Clarification: The input/output format is the same as how LeetCode serializes a binary tree. You
do not necessarily need to follow this format, so please be creative and come up with different
approaches yourself.
Example 1:
1
/ \
2 3
/ \
4 5
Input: root = [1,2,3,null,null,4,5]
Output: [1,2,3,null,null,4,5]
Example 2:
Input: root = []
Output: []
Example 3:
Input: root = [1]
Output: [1]
Example 4:
Input: root = [1,2]
Output: [1,2]
Constraints:
* The number of nodes in the tree is in the range [0, 10^4].
* -1000 <= Node.val <= 1000
*/
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <numeric>
#include <sstream>
#include "types/ds/binary_tree_nodes.hpp"
namespace Algo::DS::BT {
class Serializator {
std::string join(const std::vector<std::string>& elements) {
if (elements.empty()) { return {}; }
return std::accumulate(
std::next(elements.begin()),
elements.end(),
*elements.begin(),
[this](const auto& left, const auto& right) { return left + SEPARATOR + right; });
}
std::vector<std::string> split(const std::string& str) {
if (str.empty()) { return {}; }
std::istringstream ss{str};
std::vector<std::string> result;
for (std::string e; std::getline(ss, e, SEPARATOR); ) {
result.push_back(e);
}
return result;
}
Types::DS::NodeBT<int>* str_to_node(const std::string& str) {
if (str.empty() || str == NO_NODE) { return nullptr; }
return new Types::DS::NodeBT<int>(std::atoi(str.c_str()));
}
public:
const std::string NO_NODE = {"n"};
const std::string END_NODE = {"e"};
const char SEPARATOR = {','};
std::string serialize(Types::DS::NodeBT<int>* root) {
std::vector<std::string> elements;
std::queue<Types::DS::NodeBT<int>*> q;
q.push(root);
while (!q.empty()) {
auto* n = q.front();
q.pop();
if (n == nullptr) {
elements.push_back(NO_NODE);
continue;
}
elements.push_back(std::to_string(n->value));
if (n->left == nullptr && n->right == nullptr) {
elements.push_back(END_NODE);
}
else {
q.push(n->left);
q.push(n->right);
}
}
return join(elements);
}
Types::DS::NodeBT<int>* deserialize(const std::string& str) {
const auto elements = split(str);
if (elements.empty() || elements.front() == NO_NODE || elements.front() == END_NODE) {
return nullptr;
}
auto* root = str_to_node(elements.front());
std::vector<Types::DS::NodeBT<int>*> level_nodes;
level_nodes.push_back(root);
for (size_t i = 1; i < elements.size() && !level_nodes.empty(); ) {
std::vector<Types::DS::NodeBT<int>*> next_level;
for (auto* n : level_nodes) {
if (elements[i] == END_NODE) {
++i;
continue;
}
n->left = str_to_node(elements[i++]);
if (n->left != nullptr && i < elements.size()) {
if (elements[i] == END_NODE) {
++i;
}
else {
next_level.push_back(n->left);
}
}
n->right = str_to_node(elements[i++]);
if (n->right != nullptr && i < elements.size()) {
if (elements[i] == END_NODE) {
++i;
}
else {
next_level.push_back(n->right);
}
}
}
level_nodes = std::move(next_level);
}
return root;
}
};
}
#endif //CPPNOTESMAIN_SERIALIZE_AND_DESERIALIZE_BT_HPP
| 31.677019 | 99 | 0.512353 | iamantony |
160213f7873b5d32e8ff6e707118400633f84cd7 | 2,781 | hpp | C++ | extlib/include/xyginext/graphics/postprocess/Blur.hpp | fallahn/speljongen | 57cb5e09eec7db8c21ee7b3e7943fa0a76738c51 | [
"Unlicense"
] | 17 | 2018-06-23T14:40:56.000Z | 2019-07-02T11:58:55.000Z | extlib/include/xyginext/graphics/postprocess/Blur.hpp | fallahn/speljongen | 57cb5e09eec7db8c21ee7b3e7943fa0a76738c51 | [
"Unlicense"
] | 3 | 2018-06-23T12:35:12.000Z | 2018-06-23T12:38:54.000Z | extlib/include/xyginext/graphics/postprocess/Blur.hpp | fallahn/speljongen | 57cb5e09eec7db8c21ee7b3e7943fa0a76738c51 | [
"Unlicense"
] | null | null | null | /*********************************************************************
(c) Matt Marchant 2017 - 2019
http://trederia.blogspot.com
xygineXT - Zlib license.
This software is provided 'as-is', without any express or
implied warranty. In no event will the authors be held
liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented;
you must not claim that you wrote the original software.
If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but
is not required.
2. Altered source versions must be plainly marked as such,
and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any
source distribution.
*********************************************************************/
#pragma once
#include "xyginext/graphics/postprocess/PostProcess.hpp"
#include <SFML/Graphics/Shader.hpp>
#include <SFML/Graphics/RenderTexture.hpp>
#include <SFML/System/Clock.hpp>
#include <array>
namespace xy
{
/*!
\brief Post process effect which applies a screen-wide gaussian blur.
This effect can be enabled and disabled as needed via direct call to
setEnabled(). Blur amount is animated when
enabling or disabling for a smoother transition.
*/
class XY_EXPORT_API PostBlur final : public PostProcess
{
public:
PostBlur();
/*!
\brief Applies the effect to the screen
*/
void apply(const sf::RenderTexture&, sf::RenderTarget&) override;
/*!
\brief Enables or disables the blur effect.
By default this is disabled, so call this at least once
if no blur is apparent
*/
void setEnabled(bool);
/*!
\brief Sets the speed of the transition when enabling or disabling
the effect.
\param Value must be 1 or greater
*/
void setFadeSpeed(float value);
private:
float m_amount;
sf::Clock m_clock;
bool m_enabled;
float m_fadeSpeed;
sf::Shader m_blurShader;
sf::Shader m_downsampleShader;
sf::Shader m_outShader;
using TexturePair = std::array<sf::RenderTexture, 2u>;
TexturePair m_firstPassTextures;
TexturePair m_secondPassTextures;
void initTextures(sf::Vector2u);
void blurMultipass(TexturePair&);
void blur(const sf::RenderTexture&, sf::RenderTexture&, const sf::Vector2f&);
void downSample(const sf::RenderTexture&, sf::RenderTexture&);
};
}
| 31.247191 | 85 | 0.661273 | fallahn |
160b5c0f873ae158bb61d7d008fe97d67ebd2402 | 892 | cpp | C++ | codeforces/746B.cpp | NafiAsib/competitive-programming | 3255b2fe3329543baf9e720e1ccaf08466d77303 | [
"MIT"
] | null | null | null | codeforces/746B.cpp | NafiAsib/competitive-programming | 3255b2fe3329543baf9e720e1ccaf08466d77303 | [
"MIT"
] | null | null | null | codeforces/746B.cpp | NafiAsib/competitive-programming | 3255b2fe3329543baf9e720e1ccaf08466d77303 | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
int main()
{
char a[2002], b[2002];
int i, n, j = 1, med;
cin>>n>>a;
//if(n%2 == 0) med = n/2 - 1;
//else
med = (n-1)/2;
//cout<<med<<endl;
b[med] = a[0];
j = med+1;
if(n%2 != 0)
{
for(i = 2; a[i] != '\0'; i = i+2)
{
b[j] = a[i];
j += 1;
}
//b[j] = '\0';
j = med - 1;
for(i = 1; a[i] != '\0'; i = i+2)
{
b[j] = a[i];
j--;
}
}
if(n%2 == 0)
{
for(i = 1; a[i] != '\0'; i = i+2)
{
b[j] = a[i];
j += 1;
}
//b[j] = '\0';
j = med - 1;
for(i = 2; a[i] != '\0'; i = i+2)
{
b[j] = a[i];
j--;
}
}
b[n] = '\0';
cout<<b<<endl;
return 0;
} | 13.723077 | 41 | 0.25 | NafiAsib |
160c0d059b2fe7952cd69605a6bd4050d9c2f86f | 4,373 | cpp | C++ | src/drm/origin_drm.cpp | Proj-Ascension/Client | 436a594b750d0084831ead7f2372fb7a1a8709a6 | [
"MIT"
] | 322 | 2015-05-01T22:01:34.000Z | 2021-10-02T16:00:54.000Z | src/drm/origin_drm.cpp | Proj-Ascension/Client | 436a594b750d0084831ead7f2372fb7a1a8709a6 | [
"MIT"
] | 89 | 2015-05-02T15:27:35.000Z | 2016-08-21T17:10:23.000Z | src/drm/origin_drm.cpp | Proj-Ascension/Client | 436a594b750d0084831ead7f2372fb7a1a8709a6 | [
"MIT"
] | 105 | 2015-05-02T12:38:19.000Z | 2019-03-13T12:59:50.000Z | #include "origin_drm.h"
#include <QLineEdit>
#include <QCheckBox>
#include <QStandardPaths>
OriginDRM::OriginDRM() : DRMType("<b>Origin</b>"){}
/** Check if Origin exists or not and set various class variables accordingly. */
void OriginDRM::checkOriginExists()
{
QDir originRoot;
QDir originFolder;
#if defined(_WIN32) || defined(_WIN64)
originRoot = QDir(qgetenv("APPDATA").append("/Origin"));
#else
originRoot = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation).append("/Origin/");
#endif
if (originRoot.exists("local.xml"))
{
qDebug() << originRoot.filePath("local.xml");
pt::ptree originTree;
read_xml(originRoot.filePath("local.xml").toLocal8Bit().constData(), originTree);
for (auto &xmlIter : originTree.get_child("Settings"))
{
if (xmlIter.second.get<std::string>("<xmlattr>.key") == "DownloadInPlaceDir")
{
originFolder = QString::fromStdString(xmlIter.second.get<std::string>("<xmlattr>.value"));
break;
}
}
if (originFolder == QDir("."))
{
originFolder = QDir("C:\\Program Files (x86)\\Origin Games\\");
}
}
if (originFolder.filePath("").trimmed() != "" && originFolder.exists() && originFolder != QDir("."))
{
this->setRootDir(originFolder);
this->setIsInstalled();
statusLabel->setPixmap(QPixmap(":/system_menu/icons/tick.svg"));
descLabel = new QLabel("Origin found in " + originFolder.filePath(""));
}
else
{
statusLabel->setPixmap(QPixmap(":/system_menu/icons/cross.svg"));
descLabel = new QLabel("Origin not found. Verify installation and try again.");
}
}
/** Using rootDir, which is initialized earlier in the wizard, utilize `recursiveFindFiles()` to find every executable within
* each respective directory. Some directories will contain more than one executable, so it's up to the user to select the correct one.
*/
void OriginDRM::findGames()
{
rootDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
QStringList folderList = rootDir.entryList();
int count = 0;
for (auto i : folderList)
{
if (i != "DownloadCache")
{
pt::ptree& node = originTree.add("games.game", "");
QDir dir(rootDir.absoluteFilePath(i));
dir.setNameFilters(QStringList("*.exe"));
dir.setFilter(QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks);
QStringList test = recursiveFindFiles(dir);
node.put("name", dir.dirName().toLocal8Bit().constData());
for (auto exe : test)
{
node.add("exes.exe", exe.toLocal8Bit().constData());
}
count++;
}
}
originTree.add("games.count", count);
}
/** Getter for the originTree */
pt::ptree OriginDRM::getGames()
{
return originTree;
}
/** Create the wizard tab for Origin
* \param parent Parent of the widget
* */
QWidget* OriginDRM::createPane(QWidget* parent)
{
viewport = new QWidget(parent);
scrollArea = new QScrollArea(parent);
int row = 0;
for (pt::ptree::value_type& games : originTree.get_child("games"))
{
boost::optional<std::string> exeTest = games.second.get_optional<std::string>("exes");
if (exeTest)
{
QButtonGroup* group = new QButtonGroup();
QLineEdit* name = new QLineEdit(QString::fromStdString(games.second.get<std::string>("name")));
name->setFixedWidth(350);
QCheckBox* checkBox = new QCheckBox();
layout->addWidget(name, row, 0, Qt::AlignVCenter | Qt::AlignLeft);
row++;
for (auto& exe : games.second.get_child("exes"))
{
checkBox = new QCheckBox("Executable: " + QString::fromStdString(exe.second.data()));
group->addButton(checkBox);
layout->addWidget(checkBox, row, 0, Qt::AlignVCenter | Qt::AlignLeft);
row++;
}
buttonGroupVector.push_back(group);
}
}
viewport->setLayout(layout);
scrollArea->setWidget(viewport);
return scrollArea;
}
/** Getter for buttonGroupVector */
QList<QButtonGroup*> OriginDRM::getButtonGroupVector()
{
return buttonGroupVector;
}
| 33.381679 | 135 | 0.60965 | Proj-Ascension |
160c273090746d17ce9385402a48e8b40fe5ea04 | 1,890 | hpp | C++ | tool/tssplitter/inc/tssplitter/ts/psi/basic_traits.hpp | mrk21/tvrec | 0f261714ace005473a5d0f35d5f4d8e43d60b175 | [
"MIT"
] | null | null | null | tool/tssplitter/inc/tssplitter/ts/psi/basic_traits.hpp | mrk21/tvrec | 0f261714ace005473a5d0f35d5f4d8e43d60b175 | [
"MIT"
] | null | null | null | tool/tssplitter/inc/tssplitter/ts/psi/basic_traits.hpp | mrk21/tvrec | 0f261714ace005473a5d0f35d5f4d8e43d60b175 | [
"MIT"
] | null | null | null | #pragma once
#include <tssplitter/bitfield.hpp>
#include <tssplitter/byte_container.hpp>
namespace tssplitter { namespace ts { namespace psi {
using pointer_field_type = bitfield< 8>;
using table_id_type = pointer_field_type::next_bitfield< 8>;
using section_syntax_indicator_type = table_id_type::next_bitfield< 1>;
using always_set_to_0_type = section_syntax_indicator_type::next_bitfield< 1>;
using reserved_1_type = always_set_to_0_type::next_bitfield< 2>;
using section_length_type = reserved_1_type::next_bitfield<12>;
using last_basic_bitfield = section_length_type;
using crc_type = byte_container<sizeof(uint32_t)>;
#define PSI_BASIC_FIELD \
container_type data; \
pointer_field_type pointer_field; \
table_id_type table_id; \
section_syntax_indicator_type section_syntax_indicator; \
always_set_to_0_type always_set_to_0; \
reserved_1_type reserved_1; \
section_length_type section_length; \
template<typename Derived>
struct basic_traits: public util::crtp_helper<Derived> {
struct container_type: public variable_byte_container<container_type, typename Derived::static_container_type>, public util::union_helper {
std::size_t runtime_size(void) const {
return this->member_type<basic_traits>()->size();
}
};
std::size_t size(void) const {
return this->derived()->section_length + section_length_type::END_POSITION;
}
crc_type & crc(void) {
return *reinterpret_cast<crc_type *>(util::to_byteptr(this) + this->size() - sizeof(crc_type));
}
};
}}}
| 46.097561 | 143 | 0.624339 | mrk21 |
1614843c3ba221e5971c1b9160bd86336921f1b9 | 1,356 | cpp | C++ | src/utils/ObjectCounter.cpp | igorglotov/tizen-vk-client | de213ede7185818285f78abad36592bc864f76cc | [
"Unlicense"
] | null | null | null | src/utils/ObjectCounter.cpp | igorglotov/tizen-vk-client | de213ede7185818285f78abad36592bc864f76cc | [
"Unlicense"
] | null | null | null | src/utils/ObjectCounter.cpp | igorglotov/tizen-vk-client | de213ede7185818285f78abad36592bc864f76cc | [
"Unlicense"
] | null | null | null | /*
* CheckedObject.cpp
*
* Created on: Nov 23, 2013
* Author: wolong
*/
#include "ObjectCounter.h"
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
ObjectCounter::ObjectCounter() {
// TODO Auto-generated constructor stub
}
ObjectCounter::~ObjectCounter() {
// TODO Auto-generated destructor stub
}
HashMap *ObjectCounter::counterMap = null;
void ObjectCounter::OnConstruct(const String &key) {
if(counterMap == null) {
counterMap = new HashMap();
counterMap->Construct();
}
Integer *counter = static_cast<Integer*>(counterMap->GetValue(key));
if(counter == null) {
counter = new Integer(0);
counterMap->Add(new String(key), counter);
}
counter->value++;
}
void ObjectCounter::OnDestruct(const String &key) {
if(counterMap == null) {
counterMap = new HashMap();
counterMap->Construct();
}
Integer *counter = static_cast<Integer*>(counterMap->GetValue(key));
if(counter == null) {
counter = new Integer(0);
counterMap->Add(new String(key), counter);
}
counter->value--;
}
void ObjectCounter::Report() {
IMapEnumerator *enumerator = counterMap->GetMapEnumeratorN();
while(enumerator->MoveNext() == E_SUCCESS) {
AppLog("REPORT %ls: %d", static_cast<String *>(enumerator->GetKey())->GetPointer(), static_cast<Integer *>(enumerator->GetValue())->ToInt());
}
delete enumerator;
}
| 21.52381 | 143 | 0.69469 | igorglotov |
1620552c1a40b61d5f2f287279541604981e597e | 9,766 | cpp | C++ | applic/rfid-progr/source/P_Param.cpp | NPaolini/NPS_OpenSource | 0c7da066b02b57ce282a1903a3901a563d04a28f | [
"Unlicense"
] | null | null | null | applic/rfid-progr/source/P_Param.cpp | NPaolini/NPS_OpenSource | 0c7da066b02b57ce282a1903a3901a563d04a28f | [
"Unlicense"
] | null | null | null | applic/rfid-progr/source/P_Param.cpp | NPaolini/NPS_OpenSource | 0c7da066b02b57ce282a1903a3901a563d04a28f | [
"Unlicense"
] | null | null | null | //---------- p_param.cpp -----------------------------------------------------
//----------------------------------------------------------------------------
#include "precHeader.h"
//----------------------------------------------------------------------------
#include "p_param.h"
#include "pOwnBtnImageStd.h"
#include "macro_utils.h"
#include <Shlwapi.h>
#pragma comment(linker, "/defaultlib:Shlwapi.lib")
//----------------------------------------------------------------------------
extern paramConn getDefaultparamCom();
//----------------------------------------------------------------------------
#define MAX_PORT 99
//----------------------------------------------------------------------------
static value_name vBaudRate[] =
{
{ CBR_110, _T("110") },
{ CBR_300, _T("300") },
{ CBR_600, _T("600") },
{ CBR_1200, _T("1.200") },
{ CBR_2400, _T("2.400") },
{ CBR_4800, _T("4.800") },
{ CBR_9600, _T("9.600") },
{ CBR_14400, _T("14.400") },
{ CBR_19200, _T("19.200") },
{ CBR_38400, _T("38.400") },
{ CBR_56000, _T("56.000") },
{ CBR_57600, _T("57.600") },
{ CBR_115200, _T("115.200") },
{ CBR_128000, _T("128.000") },
{ CBR_256000, _T("256.000") }
};
//----------------------------------------------------------------------------
static value_name vParity[] =
{
{ EVENPARITY, _T("EVENPARITY") },
{ MARKPARITY, _T("MARKPARITY") },
{ NOPARITY, _T("NOPARITY") },
{ ODDPARITY, _T("ODDPARITY") },
{ SPACEPARITY,_T("SPACEPARITY") }
};
//----------------------------------------------------------------------------
static value_name vBitStop[] =
{
{ ONESTOPBIT, _T("ONESTOPBIT") },
{ ONE5STOPBITS, _T("ONE5STOPBITS") },
{ TWOSTOPBITS, _T("TWOSTOPBITS") }
};
//----------------------------------------------------------------------------
static value_name vBitLen[] =
{
{ 5, _T("5") },
{ 6, _T("6") },
{ 7, _T("7") },
{ 8, _T("8") },
};
//----------------------------------------------------------------------------
static value_name vDTR_DSR[] =
{
{ 0, _T("NO_DTR_DSR") },
{ 1, _T("ON_DTR_DSR") },
{ 2, _T("HANDSHAKE_DTR_DSR") },
};
//----------------------------------------------------------------------------
static value_name vRTS_CTS[] =
{
{ 0, _T("NO_RTS_CTS") },
{ 1, _T("ON_RTS_CTS") },
{ 2, _T("HANDSHAKE_RTS_CTS") },
{ 3, _T("TOGGLE_RTS_CTS") },
};
//----------------------------------------------------------------------------
static value_name vXON_XOFF[] =
{
{ 0, _T("NO_XON_XOFF") },
{ 1, _T("XON_XOFF") },
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
P_Param::P_Param(setting& par, PWin* parent, uint resId, HINSTANCE hinstance)
:
baseClass(parent, resId, hinstance), Par(par)
{
#define MAX_BMP SIZE_A(idBmp)
int idBmp[] = { IDB_BITMAP_DEF, IDB_BITMAP_OK, IDB_BITMAP_CANC };
Bmp.setDim(MAX_BMP);
for(uint i = 0; i < MAX_BMP; ++i)
Bmp[i] = new PBitmap(idBmp[i], getHInstance());
new POwnBtnImageStd(this, IDC_BUTTON_DEFAULT, Bmp[0]);
new POwnBtnImageStd(this, IDOK, Bmp[1]);
new POwnBtnImageStd(this, IDCANCEL, Bmp[2]);
}
//----------------------------------------------------------------------------
P_Param::~P_Param()
{
destroy();
int nElem = Bmp.getElem();
for(int i = 0; i < nElem; ++i)
delete Bmp[i];
}
//---------------------------------------------------------
static void findAndSetText(HWND cbx, LPCTSTR txt)
{
int count = SendMessage(cbx, CB_GETCOUNT, 0, 0);
TCHAR t[500];
for(int i = 0; i < count; ++i) {
SendMessage(cbx, CB_GETLBTEXT, i, (LPARAM)t);
if(!_tcscmp(t, txt)) {
SendMessage(cbx, CB_SETCURSEL, i, 0);
break;
}
}
}
//----------------------------------------------------------------------------
#define SET_CBX_(bx, vn, p) \
{ \
HWND hcbx = ::GetDlgItem(getHandle(), bx); \
fillCBX(hcbx,vn, SIZE_A(vn)); \
findAndSetText(hcbx, vn[Par.par.b.p].name); \
}
//----------------------------------------------------------------------------
#define SET_CBX_2(bx, txt, dim) \
{ \
HWND hcbx = ::GetDlgItem(getHandle(), bx); \
int sel = fillCBX(hcbx,txt,dim,Par.par.getPort()); \
SendMessage(hcbx, CB_SETCURSEL, sel, 0); \
}
//----------------------------------------------------------------------------
#define SET_PAR_(bx, vn, p) \
{ \
HWND hcbx = ::GetDlgItem(getHandle(), bx); \
Par.par.b.p = static_cast<WORD>(fillPar(hcbx, SIZE_A(vn))); \
}
//----------------------------------------------------------------------------
#define SET_PORT(bx) \
{ \
HWND hcbx = ::GetDlgItem(getHandle(), bx); \
Par.par.setPort(static_cast<WORD>(getPortNum(hcbx))); \
}
//----------------------------------------------------------------------------
static int fillPar(HWND hcbx, int num)
{
TCHAR txt[50];
::GetWindowText(hcbx, txt, SIZE_A(txt));
for(int i=0; i < num; ++i) {
TCHAR t[50];
::SendMessage(hcbx, CB_GETLBTEXT, (WPARAM)i, (LPARAM)t);
if(!_tcscmp(txt,t))
return i;
}
return 0;
}
//----------------------------------------------------------------------------
static int getPortNum(HWND hcbx)
{
TCHAR txt[50];
::GetWindowText(hcbx, txt, SIZE_A(txt));
LPTSTR p = txt;
while(*p) {
if(*p >= '0' && *p <= '9')
break;
++p;
}
int port = 0;
if(*p) {
port = _ttoi(p) - 1;
if(port < 0)
port = 0;
}
return port;
}
//----------------------------------------------------------------------------
#define IS_CHECKED(idc) \
(BST_CHECKED == SendMessage(::GetDlgItem(*this, idc), BM_GETCHECK, 0, 0))
//----------------------------------------------------------------------------
#define SET_CHECK(idc) \
SendMessage(::GetDlgItem(*this, idc), BM_SETCHECK, BST_CHECKED, 0)
//----------------------------------------------------------------------------
#define SET_UNCHECK(idc) \
SendMessage(::GetDlgItem(*this, idc), BM_SETCHECK, BST_UNCHECKED, 0)
//----------------------------------------------------------------------------
void P_Param::codeToCtrl()
{
TCHAR t[32];
for (uint i = 0; i < DIM_HEADER; ++i)
t[i] = Par.Code[i];
t[DIM_HEADER] = 0;
SET_TEXT(IDC_EDIT_HEADER, t);
SET_TEXT(IDC_EDIT_CODE, _T("0000000000"));
for (uint i = 0; i < DIM_VER; ++i)
t[i] = Par.Code[OFFS_VER + i];
t[DIM_HEADER] = 0;
SET_TEXT(IDC_EDIT_VER, t);
}
//----------------------------------------------------------------------------
void P_Param::codeFromCtrl()
{
TCHAR t[32];
GET_TEXT(IDC_EDIT_HEADER, t);
for (uint i = 0; i < DIM_HEADER; ++i)
Par.Code[i] = t[i];
for(uint i = 0; i < DIM_CODE; ++i)
Par.Code[OFFS_CODE + i] = _T('0');
GET_TEXT(IDC_EDIT_VER, t);
for (uint i = 0; i < DIM_VER; ++i)
Par.Code[OFFS_VER + i] = t[i];
Par.Code[DIM_FULL_CODE] = 0;
}
//----------------------------------------------------------------------------
void P_Param::BNClickedOk()
{
SET_PORT(IDC_COMBOBOX_COM_PORT)
SET_PAR_(IDC_COMBOBOX_BAUDRATE, vBaudRate, baud)
SET_PAR_(IDC_COMBOBOX_BITSTOP, vBitStop, stop)
SET_PAR_(IDC_COMBOBOX_DATA_LEN, vBitLen, len)
SET_PAR_(IDC_COMBOBOX_PARITY, vParity, parity)
SET_PAR_(IDC_COMBOBOX_DTR_DSR, vDTR_DSR, dtr_dsr)
SET_PAR_(IDC_COMBOBOX_RTS_CTS, vRTS_CTS, rts_cts)
SET_PAR_(IDC_COMBOBOX_XON_XOFF, vXON_XOFF, xon_xoff)
codeFromCtrl();
}
//----------------------------------------------------------------------------
static int fillCBX(HWND hcbx, LPCTSTR v, int num, int onuse)
{
::SendMessage(hcbx, CB_RESETCONTENT, 0, 0);
TCHAR t[128];
TCHAR result[409];
uint curr = 0;
int sel = -1;
for(int i = 0; i < num; ++i) {
wsprintf(t, _T("%s%d"), v, i + 1);
if(QueryDosDevice(t, result, SIZE_A(result))) {
if(StrStr(result, _T("USB")))
_tcscat_s(t, _T(" (USB)"));
::SendMessage(hcbx, CB_ADDSTRING, 0, (LPARAM)t);
if(onuse == i)
sel = curr;
++curr;
}
}
return sel;
}
//----------------------------------------------------------------------------
static void fillCBX(HWND hcbx, value_name *v, int num)
{
::SendMessage(hcbx, CB_RESETCONTENT, 0, 0);
for(int i = 0; i < num; ++i)
::SendMessage(hcbx, CB_ADDSTRING, 0, (LPARAM)(v[i].name));
}
//----------------------------------------------------------------------------
bool P_Param::create()
{
if(!baseClass::create())
return false;
fillCtrl();
return true;
}
//----------------------------------------------------------------------------
void P_Param::fillCtrl()
{
SET_CBX_2(IDC_COMBOBOX_COM_PORT, _T("Com"), MAX_PORT)
SET_CBX_(IDC_COMBOBOX_BAUDRATE, vBaudRate, baud)
SET_CBX_(IDC_COMBOBOX_BITSTOP, vBitStop, stop)
SET_CBX_(IDC_COMBOBOX_DATA_LEN, vBitLen, len)
SET_CBX_(IDC_COMBOBOX_PARITY, vParity, parity)
SET_CBX_(IDC_COMBOBOX_DTR_DSR, vDTR_DSR, dtr_dsr)
SET_CBX_(IDC_COMBOBOX_RTS_CTS, vRTS_CTS, rts_cts)
SET_CBX_(IDC_COMBOBOX_XON_XOFF, vXON_XOFF, xon_xoff)
codeToCtrl();
}
//----------------------------------------------------------------------------
LRESULT P_Param::windowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) {
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDC_BUTTON_DEFAULT:
Par.par = getDefaultparamCom();
_tcscpy_s(Par.Code, _T("nps0000000000001"));
fillCtrl();
break;
case IDOK:
BNClickedOk();
case IDCANCEL:
EndDialog(hwnd, LOWORD(wParam));
return 0;
}
}
return baseClass::windowProc(hwnd, message, wParam, lParam);
}
//----------------------------------------------------------------------------
| 32.445183 | 82 | 0.441327 | NPaolini |
16212821d9029f37c53d7f4ca5c1824d5c989787 | 3,048 | tcc | C++ | src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain.tcc | phabulu/litecoinz | f27d3e157811c8ae19bc7165d613f4d4b8ef9523 | [
"MIT"
] | 1 | 2018-03-27T16:37:14.000Z | 2018-03-27T16:37:14.000Z | src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain.tcc | phabulu/litecoinz | f27d3e157811c8ae19bc7165d613f4d4b8ef9523 | [
"MIT"
] | null | null | null | src/snark/libsnark/algebra/evaluation_domain/domains/basic_radix2_domain.tcc | phabulu/litecoinz | f27d3e157811c8ae19bc7165d613f4d4b8ef9523 | [
"MIT"
] | null | null | null | /** @file
*****************************************************************************
Implementation of interfaces for the "basic radix-2" evaluation domain.
See basic_radix2_domain.hpp .
*****************************************************************************
* @author This file is part of libsnark, developed by SCIPR Lab
* and contributors (see AUTHORS).
* @copyright MIT license (see LICENSE file)
*****************************************************************************/
#ifndef BASIC_RADIX2_DOMAIN_TCC_
#define BASIC_RADIX2_DOMAIN_TCC_
#include "algebra/evaluation_domain/domains/basic_radix2_domain_aux.hpp"
namespace libsnark {
template<typename FieldT>
basic_radix2_domain<FieldT>::basic_radix2_domain(const uint64_t m) : evaluation_domain<FieldT>(m)
{
assert(m > 1);
const uint64_t logm = log2(m);
assert(logm <= (FieldT::s));
omega = get_root_of_unity<FieldT>(m);
}
template<typename FieldT>
void basic_radix2_domain<FieldT>::FFT(std::vector<FieldT> &a)
{
enter_block("Execute FFT");
assert(a.size() == this->m);
_basic_radix2_FFT(a, omega);
leave_block("Execute FFT");
}
template<typename FieldT>
void basic_radix2_domain<FieldT>::iFFT(std::vector<FieldT> &a)
{
enter_block("Execute inverse FFT");
assert(a.size() == this->m);
_basic_radix2_FFT(a, omega.inverse());
const FieldT sconst = FieldT(a.size()).inverse();
for (uint64_t i = 0; i < a.size(); ++i)
{
a[i] *= sconst;
}
leave_block("Execute inverse FFT");
}
template<typename FieldT>
void basic_radix2_domain<FieldT>::cosetFFT(std::vector<FieldT> &a, const FieldT &g)
{
enter_block("Execute coset FFT");
_multiply_by_coset(a, g);
FFT(a);
leave_block("Execute coset FFT");
}
template<typename FieldT>
void basic_radix2_domain<FieldT>::icosetFFT(std::vector<FieldT> &a, const FieldT &g)
{
enter_block("Execute inverse coset IFFT");
iFFT(a);
_multiply_by_coset(a, g.inverse());
leave_block("Execute inverse coset IFFT");
}
template<typename FieldT>
std::vector<FieldT> basic_radix2_domain<FieldT>::lagrange_coeffs(const FieldT &t)
{
return _basic_radix2_lagrange_coeffs(this->m, t);
}
template<typename FieldT>
FieldT basic_radix2_domain<FieldT>::get_element(const uint64_t idx)
{
return omega^idx;
}
template<typename FieldT>
FieldT basic_radix2_domain<FieldT>::compute_Z(const FieldT &t)
{
return (t^this->m) - FieldT::one();
}
template<typename FieldT>
void basic_radix2_domain<FieldT>::add_poly_Z(const FieldT &coeff, std::vector<FieldT> &H)
{
assert(H.size() == this->m+1);
H[this->m] += coeff;
H[0] -= coeff;
}
template<typename FieldT>
void basic_radix2_domain<FieldT>::divide_by_Z_on_coset(std::vector<FieldT> &P)
{
const FieldT coset = FieldT::multiplicative_generator;
const FieldT Z_inverse_at_coset = this->compute_Z(coset).inverse();
for (uint64_t i = 0; i < this->m; ++i)
{
P[i] *= Z_inverse_at_coset;
}
}
} // libsnark
#endif // BASIC_RADIX2_DOMAIN_TCC_
| 26.973451 | 97 | 0.644685 | phabulu |
1621934a1dbdff8eb1a5ef3f6cd09ca90eb5d7e5 | 2,903 | cpp | C++ | Siv3D/src/Siv3D/Effect/SivEffect.cpp | tas9n/OpenSiv3D | c561cba1d88eb9cd9606ba983fcc1120192d5615 | [
"MIT"
] | 2 | 2021-11-22T00:52:48.000Z | 2021-12-24T09:33:55.000Z | Siv3D/src/Siv3D/Effect/SivEffect.cpp | tas9n/OpenSiv3D | c561cba1d88eb9cd9606ba983fcc1120192d5615 | [
"MIT"
] | null | null | null | Siv3D/src/Siv3D/Effect/SivEffect.cpp | tas9n/OpenSiv3D | c561cba1d88eb9cd9606ba983fcc1120192d5615 | [
"MIT"
] | 1 | 2021-12-31T05:08:00.000Z | 2021-12-31T05:08:00.000Z | //-----------------------------------------------
//
// This file is part of the Siv3D Engine.
//
// Copyright (c) 2008-2022 Ryo Suzuki
// Copyright (c) 2016-2022 OpenSiv3D Project
//
// Licensed under the MIT License.
//
//-----------------------------------------------
# include <Siv3D/Effect.hpp>
# include <Siv3D/Effect/IEffect.hpp>
# include <Siv3D/FreestandingMessageBox/FreestandingMessageBox.hpp>
# include <Siv3D/AssetMonitor/IAssetMonitor.hpp>
# include <Siv3D/Common/Siv3DEngine.hpp>
namespace s3d
{
template <>
AssetIDWrapper<AssetHandle<Effect>>::AssetIDWrapper()
{
if (not Siv3DEngine::isActive())
{
FreestandingMessageBox::ShowError(U"`Effect` must be initialized after engine-setup. Please fix the C++ code.");
std::abort();
}
}
template <>
AssetIDWrapper<AssetHandle<Effect>>::~AssetIDWrapper()
{
if (not Siv3DEngine::isActive())
{
return;
}
if (auto p = SIV3D_ENGINE(Effect))
{
p->release(m_id);
}
}
Effect::Effect(const double maxLifeTimeSec)
: AssetHandle{ std::make_shared<AssetIDWrapperType>(SIV3D_ENGINE(Effect)->create(maxLifeTimeSec)) }
{
SIV3D_ENGINE(AssetMonitor)->created();
}
Effect::Effect(const Duration& maxLifeTimeSec)
: Effect{ maxLifeTimeSec.count() } {}
Effect::~Effect()
{
}
Effect::operator bool() const
{
return hasEffects();
}
bool Effect::isEmpty() const
{
return (not hasEffects());
}
const Effect& Effect::add(std::unique_ptr<IEffect>&& effect) const
{
SIV3D_ENGINE(Effect)->add(m_handle->id(), std::move(effect));
return *this;
}
bool Effect::hasEffects() const
{
return (0 < num_effects());
}
size_t Effect::num_effects() const
{
return SIV3D_ENGINE(Effect)->num_effects(m_handle->id());
}
void Effect::pause() const
{
SIV3D_ENGINE(Effect)->pause(m_handle->id());
}
bool Effect::isPaused() const
{
return SIV3D_ENGINE(Effect)->isPaused(m_handle->id());
}
void Effect::resume() const
{
SIV3D_ENGINE(Effect)->resume(m_handle->id());
}
const Effect& Effect::setSpeed(const double speed) const
{
SIV3D_ENGINE(Effect)->setSpeed(m_handle->id(), speed);
return *this;
}
double Effect::getSpeed() const
{
return SIV3D_ENGINE(Effect)->getSpeed(m_handle->id());
}
const Effect& Effect::setMaxLifeTime(const double maxLifeTimeSec)
{
SIV3D_ENGINE(Effect)->setMaxLifeTime(m_handle->id(), maxLifeTimeSec);
return *this;
}
void Effect::setMaxLifeTime(const Duration& maxLifeTimeSec)
{
SIV3D_ENGINE(Effect)->setMaxLifeTime(m_handle->id(), maxLifeTimeSec.count());
}
double Effect::getMaxLifeTime() const
{
return SIV3D_ENGINE(Effect)->getMaxLifeTime(m_handle->id());
}
void Effect::update() const
{
SIV3D_ENGINE(Effect)->updateEffect(m_handle->id());
}
void Effect::clear() const
{
SIV3D_ENGINE(Effect)->clear(m_handle->id());
}
void Effect::swap(Effect& other) noexcept
{
m_handle.swap(other.m_handle);
}
}
| 20.159722 | 115 | 0.671719 | tas9n |
1628020523432c89e4431bcb9daeb491558daa2b | 1,757 | cc | C++ | src/c4/test/tstopstream.cc | rspavel/Draco | b279b1afbfbb39f2d521579697172394c5efd81d | [
"BSD-3-Clause-Open-MPI"
] | null | null | null | src/c4/test/tstopstream.cc | rspavel/Draco | b279b1afbfbb39f2d521579697172394c5efd81d | [
"BSD-3-Clause-Open-MPI"
] | null | null | null | src/c4/test/tstopstream.cc | rspavel/Draco | b279b1afbfbb39f2d521579697172394c5efd81d | [
"BSD-3-Clause-Open-MPI"
] | null | null | null | //----------------------------------*-C++-*----------------------------------//
/*!
* \file c4/test/tstopstream.cc
* \author Kent Budge
* \date Wed Apr 28 09:31:51 2010
* \brief Test c4::determinate_swap and c4::indeterminate_swap functions
* \note Copyright (C) 2016-2019 Triad National Security, LLC.
* All rights reserved.
*/
//---------------------------------------------------------------------------//
//---------------------------------------------------------------------------//
#include "c4/ParallelUnitTest.hh"
#include "c4/opstream.hh"
#include "ds++/Release.hh"
#include <cmath>
using namespace std;
using namespace rtt_dsxx;
using namespace rtt_c4;
//---------------------------------------------------------------------------//
// TESTS
//---------------------------------------------------------------------------//
void tstopstream(UnitTest &ut) {
unsigned const pid = rtt_c4::node();
if (pid == 0)
cout << "Start of write:" << endl;
opstream pout;
pout << "MPI rank " << pid << " reporting ..." << endl;
pout.send();
pout.shrink_to_fit();
pout << "MPI rank " << pid << " reporting a second time ..." << endl;
pout.shrink_to_fit();
pout.send();
if (pid == 0)
cout << ": End of write" << endl;
ut.passes("completed serialized write without hanging or segfaulting");
}
//---------------------------------------------------------------------------//
int main(int argc, char *argv[]) {
rtt_c4::ParallelUnitTest ut(argc, argv, release);
try {
tstopstream(ut);
}
UT_EPILOG(ut);
}
//---------------------------------------------------------------------------//
// end of tstopstream.cc
//---------------------------------------------------------------------------//
| 27.453125 | 79 | 0.407513 | rspavel |
1628a996e8e3d890751ae9cb9c0a66d39338cc38 | 2,148 | cc | C++ | src/tracing/track_event_legacy.cc | newpolaris/perfetto | f108ded952984ec5e7073562d4d3ae055e9cca4d | [
"Apache-2.0"
] | 2 | 2020-03-09T04:39:32.000Z | 2020-03-09T09:12:02.000Z | src/tracing/track_event_legacy.cc | joelagnel/perfetto | 425f7bf4e75cc212244f720b1e19176bc9e54ef4 | [
"Apache-2.0"
] | null | null | null | src/tracing/track_event_legacy.cc | joelagnel/perfetto | 425f7bf4e75cc212244f720b1e19176bc9e54ef4 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "perfetto/tracing/track_event_legacy.h"
#include "perfetto/tracing/track.h"
namespace perfetto {
namespace legacy {
template <>
bool ConvertThreadId(const PerfettoLegacyCurrentThreadId&,
uint64_t*,
int32_t*,
int32_t*) {
// No need to override anything for events on to the current thread.
return false;
}
} // namespace legacy
namespace internal {
void LegacyTraceId::Write(protos::pbzero::TrackEvent::LegacyEvent* event,
uint32_t event_flags) const {
// Legacy flow events always use bind_id.
if (event_flags & (TRACE_EVENT_FLAG_FLOW_OUT | TRACE_EVENT_FLAG_FLOW_IN)) {
// Flow bind_ids don't have scopes, so we need to mangle in-process ones to
// avoid collisions.
if (id_flags_ & TRACE_EVENT_FLAG_HAS_LOCAL_ID) {
event->set_bind_id(raw_id_ ^ ProcessTrack::Current().uuid);
} else {
event->set_bind_id(raw_id_);
}
return;
}
uint32_t scope_flags =
id_flags_ & (TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_HAS_LOCAL_ID |
TRACE_EVENT_FLAG_HAS_GLOBAL_ID);
switch (scope_flags) {
case TRACE_EVENT_FLAG_HAS_ID:
event->set_unscoped_id(raw_id_);
break;
case TRACE_EVENT_FLAG_HAS_LOCAL_ID:
event->set_local_id(raw_id_);
break;
case TRACE_EVENT_FLAG_HAS_GLOBAL_ID:
event->set_global_id(raw_id_);
break;
}
if (scope_)
event->set_id_scope(scope_);
}
} // namespace internal
} // namespace perfetto
| 30.253521 | 79 | 0.69041 | newpolaris |
162e4e6a93d59d81f8c4c52c7c14c17839ab4510 | 5,262 | hpp | C++ | include/UnityEngine/AudioSpeakerMode.hpp | RedBrumbler/BeatSaber-Quest-Codegen | 73dda50b5a3e51f10d86b766dcaa24b0c6226e25 | [
"Unlicense"
] | null | null | null | include/UnityEngine/AudioSpeakerMode.hpp | RedBrumbler/BeatSaber-Quest-Codegen | 73dda50b5a3e51f10d86b766dcaa24b0c6226e25 | [
"Unlicense"
] | null | null | null | include/UnityEngine/AudioSpeakerMode.hpp | RedBrumbler/BeatSaber-Quest-Codegen | 73dda50b5a3e51f10d86b766dcaa24b0c6226e25 | [
"Unlicense"
] | null | null | null | // Autogenerated from CppHeaderCreator
// Created by Sc2ad
// =========================================================================
#pragma once
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
#include "beatsaber-hook/shared/utils/byref.hpp"
// Including type: System.Enum
#include "System/Enum.hpp"
// Completed includes
// Type namespace: UnityEngine
namespace UnityEngine {
// Forward declaring type: AudioSpeakerMode
struct AudioSpeakerMode;
}
#include "beatsaber-hook/shared/utils/il2cpp-type-check.hpp"
DEFINE_IL2CPP_ARG_TYPE(::UnityEngine::AudioSpeakerMode, "UnityEngine", "AudioSpeakerMode");
// Type namespace: UnityEngine
namespace UnityEngine {
// Size: 0x4
#pragma pack(push, 1)
// Autogenerated type: UnityEngine.AudioSpeakerMode
// [TokenAttribute] Offset: FFFFFFFF
struct AudioSpeakerMode/*, public ::System::Enum*/ {
public:
public:
// public System.Int32 value__
// Size: 0x4
// Offset: 0x0
int value;
// Field size check
static_assert(sizeof(int) == 0x4);
public:
// Creating value type constructor for type: AudioSpeakerMode
constexpr AudioSpeakerMode(int value_ = {}) noexcept : value{value_} {}
// Creating interface conversion operator: operator ::System::Enum
operator ::System::Enum() noexcept {
return *reinterpret_cast<::System::Enum*>(this);
}
// Creating conversion operator: operator int
constexpr operator int() const noexcept {
return value;
}
// [ObsoleteAttribute] Offset: 0x11ED73C
// static field const value: static public UnityEngine.AudioSpeakerMode Raw
static constexpr const int Raw = 0;
// Get static field: static public UnityEngine.AudioSpeakerMode Raw
static ::UnityEngine::AudioSpeakerMode _get_Raw();
// Set static field: static public UnityEngine.AudioSpeakerMode Raw
static void _set_Raw(::UnityEngine::AudioSpeakerMode value);
// static field const value: static public UnityEngine.AudioSpeakerMode Mono
static constexpr const int Mono = 1;
// Get static field: static public UnityEngine.AudioSpeakerMode Mono
static ::UnityEngine::AudioSpeakerMode _get_Mono();
// Set static field: static public UnityEngine.AudioSpeakerMode Mono
static void _set_Mono(::UnityEngine::AudioSpeakerMode value);
// static field const value: static public UnityEngine.AudioSpeakerMode Stereo
static constexpr const int Stereo = 2;
// Get static field: static public UnityEngine.AudioSpeakerMode Stereo
static ::UnityEngine::AudioSpeakerMode _get_Stereo();
// Set static field: static public UnityEngine.AudioSpeakerMode Stereo
static void _set_Stereo(::UnityEngine::AudioSpeakerMode value);
// static field const value: static public UnityEngine.AudioSpeakerMode Quad
static constexpr const int Quad = 3;
// Get static field: static public UnityEngine.AudioSpeakerMode Quad
static ::UnityEngine::AudioSpeakerMode _get_Quad();
// Set static field: static public UnityEngine.AudioSpeakerMode Quad
static void _set_Quad(::UnityEngine::AudioSpeakerMode value);
// static field const value: static public UnityEngine.AudioSpeakerMode Surround
static constexpr const int Surround = 4;
// Get static field: static public UnityEngine.AudioSpeakerMode Surround
static ::UnityEngine::AudioSpeakerMode _get_Surround();
// Set static field: static public UnityEngine.AudioSpeakerMode Surround
static void _set_Surround(::UnityEngine::AudioSpeakerMode value);
// static field const value: static public UnityEngine.AudioSpeakerMode Mode5point1
static constexpr const int Mode5point1 = 5;
// Get static field: static public UnityEngine.AudioSpeakerMode Mode5point1
static ::UnityEngine::AudioSpeakerMode _get_Mode5point1();
// Set static field: static public UnityEngine.AudioSpeakerMode Mode5point1
static void _set_Mode5point1(::UnityEngine::AudioSpeakerMode value);
// static field const value: static public UnityEngine.AudioSpeakerMode Mode7point1
static constexpr const int Mode7point1 = 6;
// Get static field: static public UnityEngine.AudioSpeakerMode Mode7point1
static ::UnityEngine::AudioSpeakerMode _get_Mode7point1();
// Set static field: static public UnityEngine.AudioSpeakerMode Mode7point1
static void _set_Mode7point1(::UnityEngine::AudioSpeakerMode value);
// static field const value: static public UnityEngine.AudioSpeakerMode Prologic
static constexpr const int Prologic = 7;
// Get static field: static public UnityEngine.AudioSpeakerMode Prologic
static ::UnityEngine::AudioSpeakerMode _get_Prologic();
// Set static field: static public UnityEngine.AudioSpeakerMode Prologic
static void _set_Prologic(::UnityEngine::AudioSpeakerMode value);
// Get instance field reference: public System.Int32 value__
int& dyn_value__();
}; // UnityEngine.AudioSpeakerMode
#pragma pack(pop)
static check_size<sizeof(AudioSpeakerMode), 0 + sizeof(int)> __UnityEngine_AudioSpeakerModeSizeCheck;
static_assert(sizeof(AudioSpeakerMode) == 0x4);
}
#include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"
| 52.09901 | 104 | 0.733371 | RedBrumbler |
1631304d17f937600856c7180eb2da1bb08b289e | 4,024 | cpp | C++ | plugin_vc/game_vc/CShadowCamera.cpp | gta-chaos-mod/plugin-sdk | e3bf176337774a2afc797a47825f81adde78e899 | [
"Zlib"
] | 368 | 2015-01-01T21:42:00.000Z | 2022-03-29T06:22:22.000Z | plugin_vc/game_vc/CShadowCamera.cpp | gta-chaos-mod/plugin-sdk | e3bf176337774a2afc797a47825f81adde78e899 | [
"Zlib"
] | 89 | 2016-05-08T06:42:36.000Z | 2022-03-29T06:49:09.000Z | plugin_vc/game_vc/CShadowCamera.cpp | gta-chaos-mod/plugin-sdk | e3bf176337774a2afc797a47825f81adde78e899 | [
"Zlib"
] | 179 | 2015-02-03T23:41:17.000Z | 2022-03-26T08:27:16.000Z | /*
Plugin-SDK (Grand Theft Auto Vice City) source file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#include "CShadowCamera.h"
PLUGIN_SOURCE_FILE
int addrof(CShadowCamera::Create) = ADDRESS_BY_VERSION(0x626E70, 0x626E50, 0x626AC0);
int gaddrof(CShadowCamera::Create) = GLOBAL_ADDRESS_BY_VERSION(0x626E70, 0x626E50, 0x626AC0);
RwCamera *CShadowCamera::Create(int rasterSize) {
return plugin::CallMethodAndReturnDynGlobal<RwCamera *, CShadowCamera *, int>(gaddrof(CShadowCamera::Create), this, rasterSize);
}
int addrof(CShadowCamera::Destroy) = ADDRESS_BY_VERSION(0x626DE0, 0x626DC0, 0x626A30);
int gaddrof(CShadowCamera::Destroy) = GLOBAL_ADDRESS_BY_VERSION(0x626DE0, 0x626DC0, 0x626A30);
void CShadowCamera::Destroy() {
plugin::CallMethodDynGlobal<CShadowCamera *>(gaddrof(CShadowCamera::Destroy), this);
}
int addrof(CShadowCamera::DrawOutlineBorder) = ADDRESS_BY_VERSION(0x6264D0, 0x6264B0, 0x626120);
int gaddrof(CShadowCamera::DrawOutlineBorder) = GLOBAL_ADDRESS_BY_VERSION(0x6264D0, 0x6264B0, 0x626120);
RwRaster *CShadowCamera::DrawOutlineBorder(RwRGBA const &color) {
return plugin::CallMethodAndReturnDynGlobal<RwRaster *, CShadowCamera *, RwRGBA const &>(gaddrof(CShadowCamera::DrawOutlineBorder), this, color);
}
int addrof(CShadowCamera::InvertRaster) = ADDRESS_BY_VERSION(0x626BD0, 0x626BB0, 0x626820);
int gaddrof(CShadowCamera::InvertRaster) = GLOBAL_ADDRESS_BY_VERSION(0x626BD0, 0x626BB0, 0x626820);
void CShadowCamera::InvertRaster() {
plugin::CallMethodDynGlobal<CShadowCamera *>(gaddrof(CShadowCamera::InvertRaster), this);
}
int addrof(CShadowCamera::MakeGradientRaster) = ADDRESS_BY_VERSION(0x6269F0, 0x6269D0, 0x626640);
int gaddrof(CShadowCamera::MakeGradientRaster) = GLOBAL_ADDRESS_BY_VERSION(0x6269F0, 0x6269D0, 0x626640);
RwRaster *CShadowCamera::MakeGradientRaster() {
return plugin::CallMethodAndReturnDynGlobal<RwRaster *, CShadowCamera *>(gaddrof(CShadowCamera::MakeGradientRaster), this);
}
int addrof(CShadowCamera::RasterBlur) = ADDRESS_BY_VERSION(0x626780, 0x626760, 0x6263D0);
int gaddrof(CShadowCamera::RasterBlur) = GLOBAL_ADDRESS_BY_VERSION(0x626780, 0x626760, 0x6263D0);
RwRaster *CShadowCamera::RasterBlur(RwRaster *raster, int numPasses) {
return plugin::CallMethodAndReturnDynGlobal<RwRaster *, CShadowCamera *, RwRaster *, int>(gaddrof(CShadowCamera::RasterBlur), this, raster, numPasses);
}
int addrof(CShadowCamera::RasterGradient) = ADDRESS_BY_VERSION(0x6266A0, 0x626680, 0x6262F0);
int gaddrof(CShadowCamera::RasterGradient) = GLOBAL_ADDRESS_BY_VERSION(0x6266A0, 0x626680, 0x6262F0);
RwRaster *CShadowCamera::RasterGradient(RwRaster *raster) {
return plugin::CallMethodAndReturnDynGlobal<RwRaster *, CShadowCamera *, RwRaster *>(gaddrof(CShadowCamera::RasterGradient), this, raster);
}
int addrof(CShadowCamera::RasterResample) = ADDRESS_BY_VERSION(0x626900, 0x6268E0, 0x626550);
int gaddrof(CShadowCamera::RasterResample) = GLOBAL_ADDRESS_BY_VERSION(0x626900, 0x6268E0, 0x626550);
RwRaster *CShadowCamera::RasterResample(RwRaster *raster) {
return plugin::CallMethodAndReturnDynGlobal<RwRaster *, CShadowCamera *, RwRaster *>(gaddrof(CShadowCamera::RasterResample), this, raster);
}
int addrof(CShadowCamera::Update) = ADDRESS_BY_VERSION(0x626D00, 0x626CE0, 0x626950);
int gaddrof(CShadowCamera::Update) = GLOBAL_ADDRESS_BY_VERSION(0x626D00, 0x626CE0, 0x626950);
RwCamera *CShadowCamera::Update(RpAtomic *atomic) {
return plugin::CallMethodAndReturnDynGlobal<RwCamera *, CShadowCamera *, RpAtomic *>(gaddrof(CShadowCamera::Update), this, atomic);
}
int addrof(ShadowRenderCallBack) = ADDRESS_BY_VERSION(0x626DA0, 0x626D80, 0x6269F0);
int gaddrof(ShadowRenderCallBack) = GLOBAL_ADDRESS_BY_VERSION(0x626DA0, 0x626D80, 0x6269F0);
RpAtomic *ShadowRenderCallBack(RpAtomic *atomic, void *data) {
return plugin::CallAndReturnDynGlobal<RpAtomic *, RpAtomic *, void *>(gaddrof(ShadowRenderCallBack), atomic, data);
}
| 50.3 | 155 | 0.797465 | gta-chaos-mod |
1633d122e58504f849a831e667e56cc59ef747b1 | 354 | cpp | C++ | aat/cpp/src/core/exchange/exchange.cpp | mthomascarcamo/aat | fd86f513ccf79625516d2236be655498b24ec742 | [
"Apache-2.0"
] | 305 | 2020-02-24T02:25:43.000Z | 2022-03-26T22:53:43.000Z | aat/cpp/src/core/exchange/exchange.cpp | mthomascarcamo/aat | fd86f513ccf79625516d2236be655498b24ec742 | [
"Apache-2.0"
] | 79 | 2020-02-20T21:00:58.000Z | 2022-03-27T14:06:26.000Z | aat/cpp/src/core/exchange/exchange.cpp | mthomascarcamo/aat | fd86f513ccf79625516d2236be655498b24ec742 | [
"Apache-2.0"
] | 71 | 2020-05-10T11:52:25.000Z | 2022-03-29T07:51:48.000Z | #include <sstream>
#include <aat/core/exchange/exchange.hpp>
namespace aat {
namespace core {
str_t
ExchangeType::toString() const {
if (name != "") {
return "Exchange+(" + name + ")";
}
return "No Exchange";
}
json
ExchangeType::toJson() const {
json ret;
return ret;
}
} // namespace core
} // namespace aat
| 15.391304 | 41 | 0.59322 | mthomascarcamo |
1635c3fd20e2e902d382e06be3d7c1a799708e42 | 1,891 | cpp | C++ | iree/compiler/Codegen/SPIRV/AdrenoConfig.cpp | KyleHerndon/iree | 916c6f92ee4729da21ab0cf266f086f9a4f3b80b | [
"Apache-2.0"
] | null | null | null | iree/compiler/Codegen/SPIRV/AdrenoConfig.cpp | KyleHerndon/iree | 916c6f92ee4729da21ab0cf266f086f9a4f3b80b | [
"Apache-2.0"
] | 4 | 2021-01-05T09:58:18.000Z | 2021-02-11T10:50:12.000Z | iree/compiler/Codegen/SPIRV/AdrenoConfig.cpp | marbre/iree | ce1af180c87ed4b4501d4a7b6f2b2617624440c0 | [
"Apache-2.0"
] | null | null | null | // Copyright 2021 The IREE Authors
//
// Licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//===- AdrenoConfig.h - Adreno CodeGen Configurations ---------------------===//
//
// This file contains CodeGen configurations for Adreno GPUs.
//
//===----------------------------------------------------------------------===//
#include <array>
#include "iree/compiler/Codegen/SPIRV/KernelConfig.h"
#include "llvm/ADT/TypeSwitch.h"
#include "mlir/Dialect/Linalg/IR/LinalgOps.h"
#include "mlir/IR/BuiltinOps.h"
namespace mlir {
namespace iree_compiler {
namespace detail {
//===----------------------------------------------------------------------===//
// Entry Point
//===----------------------------------------------------------------------===//
LogicalResult setAdrenoCodeGenConfig(const spirv::TargetEnv &targetEnv,
Operation *rootOp) {
int64_t subgroupSize = targetEnv.getResourceLimits().subgroup_size().getInt();
return TypeSwitch<Operation *, LogicalResult>(rootOp)
.Case<linalg::BatchMatmulOp, linalg::MatmulOp>([](auto op) {
std::array<int64_t, 2> workgroupXY = {32, 2};
std::array<int64_t, 3> threadMNK = {16, 4, 4};
return setMatmulOpConfig(op, workgroupXY, threadMNK);
})
.Case<linalg::Conv2DNhwcHwcfOp>([subgroupSize](auto op) {
return setConvOpConfig(op, subgroupSize,
/*bestTilingFactor=*/32);
})
.Case<linalg::DepthwiseConv2DNhwcHwcOp>([subgroupSize](auto op) {
return setConvOpConfig(op, subgroupSize,
/*bestTilingFactor=*/16);
})
.Default([](Operation *) { return success(); });
}
} // namespace detail
} // namespace iree_compiler
} // namespace mlir
| 37.078431 | 80 | 0.567953 | KyleHerndon |
1637db86e04614c58e72af5386ad14eb6815f5f7 | 7,075 | cpp | C++ | GridShader.cpp | lanpai/tiny-space | 289ba3081c280debaa2abc879cb09ce1c17754f8 | [
"MIT"
] | 1 | 2019-10-25T22:59:50.000Z | 2019-10-25T22:59:50.000Z | GridShader.cpp | lanpai/tiny-space | 289ba3081c280debaa2abc879cb09ce1c17754f8 | [
"MIT"
] | null | null | null | GridShader.cpp | lanpai/tiny-space | 289ba3081c280debaa2abc879cb09ce1c17754f8 | [
"MIT"
] | null | null | null | #include "GridShader.h"
#include <cmath>
#include <tiny-piyo/Shaders.h>
void GridShader::Init()
{
this->_programID = CreateShader(
R"(
#version 330 core
layout(location = 0) in vec3 vertPosition;
layout(location = 1) in vec4 vertColor;
out vec3 fragPosition;
out vec4 fragColor;
out vec4 delta;
uniform mat4 view;
void main() {
delta = view * vec4(vertPosition, 1.0f);
gl_Position = delta;
fragPosition = vertPosition;
fragColor = vertColor;
}
)",
R"(
#version 330 core
in vec3 fragPosition;
in vec4 fragColor;
in vec4 delta;
out vec4 color;
void main() {
float grid = 2.0;
float gridWidth = length(delta.xyz)/ 300;
color = fragColor;
if (fragPosition.x - (grid * floor(fragPosition.x / grid)) < gridWidth ||
fragPosition.z - (grid * floor(fragPosition.z / grid)) < gridWidth) {
color = fragColor + vec4(0.7, 0.7, 0.7, 0.0);
}
}
)"
);
// Generating VAO, VBO, and IBO
if (this->_vaoID == 0)
glGenVertexArrays(1, &this->_vaoID);
if (this->_vboID == 0)
glGenBuffers(1, &this->_vboID);
if (this->_iboID == 0)
glGenBuffers(1, &this->_iboID);
// Binding the VAO and VBO, and IBO
glBindVertexArray(this->_vaoID);
glBindBuffer(GL_ARRAY_BUFFER, this->_vboID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->_iboID);
// Pointing the VAO to the correct location in the given Vertex3D object
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex3D), (void*)offsetof(Vertex3D, position));
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Vertex3D), (void*)offsetof(Vertex3D, color));
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex3D), (void*)offsetof(Vertex3D, normal));
glEnableVertexAttribArray(3);
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex3D), (void*)offsetof(Vertex3D, uv));
// Unbinding the VAO
glBindVertexArray(this->_vaoID);
}
void GridShader::Destroy()
{
if (this->_vaoID)
glDeleteVertexArrays(1, &this->_vaoID);
if (this->_vboID)
glDeleteBuffers(1, &this->_vboID);
if (this->_iboID)
glDeleteBuffers(1, &this->_iboID);
glDeleteProgram(this->_programID);
}
void GridShader::End()
{
// Binding the VBO
glBindBuffer(GL_ARRAY_BUFFER, this->_vboID);
// Uploading vertex data to the VBO
glBufferData(GL_ARRAY_BUFFER, this->_vertices.size() * sizeof(Vertex3D), nullptr, GL_DYNAMIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, this->_vertices.size() * sizeof(Vertex3D), this->_vertices.data());
// Unbinding the VBO
glBindBuffer(GL_ARRAY_BUFFER, 0);
// Binding the IBO
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->_iboID);
// Uploading index data to the IBO
glBufferData(GL_ELEMENT_ARRAY_BUFFER, this->_indices.size() * sizeof(unsigned int), nullptr, GL_DYNAMIC_DRAW);
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, this->_indices.size() * sizeof(unsigned int), this->_indices.data());
// Unbinding the IBO
glBindBuffer(GL_ARRAY_BUFFER, 0);
// Clearing vertex and index vectors
this->_numIndices = this->_indices.size();
this->_vertices.clear();
this->_indices.clear();
}
void GridShader::Render()
{
// Using GLSL program and binding the VAO
this->Use();
glBindVertexArray(this->_vaoID);
//glLineWidth(2.0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glDisable(GL_CULL_FACE);
// Drawing vertices
glDrawElements(this->drawQuads ? GL_QUADS : GL_LINES, this->_numIndices, GL_UNSIGNED_INT, 0);
// Unbinding the GLSL program and unbinding the VAO
glBindVertexArray(0);
this->Unuse();
}
void GridShader::DrawTri(Vertex3D a, Vertex3D b, Vertex3D c)
{
int firstIndex = this->_vertices.size();
// Pushing vertices into vector
this->_vertices.reserve(this->_vertices.size() + 3);
this->_vertices.push_back(a);
this->_vertices.push_back(b);
this->_vertices.push_back(c);
// Pushing corresponding indices into vector
this->_indices.reserve(this->_indices.size() + 3);
this->_indices.push_back(firstIndex);
this->_indices.push_back(firstIndex + 1);
this->_indices.push_back(firstIndex + 2);
}
void GridShader::DrawLine(Vertex3D a, Vertex3D b)
{
int firstIndex = this->_vertices.size();
// Pushing vertices into vector
this->_vertices.reserve(this->_vertices.size() + 2);
this->_vertices.push_back(a);
this->_vertices.push_back(b);
// Pushing corresponding indices into vector
this->_indices.reserve(this->_indices.size() + 2);
this->_indices.push_back(firstIndex);
this->_indices.push_back(firstIndex + 1);
}
void GridShader::DrawGrid(
double (*func)(double, double, double),
ColorRGBA8 (*color)(double, double, double),
double xmin, double xmax,
double ymin, double ymax,
double t)
{
int gridX = 0;
int gridY = 0;
int row = std::ceil((xmax - xmin) / this->_deltaX) + 1;
int col = std::ceil((ymax - ymin) / this->_deltaY) + 1;
this->_vertices.reserve(
this->_vertices.size() +
row * col - 1);
this->_indices.reserve(
this->_indices.size() +
row * col * 4 - row - col);
for (int indexX = 0; indexX < row; indexX++)
{
double x = xmin + this->_deltaX * indexX;
x = (x > xmax) ? xmax : x;
for (int indexY = 0; indexY < col; indexY++ )
{
double y = ymin + this->_deltaY * indexY;
y = (y > ymax) ? ymax : y;
int firstIndex = this->_vertices.size();
this->_vertices.push_back(Vertex3D(
float3(
x, func(x, y, t), y),
color(x, y, t)));
if (this->drawQuads) {
if (y != ymin && x != xmin) {
this->_indices.push_back(firstIndex);
this->_indices.push_back(firstIndex - 1);
this->_indices.push_back(firstIndex - row - 1);
this->_indices.push_back(firstIndex - row);
}
}
else {
if (y != ymin)
{
this->_indices.push_back(firstIndex);
this->_indices.push_back(firstIndex - 1);
}
if (x != xmin) {
this->_indices.push_back(firstIndex);
this->_indices.push_back(firstIndex - row);
}
}
gridY++;
}
gridX++;
}
}
| 30.76087 | 117 | 0.581908 | lanpai |
163b12982bd0b636414730a80926e7ab9cdf98c4 | 12,315 | cc | C++ | v8_consumer/src/utils.cc | abhi-bit/Eventing | 8836d2b262365e4ee51ec583a7818d2480c2d498 | [
"Apache-2.0"
] | null | null | null | v8_consumer/src/utils.cc | abhi-bit/Eventing | 8836d2b262365e4ee51ec583a7818d2480c2d498 | [
"Apache-2.0"
] | 11 | 2016-06-22T16:21:55.000Z | 2016-11-02T04:23:08.000Z | v8_consumer/src/utils.cc | abhi-bit/Eventing | 8836d2b262365e4ee51ec583a7818d2480c2d498 | [
"Apache-2.0"
] | 1 | 2016-06-29T11:52:31.000Z | 2016-06-29T11:52:31.000Z | // Copyright (c) 2017 Couchbase, 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.
#include <regex>
#include "js_exception.h"
#include "utils.h"
#include "../../gen/js/escodegen.h"
#include "../../gen/js/esprima.h"
#include "../../gen/js/estraverse.h"
#include "../../gen/js/source-map.h"
#include "../../gen/js/transpiler.h"
static bool ipv6 = false;
std::mutex time_now_mutex;
std::mutex convert_to_iso8601_mutex;
#if defined(WIN32) || defined(_WIN32)
int Wvasprintf(char **strp, const char *fmt, va_list ap) {
// _vscprintf tells you how big the buffer needs to be
int len = _vscprintf(fmt, ap);
if (len == -1) {
return -1;
}
size_t size = (size_t)len + 1;
char *str = static_cast<char *>(malloc(size));
if (!str) {
return -1;
}
// vsprintf_s is the "secure" version of vsprintf
int r = vsprintf_s(str, len + 1, fmt, ap);
if (r == -1) {
free(str);
return -1;
}
*strp = str;
return r;
}
int WinSprintf(char **strp, const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
int r = Wvasprintf(strp, fmt, ap);
va_end(ap);
return r;
}
#endif
v8::Local<v8::String> v8Str(v8::Isolate *isolate, const char *str) {
v8::EscapableHandleScope handle_scope(isolate);
auto v8maybe_str =
v8::String::NewFromUtf8(isolate, str, v8::NewStringType::kNormal);
v8::Local<v8::String> v8local_str;
if (TO_LOCAL(v8maybe_str, &v8local_str)) {
return handle_scope.Escape(v8local_str);
}
// TODO : Need to throw an exception and propagate it to the handler
return handle_scope.Escape(v8::String::Empty(isolate));
}
v8::Local<v8::String> v8Str(v8::Isolate *isolate, const std::string &str) {
v8::EscapableHandleScope handle_scope(isolate);
auto v8maybe_str =
v8::String::NewFromUtf8(isolate, str.c_str(), v8::NewStringType::kNormal);
v8::Local<v8::String> v8local_str;
if (TO_LOCAL(v8maybe_str, &v8local_str)) {
return handle_scope.Escape(v8local_str);
}
return handle_scope.Escape(v8::String::Empty(isolate));
}
v8::Local<v8::Name> v8Name(v8::Isolate *isolate, uint32_t key) {
v8::EscapableHandleScope handle_scope(isolate);
auto key_v8_str = v8Str(isolate, std::to_string(key));
v8::Local<v8::Name> key_name(key_v8_str);
return handle_scope.Escape(key_name);
}
v8::Local<v8::Array> v8Array(v8::Isolate *isolate,
const std::vector<std::string> &from) {
v8::EscapableHandleScope handle_scope(isolate);
auto context = isolate->GetCurrentContext();
auto array = v8::Array::New(isolate, static_cast<int>(from.size()));
for (uint32_t i = 0; i < from.size(); ++i) {
auto success = false;
if (!TO(array->Set(context, i, v8Str(isolate, from[i])), &success)) {
return handle_scope.Escape(array);
}
}
return handle_scope.Escape(array);
}
std::string JSONStringify(v8::Isolate *isolate,
const v8::Local<v8::Value> &object) {
if (IS_EMPTY(object)) {
return "";
}
v8::HandleScope handle_scope(isolate);
auto context = isolate->GetCurrentContext();
auto global = context->Global();
auto key = v8Str(isolate, "JSON");
v8::Local<v8::Value> v8val_json;
if (!TO_LOCAL(global->Get(context, key), &v8val_json)) {
return "";
}
v8::Local<v8::Object> v8obj_json;
if (!TO_LOCAL(v8val_json->ToObject(context), &v8obj_json)) {
return "";
}
key = v8Str(isolate, "stringify");
v8::Local<v8::Value> v8val_stringify;
if (!TO_LOCAL(v8obj_json->Get(context, key), &v8val_stringify)) {
return "";
}
auto v8fun_stringify = v8val_stringify.As<v8::Function>();
v8::Local<v8::Value> args[1] = {object};
v8::Local<v8::Value> v8obj_result;
if (!TO_LOCAL(v8fun_stringify->Call(context, global, 1, args),
&v8obj_result)) {
return "";
}
v8::String::Utf8Value utf8_result(v8obj_result);
return *utf8_result;
}
// Extracts a C string from a V8 Utf8Value.
const char *ToCString(const v8::String::Utf8Value &value) {
return *value ? *value : "<std::string conversion failed>";
}
std::string ConvertToISO8601(std::string timestamp) {
std::lock_guard<std::mutex> lock(convert_to_iso8601_mutex);
char buf[sizeof "2016-08-09T10:11:12"];
std::string buf_s;
time_t now;
int timerValue = atoi(timestamp.c_str());
// Expiry timers more than 30 days will mention epoch
// otherwise it will mention seconds from when key
// was set
if (timerValue > 25920000) {
now = timerValue;
strftime(buf, sizeof buf, "%FT%T", gmtime(&now));
buf_s.assign(buf);
} else {
time(&now);
now += timerValue;
strftime(buf, sizeof buf, "%FT%T", gmtime(&now));
buf_s.assign(buf);
}
return buf_s;
}
// Exception details will be appended to the first argument.
std::string ExceptionString(v8::Isolate *isolate, v8::TryCatch *try_catch) {
std::string out;
char scratch[EXCEPTION_STR_SIZE]; // just some scratch space for sprintf
v8::HandleScope handle_scope(isolate);
const char *exception_string =
JSONStringify(isolate, try_catch->Exception()).c_str();
v8::Handle<v8::Message> message = try_catch->Message();
if (message.IsEmpty()) {
// V8 didn't provide any extra information about this error;
// just print the exception.
out.append(exception_string);
out.append("\n");
} else {
// Print (filename):(line number)
v8::String::Utf8Value filename(message->GetScriptOrigin().ResourceName());
const char *filename_string = ToCString(filename);
int linenum = message->GetLineNumber();
snprintf(scratch, EXCEPTION_STR_SIZE, "%i", linenum);
out.append(filename_string);
out.append(":");
out.append(scratch);
out.append("\n");
// Print line of source code.
v8::String::Utf8Value sourceline(message->GetSourceLine());
const char *sourceline_string = ToCString(sourceline);
out.append(sourceline_string);
out.append("\n");
// Print wavy underline (GetUnderline is deprecated).
int start = message->GetStartColumn();
for (int i = 0; i < start; i++) {
out.append(" ");
}
int end = message->GetEndColumn();
for (int i = start; i < end; i++) {
out.append("^");
}
out.append("\n");
v8::String::Utf8Value stack_trace(try_catch->StackTrace());
if (stack_trace.length() > 0) {
const char *stack_trace_string = ToCString(stack_trace);
out.append(stack_trace_string);
out.append("\n");
} else {
out.append(exception_string);
out.append("\n");
}
}
return out;
}
std::vector<std::string> &split(const std::string &s, char delim,
std::vector<std::string> &elems) {
std::stringstream ss(s);
std::string item;
while (std::getline(ss, item, delim)) {
elems.push_back(item);
}
return elems;
}
std::vector<std::string> split(const std::string &s, char delim) {
std::vector<std::string> elems;
split(s, delim, elems);
return elems;
}
std::string GetTranspilerSrc() {
std::string transpiler_js_src =
std::string((const char *)js_esprima) + '\n' +
std::string((const char *)js_escodegen) + '\n' +
std::string((const char *)js_estraverse) + '\n' +
std::string((const char *)js_transpiler) + '\n' +
std::string((const char *)js_source_map);
return transpiler_js_src;
}
void SetIPv6(bool is6) { ipv6 = is6; }
std::string Localhost(bool isUrl) {
return ipv6 ? (isUrl ? "[::1]" : "::1") : "127.0.0.1";
}
bool IsIPv6() { return ipv6; }
std::string JoinHostPort(const std::string &host, const std::string &port) {
static std::regex ipv6re("^[0-9a-fA-F:]*:[0-9a-fA-F:]+$");
return std::regex_match(host, ipv6re) ? "[" + host + "]:" + port
: host + ":" + port;
}
std::pair<std::string, std::string> GetLocalKey() {
const char *usr = std::getenv("CBEVT_CALLBACK_USR");
const char *key = std::getenv("CBEVT_CALLBACK_KEY");
if (!usr || !key) {
LOG(logError) << "Failed to read CBEVT_CALLBACK_USR/KEY env var"
<< std::endl;
usr = "unknown-client";
key = "unknown-client";
}
return std::make_pair<std::string, std::string>(usr, key);
}
std::string GetTimestampNow() {
// std::ctime is not thread safe -
// http://en.cppreference.com/w/cpp/chrono/c/ctime
std::lock_guard<std::mutex> lock(time_now_mutex);
auto now = std::chrono::system_clock::now();
auto now_time = std::chrono::system_clock::to_time_t(now);
std::string now_str = std::ctime(&now_time);
now_str.erase(std::remove(now_str.begin(), now_str.end(), '\n'),
now_str.end());
return ConvertToISO8601(now_str) + "Z";
}
ParseInfo UnflattenParseInfo(std::unordered_map<std::string, std::string> &kv) {
ParseInfo info;
info.is_valid = std::stoi(kv["is_valid"]) != 0;
info.is_select_query = std::stoi(kv["is_select_query"]) != 0;
info.is_dml_query = std::stoi(kv["is_dml_query"]) != 0;
info.keyspace_name = kv["keyspace_name"];
info.info = kv["info"];
return info;
}
bool IsRetriable(lcb_error_t error) {
return static_cast<bool>(LCB_EIFTMP(error));
}
bool IsTerminatingRetriable(bool retry) { return retry; }
bool IsExecutionTerminating(v8::Isolate *isolate) {
return isolate->IsExecutionTerminating();
}
Utils::Utils(v8::Isolate *isolate, const v8::Local<v8::Context> &context)
: isolate_(isolate) {
context_.Reset(isolate_, context);
global_.Reset(isolate_, context->Global());
}
Utils::~Utils() {
context_.Reset();
global_.Reset();
}
v8::Local<v8::Value>
Utils::GetPropertyFromGlobal(const std::string &method_name) {
v8::EscapableHandleScope handle_scope(isolate_);
auto context = context_.Get(isolate_);
auto global = global_.Get(isolate_);
auto method_name_v8str = v8Str(isolate_, method_name.c_str());
v8::Local<v8::Value> method;
if (!TO_LOCAL(global->Get(context, method_name_v8str), &method)) {
return handle_scope.Escape(method);
}
return handle_scope.Escape(method);
}
v8::Local<v8::Value>
Utils::GetPropertyFromObject(const v8::Local<v8::Value> &obj_v8val,
const std::string &method_name) {
v8::EscapableHandleScope handle_scope(isolate_);
auto context = context_.Get(isolate_);
v8::Local<v8::Value> method;
v8::Local<v8::Object> obj_local;
if (!TO_LOCAL(obj_v8val->ToObject(context), &obj_local)) {
return handle_scope.Escape(method);
}
auto method_name_v8str = v8Str(isolate_, method_name.c_str());
if (!TO_LOCAL(obj_local->Get(context, method_name_v8str), &method)) {
return handle_scope.Escape(method);
}
return handle_scope.Escape(method);
}
std::string Utils::GetFunctionName(const v8::Local<v8::Value> &func_val) {
v8::HandleScope handle_scope(isolate_);
auto func = func_val.As<v8::Function>();
return ToCPPString(func->GetName());
}
std::string Utils::ToCPPString(const v8::Local<v8::Value> &str_val) {
v8::HandleScope handle_scope(isolate_);
v8::String::Utf8Value utf8(str_val);
std::string str = *utf8;
return str;
}
bool Utils::IsFuncGlobal(const v8::Local<v8::Value> &func) {
v8::HandleScope handle_scope(isolate_);
auto js_exception = UnwrapData(isolate_)->js_exception;
if (!func->IsFunction()) {
auto message = "Invalid arg: Function reference expected";
js_exception->Throw(message);
return false;
}
auto func_ref = func.As<v8::Function>();
auto func_name = ToCPPString(func_ref->GetName());
if (func_name.empty()) {
auto message = "Invalid arg: Anonymous function is not allowed";
js_exception->Throw(message);
return false;
}
auto global_func_val = GetPropertyFromGlobal(func_name);
auto global_func = global_func_val.As<v8::Function>();
if (global_func->IsUndefined()) {
auto message = func_name + " is not accessible from global scope";
js_exception->Throw(message);
return false;
}
return true;
} | 29.746377 | 80 | 0.665286 | abhi-bit |
1640bdb99b1a2bf0f02143d63fb318654f36f5b2 | 1,431 | cpp | C++ | SOSHook/stdafx.cpp | tongko/SOS | 4b7ab321b336a2077aaf957c4362962e4e65259c | [
"Apache-2.0"
] | null | null | null | SOSHook/stdafx.cpp | tongko/SOS | 4b7ab321b336a2077aaf957c4362962e4e65259c | [
"Apache-2.0"
] | null | null | null | SOSHook/stdafx.cpp | tongko/SOS | 4b7ab321b336a2077aaf957c4362962e4e65259c | [
"Apache-2.0"
] | null | null | null | // stdafx.cpp : source file that includes just the standard includes
// SOSHook.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
HMODULE g_hModule = NULL;
#ifdef _DEBUG
void* __cdecl operator new(size_t nSize, LPCSTR lpszFileName, int nLine)
{
return ::_malloc_dbg(nSize, 1, lpszFileName, nLine);
}
void __cdecl operator delete(void* pData, LPCSTR /* lpszFileName */, int /* nLine */)
{
::operator delete(pData);
}
#endif
#ifdef _DEBUG
#include <stdio.h>
void Trace(const wchar_t* pszFormat, ...)
{
wchar_t szOutput[1024];
va_list vaList;
va_start(vaList, pszFormat);
vswprintf(szOutput, _countof(szOutput), pszFormat, vaList);
::OutputDebugString(szOutput);
}
#endif // _DEBUG
std::wstring FormatError(DWORD errorId, wformat format, std::wstring name)
{
if (errorId == 0)
return std::wstring();
LPTSTR msgBuffer = nullptr;
size_t size = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, errorId, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&msgBuffer, 0, NULL);
std::wstring message(msgBuffer, size);
LocalFree(msgBuffer);
return (format % name % (wformat(L"ID: %1%, Message: %2%") % errorId % message).str()).str();
} | 26.018182 | 122 | 0.707198 | tongko |
1642c9fbf7d569e9760f9e78a9124aa1bd2816c7 | 105,166 | cpp | C++ | src/coreclr/src/vm/gdbjit.cpp | patricksadowski/runtime | aa5b2041471d7687dbddb1d275ea8a93943c43bf | [
"MIT"
] | 2 | 2020-03-28T13:38:11.000Z | 2020-12-18T15:00:04.000Z | src/coreclr/src/vm/gdbjit.cpp | patricksadowski/runtime | aa5b2041471d7687dbddb1d275ea8a93943c43bf | [
"MIT"
] | 1 | 2020-04-24T10:03:11.000Z | 2020-04-24T10:03:11.000Z | src/coreclr/src/vm/gdbjit.cpp | patricksadowski/runtime | aa5b2041471d7687dbddb1d275ea8a93943c43bf | [
"MIT"
] | 3 | 2021-02-10T16:20:05.000Z | 2021-03-12T07:55:36.000Z | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//*****************************************************************************
// File: gdbjit.cpp
//
//
// NotifyGdb implementation.
//
//*****************************************************************************
#include "common.h"
#include "formattype.h"
#include "gdbjit.h"
#include "gdbjithelpers.h"
thread_local bool tls_isSymReaderInProgress = false;
#ifdef _DEBUG
static void DumpElf(const char* methodName, const char *addr, size_t size)
{
char dump[1024] = { 0, };
strcat(dump, methodName);
strcat(dump, ".o");
FILE *f = fopen(dump, "wb");
fwrite(addr, sizeof(char), size, f);
fclose(f);
}
#endif
TypeInfoBase*
GetTypeInfoFromTypeHandle(TypeHandle typeHandle,
NotifyGdb::PTK_TypeInfoMap pTypeMap,
FunctionMemberPtrArrayHolder &method)
{
TypeInfoBase *foundTypeInfo = nullptr;
TypeKey key = typeHandle.GetTypeKey();
PTR_MethodTable pMT = typeHandle.GetMethodTable();
if (pTypeMap->Lookup(&key, &foundTypeInfo))
{
return foundTypeInfo;
}
CorElementType corType = typeHandle.GetSignatureCorElementType();
switch (corType)
{
case ELEMENT_TYPE_I1:
case ELEMENT_TYPE_U1:
case ELEMENT_TYPE_CHAR:
case ELEMENT_TYPE_VOID:
case ELEMENT_TYPE_BOOLEAN:
case ELEMENT_TYPE_I2:
case ELEMENT_TYPE_U2:
case ELEMENT_TYPE_I4:
case ELEMENT_TYPE_U4:
case ELEMENT_TYPE_I8:
case ELEMENT_TYPE_U8:
case ELEMENT_TYPE_R4:
case ELEMENT_TYPE_R8:
case ELEMENT_TYPE_U:
case ELEMENT_TYPE_I:
{
NewHolder<PrimitiveTypeInfo> typeInfo = new PrimitiveTypeInfo(typeHandle);
pTypeMap->Add(typeInfo->GetTypeKey(), typeInfo);
typeInfo.SuppressRelease();
return typeInfo;
}
case ELEMENT_TYPE_VALUETYPE:
case ELEMENT_TYPE_CLASS:
{
ApproxFieldDescIterator fieldDescIterator(pMT,
pMT->IsString() ? ApproxFieldDescIterator::INSTANCE_FIELDS : ApproxFieldDescIterator::ALL_FIELDS);
ULONG cFields = fieldDescIterator.Count();
NewHolder<ClassTypeInfo> typeInfo = new ClassTypeInfo(typeHandle, cFields, method);
NewHolder<RefTypeInfo> refTypeInfo = nullptr;
if (!typeHandle.IsValueType())
{
refTypeInfo = new NamedRefTypeInfo(typeHandle, typeInfo);
typeInfo.SuppressRelease();
pTypeMap->Add(refTypeInfo->GetTypeKey(), refTypeInfo);
refTypeInfo.SuppressRelease();
}
else
{
pTypeMap->Add(typeInfo->GetTypeKey(), typeInfo);
typeInfo.SuppressRelease();
}
//
// Now fill in the array
//
FieldDesc *pField;
for (ULONG i = 0; i < cFields; i++)
{
pField = fieldDescIterator.Next();
LPCUTF8 szName = pField->GetName();
typeInfo->members[i].m_member_name = new char[strlen(szName) + 1];
strcpy(typeInfo->members[i].m_member_name, szName);
if (!pField->IsStatic())
{
typeInfo->members[i].m_member_offset = (ULONG)pField->GetOffset();
if (!typeHandle.IsValueType())
typeInfo->members[i].m_member_offset += Object::GetOffsetOfFirstField();
}
else
{
PTR_BYTE base = 0;
MethodTable* pMT = pField->GetEnclosingMethodTable();
base = pField->GetBase();
// TODO: add support of generics with static fields
if (pField->IsRVA() || !pMT->IsDynamicStatics())
{
PTR_VOID pAddress = pField->GetStaticAddressHandle((PTR_VOID)dac_cast<TADDR>(base));
typeInfo->members[i].m_static_member_address = dac_cast<TADDR>(pAddress);
}
}
typeInfo->members[i].m_member_type =
GetTypeInfoFromTypeHandle(pField->GetExactFieldType(typeHandle), pTypeMap, method);
// handle the System.String case:
// coerce type of the second field into array type
if (pMT->IsString() && i == 1)
{
TypeInfoBase* elemTypeInfo = typeInfo->members[1].m_member_type;
typeInfo->m_array_type = new ArrayTypeInfo(typeHandle.MakeSZArray(), 1, elemTypeInfo);
typeInfo->members[1].m_member_type = typeInfo->m_array_type;
}
}
// Ignore inheritance from System.Object and System.ValueType classes.
if (!typeHandle.IsValueType() &&
pMT->GetParentMethodTable() && pMT->GetParentMethodTable()->GetParentMethodTable())
{
typeInfo->m_parent = GetTypeInfoFromTypeHandle(typeHandle.GetParent(), pTypeMap, method);
}
if (refTypeInfo)
return refTypeInfo;
else
return typeInfo;
}
case ELEMENT_TYPE_PTR:
case ELEMENT_TYPE_BYREF:
{
TypeInfoBase* valTypeInfo = GetTypeInfoFromTypeHandle(typeHandle.GetTypeParam(), pTypeMap, method);
NewHolder<RefTypeInfo> typeInfo = new RefTypeInfo(typeHandle, valTypeInfo);
typeInfo->m_type_offset = valTypeInfo->m_type_offset;
pTypeMap->Add(typeInfo->GetTypeKey(), typeInfo);
typeInfo.SuppressRelease();
return typeInfo;
}
case ELEMENT_TYPE_ARRAY:
case ELEMENT_TYPE_SZARRAY:
{
NewHolder<ClassTypeInfo> info = new ClassTypeInfo(typeHandle, pMT->GetRank() == 1 ? 2 : 3, method);
NewHolder<RefTypeInfo> refTypeInfo = new NamedRefTypeInfo(typeHandle, info);
info.SuppressRelease();
pTypeMap->Add(refTypeInfo->GetTypeKey(), refTypeInfo);
refTypeInfo.SuppressRelease();
TypeInfoBase* lengthTypeInfo = GetTypeInfoFromTypeHandle(
TypeHandle(MscorlibBinder::GetElementType(ELEMENT_TYPE_I4)), pTypeMap, method);
TypeInfoBase* valTypeInfo = GetTypeInfoFromTypeHandle(typeHandle.GetArrayElementTypeHandle(), pTypeMap, method);
info->m_array_type = new ArrayTypeInfo(typeHandle, 1, valTypeInfo);
info->members[0].m_member_name = new char[16];
strcpy(info->members[0].m_member_name, "m_NumComponents");
info->members[0].m_member_offset = ArrayBase::GetOffsetOfNumComponents();
info->members[0].m_member_type = lengthTypeInfo;
info->members[1].m_member_name = new char[7];
strcpy(info->members[1].m_member_name, "m_Data");
info->members[1].m_member_offset = ArrayBase::GetDataPtrOffset(pMT);
info->members[1].m_member_type = info->m_array_type;
if (pMT->GetRank() != 1)
{
TypeHandle dwordArray(MscorlibBinder::GetElementType(ELEMENT_TYPE_I4));
info->m_array_bounds_type = new ArrayTypeInfo(dwordArray.MakeSZArray(), pMT->GetRank(), lengthTypeInfo);
info->members[2].m_member_name = new char[9];
strcpy(info->members[2].m_member_name, "m_Bounds");
info->members[2].m_member_offset = ArrayBase::GetBoundsOffset(pMT);
info->members[2].m_member_type = info->m_array_bounds_type;
}
return refTypeInfo;
}
default:
COMPlusThrowHR(COR_E_NOTSUPPORTED);
}
}
TypeInfoBase* GetArgTypeInfo(MethodDesc* methodDescPtr,
NotifyGdb::PTK_TypeInfoMap pTypeMap,
unsigned ilIndex,
FunctionMemberPtrArrayHolder &method)
{
MetaSig sig(methodDescPtr);
TypeHandle th;
if (ilIndex == 0)
{
th = sig.GetRetTypeHandleNT();
}
else
{
while (--ilIndex)
sig.SkipArg();
sig.NextArg();
th = sig.GetLastTypeHandleNT();
}
return GetTypeInfoFromTypeHandle(th, pTypeMap, method);
}
TypeInfoBase* GetLocalTypeInfo(MethodDesc *methodDescPtr,
NotifyGdb::PTK_TypeInfoMap pTypeMap,
unsigned ilIndex,
FunctionMemberPtrArrayHolder &funcs)
{
COR_ILMETHOD_DECODER method(methodDescPtr->GetILHeader());
if (method.GetLocalVarSigTok())
{
DWORD cbSigLen;
PCCOR_SIGNATURE pComSig;
if (FAILED(methodDescPtr->GetMDImport()->GetSigFromToken(method.GetLocalVarSigTok(), &cbSigLen, &pComSig)))
{
printf("\nInvalid record");
return nullptr;
}
_ASSERTE(*pComSig == IMAGE_CEE_CS_CALLCONV_LOCAL_SIG);
SigTypeContext typeContext(methodDescPtr, TypeHandle());
MetaSig sig(pComSig, cbSigLen, methodDescPtr->GetModule(), &typeContext, MetaSig::sigLocalVars);
if (ilIndex > 0)
{
while (ilIndex--)
sig.SkipArg();
}
sig.NextArg();
TypeHandle th = sig.GetLastTypeHandleNT();
return GetTypeInfoFromTypeHandle(th, pTypeMap, funcs);
}
return nullptr;
}
HRESULT GetArgNameByILIndex(MethodDesc* methodDescPtr, unsigned index, NewArrayHolder<char> ¶mName)
{
IMDInternalImport* mdImport = methodDescPtr->GetMDImport();
mdParamDef paramToken;
USHORT seq;
DWORD attr;
HRESULT status;
// Param indexing is 1-based.
ULONG32 mdIndex = index + 1;
MetaSig sig(methodDescPtr);
if (sig.HasThis())
{
mdIndex--;
}
status = mdImport->FindParamOfMethod(methodDescPtr->GetMemberDef(), mdIndex, ¶mToken);
if (status == S_OK)
{
LPCSTR name;
status = mdImport->GetParamDefProps(paramToken, &seq, &attr, &name);
paramName = new char[strlen(name) + 1];
strcpy(paramName, name);
}
return status;
}
// Copy-pasted from src/debug/di/module.cpp
HRESULT FindNativeInfoInILVariable(DWORD dwIndex,
SIZE_T ip,
ICorDebugInfo::NativeVarInfo* nativeInfoList,
unsigned int nativeInfoCount,
ICorDebugInfo::NativeVarInfo** ppNativeInfo)
{
_ASSERTE(ppNativeInfo != NULL);
*ppNativeInfo = NULL;
int lastGoodOne = -1;
for (unsigned int i = 0; i < (unsigned)nativeInfoCount; i++)
{
if (nativeInfoList[i].varNumber == dwIndex)
{
if ((lastGoodOne == -1) || (nativeInfoList[lastGoodOne].startOffset < nativeInfoList[i].startOffset))
{
lastGoodOne = i;
}
if ((nativeInfoList[i].startOffset <= ip) &&
(nativeInfoList[i].endOffset > ip))
{
*ppNativeInfo = &(nativeInfoList[i]);
return S_OK;
}
}
}
if ((lastGoodOne > -1) && (nativeInfoList[lastGoodOne].endOffset == ip))
{
*ppNativeInfo = &(nativeInfoList[lastGoodOne]);
return S_OK;
}
return CORDBG_E_IL_VAR_NOT_AVAILABLE;
}
BYTE* DebugInfoStoreNew(void * pData, size_t cBytes)
{
return new BYTE[cBytes];
}
/* Get IL to native offsets map */
HRESULT
GetMethodNativeMap(MethodDesc* methodDesc,
ULONG32* numMap,
NewArrayHolder<DebuggerILToNativeMap> &map,
ULONG32* pcVars,
ICorDebugInfo::NativeVarInfo** ppVars)
{
// Use the DebugInfoStore to get IL->Native maps.
// It doesn't matter whether we're jitted, ngenned etc.
DebugInfoRequest request;
TADDR nativeCodeStartAddr = PCODEToPINSTR(methodDesc->GetNativeCode());
request.InitFromStartingAddr(methodDesc, nativeCodeStartAddr);
// Bounds info.
ULONG32 countMapCopy;
NewHolder<ICorDebugInfo::OffsetMapping> mapCopy(NULL);
BOOL success = DebugInfoManager::GetBoundariesAndVars(request,
DebugInfoStoreNew,
NULL, // allocator
&countMapCopy,
&mapCopy,
pcVars,
ppVars);
if (!success)
{
return E_FAIL;
}
// Need to convert map formats.
*numMap = countMapCopy;
map = new DebuggerILToNativeMap[countMapCopy];
ULONG32 i;
for (i = 0; i < *numMap; i++)
{
map[i].ilOffset = mapCopy[i].ilOffset;
map[i].nativeStartOffset = mapCopy[i].nativeOffset;
if (i > 0)
{
map[i - 1].nativeEndOffset = map[i].nativeStartOffset;
}
map[i].source = mapCopy[i].source;
}
if (*numMap >= 1)
{
map[i - 1].nativeEndOffset = 0;
}
return S_OK;
}
HRESULT FunctionMember::GetLocalsDebugInfo(NotifyGdb::PTK_TypeInfoMap pTypeMap,
LocalsInfo& locals,
int startNativeOffset,
FunctionMemberPtrArrayHolder &method)
{
ICorDebugInfo::NativeVarInfo* nativeVar = NULL;
int thisOffs = 0;
if (!md->IsStatic())
{
thisOffs = 1;
}
int i;
for (i = 0; i < m_num_args - thisOffs; i++)
{
if (FindNativeInfoInILVariable(i + thisOffs, startNativeOffset, locals.vars, locals.countVars, &nativeVar) == S_OK)
{
vars[i + thisOffs].m_var_type = GetArgTypeInfo(md, pTypeMap, i + 1, method);
GetArgNameByILIndex(md, i + thisOffs, vars[i + thisOffs].m_var_name);
vars[i + thisOffs].m_il_index = i;
vars[i + thisOffs].m_native_offset = nativeVar->loc.vlStk.vlsOffset;
vars[i + thisOffs].m_var_abbrev = 6;
}
}
//Add info about 'this' as first argument
if (thisOffs == 1)
{
if (FindNativeInfoInILVariable(0, startNativeOffset, locals.vars, locals.countVars, &nativeVar) == S_OK)
{
TypeHandle th = TypeHandle(md->GetMethodTable());
if (th.IsValueType())
th = th.MakePointer();
vars[0].m_var_type = GetTypeInfoFromTypeHandle(th, pTypeMap, method);
vars[0].m_var_name = new char[strlen("this") + 1];
strcpy(vars[0].m_var_name, "this");
vars[0].m_il_index = 0;
vars[0].m_native_offset = nativeVar->loc.vlStk.vlsOffset;
vars[0].m_var_abbrev = 13;
}
i++;
}
for (; i < m_num_vars; i++)
{
if (FindNativeInfoInILVariable(
i, startNativeOffset, locals.vars, locals.countVars, &nativeVar) == S_OK)
{
int ilIndex = i - m_num_args;
vars[i].m_var_type = GetLocalTypeInfo(md, pTypeMap, ilIndex, method);
vars[i].m_var_name = new char[strlen(locals.localsName[ilIndex]) + 1];
strcpy(vars[i].m_var_name, locals.localsName[ilIndex]);
vars[i].m_il_index = ilIndex;
vars[i].m_native_offset = nativeVar->loc.vlStk.vlsOffset;
vars[i].m_var_abbrev = 5;
TADDR nativeStart;
TADDR nativeEnd;
int ilLen = locals.localsScope[ilIndex].ilEndOffset - locals.localsScope[ilIndex].ilStartOffset;
if (GetBlockInNativeCode(locals.localsScope[ilIndex].ilStartOffset, ilLen, &nativeStart, &nativeEnd))
{
vars[i].m_low_pc = md->GetNativeCode() + nativeStart;
vars[i].m_high_pc = nativeEnd - nativeStart;
}
}
}
return S_OK;
}
MethodDebugInfo::MethodDebugInfo(int numPoints, int numLocals)
{
points = (SequencePointInfo*) CoTaskMemAlloc(sizeof(SequencePointInfo) * numPoints);
if (points == nullptr)
{
COMPlusThrowOM();
}
memset(points, 0, sizeof(SequencePointInfo) * numPoints);
size = numPoints;
if (numLocals == 0)
{
locals = nullptr;
localsSize = 0;
return;
}
locals = (LocalVarInfo*) CoTaskMemAlloc(sizeof(LocalVarInfo) * numLocals);
if (locals == nullptr)
{
CoTaskMemFree(points);
COMPlusThrowOM();
}
memset(locals, 0, sizeof(LocalVarInfo) * numLocals);
localsSize = numLocals;
}
MethodDebugInfo::~MethodDebugInfo()
{
if (locals)
{
for (int i = 0; i < localsSize; i++)
CoTaskMemFree(locals[i].name);
CoTaskMemFree(locals);
}
for (int i = 0; i < size; i++)
CoTaskMemFree(points[i].fileName);
CoTaskMemFree(points);
}
/* Get mapping of IL offsets to source line numbers */
HRESULT
GetDebugInfoFromPDB(MethodDesc* methodDescPtr,
NewArrayHolder<SymbolsInfo> &symInfo,
unsigned int &symInfoLen,
LocalsInfo &locals)
{
NewArrayHolder<DebuggerILToNativeMap> map;
ULONG32 numMap;
if (!getInfoForMethodDelegate)
return E_FAIL;
if (GetMethodNativeMap(methodDescPtr, &numMap, map, &locals.countVars, &locals.vars) != S_OK)
return E_FAIL;
const Module* mod = methodDescPtr->GetMethodTable()->GetModule();
SString modName = mod->GetFile()->GetPath();
if (modName.IsEmpty())
return E_FAIL;
StackScratchBuffer scratch;
const char* szModName = modName.GetUTF8(scratch);
MethodDebugInfo methodDebugInfo(numMap, locals.countVars);
if (getInfoForMethodDelegate(szModName, methodDescPtr->GetMemberDef(), methodDebugInfo) == FALSE)
return E_FAIL;
symInfoLen = numMap;
symInfo = new SymbolsInfo[numMap];
locals.size = methodDebugInfo.localsSize;
locals.localsName = new NewArrayHolder<char>[locals.size];
locals.localsScope = new LocalsInfo::Scope [locals.size];
for (ULONG32 i = 0; i < locals.size; i++)
{
size_t sizeRequired = WideCharToMultiByte(CP_UTF8, 0, methodDebugInfo.locals[i].name, -1, NULL, 0, NULL, NULL);
locals.localsName[i] = new char[sizeRequired];
int len = WideCharToMultiByte(
CP_UTF8, 0, methodDebugInfo.locals[i].name, -1, locals.localsName[i], sizeRequired, NULL, NULL);
locals.localsScope[i].ilStartOffset = methodDebugInfo.locals[i].startOffset;
locals.localsScope[i].ilEndOffset = methodDebugInfo.locals[i].endOffset;
}
for (ULONG32 j = 0; j < numMap; j++)
{
SymbolsInfo& s = symInfo[j];
if (j == 0) {
s.fileName[0] = 0;
s.lineNumber = 0;
s.fileIndex = 0;
} else {
s = symInfo[j - 1];
}
s.nativeOffset = map[j].nativeStartOffset;
s.ilOffset = map[j].ilOffset;
s.source = map[j].source;
s.lineNumber = 0;
for (ULONG32 i = 0; i < methodDebugInfo.size; i++)
{
const SequencePointInfo& sp = methodDebugInfo.points[i];
if (methodDebugInfo.points[i].ilOffset == map[j].ilOffset)
{
s.fileIndex = 0;
int len = WideCharToMultiByte(CP_UTF8, 0, sp.fileName, -1, s.fileName, sizeof(s.fileName), NULL, NULL);
s.fileName[len] = 0;
s.lineNumber = sp.lineNumber;
break;
}
}
}
return S_OK;
}
/* LEB128 for 32-bit unsigned integer */
int Leb128Encode(uint32_t num, char* buf, int size)
{
int i = 0;
do
{
uint8_t byte = num & 0x7F;
if (i >= size)
break;
num >>= 7;
if (num != 0)
byte |= 0x80;
buf[i++] = byte;
}
while (num != 0);
return i;
}
/* LEB128 for 32-bit signed integer */
int Leb128Encode(int32_t num, char* buf, int size)
{
int i = 0;
bool hasMore = true, isNegative = num < 0;
while (hasMore && i < size)
{
uint8_t byte = num & 0x7F;
num >>= 7;
if ((num == 0 && (byte & 0x40) == 0) || (num == -1 && (byte & 0x40) == 0x40))
hasMore = false;
else
byte |= 0x80;
buf[i++] = byte;
}
return i;
}
int GetFrameLocation(int nativeOffset, char* bufVarLoc)
{
char cnvBuf[16] = {0};
int len = Leb128Encode(static_cast<int32_t>(nativeOffset), cnvBuf, sizeof(cnvBuf));
bufVarLoc[0] = len + 1;
bufVarLoc[1] = DW_OP_fbreg;
for (int j = 0; j < len; j++)
{
bufVarLoc[j + 2] = cnvBuf[j];
}
return len + 2; // We add '2' because first 2 bytes contain length of expression and DW_OP_fbreg operation.
}
// GDB JIT interface
typedef enum
{
JIT_NOACTION = 0,
JIT_REGISTER_FN,
JIT_UNREGISTER_FN
} jit_actions_t;
struct jit_code_entry
{
struct jit_code_entry *next_entry;
struct jit_code_entry *prev_entry;
const char *symfile_addr;
UINT64 symfile_size;
};
struct jit_descriptor
{
UINT32 version;
/* This type should be jit_actions_t, but we use uint32_t
to be explicit about the bitwidth. */
UINT32 action_flag;
struct jit_code_entry *relevant_entry;
struct jit_code_entry *first_entry;
};
// GDB puts a breakpoint in this function.
// To prevent from inlining we add noinline attribute and inline assembler statement.
extern "C"
void __attribute__((noinline)) __jit_debug_register_code() { __asm__(""); };
/* Make sure to specify the version statically, because the
debugger may check the version before we can set it. */
struct jit_descriptor __jit_debug_descriptor = { 1, 0, 0, 0 };
static CrstStatic g_jitDescriptorCrst;
// END of GDB JIT interface
class DebugStringsCU
{
public:
DebugStringsCU(const char *module, const char *path)
: m_producerName("CoreCLR"),
m_moduleName(module),
m_moduleDir(path),
m_producerOffset(0),
m_moduleNameOffset(0),
m_moduleDirOffset(0)
{
}
int GetProducerOffset() const { return m_producerOffset; }
int GetModuleNameOffset() const { return m_moduleNameOffset; }
int GetModuleDirOffset() const { return m_moduleDirOffset; }
void DumpStrings(char *ptr, int &offset)
{
m_producerOffset = offset;
DumpString(m_producerName, ptr, offset);
m_moduleNameOffset = offset;
DumpString(m_moduleName, ptr, offset);
m_moduleDirOffset = offset;
DumpString(m_moduleDir, ptr, offset);
}
private:
const char* m_producerName;
const char* m_moduleName;
const char* m_moduleDir;
int m_producerOffset;
int m_moduleNameOffset;
int m_moduleDirOffset;
static void DumpString(const char *str, char *ptr, int &offset)
{
if (ptr != nullptr)
{
strcpy(ptr + offset, str);
}
offset += strlen(str) + 1;
}
};
/* Static data for .debug_abbrev */
const unsigned char AbbrevTable[] = {
1, DW_TAG_compile_unit, DW_CHILDREN_yes,
DW_AT_producer, DW_FORM_strp, DW_AT_language, DW_FORM_data2, DW_AT_name, DW_FORM_strp, DW_AT_comp_dir, DW_FORM_strp,
DW_AT_stmt_list, DW_FORM_sec_offset, 0, 0,
2, DW_TAG_base_type, DW_CHILDREN_no,
DW_AT_name, DW_FORM_strp, DW_AT_encoding, DW_FORM_data1, DW_AT_byte_size, DW_FORM_data1, 0, 0,
3, DW_TAG_typedef, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp,
DW_AT_type, DW_FORM_ref4, 0, 0,
4, DW_TAG_subprogram, DW_CHILDREN_yes,
DW_AT_name, DW_FORM_strp, DW_AT_linkage_name, DW_FORM_strp, DW_AT_decl_file, DW_FORM_data1, DW_AT_decl_line, DW_FORM_data1,
DW_AT_type, DW_FORM_ref4, DW_AT_external, DW_FORM_flag_present,
DW_AT_low_pc, DW_FORM_addr, DW_AT_high_pc, DW_FORM_size,
DW_AT_frame_base, DW_FORM_exprloc, 0, 0,
5, DW_TAG_variable, DW_CHILDREN_no,
DW_AT_name, DW_FORM_strp, DW_AT_decl_file, DW_FORM_data1, DW_AT_decl_line, DW_FORM_data1, DW_AT_type,
DW_FORM_ref4, DW_AT_location, DW_FORM_exprloc, 0, 0,
6, DW_TAG_formal_parameter, DW_CHILDREN_no,
DW_AT_name, DW_FORM_strp, DW_AT_decl_file, DW_FORM_data1, DW_AT_decl_line, DW_FORM_data1, DW_AT_type,
DW_FORM_ref4, DW_AT_location, DW_FORM_exprloc, 0, 0,
7, DW_TAG_class_type, DW_CHILDREN_yes,
DW_AT_name, DW_FORM_strp, DW_AT_byte_size, DW_FORM_data4, 0, 0,
8, DW_TAG_member, DW_CHILDREN_no,
DW_AT_name, DW_FORM_strp, DW_AT_type, DW_FORM_ref4, DW_AT_data_member_location, DW_FORM_data4, 0, 0,
9, DW_TAG_pointer_type, DW_CHILDREN_no,
DW_AT_type, DW_FORM_ref4, DW_AT_byte_size, DW_FORM_data1, 0, 0,
10, DW_TAG_array_type, DW_CHILDREN_yes,
DW_AT_type, DW_FORM_ref4, 0, 0,
11, DW_TAG_subrange_type, DW_CHILDREN_no,
DW_AT_upper_bound, DW_FORM_exprloc, 0, 0,
12, DW_TAG_subprogram, DW_CHILDREN_yes,
DW_AT_name, DW_FORM_strp, DW_AT_linkage_name, DW_FORM_strp, DW_AT_decl_file, DW_FORM_data1, DW_AT_decl_line, DW_FORM_data1,
DW_AT_type, DW_FORM_ref4, DW_AT_external, DW_FORM_flag_present,
DW_AT_low_pc, DW_FORM_addr, DW_AT_high_pc, DW_FORM_size,
DW_AT_frame_base, DW_FORM_exprloc, DW_AT_object_pointer, DW_FORM_ref4, 0, 0,
13, DW_TAG_formal_parameter, DW_CHILDREN_no,
DW_AT_name, DW_FORM_strp, DW_AT_decl_file, DW_FORM_data1, DW_AT_decl_line, DW_FORM_data1, DW_AT_type,
DW_FORM_ref4, DW_AT_location, DW_FORM_exprloc, DW_AT_artificial, DW_FORM_flag_present, 0, 0,
14, DW_TAG_member, DW_CHILDREN_no,
DW_AT_name, DW_FORM_strp, DW_AT_type, DW_FORM_ref4, DW_AT_external, DW_FORM_flag_present, 0, 0,
15, DW_TAG_variable, DW_CHILDREN_no, DW_AT_specification, DW_FORM_ref4, DW_AT_location, DW_FORM_exprloc,
0, 0,
16, DW_TAG_try_block, DW_CHILDREN_no,
DW_AT_low_pc, DW_FORM_addr, DW_AT_high_pc, DW_FORM_size,
0, 0,
17, DW_TAG_catch_block, DW_CHILDREN_no,
DW_AT_low_pc, DW_FORM_addr, DW_AT_high_pc, DW_FORM_size,
0, 0,
18, DW_TAG_inheritance, DW_CHILDREN_no, DW_AT_type, DW_FORM_ref4, DW_AT_data_member_location, DW_FORM_data1,
0, 0,
19, DW_TAG_subrange_type, DW_CHILDREN_no,
DW_AT_upper_bound, DW_FORM_udata, 0, 0,
20, DW_TAG_lexical_block, DW_CHILDREN_yes,
DW_AT_low_pc, DW_FORM_addr, DW_AT_high_pc, DW_FORM_size,
0, 0,
0
};
const int AbbrevTableSize = sizeof(AbbrevTable);
/* Static data for .debug_line, including header */
#define DWARF_LINE_BASE (-5)
#define DWARF_LINE_RANGE 14
#define DWARF_OPCODE_BASE 13
#ifdef FEATURE_GDBJIT_LANGID_CS
/* TODO: use corresponding constant when it will be added to llvm */
#define DW_LANG_MICROSOFT_CSHARP 0x9e57
#endif
DwarfLineNumHeader LineNumHeader = {
0, 2, 0, 1, 1, DWARF_LINE_BASE, DWARF_LINE_RANGE, DWARF_OPCODE_BASE, {0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1}
};
/* Static data for .debug_info */
struct __attribute__((packed)) DebugInfoCU
{
uint8_t m_cu_abbrev;
uint32_t m_prod_off;
uint16_t m_lang;
uint32_t m_cu_name;
uint32_t m_cu_dir;
uint32_t m_line_num;
} debugInfoCU = {
#ifdef FEATURE_GDBJIT_LANGID_CS
1, 0, DW_LANG_MICROSOFT_CSHARP, 0, 0
#else
1, 0, DW_LANG_C89, 0, 0
#endif
};
struct __attribute__((packed)) DebugInfoTryCatchSub
{
uint8_t m_sub_abbrev;
uintptr_t m_sub_low_pc, m_sub_high_pc;
};
struct __attribute__((packed)) DebugInfoSub
{
uint8_t m_sub_abbrev;
uint32_t m_sub_name;
uint32_t m_linkage_name;
uint8_t m_file, m_line;
uint32_t m_sub_type;
uintptr_t m_sub_low_pc, m_sub_high_pc;
uint8_t m_sub_loc[2];
};
struct __attribute__((packed)) DebugInfoSubMember
{
DebugInfoSub sub;
uint32_t m_obj_ptr;
};
struct __attribute__((packed)) DebugInfoLexicalBlock
{
uint8_t m_abbrev;
uintptr_t m_low_pc, m_high_pc;
};
// Holder for array of pointers to FunctionMember objects
class FunctionMemberPtrArrayHolder : public NewArrayHolder<NewHolder<FunctionMember>>
{
private:
int m_cElements;
public:
explicit FunctionMemberPtrArrayHolder(int cElements) :
NewArrayHolder<NewHolder<FunctionMember>>(new NewHolder<FunctionMember>[cElements]),
m_cElements(cElements)
{
}
int GetCount() const
{
return m_cElements;
}
};
struct __attribute__((packed)) DebugInfoType
{
uint8_t m_type_abbrev;
uint32_t m_type_name;
uint8_t m_encoding;
uint8_t m_byte_size;
};
struct __attribute__((packed)) DebugInfoVar
{
uint8_t m_var_abbrev;
uint32_t m_var_name;
uint8_t m_var_file, m_var_line;
uint32_t m_var_type;
};
struct __attribute__((packed)) DebugInfoTypeDef
{
uint8_t m_typedef_abbrev;
uint32_t m_typedef_name;
uint32_t m_typedef_type;
};
struct __attribute__((packed)) DebugInfoClassType
{
uint8_t m_type_abbrev;
uint32_t m_type_name;
uint32_t m_byte_size;
};
struct __attribute__((packed)) DebugInfoInheritance
{
uint8_t m_abbrev;
uint32_t m_type;
uint8_t m_data_member_location;
};
struct __attribute__((packed)) DebugInfoClassMember
{
uint8_t m_member_abbrev;
uint32_t m_member_name;
uint32_t m_member_type;
};
struct __attribute__((packed)) DebugInfoStaticMember
{
uint8_t m_member_abbrev;
uint32_t m_member_specification;
};
struct __attribute__((packed)) DebugInfoRefType
{
uint8_t m_type_abbrev;
uint32_t m_ref_type;
uint8_t m_byte_size;
};
struct __attribute__((packed)) DebugInfoArrayType
{
uint8_t m_abbrev;
uint32_t m_type;
};
void TypeInfoBase::DumpStrings(char* ptr, int& offset)
{
if (ptr != nullptr)
{
strcpy(ptr + offset, m_type_name);
m_type_name_offset = offset;
}
offset += strlen(m_type_name) + 1;
}
void TypeInfoBase::CalculateName()
{
// name the type
SString sName;
const TypeString::FormatFlags formatFlags = static_cast<TypeString::FormatFlags>(
TypeString::FormatNamespace |
TypeString::FormatAngleBrackets);
TypeString::AppendType(sName, typeHandle, formatFlags);
StackScratchBuffer buffer;
const UTF8 *utf8 = sName.GetUTF8(buffer);
if (typeHandle.IsValueType())
{
m_type_name = new char[strlen(utf8) + 1];
strcpy(m_type_name, utf8);
}
else
{
m_type_name = new char[strlen(utf8) + 1 + 2];
strcpy(m_type_name, "__");
strcpy(m_type_name + 2, utf8);
}
// Fix nested names
for (char *p = m_type_name; *p; ++p)
{
if (*p == '+')
*p = '.';
}
}
void TypeInfoBase::SetTypeHandle(TypeHandle handle)
{
typeHandle = handle;
typeKey = handle.GetTypeKey();
}
TypeHandle TypeInfoBase::GetTypeHandle()
{
return typeHandle;
}
TypeKey* TypeInfoBase::GetTypeKey()
{
return &typeKey;
}
void TypeDefInfo::DumpStrings(char *ptr, int &offset)
{
if (ptr != nullptr)
{
strcpy(ptr + offset, m_typedef_name);
m_typedef_name_offset = offset;
}
offset += strlen(m_typedef_name) + 1;
}
void TypeDefInfo::DumpDebugInfo(char *ptr, int &offset)
{
if (m_is_visited && m_base_ptr == ptr)
{
return;
}
m_base_ptr = ptr;
m_is_visited = true;
if (ptr != nullptr)
{
DebugInfoTypeDef buf;
buf.m_typedef_abbrev = 3;
buf.m_typedef_name = m_typedef_name_offset;
buf.m_typedef_type = offset + sizeof(DebugInfoTypeDef);
m_typedef_type_offset = offset;
memcpy(ptr + offset,
&buf,
sizeof(DebugInfoTypeDef));
}
offset += sizeof(DebugInfoTypeDef);
}
static const char *GetCSharpTypeName(TypeInfoBase *typeInfo)
{
switch(typeInfo->GetTypeHandle().GetSignatureCorElementType())
{
case ELEMENT_TYPE_I1: return "sbyte";
case ELEMENT_TYPE_U1: return "byte";
case ELEMENT_TYPE_CHAR: return "char";
case ELEMENT_TYPE_VOID: return "void";
case ELEMENT_TYPE_BOOLEAN: return "bool";
case ELEMENT_TYPE_I2: return "short";
case ELEMENT_TYPE_U2: return "ushort";
case ELEMENT_TYPE_I4: return "int";
case ELEMENT_TYPE_U4: return "uint";
case ELEMENT_TYPE_I8: return "long";
case ELEMENT_TYPE_U8: return "ulong";
case ELEMENT_TYPE_R4: return "float";
case ELEMENT_TYPE_R8: return "double";
default: return typeInfo->m_type_name;
}
}
PrimitiveTypeInfo::PrimitiveTypeInfo(TypeHandle typeHandle)
: TypeInfoBase(typeHandle),
m_typedef_info(new TypeDefInfo(nullptr, 0))
{
CorElementType corType = typeHandle.GetSignatureCorElementType();
m_type_encoding = CorElementTypeToDWEncoding[corType];
m_type_size = CorTypeInfo::Size(corType);
if (corType == ELEMENT_TYPE_CHAR)
{
m_type_name = new char[9];
strcpy(m_type_name, "WCHAR");
}
else
{
CalculateName();
}
}
void PrimitiveTypeInfo::DumpStrings(char* ptr, int& offset)
{
TypeInfoBase::DumpStrings(ptr, offset);
if (!m_typedef_info->m_typedef_name)
{
const char *typeName = GetCSharpTypeName(this);
m_typedef_info->m_typedef_name = new char[strlen(typeName) + 1];
strcpy(m_typedef_info->m_typedef_name, typeName);
}
m_typedef_info->DumpStrings(ptr, offset);
}
void PrimitiveTypeInfo::DumpDebugInfo(char *ptr, int &offset)
{
if (m_is_visited && m_base_ptr == ptr)
{
return;
}
m_base_ptr = ptr;
m_is_visited = true;
m_typedef_info->DumpDebugInfo(ptr, offset);
if (ptr != nullptr)
{
DebugInfoType bufType;
bufType.m_type_abbrev = 2;
bufType.m_type_name = m_type_name_offset;
bufType.m_encoding = m_type_encoding;
bufType.m_byte_size = m_type_size;
memcpy(ptr + offset,
&bufType,
sizeof(DebugInfoType));
// Replace offset from real type to typedef
m_type_offset = m_typedef_info->m_typedef_type_offset;
}
offset += sizeof(DebugInfoType);
}
ClassTypeInfo::ClassTypeInfo(TypeHandle typeHandle, int num_members, FunctionMemberPtrArrayHolder &method)
: TypeInfoBase(typeHandle),
m_num_members(num_members),
members(new TypeMember[num_members]),
m_parent(nullptr),
m_method(method),
m_array_type(nullptr)
{
CorElementType corType = typeHandle.GetSignatureCorElementType();
PTR_MethodTable pMT = typeHandle.GetMethodTable();
switch (corType)
{
case ELEMENT_TYPE_VALUETYPE:
case ELEMENT_TYPE_CLASS:
m_type_size = pMT->IsValueType() ? typeHandle.GetSize() : typeHandle.AsMethodTable()->GetBaseSize();
break;
case ELEMENT_TYPE_ARRAY:
case ELEMENT_TYPE_SZARRAY:
m_type_size = typeHandle.AsMethodTable()->GetBaseSize();
break;
default:
m_type_size = 0;
}
CalculateName();
}
void TypeMember::DumpStrings(char* ptr, int& offset)
{
if (ptr != nullptr)
{
strcpy(ptr + offset, m_member_name);
m_member_name_offset = offset;
}
offset += strlen(m_member_name) + 1;
}
void TypeMember::DumpDebugInfo(char* ptr, int& offset)
{
if (ptr != nullptr)
{
DebugInfoClassMember memberEntry;
if (m_static_member_address == 0)
memberEntry.m_member_abbrev = 8;
else
{
memberEntry.m_member_abbrev = 14;
m_member_offset = offset;
}
memberEntry.m_member_name = m_member_name_offset;
memberEntry.m_member_type = m_member_type->m_type_offset;
memcpy(ptr + offset, &memberEntry, sizeof(DebugInfoClassMember));
if (m_static_member_address == 0)
memcpy(ptr + offset + sizeof(DebugInfoClassMember), &m_member_offset, sizeof(m_member_offset));
}
offset += sizeof(DebugInfoClassMember);
if (m_static_member_address == 0)
offset += sizeof(m_member_offset);
}
void TypeMember::DumpStaticDebugInfo(char* ptr, int& offset)
{
const int ptrSize = sizeof(TADDR);
const int valueTypeBufSize = ptrSize + 6;
const int refTypeBufSize = ptrSize + 2;
bool isValueType = m_member_type->GetTypeHandle().GetSignatureCorElementType() ==
ELEMENT_TYPE_VALUETYPE;
int bufSize;
if (isValueType)
{
bufSize = valueTypeBufSize;
}
else
{
bufSize = refTypeBufSize;
}
if (ptr != nullptr)
{
DebugInfoStaticMember memberEntry;
memberEntry.m_member_abbrev = 15;
memberEntry.m_member_specification = m_member_offset;
memcpy(ptr + offset, &memberEntry, sizeof(DebugInfoStaticMember));
// for value type static fields compute address as:
// addr = (*addr+sizeof(OBJECTREF))
if (isValueType)
{
char buf[valueTypeBufSize] = {0};
buf[0] = ptrSize + 5;
buf[1] = DW_OP_addr;
for (int i = 0; i < ptrSize; i++)
{
buf[i + 2] = m_static_member_address >> (i * 8);
}
buf[ptrSize + 2] = DW_OP_deref;
buf[ptrSize + 3] = DW_OP_const1u;
buf[ptrSize + 4] = sizeof(OBJECTREF);
buf[ptrSize + 5] = DW_OP_plus;
memcpy(ptr + offset + sizeof(DebugInfoStaticMember), &buf, bufSize);
}
else
{
char buf[refTypeBufSize] = {0};
buf[0] = ptrSize + 1;
buf[1] = DW_OP_addr;
for (int i = 0; i < ptrSize; i++)
{
buf[i + 2] = m_static_member_address >> (i * 8);
}
memcpy(ptr + offset + sizeof(DebugInfoStaticMember), &buf, bufSize);
}
}
offset += sizeof(DebugInfoStaticMember);
offset += bufSize;
}
void FunctionMember::MangleName(char *buf, int &buf_offset, const char *name)
{
int name_length = strlen(name);
char tmp[20];
int tmp_len = sprintf_s(tmp, _countof(tmp), "%i", name_length);
if (tmp_len <= 0)
return;
if (buf)
strncpy(buf + buf_offset, tmp, tmp_len);
buf_offset += tmp_len;
if (buf)
{
for (int i = 0; i < name_length; i++)
{
char c = name[i];
bool valid = (c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
(c >= '0' && c <= '9');
*(buf + buf_offset + i) = valid ? c : '_';
}
}
buf_offset += name_length;
}
void FunctionMember::DumpMangledNamespaceAndMethod(char *buf, int &offset, const char *nspace, const char *mname)
{
static const char *begin_mangled = "_ZN";
static const char *end_mangled = "Ev";
static const int begin_mangled_len = strlen(begin_mangled);
static const int end_mangled_len = strlen(end_mangled);
if (buf)
strncpy(buf + offset, begin_mangled, begin_mangled_len);
offset += begin_mangled_len;
MangleName(buf, offset, nspace);
MangleName(buf, offset, mname);
if (buf)
strncpy(buf + offset, end_mangled, end_mangled_len);
offset += end_mangled_len;
if (buf)
buf[offset] = '\0';
++offset;
}
void FunctionMember::DumpLinkageName(char* ptr, int& offset)
{
SString namespaceOrClassName;
SString methodName;
md->GetMethodInfoNoSig(namespaceOrClassName, methodName);
SString utf8namespaceOrClassName;
SString utf8methodName;
namespaceOrClassName.ConvertToUTF8(utf8namespaceOrClassName);
methodName.ConvertToUTF8(utf8methodName);
const char *nspace = utf8namespaceOrClassName.GetUTF8NoConvert();
const char *mname = utf8methodName.GetUTF8NoConvert();
if (!nspace || !mname)
{
m_linkage_name_offset = 0;
return;
}
m_linkage_name_offset = offset;
DumpMangledNamespaceAndMethod(ptr, offset, nspace, mname);
}
void FunctionMember::DumpStrings(char* ptr, int& offset)
{
TypeMember::DumpStrings(ptr, offset);
for (int i = 0; i < m_num_vars; ++i)
{
vars[i].DumpStrings(ptr, offset);
}
DumpLinkageName(ptr, offset);
}
bool FunctionMember::GetBlockInNativeCode(int blockILOffset, int blockILLen, TADDR *startOffset, TADDR *endOffset)
{
PCODE pCode = md->GetNativeCode();
const int blockILEnd = blockILOffset + blockILLen;
*startOffset = 0;
*endOffset = 0;
bool inBlock = false;
for (int i = 0; i < nlines; ++i)
{
TADDR nativeOffset = lines[i].nativeOffset + pCode;
// Limit block search to current function addresses
if (nativeOffset < m_sub_low_pc)
continue;
if (nativeOffset >= m_sub_low_pc + m_sub_high_pc)
break;
// Skip invalid IL offsets
switch(lines[i].ilOffset)
{
case ICorDebugInfo::PROLOG:
case ICorDebugInfo::EPILOG:
case ICorDebugInfo::NO_MAPPING:
continue;
default:
break;
}
// Check if current IL is within block
if (blockILOffset <= lines[i].ilOffset && lines[i].ilOffset < blockILEnd)
{
if (!inBlock)
{
*startOffset = lines[i].nativeOffset;
inBlock = true;
}
}
else
{
if (inBlock)
{
*endOffset = lines[i].nativeOffset;
inBlock = false;
break;
}
}
}
if (inBlock)
{
*endOffset = m_sub_low_pc + m_sub_high_pc - pCode;
}
return *endOffset != *startOffset;
}
void FunctionMember::DumpTryCatchBlock(char* ptr, int& offset, int ilOffset, int ilLen, int abbrev)
{
TADDR startOffset;
TADDR endOffset;
if (!GetBlockInNativeCode(ilOffset, ilLen, &startOffset, &endOffset))
return;
if (ptr != nullptr)
{
DebugInfoTryCatchSub subEntry;
subEntry.m_sub_abbrev = abbrev;
subEntry.m_sub_low_pc = md->GetNativeCode() + startOffset;
subEntry.m_sub_high_pc = endOffset - startOffset;
memcpy(ptr + offset, &subEntry, sizeof(DebugInfoTryCatchSub));
}
offset += sizeof(DebugInfoTryCatchSub);
}
void FunctionMember::DumpTryCatchDebugInfo(char* ptr, int& offset)
{
if (!md)
return;
COR_ILMETHOD *pHeader = md->GetILHeader();
COR_ILMETHOD_DECODER header(pHeader);
unsigned ehCount = header.EHCount();
for (unsigned e = 0; e < ehCount; e++)
{
IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT ehBuff;
const IMAGE_COR_ILMETHOD_SECT_EH_CLAUSE_FAT* ehInfo;
ehInfo = header.EH->EHClause(e, &ehBuff);
DumpTryCatchBlock(ptr, offset, ehInfo->TryOffset, ehInfo->TryLength, 16);
DumpTryCatchBlock(ptr, offset, ehInfo->HandlerOffset, ehInfo->HandlerLength, 17);
}
}
void FunctionMember::DumpVarsWithScopes(char *ptr, int &offset)
{
NewArrayHolder<DebugInfoLexicalBlock> scopeStack = new DebugInfoLexicalBlock[m_num_vars];
int scopeStackSize = 0;
for (int i = 0; i < m_num_vars; ++i)
{
if (vars[i].m_high_pc == 0) // no scope info
{
vars[i].DumpDebugInfo(ptr, offset);
continue;
}
// Try to step out to enclosing scope, finilizing scopes on the way
while (scopeStackSize > 0 &&
vars[i].m_low_pc >= (scopeStack[scopeStackSize - 1].m_low_pc +
scopeStack[scopeStackSize - 1].m_high_pc))
{
// Finalize scope
if (ptr != nullptr)
{
memset(ptr + offset, 0, 1);
}
offset += 1;
scopeStackSize--;
}
// Continue adding to prev scope?
if (scopeStackSize > 0 &&
scopeStack[scopeStackSize - 1].m_low_pc == vars[i].m_low_pc &&
scopeStack[scopeStackSize - 1].m_high_pc == vars[i].m_high_pc)
{
vars[i].DumpDebugInfo(ptr, offset);
continue;
}
// Start new scope
scopeStackSize++;
scopeStack[scopeStackSize - 1].m_abbrev = 20;
scopeStack[scopeStackSize - 1].m_low_pc = vars[i].m_low_pc;
scopeStack[scopeStackSize - 1].m_high_pc = vars[i].m_high_pc;
if (ptr != nullptr)
{
memcpy(ptr + offset, scopeStack + (scopeStackSize - 1), sizeof(DebugInfoLexicalBlock));
}
offset += sizeof(DebugInfoLexicalBlock);
vars[i].DumpDebugInfo(ptr, offset);
}
// Finalize any remaining scopes
while (scopeStackSize > 0)
{
if (ptr != nullptr)
{
memset(ptr + offset, 0, 1);
}
offset += 1;
scopeStackSize--;
}
}
void FunctionMember::DumpDebugInfo(char* ptr, int& offset)
{
if (ptr != nullptr)
{
DebugInfoSub subEntry;
subEntry.m_sub_abbrev = 4;
subEntry.m_sub_name = m_member_name_offset;
subEntry.m_linkage_name = m_linkage_name_offset;
subEntry.m_file = m_file;
subEntry.m_line = m_line;
subEntry.m_sub_type = m_member_type->m_type_offset;
subEntry.m_sub_low_pc = m_sub_low_pc;
subEntry.m_sub_high_pc = m_sub_high_pc;
subEntry.m_sub_loc[0] = m_sub_loc[0];
subEntry.m_sub_loc[1] = m_sub_loc[1];
if (!md->IsStatic())
{
DebugInfoSubMember subMemberEntry;
subEntry.m_sub_abbrev = 12;
subMemberEntry.sub = subEntry;
subMemberEntry.m_obj_ptr = offset+sizeof(DebugInfoSubMember);
memcpy(ptr + offset, &subMemberEntry, sizeof(DebugInfoSubMember));
}
else
{
memcpy(ptr + offset, &subEntry, sizeof(DebugInfoSub));
}
m_entry_offset = offset;
dumped = true;
}
if (!md->IsStatic())
{
offset += sizeof(DebugInfoSubMember);
}
else
{
offset += sizeof(DebugInfoSub);
}
DumpVarsWithScopes(ptr, offset);
DumpTryCatchDebugInfo(ptr, offset);
// terminate children
if (ptr != nullptr)
{
ptr[offset] = 0;
}
offset++;
}
int FunctionMember::GetArgsAndLocalsLen()
{
int locSize = 0;
char tmpBuf[16];
// Format for DWARF location expression: [expression length][operation][offset in SLEB128 encoding]
for (int i = 0; i < m_num_vars; i++)
{
locSize += 2; // First byte contains expression length, second byte contains operation (DW_OP_fbreg).
locSize += Leb128Encode(static_cast<int32_t>(vars[i].m_native_offset), tmpBuf, sizeof(tmpBuf));
}
return locSize;
}
void ClassTypeInfo::DumpStrings(char* ptr, int& offset)
{
TypeInfoBase::DumpStrings(ptr, offset);
for (int i = 0; i < m_num_members; ++i)
{
members[i].DumpStrings(ptr, offset);
}
if (m_parent != nullptr)
{
m_parent->DumpStrings(ptr, offset);
}
}
void RefTypeInfo::DumpStrings(char* ptr, int& offset)
{
TypeInfoBase::DumpStrings(ptr, offset);
m_value_type->DumpStrings(ptr, offset);
}
void RefTypeInfo::DumpDebugInfo(char* ptr, int& offset)
{
if (m_is_visited && m_base_ptr == ptr)
{
return;
}
m_base_ptr = ptr;
m_is_visited = true;
m_type_offset = offset;
offset += sizeof(DebugInfoRefType);
m_value_type->DumpDebugInfo(ptr, offset);
if (ptr != nullptr)
{
DebugInfoRefType refType;
refType.m_type_abbrev = 9;
refType.m_ref_type = m_value_type->m_type_offset;
refType.m_byte_size = m_type_size;
memcpy(ptr + m_type_offset, &refType, sizeof(DebugInfoRefType));
}
else
{
m_type_offset = 0;
}
}
void NamedRefTypeInfo::DumpDebugInfo(char* ptr, int& offset)
{
if (m_is_visited && m_base_ptr == ptr)
{
return;
}
m_base_ptr = ptr;
m_is_visited = true;
m_type_offset = offset;
offset += sizeof(DebugInfoRefType) + sizeof(DebugInfoTypeDef);
m_value_type->DumpDebugInfo(ptr, offset);
if (ptr != nullptr)
{
DebugInfoRefType refType;
refType.m_type_abbrev = 9;
refType.m_ref_type = m_value_type->m_type_offset;
refType.m_byte_size = m_type_size;
memcpy(ptr + m_type_offset, &refType, sizeof(DebugInfoRefType));
DebugInfoTypeDef bugTypeDef;
bugTypeDef.m_typedef_abbrev = 3;
bugTypeDef.m_typedef_name = m_value_type->m_type_name_offset + 2;
bugTypeDef.m_typedef_type = m_type_offset;
memcpy(ptr + m_type_offset + sizeof(DebugInfoRefType), &bugTypeDef, sizeof(DebugInfoTypeDef));
m_type_offset += sizeof(DebugInfoRefType);
}
else
{
m_type_offset = 0;
}
}
void ClassTypeInfo::DumpDebugInfo(char* ptr, int& offset)
{
if (m_is_visited && m_base_ptr == ptr)
{
return;
}
m_base_ptr = ptr;
m_is_visited = true;
if (m_parent != nullptr)
{
m_parent->DumpDebugInfo(ptr, offset);
}
// make sure that types of all members are dumped
for (int i = 0; i < m_num_members; ++i)
{
if (members[i].m_member_type != this)
{
members[i].m_member_type->DumpDebugInfo(ptr, offset);
}
}
if (ptr != nullptr)
{
DebugInfoClassType bufType;
bufType.m_type_abbrev = 7;
bufType.m_type_name = m_type_name_offset;
bufType.m_byte_size = m_type_size;
memcpy(ptr + offset, &bufType, sizeof(DebugInfoClassType));
m_type_offset = offset;
}
offset += sizeof(DebugInfoClassType);
for (int i = 0; i < m_num_members; ++i)
{
members[i].DumpDebugInfo(ptr, offset);
}
for (int i = 0; i < m_method.GetCount(); ++i)
{
if (m_method[i]->md->GetMethodTable() == GetTypeHandle().GetMethodTable())
{
// our method is part of this class, we should dump it now before terminating members
m_method[i]->DumpDebugInfo(ptr, offset);
}
}
if (m_parent != nullptr)
{
if (ptr != nullptr)
{
DebugInfoInheritance buf;
buf.m_abbrev = 18;
if (RefTypeInfo *m_p = dynamic_cast<RefTypeInfo*>(m_parent))
buf.m_type = m_p->m_value_type->m_type_offset;
else
buf.m_type = m_parent->m_type_offset;
buf.m_data_member_location = 0;
memcpy(ptr + offset, &buf, sizeof(DebugInfoInheritance));
}
offset += sizeof(DebugInfoInheritance);
}
// members terminator
if (ptr != nullptr)
{
ptr[offset] = 0;
}
offset++;
for (int i = 0; i < m_num_members; ++i)
{
if (members[i].m_static_member_address != 0)
members[i].DumpStaticDebugInfo(ptr, offset);
}
}
void ArrayTypeInfo::DumpDebugInfo(char* ptr, int& offset)
{
if (m_is_visited && m_base_ptr == ptr)
{
return;
}
m_base_ptr = ptr;
m_is_visited = true;
m_elem_type->DumpDebugInfo(ptr, offset);
if (ptr != nullptr)
{
DebugInfoArrayType arrType;
arrType.m_abbrev = 10; // DW_TAG_array_type abbrev
arrType.m_type = m_elem_type->m_type_offset;
memcpy(ptr + offset, &arrType, sizeof(DebugInfoArrayType));
m_type_offset = offset;
}
offset += sizeof(DebugInfoArrayType);
char tmp[16] = { 0 };
int len = Leb128Encode(static_cast<uint32_t>(m_count - 1), tmp + 1, sizeof(tmp) - 1);
if (ptr != nullptr)
{
tmp[0] = 19; // DW_TAG_subrange_type abbrev with const upper bound
memcpy(ptr + offset, tmp, len + 1);
}
offset += len + 1;
if (ptr != nullptr)
{
memset(ptr + offset, 0, 1);
}
offset += 1;
}
void VarDebugInfo::DumpStrings(char *ptr, int& offset)
{
if (ptr != nullptr)
{
strcpy(ptr + offset, m_var_name);
m_var_name_offset = offset;
}
offset += strlen(m_var_name) + 1;
}
void VarDebugInfo::DumpDebugInfo(char* ptr, int& offset)
{
char bufVarLoc[16];
int len = GetFrameLocation(m_native_offset, bufVarLoc);
if (ptr != nullptr)
{
DebugInfoVar bufVar;
bufVar.m_var_abbrev = m_var_abbrev;
bufVar.m_var_name = m_var_name_offset;
bufVar.m_var_file = 1;
bufVar.m_var_line = 1;
bufVar.m_var_type = m_var_type->m_type_offset;
memcpy(ptr + offset, &bufVar, sizeof(DebugInfoVar));
memcpy(ptr + offset + sizeof(DebugInfoVar), bufVarLoc, len);
}
offset += sizeof(DebugInfoVar);
offset += len;
}
/* static data for symbol strings */
struct Elf_Symbol {
const char* m_name;
int m_off;
TADDR m_value;
int m_section, m_size;
NewArrayHolder<char> m_symbol_name;
Elf_Symbol() : m_name(nullptr), m_off(0), m_value(0), m_section(0), m_size(0) {}
};
template <class T>
static int countFuncs(T &arr, int n)
{
int count = 0;
for (int i = 0; i < n; i++) {
if (arr[i].ilOffset == ICorDebugInfo::PROLOG)
{
count++;
}
}
return count;
}
template <class T>
static int getNextPrologueIndex(int from, T &arr, int n)
{
for (int i = from; i < n; ++i) {
if (arr[i].ilOffset == ICorDebugInfo::PROLOG)
{
return i;
}
}
return -1;
}
static NewArrayHolder<WCHAR> g_wszModuleNames;
static DWORD g_cBytesNeeded;
static inline bool isListedModule(const WCHAR *wszModuleFile)
{
if (g_wszModuleNames == nullptr)
{
return false;
}
_ASSERTE(g_cBytesNeeded > 0);
BOOL isUserDebug = FALSE;
NewArrayHolder<WCHAR> wszModuleName = new WCHAR[g_cBytesNeeded];
LPWSTR pComma = wcsstr(g_wszModuleNames, W(","));
LPWSTR tmp = g_wszModuleNames;
while (pComma != NULL)
{
wcsncpy(wszModuleName, tmp, pComma - tmp);
wszModuleName[pComma - tmp] = W('\0');
if (wcscmp(wszModuleName, wszModuleFile) == 0)
{
isUserDebug = TRUE;
break;
}
tmp = pComma + 1;
pComma = wcsstr(tmp, W(","));
}
if (isUserDebug == FALSE)
{
wcsncpy(wszModuleName, tmp, wcslen(tmp));
wszModuleName[wcslen(tmp)] = W('\0');
if (wcscmp(wszModuleName, wszModuleFile) == 0)
{
isUserDebug = TRUE;
}
}
return isUserDebug;
}
static NotifyGdb::AddrSet g_codeAddrs;
static CrstStatic g_codeAddrsCrst;
class Elf_SectionTracker
{
private:
unsigned int m_Flag;
private:
NewArrayHolder<char> m_NamePtr;
unsigned int m_NameLen;
private:
unsigned int m_Ind;
unsigned int m_Off;
unsigned int m_Len;
private:
Elf_Shdr m_Hdr;
private:
Elf_SectionTracker *m_Next;
public:
Elf_SectionTracker(const char *name, unsigned ind, unsigned off, uint32_t type, uint64_t flags);
~Elf_SectionTracker();
public:
bool NeedHeaderUpdate() const;
void DisableHeaderUpdate();
public:
unsigned int GetIndex() const { return m_Ind; }
unsigned int GetOffset() const { return m_Off; }
unsigned int GetSize() const { return m_Len; }
public:
const char *GetName() const { return m_NamePtr; }
unsigned int GetNameLen() const { return m_NameLen; }
public:
Elf_SectionTracker *GetNext(void);
void SetNext(Elf_SectionTracker *next);
public:
void Forward(unsigned int len);
public:
Elf_Shdr *Header(void);
const Elf_Shdr *Header(void) const;
};
Elf_SectionTracker::Elf_SectionTracker(const char *name,
unsigned ind, unsigned off,
uint32_t type, uint64_t flags)
: m_Flag(0),
m_NamePtr(nullptr),
m_NameLen(0),
m_Ind(ind),
m_Off(off),
m_Len(0),
m_Next(nullptr)
{
if (name)
{
unsigned int len = strlen(name);
char *ptr = new char[len + 1];
strncpy(ptr, name, len + 1);
m_NamePtr = ptr;
m_NameLen = len;
}
m_Hdr.sh_type = type;
m_Hdr.sh_flags = flags;
m_Hdr.sh_name = 0;
m_Hdr.sh_addr = 0;
m_Hdr.sh_offset = 0;
m_Hdr.sh_size = 0;
m_Hdr.sh_link = SHN_UNDEF;
m_Hdr.sh_info = 0;
m_Hdr.sh_addralign = 1;
m_Hdr.sh_entsize = 0;
}
Elf_SectionTracker::~Elf_SectionTracker()
{
}
#define ESTF_NO_HEADER_UPDATE 0x00000001
bool Elf_SectionTracker::NeedHeaderUpdate() const
{
return !(m_Flag & ESTF_NO_HEADER_UPDATE);
}
void Elf_SectionTracker::DisableHeaderUpdate()
{
m_Flag |= ESTF_NO_HEADER_UPDATE;
}
void Elf_SectionTracker::Forward(unsigned int len)
{
m_Len += len;
}
void Elf_SectionTracker::SetNext(Elf_SectionTracker *next)
{
m_Next = next;
}
Elf_SectionTracker *Elf_SectionTracker::GetNext(void)
{
return m_Next;
}
Elf_Shdr *Elf_SectionTracker::Header(void)
{
return &m_Hdr;
}
const Elf_Shdr *Elf_SectionTracker::Header(void) const
{
return &m_Hdr;
}
class Elf_Buffer
{
private:
NewArrayHolder<char> m_Ptr;
unsigned int m_Len;
unsigned int m_Pos;
public:
Elf_Buffer(unsigned int len);
private:
char *Ensure(unsigned int len);
void Forward(unsigned int len);
public:
unsigned int GetPos() const
{
return m_Pos;
}
char *GetPtr(unsigned int off = 0)
{
return m_Ptr.GetValue() + off;
}
public:
char *Reserve(unsigned int len);
template <typename T> T *ReserveT(unsigned int len = sizeof(T))
{
_ASSERTE(len >= sizeof(T));
return reinterpret_cast<T *>(Reserve(len));
}
public:
void Append(const char *src, unsigned int len);
template <typename T> void AppendT(T *src)
{
Append(reinterpret_cast<const char *>(src), sizeof(T));
}
};
Elf_Buffer::Elf_Buffer(unsigned int len)
: m_Ptr(new char[len])
, m_Len(len)
, m_Pos(0)
{
}
char *Elf_Buffer::Ensure(unsigned int len)
{
bool bAdjusted = false;
while (m_Pos + len > m_Len)
{
m_Len *= 2;
bAdjusted = true;
}
if (bAdjusted)
{
char *ptr = new char [m_Len * 2];
memcpy(ptr, m_Ptr.GetValue(), m_Pos);
m_Ptr = ptr;
}
return GetPtr(m_Pos);
}
void Elf_Buffer::Forward(unsigned int len)
{
m_Pos += len;
}
char *Elf_Buffer::Reserve(unsigned int len)
{
char *ptr = Ensure(len);
Forward(len);
return ptr;
}
void Elf_Buffer::Append(const char *src, unsigned int len)
{
char *dst = Reserve(len);
memcpy(dst, src, len);
}
#define ELF_BUILDER_TEXT_SECTION_INDEX 1
class Elf_Builder
{
private:
Elf_Buffer m_Buffer;
private:
unsigned int m_SectionCount;
Elf_SectionTracker *m_First;
Elf_SectionTracker *m_Last;
Elf_SectionTracker *m_Curr;
public:
Elf_Builder();
~Elf_Builder();
public:
unsigned int GetSectionCount(void) { return m_SectionCount; }
public:
void Initialize(PCODE codePtr, TADDR codeLen);
public:
Elf_SectionTracker *OpenSection(const char *name, uint32_t type, uint64_t flags);
void CloseSection();
public:
char *Reserve(unsigned int len);
template <typename T> T *ReserveT(unsigned int len = sizeof(T))
{
_ASSERTE(len >= sizeof(T));
return reinterpret_cast<T *>(Reserve(len));
}
public:
void Append(const char *src, unsigned int len);
template <typename T> void AppendT(T *src)
{
Append(reinterpret_cast<const char *>(src), sizeof(T));
}
public:
void Finalize(void);
public:
char *Export(size_t *len);
};
Elf_Builder::Elf_Builder()
: m_Buffer(128),
m_SectionCount(0),
m_First(nullptr),
m_Last(nullptr),
m_Curr(nullptr)
{
}
Elf_Builder::~Elf_Builder()
{
Elf_SectionTracker *curr = m_First;
while (curr)
{
Elf_SectionTracker *next = curr->GetNext();
delete curr;
curr = next;
}
}
void Elf_Builder::Initialize(PCODE codePtr, TADDR codeLen)
{
//
// Reserve ELF Header
//
m_Buffer.Reserve(sizeof(Elf_Ehdr));
//
// Create NULL section
//
Elf_SectionTracker *null = OpenSection("", SHT_NULL, 0);
{
null->DisableHeaderUpdate();
null->Header()->sh_addralign = 0;
}
CloseSection();
//
// Create '.text' section
//
Elf_SectionTracker *text = OpenSection(".text", SHT_PROGBITS, SHF_ALLOC | SHF_EXECINSTR);
{
text->DisableHeaderUpdate();
text->Header()->sh_addr = codePtr;
text->Header()->sh_size = codeLen;
_ASSERTE(text->GetIndex() == ELF_BUILDER_TEXT_SECTION_INDEX);
}
CloseSection();
}
char *Elf_Builder::Reserve(unsigned int len)
{
_ASSERTE(m_Curr != nullptr && "Section should be opened before");
char *ptr = m_Buffer.Reserve(len);
m_Curr->Forward(len);
return ptr;
}
void Elf_Builder::Append(const char *src, unsigned int len)
{
_ASSERTE(m_Curr != nullptr && "Section should be opened before");
char *dst = Reserve(len);
memcpy(dst, src, len);
}
Elf_SectionTracker *Elf_Builder::OpenSection(const char *name, uint32_t type, uint64_t flags)
{
_ASSERTE(m_Curr == nullptr && "Section should be closed before");
Elf_SectionTracker *next = new Elf_SectionTracker(name, m_SectionCount, m_Buffer.GetPos(), type, flags);
if (m_First == NULL)
{
m_First = next;
}
if (m_Last != NULL)
{
m_Last->SetNext(next);
}
m_SectionCount++;
m_Last = next;
m_Curr = next;
return next;
}
void Elf_Builder::CloseSection()
{
_ASSERTE(m_Curr != nullptr && "Section should be opened before");
m_Curr = nullptr;
}
char *Elf_Builder::Export(size_t *pLen)
{
unsigned int len = m_Buffer.GetPos();
const char *src = m_Buffer.GetPtr();
char *dst = new char[len];
memcpy(dst, src, len);
if (pLen)
{
*pLen = len;
}
return dst;
}
void Elf_Builder::Finalize()
{
//
// Create '.shstrtab'
//
Elf_SectionTracker *shstrtab = OpenSection(".shstrtab", SHT_STRTAB, 0);
{
Elf_SectionTracker *curr = m_First;
while (curr)
{
unsigned int off = shstrtab->GetSize();
unsigned int len = curr->GetNameLen();
char *dst = Reserve(len + 1);
memcpy(dst, curr->GetName(), len);
dst[len] = '\0';
curr->Header()->sh_name = off;
curr = curr->GetNext();
}
}
CloseSection();
//
// Create Section Header(s) Table
//
unsigned int shtOffset = m_Buffer.GetPos();
{
Elf_SectionTracker *curr = m_First;
while (curr)
{
if (curr->NeedHeaderUpdate())
{
curr->Header()->sh_offset = curr->GetOffset();
curr->Header()->sh_size = curr->GetSize();
}
m_Buffer.AppendT(curr->Header());
curr = curr->GetNext();
}
}
//
// Update ELF Header
//
Elf_Ehdr *elfHeader = new (m_Buffer.GetPtr()) Elf_Ehdr;
#ifdef TARGET_ARM
elfHeader->e_flags = EF_ARM_EABI_VER5;
#ifdef ARM_SOFTFP
elfHeader->e_flags |= EF_ARM_SOFT_FLOAT;
#else
elfHeader->e_flags |= EF_ARM_VFP_FLOAT;
#endif
#endif
elfHeader->e_shoff = shtOffset;
elfHeader->e_shentsize = sizeof(Elf_Shdr);
elfHeader->e_shnum = m_SectionCount;
elfHeader->e_shstrndx = shstrtab->GetIndex();
}
#ifdef FEATURE_GDBJIT_FRAME
struct __attribute__((packed)) Length
{
UINT32 value;
Length &operator=(UINT32 n)
{
value = n;
return *this;
}
Length()
{
value = 0;
}
};
struct __attribute__((packed)) CIE
{
Length length;
UINT32 id;
UINT8 version;
UINT8 augmentation;
UINT8 code_alignment_factor;
INT8 data_alignment_factor;
UINT8 return_address_register;
UINT8 instructions[0];
};
struct __attribute__((packed)) FDE
{
Length length;
UINT32 cie;
PCODE initial_location;
TADDR address_range;
UINT8 instructions[0];
};
static void BuildDebugFrame(Elf_Builder &elfBuilder, PCODE pCode, TADDR codeSize)
{
#if defined(TARGET_ARM)
const unsigned int code_alignment_factor = 2;
const int data_alignment_factor = -4;
UINT8 cieCode[] = {
// DW_CFA_def_cfa 13[sp], 0
0x0c, 0x0d, 0x00,
};
UINT8 fdeCode[] = {
// DW_CFA_advance_loc 1
0x02, 0x01,
// DW_CFA_def_cfa_offset 8
0x0e, 0x08,
// DW_CFA_offset 11(r11), -8(= -4 * 2)
(0x02 << 6) | 0x0b, 0x02,
// DW_CFA_offset 14(lr), -4(= -4 * 1)
(0x02 << 6) | 0x0e, 0x01,
// DW_CFA_def_cfa_register 11(r11)
0x0d, 0x0b,
};
#elif defined(TARGET_X86)
const unsigned int code_alignment_factor = 1;
const int data_alignment_factor = -4;
UINT8 cieCode[] = {
// DW_CFA_def_cfa 4(esp), 4
0x0c, 0x04, 0x04,
// DW_CFA_offset 8(eip), -4(= -4 * 1)
(0x02 << 6) | 0x08, 0x01,
};
UINT8 fdeCode[] = {
// DW_CFA_advance_loc 1
0x02, 0x01,
// DW_CFA_def_cfa_offset 8
0x0e, 0x08,
// DW_CFA_offset 5(ebp), -8(= -4 * 2)
(0x02 << 6) | 0x05, 0x02,
// DW_CFA_def_cfa_register 5(ebp)
0x0d, 0x05,
};
#elif defined(TARGET_AMD64)
const unsigned int code_alignment_factor = 1;
const int data_alignment_factor = -8;
UINT8 cieCode[] = {
// DW_CFA_def_cfa 7(rsp), 8
0x0c, 0x07, 0x08,
// DW_CFA_offset 16, -16 (= -8 * 2)
(0x02 << 6) | 0x10, 0x01,
};
UINT8 fdeCode[] = {
// DW_CFA_advance_loc(1)
0x02, 0x01,
// DW_CFA_def_cfa_offset(16)
0x0e, 0x10,
// DW_CFA_offset 6, -16 (= -8 * 2)
(0x02 << 6) | 0x06, 0x02,
// DW_CFA_def_cfa_register(6)
0x0d, 0x06,
};
#elif defined(TARGET_ARM64)
const unsigned int code_alignment_factor = 1;
const int data_alignment_factor = -4;
UINT8 cieCode[] = {
// DW_CFA_def_cfa 31(sp), 0
0x0c, 0x1f, 0x00,
};
UINT8 fdeCode[] = {
// DW_CFA_advance_loc(1)
0x02, 0x01,
// DW_CFA_def_cfa_offset 16
0x0e, 0x10,
// DW_CFA_def_cfa_register 29(r29/fp)
0x0d, 0x1d,
// DW_CFA_offset: r30 (x30) at cfa-8
(0x02 << 6) | 0x1e, 0x02,
// DW_CFA_offset: r29 (x29) at cfa-16
(0x02 << 6) | 0x1d, 0x04,
};
#else
#error "Unsupported architecture"
#endif
elfBuilder.OpenSection(".debug_frame", SHT_PROGBITS, 0);
//
// Common Information Entry
//
int cieLen = ALIGN_UP(sizeof(CIE) + sizeof(cieCode), ADDRESS_SIZE) + sizeof(Length);
CIE *pCIE = elfBuilder.ReserveT<CIE>(cieLen);
memset(pCIE, 0, cieLen);
pCIE->length = cieLen - sizeof(Length);
pCIE->id = 0xffffffff;
pCIE->version = 3;
pCIE->augmentation = 0;
Leb128Encode(code_alignment_factor, reinterpret_cast<char *>(&pCIE->code_alignment_factor), 1);
Leb128Encode(data_alignment_factor, reinterpret_cast<char *>(&pCIE->data_alignment_factor), 1);
pCIE->return_address_register = 0;
memcpy(&pCIE->instructions, cieCode, sizeof(cieCode));
//
// Frame Description Entry
//
int fdeLen = ALIGN_UP((sizeof(FDE) + sizeof(fdeCode)), ADDRESS_SIZE) + sizeof(Length);
FDE *pFDE = elfBuilder.ReserveT<FDE>(fdeLen);
memset(pFDE, 0, fdeLen);
pFDE->length = fdeLen - sizeof(Length);
pFDE->cie = 0;
pFDE->initial_location = pCode;
pFDE->address_range = codeSize;
memcpy(&pFDE->instructions, fdeCode, sizeof(fdeCode));
elfBuilder.CloseSection();
}
#endif // FEATURE_GDBJIT_FRAME
void NotifyGdb::Initialize()
{
g_jitDescriptorCrst.Init(CrstNotifyGdb);
g_codeAddrsCrst.Init(CrstNotifyGdb);
// Get names of interesting modules from environment
if (g_wszModuleNames == nullptr && g_cBytesNeeded == 0)
{
DWORD cCharsNeeded = GetEnvironmentVariableW(W("CORECLR_GDBJIT"), NULL, 0);
if (cCharsNeeded == 0)
{
g_cBytesNeeded = 0xffffffff;
return;
}
WCHAR *wszModuleNamesBuf = new WCHAR[cCharsNeeded+1];
cCharsNeeded = GetEnvironmentVariableW(W("CORECLR_GDBJIT"), wszModuleNamesBuf, cCharsNeeded);
if (cCharsNeeded == 0)
{
delete[] wszModuleNamesBuf;
g_cBytesNeeded = 0xffffffff;
return;
}
g_wszModuleNames = wszModuleNamesBuf;
g_cBytesNeeded = cCharsNeeded + 1;
}
}
/* Create ELF/DWARF debug info for jitted method */
void NotifyGdb::MethodPrepared(MethodDesc* methodDescPtr)
{
EX_TRY
{
if (!tls_isSymReaderInProgress)
{
tls_isSymReaderInProgress = true;
NotifyGdb::OnMethodPrepared(methodDescPtr);
tls_isSymReaderInProgress = false;
}
}
EX_CATCH
{
}
EX_END_CATCH(SwallowAllExceptions);
}
void NotifyGdb::OnMethodPrepared(MethodDesc* methodDescPtr)
{
PCODE pCode = methodDescPtr->GetNativeCode();
if (pCode == NULL)
return;
/* Get method name & size of jitted code */
EECodeInfo codeInfo(pCode);
if (!codeInfo.IsValid())
{
return;
}
TADDR codeSize = codeInfo.GetCodeManager()->GetFunctionSize(codeInfo.GetGCInfoToken());
pCode = PCODEToPINSTR(pCode);
/* Get module name */
const Module* mod = methodDescPtr->GetMethodTable()->GetModule();
SString modName = mod->GetFile()->GetPath();
StackScratchBuffer scratch;
const char* szModName = modName.GetUTF8(scratch);
const char* szModuleFile = SplitFilename(szModName);
int length = MultiByteToWideChar(CP_UTF8, 0, szModuleFile, -1, NULL, 0);
if (length == 0)
return;
NewArrayHolder<WCHAR> wszModuleFile = new WCHAR[length+1];
length = MultiByteToWideChar(CP_UTF8, 0, szModuleFile, -1, wszModuleFile, length);
if (length == 0)
return;
bool bNotify = false;
Elf_Builder elfBuilder;
elfBuilder.Initialize(pCode, codeSize);
#ifdef FEATURE_GDBJIT_FRAME
if (g_pConfig->ShouldEmitDebugFrame())
{
bool bEmitted = EmitFrameInfo(elfBuilder, pCode, codeSize);
bNotify = bNotify || bEmitted;
}
#endif
// remove '.ni.dll' or '.ni.exe' suffix from wszModuleFile
LPWSTR pNIExt = const_cast<LPWSTR>(wcsstr(wszModuleFile, W(".ni.exe"))); // where '.ni.exe' start at
if (!pNIExt)
{
pNIExt = const_cast<LPWSTR>(wcsstr(wszModuleFile, W(".ni.dll"))); // where '.ni.dll' start at
}
if (pNIExt)
{
wcscpy(pNIExt, W(".dll"));
}
if (isListedModule(wszModuleFile))
{
bool bEmitted = EmitDebugInfo(elfBuilder, methodDescPtr, pCode, codeSize);
bNotify = bNotify || bEmitted;
}
#ifdef FEATURE_GDBJIT_SYMTAB
else
{
bool bEmitted = EmitSymtab(elfBuilder, methodDescPtr, pCode, codeSize);
bNotify = bNotify || bEmitted;
}
#endif
if (!bNotify)
{
return;
}
elfBuilder.Finalize();
char *symfile_addr = NULL;
size_t symfile_size = 0;
symfile_addr = elfBuilder.Export(&symfile_size);
#ifdef _DEBUG
LPCUTF8 methodName = methodDescPtr->GetName();
if (g_pConfig->ShouldDumpElfOnMethod(methodName))
{
DumpElf(methodName, symfile_addr, symfile_size);
}
#endif
/* Create GDB JIT structures */
NewHolder<jit_code_entry> jit_symbols = new jit_code_entry;
/* Fill the new entry */
jit_symbols->next_entry = jit_symbols->prev_entry = 0;
jit_symbols->symfile_addr = symfile_addr;
jit_symbols->symfile_size = symfile_size;
{
CrstHolder crst(&g_jitDescriptorCrst);
/* Link into list */
jit_code_entry *head = __jit_debug_descriptor.first_entry;
__jit_debug_descriptor.first_entry = jit_symbols;
if (head != 0)
{
jit_symbols->next_entry = head;
head->prev_entry = jit_symbols;
}
jit_symbols.SuppressRelease();
/* Notify the debugger */
__jit_debug_descriptor.relevant_entry = jit_symbols;
__jit_debug_descriptor.action_flag = JIT_REGISTER_FN;
__jit_debug_register_code();
}
}
#ifdef FEATURE_GDBJIT_FRAME
bool NotifyGdb::EmitFrameInfo(Elf_Builder &elfBuilder, PCODE pCode, TADDR codeSize)
{
BuildDebugFrame(elfBuilder, pCode, codeSize);
return true;
}
#endif // FEATURE_GDBJIT_FRAME
#ifdef FEATURE_GDBJIT_SYMTAB
bool NotifyGdb::EmitSymtab(Elf_Builder &elfBuilder, MethodDesc* methodDescPtr, PCODE pCode, TADDR codeSize)
{
NewArrayHolder<DebuggerILToNativeMap> map = nullptr;
NewArrayHolder<Elf_Symbol> symbols = nullptr;
NewArrayHolder<NewArrayHolder<char>> symbolNames = nullptr;
ULONG32 numMap;
int symbolCount;
LPCUTF8 methodName = methodDescPtr->GetName();
if (GetMethodNativeMap(methodDescPtr, &numMap, map, NULL, NULL) == S_OK)
{
int methodCount = countFuncs(map, numMap);
symbolCount = methodCount + 1;
symbols = new Elf_Symbol[symbolCount];
if (methodCount > 1)
symbolNames = new NewArrayHolder<char>[methodCount - 1];
int startIndex = getNextPrologueIndex(0, map, numMap);
int methodNameSize = strlen(methodName) + 10;
for (int i = 1; i < symbolCount; ++i)
{
int endIndex = getNextPrologueIndex(startIndex + 1, map, numMap);
PCODE methodStart = map[startIndex].nativeStartOffset;
TADDR methodSize = endIndex == -1 ? codeSize - methodStart : map[endIndex].nativeStartOffset - methodStart;
if (i == 1)
{
symbols[i].m_name = methodName;
}
else
{
int symbolNameIndex = i - 2;
symbolNames[symbolNameIndex] = new char[methodNameSize];
sprintf_s(symbolNames[symbolNameIndex], methodNameSize, "%s_%d", methodName, symbolNameIndex + 1);
symbols[i].m_name = symbolNames[symbolNameIndex];
}
symbols[i].m_value = pCode + methodStart;
symbols[i].m_size = methodSize;
startIndex = endIndex;
}
}
else
{
symbolCount = 2;
symbols = new Elf_Symbol[symbolCount];
symbols[1].m_name = methodName;
symbols[1].m_value = pCode;
symbols[1].m_size = codeSize;
}
symbols[0].m_name = "";
MemBuf sectSymTab, sectStrTab;
if (!BuildStringTableSection(sectStrTab, symbols, symbolCount))
{
return false;
}
if (!BuildSymbolTableSection(sectSymTab, pCode, codeSize, symbolCount - 1, symbols, symbolCount, 0))
{
return false;
}
Elf_SectionTracker *strtab = elfBuilder.OpenSection(".strtab", SHT_STRTAB, 0);
elfBuilder.Append(sectStrTab.MemPtr, sectStrTab.MemSize);
elfBuilder.CloseSection();
Elf_SectionTracker *symtab = elfBuilder.OpenSection(".symtab", SHT_SYMTAB, 0);
elfBuilder.Append(sectSymTab.MemPtr, sectSymTab.MemSize);
symtab->Header()->sh_link = strtab->GetIndex();
symtab->Header()->sh_entsize = sizeof(Elf_Sym);
elfBuilder.CloseSection();
return true;
}
#endif // FEATURE_GDBJIT_SYMTAB
bool NotifyGdb::EmitDebugInfo(Elf_Builder &elfBuilder, MethodDesc* methodDescPtr, PCODE pCode, TADDR codeSize)
{
unsigned int thunkIndexBase = elfBuilder.GetSectionCount();
LPCUTF8 methodName = methodDescPtr->GetName();
int symbolCount = 0;
NewArrayHolder<Elf_Symbol> symbolNames;
unsigned int symInfoLen = 0;
NewArrayHolder<SymbolsInfo> symInfo = nullptr;
LocalsInfo locals;
NewHolder<TK_TypeInfoMap> pTypeMap = new TK_TypeInfoMap();
/* Get debug info for method from portable PDB */
HRESULT hr = GetDebugInfoFromPDB(methodDescPtr, symInfo, symInfoLen, locals);
if (FAILED(hr) || symInfoLen == 0)
{
return false;
}
int method_count = countFuncs(symInfo, symInfoLen);
FunctionMemberPtrArrayHolder method(method_count);
CodeHeader* pCH = (CodeHeader*)pCode - 1;
CalledMethod* pCalledMethods = reinterpret_cast<CalledMethod*>(pCH->GetCalledMethods());
/* Collect addresses of thunks called by method */
if (!CollectCalledMethods(pCalledMethods, (TADDR)methodDescPtr->GetNativeCode(), method, symbolNames, symbolCount))
{
return false;
}
pCH->SetCalledMethods(NULL);
MetaSig sig(methodDescPtr);
int nArgsCount = sig.NumFixedArgs();
if (sig.HasThis())
nArgsCount++;
unsigned int firstLineIndex = 0;
for (;firstLineIndex < symInfoLen; firstLineIndex++) {
if (symInfo[firstLineIndex].lineNumber != 0 && symInfo[firstLineIndex].lineNumber != HiddenLine) break;
}
if (firstLineIndex >= symInfoLen)
{
return false;
}
int start_index = getNextPrologueIndex(0, symInfo, symInfoLen);
for (int method_index = 0; method_index < method.GetCount(); ++method_index)
{
method[method_index] = new FunctionMember(methodDescPtr, locals.size, nArgsCount);
int end_index = getNextPrologueIndex(start_index + 1, symInfo, symInfoLen);
PCODE method_start = symInfo[start_index].nativeOffset;
TADDR method_size = end_index == -1 ? codeSize - method_start : symInfo[end_index].nativeOffset - method_start;
// method return type
method[method_index]->m_member_type = GetArgTypeInfo(methodDescPtr, pTypeMap, 0, method);
method[method_index]->m_sub_low_pc = pCode + method_start;
method[method_index]->m_sub_high_pc = method_size;
method[method_index]->lines = symInfo;
method[method_index]->nlines = symInfoLen;
method[method_index]->GetLocalsDebugInfo(pTypeMap, locals, symInfo[firstLineIndex].nativeOffset, method);
size_t methodNameSize = strlen(methodName) + 10;
method[method_index]->m_member_name = new char[methodNameSize];
if (method_index == 0)
sprintf_s(method[method_index]->m_member_name, methodNameSize, "%s", methodName);
else
sprintf_s(method[method_index]->m_member_name, methodNameSize, "%s_%i", methodName, method_index);
// method's class
GetTypeInfoFromTypeHandle(TypeHandle(method[method_index]->md->GetMethodTable()), pTypeMap, method);
start_index = end_index;
}
MemBuf sectSymTab, sectStrTab, dbgInfo, dbgAbbrev, dbgPubname, dbgPubType, dbgLine,
dbgStr;
/* Build .debug_abbrev section */
if (!BuildDebugAbbrev(dbgAbbrev))
{
return false;
}
const char *cuPath = "";
/* Build .debug_line section */
if (!BuildLineTable(dbgLine, pCode, codeSize, symInfo, symInfoLen, cuPath))
{
return false;
}
// Split full path to compile unit into file name and directory path
const char *fileName = SplitFilename(cuPath);
int dirLen = fileName - cuPath;
NewArrayHolder<char> dirPath;
if (dirLen != 0)
{
dirPath = new char[dirLen];
memcpy(dirPath, cuPath, dirLen - 1);
dirPath[dirLen - 1] = '\0';
}
DebugStringsCU debugStringsCU(fileName, dirPath ? (const char *)dirPath : "");
/* Build .debug_str section */
if (!BuildDebugStrings(dbgStr, pTypeMap, method, debugStringsCU))
{
return false;
}
/* Build .debug_info section */
if (!BuildDebugInfo(dbgInfo, pTypeMap, method, debugStringsCU))
{
return false;
}
for (int i = 0; i < method.GetCount(); ++i)
{
method[i]->lines = nullptr;
method[i]->nlines = 0;
}
/* Build .debug_pubname section */
if (!BuildDebugPub(dbgPubname, methodName, dbgInfo.MemSize, 0x28))
{
return false;
}
/* Build debug_pubtype section */
if (!BuildDebugPub(dbgPubType, "int", dbgInfo.MemSize, 0x1a))
{
return false;
}
/* Build .strtab section */
symbolNames[0].m_name = "";
for (int i = 0; i < method.GetCount(); ++i)
{
symbolNames[1 + i].m_name = method[i]->m_member_name;
symbolNames[1 + i].m_value = method[i]->m_sub_low_pc;
symbolNames[1 + i].m_section = 1;
symbolNames[1 + i].m_size = method[i]->m_sub_high_pc;
}
if (!BuildStringTableSection(sectStrTab, symbolNames, symbolCount))
{
return false;
}
/* Build .symtab section */
if (!BuildSymbolTableSection(sectSymTab, pCode, codeSize, method.GetCount(), symbolNames, symbolCount, thunkIndexBase))
{
return false;
}
for (int i = 1 + method.GetCount(); i < symbolCount; i++)
{
char name[256];
sprintf_s(name, _countof(name), ".thunk_%i", i);
Elf_SectionTracker *thunk = elfBuilder.OpenSection(name, SHT_PROGBITS, SHF_ALLOC | SHF_EXECINSTR);
thunk->DisableHeaderUpdate();
elfBuilder.CloseSection();
}
elfBuilder.OpenSection(".debug_str", SHT_PROGBITS, SHF_MERGE | SHF_STRINGS);
elfBuilder.Append(dbgStr.MemPtr, dbgStr.MemSize);
elfBuilder.CloseSection();
elfBuilder.OpenSection(".debug_abbrev", SHT_PROGBITS, 0);
elfBuilder.Append(dbgAbbrev.MemPtr, dbgAbbrev.MemSize);
elfBuilder.CloseSection();
elfBuilder.OpenSection(".debug_info", SHT_PROGBITS, 0);
elfBuilder.Append(dbgInfo.MemPtr, dbgInfo.MemSize);
elfBuilder.CloseSection();
elfBuilder.OpenSection(".debug_pubnames", SHT_PROGBITS, 0);
elfBuilder.Append(dbgPubname.MemPtr, dbgPubname.MemSize);
elfBuilder.CloseSection();
elfBuilder.OpenSection(".debug_pubtypes", SHT_PROGBITS, 0);
elfBuilder.Append(dbgPubType.MemPtr, dbgPubType.MemSize);
elfBuilder.CloseSection();
elfBuilder.OpenSection(".debug_line", SHT_PROGBITS, 0);
elfBuilder.Append(dbgLine.MemPtr, dbgLine.MemSize);
elfBuilder.CloseSection();
Elf_SectionTracker *strtab = elfBuilder.OpenSection(".strtab", SHT_STRTAB, 0);
elfBuilder.Append(sectStrTab.MemPtr, sectStrTab.MemSize);
elfBuilder.CloseSection();
Elf_SectionTracker *symtab = elfBuilder.OpenSection(".symtab", SHT_SYMTAB, 0);
elfBuilder.Append(sectSymTab.MemPtr, sectSymTab.MemSize);
symtab->Header()->sh_link = strtab->GetIndex();
symtab->Header()->sh_entsize = sizeof(Elf_Sym);
elfBuilder.CloseSection();
return true;
}
void NotifyGdb::MethodPitched(MethodDesc* methodDescPtr)
{
PCODE pCode = methodDescPtr->GetNativeCode();
if (pCode == NULL)
return;
CrstHolder crst(&g_jitDescriptorCrst);
/* Find relevant entry */
for (jit_code_entry* jit_symbols = __jit_debug_descriptor.first_entry; jit_symbols != 0; jit_symbols = jit_symbols->next_entry)
{
const char* ptr = jit_symbols->symfile_addr;
uint64_t size = jit_symbols->symfile_size;
const Elf_Ehdr* pEhdr = reinterpret_cast<const Elf_Ehdr*>(ptr);
const Elf_Shdr* pShdr = reinterpret_cast<const Elf_Shdr*>(ptr + pEhdr->e_shoff);
pShdr += ELF_BUILDER_TEXT_SECTION_INDEX; // bump to .text section
if (pShdr->sh_addr == pCode)
{
/* Notify the debugger */
__jit_debug_descriptor.relevant_entry = jit_symbols;
__jit_debug_descriptor.action_flag = JIT_UNREGISTER_FN;
__jit_debug_register_code();
/* Free memory */
delete[] ptr;
/* Unlink from list */
if (jit_symbols->prev_entry == 0)
__jit_debug_descriptor.first_entry = jit_symbols->next_entry;
else
jit_symbols->prev_entry->next_entry = jit_symbols->next_entry;
delete jit_symbols;
break;
}
}
}
/* Build the DWARF .debug_line section */
bool NotifyGdb::BuildLineTable(MemBuf& buf, PCODE startAddr, TADDR codeSize, SymbolsInfo* lines, unsigned nlines,
const char * &cuPath)
{
MemBuf fileTable, lineProg;
/* Build file table */
if (!BuildFileTable(fileTable, lines, nlines, cuPath))
return false;
/* Build line info program */
if (!BuildLineProg(lineProg, startAddr, codeSize, lines, nlines))
{
return false;
}
buf.MemSize = sizeof(DwarfLineNumHeader) + fileTable.MemSize + lineProg.MemSize;
buf.MemPtr = new char[buf.MemSize];
/* Fill the line info header */
DwarfLineNumHeader* header = reinterpret_cast<DwarfLineNumHeader*>(buf.MemPtr.GetValue());
memcpy(buf.MemPtr, &LineNumHeader, sizeof(DwarfLineNumHeader));
header->m_length = buf.MemSize - sizeof(header->m_length);
// Set m_hdr_field to the number of bytes following the m_hdr_field field to the beginning of the first byte of
// the line number program itself.
header->m_hdr_length = sizeof(DwarfLineNumHeader)
- sizeof(header->m_length)
- sizeof(header->m_version)
- sizeof(header->m_hdr_length)
+ fileTable.MemSize;
/* copy file table */
memcpy(buf.MemPtr + sizeof(DwarfLineNumHeader), fileTable.MemPtr, fileTable.MemSize);
/* copy line program */
memcpy(buf.MemPtr + sizeof(DwarfLineNumHeader) + fileTable.MemSize, lineProg.MemPtr, lineProg.MemSize);
return true;
}
// A class for building Directory Table and File Table (in .debug_line section) from a list of files
class NotifyGdb::FileTableBuilder
{
int m_capacity;
NewArrayHolder< NewArrayHolder<char> > m_dirs;
int m_dirs_count;
struct FileEntry
{
const char* path;
const char* name;
int dir;
};
NewArrayHolder<FileEntry> m_files;
int m_files_count;
int FindDir(const char *name) const
{
for (int i = 0; i < m_dirs_count; ++i)
{
if (strcmp(m_dirs[i], name) == 0)
return i;
}
return -1;
}
int FindFile(const char *path) const
{
for (int i = 0; i < m_files_count; ++i)
{
if (strcmp(m_files[i].path, path) == 0)
return i;
}
return -1;
}
public:
FileTableBuilder(int capacity) :
m_capacity(capacity),
m_dirs(new NewArrayHolder<char>[capacity]),
m_dirs_count(0),
m_files(new FileEntry[capacity]),
m_files_count(0)
{
}
int Add(const char *path)
{
// Already exists?
int i = FindFile(path);
if (i != -1)
return i;
if (m_files_count >= m_capacity)
return -1;
// Add new file entry
m_files[m_files_count].path = path;
const char *filename = SplitFilename(path);
m_files[m_files_count].name = filename;
int dirLen = filename - path;
if (dirLen == 0)
{
m_files[m_files_count].dir = 0;
return m_files_count++;
}
// Construct directory path
NewArrayHolder<char> dirName = new char[dirLen + 1];
int delimiterDelta = dirLen == 1 ? 0 : 1; // Avoid empty dir entry when file is at Unix root /
memcpy(dirName, path, dirLen - delimiterDelta);
dirName[dirLen - delimiterDelta] = '\0';
// Try to find existing directory entry
i = FindDir(dirName);
if (i != -1)
{
m_files[m_files_count].dir = i + 1;
return m_files_count++;
}
// Create new directory entry
if (m_dirs_count >= m_capacity)
return -1;
m_dirs[m_dirs_count++] = dirName.Extract();
m_files[m_files_count].dir = m_dirs_count;
return m_files_count++;
}
void Build(MemBuf& buf)
{
unsigned totalSize = 0;
// Compute buffer size
for (unsigned i = 0; i < m_dirs_count; ++i)
totalSize += strlen(m_dirs[i]) + 1;
totalSize += 1;
char cnv_buf[16];
for (unsigned i = 0; i < m_files_count; ++i)
{
int len = Leb128Encode(static_cast<uint32_t>(m_files[i].dir), cnv_buf, sizeof(cnv_buf));
totalSize += strlen(m_files[i].name) + 1 + len + 2;
}
totalSize += 1;
// Fill the buffer
buf.MemSize = totalSize;
buf.MemPtr = new char[buf.MemSize];
char *ptr = buf.MemPtr;
for (unsigned i = 0; i < m_dirs_count; ++i)
{
strcpy(ptr, m_dirs[i]);
ptr += strlen(m_dirs[i]) + 1;
}
// final zero byte for directory table
*ptr++ = 0;
for (unsigned i = 0; i < m_files_count; ++i)
{
strcpy(ptr, m_files[i].name);
ptr += strlen(m_files[i].name) + 1;
// Index in directory table
int len = Leb128Encode(static_cast<uint32_t>(m_files[i].dir), cnv_buf, sizeof(cnv_buf));
memcpy(ptr, cnv_buf, len);
ptr += len;
// Two LEB128 entries which we don't care
*ptr++ = 0;
*ptr++ = 0;
}
// final zero byte
*ptr = 0;
}
};
/* Buid the source files table for DWARF source line info */
bool NotifyGdb::BuildFileTable(MemBuf& buf, SymbolsInfo* lines, unsigned nlines, const char * &cuPath)
{
FileTableBuilder fileTable(nlines);
cuPath = "";
for (unsigned i = 0; i < nlines; ++i)
{
const char* fileName = lines[i].fileName;
if (fileName[0] == '\0')
continue;
if (*cuPath == '\0') // Use first non-empty filename as compile unit
cuPath = fileName;
lines[i].fileIndex = fileTable.Add(fileName);
}
fileTable.Build(buf);
return true;
}
/* Command to set absolute address */
void NotifyGdb::IssueSetAddress(char*& ptr, PCODE addr)
{
*ptr++ = 0;
*ptr++ = ADDRESS_SIZE + 1;
*ptr++ = DW_LNE_set_address;
*reinterpret_cast<PCODE*>(ptr) = addr;
ptr += ADDRESS_SIZE;
}
/* End of line program */
void NotifyGdb::IssueEndOfSequence(char*& ptr)
{
*ptr++ = 0;
*ptr++ = 1;
*ptr++ = DW_LNE_end_sequence;
}
/* Command w/o parameters */
void NotifyGdb::IssueSimpleCommand(char*& ptr, uint8_t command)
{
*ptr++ = command;
}
/* Command with one LEB128 parameter */
void NotifyGdb::IssueParamCommand(char*& ptr, uint8_t command, char* param, int param_size)
{
*ptr++ = command;
while (param_size-- > 0)
{
*ptr++ = *param++;
}
}
static void fixLineMapping(SymbolsInfo* lines, unsigned nlines)
{
// Fix EPILOGUE line mapping
int prevLine = 0;
for (int i = 0; i < nlines; ++i)
{
if (lines[i].lineNumber == HiddenLine)
continue;
if (lines[i].ilOffset == ICorDebugInfo::PROLOG) // will be fixed in next step
{
prevLine = 0;
}
else
{
if (lines[i].lineNumber == 0)
{
lines[i].lineNumber = prevLine;
}
else
{
prevLine = lines[i].lineNumber;
}
}
}
// Fix PROLOGUE line mapping
prevLine = lines[nlines - 1].lineNumber;
for (int i = nlines - 1; i >= 0; --i)
{
if (lines[i].lineNumber == HiddenLine)
continue;
if (lines[i].lineNumber == 0)
lines[i].lineNumber = prevLine;
else
prevLine = lines[i].lineNumber;
}
// Skip HiddenLines
for (int i = 0; i < nlines; ++i)
{
if (lines[i].lineNumber == HiddenLine)
{
lines[i].lineNumber = 0;
if (i + 1 < nlines && lines[i + 1].ilOffset == ICorDebugInfo::NO_MAPPING)
lines[i + 1].lineNumber = 0;
}
}
}
/* Build program for DWARF source line section */
bool NotifyGdb::BuildLineProg(MemBuf& buf, PCODE startAddr, TADDR codeSize, SymbolsInfo* lines, unsigned nlines)
{
char cnv_buf[16];
/* reserve memory assuming worst case: set address, advance line command, set proglogue/epilogue and copy for each line */
buf.MemSize =
+ 6 /* set file command */
+ nlines * 6 /* advance line commands */
+ nlines * (3 + ADDRESS_SIZE) /* set address commands */
+ nlines * 1 /* set prologue end or epilogue begin commands */
+ nlines * 1 /* copy commands */
+ 6 /* advance PC command */
+ 3; /* end of sequence command */
buf.MemPtr = new char[buf.MemSize];
char* ptr = buf.MemPtr;
if (buf.MemPtr == nullptr)
return false;
fixLineMapping(lines, nlines);
int prevLine = 1, prevFile = 0;
for (int i = 0; i < nlines; ++i)
{
/* different source file */
if (lines[i].fileIndex != prevFile)
{
int len = Leb128Encode(static_cast<uint32_t>(lines[i].fileIndex+1), cnv_buf, sizeof(cnv_buf));
IssueParamCommand(ptr, DW_LNS_set_file, cnv_buf, len);
prevFile = lines[i].fileIndex;
}
// GCC don't use the is_prologue_end flag to mark the first instruction after the prologue.
// Instead of it it is issueing a line table entry for the first instruction of the prologue
// and one for the first instruction after the prologue.
// We do not want to confuse the debugger so we have to avoid adding a line in such case.
if (i > 0 && lines[i - 1].nativeOffset == lines[i].nativeOffset)
continue;
IssueSetAddress(ptr, startAddr + lines[i].nativeOffset);
if (lines[i].lineNumber != prevLine) {
int len = Leb128Encode(static_cast<int32_t>(lines[i].lineNumber - prevLine), cnv_buf, sizeof(cnv_buf));
IssueParamCommand(ptr, DW_LNS_advance_line, cnv_buf, len);
prevLine = lines[i].lineNumber;
}
if (lines[i].ilOffset == ICorDebugInfo::EPILOG)
IssueSimpleCommand(ptr, DW_LNS_set_epilogue_begin);
else if (i > 0 && lines[i - 1].ilOffset == ICorDebugInfo::PROLOG)
IssueSimpleCommand(ptr, DW_LNS_set_prologue_end);
IssueParamCommand(ptr, DW_LNS_copy, NULL, 0);
}
int lastAddr = nlines > 0 ? lines[nlines - 1].nativeOffset : 0;
// Advance PC to the end of function
if (lastAddr < codeSize) {
int len = Leb128Encode(static_cast<uint32_t>(codeSize - lastAddr), cnv_buf, sizeof(cnv_buf));
IssueParamCommand(ptr, DW_LNS_advance_pc, cnv_buf, len);
}
IssueEndOfSequence(ptr);
buf.MemSize = ptr - buf.MemPtr;
return true;
}
/* Build the DWARF .debug_str section */
bool NotifyGdb::BuildDebugStrings(MemBuf& buf,
PTK_TypeInfoMap pTypeMap,
FunctionMemberPtrArrayHolder &method,
DebugStringsCU &debugStringsCU)
{
int totalLength = 0;
/* calculate total section size */
debugStringsCU.DumpStrings(nullptr, totalLength);
for (int i = 0; i < method.GetCount(); ++i)
{
method[i]->DumpStrings(nullptr, totalLength);
}
{
auto iter = pTypeMap->Begin();
while (iter != pTypeMap->End())
{
TypeInfoBase *typeInfo = iter->Value();
typeInfo->DumpStrings(nullptr, totalLength);
iter++;
}
}
buf.MemSize = totalLength;
buf.MemPtr = new char[totalLength];
/* copy strings */
char* bufPtr = buf.MemPtr;
int offset = 0;
debugStringsCU.DumpStrings(bufPtr, offset);
for (int i = 0; i < method.GetCount(); ++i)
{
method[i]->DumpStrings(bufPtr, offset);
}
{
auto iter = pTypeMap->Begin();
while (iter != pTypeMap->End())
{
TypeInfoBase *typeInfo = iter->Value();
typeInfo->DumpStrings(bufPtr, offset);
iter++;
}
}
return true;
}
/* Build the DWARF .debug_abbrev section */
bool NotifyGdb::BuildDebugAbbrev(MemBuf& buf)
{
buf.MemPtr = new char[AbbrevTableSize];
buf.MemSize = AbbrevTableSize;
memcpy(buf.MemPtr, AbbrevTable, AbbrevTableSize);
return true;
}
/* Build tge DWARF .debug_info section */
bool NotifyGdb::BuildDebugInfo(MemBuf& buf,
PTK_TypeInfoMap pTypeMap,
FunctionMemberPtrArrayHolder &method,
DebugStringsCU &debugStringsCU)
{
int totalTypeVarSubSize = 0;
{
auto iter = pTypeMap->Begin();
while (iter != pTypeMap->End())
{
TypeInfoBase *typeInfo = iter->Value();
typeInfo->DumpDebugInfo(nullptr, totalTypeVarSubSize);
iter++;
}
}
for (int i = 0; i < method.GetCount(); ++i)
{
method[i]->DumpDebugInfo(nullptr, totalTypeVarSubSize);
}
//int locSize = GetArgsAndLocalsLen(argsDebug, argsDebugSize, localsDebug, localsDebugSize);
buf.MemSize = sizeof(DwarfCompUnit) + sizeof(DebugInfoCU) + totalTypeVarSubSize + 2;
buf.MemPtr = new char[buf.MemSize];
int offset = 0;
/* Compile uint header */
DwarfCompUnit* cu = reinterpret_cast<DwarfCompUnit*>(buf.MemPtr.GetValue());
cu->m_length = buf.MemSize - sizeof(uint32_t);
cu->m_version = 4;
cu->m_abbrev_offset = 0;
cu->m_addr_size = ADDRESS_SIZE;
offset += sizeof(DwarfCompUnit);
DebugInfoCU* diCU =
reinterpret_cast<DebugInfoCU*>(buf.MemPtr + offset);
memcpy(buf.MemPtr + offset, &debugInfoCU, sizeof(DebugInfoCU));
offset += sizeof(DebugInfoCU);
diCU->m_prod_off = debugStringsCU.GetProducerOffset();
diCU->m_cu_name = debugStringsCU.GetModuleNameOffset();
diCU->m_cu_dir = debugStringsCU.GetModuleDirOffset();
{
auto iter = pTypeMap->Begin();
while (iter != pTypeMap->End())
{
TypeInfoBase *typeInfo = iter->Value();
typeInfo->DumpDebugInfo(buf.MemPtr, offset);
iter++;
}
}
for (int i = 0; i < method.GetCount(); ++i)
{
if (!method[i]->IsDumped())
{
method[i]->DumpDebugInfo(buf.MemPtr, offset);
}
else
{
method[i]->DumpDebugInfo(buf.MemPtr, method[i]->m_entry_offset);
}
}
memset(buf.MemPtr + offset, 0, buf.MemSize - offset);
return true;
}
/* Build the DWARF lookup section */
bool NotifyGdb::BuildDebugPub(MemBuf& buf, const char* name, uint32_t size, uint32_t die_offset)
{
uint32_t length = sizeof(DwarfPubHeader) + sizeof(uint32_t) + strlen(name) + 1 + sizeof(uint32_t);
buf.MemSize = length;
buf.MemPtr = new char[buf.MemSize];
DwarfPubHeader* header = reinterpret_cast<DwarfPubHeader*>(buf.MemPtr.GetValue());
header->m_length = length - sizeof(uint32_t);
header->m_version = 2;
header->m_debug_info_off = 0;
header->m_debug_info_len = size;
*reinterpret_cast<uint32_t*>(buf.MemPtr + sizeof(DwarfPubHeader)) = die_offset;
strcpy(buf.MemPtr + sizeof(DwarfPubHeader) + sizeof(uint32_t), name);
*reinterpret_cast<uint32_t*>(buf.MemPtr + length - sizeof(uint32_t)) = 0;
return true;
}
/* Store addresses and names of the called methods into symbol table */
bool NotifyGdb::CollectCalledMethods(CalledMethod* pCalledMethods,
TADDR nativeCode,
FunctionMemberPtrArrayHolder &method,
NewArrayHolder<Elf_Symbol> &symbolNames,
int &symbolCount)
{
AddrSet tmpCodeAddrs;
CrstHolder crst(&g_codeAddrsCrst);
if (!g_codeAddrs.Contains(nativeCode))
g_codeAddrs.Add(nativeCode);
CalledMethod* pList = pCalledMethods;
/* count called methods */
while (pList != NULL)
{
TADDR callAddr = (TADDR)pList->GetCallAddr();
if (!tmpCodeAddrs.Contains(callAddr) && !g_codeAddrs.Contains(callAddr)) {
tmpCodeAddrs.Add(callAddr);
}
pList = pList->GetNext();
}
symbolCount = 1 + method.GetCount() + tmpCodeAddrs.GetCount();
symbolNames = new Elf_Symbol[symbolCount];
pList = pCalledMethods;
int i = 1 + method.GetCount();
while (i < symbolCount && pList != NULL)
{
TADDR callAddr = (TADDR)pList->GetCallAddr();
if (!g_codeAddrs.Contains(callAddr))
{
MethodDesc* pMD = pList->GetMethodDesc();
LPCUTF8 methodName = pMD->GetName();
int symbolNameLength = strlen(methodName) + sizeof("__thunk_");
symbolNames[i].m_symbol_name = new char[symbolNameLength];
symbolNames[i].m_name = symbolNames[i].m_symbol_name;
sprintf_s((char*)symbolNames[i].m_name, symbolNameLength, "__thunk_%s", methodName);
symbolNames[i].m_value = callAddr;
++i;
g_codeAddrs.Add(callAddr);
}
pList = pList->GetNext();
}
symbolCount = i;
return true;
}
/* Build ELF .strtab section */
bool NotifyGdb::BuildStringTableSection(MemBuf& buf, NewArrayHolder<Elf_Symbol> &symbolNames, int symbolCount)
{
int len = 0;
for (int i = 0; i < symbolCount; ++i)
len += strlen(symbolNames[i].m_name) + 1;
len++; // end table with zero-length string
buf.MemSize = len;
buf.MemPtr = new char[buf.MemSize];
char* ptr = buf.MemPtr;
for (int i = 0; i < symbolCount; ++i)
{
symbolNames[i].m_off = ptr - buf.MemPtr;
strcpy(ptr, symbolNames[i].m_name);
ptr += strlen(symbolNames[i].m_name) + 1;
}
buf.MemPtr[buf.MemSize-1] = 0;
return true;
}
/* Build ELF .symtab section */
bool NotifyGdb::BuildSymbolTableSection(MemBuf& buf, PCODE addr, TADDR codeSize, int methodCount,
NewArrayHolder<Elf_Symbol> &symbolNames, int symbolCount,
unsigned int thunkIndexBase)
{
buf.MemSize = symbolCount * sizeof(Elf_Sym);
buf.MemPtr = new char[buf.MemSize];
Elf_Sym *sym = reinterpret_cast<Elf_Sym*>(buf.MemPtr.GetValue());
sym[0].st_name = 0;
sym[0].st_info = 0;
sym[0].st_other = 0;
sym[0].st_value = 0;
sym[0].st_size = 0;
sym[0].st_shndx = SHN_UNDEF;
for (int i = 1; i < 1 + methodCount; ++i)
{
sym[i].st_name = symbolNames[i].m_off;
sym[i].setBindingAndType(STB_GLOBAL, STT_FUNC);
sym[i].st_other = 0;
sym[i].st_value = PINSTRToPCODE(symbolNames[i].m_value - addr);
sym[i].st_shndx = ELF_BUILDER_TEXT_SECTION_INDEX;
sym[i].st_size = symbolNames[i].m_size;
}
for (int i = 1 + methodCount; i < symbolCount; ++i)
{
sym[i].st_name = symbolNames[i].m_off;
sym[i].setBindingAndType(STB_GLOBAL, STT_FUNC);
sym[i].st_other = 0;
sym[i].st_shndx = thunkIndexBase + (i - (1 + methodCount)); // .thunks section index
sym[i].st_size = 8;
#ifdef TARGET_ARM
sym[i].st_value = 1; // for THUMB code
#else
sym[i].st_value = 0;
#endif
}
return true;
}
/* Split file name part from the full path */
const char * NotifyGdb::SplitFilename(const char* path)
{
// Search for the last directory delimiter (Windows or Unix)
const char *pSlash = nullptr;
for (const char *p = path; *p != '\0'; p++)
{
if (*p == '/' || *p == '\\')
pSlash = p;
}
return pSlash ? pSlash + 1 : path;
}
/* ELF 32bit header */
Elf32_Ehdr::Elf32_Ehdr()
{
e_ident[EI_MAG0] = ElfMagic[0];
e_ident[EI_MAG1] = ElfMagic[1];
e_ident[EI_MAG2] = ElfMagic[2];
e_ident[EI_MAG3] = ElfMagic[3];
e_ident[EI_CLASS] = ELFCLASS32;
e_ident[EI_DATA] = ELFDATA2LSB;
e_ident[EI_VERSION] = EV_CURRENT;
e_ident[EI_OSABI] = ELFOSABI_NONE;
e_ident[EI_ABIVERSION] = 0;
for (int i = EI_PAD; i < EI_NIDENT; ++i)
e_ident[i] = 0;
e_type = ET_REL;
#if defined(TARGET_X86)
e_machine = EM_386;
#elif defined(TARGET_ARM)
e_machine = EM_ARM;
#endif
e_flags = 0;
e_version = 1;
e_entry = 0;
e_phoff = 0;
e_ehsize = sizeof(Elf32_Ehdr);
e_phentsize = 0;
e_phnum = 0;
}
/* ELF 64bit header */
Elf64_Ehdr::Elf64_Ehdr()
{
e_ident[EI_MAG0] = ElfMagic[0];
e_ident[EI_MAG1] = ElfMagic[1];
e_ident[EI_MAG2] = ElfMagic[2];
e_ident[EI_MAG3] = ElfMagic[3];
e_ident[EI_CLASS] = ELFCLASS64;
e_ident[EI_DATA] = ELFDATA2LSB;
e_ident[EI_VERSION] = EV_CURRENT;
e_ident[EI_OSABI] = ELFOSABI_NONE;
e_ident[EI_ABIVERSION] = 0;
for (int i = EI_PAD; i < EI_NIDENT; ++i)
e_ident[i] = 0;
e_type = ET_REL;
#if defined(TARGET_AMD64)
e_machine = EM_X86_64;
#elif defined(TARGET_ARM64)
e_machine = EM_AARCH64;
#endif
e_flags = 0;
e_version = 1;
e_entry = 0;
e_phoff = 0;
e_ehsize = sizeof(Elf64_Ehdr);
e_phentsize = 0;
e_phnum = 0;
}
| 28.461705 | 131 | 0.607582 | patricksadowski |
16436957f8231aba3e04fd20fac6f2b0790ae28e | 1,267 | cpp | C++ | foobar2000/helpers/packet_decoder_mp3_common.cpp | jpbattaille/foobar2000 | 9b057e21fee0a185d09d520de9bb7bce27cb264b | [
"Unlicense"
] | 147 | 2017-11-19T22:22:09.000Z | 2019-06-24T11:57:40.000Z | foobar_sdk/foobar2000/helpers/packet_decoder_mp3_common.cpp | izilzty/foo_usbhid_m202md28a | b4d6df8baa290fe2ad33c57ec8acd77dcd82500a | [
"Unlicense"
] | 28 | 2018-05-22T19:57:58.000Z | 2019-06-21T23:31:50.000Z | fb2k/foobar2000/helpers/packet_decoder_mp3_common.cpp | hozuki/foo_input_nemuc | 884fc8d7c1af2ac7eb8235cd5691d156109db94a | [
"MIT"
] | 14 | 2017-11-22T01:53:31.000Z | 2019-04-04T18:45:18.000Z | #include "stdafx.h"
#include "packet_decoder_mp3_common.h"
#include "mp3_utils.h"
unsigned packet_decoder_mp3_common::parseDecoderSetup( const GUID & p_owner,t_size p_param1,const void * p_param2,t_size p_param2size )
{
if (p_owner == owner_MP3) return 3;
else if (p_owner == owner_MP2) return 2;
else if (p_owner == owner_MP1) return 1;
else if (p_owner == owner_MP4)
{
switch(p_param1)
{
case 0x6B:
return 3;
break;
case 0x69:
return 3;
break;
default:
return 0;
}
}
else if (p_owner == owner_matroska)
{
if (p_param2size==sizeof(matroska_setup))
{
const matroska_setup * setup = (const matroska_setup*) p_param2;
if (!strcmp(setup->codec_id,"A_MPEG/L3")) return 3;
else if (!strcmp(setup->codec_id,"A_MPEG/L2")) return 2;
else if (!strcmp(setup->codec_id,"A_MPEG/L1")) return 1;
else return 0;
}
else return 0;
}
else return 0;
}
unsigned packet_decoder_mp3_common::layer_from_frame(const void * frame, size_t size) {
using namespace mp3_utils;
TMPEGFrameInfo info;
if (!ParseMPEGFrameHeader(info, frame, size)) throw exception_io_data();
return info.m_layer;
} | 28.795455 | 135 | 0.632202 | jpbattaille |
f3876d43438b47cf5a242d7df5c8da3aa37fa4ad | 29,080 | cpp | C++ | Source/API/D3D12/SwapChainD3D12.cpp | KawBuma/Buma3D | 73b1c7a99c979492f072d4ead89f2d357d5e048a | [
"MIT"
] | 5 | 2020-11-25T05:05:13.000Z | 2022-02-09T09:35:21.000Z | Source/API/D3D12/SwapChainD3D12.cpp | KawBuma/Buma3D | 73b1c7a99c979492f072d4ead89f2d357d5e048a | [
"MIT"
] | 5 | 2020-11-11T09:52:59.000Z | 2021-12-15T13:27:37.000Z | Source/API/D3D12/SwapChainD3D12.cpp | KawBuma/Buma3D | 73b1c7a99c979492f072d4ead89f2d357d5e048a | [
"MIT"
] | null | null | null | #include "Buma3DPCH.h"
#include "SwapChainD3D12.h"
namespace buma3d
{
namespace /*anonymous*/
{
DXGI_USAGE GetNativeBufferFlags(SWAP_CHAIN_BUFFER_FLAGS _flags)
{
DXGI_USAGE result = 0;
if (_flags & SWAP_CHAIN_BUFFER_FLAG_SHADER_RESOURCE)
result |= DXGI_USAGE_SHADER_INPUT;
if (_flags & SWAP_CHAIN_BUFFER_FLAG_COLOR_ATTACHMENT)
result |= DXGI_USAGE_RENDER_TARGET_OUTPUT;
if (_flags & SWAP_CHAIN_BUFFER_FLAG_UNORDERED_ACCESS)
result |= DXGI_USAGE_UNORDERED_ACCESS;
// TODO: GetNativeBufferFlags
//if (_flags & SWAP_CHAIN_BUFFER_FLAG_ALLOW_SIMULTANEOUS_ACCESS)
// result |= ;
return result;
}
DXGI_ALPHA_MODE GetNativeAlphaMode(SWAP_CHAIN_ALPHA_MODE _mode)
{
switch (_mode)
{
case SWAP_CHAIN_ALPHA_MODE_DEFAULT : return DXGI_ALPHA_MODE_UNSPECIFIED;
case SWAP_CHAIN_ALPHA_MODE_IGNORE : return DXGI_ALPHA_MODE_IGNORE;
case SWAP_CHAIN_ALPHA_MODE_STRAIGHT : return DXGI_ALPHA_MODE_STRAIGHT;
case SWAP_CHAIN_ALPHA_MODE_PRE_MULTIPLIED : return DXGI_ALPHA_MODE_STRAIGHT;
default:
break;
}
return DXGI_ALPHA_MODE_UNSPECIFIED;
}
DEFINE_ENUM_FLAG_OPERATORS(DXGI_SWAP_CHAIN_FLAG);
DXGI_SWAP_CHAIN_FLAG GetNativeSwapChainFlags(SWAP_CHAIN_FLAGS _flags)
{
//DXGI_SWAP_CHAIN_FLAG result = (DXGI_SWAP_CHAIN_FLAG)0;
// 以下のフラグはデフォルトで使用します。
DXGI_SWAP_CHAIN_FLAG result = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH | DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
if (_flags & SWAP_CHAIN_FLAG_FULLSCREEN_EXCLUSIVE)
result |= DXGI_SWAP_CHAIN_FLAG_NONPREROTATED;
if (_flags & SWAP_CHAIN_FLAG_DISABLE_VERTICAL_SYNC)
result |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING;
if (_flags & SWAP_CHAIN_FLAG_PROTECT_CONTENTS)
result |= DXGI_SWAP_CHAIN_FLAG_HW_PROTECTED;
return result;
}
}
B3D_APIENTRY SwapChainD3D12::SwapChainD3D12()
: ref_count { 1 }
, name {}
, desc {}
, desc_data {}
, surface {}
, device {}
, present_queues {}
, present_queues_head {}
, swapchain_buffers {}
, current_buffer_index {}
, is_enabled_fullscreen {}
, swapchain {}
, prev_present_completion_event {}
, present_info {}
, fences_data {}
, is_acquired {}
{
}
B3D_APIENTRY SwapChainD3D12::~SwapChainD3D12()
{
Uninit();
}
BMRESULT
B3D_APIENTRY SwapChainD3D12::Init(DeviceD3D12* _device, const SWAP_CHAIN_DESC& _desc)
{
(device = _device)->AddRef();
fences_data = B3DNewArgs(SWAPCHAIN_FENCES_DATA);
B3D_RET_IF_FAILED(CopyDesc(_desc));
B3D_RET_IF_FAILED(CheckValidity());
B3D_RET_IF_FAILED(CreateDXGISwapChain());
B3D_RET_IF_FAILED(PreparePresentInfo());
B3D_RET_IF_FAILED(GetSwapChainBuffers());
return BMRESULT_SUCCEED;
}
BMRESULT
B3D_APIENTRY SwapChainD3D12::CopyDesc(const SWAP_CHAIN_DESC& _desc)
{
desc = _desc;
// _desc.present_queuesに全て同じキューが指定されている場合通常のスワップチェインとして扱う
if (_desc.num_present_queues > 1)
{
uint32_t same_queue_count = 0;
ICommandQueue* queue0 = _desc.present_queues[0];
for (uint32_t i = 0; i < _desc.num_present_queues; i++)
{
if (_desc.present_queues[i] == queue0)
same_queue_count++;
}
if (_desc.num_present_queues == same_queue_count)
{
desc.num_present_queues = 1;
B3D_ADD_DEBUG_MSG(DEBUG_MESSAGE_SEVERITY_WARNING, DEBUG_MESSAGE_CATEGORY_FLAG_INITIALIZATION
, "SWAP_CHAIN_DESC::present_queuesの全ての要素に同一のコマンドキューが指定されています。SWAP_CHAIN_DESC::num_present_queuesは1に設定されました。");
}
}
hlp::SafeRelease(surface);
(surface = _desc.surface->As<SurfaceD3D12>())->AddRef();
// コマンドキューをキャッシュ
if (_desc.present_queues == RCAST<ICommandQueue**>(present_queues_head)&&
_desc.buffer.count == (uint32_t)present_queues.size())
{
// Recreateの場合にGetDescから返された値が使用され、バックバッファ数に変更がない場合、何もしません。
}
else
{
util::DyArray<CommandQueueD3D12*> present_queues_tmp(_desc.buffer.count);
auto present_queues_tmp_data = present_queues_tmp.data();
for (uint32_t i = 0; i < _desc.buffer.count; i++)
{
// バックバッファの数だけキャッシュするので、num_present_queuesが1の場合インデックス0のキューを複数セットします。
present_queues_tmp_data[i] = _desc.present_queues[_desc.num_present_queues == 1 ? 0 : i]->As<CommandQueueD3D12>();
present_queues_tmp_data[i]->AddRef();
}
// Recreateの場合、以前のコマンドキューを開放
for (auto& i : present_queues)
hlp::SafeRelease(i);
present_queues.swap(present_queues_tmp);
present_queues_head = present_queues.data();
desc.present_queues = RCAST<ICommandQueue**>(present_queues_head);
}
// TEXTURE_FORMAT_DESC
auto&& tfd = desc.buffer.format_desc;
if (util::IsTypelessFormat(tfd.format))
{
auto&& fc = device->GetFormatCompatibilityChecker();
auto dd = B3DMakeUnique(DESC_DATA);
if (tfd.num_mutable_formats == 0)// default
{
dd->mutable_formats = fc.GetTypelessCompatibleFormats().at(tfd.format)->compatible_formats;
dd->is_shared_from_typeless_compatible_formats = true;
}
else
{
auto&& f = fc.CheckCompatibility(tfd);
if (f == nullptr)
{
B3D_ADD_DEBUG_MSG(DEBUG_MESSAGE_SEVERITY_ERROR, DEBUG_MESSAGE_CATEGORY_FLAG_INITIALIZATION
, "TEXTURE_FORMAT_DESC::mutable_formatsに、TYPELESSフォーマットと互換性が無い、または現在のデバイスでは対応していないフォーマットが含まれています。");
return BMRESULT_FAILED_INVALID_PARAMETER;
}
auto&& mf = dd->mutable_formats = B3DMakeShared(util::DyArray<RESOURCE_FORMAT>);
dd->is_shared_from_typeless_compatible_formats = false;
mf->resize(tfd.num_mutable_formats);
util::MemCopyArray(mf->data(), tfd.mutable_formats, tfd.num_mutable_formats);
}
dd.swap(desc_data);
tfd.mutable_formats = desc_data->mutable_formats->data();
}
else
{
tfd.num_mutable_formats = 0;
tfd.mutable_formats = nullptr;
}
return BMRESULT_SUCCEED;
}
BMRESULT
B3D_APIENTRY SwapChainD3D12::CheckValidity()
{
// プレゼント操作のサポートを確認
{
size_t index = 0;
auto adapter = device->GetDeviceAdapter();
for (auto& i : present_queues)
{
if (hlp::IsFailed(adapter->QueryPresentationSupport(i->GetDesc().type, surface)))
{
B3D_ADD_DEBUG_MSG2(DEBUG_MESSAGE_SEVERITY_ERROR, DEBUG_MESSAGE_CATEGORY_FLAG_INITIALIZATION
, __FUNCTION__": SWAP_CHAIN_DESC::present_queues[", index, "]はプレゼント操作をサポートしていません。");
return BMRESULT_FAILED_INVALID_PARAMETER;
}
index++;
}
}
// NOTE: D3D12では、FLIPスワップ効果が必須で、加えてFLIPスワップ効果を使用する場合DXGI_SWAP_CHAIN_DESC1::BufferCountに少なくとも2以上の値が必要です。
if (desc.buffer.count < 2)
{
B3D_ADD_DEBUG_MSG(DEBUG_MESSAGE_SEVERITY_ERROR, DEBUG_MESSAGE_CATEGORY_FLAG_INITIALIZATION
, __FUNCTION__": SWAP_CHAIN_BUFFER_DESC::countは少なくとも2以上である必要があります。");
return BMRESULT_FAILED_INVALID_PARAMETER;
}
// 排他フルスクリーンのサポートを確認
if (desc.flags & SWAP_CHAIN_FLAG_FULLSCREEN_EXCLUSIVE &&
desc.flags & SWAP_CHAIN_FLAG_DISABLE_VERTICAL_SYNC)
{
B3D_ADD_DEBUG_MSG(DEBUG_MESSAGE_SEVERITY_ERROR, DEBUG_MESSAGE_CATEGORY_FLAG_INITIALIZATION
, __FUNCTION__": 現在の内部APIでは、排他フルスクリーン機能を有効にする場合SWAP_CHAIN_FLAG_DISABLE_VERTICAL_SYNCが指定されない必要があります。");
return BMRESULT_FAILED_INVALID_PARAMETER;
}
return BMRESULT_SUCCEED;
}
BMRESULT
B3D_APIENTRY SwapChainD3D12::CreateDXGISwapChain()
{
// Recreateの場合以前のバッファを開放し破棄
if (swapchain)
{
// スワップチェーンを破棄前にフルスクリーンを解除
auto hr = swapchain->SetFullscreenState(FALSE, nullptr);
B3D_RET_IF_FAILED(HR_TRACE_IF_FAILED(hr));
is_enabled_fullscreen = false;
// NOTE: D3D12ではスワップチェーン作成時に渡すhWnd毎に1つ以上のスワップチェインを作成出来ずエラーとなるので予め破棄します。
auto count = swapchain->Release();
B3D_ASSERT(count == 0 && __FUNCTION__": swapchain->Release() != 0");
swapchain = nullptr;
}
desc.buffer.flags |= SWAP_CHAIN_BUFFER_FLAG_COPY_SRC | SWAP_CHAIN_BUFFER_FLAG_COPY_DST;
DXGI_SWAP_CHAIN_DESC1 scdesc{};
scdesc.Width = desc.buffer.width;
scdesc.Height = desc.buffer.height;
scdesc.Format = util::GetNativeFormat(desc.buffer.format_desc.format);
scdesc.Stereo = FALSE;
scdesc.SampleDesc.Count = 1;
scdesc.SampleDesc.Quality = 0;
scdesc.BufferUsage = GetNativeBufferFlags(desc.buffer.flags);
scdesc.BufferCount = desc.buffer.count;
scdesc.Scaling = DXGI_SCALING_NONE;
scdesc.SwapEffect = desc.flags & SWAP_CHAIN_FLAG_ALLOW_DISCARD_AFTER_PRESENT ? DXGI_SWAP_EFFECT_FLIP_DISCARD : DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
scdesc.AlphaMode = GetNativeAlphaMode(desc.alpha_mode);
scdesc.Flags = GetNativeSwapChainFlags(desc.flags);
DXGI_SWAP_CHAIN_FULLSCREEN_DESC fsdesc{};
fsdesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
fsdesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
fsdesc.Windowed = desc.flags & SWAP_CHAIN_FLAG_FULLSCREEN_EXCLUSIVE ? FALSE : TRUE;
// TODO: ストアアプリの対応。
// スワップチェインの作成
auto hwnd = RCAST<HWND>(RCAST<const SURFACE_PLATFORM_DATA_WINDOWS*>(desc.surface->GetDesc().platform_data.data)->hwnd);
util::ComPtr<IDXGISwapChain1> sc;
auto&& f = device->GetDeviceFactory()->GetDXGIFactory();
auto hr = f->CreateSwapChainForHwnd(desc.present_queues[0]->As<CommandQueueD3D12>()->GetD3D12CommandQueue()
, hwnd
, &scdesc, &fsdesc
, nullptr/*出力先を制限しない。TODO: 共通化可能な機能を見つける。*/
, &sc);
B3D_RET_IF_FAILED(HR_TRACE_IF_FAILED(hr));
// プリローテーション
if (!(desc.flags & SWAP_CHAIN_FLAG_FULLSCREEN_EXCLUSIVE))
{
// SetRotationを使用できるのは、ウィンドウモードで表示するフリップモデルスワップチェーンのバックバッファーを回転する場合のみです。
hr = sc->SetRotation(util::GetNativeRotationMode(desc.pre_roration));
B3D_RET_IF_FAILED(HR_TRACE_IF_FAILED(hr));
}
// DXGI側が、hwndを所有するアプリケーションのメッセージキューを監視しないようにする
{
util::ComPtr<IDXGIFactory2> sc_parent;
hr = sc->GetParent(IID_PPV_ARGS(&sc_parent));
B3D_RET_IF_FAILED(HR_TRACE_IF_FAILED(hr));
hr = sc_parent->MakeWindowAssociation(hwnd, DXGI_MWA_NO_WINDOW_CHANGES | DXGI_MWA_NO_ALT_ENTER | DXGI_MWA_NO_PRINT_SCREEN);
B3D_RET_IF_FAILED(HR_TRACE_IF_FAILED(hr));
}
// IDXGISwapChain4を取得
hr = sc->QueryInterface(&swapchain);
B3D_RET_IF_FAILED(HR_TRACE_IF_FAILED(hr));
// 色空間は作成時から固定する
hr = swapchain->SetColorSpace1(util::GetNativeColorSpace(desc.color_space));
B3D_RET_IF_FAILED(HR_TRACE_IF_FAILED(hr));
// フレームレイテンシ
if (desc.flags & SWAP_CHAIN_FLAG_DISABLE_VERTICAL_SYNC)
{
hr = swapchain->SetMaximumFrameLatency(desc.buffer.count);
}
else
{
// 垂直同期が有効の場合、フレームレイテンシは1に設定します。
// 直近のPresent操作をIDXGISwapChain::Present1前に待機します。
hr = swapchain->SetMaximumFrameLatency(1);
}
B3D_RET_IF_FAILED(HR_TRACE_IF_FAILED(hr));
prev_present_completion_event = swapchain->GetFrameLatencyWaitableObject();
// 排他フルスクリーン
if (desc.flags & SWAP_CHAIN_FLAG_FULLSCREEN_EXCLUSIVE)
{
hr = sc->SetFullscreenState(TRUE, nullptr/*出力先はデフォルト*/);
B3D_RET_IF_FAILED(HR_TRACE_IF_FAILED(hr));
is_enabled_fullscreen = true;
}
// 複数ノードを用いたプレゼント操作
if (desc.num_present_queues > 1)
{
// ノードマスクを取得
util::DyArray<NodeMask> queue_node_masks(desc.buffer.count);
NodeMask* queue_node_masks_head = queue_node_masks.data();
for (uint32_t i = 0; i < desc.buffer.count; i++)
{
auto&& present_queue_index = std::min(i, desc.num_present_queues);
auto mask = present_queues_head[present_queue_index]->GetDesc().node_mask;
queue_node_masks_head[i] = mask;
}
// D3D12コマンドキューを取得
util::DyArray<ID3D12CommandQueue*> q12(desc.buffer.count);
auto q12_data = q12.data();
for (uint32_t i = 0; i < desc.buffer.count; i++)
{
auto&& present_queue_index = std::min(i, desc.num_present_queues);
q12_data[i] = present_queues_head[present_queue_index]->GetD3D12CommandQueue();
}
// NOTE: null以外のpCreationNodeMask配列でResizeBuffers1を使用して作成されたバッファーはすべてのノードに可視(visible)です。(visibleNodeMaskの(デバイスに含まれるノード数の範囲内の)ビットが全て有効)
hr = swapchain->ResizeBuffers1(scdesc.BufferCount
, scdesc.Width, scdesc.Height
, scdesc.Format
, scdesc.Flags
, queue_node_masks_head, RCAST<IUnknown**>(q12_data));
B3D_RET_IF_FAILED(HR_TRACE_IF_FAILED(hr));
}
else if (is_enabled_fullscreen)
{
// NOTE: Full-Screen Issues: https://docs.microsoft.com/en-us/windows/win32/direct3darticles/dxgi-best-practices#full-screen-issues
hr = swapchain->ResizeBuffers(scdesc.BufferCount
, scdesc.Width, scdesc.Height
, scdesc.Format
, scdesc.Flags);
B3D_RET_IF_FAILED(HR_TRACE_IF_FAILED(hr));
}
return BMRESULT_SUCCEED;
}
BMRESULT
B3D_APIENTRY SwapChainD3D12::PreparePresentInfo()
{
if (desc.flags & SWAP_CHAIN_FLAG_DISABLE_VERTICAL_SYNC)
{
present_info.flags |= DXGI_PRESENT_ALLOW_TEARING;
present_info.sync_interval = 0; // 垂直同期を行わない。
present_info.params = {}; // 矩形は指定不可。
}
else
{
// DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT フラグが指定されたスワップチェインでは、垂直同期の待機が FrameLatencyWaitableObject にオフロードされます。
// DXGI_PRESENT_DO_NOT_WAIT フラグは上記の動作によって無効化されます。
present_info.sync_interval = 1;
if (present_info.dirty_rects.empty())
present_info.dirty_rects.resize(3); // default
present_info.params = {}; // 矩形を指定可能。
present_info.params.pDirtyRects = present_info.dirty_rects.data();
}
auto&& fd = *fences_data;
fd.dummy_fence_value = 0;
fd.fence_submit.num_fences = 1;
fd.fence_submit.fence_values = &fd.dummy_fence_value;
B3D_RET_IF_FAILED(fd.ResizeFences(device, desc.buffer.count));
return BMRESULT_SUCCEED;
}
BMRESULT
B3D_APIENTRY SwapChainD3D12::GetSwapChainBuffers()
{
swapchain_buffers.resize(desc.buffer.count);
auto b3d_buffers = swapchain_buffers.data();
for (uint32_t i = 0; i < desc.buffer.count; i++)
{
util::ComPtr<ID3D12Resource> buffer;
auto hr = swapchain->GetBuffer(i, IID_PPV_ARGS(&buffer));
B3D_RET_IF_FAILED(HR_TRACE_IF_FAILED(hr));
B3D_RET_IF_FAILED(TextureD3D12::CreateForSwapChain(this, buffer, &b3d_buffers[i]));
}
current_buffer_index = swapchain->GetCurrentBackBufferIndex();
return BMRESULT_SUCCEED;
}
BMRESULT
B3D_APIENTRY SwapChainD3D12::ReleaseSwapChainBuffers()
{
//if (is_acquired)
//{
// B3D_ADD_DEBUG_MSG2(DEBUG_MESSAGE_SEVERITY_ERROR, DEBUG_MESSAGE_CATEGORY_FLAG_CLEANUP
// , __FUNCTION__": スワップチェインを再作成、または破棄する前に、AcquireNextBufferから取得したバックバッファのプレゼントを完了する必要があります。");
// return BMRESULT_FAILED_INVALID_CALL;
//}
size_t count = 0;
BMRESULT bmr = BMRESULT_SUCCEED;
for (auto& i : swapchain_buffers)
{
auto rc = i->GetRefCount();
if (rc != 1)
{
B3D_ADD_DEBUG_MSG2(DEBUG_MESSAGE_SEVERITY_ERROR, DEBUG_MESSAGE_CATEGORY_FLAG_CLEANUP
, __FUNCTION__": バックバッファ [", count, "]はまだ参照されています(カウント数: ", (rc - 1)
, ")。 スワップチェーンが破棄または再作成される前に、GetBuffers()から取得した全てのバッファは解放されている必要があります。");
bmr = BMRESULT_FAILED_INVALID_CALL;
}
count++;
}
if (hlp::IsSucceed(bmr))
{
for (auto& i : swapchain_buffers)
{
i->Release();
i = nullptr;
}
swapchain_buffers.clear();
}
return bmr;
}
void
B3D_APIENTRY SwapChainD3D12::Uninit()
{
if (prev_present_completion_event != NULL)
CloseHandle(prev_present_completion_event);
prev_present_completion_event = NULL;
ReleaseSwapChainBuffers();
hlp::SwapClear(swapchain_buffers);
present_info = {};
B3DSafeDelete(fences_data)
hlp::SafeRelease(swapchain);
is_enabled_fullscreen = {};
current_buffer_index = {};
desc_data.reset();
desc = {};
for (auto& i : present_queues)
hlp::SafeRelease(i);
present_queues_head = {};
hlp::SafeRelease(surface);
hlp::SafeRelease(device);
name.reset();
}
BMRESULT
B3D_APIENTRY SwapChainD3D12::Create(DeviceD3D12* _device, const SWAP_CHAIN_DESC& _desc, SwapChainD3D12** _dst)
{
util::Ptr<SwapChainD3D12> ptr;
ptr.Attach(B3DCreateImplementationClass(SwapChainD3D12));
B3D_RET_IF_FAILED(ptr->Init(_device, _desc));
*_dst = ptr.Detach();
return BMRESULT_SUCCEED;
}
void
B3D_APIENTRY SwapChainD3D12::AddRef()
{
++ref_count;
B3D_REFCOUNT_DEBUG(ref_count);
}
uint32_t
B3D_APIENTRY SwapChainD3D12::Release()
{
B3D_REFCOUNT_DEBUG(ref_count - 1);
auto count = --ref_count;
if (count == 0)
B3DDestroyImplementationClass(this);
return count;
}
uint32_t
B3D_APIENTRY SwapChainD3D12::GetRefCount() const
{
return ref_count;
}
const char*
B3D_APIENTRY SwapChainD3D12::GetName() const
{
return name ? name->c_str() : nullptr;
}
BMRESULT
B3D_APIENTRY SwapChainD3D12::SetName(const char* _name)
{
if (!util::IsEnabledDebug(this))
return BMRESULT_FAILED;
if (swapchain)
{
auto hr = D3D_SET_OBJECT_NAME_W(swapchain, hlp::to_wstring(_name).c_str());
B3D_RET_IF_FAILED(HR_TRACE_IF_FAILED(hr));
}
if (name && !_name)
name.reset();
else
name = B3DMakeUniqueArgs(util::NameableObjStr, _name);
return BMRESULT_SUCCEED;
}
IDevice*
B3D_APIENTRY SwapChainD3D12::GetDevice() const
{
return device;
}
const SWAP_CHAIN_DESC&
B3D_APIENTRY SwapChainD3D12::GetDesc() const
{
return desc;
}
BMRESULT
B3D_APIENTRY SwapChainD3D12::GetBuffer(uint32_t _buffer_idnex, ITexture** _dst)
{
if (_buffer_idnex >= desc.buffer.count)
return BMRESULT_FAILED_OUT_OF_RANGE;
(*_dst = swapchain_buffers.data()[_buffer_idnex])->AddRef();
return BMRESULT_SUCCEED;
}
BMRESULT
B3D_APIENTRY SwapChainD3D12::AcquireNextBuffer(const SWAP_CHAIN_ACQUIRE_NEXT_BUFFER_INFO& _info, uint32_t* _buffer_index)
{
if (is_acquired)
{
B3D_ADD_DEBUG_MSG(DEBUG_MESSAGE_SEVERITY_ERROR, DEBUG_MESSAGE_CATEGORY_FLAG_EXECUTION
, __FUNCTION__": 以前にAcquireNextBufferが呼び出されてから、プレゼント操作が実行されていません。 次のバックバッファインデックスを取得するにはISwapChain::Presentを呼び出す必要があります。");
return BMRESULT_FAILED_INVALID_CALL;
}
if (util::IsEnabledDebug(this))
{
if (!(_info.signal_fence || _info.signal_fence_to_cpu))
{
B3D_ADD_DEBUG_MSG(DEBUG_MESSAGE_SEVERITY_ERROR, DEBUG_MESSAGE_CATEGORY_FLAG_EXECUTION, __FUNCTION__": _info.signal_fenceとsignal_fence_to_cpuの両方がnullptrであってはなりません。");
return BMRESULT_FAILED_INVALID_PARAMETER;
}
if (_info.signal_fence && _info.signal_fence->GetDesc().type != FENCE_TYPE_BINARY_GPU_TO_GPU)
{
B3D_ADD_DEBUG_MSG(DEBUG_MESSAGE_SEVERITY_ERROR, DEBUG_MESSAGE_CATEGORY_FLAG_EXECUTION, __FUNCTION__": _info.signal_fence はFENCE_TYPE_BINARY_GPU_TO_GPUである必要があります。");
return BMRESULT_FAILED_INVALID_PARAMETER;
}
if (_info.signal_fence_to_cpu && _info.signal_fence_to_cpu->GetDesc().type != FENCE_TYPE_BINARY_GPU_TO_CPU)
{
B3D_ADD_DEBUG_MSG(DEBUG_MESSAGE_SEVERITY_ERROR, DEBUG_MESSAGE_CATEGORY_FLAG_EXECUTION, __FUNCTION__": _info.signal_fence_to_cpu はFENCE_TYPE_BINARY_GPU_TO_CPUである必要があります。");
return BMRESULT_FAILED_INVALID_PARAMETER;
}
}
/* NOTE: SwapPayloadについて
引数のシグナルフェンスにスワップチェインフェンスとその時のフェンス値を渡します。
引数のシグナルフェンスのペイロード(impl)をスワップして、自身(スワップチェインのフェンスペイロード)が元のペイロードであるかのように擬態します。この時元のペイロードは保持しておきます。
これにより、引数のシグナルフェンスへスワップチェインフェンスのシグナルをクローンすることが可能です。次に、Reset時またはWait時に元のペイロードに再び戻します。
D3D12フェンスの特徴として、全て値ベース(TIMELINE)であり、スワップチェインのフェンスペイロードを複数のフェンスにクローンしてもWaitまたはResetによる非シグナル化は実際には発生しません。
これにより、クローン時のシグナル値のみ保持しておけば、スワップチェインフェンスのシグナルを複数FenceD3D12に共有し、それぞれが任意のシグナル値で待機できます。
問題としては、スワップチェインのフェンスを保持したフェンスが存在したままISwapChainが開放されてしまった場合があります。
ペイロードはISwapChainが保有するため、ISwapChainが開放される前にペイロードを元に戻す必要があります。
適当に行うならば、ペイロードのスワップ毎に参照カウントを増加させれば良いが、AcquireNextBufferは毎フレーム呼び出される処理のため、このコストは回避すべきです。
内部でこれらを管理するコストが、アプリケーションによってペイロードを元に戻すコストと実装の複雑さを上回るため、新たに制約を追加する必要があります。 (SWAP_CHAIN_ACQUIRE_NEXT_BUFFER_INFO)
別の問題として、グラフィックスAPIをまたぐフェンスのエクスポート、インポートが困難になります。 これについても追加の調査が必要です。
*/
auto next_buffer_index = swapchain->GetCurrentBackBufferIndex();
// Presentでシグナルされたフェンス値を待機
fences_data->SetForWait(next_buffer_index);
auto&& present_complete_fence = fences_data->present_fences_head[next_buffer_index];
auto present_complete_fence_val = fences_data->present_fence_values_head[next_buffer_index];
BMRESULT result = present_complete_fence->Wait(present_complete_fence_val, _info.timeout_millisec);
B3D_RET_IF_FAILED(result);
// 引数のフェンスをプレゼント完了通知用フェンスのペイロードにすり替え
if (_info.signal_fence)
{
auto bmr = _info.signal_fence->As<FenceD3D12>()->SwapPayload(present_complete_fence, present_complete_fence_val);
B3D_RET_IF_FAILED(bmr);
}
if (_info.signal_fence_to_cpu)
{
auto bmr = _info.signal_fence_to_cpu->As<FenceD3D12>()->SwapPayload(present_complete_fence, present_complete_fence_val);
B3D_RET_IF_FAILED(bmr);
}
is_acquired = true;
current_buffer_index = next_buffer_index;
*_buffer_index = next_buffer_index;
return result;
}
BMRESULT
B3D_APIENTRY SwapChainD3D12::Present(const SWAP_CHAIN_PRESENT_INFO& _info)
{
if (!is_acquired)
{
B3D_ADD_DEBUG_MSG(DEBUG_MESSAGE_SEVERITY_ERROR, DEBUG_MESSAGE_CATEGORY_FLAG_EXECUTION
, __FUNCTION__": AcquireNextBufferが呼び出されていません。 プレゼントを実行する前にISwapChain::AcquireNextBufferを呼び出す必要があります。");
return BMRESULT_FAILED_INVALID_CALL;
}
if (_info.wait_fence)
{
if (util::IsEnabledDebug(this))
{
if (_info.wait_fence->GetDesc().type != FENCE_TYPE_BINARY_GPU_TO_GPU)
{
B3D_ADD_DEBUG_MSG(DEBUG_MESSAGE_SEVERITY_ERROR, DEBUG_MESSAGE_CATEGORY_FLAG_EXECUTION, __FUNCTION__": _info.wait_fence はFENCE_TYPE_BINARY_GPU_TO_GPUである必要があります。");
return BMRESULT_FAILED_INVALID_PARAMETER;
}
}
// 引数のフェンス待機操作を送信
auto fence12 = _info.wait_fence->As<FenceD3D12>();
fence12->SubmitWait(present_queues_head[current_buffer_index]->GetD3D12CommandQueue(), nullptr);
}
// 矩形を設定
present_info.Set(_info.num_present_regions, _info.present_regions);
if (!(desc.flags & SWAP_CHAIN_FLAG_DISABLE_VERTICAL_SYNC))
{
// 前のPresent操作が完了するまで、今回のPresent操作をここで待機します。
// 初回フレームの場合に待機を避ける必要はありません: https://docs.microsoft.com/en-us/windows/win32/api/dxgi1_3/nf-dxgi1_3-idxgiswapchain2-getframelatencywaitableobject#:~:text=Note%20that%20this%20requirement%20includes%20the%20first%20frame%20the%20app%20renders%20with%20the%20swap%20chain.
auto wait_result = WaitForSingleObjectEx(prev_present_completion_event, INFINITE, FALSE);
if (wait_result != WAIT_OBJECT_0)
return BMRESULT_FAILED;
}
auto hr = swapchain->Present1(present_info.sync_interval, present_info.flags, &present_info.params);
auto bmr = HR_TRACE_IF_FAILED(hr);
// プレゼント完了通知用フェンスのシグナル操作を送信
fences_data->SetForSignal(current_buffer_index);
present_queues_head[current_buffer_index]->SubmitSignal(fences_data->fence_submit);
is_acquired = false;
return bmr;
}
BMRESULT
B3D_APIENTRY SwapChainD3D12::Recreate(const SWAP_CHAIN_DESC& _desc)
{
B3D_RET_IF_FAILED(ReleaseSwapChainBuffers());
current_buffer_index = 0;
if (prev_present_completion_event)
{
CloseHandle(prev_present_completion_event);
prev_present_completion_event = NULL;
}
B3D_RET_IF_FAILED(CopyDesc(_desc));
B3D_RET_IF_FAILED(CheckValidity());
B3D_RET_IF_FAILED(CreateDXGISwapChain());
B3D_RET_IF_FAILED(PreparePresentInfo());
B3D_RET_IF_FAILED(GetSwapChainBuffers());
return BMRESULT_SUCCEED;
}
BMRESULT
B3D_APIENTRY SwapChainD3D12::SetHDRMetaData(const SWAP_CHAIN_HDR_METADATA& _metadata)
{
DXGI_HDR_METADATA_HDR10 metadata = {
{ SCAST<UINT16>(50000.f * _metadata.primary_red.x) , SCAST<UINT16>(50000.f * _metadata.primary_red.y) } // RedPrimary[2]
, { SCAST<UINT16>(50000.f * _metadata.primary_green.x), SCAST<UINT16>(50000.f * _metadata.primary_green.y) } // GreenPrimary[2]
, { SCAST<UINT16>(50000.f * _metadata.primary_blue.x) , SCAST<UINT16>(50000.f * _metadata.primary_blue.y) } // BluePrimary[2]
, { SCAST<UINT16>(50000.f * _metadata.white_point.x) , SCAST<UINT16>(50000.f * _metadata.white_point.y) } // WhitePoint[2]
, SCAST<UINT> (10000.f * _metadata.max_luminance) // MaxMasteringLuminance
, SCAST<UINT> (10000.f * _metadata.min_luminance) // MinMasteringLuminance
, SCAST<UINT16>(_metadata.max_content_light_level) // MaxContentLightLevel
, SCAST<UINT16>(_metadata.max_frame_average_light_level) // MaxFrameAverageLightLevel
};
auto hr = swapchain->SetHDRMetaData(DXGI_HDR_METADATA_TYPE_HDR10, sizeof(metadata), &metadata);
B3D_RET_IF_FAILED(HR_TRACE_IF_FAILED(hr));
return BMRESULT_SUCCEED;
}
IDXGISwapChain4*
B3D_APIENTRY SwapChainD3D12::GetDXGISwapChain() const
{
return swapchain;
}
void SwapChainD3D12::PRESENT_INFO::Set(size_t _num_rects, const SCISSOR_RECT* _rects)
{
if (_num_rects > dirty_rects.size())
{
dirty_rects.resize(_num_rects);
params.pDirtyRects = dirty_rects.data();
}
params.DirtyRectsCount = (UINT)_num_rects;
for (uint32_t i = 0; i < _num_rects; i++)
{
util::ConvertNativeScissorRect(_rects[i], ¶ms.pDirtyRects[i]);
}
}
SwapChainD3D12::SWAPCHAIN_FENCES_DATA::~SWAPCHAIN_FENCES_DATA()
{
for (auto& i : present_fences)
hlp::SafeRelease(i);
present_fences = {};
present_fences_head = {};
fence_submit = {};
dummy_fence_value = {};
present_fence_values = {};
present_fence_values_head = {};
}
void SwapChainD3D12::SWAPCHAIN_FENCES_DATA::SetForSignal(uint32_t _current_buffer_index)
{
fence_submit.fences = RCAST<IFence**>(present_fences_head + _current_buffer_index);
fence_submit.fence_values = &(++present_fence_values_head[_current_buffer_index]);
}
void SwapChainD3D12::SWAPCHAIN_FENCES_DATA::SetForWait(uint32_t _current_buffer_index)
{
fence_submit.fences = RCAST<IFence**>(present_fences_head + _current_buffer_index);
fence_submit.fence_values = &present_fence_values_head[_current_buffer_index];
}
BMRESULT SwapChainD3D12::SWAPCHAIN_FENCES_DATA::ResizeFences(DeviceD3D12* _device, uint32_t _buffer_count)
{
auto prev_size = (uint32_t)present_fences.size();
if (_buffer_count > prev_size)
{
fence_results .resize(_buffer_count, BMRESULT_SUCCEED_NOT_READY);
present_fences .resize(_buffer_count);
present_fence_values .resize(_buffer_count);
fence_results_head = fence_results .data();
present_fences_head = present_fences .data();
present_fence_values_head = present_fence_values.data();
FENCE_DESC fdesc{ FENCE_TYPE_TIMELINE, 0 ,FENCE_FLAG_NONE };
for (size_t i = prev_size; i < _buffer_count; i++)
{
util::Ptr<FenceD3D12> f;
B3D_RET_IF_FAILED(FenceD3D12::Create(_device, fdesc, &f, /*for swapchain*/true));
present_fences_head[i] = f.Detach();
}
}
return BMRESULT_SUCCEED;
}
}// namespace buma3d
| 35.856967 | 277 | 0.676135 | KawBuma |
f38c23aae6c334dab4632f2c183a401cd169e464 | 106 | cpp | C++ | qt_course/examples/01_trivial/01_hello_console/main.cpp | matus-chochlik/various | 2a9f5eddd964213f7d1e1ce8328e2e0b2a8e998b | [
"MIT"
] | 1 | 2020-10-25T12:28:50.000Z | 2020-10-25T12:28:50.000Z | qt_course/examples/01_trivial/01_hello_console/main.cpp | matus-chochlik/various | 2a9f5eddd964213f7d1e1ce8328e2e0b2a8e998b | [
"MIT"
] | null | null | null | qt_course/examples/01_trivial/01_hello_console/main.cpp | matus-chochlik/various | 2a9f5eddd964213f7d1e1ce8328e2e0b2a8e998b | [
"MIT"
] | null | null | null | #include <QTextStream>
int main(void)
{
QTextStream(stdout) << "Hello, console!" << endl;
return 0;
}
| 13.25 | 50 | 0.650943 | matus-chochlik |
f38c375991b9e958cc50caeee3781df7ce52eda5 | 1,951 | cpp | C++ | microNode/libraries/FRAM/fram.cpp | loranodes/arduino-core | 256eaf15e8a6bef67174fb162c54f1c73854c11c | [
"MIT"
] | null | null | null | microNode/libraries/FRAM/fram.cpp | loranodes/arduino-core | 256eaf15e8a6bef67174fb162c54f1c73854c11c | [
"MIT"
] | null | null | null | microNode/libraries/FRAM/fram.cpp | loranodes/arduino-core | 256eaf15e8a6bef67174fb162c54f1c73854c11c | [
"MIT"
] | null | null | null | #include "Arduino.h"
#include "fram.h"
#include "Wire.h"
void FRAMinit(){
Wire.begin();
}
void FRAMwrite(uint16_t address, uint8_t data){
Wire.beginTransmission(pageAddress(address));
Wire.write(wordAddress(address));
Wire.write(data);
Wire.endTransmission(true);
}
void FRAMwriteblock(uint16_t startAddress, uint8_t data[], uint16_t length){
Wire.beginTransmission(pageAddress(startAddress));
Wire.write(wordAddress(startAddress));
Wire.write(data, length);
Wire.endTransmission(true);
}
uint8_t FRAMread(uint16_t address){
Wire.beginTransmission(pageAddress(address));
Wire.write(wordAddress(address));
Wire.endTransmission(false);
Wire.requestFrom(pageAddress(address), 1);
uint8_t data = Wire.read();
return data;
}
void FRAMreadblock(uint16_t startAddress, uint8_t buffer[], uint16_t number){
Wire.beginTransmission(pageAddress(startAddress));
Wire.write(wordAddress(startAddress));
Wire.endTransmission(false);
Wire.requestFrom(pageAddress(startAddress), number);
for(int i = 0; i < number; i++){
buffer[i] = Wire.read();
}
}
void FRAMpack(uint16_t address, void* data, uint8_t len){
Wire.beginTransmission(pageAddress(address));
Wire.write(wordAddress(address));
Wire.write((uint8_t*)data, len);
Wire.endTransmission(true);
}
uint8_t FRAMunpack(uint16_t address, void* data, uint8_t len){
uint8_t rc;
uint8_t *p = (uint8_t*)data;
Wire.beginTransmission(pageAddress(address));
Wire.write(wordAddress(address));
Wire.endTransmission(false);
Wire.requestFrom(pageAddress(address), len);
for(rc = 0, p; rc < len ; rc++, p++){
*p = (uint8_t)Wire.read();
}
return rc;
}
uint8_t pageAddress(uint16_t dataAddress){
uint8_t page = dataAddress >> 8;
return (BASEADDR | page);
}
uint8_t wordAddress(uint16_t dataAddress){
return (dataAddress & 0b11111111);
}
| 20.978495 | 77 | 0.689903 | loranodes |
f38ea185dffc2d98f18b3a6f76d766369afc1af5 | 393 | cpp | C++ | GPM/MathTestProject/src/main.cpp | Hukunaa/GPM_Maths_Library | 7b2515a6a5fec5bfe213e1d503d4607c753e9cf3 | [
"MIT"
] | null | null | null | GPM/MathTestProject/src/main.cpp | Hukunaa/GPM_Maths_Library | 7b2515a6a5fec5bfe213e1d503d4607c753e9cf3 | [
"MIT"
] | null | null | null | GPM/MathTestProject/src/main.cpp | Hukunaa/GPM_Maths_Library | 7b2515a6a5fec5bfe213e1d503d4607c753e9cf3 | [
"MIT"
] | null | null | null | #include <iostream>
#include <GPM/GPM.h>
int main(const int p_argc, char** p_argv)
{
try
{
// Try stuff here
Matrix4F rot = GPM::Matrix4F::LookAt(GPM::Vector3F(0, 0, 0), GPM::Vector3F(0, 0, 3), GPM::Vector3F(0, 1, 0));
std::cout << rot;
}
catch (const std::exception & e)
{
std::cerr << "Exception thrown: " << e.what() << '\n';
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
} | 20.684211 | 111 | 0.615776 | Hukunaa |
f38ff80ab6fed64a9b95d6412c4a20cd785a495e | 379 | cpp | C++ | code/nastyhacks.cpp | matthewReff/Kattis-Problems | 848628af630c990fb91bde6256a77afad6a3f5f6 | [
"MIT"
] | 8 | 2020-02-21T22:21:01.000Z | 2022-02-16T05:30:54.000Z | code/nastyhacks.cpp | matthewReff/Kattis-Problems | 848628af630c990fb91bde6256a77afad6a3f5f6 | [
"MIT"
] | null | null | null | code/nastyhacks.cpp | matthewReff/Kattis-Problems | 848628af630c990fb91bde6256a77afad6a3f5f6 | [
"MIT"
] | 3 | 2020-08-05T05:42:35.000Z | 2021-08-30T05:39:51.000Z | #include <iostream>
#include <string>
using namespace std;
int main(){
int dataSets = 0;
int rev, exp, adv;
cin >> dataSets;
for (int i = 0; i < dataSets; i++){
cin >> rev >> exp >> adv;
if (rev > (exp - adv)){
cout << "do not advertise\n";
}
else if (rev == (exp - adv)){
cout << "does not matter\n";
}
else{
cout << "advertise\n";
}
}
return 0;
} | 16.478261 | 36 | 0.540897 | matthewReff |
f3941ed6817872126382884d637645ecee3207a7 | 57,751 | cpp | C++ | ros/src/util/packages/kitti_pkg/kitti_player/src/kitti_player.cpp | filiperinaldi/Autoware | 9fae6cc7cb8253586578dbb62a2f075b52849e6e | [
"Apache-2.0"
] | 64 | 2018-11-19T02:34:05.000Z | 2021-12-27T06:19:48.000Z | ros/src/util/packages/kitti_pkg/kitti_player/src/kitti_player.cpp | anhnv3991/autoware | d5b2ed9dc309193c8a2a7c77a2b6c88104c28328 | [
"Apache-2.0"
] | 18 | 2019-04-08T16:09:37.000Z | 2019-06-05T15:24:40.000Z | ros/src/util/packages/kitti_pkg/kitti_player/src/kitti_player.cpp | anhnv3991/autoware | d5b2ed9dc309193c8a2a7c77a2b6c88104c28328 | [
"Apache-2.0"
] | 34 | 2018-11-27T08:57:32.000Z | 2022-02-18T08:06:04.000Z | // redmine usage: This commit refs #388 @2h
// ###############################################################################################
// ###############################################################################################
// ###############################################################################################
/*
* KITTI_PLAYER v2.
*
* Augusto Luis Ballardini, [email protected]
*
* https://github.com/iralabdisco/kitti_player
*
* WARNING: this package is using some C++11
*
*/
// ###############################################################################################
// ###############################################################################################
// ###############################################################################################
#include <iostream>
#include <fstream>
#include <limits>
#include <sstream>
#include <string>
#include <ros/ros.h>
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
//#include <boost/locale.hpp>
#include <boost/program_options.hpp>
#include <boost/progress.hpp>
#include <boost/tokenizer.hpp>
#include <boost/tokenizer.hpp>
#include <cv_bridge/cv_bridge.h>
#include <image_transport/image_transport.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <sensor_msgs/distortion_models.h>
#include <sensor_msgs/image_encodings.h>
#include <sensor_msgs/Imu.h>
#include <sensor_msgs/NavSatFix.h>
#include <sensor_msgs/PointCloud2.h>
#include <stereo_msgs/DisparityImage.h>
#include <tf/LinearMath/Transform.h>
#include <tf/transform_broadcaster.h>
#include <tf/transform_listener.h>
#include <time.h>
/// EXTRA messages, not from KITTI
/// Inser here further detectors & features to be published
//#include <road_layout_estimation/msg_lines.h>
//#include <road_layout_estimation/msg_lineInfo.h>
using namespace std;
using namespace pcl;
using namespace ros;
using namespace tf;
namespace po = boost::program_options;
struct kitti_player_options
{
string path;
float frequency; // publisher frequency. 1 > Kitti default 10Hz
bool all_data; // publish everything
bool velodyne; // publish velodyne point clouds /as PCL
bool gps; // publish GPS sensor_msgs/NavSatFix message
bool imu; // publish IMU sensor_msgs/Imu Message message
bool grayscale; // publish
bool color; // publish
bool viewer; // enable CV viewer
bool timestamps; // use KITTI timestamps;
bool sendTransform; // publish velodyne TF IMU 3DOF orientation wrt fixed frame
bool stereoDisp; // use precalculated stereoDisparities
bool viewDisparities; // view use precalculated stereoDisparities
unsigned int startFrame; // start the replay at frame ...
/// Extra parameters
bool laneDetections; // send laneDetections;
};
/**
* @brief publish_velodyne
* @param pub The ROS publisher as reference
* @param infile file with data to publish
* @param header Header to use to publish the message
* @return 1 if file is correctly readed, 0 otherwise
*/
int publish_velodyne(ros::Publisher &pub, string infile, std_msgs::Header *header)
{
fstream input(infile.c_str(), ios::in | ios::binary);
if(!input.good())
{
ROS_ERROR_STREAM ( "Could not read file: " << infile );
return 0;
}
else
{
ROS_DEBUG_STREAM ("reading " << infile);
input.seekg(0, ios::beg);
pcl::PointCloud<pcl::PointXYZI>::Ptr points (new pcl::PointCloud<pcl::PointXYZI>);
int i;
for (i=0; input.good() && !input.eof(); i++) {
pcl::PointXYZI point;
input.read((char *) &point.x, 3*sizeof(float));
input.read((char *) &point.intensity, sizeof(float));
points->push_back(point);
}
input.close();
//workaround for the PCL headers... http://wiki.ros.org/hydro/Migration#PCL
sensor_msgs::PointCloud2 pc2;
pc2.header.frame_id= "velodyne"; //ros::this_node::getName();
pc2.header.stamp=header->stamp;
pc2.header.seq=header->seq;
points->header = pcl_conversions::toPCL(pc2.header);
pub.publish(points);
return 1;
}
}
/**
* @brief getCalibration
* @param dir_root
* @param camera_name
* @param K double K[9] - Calibration Matrix
* @param D double D[5] - Distortion Coefficients
* @param R double R[9] - Rectification Matrix
* @param P double P[12] - Projection Matrix Rectified (u,v,w) = P * R * (x,y,z,q)
* @return 1: file found, 0: file not found
*
* from: http://kitti.is.tue.mpg.de/kitti/devkit_raw_data.zip
* calib_cam_to_cam.txt: Camera-to-camera calibration
*
* - S_xx: 1x2 size of image xx before rectification
* - K_xx: 3x3 calibration matrix of camera xx before rectification
* - D_xx: 1x5 distortion vector of camera xx before rectification
* - R_xx: 3x3 rotation matrix of camera xx (extrinsic)
* - T_xx: 3x1 translation vector of camera xx (extrinsic)
* - S_rect_xx: 1x2 size of image xx after rectification
* - R_rect_xx: 3x3 rectifying rotation to make image planes co-planar
* - P_rect_xx: 3x4 projection matrix after rectification
*/
int getCalibration(string dir_root, string camera_name, double* K,std::vector<double> & D,double *R,double* P){
string calib_cam_to_cam=dir_root+"calib_cam_to_cam.txt";
ifstream file_c2c(calib_cam_to_cam.c_str());
if (!file_c2c.is_open())
return false;
ROS_INFO_STREAM("Reading camera" << camera_name << " calibration from " << calib_cam_to_cam);
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> sep{" "};
string line="";
char index=0;
tokenizer::iterator token_iterator;
while (getline(file_c2c,line))
{
// Parse string phase 1, tokenize it using Boost.
tokenizer tok(line,sep);
// Move the iterator at the beginning of the tokenize vector and check for K/D/R/P matrices.
token_iterator=tok.begin();
if (strcmp((*token_iterator).c_str(),((string)(string("K_")+camera_name+string(":"))).c_str())==0) //Calibration Matrix
{
index=0; //should be 9 at the end
ROS_DEBUG_STREAM("K_" << camera_name);
for (token_iterator++; token_iterator != tok.end(); token_iterator++)
{
//std::cout << *token_iterator << '\n';
K[index++]=boost::lexical_cast<double>(*token_iterator);
}
}
// EXPERIMENTAL: use with unrectified images
// token_iterator=tok.begin();
// if (strcmp((*token_iterator).c_str(),((string)(string("D_")+camera_name+string(":"))).c_str())==0) //Distortion Coefficients
// {
// index=0; //should be 5 at the end
// ROS_DEBUG_STREAM("D_" << camera_name);
// for (token_iterator++; token_iterator != tok.end(); token_iterator++)
// {
//// std::cout << *token_iterator << '\n';
// D[index++]=boost::lexical_cast<double>(*token_iterator);
// }
// }
token_iterator=tok.begin();
if (strcmp((*token_iterator).c_str(),((string)(string("R_")+camera_name+string(":"))).c_str())==0) //Rectification Matrix
{
index=0; //should be 12 at the end
ROS_DEBUG_STREAM("R_" << camera_name);
for (token_iterator++; token_iterator != tok.end(); token_iterator++)
{
//std::cout << *token_iterator << '\n';
R[index++]=boost::lexical_cast<double>(*token_iterator);
}
}
token_iterator=tok.begin();
if (strcmp((*token_iterator).c_str(),((string)(string("P_rect_")+camera_name+string(":"))).c_str())==0) //Projection Matrix Rectified
{
index=0; //should be 12 at the end
ROS_DEBUG_STREAM("P_rect_" << camera_name);
for (token_iterator++; token_iterator != tok.end(); token_iterator++)
{
//std::cout << *token_iterator << '\n';
P[index++]=boost::lexical_cast<double>(*token_iterator);
}
}
}
ROS_INFO_STREAM("... ok");
return true;
}
int getGPS(string filename, sensor_msgs::NavSatFix *ros_msgGpsFix, std_msgs::Header *header)
{
ifstream file_oxts(filename.c_str());
if (!file_oxts.is_open()){
ROS_ERROR_STREAM("Fail to open " << filename);
return 0;
}
ROS_DEBUG_STREAM("Reading GPS data from oxts file: " << filename );
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> sep{" "};
string line="";
getline(file_oxts,line);
tokenizer tok(line,sep);
vector<string> s(tok.begin(), tok.end());
ros_msgGpsFix->header.frame_id = ros::this_node::getName();
ros_msgGpsFix->header.stamp = header->stamp;
ros_msgGpsFix->latitude = boost::lexical_cast<double>(s[0]);
ros_msgGpsFix->longitude = boost::lexical_cast<double>(s[1]);
ros_msgGpsFix->altitude = boost::lexical_cast<double>(s[2]);
ros_msgGpsFix->position_covariance_type = sensor_msgs::NavSatFix::COVARIANCE_TYPE_APPROXIMATED;
for (int i=0;i<9;i++)
ros_msgGpsFix->position_covariance[i] = 0.0f;
ros_msgGpsFix->position_covariance[0] = boost::lexical_cast<double>(s[23]);
ros_msgGpsFix->position_covariance[4] = boost::lexical_cast<double>(s[23]);
ros_msgGpsFix->position_covariance[8] = boost::lexical_cast<double>(s[23]);
ros_msgGpsFix->status.service = sensor_msgs::NavSatStatus::SERVICE_GPS;
ros_msgGpsFix->status.status = sensor_msgs::NavSatStatus::STATUS_GBAS_FIX;
return 1;
}
int getIMU(string filename, sensor_msgs::Imu *ros_msgImu, std_msgs::Header *header)
{
ifstream file_oxts(filename.c_str());
if (!file_oxts.is_open())
{
ROS_ERROR_STREAM("Fail to open " << filename);
return 0;
}
ROS_DEBUG_STREAM("Reading IMU data from oxts file: " << filename );
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> sep{" "};
string line="";
getline(file_oxts,line);
tokenizer tok(line,sep);
vector<string> s(tok.begin(), tok.end());
ros_msgImu->header.frame_id = ros::this_node::getName();
ros_msgImu->header.stamp = header->stamp;
// - ax: acceleration in x, i.e. in direction of vehicle front (m/s^2)
// - ay: acceleration in y, i.e. in direction of vehicle left (m/s^2)
// - az: acceleration in z, i.e. in direction of vehicle top (m/s^2)
ros_msgImu->linear_acceleration.x = boost::lexical_cast<double>(s[11]);
ros_msgImu->linear_acceleration.y = boost::lexical_cast<double>(s[12]);
ros_msgImu->linear_acceleration.z = boost::lexical_cast<double>(s[13]);
// - vf: forward velocity, i.e. parallel to earth-surface (m/s)
// - vl: leftward velocity, i.e. parallel to earth-surface (m/s)
// - vu: upward velocity, i.e. perpendicular to earth-surface (m/s)
ros_msgImu->angular_velocity.x = boost::lexical_cast<double>(s[8]);
ros_msgImu->angular_velocity.y = boost::lexical_cast<double>(s[9]);
ros_msgImu->angular_velocity.z = boost::lexical_cast<double>(s[10]);
// - roll: roll angle (rad), 0 = level, positive = left side up (-pi..pi)
// - pitch: pitch angle (rad), 0 = level, positive = front down (-pi/2..pi/2)
// - yaw: heading (rad), 0 = east, positive = counter clockwise (-pi..pi)
tf::Quaternion q=tf::createQuaternionFromRPY( boost::lexical_cast<double>(s[3]),
boost::lexical_cast<double>(s[4]),
boost::lexical_cast<double>(s[5])
);
ros_msgImu->orientation.x = q.getX();
ros_msgImu->orientation.y = q.getY();
ros_msgImu->orientation.z = q.getZ();
ros_msgImu->orientation.w = q.getW();
return 1;
}
/**
* @brief parseTime
* @param timestamp in Epoch
* @return std_msgs::Header with input timpestamp converted from file input
*
* Epoch time conversion
* http://www.epochconverter.com/programming/functions-c.php
*/
std_msgs::Header parseTime(string timestamp)
{
std_msgs::Header header;
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
// example: 2011-09-26 13:21:35.134391552
// 01234567891111111111222222222
// 0123456789012345678
struct tm t = {0}; // Initalize to all 0's
t.tm_year = boost::lexical_cast<int>(timestamp.substr(0,4)) - 1900;
t.tm_mon = boost::lexical_cast<int>(timestamp.substr(5,2)) - 1;
t.tm_mday = boost::lexical_cast<int>(timestamp.substr(8,2));
t.tm_hour = boost::lexical_cast<int>(timestamp.substr(11,2));
t.tm_min = boost::lexical_cast<int>(timestamp.substr(14,2));
t.tm_sec = boost::lexical_cast<int>(timestamp.substr(17,2));
t.tm_isdst = -1;
time_t timeSinceEpoch = mktime(&t);
header.stamp.sec = timeSinceEpoch;
header.stamp.nsec = boost::lexical_cast<int>(timestamp.substr(20,8));
return header;
}
/**
* @brief getLaneDetection
* @param infile
* @param msg_lines
* @return
*/
/*
int getLaneDetection(string infile, road_layout_estimation::msg_lines *msg_lines)
{
ROS_DEBUG_STREAM("Reading lane detections from " << infile);
ifstream detection_file(infile);
if (!detection_file.is_open())
return false;
msg_lines->number_of_lines = 0;
msg_lines->goodLines = 0;
msg_lines->width = 0;
msg_lines->oneway = 0;
msg_lines->naive_width = 0;
msg_lines->lines.clear();
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> sep{"\t"}; // TAB
string line="";
char index = 0;
double last_right_detection = std::numeric_limits<double>::min(); //uses *ONLY* the valid lines
double last_left_detection = std::numeric_limits<double>::max(); //uses *ONLY* the valid lines
double naive_last_right_detection = std::numeric_limits<double>::min(); //uses all values, even if the line is not valid
double naive_last_left_detection = std::numeric_limits<double>::max(); //uses all values, even if the line is not valid
while (getline(detection_file,line))
{
// Parse string phase 1, tokenize it using Boost.
tokenizer tok(line,sep);
if (index==0)
{
vector<string> s(tok.begin(), tok.end());
msg_lines->goodLines = boost::lexical_cast<int>(s[0]);
index++;
}
else
{
road_layout_estimation::msg_lineInfo line;
vector<string> s(tok.begin(), tok.end());
if (s.size()!=3)
{
ROS_WARN_STREAM("Unexpected file format, can't read");
return false;
}
line.isValid = boost::lexical_cast<bool> (s[0]);
line.counter = boost::lexical_cast<int> (s[1]);
line.offset = boost::lexical_cast<float> (s[2]);
msg_lines->lines.push_back(line);
if (line.isValid)
{
if (line.offset > last_right_detection)
last_right_detection = line.offset;
if (line.offset < last_left_detection)
last_left_detection = line.offset;
}
if (line.offset > naive_last_right_detection)
naive_last_right_detection = line.offset;
if (line.offset < naive_last_left_detection)
naive_last_left_detection = line.offset;
index++;
}
}
// Number of lines in the file, 1 line 'in the picture' is one row in the file, minus
// one, the first, that is the number of "good" (current tracked in good state) lines.
msg_lines->number_of_lines = index -1 ;
if (msg_lines->goodLines > 1)
msg_lines->width = abs(last_left_detection) + abs(last_right_detection);
else
msg_lines->width = abs(last_left_detection);
msg_lines->naive_width = abs(naive_last_left_detection) + abs(naive_last_right_detection);
msg_lines->way_id = 0; ///WARNING this value is not used yet.
if (msg_lines->width == std::numeric_limits<double>::max())
msg_lines->width = 0.0f;
if (msg_lines->naive_width == std::numeric_limits<double>::max())
msg_lines->naive_width = 0.0f;
ROS_DEBUG_STREAM("Number of LANEs: " << msg_lines->number_of_lines << "\tNumber of good LINEs "<<msg_lines->goodLines);
ROS_DEBUG_STREAM("... getLaneDetection ok");
return true;
}
*/
/**
* @brief main Kitti_player, a player for KITTI raw datasets
* @param argc
* @param argv
* @return 0 and ros::shutdown at the end of the dataset, -1 if errors
*
* Allowed options:
* -h [ --help ] help message
* -d [ --directory ] arg *required* - path to the kitti dataset Directory
* -f [ --frequency ] arg (=1) set replay Frequency
* -a [ --all ] [=arg(=1)] (=0) replay All data
* -v [ --velodyne ] [=arg(=1)] (=0) replay Velodyne data
* -g [ --gps ] [=arg(=1)] (=0) replay Gps data
* -i [ --imu ] [=arg(=1)] (=0) replay Imu data
* -G [ --grayscale ] [=arg(=1)] (=0) replay Stereo Grayscale images
* -C [ --color ] [=arg(=1)] (=0) replay Stereo Color images
* -V [ --viewer ] [=arg(=1)] (=0) enable image viewer
* -T [ --timestamps ] [=arg(=1)] (=0) use KITTI timestamps
* -s [ --stereoDisp ] [=arg(=1)] (=0) use pre-calculated disparities
* -D [ --viewDisp ] [=arg(=1)] (=0) view loaded disparity images
* -l [ --laneDetect ] [=arg(=1)] (=0) send extra lanes message
* -F [ --frame ] [=arg(=0)] (=0) start playing at frame ...
*
* Datasets can be downloaded from: http://www.cvlibs.net/datasets/kitti/raw_data.php
*/
int main(int argc, char **argv)
{
kitti_player_options options;
po::variables_map vm;
po::options_description desc("Kitti_player, a player for KITTI raw datasets\nDatasets can be downloaded from: http://www.cvlibs.net/datasets/kitti/raw_data.php\n\nAllowed options",200);
desc.add_options()
("help,h" , "help message")
("directory ,d", po::value<string> (&options.path)->required() , "*required* - path to the kitti dataset Directory")
("frequency ,f", po::value<float> (&options.frequency) ->default_value(1.0) , "set replay Frequency")
("all ,a", po::value<bool> (&options.all_data) ->default_value(0) ->implicit_value(1) , "replay All data")
("velodyne ,v", po::value<bool> (&options.velodyne) ->default_value(0) ->implicit_value(1) , "replay Velodyne data")
("gps ,g", po::value<bool> (&options.gps) ->default_value(0) ->implicit_value(1) , "replay Gps data")
("imu ,i", po::value<bool> (&options.imu) ->default_value(0) ->implicit_value(1) , "replay Imu data")
("grayscale ,G", po::value<bool> (&options.grayscale) ->default_value(0) ->implicit_value(1) , "replay Stereo Grayscale images")
("color ,C", po::value<bool> (&options.color) ->default_value(0) ->implicit_value(1) , "replay Stereo Color images")
("viewer ,V", po::value<bool> (&options.viewer) ->default_value(0) ->implicit_value(1) , "enable image viewer")
("timestamps,T", po::value<bool> (&options.timestamps) ->default_value(0) ->implicit_value(1) , "use KITTI timestamps")
("stereoDisp,s", po::value<bool> (&options.stereoDisp) ->default_value(0) ->implicit_value(1) , "use pre-calculated disparities")
("viewDisp ,D ", po::value<bool> (&options.viewDisparities)->default_value(0) ->implicit_value(1) , "view loaded disparity images")
("laneDetect,l", po::value<bool> (&options.laneDetections) ->default_value(0) ->implicit_value(1) , "send extra lanes message")
("frame ,F", po::value<unsigned int> (&options.startFrame) ->default_value(0) ->implicit_value(0) , "start playing at frame...")
;
try // parse options
{
po::parsed_options parsed = po::command_line_parser(argc-2, argv).options(desc).allow_unregistered().run();
po::store(parsed, vm);
po::notify(vm);
vector<string> to_pass_further = po::collect_unrecognized(parsed.options, po::include_positional);
// Can't handle __ros (ROS parameters ... )
// if (to_pass_further.size()>0)
// {
// ROS_WARN_STREAM("Unknown Options Detected, shutting down node\n");
// cerr << desc << endl;
// return 1;
// }
}
catch(...)
{
cerr << desc << endl;
cout << "kitti_player needs a directory tree like the following:" << endl;
cout << "└── 2011_09_26_drive_0001_sync" << endl;
cout << " ├── image_00 " << endl;
cout << " │ └── data " << endl;
cout << " │ └ timestamps.txt " << endl;
cout << " ├── image_01 " << endl;
cout << " │ └── data " << endl;
cout << " │ └ timestamps.txt " << endl;
cout << " ├── image_02 " << endl;
cout << " │ └── data " << endl;
cout << " │ └ timestamps.txt " << endl;
cout << " ├── image_03 " << endl;
cout << " │ └── data " << endl;
cout << " │ └ timestamps.txt " << endl;
cout << " ├── oxts " << endl;
cout << " │ └── data " << endl;
cout << " │ └ timestamps.txt " << endl;
cout << " ├── velodyne_points " << endl;
cout << " │ └── data " << endl;
cout << " │ └ timestamps.txt " << endl;
cout << " └── calib_cam_to_cam.txt " << endl << endl;
ROS_WARN_STREAM("Parse error, shutting down node\n");
return -1;
}
ros::init(argc, argv, "kitti_player");
ros::NodeHandle node("kitti_player");
ros::Rate loop_rate(options.frequency);
/// This sets the logger level; use this to disable all ROS prints
if( ros::console::set_logger_level(ROSCONSOLE_DEFAULT_NAME, ros::console::levels::Debug) )
ros::console::notifyLoggerLevelsChanged();
else
std::cout << "Error while setting the logger level!" << std::endl;
DIR *dir;
struct dirent *ent;
unsigned int total_entries = 0; //number of elements to be played
unsigned int entries_played = 0; //number of elements played until now
unsigned int len = 0; //counting elements support variable
string dir_root ;
string dir_image00 ;string full_filename_image00; string dir_timestamp_image00;
string dir_image01 ;string full_filename_image01; string dir_timestamp_image01;
string dir_image02 ;string full_filename_image02; string dir_timestamp_image02;
string dir_image03 ;string full_filename_image03; string dir_timestamp_image03;
string dir_image04 ;string full_filename_image04;
string dir_laneDetections ;string full_filename_laneDetections;
string dir_laneProjected ;string full_filename_laneProjected;
string dir_oxts ;string full_filename_oxts; string dir_timestamp_oxts;
string dir_velodyne_points ;string full_filename_velodyne; string dir_timestamp_velodyne; //average of start&end (time of scan)
string str_support;
cv::Mat cv_image00;
cv::Mat cv_image01;
cv::Mat cv_image02;
cv::Mat cv_image03;
cv::Mat cv_image04;
cv::Mat cv_laneProjected;
std_msgs::Header header_support;
image_transport::ImageTransport it(node);
image_transport::CameraPublisher pub00 = it.advertiseCamera("grayscale/left/image_rect", 1);
image_transport::CameraPublisher pub01 = it.advertiseCamera("grayscale/right/image_rect", 1);
image_transport::CameraPublisher pub02 = it.advertiseCamera("color/left/image_rect", 1);
image_transport::CameraPublisher pub03 = it.advertiseCamera("color/right/image_rect", 1);
sensor_msgs::Image ros_msg00;
sensor_msgs::Image ros_msg01;
sensor_msgs::Image ros_msg02;
sensor_msgs::Image ros_msg03;
// sensor_msgs::CameraInfo ros_cameraInfoMsg;
sensor_msgs::CameraInfo ros_cameraInfoMsg_camera00;
sensor_msgs::CameraInfo ros_cameraInfoMsg_camera01;
sensor_msgs::CameraInfo ros_cameraInfoMsg_camera02;
sensor_msgs::CameraInfo ros_cameraInfoMsg_camera03;
cv_bridge::CvImage cv_bridge_img;
ros::Publisher map_pub = node.advertise<pcl::PointCloud<pcl::PointXYZ> > ("hdl64e", 1, true);
ros::Publisher gps_pub = node.advertise<sensor_msgs::NavSatFix> ("oxts/gps", 1, true);
ros::Publisher gps_pub_initial = node.advertise<sensor_msgs::NavSatFix> ("oxts/gps_initial", 1, true);
ros::Publisher imu_pub = node.advertise<sensor_msgs::Imu> ("oxts/imu", 1, true);
ros::Publisher disp_pub = node.advertise<stereo_msgs::DisparityImage> ("preprocessed_disparity",1,true);
//ros::Publisher lanes_pub = node.advertise<road_layout_estimation::msg_lines>("lanes",1,true);
sensor_msgs::NavSatFix ros_msgGpsFix;
sensor_msgs::NavSatFix ros_msgGpsFixInitial; // This message contains the first reading of the file
bool firstGpsData = true; // Flag to store the ros_msgGpsFixInitial message
sensor_msgs::Imu ros_msgImu;
//road_layout_estimation::msg_lines msgLanes;
if (vm.count("help")) {
cout << desc << endl;
cout << "kitti_player needs a directory tree like the following:" << endl;
cout << "└── 2011_09_26_drive_0001_sync" << endl;
cout << " ├── image_00 " << endl;
cout << " │ └── data " << endl;
cout << " │ └ timestamps.txt " << endl;
cout << " ├── image_01 " << endl;
cout << " │ └── data " << endl;
cout << " │ └ timestamps.txt " << endl;
cout << " ├── image_02 " << endl;
cout << " │ └── data " << endl;
cout << " │ └ timestamps.txt " << endl;
cout << " ├── image_03 " << endl;
cout << " │ └── data " << endl;
cout << " │ └ timestamps.txt " << endl;
cout << " ├── oxts " << endl;
cout << " │ └── data " << endl;
cout << " │ └ timestamps.txt " << endl;
cout << " ├── velodyne_points " << endl;
cout << " │ └── data " << endl;
cout << " │ └ timestamps.txt " << endl;
cout << " └── calib_cam_to_cam.txt " << endl << endl;
return 1;
}
if (!(options.all_data || options.color || options.gps || options.grayscale || options.imu || options.velodyne))
{
ROS_WARN_STREAM("Job finished without playing the dataset. No 'publishing' parameters provided");
node.shutdown();
return 1;
}
dir_root = options.path;
dir_image00 = options.path;
dir_image01 = options.path;
dir_image02 = options.path;
dir_image03 = options.path;
dir_image04 = options.path;
dir_oxts = options.path;
dir_velodyne_points = options.path;
dir_image04 = options.path;
(*(options.path.end()-1) != '/' ? dir_root = options.path+"/" : dir_root = options.path);
(*(options.path.end()-1) != '/' ? dir_image00 = options.path+"/image_00/data/" : dir_image00 = options.path+"image_00/data/");
(*(options.path.end()-1) != '/' ? dir_image01 = options.path+"/image_01/data/" : dir_image01 = options.path+"image_01/data/");
(*(options.path.end()-1) != '/' ? dir_image02 = options.path+"/image_02/data/" : dir_image02 = options.path+"image_02/data/");
(*(options.path.end()-1) != '/' ? dir_image03 = options.path+"/image_03/data/" : dir_image03 = options.path+"image_03/data/");
(*(options.path.end()-1) != '/' ? dir_image04 = options.path+"/disparities/" : dir_image04 = options.path+"disparities/");
(*(options.path.end()-1) != '/' ? dir_oxts = options.path+"/oxts/data/" : dir_oxts = options.path+"oxts/data/");
(*(options.path.end()-1) != '/' ? dir_velodyne_points = options.path+"/velodyne_points/data/" : dir_velodyne_points = options.path+"velodyne_points/data/");
(*(options.path.end()-1) != '/' ? dir_timestamp_image00 = options.path+"/image_00/" : dir_timestamp_image00 = options.path+"image_00/");
(*(options.path.end()-1) != '/' ? dir_timestamp_image01 = options.path+"/image_01/" : dir_timestamp_image01 = options.path+"image_01/");
(*(options.path.end()-1) != '/' ? dir_timestamp_image02 = options.path+"/image_02/" : dir_timestamp_image02 = options.path+"image_02/");
(*(options.path.end()-1) != '/' ? dir_timestamp_image03 = options.path+"/image_03/" : dir_timestamp_image03 = options.path+"image_03/");
(*(options.path.end()-1) != '/' ? dir_timestamp_oxts = options.path+"/oxts/" : dir_timestamp_oxts = options.path+"oxts/");
(*(options.path.end()-1) != '/' ? dir_timestamp_velodyne = options.path+"/velodyne_points/" : dir_timestamp_velodyne = options.path+"velodyne_points/");
(*(options.path.end()-1) != '/' ? dir_timestamp_velodyne = options.path+"/velodyne_points/" : dir_timestamp_velodyne = options.path+"velodyne_points/");
/// EXTRA
/// 01. Lane detections
(*(options.path.end()-1) != '/' ? dir_laneDetections = options.path+"/lane/" : dir_laneDetections = options.path+"lane/");
(*(options.path.end()-1) != '/' ? dir_laneProjected = options.path+"/all/" : dir_laneProjected = options.path+"all/");
// Check all the directories
if (
(options.all_data && ( (opendir(dir_image00.c_str()) == NULL) ||
(opendir(dir_image01.c_str()) == NULL) ||
(opendir(dir_image02.c_str()) == NULL) ||
(opendir(dir_image03.c_str()) == NULL) ||
(opendir(dir_oxts.c_str()) == NULL) ||
(opendir(dir_velodyne_points.c_str()) == NULL)))
||
(options.color && ( (opendir(dir_image02.c_str()) == NULL) ||
(opendir(dir_image03.c_str()) == NULL)))
||
(options.grayscale && ( (opendir(dir_image00.c_str()) == NULL) ||
(opendir(dir_image01.c_str()) == NULL)))
||
(options.imu && ( (opendir(dir_oxts.c_str()) == NULL)))
||
(options.gps && ( (opendir(dir_oxts.c_str()) == NULL)))
//||
//(options.stereoDisp && ( (opendir(dir_image04.c_str()) == NULL)))
||
(options.velodyne && ( (opendir(dir_velodyne_points.c_str()) == NULL)))
//||
//(options.laneDetections && ( (opendir(dir_laneDetections.c_str()) == NULL)))
||
(options.timestamps && ( (opendir(dir_timestamp_image00.c_str()) == NULL) ||
(opendir(dir_timestamp_image01.c_str()) == NULL) ||
(opendir(dir_timestamp_image02.c_str()) == NULL) ||
(opendir(dir_timestamp_image03.c_str()) == NULL) ||
(opendir(dir_timestamp_oxts.c_str()) == NULL) ||
(opendir(dir_timestamp_velodyne.c_str()) == NULL)))
)
{
ROS_ERROR("Incorrect tree directory , use --help for details");
node.shutdown();
return -1;
}
else
{
ROS_INFO_STREAM ("Checking directories...");
ROS_INFO_STREAM (options.path << "\t[OK]");
}
//count elements in the folder
if (options.all_data)
{
dir = opendir(dir_image02.c_str());
while(ent = readdir(dir))
{
//skip . & ..
len = strlen (ent->d_name);
//skip . & ..
if (len>2)
total_entries++;
}
closedir (dir);
}
else
{
bool done=false;
if (!done && options.color)
{
total_entries=0;
dir = opendir(dir_image02.c_str());
while(ent = readdir(dir))
{
//skip . & ..
len = strlen (ent->d_name);
//skip . & ..
if (len>2)
total_entries++;
} closedir (dir);
done=true;
}
if (!done && options.grayscale)
{
total_entries=0;
dir = opendir(dir_image00.c_str());
while(ent = readdir(dir))
{
//skip . & ..
len = strlen (ent->d_name);
//skip . & ..
if (len>2)
total_entries++;
}
closedir (dir);
done=true;
}
if (!done && options.gps)
{
total_entries=0;
dir = opendir(dir_oxts.c_str());
while(ent = readdir(dir))
{
//skip . & ..
len = strlen (ent->d_name);
//skip . & ..
if (len>2)
total_entries++;
}
closedir (dir);
done=true;
}
if (!done && options.imu)
{
total_entries=0;
dir = opendir(dir_oxts.c_str());
while(ent = readdir(dir))
{
//skip . & ..
len = strlen (ent->d_name);
//skip . & ..
if (len>2)
total_entries++;
}
closedir (dir);
done=true;
}
if (!done && options.velodyne)
{
total_entries=0;
dir = opendir(dir_oxts.c_str());
while(ent = readdir(dir))
{
//skip . & ..
len = strlen (ent->d_name);
//skip . & ..
if (len>2)
total_entries++;
}
closedir (dir);
done=true;
}
if (!done && options.stereoDisp)
{
total_entries=0;
dir = opendir(dir_image04.c_str());
while(ent = readdir(dir))
{
//skip . & ..
len = strlen (ent->d_name);
//skip . & ..
if (len>2)
total_entries++;
}
closedir (dir);
done=true;
}
if (!done && options.laneDetections)
{
total_entries=0;
dir = opendir(dir_laneDetections.c_str());
while(ent = readdir(dir))
{
//skip . & ..
len = strlen (ent->d_name);
//skip . & ..
if (len>2)
total_entries++;
}
closedir (dir);
done=true;
}
}
// Check options.startFrame and total_entries
if (options.startFrame > total_entries)
{
ROS_ERROR("Error, start number > total entries in the dataset");
node.shutdown();
return -1;
}
else
{
entries_played = options.startFrame;
ROS_INFO_STREAM("The entry point (frame number) is: " << entries_played);
}
if(options.viewer)
{
ROS_INFO_STREAM("Opening CV viewer(s)");
if(options.color || options.all_data)
{
ROS_DEBUG_STREAM("color||all " << options.color << " " << options.all_data);
cv::namedWindow("CameraSimulator Color Viewer",CV_WINDOW_AUTOSIZE);
full_filename_image02 = dir_image02 + boost::str(boost::format("%010d") % 0 ) + ".png";
cv_image02 = cv::imread(full_filename_image02, CV_LOAD_IMAGE_UNCHANGED);
cv::waitKey(5);
}
if(options.grayscale || options.all_data)
{
ROS_DEBUG_STREAM("grayscale||all " << options.grayscale << " " << options.all_data);
cv::namedWindow("CameraSimulator Grayscale Viewer",CV_WINDOW_AUTOSIZE);
full_filename_image00 = dir_image00 + boost::str(boost::format("%010d") % 0 ) + ".png";
cv_image00 = cv::imread(full_filename_image00, CV_LOAD_IMAGE_UNCHANGED);
cv::waitKey(5);
}
if (options.viewDisparities || options.all_data)
{
ROS_DEBUG_STREAM("viewDisparities||all " << options.grayscale << " " << options.all_data);
cv::namedWindow("Reprojection of Detected Lines",CV_WINDOW_AUTOSIZE);
full_filename_laneProjected = dir_laneProjected + boost::str(boost::format("%010d") % 0 ) + ".png";
cv_laneProjected = cv::imread(full_filename_laneProjected, CV_LOAD_IMAGE_UNCHANGED);
cv::waitKey(5);
}
ROS_INFO_STREAM("Opening CV viewer(s)... OK");
}
// CAMERA INFO SECTION: read one for all
ros_cameraInfoMsg_camera00.header.stamp = ros::Time::now();
ros_cameraInfoMsg_camera00.header.frame_id = ros::this_node::getName();
ros_cameraInfoMsg_camera00.height = 0;
ros_cameraInfoMsg_camera00.width = 0;
//ros_cameraInfoMsg_camera00.D.resize(5);
//ros_cameraInfoMsg_camera00.distortion_model=sensor_msgs::distortion_models::PLUMB_BOB;
ros_cameraInfoMsg_camera01.header.stamp = ros::Time::now();
ros_cameraInfoMsg_camera01.header.frame_id = ros::this_node::getName();
ros_cameraInfoMsg_camera01.height = 0;
ros_cameraInfoMsg_camera01.width = 0;
//ros_cameraInfoMsg_camera01.D.resize(5);
//ros_cameraInfoMsg_camera00.distortion_model=sensor_msgs::distortion_models::PLUMB_BOB;
ros_cameraInfoMsg_camera02.header.stamp = ros::Time::now();
ros_cameraInfoMsg_camera02.header.frame_id = ros::this_node::getName();
ros_cameraInfoMsg_camera02.height = 0;
ros_cameraInfoMsg_camera02.width = 0;
//ros_cameraInfoMsg_camera02.D.resize(5);
//ros_cameraInfoMsg_camera02.distortion_model=sensor_msgs::distortion_models::PLUMB_BOB;
ros_cameraInfoMsg_camera03.header.stamp = ros::Time::now();
ros_cameraInfoMsg_camera03.header.frame_id = ros::this_node::getName();
ros_cameraInfoMsg_camera03.height = 0;
ros_cameraInfoMsg_camera03.width = 0;
//ros_cameraInfoMsg_camera03.D.resize(5);
//ros_cameraInfoMsg_camera03.distortion_model=sensor_msgs::distortion_models::PLUMB_BOB;
if(options.color || options.all_data)
{
if(
!(getCalibration(dir_root,"02",ros_cameraInfoMsg_camera02.K.data(),ros_cameraInfoMsg_camera02.D,ros_cameraInfoMsg_camera02.R.data(),ros_cameraInfoMsg_camera02.P.data()) &&
getCalibration(dir_root,"03",ros_cameraInfoMsg_camera03.K.data(),ros_cameraInfoMsg_camera03.D,ros_cameraInfoMsg_camera03.R.data(),ros_cameraInfoMsg_camera03.P.data()))
)
{
ROS_ERROR_STREAM("Error reading CAMERA02/CAMERA03 calibration");
//node.shutdown();
//return -1;
}
//Assume same height/width for the camera pair
full_filename_image02 = dir_image02 + boost::str(boost::format("%010d") % 0 ) + ".png";
cv_image02 = cv::imread(full_filename_image02, CV_LOAD_IMAGE_UNCHANGED);
cv::waitKey(5);
ros_cameraInfoMsg_camera03.height = ros_cameraInfoMsg_camera02.height = cv_image02.rows;// -1;TODO: CHECK, qui potrebbe essere -1
ros_cameraInfoMsg_camera03.width = ros_cameraInfoMsg_camera02.width = cv_image02.cols;// -1;
}
if(options.grayscale || options.all_data)
{
if(
!(getCalibration(dir_root,"00",ros_cameraInfoMsg_camera00.K.data(),ros_cameraInfoMsg_camera00.D,ros_cameraInfoMsg_camera00.R.data(),ros_cameraInfoMsg_camera00.P.data()) &&
getCalibration(dir_root,"01",ros_cameraInfoMsg_camera01.K.data(),ros_cameraInfoMsg_camera01.D,ros_cameraInfoMsg_camera01.R.data(),ros_cameraInfoMsg_camera01.P.data()))
)
{
ROS_ERROR_STREAM("Error reading CAMERA00/CAMERA01 calibration");
//node.shutdown();
//return -1;
}
//Assume same height/width for the camera pair
full_filename_image00 = dir_image00 + boost::str(boost::format("%010d") % 0 ) + ".png";
cv_image00 = cv::imread(full_filename_image00, CV_LOAD_IMAGE_UNCHANGED);
cv::waitKey(5);
ros_cameraInfoMsg_camera01.height = ros_cameraInfoMsg_camera00.height = cv_image00.rows;// -1; TODO: CHECK -1?
ros_cameraInfoMsg_camera01.width = ros_cameraInfoMsg_camera00.width = cv_image00.cols;// -1;
}
boost::progress_display progress(total_entries) ;
double cv_min, cv_max=0.0f;
// This is the main KITTI_PLAYER Loop
do
{
// single timestamp for all published stuff
Time current_timestamp=ros::Time::now();
if(options.stereoDisp)
{
// Allocate new disparity image message
stereo_msgs::DisparityImagePtr disp_msg = boost::make_shared<stereo_msgs::DisparityImage>();
full_filename_image04 = dir_image04 + boost::str(boost::format("%010d") % entries_played ) + ".png";
cv_image04 = cv::imread(full_filename_image04, CV_LOAD_IMAGE_GRAYSCALE);
cv::minMaxLoc(cv_image04,&cv_min,&cv_max);
disp_msg->min_disparity = (int)cv_min;
disp_msg->max_disparity = (int)cv_max;
disp_msg->valid_window.x_offset = 0; // should be safe, checked!
disp_msg->valid_window.y_offset = 0; // should be safe, checked!
disp_msg->valid_window.width = 0; // should be safe, checked!
disp_msg->valid_window.height = 0; // should be safe, checked!
disp_msg->T = 0; // should be safe, checked!
disp_msg->f = 0; // should be safe, checked!
disp_msg->delta_d = 0; // should be safe, checked!
disp_msg->header.stamp = current_timestamp;
disp_msg->header.frame_id = ros::this_node::getName();
disp_msg->header.seq = progress.count();
sensor_msgs::Image& dimage = disp_msg->image;
dimage.width = cv_image04.size().width ;
dimage.height = cv_image04.size().height ;
dimage.encoding = sensor_msgs::image_encodings::TYPE_32FC1;
dimage.step = dimage.width * sizeof(float);
dimage.data.resize(dimage.step * dimage.height);
cv::Mat_<float> dmat(dimage.height, dimage.width, reinterpret_cast<float*>(&dimage.data[0]), dimage.step);
cv_image04.convertTo(dmat,dmat.type());
disp_pub.publish(disp_msg);
}
/*
if(options.laneDetections)
{
//msgLanes;
//msgSingleLaneInfo;
string file=dir_laneDetections+boost::str(boost::format("%010d") % entries_played )+".txt";
if(getLaneDetection(file,&msgLanes))
{
msgLanes.header.stamp = current_timestamp;
msgLanes.header.frame_id = ros::this_node::getName();
lanes_pub.publish(msgLanes);
}
if (options.viewDisparities)
{
full_filename_laneProjected = dir_laneProjected + boost::str(boost::format("%010d") % entries_played ) + ".png";
cv_laneProjected = cv::imread(full_filename_laneProjected, CV_LOAD_IMAGE_UNCHANGED);
cv::imshow("Reprojection of Detected Lines",cv_laneProjected);
cv::waitKey(5);
}
}
*/
if(options.color || options.all_data)
{
full_filename_image02 = dir_image02 + boost::str(boost::format("%010d") % entries_played ) + ".png";
full_filename_image03 = dir_image03 + boost::str(boost::format("%010d") % entries_played ) + ".png";
ROS_DEBUG_STREAM ( full_filename_image02 << endl << full_filename_image03 << endl << endl);
cv_image02 = cv::imread(full_filename_image02, CV_LOAD_IMAGE_UNCHANGED);
cv_image03 = cv::imread(full_filename_image03, CV_LOAD_IMAGE_UNCHANGED);
if ( (cv_image02.data == NULL) || (cv_image03.data == NULL) ){
ROS_ERROR_STREAM("Error reading color images (02 & 03)");
ROS_ERROR_STREAM(full_filename_image02 << endl << full_filename_image03);
node.shutdown();
return -1;
}
if(options.viewer)
{
//display the left image only
cv::imshow("CameraSimulator Color Viewer",cv_image02);
//give some time to draw images
cv::waitKey(5);
}
cv_bridge_img.encoding = sensor_msgs::image_encodings::BGR8;
cv_bridge_img.header.frame_id = "camera"; //ros::this_node::getName();
if (!options.timestamps)
{
cv_bridge_img.header.stamp = current_timestamp ;
ros_msg02.header.stamp = ros_cameraInfoMsg_camera02.header.stamp = cv_bridge_img.header.stamp;
}
else
{
str_support = dir_timestamp_image02 + "timestamps.txt";
ifstream timestamps(str_support.c_str());
if (!timestamps.is_open())
{
string timestamps_string;
timestamps >> timestamps_string;
ROS_ERROR_STREAM("Fail to open " << timestamps_string);
node.shutdown();
return -1;
}
timestamps.seekg(30*entries_played);
getline(timestamps,str_support);
cv_bridge_img.header.stamp = parseTime(str_support).stamp;
ros_msg02.header.stamp = ros_cameraInfoMsg_camera02.header.stamp = cv_bridge_img.header.stamp;
}
cv_bridge_img.image = cv_image02;
cv_bridge_img.toImageMsg(ros_msg02);
if (!options.timestamps)
{
cv_bridge_img.header.stamp = current_timestamp;
ros_msg03.header.stamp = ros_cameraInfoMsg_camera03.header.stamp = cv_bridge_img.header.stamp;
}
else
{
str_support = dir_timestamp_image03 + "timestamps.txt";
ifstream timestamps(str_support.c_str());
if (!timestamps.is_open())
{
string timestamps_string;
timestamps >> timestamps_string;
ROS_ERROR_STREAM("Fail to open " << timestamps_string);
node.shutdown();
return -1;
}
timestamps.seekg(30*entries_played);
getline(timestamps,str_support);
cv_bridge_img.header.stamp = parseTime(str_support).stamp;
ros_msg03.header.stamp = ros_cameraInfoMsg_camera03.header.stamp = cv_bridge_img.header.stamp;
}
cv_bridge_img.image = cv_image03;
cv_bridge_img.toImageMsg(ros_msg03);
pub02.publish(ros_msg02,ros_cameraInfoMsg_camera02);
pub03.publish(ros_msg03,ros_cameraInfoMsg_camera03);
}
if(options.grayscale || options.all_data)
{
full_filename_image00 = dir_image00 + boost::str(boost::format("%010d") % entries_played ) + ".png";
full_filename_image01 = dir_image01 + boost::str(boost::format("%010d") % entries_played ) + ".png";
ROS_DEBUG_STREAM ( full_filename_image00 << endl << full_filename_image01 << endl << endl);
cv_image00 = cv::imread(full_filename_image00, CV_LOAD_IMAGE_UNCHANGED);
cv_image01 = cv::imread(full_filename_image01, CV_LOAD_IMAGE_UNCHANGED);
if ( (cv_image00.data == NULL) || (cv_image01.data == NULL) ){
ROS_ERROR_STREAM("Error reading color images (00 & 01)");
ROS_ERROR_STREAM(full_filename_image00 << endl << full_filename_image01);
node.shutdown();
return -1;
}
if(options.viewer)
{
//display the left image only
cv::imshow("CameraSimulator Grayscale Viewer",cv_image00);
//give some time to draw images
cv::waitKey(5);
}
cv_bridge_img.encoding = sensor_msgs::image_encodings::MONO8;
cv_bridge_img.header.frame_id = "camera"; //ros::this_node::getName();
if (!options.timestamps)
{
cv_bridge_img.header.stamp = current_timestamp;
ros_msg00.header.stamp = ros_cameraInfoMsg_camera00.header.stamp = cv_bridge_img.header.stamp;
}
else
{
str_support = dir_timestamp_image02 + "timestamps.txt";
ifstream timestamps(str_support.c_str());
if (!timestamps.is_open())
{
string timestamps_string;
timestamps >> timestamps_string;
ROS_ERROR_STREAM("Fail to open " << timestamps_string);
node.shutdown();
return -1;
}
timestamps.seekg(30*entries_played);
getline(timestamps,str_support);
cv_bridge_img.header.stamp = parseTime(str_support).stamp;
ros_msg00.header.stamp = ros_cameraInfoMsg_camera00.header.stamp = cv_bridge_img.header.stamp;
}
cv_bridge_img.image = cv_image00;
cv_bridge_img.toImageMsg(ros_msg00);
if (!options.timestamps)
{
cv_bridge_img.header.stamp = current_timestamp;
ros_msg01.header.stamp = ros_cameraInfoMsg_camera01.header.stamp = cv_bridge_img.header.stamp;
}
else
{
str_support = dir_timestamp_image02 + "timestamps.txt";
ifstream timestamps(str_support.c_str());
if (!timestamps.is_open())
{
string timestamps_string;
timestamps >> timestamps_string;
ROS_ERROR_STREAM("Fail to open " << timestamps_string);
node.shutdown();
return -1;
}
timestamps.seekg(30*entries_played);
getline(timestamps,str_support);
cv_bridge_img.header.stamp = parseTime(str_support).stamp;
ros_msg01.header.stamp = ros_cameraInfoMsg_camera01.header.stamp = cv_bridge_img.header.stamp;
}
cv_bridge_img.image = cv_image01;
cv_bridge_img.toImageMsg(ros_msg01);
pub00.publish(ros_msg00,ros_cameraInfoMsg_camera00);
pub01.publish(ros_msg01,ros_cameraInfoMsg_camera01);
}
if(options.velodyne || options.all_data)
{
header_support.stamp = current_timestamp;
full_filename_velodyne = dir_velodyne_points + boost::str(boost::format("%010d") % entries_played ) + ".bin";
if (!options.timestamps)
publish_velodyne(map_pub, full_filename_velodyne,&header_support);
else
{
str_support = dir_timestamp_velodyne + "timestamps.txt";
ifstream timestamps(str_support.c_str());
if (!timestamps.is_open())
{
string timestamps_string;
timestamps >> timestamps_string;
ROS_ERROR_STREAM("Fail to open " << timestamps_string);
node.shutdown();
return -1;
}
timestamps.seekg(30*entries_played);
getline(timestamps,str_support);
header_support.stamp = parseTime(str_support).stamp;
header_support.seq = progress.count();
publish_velodyne(map_pub, full_filename_velodyne,&header_support);
}
}
if(options.gps || options.all_data)
{
header_support.stamp = current_timestamp; //ros::Time::now();
if (options.timestamps)
{
str_support = dir_timestamp_oxts + "timestamps.txt";
ifstream timestamps(str_support.c_str());
if (!timestamps.is_open())
{
string timestamps_string;
timestamps >> timestamps_string;
ROS_ERROR_STREAM("Fail to open " << timestamps_string);
node.shutdown();
return -1;
}
timestamps.seekg(30*entries_played);
getline(timestamps,str_support);
header_support.stamp = parseTime(str_support).stamp;
}
full_filename_oxts = dir_oxts + boost::str(boost::format("%010d") % entries_played ) + ".txt";
if (!getGPS(full_filename_oxts,&ros_msgGpsFix,&header_support))
{
ROS_ERROR_STREAM("Fail to open " << full_filename_oxts);
node.shutdown();
return -1;
}
if (firstGpsData)
{
ROS_DEBUG_STREAM("Setting initial GPS fix at " << endl << ros_msgGpsFix);
firstGpsData = false;
ros_msgGpsFixInitial = ros_msgGpsFix;
ros_msgGpsFixInitial.header.frame_id = "/local_map";
ros_msgGpsFixInitial.altitude = 0.0f;
}
gps_pub.publish(ros_msgGpsFix);
gps_pub_initial.publish(ros_msgGpsFixInitial);
}
if(options.imu || options.all_data)
{
header_support.stamp = current_timestamp; //ros::Time::now();
if (options.timestamps)
{
str_support = dir_timestamp_oxts + "timestamps.txt";
ifstream timestamps(str_support.c_str());
if (!timestamps.is_open())
{
string timestamps_string;
timestamps >> timestamps_string;
ROS_ERROR_STREAM("Fail to open " << timestamps_string);
node.shutdown();
return -1;
}
timestamps.seekg(30*entries_played);
getline(timestamps,str_support);
header_support.stamp = parseTime(str_support).stamp;
}
full_filename_oxts = dir_oxts + boost::str(boost::format("%010d") % entries_played ) + ".txt";
if (!getIMU(full_filename_oxts,&ros_msgImu,&header_support))
{
ROS_ERROR_STREAM("Fail to open " << full_filename_oxts);
node.shutdown();
return -1;
}
imu_pub.publish(ros_msgImu);
}
++progress;
entries_played++;
loop_rate.sleep();
}
while(entries_played<=total_entries-1 && ros::ok());
if(options.viewer)
{
ROS_INFO_STREAM(" Closing CV viewer(s)");
if(options.color || options.all_data)
cv::destroyWindow("CameraSimulator Color Viewer");
if(options.grayscale || options.all_data)
cv::destroyWindow("CameraSimulator Grayscale Viewer");
if (options.viewDisparities)
cv::destroyWindow("Reprojection of Detected Lines");
ROS_INFO_STREAM(" Closing CV viewer(s)... OK");
}
ROS_INFO_STREAM("Done!");
node.shutdown();
return 0;
}
| 43.259176 | 189 | 0.561531 | filiperinaldi |
f3956e30071100252e640894359d9a4ebf8c1d42 | 1,548 | cpp | C++ | Prog-CalibrateCamera/src/Logger.cpp | BProj-LMN/Studienarbeit | 94cb93654e58f155aa6b56b93230a49f63846e01 | [
"BSD-3-Clause"
] | null | null | null | Prog-CalibrateCamera/src/Logger.cpp | BProj-LMN/Studienarbeit | 94cb93654e58f155aa6b56b93230a49f63846e01 | [
"BSD-3-Clause"
] | null | null | null | Prog-CalibrateCamera/src/Logger.cpp | BProj-LMN/Studienarbeit | 94cb93654e58f155aa6b56b93230a49f63846e01 | [
"BSD-3-Clause"
] | null | null | null | /*
* Logger.cpp
*
* function: Logger Singleton for logging with different log levels to a file
*
* author: Jannik Beyerstedt
*/
#include "Logger.h"
#include <iomanip>
Logger::Logger() {
logfile.open("logfile.txt", std::ios::trunc);
logfile << std::setprecision(3) << std::fixed;
time_start = std::chrono::high_resolution_clock::now();
logLevel = ERROR;
}
Logger::~Logger() {
logfile.close();
}
void Logger::setLogLevel(log_t logLevel) {
this->logLevel = logLevel;
}
log_t Logger::getLogLevel() {
return logLevel;
}
std::ofstream& Logger::log(log_t logType) {
std::chrono::duration<double, std::milli> timediff_ms = std::chrono::high_resolution_clock::now() - time_start;
auto time = std::chrono::system_clock::now();
logfile << std::chrono::system_clock::to_time_t(time) << " (" << timediff_ms.count() << ") [" << logType << "] ";
return logfile;
}
std::ofstream& Logger::log() {
std::chrono::duration<double, std::milli> timediff_ms = std::chrono::high_resolution_clock::now() - time_start;
auto time = std::chrono::system_clock::now();
logfile << std::chrono::system_clock::to_time_t(time) << " (" << timediff_ms.count() << ") ";
return logfile;
}
LogScope::LogScope(const std::string& s)
: logger(Logger::getLogger()), s_(s) {
if (!(Logger::getLogger().getLogLevel() < DEBUG)) {
logger.log(DEBUG) << "entering function " << s_ << "\n";
}
}
LogScope::~LogScope() {
if (!(Logger::getLogger().getLogLevel() < DEBUG)) {
logger.log(DEBUG) << "exiting function " << s_ << "\n";
}
}
| 25.377049 | 115 | 0.646641 | BProj-LMN |
f395941baaf477d25d4a8d532a72c23989a73cf3 | 386 | cpp | C++ | competitive_programming/programming_contests/uri/the_race_of_slugs.cpp | LeandroTk/Algorithms | 569ed68eba3eeff902f8078992099c28ce4d7cd6 | [
"MIT"
] | 205 | 2018-12-01T17:49:49.000Z | 2021-12-22T07:02:27.000Z | competitive_programming/programming_contests/uri/the_race_of_slugs.cpp | LeandroTk/Algorithms | 569ed68eba3eeff902f8078992099c28ce4d7cd6 | [
"MIT"
] | 2 | 2020-01-01T16:34:29.000Z | 2020-04-26T19:11:13.000Z | competitive_programming/programming_contests/uri/the_race_of_slugs.cpp | LeandroTk/Algorithms | 569ed68eba3eeff902f8078992099c28ce4d7cd6 | [
"MIT"
] | 50 | 2018-11-28T20:51:36.000Z | 2021-11-29T04:08:25.000Z | // https://www.urionlinejudge.com.br/judge/en/problems/view/1789
#include <iostream>
using namespace std;
int main() {
int n, x, faster = 0;
while (scanf("%d", &n) != EOF) {
while (n--) {
cin >> x;
if (x > faster) faster = x;
}
if (faster < 10) cout << 1 << endl;
else if (faster < 20) cout << 2 << endl;
else cout << 3 << endl;
faster = 0;
}
return 0;
} | 14.846154 | 64 | 0.546632 | LeandroTk |
f39eb71102fb1006d6183b7187098ee51401ba17 | 3,220 | cpp | C++ | test/record/object.cpp | pmiddend/fcppt | 9f437acbb10258e6df6982a550213a05815eb2be | [
"BSL-1.0"
] | null | null | null | test/record/object.cpp | pmiddend/fcppt | 9f437acbb10258e6df6982a550213a05815eb2be | [
"BSL-1.0"
] | null | null | null | test/record/object.cpp | pmiddend/fcppt | 9f437acbb10258e6df6982a550213a05815eb2be | [
"BSL-1.0"
] | null | null | null | // Copyright Carl Philipp Reh 2009 - 2018.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <fcppt/noncopyable.hpp>
#include <fcppt/record/element.hpp>
#include <fcppt/record/get.hpp>
#include <fcppt/record/make_label.hpp>
#include <fcppt/record/set.hpp>
#include <fcppt/record/variadic.hpp>
#include <fcppt/config/external_begin.hpp>
#include <catch2/catch.hpp>
#include <utility>
#include <fcppt/config/external_end.hpp>
TEST_CASE(
"record::object",
"[record]"
)
{
class copy_only
{
public:
explicit
copy_only(
int const _value
)
:
value_(
_value
)
{
}
copy_only(
copy_only const &
) = default;
int
value() const
{
return
value_;
}
private:
int value_;
};
class move_only
{
FCPPT_NONCOPYABLE(
move_only
);
public:
explicit
move_only(
int const _value
)
:
value_{
_value
},
valid_{
true
}
{
}
move_only(
move_only &&_other
)
:
value_{
_other.value_
},
valid_{
_other.valid_
}
{
_other.valid_ =
false;
}
move_only &
operator=(
move_only &&_other
)
{
value_ =
_other.value_;
valid_ =
_other.valid_;
_other.valid_ =
false;
return
*this;
}
~move_only()
{
}
int
value() const
{
CHECK(
valid_
);
return
value_;
}
private:
int value_;
bool valid_;
};
FCPPT_RECORD_MAKE_LABEL(
int_label
);
FCPPT_RECORD_MAKE_LABEL(
bool_label
);
FCPPT_RECORD_MAKE_LABEL(
copy_only_label
);
FCPPT_RECORD_MAKE_LABEL(
move_only_label
);
typedef
fcppt::record::variadic<
fcppt::record::element<
int_label,
int
>,
fcppt::record::element<
bool_label,
bool
>,
fcppt::record::element<
copy_only_label,
copy_only
>,
fcppt::record::element<
move_only_label,
move_only
>
>
my_record;
int const arg1{
4
};
my_record test{
int_label{} =
arg1,
bool_label{} =
true,
copy_only_label{} =
copy_only(
42
),
move_only_label{} =
move_only{
10
}
};
CHECK(
fcppt::record::get<
int_label
>(
test
)
==
4
);
CHECK(
fcppt::record::get<
bool_label
>(
test
)
);
CHECK(
fcppt::record::get<
copy_only_label
>(
test
).value()
==
42
);
CHECK(
fcppt::record::get<
move_only_label
>(
test
).value()
==
10
);
my_record test2(
std::move(
test
)
);
CHECK(
fcppt::record::get<
int_label
>(
test2
)
==
4
);
CHECK(
fcppt::record::get<
bool_label
>(
test2
)
);
CHECK(
fcppt::record::get<
move_only_label
>(
test2
).value()
==
10
);
fcppt::record::set<
bool_label
>(
test2,
false
);
CHECK_FALSE(
fcppt::record::get<
bool_label
>(
test2
)
);
fcppt::record::set<
move_only_label
>(
test2,
move_only{
100
}
);
CHECK(
fcppt::record::get<
move_only_label
>(
test2
).value()
==
100
);
fcppt::record::get<
int_label
>(
test2
) =
42;
CHECK(
fcppt::record::get<
int_label
>(
test2
)
==
42
);
}
| 10.592105 | 61 | 0.581056 | pmiddend |
f39f9901fd56c6a8d1b8a44591374f786561c487 | 5,593 | cc | C++ | src/cc/kfsio/ChunkAccessToken.cc | beol/qfs | 41201cfc1ff6c081324543712d0c02074fa66326 | [
"Apache-2.0"
] | null | null | null | src/cc/kfsio/ChunkAccessToken.cc | beol/qfs | 41201cfc1ff6c081324543712d0c02074fa66326 | [
"Apache-2.0"
] | null | null | null | src/cc/kfsio/ChunkAccessToken.cc | beol/qfs | 41201cfc1ff6c081324543712d0c02074fa66326 | [
"Apache-2.0"
] | null | null | null | //---------------------------------------------------------- -*- Mode: C++ -*-
// $Id$
//
// Created 2013/10/9
// Author: Mike Ovsiannikov
//
// Copyright 2013,2016 Quantcast Corporation. All rights reserved.
//
// This file is part of Kosmos File System (KFS).
//
// 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 "ChunkAccessToken.h"
#include "common/MsgLogger.h"
namespace KFS
{
using std::ostream;
class ChunkAccessToken::Subject : public DelegationToken::Subject
{
public:
Subject(
kfsChunkId_t inChunkId,
int64_t inId)
{
char* thePtr = mBuf;
const char* const theEndPtr = thePtr + kSubjectLength;
*thePtr++ = 'C';
*thePtr++ = 'A';
kfsChunkId_t theId = inChunkId;
while (thePtr < theEndPtr - sizeof(inId)) {
*thePtr++ = (char)(theId & 0xFF);
theId >>= 8;
}
int64_t theWId = inId;
while (thePtr < theEndPtr) {
*thePtr++ = (char)(theWId & 0xFF);
theWId >>= 8;
}
}
virtual int Get(
const DelegationToken& inToken,
const char*& outPtr)
{
outPtr = mBuf;
return (((inToken.GetFlags() &
(kUsesWriteIdFlag | kUsesLeaseIdFlag)) != 0) ?
kSubjectLength : kSubjectLength - (int)sizeof(int64_t));
}
operator DelegationToken::Subject* ()
{ return this; }
private:
enum {
kSubjectLength = 2 + (int)sizeof(kfsChunkId_t) + (int)sizeof(int64_t)
};
char mBuf[kSubjectLength];
};
ChunkAccessToken::ChunkAccessToken(
kfsChunkId_t inChunkId,
kfsUid_t inUid,
TokenSeq inSeq,
kfsKeyId_t inKeyId,
int64_t inIssueTime,
uint16_t inFlags,
uint32_t inValidForSec,
const char* inKeyPtr,
int inKeyLen,
int64_t inId)
: mChunkId(inChunkId),
mDelegationToken(
inUid,
inSeq,
inKeyId,
inIssueTime,
inFlags,
inValidForSec,
inKeyPtr,
inKeyLen,
Subject(inChunkId, inId)
)
{
}
bool
ChunkAccessToken::Process(
kfsChunkId_t inChunkId,
const char* inBufPtr,
int inBufLen,
int64_t inTimeNowSec,
const CryptoKeys& inKeys,
string* outErrMsgPtr,
int64_t inId)
{
Subject theSubject(inChunkId, inId);
return (0 <= mDelegationToken.Process(
inBufPtr,
inBufLen,
inTimeNowSec,
inKeys,
0, // inSessionKeyPtr
-1, // inMaxSessionKeyLength
outErrMsgPtr,
&theSubject
));
}
bool
ChunkAccessToken::Process(
kfsChunkId_t inChunkId,
kfsUid_t inUid,
const char* inBufPtr,
int inBufLen,
int64_t inTimeNowSec,
const CryptoKeys& inKeys,
string* outErrMsgPtr,
int64_t inId)
{
if (! Process(
inChunkId,
inUid,
inBufPtr,
inBufLen,
inTimeNowSec,
inKeys,
outErrMsgPtr,
inId)) {
return false;
}
if (inUid != mDelegationToken.GetUid()) {
if (outErrMsgPtr) {
*outErrMsgPtr = "user id mismatch";
} else {
KFS_LOG_STREAM_ERROR <<
"user id mismatch: uid: " << inUid <<
" token uid: " << mDelegationToken.GetUid() <<
KFS_LOG_EOM;
}
return false;
}
return true;
}
ostream&
ChunkAccessToken::ShowSelf(
ostream& inStream) const
{
return (inStream <<
"chunkId: " << mChunkId <<
" " << mDelegationToken.Show()
);
}
/* static */ bool
ChunkAccessToken::WriteToken(
IOBufferWriter& inWriter,
kfsChunkId_t inChunkId,
kfsUid_t inUid,
TokenSeq inSeq,
kfsKeyId_t inKeyId,
int64_t inIssuedTime,
uint16_t inFlags,
uint32_t inValidForSec,
const char* inKeyPtr,
int inKeyLen,
int64_t inId)
{
Subject theSubject(inChunkId, inId);
return DelegationToken::WriteToken(
inWriter,
inUid,
inSeq,
inKeyId,
inIssuedTime,
inFlags,
inValidForSec,
inKeyPtr,
inKeyLen,
&theSubject
);
}
/* static */ bool
ChunkAccessToken::WriteToken(
ostream& inStream,
kfsChunkId_t inChunkId,
kfsUid_t inUid,
TokenSeq inSeq,
kfsKeyId_t inKeyId,
int64_t inIssuedTime,
uint16_t inFlags,
uint32_t inValidForSec,
const char* inKeyPtr,
int inKeyLen,
int64_t inId)
{
Subject theSubject(inChunkId, inId);
return DelegationToken::WriteToken(
inStream,
inUid,
inSeq,
inKeyId,
inIssuedTime,
inFlags,
inValidForSec,
inKeyPtr,
inKeyLen,
&theSubject
);
}
}
| 24.530702 | 78 | 0.547649 | beol |
f3a37d53defb5dbef57d32c49afcf11d90b318cf | 1,136 | cpp | C++ | src/XML Tree/XML_Node.cpp | VladimirAnaniev/XML-Parser | 118f71831dc5ba96d1f6e57d42560e866d0fe22b | [
"MIT"
] | 1 | 2020-09-20T16:11:58.000Z | 2020-09-20T16:11:58.000Z | src/XML Tree/XML_Node.cpp | VladimirAnaniev/XML-Parser | 118f71831dc5ba96d1f6e57d42560e866d0fe22b | [
"MIT"
] | 2 | 2017-06-03T16:29:01.000Z | 2017-08-30T11:40:29.000Z | src/XML Tree/XML_Node.cpp | VladimirAnaniev/XML-Parser | 118f71831dc5ba96d1f6e57d42560e866d0fe22b | [
"MIT"
] | null | null | null | #include "XML_Node.h"
#include "../Parser/Parser.h"
String XML_Node::getTag() const {
return this->data.tag;
}
void XML_Node::addArgument(Argument arg) {
this->data.arguments.push(arg);
}
List<Argument> &XML_Node::getArguments() {
return this->data.arguments;
}
Argument XML_Node::removeArgument(int index) {
return this->data.arguments.deleteAt(index);
}
void XML_Node::setTag(String tag) {
this->data.tag.set(tag);
}
void XML_Node::setId(String id) {
this->data.id.set(id);
}
String XML_Node::getId() const {
return this->data.id;
}
void XML_Node::setContent(String content) {
this->data.content = content;
}
String XML_Node::getContent() const {
return this->data.content;
}
XML_Node *XML_Node::findById(String id) {
if (this->getId() == id) return this;
List<TreeNode *> children = this->getChildren();
for (int i = 0; i < children.getSize(); i++) {
XML_Node *result = ((XML_Node *) children[i])->findById(id);
if (result != nullptr) return result;
}
return nullptr;
}
String XML_Node::toString() {
return Parser::nodeTreeToString(this);
}
| 19.586207 | 68 | 0.65669 | VladimirAnaniev |
f3a41cdae45cbc6517b3da51420429faa4244481 | 6,266 | cpp | C++ | Tests/UnitTests/ReaderTests/ImageReaderTests.cpp | alexboukhvalova/CNTK | 8835d4f61b393f068a4f019424bbc80c0b4e761a | [
"RSA-MD"
] | 6 | 2019-08-18T05:29:09.000Z | 2021-01-19T09:58:45.000Z | Tests/UnitTests/ReaderTests/ImageReaderTests.cpp | Omar-Belghaouti/CNTK | 422f710242c602b2660a634f2234abf5aaf5b337 | [
"RSA-MD"
] | null | null | null | Tests/UnitTests/ReaderTests/ImageReaderTests.cpp | Omar-Belghaouti/CNTK | 422f710242c602b2660a634f2234abf5aaf5b337 | [
"RSA-MD"
] | 1 | 2019-03-20T21:44:46.000Z | 2019-03-20T21:44:46.000Z | //
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
//
#include "stdafx.h"
#include "Common/ReaderTestHelper.h"
using namespace Microsoft::MSR::CNTK;
namespace Microsoft { namespace MSR { namespace CNTK { namespace Test {
struct ImageReaderFixture : ReaderFixture
{
ImageReaderFixture()
: ReaderFixture("/Data")
{
}
};
BOOST_FIXTURE_TEST_SUITE(ReaderTestSuite, ImageReaderFixture)
BOOST_AUTO_TEST_CASE(ImageReaderSimple)
{
HelperRunReaderTest<float>(
testDataPath() + "/Config/ImageReaderSimple_Config.cntk",
testDataPath() + "/Control/ImageReaderSimple_Control.txt",
testDataPath() + "/Control/ImageReaderSimple_Output.txt",
"Simple_Test",
"reader",
4,
4,
1,
1,
0,
0,
1);
}
BOOST_AUTO_TEST_CASE(ImageAndTextReaderSimple)
{
HelperRunReaderTest<float>(
testDataPath() + "/Config/ImageAndTextReaderSimple_Config.cntk",
testDataPath() + "/Control/ImageAndTextReaderSimple_Control.txt",
testDataPath() + "/Control/ImageAndTextReaderSimple_Output.txt",
"Simple_Test",
"reader",
4,
4,
1,
1,
0,
0,
1);
}
BOOST_AUTO_TEST_CASE(ImageReaderBadMap)
{
BOOST_REQUIRE_EXCEPTION(
HelperRunReaderTest<float>(
testDataPath() + "/Config/ImageReaderBadMap_Config.cntk",
testDataPath() + "/Control/ImageReaderSimple_Control.txt",
testDataPath() + "/Control/ImageReaderSimple_Output.txt",
"Simple_Test",
"reader",
4,
4,
1,
1,
0,
0,
1),
std::runtime_error,
[](std::runtime_error const& ex) { return string("Invalid map file format, must contain 2 or 3 tab-delimited columns, line 2 in file ./ImageReaderBadMap_map.txt.") == ex.what(); });
}
BOOST_AUTO_TEST_CASE(ImageReaderBadLabel)
{
BOOST_REQUIRE_EXCEPTION(
HelperRunReaderTest<float>(
testDataPath() + "/Config/ImageReaderBadLabel_Config.cntk",
testDataPath() + "/Control/ImageReaderSimple_Control.txt",
testDataPath() + "/Control/ImageReaderSimple_Output.txt",
"Simple_Test",
"reader",
4,
4,
1,
1,
0,
0,
1),
std::runtime_error,
[](std::runtime_error const& ex) { return string("Cannot parse label value on line 1, second column, in file ./ImageReaderBadLabel_map.txt.") == ex.what(); });
}
BOOST_AUTO_TEST_CASE(ImageReaderLabelOutOfRange)
{
BOOST_REQUIRE_EXCEPTION(
HelperRunReaderTest<float>(
testDataPath() + "/Config/ImageReaderLabelOutOfRange_Config.cntk",
testDataPath() + "/Control/ImageReaderSimple_Control.txt",
testDataPath() + "/Control/ImageReaderSimple_Output.txt",
"Simple_Test",
"reader",
4,
4,
1,
1,
0,
0,
1),
std::runtime_error,
[](std::runtime_error const& ex) { return string("Image 'images\\red.jpg' has invalid class id '10'. Expected label dimension is '4'. Line 3 in file ./ImageReaderLabelOutOfRange_map.txt.") == ex.what(); });
}
BOOST_AUTO_TEST_CASE(ImageReaderZip)
{
HelperRunReaderTest<float>(
testDataPath() + "/Config/ImageReaderZip_Config.cntk",
testDataPath() + "/Control/ImageReaderZip_Control.txt",
testDataPath() + "/Control/ImageReaderZip_Output.txt",
"Zip_Test",
"reader",
4,
4,
1,
1,
0,
0,
1);
}
BOOST_AUTO_TEST_CASE(ImageReaderZipMissingFile)
{
BOOST_REQUIRE_EXCEPTION(
HelperRunReaderTest<float>(
testDataPath() + "/Config/ImageReaderZipMissing_Config.cntk",
testDataPath() + "/Control/ImageReaderZip_Control.txt",
testDataPath() + "/Control/ImageReaderZip_Output.txt",
"ZipMissing_Test",
"reader",
4,
4,
1,
1,
0,
0,
1),
std::runtime_error,
[](std::runtime_error const& ex) { return string("Failed to get file info of missing.jpg, zip library error: Unknown error -1") == ex.what(); });
}
BOOST_AUTO_TEST_CASE(ImageReaderMultiView)
{
HelperRunReaderTest<float>(
testDataPath() + "/Config/ImageReaderMultiView_Config.cntk",
testDataPath() + "/Control/ImageReaderMultiView_Control.txt",
testDataPath() + "/Control/ImageReaderMultiView_Output.txt",
"MultiView_Test",
"reader",
10,
10,
1,
1,
0,
0,
1);
}
BOOST_AUTO_TEST_CASE(ImageReaderIntensityTransform)
{
HelperRunReaderTest<float>(
testDataPath() + "/Config/ImageReaderIntensityTransform_Config.cntk",
testDataPath() + "/Control/ImageReaderIntensityTransform_Control.txt",
testDataPath() + "/Control/ImageReaderIntensityTransform_Output.txt",
"IntensityTransform_Test",
"reader",
1,
1,
2,
1,
0,
0,
1);
}
BOOST_AUTO_TEST_CASE(ImageReaderColorTransform)
{
HelperRunReaderTest<float>(
testDataPath() + "/Config/ImageReaderColorTransform_Config.cntk",
testDataPath() + "/Control/ImageReaderColorTransform_Control.txt",
testDataPath() + "/Control/ImageReaderColorTransform_Output.txt",
"ColorTransform_Test",
"reader",
1,
1,
2,
1,
0,
0,
1);
}
BOOST_AUTO_TEST_CASE(ImageReaderGrayscale)
{
HelperRunReaderTest<float>(
testDataPath() + "/Config/ImageReaderGrayscale_Config.cntk",
testDataPath() + "/Control/ImageReaderGrayscale_Control.txt",
testDataPath() + "/Control/ImageReaderGrayscale_Output.txt",
"Grayscale_Test",
"reader",
1,
1,
1,
1,
0,
0,
1);
}
BOOST_AUTO_TEST_SUITE_END()
} } } }
| 27.848889 | 218 | 0.588733 | alexboukhvalova |
f3a577fcb91417cf1d9a6e4807469ace4b0d48d0 | 5,612 | hpp | C++ | ntt/schoenhage-strassen-radix2.hpp | NachiaVivias/library | 73091ddbb00bc59328509c8f6e662fea2b772994 | [
"CC0-1.0"
] | 69 | 2020-11-06T05:21:42.000Z | 2022-03-29T03:38:35.000Z | ntt/schoenhage-strassen-radix2.hpp | NachiaVivias/library | 73091ddbb00bc59328509c8f6e662fea2b772994 | [
"CC0-1.0"
] | 21 | 2020-07-25T04:47:12.000Z | 2022-02-01T14:39:29.000Z | ntt/schoenhage-strassen-radix2.hpp | NachiaVivias/library | 73091ddbb00bc59328509c8f6e662fea2b772994 | [
"CC0-1.0"
] | 9 | 2020-11-06T11:55:10.000Z | 2022-03-20T04:45:31.000Z | #pragma once
template <typename T>
struct Schoenhage_Strassen_radix2 {
T* buf = nullptr;
void rot(T* dst, T* src, int s, int d) {
assert(0 <= d and d < 2 * s);
bool f = s <= d;
if (s <= d) d -= s;
int i = 0;
if (f) {
for (; i < s - d; i++) dst[i + d] = -src[i];
for (; i < s; i++) dst[i + d - s] = src[i];
} else {
for (; i < s - d; i++) dst[i + d] = src[i];
for (; i < s; i++) dst[i + d - s] = -src[i];
}
}
void in_add(T* dst, T* src, int s) {
for (int i = 0; i < s; i++) dst[i] += src[i];
}
void in_sub(T* dst, T* src, int s) {
for (int i = 0; i < s; i++) dst[i] -= src[i];
}
void cp(T* dst, T* src, int s) { memcpy(dst, src, s * sizeof(T)); }
void reset(T* dst, int s) { fill(dst, dst + s, T()); }
// R[x] / (1 + x^(2^m)) 上の長さ2^LのFFT
void fft(T* a, int l, int m) {
if (l == 0) return;
int L = 1 << l, M = 1 << m;
assert(M * 2 >= L);
assert(buf != nullptr);
vector<int> dw(l - 1);
for (int i = 0; i < l - 1; i++) {
dw[i] = (1 << (l - 2 - i)) + (1 << (l - 1 - i)) - (1 << (l - 1));
if (dw[i] < 0) dw[i] += L;
if (L == M) dw[i] *= 2;
if (2 * L == M) dw[i] *= 4;
}
for (int d = L; d >>= 1;) {
int w = 0;
for (int s = 0, k = 0;;) {
for (int i = s, j = s + d; i < s + d; ++i, ++j) {
T *ai = a + i * M, *aj = a + j * M;
rot(buf, aj, M, w);
cp(aj, ai, M);
in_add(ai, buf, M);
in_sub(aj, buf, M);
}
if ((s += 2 * d) >= L) break;
w += dw[__builtin_ctz(++k)];
if (w >= 2 * M) w -= 2 * M;
}
}
}
// R[x] / (1 + x^(2^m)) 上の長さ2^LのIFFT
void ifft(T* a, int l, int m) {
if (l == 0) return;
int L = 1 << l, M = 1 << m;
assert(M * 2 >= L);
assert(buf != nullptr);
vector<int> dw(l - 1);
for (int i = 0; i < l - 1; i++) {
dw[i] = (1 << (l - 2 - i)) + (1 << (l - 1 - i)) - (1 << (l - 1));
if (dw[i] < 0) dw[i] += L;
if (L == M) dw[i] *= 2;
if (2 * L == M) dw[i] *= 4;
}
for (int d = 1; d < L; d *= 2) {
int w = 0;
for (int s = 0, k = 0;;) {
for (int i = s, j = s + d; i < s + d; ++i, ++j) {
T *ai = a + i * M, *aj = a + j * M;
cp(buf, ai, M);
in_add(ai, aj, M);
in_sub(buf, aj, M);
rot(aj, buf, M, w);
}
if ((s += 2 * d) >= L) break;
w -= dw[__builtin_ctz(++k)];
if (w < 0) w += 2 * M;
}
}
}
// a <- ab / (x^(2^n)+1)
int naive_mul(T* a, T* b, int n) {
int N = 1 << n;
reset(buf, N);
for (int i = 0; i < N; i++) {
int j = 0;
for (; j < N - i; j++) buf[i + j] += a[i] * b[j];
for (; j < N; j++) buf[i + j - N] -= a[i] * b[j];
}
cp(a, buf, N);
return 0;
}
// a <- ab / (x^(2^n)+1)
int inplace_mul(T* a, T* b, int n) {
if (n <= 5) {
naive_mul(a, b, n);
return 0;
}
int l = (n + 1) / 2;
int m = n / 2;
int L = 1 << l, M = 1 << m, N = 1 << n;
int cnt = 0;
// R[x] (x^(2^(m+1))-1) R[y] (y^(2^l)-1)
vector<T> A(N * 2), B(N * 2);
reset(buf + M, M);
for (int i = 0, s = 0, ds = 2 * M / L; i < L; i++) {
// y -> x^{2m/r} y
cp(buf, a + i * M, M);
rot(A.data() + i * M * 2, buf, 2 * M, s);
cp(buf, b + i * M, M);
rot(B.data() + i * M * 2, buf, 2 * M, s);
s += ds;
if (s >= 4 * M) s -= 4 * M;
}
fft(A.data(), l, m + 1);
fft(B.data(), l, m + 1);
for (int i = 0; i < L; i++) {
cnt = inplace_mul(A.data() + i * M * 2, B.data() + i * M * 2, m + 1);
}
ifft(A.data(), l, m + 1);
for (int i = 0, s = 0, ds = 2 * M / L; i < L; i++) {
// y -> x^{-2m/r} y
cp(buf, A.data() + i * M * 2, 2 * M);
rot(A.data() + i * M * 2, buf, 2 * M, s);
s -= ds;
if (s < 0) s += 4 * M;
}
for (int i = 0; i < L; i++) {
for (int j = 0; j < M; j++) {
a[i * M + j] = A[i * M * 2 + j];
if (i == 0) {
a[i * M + j] -= A[(L - 1) * M * 2 + M + j];
} else {
a[i * M + j] += A[(i - 1) * M * 2 + M + j];
}
}
}
return cnt + l;
}
// a <- ab / (x^(2^n)-1)
int inplace_mul2(T* a, T* b, int n) {
if (n <= 5) {
naive_mul(a, b, n);
return 0;
}
int l = (n + 1) / 2;
int m = n / 2;
int L = 1 << l, M = 1 << m, N = 1 << n;
int cnt = 0;
// R[x] (x^(2^(m+1))-1) R[y] (y^(2^l)-1)
vector<T> A(N * 2), B(N * 2);
for (int i = 0; i < L; i++) {
cp(A.data() + i * M * 2, a + i * M, M);
cp(B.data() + i * M * 2, b + i * M, M);
}
fft(A.data(), l, m + 1);
fft(B.data(), l, m + 1);
for (int i = 0; i < L; i++) {
cnt = inplace_mul(A.data() + i * M * 2, B.data() + i * M * 2, m + 1);
}
ifft(A.data(), l, m + 1);
for (int i = 0; i < L; i++) {
for (int j = 0; j < M; j++) {
a[i * M + j] = A[i * M * 2 + j];
a[i * M + j] += A[(i ? i - 1 : L - 1) * M * 2 + M + j];
}
}
return cnt + l;
}
pair<vector<T>, int> multiply(const vector<T>& a, const vector<T>& b) {
int L = a.size() + b.size() - 1;
int M = 1, m = 0;
while (M < L) M *= 2, m++;
buf = new T[M];
vector<T> s(M), t(M);
for (int i = 0; i < (int)a.size(); i++) s[i] = a[i];
for (int i = 0; i < (int)b.size(); i++) t[i] = b[i];
int cnt = inplace_mul2(s.data(), t.data(), m);
vector<T> u(L);
for (int i = 0; i < L; i++) u[i] = s[i];
delete[] buf;
return make_pair(u, cnt);
}
};
/**
* @brief Schönhage-Strassen Algorithm(radix-2)
*/
| 26.347418 | 75 | 0.349252 | NachiaVivias |
f3a8bb2621f54b42e2e744a1314cb98f8e1c4a20 | 1,304 | hh | C++ | include/MEPED_DetectorMessenger.hh | kbyando/meped-etelescope | cb1805cb8d1662a561fb1b7a405aecbfffac8f2c | [
"Apache-2.0"
] | null | null | null | include/MEPED_DetectorMessenger.hh | kbyando/meped-etelescope | cb1805cb8d1662a561fb1b7a405aecbfffac8f2c | [
"Apache-2.0"
] | null | null | null | include/MEPED_DetectorMessenger.hh | kbyando/meped-etelescope | cb1805cb8d1662a561fb1b7a405aecbfffac8f2c | [
"Apache-2.0"
] | null | null | null | // NOAA POES Monte Carlo Simulation v1.3, 17/09/2008e
// MEPED (Medium Energy Proton and Electron Detector)
// Karl Yando, Professor Robyn Millan
// Dartmouth College, 2008
//
// "MEPED_DetectorMessenger.hh" - (generic)
#ifndef MEPED_DetectorMessenger_h
#define MEPED_DetectorMessenger_h 1
#include "globals.hh"
#include "G4UImessenger.hh"
class MEPED_DetectorConstruction;
class G4UIdirectory;
class G4UIcmdWithAString;
class G4UIcmdWithAnInteger;
class G4UIcmdWithADoubleAndUnit;
class G4UIcmdWithoutParameter;
class MEPED_DetectorMessenger: public G4UImessenger
{
public:
MEPED_DetectorMessenger(MEPED_DetectorConstruction* );
~MEPED_DetectorMessenger();
void SetNewValue(G4UIcommand*, G4String);
private:
MEPED_DetectorConstruction* MEPED_Detector;
G4UIdirectory* MEPEDDir;
G4UIdirectory* detDir;
G4UIcmdWithAString* DeteMaterCmd;
G4UIcmdWithAString* ShieldMaterCmd;
G4UIcmdWithAString* HouseMaterCmd;
G4UIcmdWithAString* ContactMaterCmd;
G4UIcmdWithAString* BelvilleMaterCmd;
G4UIcmdWithAString* InsulatorMaterCmd;
G4UIcmdWithAString* FoilMaterCmd;
G4UIcmdWithADoubleAndUnit* DetectorThickCmd;
G4UIcmdWithoutParameter* UpdateCmd;
};
#endif
| 27.744681 | 58 | 0.742331 | kbyando |
f3a99d7e42e117c5859ebaaabe12d20ddb502f45 | 4,281 | hpp | C++ | engine/gems/image/conversions.hpp | stereoboy/isaac_sdk_20191213 | 73c863254e626c8d498870189fbfb20be4e10fb3 | [
"FSFAP"
] | 1 | 2020-04-14T13:55:16.000Z | 2020-04-14T13:55:16.000Z | engine/gems/image/conversions.hpp | stereoboy/isaac_sdk_20191213 | 73c863254e626c8d498870189fbfb20be4e10fb3 | [
"FSFAP"
] | 4 | 2020-09-25T22:34:29.000Z | 2022-02-09T23:45:12.000Z | engine/gems/image/conversions.hpp | stereoboy/isaac_sdk_20191213 | 73c863254e626c8d498870189fbfb20be4e10fb3 | [
"FSFAP"
] | 1 | 2020-07-02T11:51:17.000Z | 2020-07-02T11:51:17.000Z | /*
Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
NVIDIA CORPORATION and its licensors retain all intellectual property
and proprietary rights in and to this software, related documentation
and any modifications thereto. Any use, reproduction, disclosure or
distribution of this software and related documentation without an express
license agreement from NVIDIA CORPORATION is strictly prohibited.
*/
#pragma once
#include "engine/core/image/image.hpp"
#include "engine/core/tensor/tensor.hpp"
#include "third_party/nlohmann/json.hpp"
namespace isaac {
// Convert the image encoded in yuyv to rgb.
// The yuyv format is described here:
// https://www.linuxtv.org/downloads/v4l-dvb-apis-old/V4L2-PIX-FMT-YUYV.html
void ConvertYuyvToRgb(const Image2ub& yuyv, Image3ub& rgb);
// Convert a pixels colorspace from rgb to hsv.
// The rgb values are expected to be in [0, 1].
// The result will have H in [0, 360], S in [0, 255], V in [0, 255].
// https://en.wikipedia.org/wiki/HSL_and_HSV
Pixel3f RgbToHsv(const Pixel3f& rgb);
// Convert a float32 RGBA image to a uint8 RGB image
// Input RGBA pixel values are expected to be in [0, 1].
// Result RGB pixel values will be in [0, 255].
void ConvertRgbaToRgb(ImageConstView4f source, ImageView3ub target);
// Convert a uint8 RGBA image to a uint8 RGB image dropping the alpha channel
void ConvertRgbaToRgb(ImageConstView4ub source, ImageView3ub target);
// Convert a uint8 BGRA image to a uint8 RGB image dropping the alpha channel
void ConvertBgraToRgb(ImageConstView4ub source, ImageView3ub target);
// Convert a uint8 RGB image to a uint8 RGBA image and sets the alpha channel to `alpha`.
void ConvertRgbToRgba(ImageConstView3ub source, ImageView4ub target,
uint8_t alpha = 255);
// Converts a uint16_t image to a 1f image using a scale factor
void ConvertUi16ToF32(ImageConstView1ui16 source, ImageView1f target, float scale);
// Converts a 1f image to a uint16_t image using a scale factor
void ConvertF32ToUi16(ImageConstView1f source, ImageView1ui16 target, float scale);
// The indexing order for row, column, channel can be specified by the ImageToTensorIndexOrder
// enum.
enum class ImageToTensorIndexOrder {
k012 = 1, // Specifies ordering as row, column, channel
k201 = 2 // Specifies ordering as channel, row, column
};
// Use strings when serializing ImageToTensorIndexOrder enum
NLOHMANN_JSON_SERIALIZE_ENUM(ImageToTensorIndexOrder, {
{ImageToTensorIndexOrder::k012, "012"},
{ImageToTensorIndexOrder::k201, "201"},
});
// The normalization method for row, column, channel can be specified by the
// ImageToTensorNormalization enum.
enum class ImageToTensorNormalization {
kNone = 1,
kUnit = 2, // Normalize each pixel intensity into a range [0, 1] or vice versa
kPositiveNegative = 3, // Normalize each pixel intensity into a range [-1, 1] or vice versa
kHalfAndHalf = 4 // Normalize each pixel intensity into a range [-0.5, 0.5] or vice versa
};
// Use strings when serializing ImageToTensorNormalization enum
NLOHMANN_JSON_SERIALIZE_ENUM(ImageToTensorNormalization, {
{ImageToTensorNormalization::kNone, "None"},
{ImageToTensorNormalization::kUnit, "Unit"},
{ImageToTensorNormalization::kPositiveNegative, "PositiveNegative"},
{ImageToTensorNormalization::kHalfAndHalf, "HalfAndHalf"},
});
// Copy an image into a tensor and normalize each pixel intensity into a given range.
void ImageToNormalizedTensor(
ImageConstView3ub rgb_image,
Tensor3f& tensor,
ImageToTensorIndexOrder index_order = ImageToTensorIndexOrder::k012,
ImageToTensorNormalization normalization = ImageToTensorNormalization::kPositiveNegative);
// Converts a 3-channel 8-bit image to a 32-bit floating point tensor.
void ImageToNormalizedTensor(
CudaImageConstView3ub rgb_image,
CudaTensorView3f result,
ImageToTensorIndexOrder index_order = ImageToTensorIndexOrder::k012,
ImageToTensorNormalization normalization = ImageToTensorNormalization::kPositiveNegative);
// Copy a tensor into an image and normalize each pixel intensity into into a given range.
void NormalizedTensorToImage(
TensorConstView3f tensor,
ImageToTensorNormalization normalization, Image3ub& rgb_image);
} // namespace isaac
| 42.81 | 98 | 0.772483 | stereoboy |
f3aa41b696f21cba2f2d1a5dfa4b8dd8664c7306 | 36,350 | cpp | C++ | src/SurfaceSource/SurfaceSource.cpp | sellitforcache/ss2dist | 943284bca9ca5ce8ffeb43ef3b6ef2e39d207702 | [
"BSD-3-Clause"
] | null | null | null | src/SurfaceSource/SurfaceSource.cpp | sellitforcache/ss2dist | 943284bca9ca5ce8ffeb43ef3b6ef2e39d207702 | [
"BSD-3-Clause"
] | null | null | null | src/SurfaceSource/SurfaceSource.cpp | sellitforcache/ss2dist | 943284bca9ca5ce8ffeb43ef3b6ef2e39d207702 | [
"BSD-3-Clause"
] | 1 | 2018-09-25T13:50:15.000Z | 2018-09-25T13:50:15.000Z | #include <fstream>
#include <vector>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <valarray>
#include <climits>
#include <sstream>
#include <sys/stat.h>
#include <bitset>
#include "SurfaceSource.hpp"
/*
Adapated from https://wiki.calculquebec.ca/w/C%2B%2B_:_fichier_Fortran_binaire/en
*/
void SurfaceSource::Init(){
// init paramters
strncpy(id, " \0" , 9 );
strncpy(kods, " \0" , 9 );
strncpy(vers, " \0" , 6 );
strncpy(lods, " \0" , 9 );
strncpy(idtms, " \0" , 20 );
strncpy(probs, " \0" , 20 );
strncpy(aids, " \0" , 81 );
knods = 0;
np1 = 0;
nrss = 0;
nrcd = 0;
njsw = 0;
niss = 0;
niwr = 0;
mipts = 0;
kjaq = 0;
surface_count = 0;
// init particle lookup table
strncpy(particles[ 1-1].name , "neutron\0" , 8);
strncpy(particles[ 5-1].name , "anti-neutron\0" ,13);
strncpy(particles[ 2-1].name , "photon\0" , 7);
strncpy(particles[ 3-1].name , "electron\0" , 9);
strncpy(particles[ 8-1].name , "positron\0" , 9);
strncpy(particles[ 4-1].name , "muon-\0" , 6);
strncpy(particles[ 16-1].name , "muon+\0" , 6);
strncpy(particles[ 6-1].name , "electron neutrino\0" ,18);
strncpy(particles[ 17-1].name , "anti-electron neutrino\0" ,23);
strncpy(particles[ 7-1].name , "muon neutrino\0" ,14);
strncpy(particles[ 18-1].name , "anti muon neutrino\0" ,19);
strncpy(particles[ 9-1].name , "proton\0" , 7);
strncpy(particles[ 19-1].name , "anti-proton\0" ,12);
strncpy(particles[ 10-1].name , "lambda baryon\0" ,14);
strncpy(particles[ 25-1].name , "anti lambda baryon\0" ,19);
strncpy(particles[ 11-1].name , "positive sigma baryon\0" ,22);
strncpy(particles[ 26-1].name , "anti positive sigma baryon\0" ,17);
strncpy(particles[ 12-1].name , "negative sigma baryon\0" ,22);
strncpy(particles[ 27-1].name , "anti negative sigma baryon\0" ,27);
strncpy(particles[ 13-1].name , "cascade\0" , 8);
strncpy(particles[ 28-1].name , "anti cascade\0" ,13);
strncpy(particles[ 14-1].name , "negative cascade\0" ,17);
strncpy(particles[ 29-1].name , "positive cascade\0" ,17);
strncpy(particles[ 15-1].name , "omega baryon\0" ,13);
strncpy(particles[ 30-1].name , "anti omega baryon\0" ,18);
strncpy(particles[ 20-1].name , "positive pion\0" ,14);
strncpy(particles[ 35-1].name , "negative pion\0" ,14);
strncpy(particles[ 21-1].name , "neutral pion\0" ,13);
strncpy(particles[ 22-1].name , "positive kaon\0" ,14);
strncpy(particles[ 36-1].name , "negative kaon\0" ,14);
strncpy(particles[ 23-1].name , "kaon, short\0" ,12);
strncpy(particles[ 24-1].name , "kaon, long\0" ,11);
strncpy(particles[ 31-1].name , "deuteron\0" , 9);
strncpy(particles[ 32-1].name , "triton\0" , 7);
strncpy(particles[ 33-1].name , "helion\0" , 7);
strncpy(particles[ 34-1].name , "alpha\0" , 6);
strncpy(particles[ 37-1].name , "heavy ions\0" ,11);
//
strncpy(particles[ 1-1].symbol , "n\0", 2);
strncpy(particles[ 5-1].symbol , "q\0", 2);
strncpy(particles[ 2-1].symbol , "p\0", 2);
strncpy(particles[ 3-1].symbol , "e\0", 2);
strncpy(particles[ 8-1].symbol , "f\0", 2);
strncpy(particles[ 4-1].symbol , "|\0", 2);
strncpy(particles[ 16-1].symbol , "!\0", 2);
strncpy(particles[ 6-1].symbol , "u\0", 2);
strncpy(particles[ 17-1].symbol , "<\0", 2);
strncpy(particles[ 7-1].symbol , "v\0", 2);
strncpy(particles[ 18-1].symbol , ">\0", 2);
strncpy(particles[ 9-1].symbol , "h\0", 2);
strncpy(particles[ 19-1].symbol , "g\0", 2);
strncpy(particles[ 10-1].symbol , "l\0", 2);
strncpy(particles[ 25-1].symbol , "b\0", 2);
strncpy(particles[ 11-1].symbol , "+\0", 2);
strncpy(particles[ 26-1].symbol , "_\0", 2);
strncpy(particles[ 12-1].symbol , "-\0", 2);
strncpy(particles[ 27-1].symbol , "~\0", 2);
strncpy(particles[ 13-1].symbol , "x\0", 2);
strncpy(particles[ 28-1].symbol , "c\0", 2);
strncpy(particles[ 14-1].symbol , "y\0", 2);
strncpy(particles[ 29-1].symbol , "w\0", 2);
strncpy(particles[ 15-1].symbol , "o\0", 2);
strncpy(particles[ 30-1].symbol , "@\0", 2);
strncpy(particles[ 20-1].symbol , "/\0", 2);
strncpy(particles[ 35-1].symbol , "*\0", 2);
strncpy(particles[ 21-1].symbol , "z\0", 2);
strncpy(particles[ 22-1].symbol , "k\0", 2);
strncpy(particles[ 36-1].symbol , "?\0", 2);
strncpy(particles[ 23-1].symbol , "%\0", 2);
strncpy(particles[ 24-1].symbol , "^\0", 2);
strncpy(particles[ 31-1].symbol , "d\0", 2);
strncpy(particles[ 32-1].symbol , "t\0", 2);
strncpy(particles[ 33-1].symbol , "s\0", 2);
strncpy(particles[ 34-1].symbol , "a\0", 2);
strncpy(particles[ 37-1].symbol , "#\0", 2);
// init surface lookup table
strncpy(surface_card[ 0].symbol , "XXX\0" , 4);
strncpy(surface_card[ 1].symbol , "p \0" , 4);
strncpy(surface_card[ 2].symbol , "px \0" , 4);
strncpy(surface_card[ 3].symbol , "py \0" , 4);
strncpy(surface_card[ 4].symbol , "pz \0" , 4);
strncpy(surface_card[ 5].symbol , "so \0" , 4);
strncpy(surface_card[ 6].symbol , "s \0" , 4);
strncpy(surface_card[ 7].symbol , "sx \0" , 4);
strncpy(surface_card[ 8].symbol , "sy \0" , 4);
strncpy(surface_card[ 9].symbol , "sz \0" , 4);
strncpy(surface_card[10].symbol , "c/x\0" , 4);
strncpy(surface_card[11].symbol , "c/y\0" , 4);
strncpy(surface_card[12].symbol , "c/z\0" , 4);
strncpy(surface_card[13].symbol , "cx \0" , 4);
strncpy(surface_card[14].symbol , "cy \0" , 4);
strncpy(surface_card[15].symbol , "cz \0" , 4);
strncpy(surface_card[16].symbol , "k/x\0" , 4);
strncpy(surface_card[17].symbol , "k/y\0" , 4);
strncpy(surface_card[18].symbol , "k/z\0" , 4);
strncpy(surface_card[19].symbol , "kx \0" , 4);
strncpy(surface_card[20].symbol , "ky \0" , 4);
strncpy(surface_card[21].symbol , "kz \0" , 4);
strncpy(surface_card[22].symbol , "sq \0" , 4);
strncpy(surface_card[23].symbol , "gq \0" , 4);
strncpy(surface_card[24].symbol , "tx \0" , 4);
strncpy(surface_card[25].symbol , "ty \0" , 4);
strncpy(surface_card[26].symbol , "tz \0" , 4);
strncpy(surface_card[27].symbol , "x \0" , 4);
strncpy(surface_card[28].symbol , "y \0" , 4);
strncpy(surface_card[29].symbol , "z \0" , 4);
strncpy(surface_card[30].symbol , "box\0" , 4);
strncpy(surface_card[31].symbol , "rpp\0" , 4);
strncpy(surface_card[32].symbol , "sph\0" , 4);
strncpy(surface_card[33].symbol , "rcc\0" , 4);
strncpy(surface_card[34].symbol , "rec\0" , 4);
strncpy(surface_card[35].symbol , "ell\0" , 4);
strncpy(surface_card[36].symbol , "trc\0" , 4);
strncpy(surface_card[37].symbol , "wed\0" , 4);
strncpy(surface_card[38].symbol , "arb\0" , 4);
strncpy(surface_card[39].symbol , "rhp\0" , 4);
strncpy(surface_card[40].symbol , "hex\0" , 4);
//
surface_card[ 0].n_coefficients = 0;
surface_card[ 1].n_coefficients = 4;
surface_card[ 2].n_coefficients = 1;
surface_card[ 3].n_coefficients = 1;
surface_card[ 4].n_coefficients = 1;
surface_card[ 5].n_coefficients = 1;
surface_card[ 6].n_coefficients = 4;
surface_card[ 7].n_coefficients = 2;
surface_card[ 8].n_coefficients = 2;
surface_card[ 9].n_coefficients = 2;
surface_card[10].n_coefficients = 3;
surface_card[11].n_coefficients = 3;
surface_card[12].n_coefficients = 3;
surface_card[13].n_coefficients = 1;
surface_card[14].n_coefficients = 1;
surface_card[15].n_coefficients = 1;
surface_card[16].n_coefficients = 5;
surface_card[17].n_coefficients = 5;
surface_card[18].n_coefficients = 5;
surface_card[19].n_coefficients = 3;
surface_card[20].n_coefficients = 3;
surface_card[21].n_coefficients = 3;
surface_card[22].n_coefficients = 10;
surface_card[23].n_coefficients = 10;
surface_card[24].n_coefficients = 6;
surface_card[25].n_coefficients = 6;
surface_card[26].n_coefficients = 6;
surface_card[27].n_coefficients = 0;
surface_card[28].n_coefficients = 0;
surface_card[29].n_coefficients = 0;
surface_card[30].n_coefficients = 12;
surface_card[31].n_coefficients = 6;
surface_card[32].n_coefficients = 4;
surface_card[33].n_coefficients = 7;
surface_card[34].n_coefficients = 12;
surface_card[35].n_coefficients = 7;
surface_card[36].n_coefficients = 8;
surface_card[37].n_coefficients = 12;
surface_card[38].n_coefficients = 30;
surface_card[39].n_coefficients = 15;
surface_card[40].n_coefficients = 15;
//
strncpy(surface_card[ 0].description , "INDEXING ERROR \0", 41);
strncpy(surface_card[ 1].description , "General plane \0", 41);
strncpy(surface_card[ 2].description , "Plane normal to X-axis \0", 41);
strncpy(surface_card[ 3].description , "Plane normal to Y-axis \0", 41);
strncpy(surface_card[ 4].description , "Plane normal to Z-axis \0", 41);
strncpy(surface_card[ 5].description , "Sphere centered at the origin \0", 41);
strncpy(surface_card[ 6].description , "General sphere \0", 41);
strncpy(surface_card[ 7].description , "Sphere centered on X-axis \0", 41);
strncpy(surface_card[ 8].description , "Sphere centered on Y-axis \0", 41);
strncpy(surface_card[ 9].description , "Sphere centered on Z-axis \0", 41);
strncpy(surface_card[10].description , "Cylinder parallel to X-axis \0", 41);
strncpy(surface_card[11].description , "Cylinder parallel to Y-axis \0", 41);
strncpy(surface_card[12].description , "Cylinder parallel to Z-axis \0", 41);
strncpy(surface_card[13].description , "Cylinder on X-axis \0", 41);
strncpy(surface_card[14].description , "Cylinder on Y-axis \0", 41);
strncpy(surface_card[15].description , "Cylinder on Z-axis \0", 41);
strncpy(surface_card[16].description , "Cone parallel to X-axis \0", 41);
strncpy(surface_card[17].description , "Cone parallel to Y-axis \0", 41);
strncpy(surface_card[18].description , "Cone parallel to Z-axis \0", 41);
strncpy(surface_card[19].description , "Cone on X-axis \0", 41);
strncpy(surface_card[20].description , "Cone on Y-axis \0", 41);
strncpy(surface_card[21].description , "Cone on Z-axis \0", 41);
strncpy(surface_card[22].description , "Quadric parallel to X-,Y-, or Z-axis \0", 41);
strncpy(surface_card[23].description , "Quadric not parallel to X-,Y-, or Z-axis\0", 41);
strncpy(surface_card[24].description , "Torus parallel to X-axis \0", 41);
strncpy(surface_card[25].description , "Torus parallel to Y-axis \0", 41);
strncpy(surface_card[26].description , "Torus parallel to Z-axis \0", 41);
strncpy(surface_card[27].description , "Surface defined by points sym. about X \0", 41);
strncpy(surface_card[28].description , "Surface defined by points sym. about Y \0", 41);
strncpy(surface_card[29].description , "Surface defined by points sym. about Z \0", 41);
strncpy(surface_card[30].description , "Arbitrarily oriented orthogonal box \0", 41);
strncpy(surface_card[31].description , "Rectangular Parallelepiped \0", 41);
strncpy(surface_card[32].description , "Sphere \0", 41);
strncpy(surface_card[33].description , "Right Circular Cylinder \0", 41);
strncpy(surface_card[34].description , "Right Elliptical Cylinder \0", 41);
strncpy(surface_card[35].description , "Ellipsoid \0", 41);
strncpy(surface_card[36].description , "Truncated Right-angle Cone \0", 41);
strncpy(surface_card[37].description , "Wedge \0", 41);
strncpy(surface_card[38].description , "Arbitrary polydron \0", 41);
strncpy(surface_card[39].description , "Right Hexagonal Prism \0", 41);
strncpy(surface_card[40].description , "Right Hexagonal Prism - Same as RHP \0", 41);
}
//
// CON/DE-STRUCTORS
//
SurfaceSource::~SurfaceSource(){
input_file.close();
output_file.close();
}
SurfaceSource::SurfaceSource(const std::string& fileName){
Init();
OpenWssaFile_Read(fileName.c_str());
}
SurfaceSource::SurfaceSource(const std::string& fileName1, const std::string& fileName2){
Init();
OpenWssaFile_Read( fileName1.c_str());
OpenWssaFile_Write(fileName2.c_str());
}
SurfaceSource::SurfaceSource(const char* fileName){
Init();
OpenWssaFile_Read(fileName);
}
SurfaceSource::SurfaceSource(const char* fileName1, const char* fileName2){
Init();
OpenWssaFile_Read(fileName1);
OpenWssaFile_Write(fileName2);
}
SurfaceSource::SurfaceSource(const std::string& fileName, const int flag){
Init();
switch(flag){
case RSSA_READ: OpenWssaFile_Read( fileName.c_str()); break;
case RSSA_WRITE: OpenWssaFile_Write(fileName.c_str()); break;
}
}
SurfaceSource::SurfaceSource(const char* fileName, const int flag){
Init();
switch(flag){
case RSSA_READ: OpenWssaFile_Read( fileName); break;
case RSSA_WRITE: OpenWssaFile_Write(fileName); break;
}
}
//
// FILE IO
//
bool SurfaceSource::OpenWssaFile_Read(const char* fileName){
// for file check
struct stat buffer;
// set object name
input_file_name.assign(fileName);
// open file
if( (stat (fileName, &buffer) == 0)){
input_file.open(fileName, std::ios::in | std::ios::binary);
return true;
}
else{
printf("problem opening %s for reading.\n",fileName);
return false;
}
}
bool SurfaceSource::OpenWssaFile_Write(const char* fileName){
// for file check
struct stat buffer;
// set object name
output_file_name.assign(fileName);
// open file, make sure it doens't already exist
if( (stat (fileName, &buffer) != 0)){
output_file.open(fileName, std::ios::out | std::ios::binary);
return true;
}
else{
printf("problem opening %s for writing.\n",fileName);
return false;
}
}
//
// RECORD READS
//
bool SurfaceSource::ReadRecord(void** destination, size_t* size, size_t NumberOfEntries)
{
int record_length0 = 0;
int record_length1 = 0;
int null = 0;
int length_read = 0;
int dist_to_end = 0;
if (input_file.good())
{
// read starting delimiter
input_file.read((char*) &record_length0, RECORD_DELIMITER_LENGTH);
//printf("READ RECORD LENGTH %d\n",record_length0);
// read what's asked for
for(int i=0;i<NumberOfEntries;i++){
length_read = length_read + size[i];
if(length_read>record_length0){
printf("DATA REQUESTED (%d) OVERRAN RECORD LENGTH (%d)!\n",length_read,record_length0);
return false;
}
else{
input_file.read((char*) destination[i], size[i]);
}
}
// go to the end of the record
dist_to_end = record_length0-length_read;
if( dist_to_end > 0 ){
printf("--> skipping ahead %d bytes to end of record after %d entries\n",dist_to_end, NumberOfEntries);
input_file.seekg(dist_to_end, std::ios::cur);
}
// read ending delimiter, assert
input_file.read((char*) &record_length1, RECORD_DELIMITER_LENGTH);
if(record_length0!=record_length1){
printf("BEGINNING (%d) AND ENDING (%d) RECORD LENGTH DELIMITERS DO NOT MATCH\n",record_length0,record_length1);
return false;
}
else{
return true;
}
}
else
{
return false;
}
}
bool SurfaceSource::ReadSurfaceRecord0(int* numbers, int* types, int* lengths, surface* parameters)
{
// internal variables
int record_length0 = 0;
int record_length1 = 0;
// read record
if (input_file.good())
{
input_file.read((char*) &record_length0, sizeof(record_length0));
input_file.read((char*) numbers, sizeof(int));
input_file.read((char*) types, sizeof(int));
input_file.read((char*) lengths, sizeof(int));
input_file.read((char*) parameters,lengths[0]*sizeof(parameters->value[0]));
input_file.read((char*) &record_length1, sizeof(record_length1));
if(record_length0!=record_length1){
printf("SurfaceRecord0 BEGINNING (%d) AND ENDING (%d) RECORD LENGTH DELIMITERS DO NOT MATCH\n",record_length0,record_length1);
return false;
}
else{
return true;
}
}
else
{
return false;
}
}
bool SurfaceSource::ReadSurfaceRecord1(int* numbers, int* types, int* lengths, surface* parameters, int* facets)
{
// internal variables
int record_length = 0;
if (input_file.good())
{
input_file.read((char*) &record_length, sizeof(record_length));
input_file.read((char*) numbers, sizeof(int));
input_file.read((char*) facets, sizeof(int));
input_file.read((char*) types, sizeof(int));
input_file.read((char*) lengths, sizeof(int));
input_file.read((char*) parameters,lengths[0]*sizeof(parameters->value[0]));
input_file.seekg(RECORD_DELIMITER_LENGTH, std::ios::cur);
return true;
}
else
{
return false;
}
}
bool SurfaceSource::ReadSummaryRecord(int** summaries)
{
int record_length0 = 0;
int record_length1 = 0;
int null = 0;
double dnull = 0.0;
int length_read = 0;
int dist_to_end = 0;
int this_record_legnth = 0;
if (input_file.good())
{
// read starting delimiter
input_file.read((char*) &record_length0, RECORD_DELIMITER_LENGTH);
//printf("RECORD LENGTH %d\n",record_length0);
// read dumb leading (double) zero
input_file.read((char*) &dnull, sizeof(double));
length_read = sizeof(double);
// read what's asked for
for(int i=0;i<surface_count;i++){
for(int j=0;j<surface_summary_length;j++){
length_read = length_read + sizeof(int);
if(length_read>record_length0){
printf("SUMMARY DATA REQUESTED (%d) OVERRAN RECORD LENGTH (%d)!\n",length_read,record_length0);
return false;
}
else{
input_file.read((char*) &summaries[i][j], sizeof(int));
}
}
}
// go to the end of the record
dist_to_end = record_length0-length_read;
if( dist_to_end > 0 ){
printf("--> skipping ahead %d bytes to end of record\n",dist_to_end);
input_file.seekg(dist_to_end, std::ios::cur);
}
// read ending delimiter, assert
input_file.read((char*) &record_length1, RECORD_DELIMITER_LENGTH);
if(record_length0!=record_length1){
printf("BEGINNING (%d) AND ENDING (%d) SUMMARY RECORD LENGTH DELIMITERS DO NOT MATCH\n",record_length0,record_length1);
return false;
}
else{
return true;
}
}
else
{
return false;
}
}
//
// RECORD WRITES
//
bool SurfaceSource::WriteRecord(void** source, size_t* size, size_t NumberOfEntries)
{
int record_length0 = 0;
for (int i=0;i<NumberOfEntries;i++){
record_length0 += size[i];
}
//printf("WRITE RECORD LENGTH %d\n",record_length0);
if (output_file.good())
{
// read starting delimiter
output_file.write((char*) &record_length0, RECORD_DELIMITER_LENGTH);
// write what's given
for(int i=0;i<NumberOfEntries;i++){
output_file.write((char*) source[i], size[i]);
}
// write ending delimiter
output_file.write((char*) &record_length0, RECORD_DELIMITER_LENGTH);
return true;
}
else
{
printf("OUTPUT FILE NOT GOOD.\n");
return false;
}
}
bool SurfaceSource::WriteSurfaceRecord0(int* numbers, int* types, int* lengths, surface* parameters)
{
// internal variables
int record_length = 3*sizeof(int) + lengths[0]*sizeof(parameters->value[0]);
// write record
if (output_file.good())
{
output_file.write((char*) &record_length, RECORD_DELIMITER_LENGTH);
output_file.write((char*) numbers, sizeof(int));
output_file.write((char*) types, sizeof(int));
output_file.write((char*) lengths, sizeof(int));
output_file.write((char*) parameters,lengths[0]*sizeof(parameters->value[0]));
output_file.write((char*) &record_length, RECORD_DELIMITER_LENGTH);
return true;
}
else
{
return false;
}
}
bool SurfaceSource::WriteSurfaceRecord1(int* numbers, int* types, int* lengths, surface* parameters, int* facets)
{
// internal variables
int record_length = 4*sizeof(int) + lengths[0]*sizeof(parameters->value[0]);
if (output_file.good())
{
output_file.write((char*) &record_length, RECORD_DELIMITER_LENGTH);
output_file.write((char*) numbers, sizeof(int));
output_file.write((char*) facets, sizeof(int));
output_file.write((char*) types, sizeof(int));
output_file.write((char*) lengths, sizeof(int));
output_file.write((char*) parameters,lengths[0]*sizeof(parameters->value[0]));
output_file.write((char*) &record_length, RECORD_DELIMITER_LENGTH);
return true;
}
else
{
return false;
}
}
bool SurfaceSource::WriteSummaryRecord(int** summaries)
{
int record_length0 = surface_summary_length*surface_count*sizeof(int)+sizeof(double);
int null = 0;
double dnull = 0.0;
int length_write = 0;
if (output_file.good())
{
// write starting delimiter
output_file.write((char*) &record_length0, RECORD_DELIMITER_LENGTH);
// write stupid leading (double) zero
output_file.write((char*) &dnull, sizeof(double));
// write what's asked for
for(int i=0;i<surface_count;i++){
for(int j=0;j<surface_summary_length;j++){
length_write = length_write + sizeof(int);
output_file.write((char*) &summaries[i][j], sizeof(int));
}
}
// write ending delimiter, assert
output_file.write((char*) &record_length0, RECORD_DELIMITER_LENGTH);
return true;
}
else
{
return false;
}
}
//
// HIGHER LEVEL ROUTINES
//
void SurfaceSource::ReadHeader(){
// HEADER FORMATTING
//
// record 1: id;
// record 2: kods,vers,lods,idtms,probs,aids,knods;
// record 3: np1,nrss,nrcd,njsw,niss;
// record 4: niwr,mipts,kjaq;
//
// id = The ID string, should be SF_00001 for MCNP6-made surface source, char8
// kods = code name, char8
// vers = code version, char5
// lods = LODDAT of code that wrote surface source file, char8
// idtms = IDTM of the surface source write run, char19
// probs = probid, problem id, char19
// aids = title string of the creation run, char80
// knods = ending dump number, int
// np1 = total number of histories in SS write run, int
// nrss = the total number of tracks recorded, int
// nrcd = Number of values in a surface-source record, int
// njsw = Number of surfaces in JASW, int
// niss = Number of histories in input surface source, int
// niwr = Number of cells in RSSA file, int
// mipts = Source particle type, int
// kjaq = Flag for macrobody facets on source tape, int
//
//
// the next njsw+niwr records describe the surfaces/cells in the SS
//
//
// the last record is the SS summary vector
// first record
void** pointers = new void* [20];
size_t* sizes = new size_t [20];
size_t size = 1;
pointers[0] = (void**) &id;
sizes[0] = sizeof(id)-1;
if(!ReadRecord(pointers, sizes, size)){printf("ERROR READING FIRST RECORD\n");std::exit(1);}
// second record, first make array of pointers, then sizes
size = 7;
pointers[0] = (void*) &kods;
pointers[1] = (void*) &vers;
pointers[2] = (void*) &lods;
pointers[3] = (void*) &idtms;
pointers[4] = (void*) &probs;
pointers[5] = (void*) &aids;
pointers[6] = (void*) &knods;
sizes[0] = sizeof(kods)-1;
sizes[1] = sizeof(vers)-1;
sizes[2] = sizeof(lods)-1;
sizes[3] = sizeof(idtms)-1;
sizes[4] = sizeof(probs)-1;
sizes[5] = sizeof(aids)-1;
sizes[6] = sizeof(knods);
if(!ReadRecord(pointers, sizes, size)){printf("ERROR READING SECOND RECORD\n");std::exit(1);}
// third record, first make array of pointers, then sizes
size = 5;
pointers[0] = (void*) &np1;
pointers[1] = (void*) &nrss;
pointers[2] = (void*) &nrcd;
pointers[3] = (void*) &njsw;
pointers[4] = (void*) &niss;
sizes[0] = sizeof(np1);
sizes[1] = sizeof(nrss);
sizes[2] = sizeof(nrcd);
sizes[3] = sizeof(njsw);
sizes[4] = sizeof(niss);
if(!ReadRecord(pointers, sizes, size)){printf("ERROR READING THIRD RECORD\n");std::exit(1);}
// fourth record, first make array of pointers, then sizes
size = 3+17; // 17 zeros written after for whatever reason!
pointers[0] = (void*) &niwr;
pointers[1] = (void*) &mipts;
pointers[2] = (void*) &kjaq;
int null = 0;
for (int g=3;g<3+17;g++){pointers[g]=&null;}
sizes[0] = sizeof(niwr);
sizes[1] = sizeof(mipts);
sizes[2] = sizeof(kjaq);
for (int g=3;g<3+17;g++){sizes[g]=sizeof(null);}
if(!ReadRecord(pointers, sizes, size)){printf("ERROR READING FOURTH RECORD\n");std::exit(1);}
// init arays for surface information
surface_count = njsw+niwr;
surface_parameters = new surface [surface_count];
surface_parameters_lengths = new int [surface_count];
surface_numbers = new int [surface_count];
surface_types = new int [surface_count];
surface_facets = new int [surface_count];
surface_summaries = new int* [surface_count];
for(int i = 0 ; i < surface_count ; i++){
for(int j = 0 ; j < 10 ; j++){
surface_parameters [i].value[j] = 0;
}
surface_summaries[i] = new int [surface_summary_length];
for(int k=0;k<surface_summary_length;k++){
surface_summaries[i][k]=0;
}
surface_numbers [i] = -1;
surface_facets [i] = -1;
}
// go on, copying surface/cell information from the next records until particle data starts
for(int i = 0 ; i < surface_count ; i++){
if( kjaq==0 | i>njsw-1 ) {
ReadSurfaceRecord0(&surface_numbers[i],&surface_types[i],&surface_parameters_lengths[i],&surface_parameters[i]);
}
if( kjaq==1 & i<=njsw-1 ) {
ReadSurfaceRecord1(&surface_numbers[i],&surface_types[i],&surface_parameters_lengths[i],&surface_parameters[i],&surface_facets[i]);
}
}
// last record is the summary tables
ReadSummaryRecord(surface_summaries);
}
void SurfaceSource::WriteHeader(){
// HEADER FORMATTING
//
// record 1: id;
// record 2: kods,vers,lods,idtms,probs,aids,knods;
// record 3: np1,nrss,nrcd,njsw,niss;
// record 4: niwr,mipts,kjaq;
//
// id = The ID string, should be SF_00001 for MCNP6-made surface source, char8
// kods = code name, char8
// vers = code version, char5
// lods = LODDAT of code that wrote surface source file, char8
// idtms = IDTM of the surface source write run, char19
// probs = probid, problem id, char19
// aids = title string of the creation run, char80
// knods = ending dump number, int
// np1 = total number of histories in SS write run, int
// nrss = the total number of tracks recorded, int
// nrcd = Number of values in a surface-source record, int
// njsw = Number of surfaces in JASW, int
// niss = Number of histories in input surface source, int
// niwr = Number of cells in RSSA file, int
// mipts = Source particle type, int
// kjaq = Flag for macrobody facets on source tape, int
//
//
// the next njsw+niwr records describe the surfaces/cells in the SS
//
//
// the last record is the SS summary vector
// first record
int largest_size = 3+17;
void** pointers = new void* [largest_size];
size_t* sizes = new size_t [largest_size];
size_t size = 1;
pointers[0] = (void**) &id;
sizes[0] = sizeof(id)-1;
if(!WriteRecord(pointers, sizes, size)){printf("ERROR WRITING FIRST RECORD\n");std::exit(1);}
// second record, first make array of pointers, then sizes
size = 7;
pointers[0] = (void*) &kods;
pointers[1] = (void*) &vers;
pointers[2] = (void*) &lods;
pointers[3] = (void*) &idtms;
pointers[4] = (void*) &probs;
pointers[5] = (void*) &aids;
pointers[6] = (void*) &knods;
sizes[0] = sizeof(kods)-1;
sizes[1] = sizeof(vers)-1;
sizes[2] = sizeof(lods)-1;
sizes[3] = sizeof(idtms)-1;
sizes[4] = sizeof(probs)-1;
sizes[5] = sizeof(aids)-1;
sizes[6] = sizeof(knods);
if(!WriteRecord(pointers, sizes, size)){printf("ERROR WRITING SECOND RECORD\n");std::exit(1);}
// third record, first make array of pointers, then sizes
size = 5;
pointers[0] = (void*) &np1;
pointers[1] = (void*) &nrss;
pointers[2] = (void*) &nrcd;
pointers[3] = (void*) &njsw;
pointers[4] = (void*) &niss;
sizes[0] = sizeof(np1);
sizes[1] = sizeof(nrss);
sizes[2] = sizeof(nrcd);
sizes[3] = sizeof(njsw);
sizes[4] = sizeof(niss);
if(!WriteRecord(pointers, sizes, size)){printf("ERROR WRITING THIRD RECORD\n");std::exit(1);}
// fourth record, first make array of pointers, then sizes
size = 3+17;
pointers[0] = (void*) &niwr;
pointers[1] = (void*) &mipts;
pointers[2] = (void*) &kjaq;
int null = 0;
for (int g=3;g<size;g++){pointers[g]=&null;}
sizes[0] = sizeof(niwr);
sizes[1] = sizeof(mipts);
sizes[2] = sizeof(kjaq);
for (int g=3;g<size;g++){sizes[g]=sizeof(null);}
if(!WriteRecord(pointers, sizes, size)){printf("ERROR WRITING FOURTH RECORD\n");std::exit(1);}
// init arays for surface information
//surface_count = njsw+niwr;
//surface_parameters = new surface [surface_count];
//surface_parameters_lengths = new int [surface_count];
//surface_numbers = new int [surface_count];
//surface_types = new int [surface_count];
//surface_facets = new int [surface_count];
//surface_summaries = new int* [surface_count];
//for(int i = 0 ; i < surface_count ; i++){
// for(int j = 0 ; j < 10 ; j++){
// surface_parameters [i].value[j] = 0;
// }
// surface_summaries[i] = new int [surface_summary_length];
// for(int k=0;k<surface_summary_length;k++){
// surface_summaries[i][k]=0;
// }
// surface_numbers [i] = -1;
// surface_facets [i] = -1;
//}
// go on, copying surface/cell information from the next records until particle data starts
for(int i = 0 ; i < surface_count ; i++){
if( kjaq==0 | i>njsw-1 ) {
WriteSurfaceRecord0(&surface_numbers[i],&surface_types[i],&surface_parameters_lengths[i],&surface_parameters[i]);
}
if( kjaq==1 & i<=njsw-1 ) {
WriteSurfaceRecord1(&surface_numbers[i],&surface_types[i],&surface_parameters_lengths[i],&surface_parameters[i],&surface_facets[i]);
}
}
// last record is the summary tables
WriteSummaryRecord(surface_summaries);
output_file.flush();
}
void SurfaceSource::PrintSizes(){
printf("== DATA SIZE INFORMATION == \n");
printf("normal integers : %1ld bytes\n", sizeof(knods));
printf("floating points : %1ld bytes\n", sizeof(surface_parameters->value[0]));
printf("characters : %1ld bytes\n", sizeof(id[0]));
printf("\n");
}
void SurfaceSource::PrintHeader(){
printf("=========================================== HEADER INFORMATION =========================================== \n");
printf("RSSA ID string : %8s \n", id);
printf("code name : %8s \n", kods);
printf("code version : %5s \n", vers);
printf("LODDAT of code that wrote surface source file : %8s \n", lods);
printf("IDTM of the surface source write run : %19s\n", idtms);
printf("probid, problem id : %19s\n", probs);
printf("title string of the creation run : %80s\n", aids);
printf("ending dump number : %d\n", knods);
printf("total number of histories in SS write run : %lld\n", np1);
printf("the total number of tracks recorded : %lld\n", nrss);
printf("Number of values in a surface-source record : %d\n", nrcd);
printf("Number of surfaces in JASW : %d\n", njsw);
printf("Number of histories in input surface source : %lld\n", niss);
printf("Number of cells in RSSA file : %d\n", niwr);
printf("Source particle type : %d\n", mipts);
printf("Flag for macrobody facets on source tape : %d\n", kjaq);
if( kjaq == 0 ) {
printf("\n============================================================ SURFACE INFORMATION ============================================================ \n");
printf("creation-run surfaces | surface | type | coefficients\n");
}
else if( kjaq == 1 ) {
printf("\n============================================================ SURFACE INFORMATION ============================================================ \n");
printf("creation-run surfaces | surface | facet | type | coefficients\n");
}
for(int i = 0 ; i < surface_count ; i++){
if( kjaq == 0 ) {
printf(" %5d %5d %s ",i,surface_numbers[i],surface_card[surface_types[i]].symbol);
for(int j = 0 ; j < surface_parameters_lengths[i] ; j++){
printf(" % 10.8E",surface_parameters[i].value[j]);
}
printf("\n");
}
else if( kjaq == 1 ) {
printf(" %5d %5d %1d %s ",i,surface_numbers[i],surface_facets[i],surface_card[surface_types[i]].symbol);
for(int j = 0 ; j < surface_parameters_lengths[i] ; j++){
printf(" % 10.8E",surface_parameters[i].value[j]);
}
printf("\n");
}
}
printf("\n");
printf("\n============================================================= SURFACE SUMMARIES ============================================================= \n");
int a,b,c,d;
for(int i=0;i<surface_count;i++){
printf("--=== Surface %5d ===--\n",surface_numbers[i]);
printf("%20s %21s\n","TOTAL TRACKS","INDEPENDENT HISTORIES");
printf(" %12d %12d\n",surface_summaries[i][0],surface_summaries[i][1]);
for(int j=0;j<mipts;j++){
a = surface_summaries[i][(2+j*4)+0];
b = surface_summaries[i][(2+j*4)+1];
c = surface_summaries[i][(2+j*4)+2];
d = surface_summaries[i][(2+j*4)+3];
if (a+b+c+d > 0){
printf("---- %s ----\n",particles[j].name);
printf("%20s %20s %20s %20s\n","TOTAL TRACKS","INDEPENDENT TRACKS","UNCOLLIDED","INDEP. UNCOLLIDED");
printf(" %12d %12d %12d %12d\n",a,b,c,d);
}
}
printf("\n");
}
}
void SurfaceSource::GetTrack(track* this_track){
// local vars
size_t sizes = 11*sizeof(double);
// try reading it all in at once... copy from array to make sure struct padding doesn't do anything...
double* this_track_data = new double [12];
if(!ReadRecord((void**) &this_track_data, &sizes, 1)){printf("ERROR READING TRACKS RECORD\n");std::exit(1);}
this_track->nps = this_track_data[ 0];
this_track->bitarray = this_track_data[ 1];
this_track->wgt = this_track_data[ 2];
this_track->erg = this_track_data[ 3];
this_track->tme = this_track_data[ 4];
this_track->x = this_track_data[ 5];
this_track->y = this_track_data[ 6];
this_track->z = this_track_data[ 7];
this_track->xhat = this_track_data[ 8];
this_track->yhat = this_track_data[ 9];
this_track->cs = this_track_data[10];
this_track->zhat = this_track_data[11];
delete this_track_data;
// calculate missing zhat from the data
if ((this_track->xhat*this_track->xhat+this_track->yhat*this_track->yhat)<1.0){
this_track->zhat = copysign(std::sqrt(1.0 - this_track->xhat*this_track->xhat -
this_track->yhat*this_track->yhat), this_track->bitarray);
}
else{
this_track->zhat = 0.0;
}
}
void SurfaceSource::PutTrack(double nps, double bitarray, double wgt, double erg, double tme, double x, double y, double z, double xhat, double yhat, double cs, double zhat){
// local vars
size_t sizes = 11*sizeof(double); // only write the first 11, track in record doesn't have zhat
double* this_track_data = new double [12];
this_track_data[ 0] = nps ;
this_track_data[ 1] = bitarray;
this_track_data[ 2] = wgt ;
this_track_data[ 3] = erg ;
this_track_data[ 4] = tme ;
this_track_data[ 5] = x ;
this_track_data[ 6] = y ;
this_track_data[ 7] = z ;
this_track_data[ 8] = xhat ;
this_track_data[ 9] = yhat ;
this_track_data[10] = cs ;
this_track_data[11] = zhat ;
// writing it all in at once...
if(!WriteRecord((void**) &this_track_data, &sizes, 1)){printf("ERROR WRITING TRACK RECORD\n");std::exit(1);}
delete this_track_data;
}
void SurfaceSource::PutTrack(track* this_track){
// pass to other method since it copies to a continguous array, so contiguity is guranteed, some compilers might pad the struct...
PutTrack( this_track->nps,
this_track->bitarray,
this_track->wgt,
this_track->erg,
this_track->tme,
this_track->x,
this_track->y,
this_track->z,
this_track->xhat,
this_track->yhat,
this_track->cs,
this_track->zhat
);
}
| 36.133201 | 174 | 0.635626 | sellitforcache |
f3ac9ec03734001a5239da0d0e564b5d54538367 | 2,111 | hpp | C++ | simulations/landau/pdi_out.yml.hpp | gyselax/gyselalibxx | 5f9b4b1e20050f87e2a9f05d510bedf0f9a15b34 | [
"MIT"
] | 3 | 2022-02-28T08:47:07.000Z | 2022-03-01T10:29:08.000Z | simulations/landau/pdi_out.yml.hpp | gyselax/gyselalibxx | 5f9b4b1e20050f87e2a9f05d510bedf0f9a15b34 | [
"MIT"
] | null | null | null | simulations/landau/pdi_out.yml.hpp | gyselax/gyselalibxx | 5f9b4b1e20050f87e2a9f05d510bedf0f9a15b34 | [
"MIT"
] | null | null | null | // SPDX-License-Identifier: MIT
constexpr char const* const PDI_CFG = R"PDI_CFG(
metadata:
Nx : int
Nvx : int
iter : int
time_saved : double
nbstep_diag: int
iter_saved : int
MeshX_extents: { type: array, subtype: int64, size: 1 }
MeshX:
type: array
subtype: double
size: [ '$MeshX_extents[0]' ]
MeshVx_extents: { type: array, subtype: int64, size: 1 }
MeshVx:
type: array
subtype: double
size: [ '$MeshVx_extents[0]' ]
Nkinspecies: int
fdistribu_charges_extents : { type: array, subtype: int64, size: 1 }
fdistribu_charges:
type: array
subtype: int
size: [ '$fdistribu_charges_extents[0]' ]
fdistribu_masses_extents : { type: array, subtype: int64, size: 1 }
fdistribu_masses:
type: array
subtype: double
size: [ '$fdistribu_masses_extents[0]' ]
fdistribu_eq_extents : { type: array, subtype: int64, size: 2 }
fdistribu_eq:
type: array
subtype: double
size: [ '$fdistribu_eq_extents[0]', '$fdistribu_eq_extents[1]' ]
data:
fdistribu_extents: { type: array, subtype: int64, size: 3 }
fdistribu:
type: array
subtype: double
size: [ '$fdistribu_extents[0]', '$fdistribu_extents[1]', '$fdistribu_extents[2]' ]
electrostatic_potential_extents: { type: array, subtype: int64, size: 1 }
electrostatic_potential:
type: array
subtype: double
size: [ '$electrostatic_potential_extents[0]' ]
plugins:
set_value:
on_init:
- share:
- iter_saved: 0
on_data:
iter:
- set:
- iter_saved: '${iter}/${nbstep_diag}'
on_finalize:
- release: [iter_saved]
decl_hdf5:
- file: 'VOICEXX_initstate.h5'
on_event: [initial_state]
collision_policy: replace_and_warn
write: [Nx, Nvx, MeshX, MeshVx, nbstep_diag, Nkinspecies, fdistribu_charges,fdistribu_masses, fdistribu_eq]
- file: 'VOICEXX_${iter_saved:05}.h5'
on_event: [iteration, last_iteration]
when: '${iter} % ${nbstep_diag} = 0'
collision_policy: replace_and_warn
write: [time_saved, fdistribu, electrostatic_potential]
#trace: ~
)PDI_CFG";
| 28.917808 | 113 | 0.661772 | gyselax |
f3af83afc90d2e5d70380cedd8f4f19e2436f029 | 312 | cpp | C++ | MSVC/14.24.28314/crt/src/vcruntime/exe_main.cpp | 825126369/UCRT | 8853304fdc2a5c216658d08b6dbbe716aa2a7b1f | [
"MIT"
] | 2 | 2021-01-27T10:19:30.000Z | 2021-02-09T06:24:30.000Z | MSVC/14.24.28314/crt/src/vcruntime/exe_main.cpp | 825126369/UCRT | 8853304fdc2a5c216658d08b6dbbe716aa2a7b1f | [
"MIT"
] | null | null | null | MSVC/14.24.28314/crt/src/vcruntime/exe_main.cpp | 825126369/UCRT | 8853304fdc2a5c216658d08b6dbbe716aa2a7b1f | [
"MIT"
] | 1 | 2021-01-27T10:19:36.000Z | 2021-01-27T10:19:36.000Z | //
// exe_wwinmain.cpp
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// The mainCRTStartup() entry point, linked into client executables that
// uses main().
//
#define _SCRT_STARTUP_MAIN
#include "exe_common.inl"
extern "C" int mainCRTStartup()
{
return __scrt_common_main();
}
| 17.333333 | 72 | 0.705128 | 825126369 |
f3b08568106455f684f40669c567e4062eea231e | 427 | cpp | C++ | programming/numerical_algorithms/horner_value.cpp | Kartm/hs-cs-final-exam | 6af11324740d53a68b921582ab6ec1adee7634e6 | [
"MIT"
] | 1 | 2019-01-27T13:34:42.000Z | 2019-01-27T13:34:42.000Z | programming/numerical_algorithms/horner_value.cpp | Kartm/hs-cs-final-exam | 6af11324740d53a68b921582ab6ec1adee7634e6 | [
"MIT"
] | null | null | null | programming/numerical_algorithms/horner_value.cpp | Kartm/hs-cs-final-exam | 6af11324740d53a68b921582ab6ec1adee7634e6 | [
"MIT"
] | null | null | null | #include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int calculate(vector<int> coefficients, int x) {
int result = coefficients[0];
for(int i = 1; i < coefficients.size(); i++) {
result = result * x + coefficients[i];
}
return result;
}
int main() {
//* x*x*x + 2*x - 10;
vector<int> coefficients {1, 0, 2, -10};
cout << calculate(coefficients, 10);
return 0;
} | 21.35 | 50 | 0.594848 | Kartm |
f3b203cab02e2ef25204d35e14bd9ac6f4cf315b | 261 | hpp | C++ | SystemResource/Source/Container/QuadTree/QuadTreePosition.hpp | BitPaw/BitFireEngine | 2c02a4eae19276bf60ac925e4393966cec605112 | [
"MIT"
] | 5 | 2021-10-19T18:30:43.000Z | 2022-03-19T22:02:02.000Z | SystemResource/Source/Container/QuadTree/QuadTreePosition.hpp | BitPaw/BitFireEngine | 2c02a4eae19276bf60ac925e4393966cec605112 | [
"MIT"
] | 12 | 2022-03-09T13:40:21.000Z | 2022-03-31T12:47:48.000Z | SystemResource/Source/Container/QuadTree/QuadTreePosition.hpp | BitPaw/BitFireEngine | 2c02a4eae19276bf60ac925e4393966cec605112 | [
"MIT"
] | null | null | null | #pragma once
namespace BF
{
template<typename NumberType>
struct QuadTreePosition
{
public:
NumberType X;
NumberType Y;
QuadTreePosition()
{
X = 0;
Y = 0;
}
QuadTreePosition(NumberType x, NumberType y)
{
X = x;
Y = y;
}
};
} | 10.875 | 46 | 0.609195 | BitPaw |
f3b86313a2b242622e540a7112921b8a072d7eac | 6,712 | cpp | C++ | kernel/thor/arch/arm/ints.cpp | kITerE/managarm | e6d1229a0bed68cb672a9cad300345a9006d78c1 | [
"MIT"
] | 935 | 2018-05-23T14:56:18.000Z | 2022-03-29T07:27:20.000Z | kernel/thor/arch/arm/ints.cpp | kITerE/managarm | e6d1229a0bed68cb672a9cad300345a9006d78c1 | [
"MIT"
] | 314 | 2018-05-04T15:58:06.000Z | 2022-03-30T16:24:17.000Z | kernel/thor/arch/arm/ints.cpp | kITerE/managarm | e6d1229a0bed68cb672a9cad300345a9006d78c1 | [
"MIT"
] | 65 | 2019-04-21T14:26:51.000Z | 2022-03-12T03:16:41.000Z | #include <thor-internal/arch/cpu.hpp>
#include <thor-internal/arch/ints.hpp>
#include <thor-internal/arch/gic.hpp>
#include <thor-internal/debug.hpp>
#include <thor-internal/thread.hpp>
#include <assert.h>
namespace thor {
extern "C" void *thorExcVectors;
void initializeIrqVectors() {
asm volatile ("msr vbar_el1, %0" :: "r"(&thorExcVectors));
}
extern "C" void enableIntsAndHaltForever();
void suspendSelf() {
assert(!intsAreEnabled());
getCpuData()->currentDomain = static_cast<uint64_t>(Domain::idle);
enableIntsAndHaltForever();
}
extern frg::manual_box<GicDistributor> dist;
void sendPingIpi(int id) {
dist->sendIpi(getCpuData(id)->gicCpuInterface->interfaceNumber(), 0);
}
void sendShootdownIpi() {
dist->sendIpiToOthers(1);
}
extern "C" void onPlatformInvalidException(FaultImageAccessor image) {
thor::panicLogger() << "thor: an invalid exception has occured" << frg::endlog;
}
namespace {
Word mmuAbortError(uint64_t esr) {
Word errorCode = 0;
auto ec = esr >> 26;
auto iss = esr & ((1 << 25) - 1);
// Originated from EL0
if (ec == 0x20 || ec == 0x24)
errorCode |= kPfUser;
// Is an instruction abort
if (ec == 0x20 || ec == 0x21) {
errorCode |= kPfInstruction;
} else {
if (iss & (1 << 6))
errorCode |= kPfWrite;
}
auto sc = iss & 0x3F;
if (sc < 16) {
auto type = (sc >> 2) & 0b11;
if (type == 0) // Address size fault
errorCode |= kPfBadTable;
if (type != 1) // Not a translation fault
errorCode |= kPfAccess;
}
return errorCode;
}
bool updatePageAccess(FaultImageAccessor image, Word error) {
if ((error & kPfWrite) && (error & kPfAccess) && !inHigherHalf(*image.faultAddr())) {
// Check if it's just a writable page that's not dirty yet
smarter::borrowed_ptr<Thread> this_thread = getCurrentThread();
return this_thread->getAddressSpace()->updatePageAccess(*image.faultAddr() & ~(kPageSize - 1));
}
return false;
}
} // namespace anonymous
void handlePageFault(FaultImageAccessor image, uintptr_t address, Word errorCode);
void handleOtherFault(FaultImageAccessor image, Interrupt fault);
void handleSyscall(SyscallImageAccessor image);
constexpr bool logUpdatePageAccess = false;
extern "C" void onPlatformSyncFault(FaultImageAccessor image) {
auto ec = *image.code() >> 26;
enableInts();
switch (ec) {
case 0x00: // Invalid
case 0x18: // Trapped MSR, MRS, or System instruction
handleOtherFault(image, kIntrIllegalInstruction);
break;
case 0x20: // Instruction abort, lower EL
case 0x21: // Instruction abort, same EL
case 0x24: // Data abort, lower EL
case 0x25: { // Data abort, same EL
auto error = mmuAbortError(*image.code());
if (updatePageAccess(image, error)) {
if constexpr (logUpdatePageAccess) {
infoLogger() << "thor: updated page "
<< (void *)(*image.faultAddr() & ~(kPageSize - 1))
<< " status on access from " << (void *)*image.ip() << frg::endlog;
}
break;
}
handlePageFault(image, *image.faultAddr(), error);
break;
}
case 0x15: // Trapped SVC in AArch64
handleSyscall(image);
break;
case 0x30: // Breakpoint, lower EL
case 0x31: // Breakpoint, same EL
handleOtherFault(image, kIntrBreakpoint);
break;
case 0x0E: // Illegal Execution fault
case 0x22: // IP alignment fault
case 0x26: // SP alignment fault
handleOtherFault(image, kIntrGeneralFault);
break;
case 0x3C: // BRK instruction
handleOtherFault(image, kIntrBreakpoint);
break;
default:
panicLogger() << "Unexpected fault " << ec
<< " from ip: " << (void *)*image.ip() << "\n"
<< "sp: " << (void *)*image.sp() << " "
<< "syndrome: 0x" << frg::hex_fmt(*image.code()) << " "
<< "saved state: 0x" << frg::hex_fmt(*image.rflags()) << frg::endlog;
}
disableInts();
}
extern "C" void onPlatformAsyncFault(FaultImageAccessor image) {
urgentLogger() << "thor: On CPU " << getCpuData()->cpuIndex << frg::endlog;
urgentLogger() << "thor: An asynchronous fault has occured!" << frg::endlog;
auto code = *image.code();
auto ec = code >> 26;
bool recoverable = false;
if (ec == 0x2F) {
bool ids = code & (1 << 24);
bool iesb = code & (1 << 13);
uint8_t aet = (code >> 10) & 7;
bool ea = code & (1 << 9);
uint8_t dfsc = code & 0x3F;
constexpr const char *aet_str[] = {
"Uncontainable",
"Unrecoverable state",
"Restartable state",
"Recoverable state",
"Reserved",
"Reserved",
"Corrected",
"Reserved"
};
if (ids) {
urgentLogger() << "thor: SError with implementation defined information: ESR = 0x"
<< frg::hex_fmt{code} << frg::endlog;
} else {
auto log = urgentLogger();
log << "thor: ";
if (dfsc == 0x11)
log << aet_str[aet] << " ";
log << "SError ";
log << " (EA = " << (ea ? "true" : "false")
<< ", IESB = " << (iesb ? "true" : "false") << ")";
if (dfsc != 0x11)
log << " with DFSC = " << dfsc;
log << frg::endlog;
if (aet == 2 || aet == 12)
recoverable = true;
}
} else {
urgentLogger() << "thor: unexpectec EC " << ec << " (ESR = 0x"
<< frg::hex_fmt{code} << ")" << frg::endlog;
}
urgentLogger() << "thor: IP = 0x" << frg::hex_fmt{*image.ip()}
<< ", SP = 0x" << frg::hex_fmt{*image.sp()} << frg::endlog;
if (!recoverable)
panicLogger() << "thor: Panic due to unrecoverable error" << frg::endlog;
}
void handleIrq(IrqImageAccessor image, int number);
void handlePreemption(IrqImageAccessor image);
static constexpr bool logSGIs = false;
static constexpr bool logSpurious = false;
extern "C" void onPlatformIrq(IrqImageAccessor image) {
auto &cpuInterface = getCpuData()->gicCpuInterface;
auto [cpu, irq] = cpuInterface->get();
asm volatile ("isb" ::: "memory");
if (irq < 16) {
if constexpr (logSGIs)
infoLogger() << "thor: onPlatformIrq: on CPU " << getCpuData()->cpuIndex << ", got a SGI (no. " << irq << ") that originated from CPU " << cpu << frg::endlog;
cpuInterface->eoi(cpu, irq);
if (irq == 0) {
handlePreemption(image);
} else {
assert(irq == 1);
assert(!irqMutex().nesting());
disableUserAccess();
for(int i = 0; i < maxAsid; i++)
getCpuData()->asidBindings[i].shootdown();
getCpuData()->globalBinding.shootdown();
}
} else if (irq >= 1020) {
if constexpr (logSpurious)
infoLogger() << "thor: on CPU " << getCpuData()->cpuIndex << ", spurious IRQ " << irq << " occured" << frg::endlog;
// no need to EOI spurious irqs
} else {
handleIrq(image, irq);
}
}
extern "C" void onPlatformWork() {
assert(!irqMutex().nesting());
// TODO: User-access should already be disabled here.
disableUserAccess();
enableInts();
getCurrentThread()->mainWorkQueue()->run();
disableInts();
}
} // namespace thor
| 26.425197 | 161 | 0.637217 | kITerE |
f3bba51408e86ab52e64850002a9730e4b3a3adc | 2,984 | hpp | C++ | copper/hpp/triangle.hpp | CobaltXII/sterling | abef14ec8019aca55e359f78da5711c70be77d35 | [
"MIT"
] | 1 | 2019-03-15T11:55:15.000Z | 2019-03-15T11:55:15.000Z | copper/hpp/triangle.hpp | CobaltXII/copper | abef14ec8019aca55e359f78da5711c70be77d35 | [
"MIT"
] | null | null | null | copper/hpp/triangle.hpp | CobaltXII/copper | abef14ec8019aca55e359f78da5711c70be77d35 | [
"MIT"
] | null | null | null | #pragma once
struct triangle: shape
{
float x0;
float y0;
float z0;
float x1;
float y1;
float z1;
float x2;
float y2;
float z2;
float norm_x;
float norm_y;
float norm_z;
triangle
(
material_type material,
float x0,
float y0,
float z0,
float x1,
float y1,
float z1,
float x2,
float y2,
float z2,
float r,
float g,
float b
)
{
this->primitive = shape_type::st_triangle;
this->x0 = x0;
this->y0 = y0;
this->z0 = z0;
this->x1 = x1;
this->y1 = y1;
this->z1 = z1;
this->x2 = x2;
this->y2 = y2;
this->z2 = z2;
this->r = r;
this->g = g;
this->b = b;
this->material = material;
// Surface normal.
float v1v0_x = x1 - x0;
float v1v0_y = y1 - y0;
float v1v0_z = z1 - z0;
float v2v0_x = x2 - x0;
float v2v0_y = y2 - y0;
float v2v0_z = z2 - z0;
float cross_x = v1v0_y * v2v0_z - v2v0_y * v1v0_z;
float cross_y = v1v0_x * v2v0_z - v2v0_x * v1v0_z;
float cross_z = v1v0_x * v2v0_y - v2v0_x * v1v0_y;
float cross_len = sqrtf
(
cross_x * cross_x +
cross_y * cross_y +
cross_z * cross_z
);
norm_x = cross_x / cross_len;
norm_y = cross_y / cross_len;
norm_z = cross_z / cross_len;
}
};
inline triangle TO_TRIANGLE(shape* __victim)
{
return *((triangle*)__victim);
}
inline float triangle_intersect
(
triangle triangle1,
float ray_ox, float ray_oy, float ray_oz,
float ray_dx, float ray_dy, float ray_dz,
float* norm_x,
float* norm_y,
float* norm_z,
float* texture_u,
float* texture_v
)
{
#define v0_x (triangle1.x0)
#define v0_y (triangle1.y0)
#define v0_z (triangle1.z0)
#define v1_x (triangle1.x1)
#define v1_y (triangle1.y1)
#define v1_z (triangle1.z1)
#define v2_x (triangle1.x2)
#define v2_y (triangle1.y2)
#define v2_z (triangle1.z2)
float v0v1_x = v1_x - v0_x;
float v0v1_y = v1_y - v0_y;
float v0v1_z = v1_z - v0_z;
float v0v2_x = v2_x - v0_x;
float v0v2_y = v2_y - v0_y;
float v0v2_z = v2_z - v0_z;
float pvec_x = ray_dy * v0v2_z - ray_dz * v0v2_y;
float pvec_y = ray_dz * v0v2_x - ray_dx * v0v2_z;
float pvec_z = ray_dx * v0v2_y - ray_dy * v0v2_x;
float inv_det = 1.0f /
(
v0v1_x * pvec_x +
v0v1_y * pvec_y +
v0v1_z * pvec_z
);
float tvec_x = ray_ox - v0_x;
float tvec_y = ray_oy - v0_y;
float tvec_z = ray_oz - v0_z;
float u = inv_det *
(
tvec_x * pvec_x +
tvec_y * pvec_y +
tvec_z * pvec_z
);
if (u < 0.0f || u > 1.0f)
{
return -1.0f;
}
float qvec_x = tvec_y * v0v1_z - tvec_z * v0v1_y;
float qvec_y = tvec_z * v0v1_x - tvec_x * v0v1_z;
float qvec_z = tvec_x * v0v1_y - tvec_y * v0v1_x;
float v = inv_det *
(
ray_dx * qvec_x +
ray_dy * qvec_y +
ray_dz * qvec_z
);
if (v < 0.0f || u + v > 1.0f)
{
return -1.0f;
}
float t = inv_det *
(
v0v2_x * qvec_x +
v0v2_y * qvec_y +
v0v2_z * qvec_z
);
set_ptr(norm_x, triangle1.norm_x);
set_ptr(norm_y, triangle1.norm_y);
set_ptr(norm_z, triangle1.norm_z);
set_ptr(texture_u, u);
set_ptr(texture_v, v);
return t;
} | 15.957219 | 52 | 0.632708 | CobaltXII |
f3bf94ef4e82be09f5968720040b6142bcd48cd7 | 11,104 | cpp | C++ | src/tools/codeeditor/docsearchcontroller.cpp | SpartanJ/eepp | 21e8ae53af9bc5eb3fd1043376f2b3a4b3ff5fac | [
"MIT"
] | 37 | 2020-01-20T06:21:24.000Z | 2022-03-21T17:44:50.000Z | src/tools/codeeditor/docsearchcontroller.cpp | SpartanJ/eepp | 21e8ae53af9bc5eb3fd1043376f2b3a4b3ff5fac | [
"MIT"
] | null | null | null | src/tools/codeeditor/docsearchcontroller.cpp | SpartanJ/eepp | 21e8ae53af9bc5eb3fd1043376f2b3a4b3ff5fac | [
"MIT"
] | 9 | 2019-03-22T00:33:07.000Z | 2022-03-01T01:35:59.000Z | #include "docsearchcontroller.hpp"
#include "codeeditor.hpp"
DocSearchController::DocSearchController( UICodeEditorSplitter* editorSplitter, App* app ) :
mEditorSplitter( editorSplitter ), mApp( app ) {}
void DocSearchController::initSearchBar( UISearchBar* searchBar ) {
mSearchBarLayout = searchBar;
mSearchBarLayout->setVisible( false )->setEnabled( false );
auto addClickListener = [&]( UIWidget* widget, std::string cmd ) {
widget->addEventListener( Event::MouseClick, [this, cmd]( const Event* event ) {
const MouseEvent* mouseEvent = static_cast<const MouseEvent*>( event );
if ( mouseEvent->getFlags() & EE_BUTTON_LMASK )
mSearchBarLayout->execute( cmd );
} );
};
auto addReturnListener = [&]( UIWidget* widget, std::string cmd ) {
widget->addEventListener( Event::OnPressEnter, [this, cmd]( const Event* ) {
mSearchBarLayout->execute( cmd );
} );
};
UITextInput* findInput = mSearchBarLayout->find<UITextInput>( "search_find" );
UITextInput* replaceInput = mSearchBarLayout->find<UITextInput>( "search_replace" );
UICheckBox* caseSensitiveChk = mSearchBarLayout->find<UICheckBox>( "case_sensitive" );
UICheckBox* wholeWordChk = mSearchBarLayout->find<UICheckBox>( "whole_word" );
UICheckBox* luaPatternChk = mSearchBarLayout->find<UICheckBox>( "lua_pattern" );
caseSensitiveChk->addEventListener(
Event::OnValueChange, [&, caseSensitiveChk]( const Event* ) {
mSearchState.caseSensitive = caseSensitiveChk->isChecked();
} );
wholeWordChk->addEventListener( Event::OnValueChange, [&, wholeWordChk]( const Event* ) {
mSearchState.wholeWord = wholeWordChk->isChecked();
} );
luaPatternChk->addEventListener( Event::OnValueChange, [&, luaPatternChk]( const Event* ) {
mSearchState.type = luaPatternChk->isChecked() ? TextDocument::FindReplaceType::LuaPattern
: TextDocument::FindReplaceType::Normal;
} );
findInput->addEventListener( Event::OnTextChanged, [&, findInput]( const Event* ) {
if ( mSearchState.editor && mEditorSplitter->editorExists( mSearchState.editor ) ) {
mSearchState.text = findInput->getText();
mSearchState.editor->setHighlightWord( mSearchState.text );
if ( !mSearchState.text.empty() ) {
mSearchState.editor->getDocument().setSelection( { 0, 0 } );
if ( !findNextText( mSearchState ) ) {
findInput->addClass( "error" );
} else {
findInput->removeClass( "error" );
}
} else {
findInput->removeClass( "error" );
mSearchState.editor->getDocument().setSelection(
mSearchState.editor->getDocument().getSelection().start() );
}
}
} );
mSearchBarLayout->addCommand( "close-searchbar", [&] {
hideSearchBar();
if ( mEditorSplitter->getCurEditor() )
mEditorSplitter->getCurEditor()->setFocus();
if ( mSearchState.editor ) {
if ( mEditorSplitter->editorExists( mSearchState.editor ) ) {
mSearchState.editor->setHighlightWord( "" );
mSearchState.editor->setHighlightTextRange( TextRange() );
}
}
} );
mSearchBarLayout->addCommand( "repeat-find", [this] { findNextText( mSearchState ); } );
mSearchBarLayout->addCommand( "replace-all", [this, replaceInput] {
size_t count = replaceAll( mSearchState, replaceInput->getText() );
mApp->getNotificationCenter()->addNotification(
String::format( "Replaced %zu occurrences.", count ) );
replaceInput->setFocus();
} );
mSearchBarLayout->addCommand( "find-and-replace", [this, replaceInput] {
findAndReplace( mSearchState, replaceInput->getText() );
} );
mSearchBarLayout->addCommand( "find-prev", [this] { findPrevText( mSearchState ); } );
mSearchBarLayout->addCommand( "replace-selection", [this, replaceInput] {
replaceSelection( mSearchState, replaceInput->getText() );
} );
mSearchBarLayout->addCommand( "change-case", [&, caseSensitiveChk] {
caseSensitiveChk->setChecked( !caseSensitiveChk->isChecked() );
} );
mSearchBarLayout->addCommand( "change-whole-word", [&, wholeWordChk] {
wholeWordChk->setChecked( !wholeWordChk->isChecked() );
} );
mSearchBarLayout->addCommand( "toggle-lua-pattern", [&, luaPatternChk] {
luaPatternChk->setChecked( !luaPatternChk->isChecked() );
} );
mSearchBarLayout->getKeyBindings().addKeybindsString( { { "f3", "repeat-find" },
{ "ctrl+g", "repeat-find" },
{ "escape", "close-searchbar" },
{ "ctrl+r", "replace-all" },
{ "ctrl+s", "change-case" },
{ "ctrl+w", "change-whole-word" },
{ "ctrl+l", "toggle-lua-pattern" } } );
addReturnListener( findInput, "repeat-find" );
addReturnListener( replaceInput, "find-and-replace" );
addClickListener( mSearchBarLayout->find<UIPushButton>( "find_prev" ), "find-prev" );
addClickListener( mSearchBarLayout->find<UIPushButton>( "find_next" ), "repeat-find" );
addClickListener( mSearchBarLayout->find<UIPushButton>( "replace" ), "replace-selection" );
addClickListener( mSearchBarLayout->find<UIPushButton>( "replace_find" ), "find-and-replace" );
addClickListener( mSearchBarLayout->find<UIPushButton>( "replace_all" ), "replace-all" );
addClickListener( mSearchBarLayout->find<UIWidget>( "searchbar_close" ), "close-searchbar" );
replaceInput->addEventListener( Event::OnTabNavigate,
[findInput]( const Event* ) { findInput->setFocus(); } );
}
void DocSearchController::showFindView() {
mApp->hideLocateBar();
mApp->hideGlobalSearchBar();
UICodeEditor* editor = mEditorSplitter->getCurEditor();
if ( !editor )
return;
mSearchState.editor = editor;
mSearchState.range = TextRange();
mSearchState.caseSensitive =
mSearchBarLayout->find<UICheckBox>( "case_sensitive" )->isChecked();
mSearchState.wholeWord = mSearchBarLayout->find<UICheckBox>( "whole_word" )->isChecked();
mSearchBarLayout->setEnabled( true )->setVisible( true );
UITextInput* findInput = mSearchBarLayout->find<UITextInput>( "search_find" );
findInput->getDocument().selectAll();
findInput->setFocus();
const TextDocument& doc = editor->getDocument();
if ( doc.getSelection().hasSelection() && doc.getSelection().inSameLine() ) {
String text = doc.getSelectedText();
if ( !text.empty() ) {
findInput->setText( text );
findInput->getDocument().selectAll();
} else if ( !findInput->getText().empty() ) {
findInput->getDocument().selectAll();
}
} else if ( doc.getSelection().hasSelection() ) {
mSearchState.range = doc.getSelection( true );
if ( !findInput->getText().empty() )
findInput->getDocument().selectAll();
}
mSearchState.text = findInput->getText();
editor->setHighlightTextRange( mSearchState.range );
editor->setHighlightWord( mSearchState.text );
editor->getDocument().setActiveClient( editor );
}
bool DocSearchController::findPrevText( SearchState& search ) {
if ( search.text.empty() )
search.text = mLastSearch;
if ( !search.editor || !mEditorSplitter->editorExists( search.editor ) || search.text.empty() )
return false;
search.editor->getDocument().setActiveClient( search.editor );
mLastSearch = search.text;
TextDocument& doc = search.editor->getDocument();
TextRange range = doc.getDocRange();
TextPosition from = doc.getSelection( true ).start();
if ( search.range.isValid() ) {
range = doc.sanitizeRange( search.range ).normalized();
from = from < range.start() ? range.start() : from;
}
TextPosition found =
doc.findLast( search.text, from, search.caseSensitive, search.wholeWord, search.range );
if ( found.isValid() ) {
doc.setSelection( { doc.positionOffset( found, search.text.size() ), found } );
return true;
} else {
found = doc.findLast( search.text, range.end() );
if ( found.isValid() ) {
doc.setSelection( { doc.positionOffset( found, search.text.size() ), found } );
return true;
}
}
return false;
}
bool DocSearchController::findNextText( SearchState& search ) {
if ( search.text.empty() )
search.text = mLastSearch;
if ( !search.editor || !mEditorSplitter->editorExists( search.editor ) || search.text.empty() )
return false;
search.editor->getDocument().setActiveClient( search.editor );
mLastSearch = search.text;
TextDocument& doc = search.editor->getDocument();
TextRange range = doc.getDocRange();
TextPosition from = doc.getSelection( true ).end();
if ( search.range.isValid() ) {
range = doc.sanitizeRange( search.range ).normalized();
from = from < range.start() ? range.start() : from;
}
TextRange found =
doc.find( search.text, from, search.caseSensitive, search.wholeWord, search.type, range );
if ( found.isValid() ) {
doc.setSelection( found.reversed() );
return true;
} else {
found = doc.find( search.text, range.start(), search.caseSensitive, search.wholeWord,
search.type, range );
if ( found.isValid() ) {
doc.setSelection( found.reversed() );
return true;
}
}
return false;
}
bool DocSearchController::replaceSelection( SearchState& search, const String& replacement ) {
if ( !search.editor || !mEditorSplitter->editorExists( search.editor ) ||
!search.editor->getDocument().hasSelection() )
return false;
search.editor->getDocument().setActiveClient( search.editor );
search.editor->getDocument().replaceSelection( replacement );
return true;
}
int DocSearchController::replaceAll( SearchState& search, const String& replace ) {
if ( !search.editor || !mEditorSplitter->editorExists( search.editor ) )
return 0;
if ( search.text.empty() )
search.text = mLastSearch;
if ( search.text.empty() )
return 0;
search.editor->getDocument().setActiveClient( search.editor );
mLastSearch = search.text;
TextDocument& doc = search.editor->getDocument();
TextPosition startedPosition = doc.getSelection().start();
int count = doc.replaceAll( search.text, replace, search.caseSensitive, search.wholeWord,
search.type, search.range );
doc.setSelection( startedPosition );
return count;
}
bool DocSearchController::findAndReplace( SearchState& search, const String& replace ) {
if ( !search.editor || !mEditorSplitter->editorExists( search.editor ) )
return false;
if ( search.text.empty() )
search.text = mLastSearch;
if ( search.text.empty() )
return false;
search.editor->getDocument().setActiveClient( search.editor );
mLastSearch = search.text;
TextDocument& doc = search.editor->getDocument();
if ( doc.hasSelection() && doc.getSelectedText() == search.text ) {
return replaceSelection( search, replace );
} else {
return findNextText( search );
}
}
void DocSearchController::hideSearchBar() {
mSearchBarLayout->setEnabled( false )->setVisible( false );
}
void DocSearchController::onCodeEditorFocusChange( UICodeEditor* editor ) {
if ( mSearchState.editor && mSearchState.editor != editor ) {
String word = mSearchState.editor->getHighlightWord();
mSearchState.editor->setHighlightWord( "" );
mSearchState.editor->setHighlightTextRange( TextRange() );
mSearchState.text = "";
mSearchState.range = TextRange();
if ( editor ) {
mSearchState.editor = editor;
mSearchState.editor->setHighlightWord( word );
mSearchState.range = TextRange();
}
}
}
SearchState& DocSearchController::getSearchState() {
return mSearchState;
}
| 39.375887 | 96 | 0.706412 | SpartanJ |
f3c3ee553473a1a56d52f298a0d5cdae363bcf10 | 434 | cpp | C++ | level_zero/core/source/gen12lp/adlp/cmdqueue_adlp.cpp | troels/compute-runtime | 3269e719a3ee7bcd97c50ec2cfe78fc8674adec0 | [
"Intel",
"MIT"
] | 778 | 2017-09-29T20:02:43.000Z | 2022-03-31T15:35:28.000Z | level_zero/core/source/gen12lp/adlp/cmdqueue_adlp.cpp | troels/compute-runtime | 3269e719a3ee7bcd97c50ec2cfe78fc8674adec0 | [
"Intel",
"MIT"
] | 478 | 2018-01-26T16:06:45.000Z | 2022-03-30T10:19:10.000Z | level_zero/core/source/gen12lp/adlp/cmdqueue_adlp.cpp | troels/compute-runtime | 3269e719a3ee7bcd97c50ec2cfe78fc8674adec0 | [
"Intel",
"MIT"
] | 215 | 2018-01-30T08:39:32.000Z | 2022-03-29T11:08:51.000Z | /*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/core/source/cmdqueue/cmdqueue_hw.inl"
#include "level_zero/core/source/cmdqueue/cmdqueue_hw_base.inl"
#include "cmdqueue_extended.inl"
namespace L0 {
template struct CommandQueueHw<IGFX_GEN12LP_CORE>;
static CommandQueuePopulateFactory<IGFX_ALDERLAKE_P, CommandQueueHw<IGFX_GEN12LP_CORE>>
populateADLP;
} // namespace L0 | 24.111111 | 87 | 0.790323 | troels |
f3ca6f4d336f0b837cea93e26f59bcefe1e2cf61 | 625 | cpp | C++ | SimpleEngine/Simulation/WorldLogic.cpp | RichardBangs/SimpleEngine | a4acdf11d05e018db5a55994291475df55856c0c | [
"MIT"
] | null | null | null | SimpleEngine/Simulation/WorldLogic.cpp | RichardBangs/SimpleEngine | a4acdf11d05e018db5a55994291475df55856c0c | [
"MIT"
] | null | null | null | SimpleEngine/Simulation/WorldLogic.cpp | RichardBangs/SimpleEngine | a4acdf11d05e018db5a55994291475df55856c0c | [
"MIT"
] | null | null | null | #include "WorldLogic.h"
#include "WorldState.h"
#include "GameState.h"
#include "Events\ObjectDestroyedEvent.h"
namespace Simulation
{
WorldLogic::WorldLogic()
{
}
WorldLogic::~WorldLogic()
{
}
void WorldLogic::Tick(WorldState* thisWorld, GameState* stateLastFrame, std::vector<EventBase*> eventsThisFrame)
{
for (auto it = eventsThisFrame.begin(); it < eventsThisFrame.end(); ++it)
{
EventBase* myEvent = *it;
switch (myEvent->GetType())
{
case eEventType::ObjectDestroyed:
{
thisWorld->_objects.erase(static_cast<ObjectDestroyedEvent*>(myEvent)->_id);
}
break;
}
}
}
} | 17.857143 | 113 | 0.68 | RichardBangs |
Subsets and Splits