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
108
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
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
listlengths
1
9
max_issues_count
int64
1
67k
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
listlengths
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
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
3bd3af53a10d780672f128befebe9c6214a4c9f1
15,952
cpp
C++
tools/roughness-prefilter/src/main.cpp
bytememofo/filament
b0ab4c7321822b2f4e916e6b5fc7c4203f017886
[ "Apache-2.0" ]
1
2019-02-13T04:38:26.000Z
2019-02-13T04:38:26.000Z
tools/roughness-prefilter/src/main.cpp
bytememofo/filament
b0ab4c7321822b2f4e916e6b5fc7c4203f017886
[ "Apache-2.0" ]
null
null
null
tools/roughness-prefilter/src/main.cpp
bytememofo/filament
b0ab4c7321822b2f4e916e6b5fc7c4203f017886
[ "Apache-2.0" ]
null
null
null
/* * Copyright (C) 2015 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 <algorithm> #include <cstring> #include <fstream> #include <iostream> #include <thread> #include <math/vec3.h> #include <imageio/ImageDecoder.h> #include <imageio/ImageEncoder.h> #include <utils/JobSystem.h> #include <utils/Path.h> #include <getopt/getopt.h> using namespace math; using namespace image; using namespace utils; static ImageEncoder::Format g_format = ImageEncoder::Format::PNG_LINEAR; static bool g_formatSpecified = false; static bool g_linearOutput = false; static std::string g_compression; static Path g_roughnessMap; static float g_roughness = 0.0; static void printUsage(const char* name) { std::string execName(Path(name).getName()); std::string usage( "ROUGHNESSPREFILTER generates pre-filtered roughness maps from normal maps\n" "to help mitigate specular aliasing.\n" "Usage:\n" " ROUGHNESSPREFILTER [options] <normal-map> <output-roughness-map>\n" "\n" "Output note:\n" " One file will be generated per mip-level. The size of the first level will be\n" " the greater of the input normal map and input roughness map.\n" "\n" "Supported input formats:\n" " PNG, 8 and 16 bits\n" " Radiance (.hdr)\n" " Photoshop (.psd), 16 and 32 bits\n" " OpenEXR (.exr)\n" "\n" "Options:\n" " --help, -h\n" " print this message\n\n" " --license\n" " Print copyright and license information\n\n" " --roughness=[0..1], -r [0..1]\n" " desired constant roughness, ignored if --roughness-map is specified\n\n" " --roughness-map=<input-roughness-map>, -m <input-roughness-map>\n" " input roughness map\n\n" " --format=[exr|hdr|psd|png|dds], -f [exr|hdr|psd|png|dds]\n" " specify output file format, inferred from file name if omitted\n\n" " --compression=COMPRESSION, -c COMPRESSION\n" " format specific compression:\n" " PNG: Ignored\n" " Radiance: Ignored\n" " Photoshop: 16 (default), 32\n" " OpenEXR: RAW, RLE, ZIPS, ZIP, PIZ (default)\n" " DDS: 8, 16 (default), 32\n\n" " --linear, -l\n" " force linear output when the PNG format is selected\n\n" ); const std::string from("ROUGHNESSPREFILTER"); for (size_t pos = usage.find(from); pos != std::string::npos; pos = usage.find(from, pos)) { usage.replace(pos, from.length(), execName); } printf("%s", usage.c_str()); } static void license() { std::cout << #include "licenses/licenses.inc" ; } static int handleArguments(int argc, char* argv[]) { static constexpr const char* OPTSTR = "hr:c:f:m:l"; static const struct option OPTIONS[] = { { "help", no_argument, nullptr, 'h' }, { "license", no_argument, nullptr, 's' }, { "format", required_argument, nullptr, 'f' }, { "compression", required_argument, nullptr, 'c' }, { "roughness", required_argument, nullptr, 'r' }, { "roughness-map", required_argument, nullptr, 'm' }, { "linear", no_argument, nullptr, 'l' }, { nullptr, 0, nullptr, 0 } // termination of the option list }; int opt; int optionIndex = 0; while ((opt = getopt_long(argc, argv, OPTSTR, OPTIONS, &optionIndex)) >= 0) { std::string arg(optarg ? optarg : ""); switch (opt) { default: case 'h': printUsage(argv[0]); exit(0); // break; case 's': license(); exit(0); // break; case 'f': if (arg == "png") { g_format = ImageEncoder::Format::PNG; g_formatSpecified = true; } if (arg == "hdr") { g_format = ImageEncoder::Format::HDR; g_formatSpecified = true; } if (arg == "exr") { g_format = ImageEncoder::Format::EXR; g_formatSpecified = true; } if (arg == "psd") { g_format = ImageEncoder::Format::PSD; g_formatSpecified = true; } if (arg == "dds") { g_format = ImageEncoder::Format::DDS_LINEAR; g_formatSpecified = true; } break; case 'c': g_compression = arg; break; case 'r': try { g_roughness = std::stof(arg); } catch (std::invalid_argument& e) { std::cerr << "The specified roughness must be [0..1]: " << arg << std::endl; exit(1); } catch (std::out_of_range& e) { std::cerr << "The specified roughness must be [0..1]: " << arg << std::endl; exit(1); } break; case 'm': g_roughnessMap = arg; break; case 'l': g_linearOutput = true; break; } } return optind; } inline bool isPOT(size_t x) { return !(x & (x - 1)); } float solveVMF(const float2& pos, const size_t sampleCount, const float roughness, const Image& normal) { float3 averageNormal(0.0f); float2 topLeft(-float(sampleCount) / 2.0f + 0.5f); for (size_t y = 0; y < sampleCount; y++) { for (size_t x = 0; x < sampleCount; x++) { float2 offset(topLeft + float2(x, y)); float2 samplePos(floor(pos + offset) + 0.5f); float3 sampleNormal = *static_cast<float3*>( normal.getPixelRef(size_t(samplePos.x), size_t(samplePos.y))); sampleNormal = sampleNormal * 2.0f - 1.0f; averageNormal += normalize(sampleNormal); } } averageNormal /= (sampleCount * sampleCount); float r = length(averageNormal); float kappa = 10000.0f; if (r < 1.0f) { kappa = (3.0f * r - r * r * r) / (1.0f - r * r); } // See: Karis, 2018, "Normal map filtering using vMF (part 3)" // The original formulation in Neubelt et al. 2013, // "Crafting a Next-Gen Material Pipeline for The Order: 1886" contains an error // and defines alpha' = sqrt(alpha^2 + 1 / kappa) return std::sqrt(roughness * roughness + (2.0f / kappa)); } void prefilter(const Image& normal, const size_t mipLevel, Image& output) { const size_t width = output.getWidth(); const size_t height = output.getHeight(); const size_t sampleCount = 1u << mipLevel; for (size_t y = 0; y < height; y++) { auto* outputRow = static_cast<float3*>(output.getPixelRef(0, y)); for (size_t x = 0; x < width; x++, outputRow++) { const float2 uv = (float2(x, y) + 0.5f) / float2(width, height); const float2 pos = uv * normal.getWidth(); const float roughness = g_roughness; *outputRow = float3(solveVMF(pos, sampleCount, roughness, normal)); } } } template<bool FIRST_MIP> void prefilter(const Image& normal, const Image& roughness, const size_t mipLevel, Image& output) { const size_t width = output.getWidth(); const size_t height = output.getHeight(); const size_t sampleCount = 1u << mipLevel; for (size_t y = 0; y < height; y++) { auto* outputRow = static_cast<float3*>(output.getPixelRef(0, y)); for (size_t x = 0; x < width; x++, outputRow++) { const float3* data = static_cast<float3*>(roughness.getPixelRef(x, y)); if (FIRST_MIP) { *outputRow = *data; } else { const float2 uv = (float2(x, y) + 0.5f) / float2(width, height); const float2 pos = uv * normal.getWidth(); *outputRow = float3(solveVMF(pos, sampleCount, data->r, normal)); } } } } int main(int argc, char* argv[]) { int optionIndex = handleArguments(argc, argv); int numArgs = argc - optionIndex; if (numArgs < 2) { printUsage(argv[0]); return 1; } Path normalMap(argv[optionIndex ]); Path outputMap(argv[optionIndex + 1]); if (!normalMap.exists()) { std::cerr << "The input normal map does not exist: " << normalMap << std::endl; exit(1); } // make sure we load the normal maps as linear data std::ifstream inputStream(normalMap, std::ios::binary); Image normalImage = ImageDecoder::decode(inputStream, normalMap, ImageDecoder::ColorSpace::LINEAR); inputStream.close(); if (!normalImage.isValid()) { std::cerr << "The input normal map is invalid: " << normalMap << std::endl; exit(1); } if (!isPOT(normalImage.getWidth()) || !isPOT(normalImage.getHeight()) || normalImage.getWidth() != normalImage.getHeight()) { std::cerr << "The input normal map must have equal power-of-2 dimensions: " << normalImage.getWidth() << "x" << normalImage.getHeight() << std::endl; exit(1); } Image roughnessImage; std::vector<Image> mipImages; bool hasRoughnessMap = false; if (!g_roughnessMap.isEmpty()) { Path roughnessMap(g_roughnessMap); if (!roughnessMap.exists()) { std::cerr << "The input roughness map does not exist: " << roughnessMap << std::endl; exit(1); } hasRoughnessMap = true; inputStream.open(roughnessMap, std::ios::binary); roughnessImage = ImageDecoder::decode(inputStream, roughnessMap, ImageDecoder::ColorSpace::LINEAR); inputStream.close(); if (!roughnessImage.isValid()) { std::cerr << "The input roughness map is invalid: " << roughnessMap << std::endl; exit(1); } if (!isPOT(roughnessImage.getWidth()) || !isPOT(roughnessImage.getHeight()) || roughnessImage.getWidth() != roughnessImage.getHeight()) { std::cerr << "The input roughness map must have equal power-of-2 dimensions: " << roughnessImage.getWidth() << "x" << roughnessImage.getHeight() << std::endl; exit(1); } if (roughnessImage.getWidth() != normalImage.getWidth() || roughnessImage.getHeight() != normalImage.getHeight()) { std::cerr << "The input normal and roughness maps must have the same dimensions" << std::endl; exit(1); } } if (!g_formatSpecified) { g_format = ImageEncoder::chooseFormat(outputMap, g_linearOutput); } else { if (g_format == ImageEncoder::Format::PNG && g_linearOutput) { g_format = ImageEncoder::Format::PNG_LINEAR; } } const size_t width = hasRoughnessMap ? roughnessImage.getWidth() : normalImage.getWidth(); const size_t height = hasRoughnessMap ? roughnessImage.getHeight() : normalImage.getHeight(); const size_t mipLevels = size_t(std::log2f(width)) + 1; size_t channels = 3; switch (g_format) { case ImageEncoder::Format::DDS: case ImageEncoder::Format::DDS_LINEAR: case ImageEncoder::Format::PNG: case ImageEncoder::Format::PNG_LINEAR: channels = 1; break; default: break; } if (hasRoughnessMap) { mipImages.push_back(std::move(roughnessImage)); Image* prevMip = &mipImages.at(0); for (size_t i = 1; i <= mipLevels; i++) { const size_t w = width >> i; const size_t h = height >> i; const size_t size = w * h * sizeof(float3); std::unique_ptr<uint8_t[]> buffer(new uint8_t[size]); Image image(std::move(buffer), w, h, w * sizeof(float3), sizeof(float3), channels); for (size_t y = 0; y < h; y++) { auto* dst = static_cast<float3*>(image.getPixelRef(0, y)); for (size_t x = 0; x < w; x++, dst++) { float3 aa = *static_cast<float3*>(prevMip->getPixelRef(x * 2, y * 2)); float3 ba = *static_cast<float3*>(prevMip->getPixelRef(x * 2 + 1, y * 2)); float3 ab = *static_cast<float3*>(prevMip->getPixelRef(x * 2, y * 2 + 1)); float3 bb = *static_cast<float3*>(prevMip->getPixelRef(x * 2 + 1, y * 2 + 1)); *dst = (aa + ba + ab + bb) / 4.0f; } } mipImages.push_back(std::move(image)); prevMip = &mipImages.at(i); } } JobSystem js; js.adopt(); JobSystem::Job* parent = js.createJob(); for (size_t i = 0; i < mipLevels; i++) { JobSystem::Job* mip = jobs::createJob(js, parent, [&normalImage, &mipImages, outputMap, i, width, height, channels, hasRoughnessMap]() { const size_t w = width >> i; const size_t h = height >> i; const size_t size = w * h * sizeof(float3); std::unique_ptr<uint8_t[]> buffer(new uint8_t[size]); Image image(std::move(buffer), w, h, w * sizeof(float3), sizeof(float3), channels); if (i == 0) { if (hasRoughnessMap) { if (mipImages.at(0).getBytesPerRow() == image.getBytesPerRow()) { memcpy(image.getData(), mipImages.at(0).getData(), size); } else { prefilter<true>(normalImage, mipImages.at(0), 0, image); } } else { std::fill_n(static_cast<float3*>(image.getData()), w * h, float3(g_roughness)); } } else { if (hasRoughnessMap) { prefilter<false>(normalImage, mipImages.at(i), i, image); } else { prefilter(normalImage, i, image); } } const std::string ext = outputMap.getExtension(); const std::string name = outputMap.getNameWithoutExtension(); Path out = Path(outputMap.getParent()).concat( name + "_" + std::to_string(i) + "." + ext); // NOLINT std::ofstream outputStream(out, std::ios::binary | std::ios::trunc); if (!outputStream.good()) { std::cerr << "The output file cannot be opened: " << out << std::endl; } else { ImageEncoder::encode(outputStream, g_format, image, g_compression, out.getPath()); outputStream.close(); if (!outputStream.good()) { std::cerr << "An error occurred while writing the output file: " << out << std::endl; } } }); js.run(mip); } js.runAndWait(parent); }
37.446009
106
0.534478
bytememofo
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
3bd9c696e4903a85942567ee8e3eaa4ca3804602
6,743
cpp
C++
src/generated/CPACSSparPosition.cpp
cfsengineering/CPACSCreator-Version0
56d5c7915da7e8918479c505d70a70492c47219b
[ "Apache-2.0" ]
10
2018-09-05T15:12:26.000Z
2019-05-04T05:41:39.000Z
src/generated/CPACSSparPosition.cpp
cfsengineering/CPACSCreator-Version0
56d5c7915da7e8918479c505d70a70492c47219b
[ "Apache-2.0" ]
null
null
null
src/generated/CPACSSparPosition.cpp
cfsengineering/CPACSCreator-Version0
56d5c7915da7e8918479c505d70a70492c47219b
[ "Apache-2.0" ]
1
2019-01-12T13:54:14.000Z
2019-01-12T13:54:14.000Z
// Copyright (c) 2018 RISC Software GmbH // // This file was generated by CPACSGen from CPACS XML Schema (c) German Aerospace Center (DLR/SC). // Do not edit, all changes are lost when files are re-generated. // // 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 <cassert> #include "CCPACSWingSparPositions.h" #include "CPACSSparPosition.h" #include "CTiglError.h" #include "CTiglLogging.h" #include "CTiglUIDManager.h" #include "TixiHelper.h" namespace tigl { namespace generated { CPACSSparPosition::CPACSSparPosition(CCPACSWingSparPositions* parent, CTiglUIDManager* uidMgr) : m_uidMgr(uidMgr) , m_xsi(0) { //assert(parent != NULL); m_parent = parent; } CPACSSparPosition::~CPACSSparPosition() { if (m_uidMgr && m_uID) m_uidMgr->TryUnregisterObject(*m_uID); } const CCPACSWingSparPositions* CPACSSparPosition::GetParent() const { return m_parent; } CCPACSWingSparPositions* CPACSSparPosition::GetParent() { return m_parent; } CTiglUIDManager& CPACSSparPosition::GetUIDManager() { return *m_uidMgr; } const CTiglUIDManager& CPACSSparPosition::GetUIDManager() const { return *m_uidMgr; } void CPACSSparPosition::ReadCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) { // read attribute uID if (tixi::TixiCheckAttribute(tixiHandle, xpath, "uID")) { m_uID = tixi::TixiGetAttribute<std::string>(tixiHandle, xpath, "uID"); if (m_uID->empty()) { LOG(WARNING) << "Optional attribute uID is present but empty at xpath " << xpath; } } // read element xsi if (tixi::TixiCheckElement(tixiHandle, xpath + "/xsi")) { m_xsi = tixi::TixiGetElement<double>(tixiHandle, xpath + "/xsi"); } else { LOG(ERROR) << "Required element xsi is missing at xpath " << xpath; } // read element eta if (tixi::TixiCheckElement(tixiHandle, xpath + "/eta")) { m_eta_choice1 = tixi::TixiGetElement<double>(tixiHandle, xpath + "/eta"); } // read element elementUID if (tixi::TixiCheckElement(tixiHandle, xpath + "/elementUID")) { m_elementUID_choice2 = tixi::TixiGetElement<std::string>(tixiHandle, xpath + "/elementUID"); if (m_elementUID_choice2->empty()) { LOG(WARNING) << "Optional element elementUID is present but empty at xpath " << xpath; } } if (m_uidMgr && m_uID) m_uidMgr->RegisterObject(*m_uID, *this); if (!ValidateChoices()) { LOG(ERROR) << "Invalid choice configuration at xpath " << xpath; } } void CPACSSparPosition::WriteCPACS(const TixiDocumentHandle& tixiHandle, const std::string& xpath) const { // write attribute uID if (m_uID) { tixi::TixiSaveAttribute(tixiHandle, xpath, "uID", *m_uID); } else { if (tixi::TixiCheckAttribute(tixiHandle, xpath, "uID")) { tixi::TixiRemoveAttribute(tixiHandle, xpath, "uID"); } } // write element xsi tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/xsi"); tixi::TixiSaveElement(tixiHandle, xpath + "/xsi", m_xsi); // write element eta if (m_eta_choice1) { tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/eta"); tixi::TixiSaveElement(tixiHandle, xpath + "/eta", *m_eta_choice1); } else { if (tixi::TixiCheckElement(tixiHandle, xpath + "/eta")) { tixi::TixiRemoveElement(tixiHandle, xpath + "/eta"); } } // write element elementUID if (m_elementUID_choice2) { tixi::TixiCreateElementIfNotExists(tixiHandle, xpath + "/elementUID"); tixi::TixiSaveElement(tixiHandle, xpath + "/elementUID", *m_elementUID_choice2); } else { if (tixi::TixiCheckElement(tixiHandle, xpath + "/elementUID")) { tixi::TixiRemoveElement(tixiHandle, xpath + "/elementUID"); } } } bool CPACSSparPosition::ValidateChoices() const { return ( ( ( // mandatory elements of this choice must be there m_eta_choice1.is_initialized() && // elements of other choices must not be there !( m_elementUID_choice2.is_initialized() ) ) + ( // mandatory elements of this choice must be there m_elementUID_choice2.is_initialized() && // elements of other choices must not be there !( m_eta_choice1.is_initialized() ) ) == 1 ) ) ; } const boost::optional<std::string>& CPACSSparPosition::GetUID() const { return m_uID; } void CPACSSparPosition::SetUID(const boost::optional<std::string>& value) { if (m_uidMgr) { if (m_uID) m_uidMgr->TryUnregisterObject(*m_uID); if (value) m_uidMgr->RegisterObject(*value, *this); } m_uID = value; } const double& CPACSSparPosition::GetXsi() const { return m_xsi; } void CPACSSparPosition::SetXsi(const double& value) { m_xsi = value; } const boost::optional<double>& CPACSSparPosition::GetEta_choice1() const { return m_eta_choice1; } void CPACSSparPosition::SetEta_choice1(const boost::optional<double>& value) { m_eta_choice1 = value; } const boost::optional<std::string>& CPACSSparPosition::GetElementUID_choice2() const { return m_elementUID_choice2; } void CPACSSparPosition::SetElementUID_choice2(const boost::optional<std::string>& value) { m_elementUID_choice2 = value; } } // namespace generated } // namespace tigl
31.217593
108
0.586089
cfsengineering
3bda2ed3c0bd6777e3ede9bb0a802e59812e8db6
827
cpp
C++
cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/default_conditional_hit_count.cpp
mkinsner/llvm
589d48844edb12cd357b3024248b93d64b6760bf
[ "Apache-2.0" ]
605
2019-10-18T01:15:54.000Z
2022-03-31T14:31:04.000Z
cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/default_conditional_hit_count.cpp
mkinsner/llvm
589d48844edb12cd357b3024248b93d64b6760bf
[ "Apache-2.0" ]
3,180
2019-10-18T01:21:21.000Z
2022-03-31T23:25:41.000Z
cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/default_conditional_hit_count.cpp
mkinsner/llvm
589d48844edb12cd357b3024248b93d64b6760bf
[ "Apache-2.0" ]
275
2019-10-18T05:27:22.000Z
2022-03-30T09:04:21.000Z
// Purpose: // Test that \DexFinishTest can be used with a combination of a hit_count // and a condition, so that the test exits after the line referenced // by \DexFinishTest is stepped on while the condition (x == 2) is true a // given number of times. // Tests using the default controller (no \DexLimitSteps). // // REQUIRES: system-linux // // RUN: %dexter_regression_test -- %s | FileCheck %s // CHECK: default_conditional_hit_count.cpp int main() { for (int y = 0; y < 4; ++y) for (int x = 0; x < 4; ++x) (void)0; // DexLabel('finish_line') } // DexFinishTest('x', 2, on_line=ref('finish_line'), hit_count=2) // DexExpectWatchValue('x', 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, on_line=ref('finish_line')) // DexExpectWatchValue('y', 0, 1, 2, on_line=ref('finish_line'))
37.590909
94
0.631197
mkinsner
3bda9d13f480be17f8d1b7d5571b0ec1184da805
3,799
cpp
C++
docs/template_plugin/tests/functional/op_reference/sinh.cpp
ryanloney/openvino-1
4e0a740eb3ee31062ba0df88fcf438564f67edb7
[ "Apache-2.0" ]
1,127
2018-10-15T14:36:58.000Z
2020-04-20T09:29:44.000Z
docs/template_plugin/tests/functional/op_reference/sinh.cpp
ryanloney/openvino-1
4e0a740eb3ee31062ba0df88fcf438564f67edb7
[ "Apache-2.0" ]
439
2018-10-20T04:40:35.000Z
2020-04-19T05:56:25.000Z
docs/template_plugin/tests/functional/op_reference/sinh.cpp
ryanloney/openvino-1
4e0a740eb3ee31062ba0df88fcf438564f67edb7
[ "Apache-2.0" ]
414
2018-10-17T05:53:46.000Z
2020-04-16T17:29:53.000Z
// Copyright (C) 2018-2022 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include <gtest/gtest.h> #include "openvino/op/sinh.hpp" #include "base_reference_test.hpp" using namespace ov; namespace reference_tests { namespace { struct SinhParams { reference_tests::Tensor input; reference_tests::Tensor expected; }; struct Builder : ParamsBuilder<SinhParams> { REFERENCE_TESTS_ADD_SET_PARAM(Builder, input); REFERENCE_TESTS_ADD_SET_PARAM(Builder, expected); }; class ReferenceSinhLayerTest : public testing::TestWithParam<SinhParams>, public CommonReferenceTest { public: void SetUp() override { auto params = GetParam(); function = CreateFunction(params.input.shape, params.input.type); inputData = {params.input.data}; refOutData = {params.expected.data}; } static std::string getTestCaseName(const testing::TestParamInfo<SinhParams>& obj) { auto param = obj.param; std::ostringstream result; result << "shape=" << param.input.shape << "_"; result << "type=" << param.input.type; return result.str(); } private: static std::shared_ptr<Model> CreateFunction(const Shape& shape, const element::Type& type) { const auto in = std::make_shared<op::v0::Parameter>(type, shape); const auto Sinh = std::make_shared<op::v0::Sinh>(in); return std::make_shared<ov::Model>(NodeVector {Sinh}, ParameterVector {in}); } }; TEST_P(ReferenceSinhLayerTest, SinhWithHardcodedRefs) { Exec(); } } // namespace INSTANTIATE_TEST_SUITE_P( smoke_Sinh_With_Hardcoded_Refs, ReferenceSinhLayerTest, ::testing::Values( Builder {} .input({{11}, element::f16, std::vector<ngraph::float16> {-4.f, -2.f, -1.f, -0.5f, -0.25f, 0.f, 0.25f, 0.5f, 1.f, 2.f, 4.f}}) .expected({{11}, element::f16, std::vector<ngraph::float16> {-27.28991720f, -3.62686041f, -1.17520120f, -0.52109531f, -0.25261232f, 0.00000000f, 0.25261232f, 0.52109531f, 1.17520120f, 3.62686041f, 27.28991720f}}), Builder {} .input({{11}, element::f32, std::vector<float> {-4.f, -2.f, -1.f, -0.5f, -0.25f, 0.f, 0.25f, 0.5f, 1.f, 2.f, 4.f}}) .expected({{11}, element::f32, std::vector<float> {-27.28991720f, -3.62686041f, -1.17520120f, -0.52109531f, -0.25261232f, 0.00000000f, 0.25261232f, 0.52109531f, 1.17520120f, 3.62686041f, 27.28991720f}}), Builder {} .input({{7}, element::i32, std::vector<int32_t> {-4, -2, -1, 0, 1, 2, 4}}) .expected({{7}, element::i32, std::vector<int32_t> {-27, -4, -1, 0, 1, 4, 27}}), Builder {} .input({{7}, element::i64, std::vector<int64_t> {-4, -2, -1, 0, 1, 2, 4}}) .expected({{7}, element::i64, std::vector<int64_t> {-27, -4, -1, 0, 1, 4, 27}}), Builder {} .input({{4}, element::u32, std::vector<uint32_t> {0, 1, 2, 4}}) .expected({{4}, element::u32, std::vector<uint32_t> {0, 1, 4, 27}}), Builder {} .input({{4}, element::u64, std::vector<uint64_t> {0, 1, 2, 4}}) .expected({{4}, element::u64, std::vector<uint64_t> {0, 1, 4, 27}})), ReferenceSinhLayerTest::getTestCaseName); } // namespace reference_tests
38.373737
137
0.528034
ryanloney
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 (tobias.sargeant@gmail.com). // 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
3bdb2975a5dded002440ddc1c0ff3d0f3662f350
12,297
hpp
C++
png_text_chunk.hpp
estshorter/extract-png-text-chunk
0f7f35fa84f7c42ec921b2ffc531f06984b6f46b
[ "CC0-1.0" ]
null
null
null
png_text_chunk.hpp
estshorter/extract-png-text-chunk
0f7f35fa84f7c42ec921b2ffc531f06984b6f46b
[ "CC0-1.0" ]
null
null
null
png_text_chunk.hpp
estshorter/extract-png-text-chunk
0f7f35fa84f7c42ec921b2ffc531f06984b6f46b
[ "CC0-1.0" ]
null
null
null
#pragma once #include <algorithm> #include <array> #include <fstream> #include <iostream> #include <string> #include <unordered_map> #include <vector> #define CRCPP_USE_CPP11 #include "CRC.h" namespace png_text_chunk { using KV = std::pair<std::string, std::string>; template <typename T> struct is_char { static const bool value = std::is_same<T, char>::value || std::is_same<T, signed char>::value || std::is_same<T, unsigned char>::value; }; template <typename T> inline constexpr bool is_char_v = is_char<T>::value; inline std::uint32_t swap_endian(std::uint32_t data) { return ((data >> 24) & 0xff) | // move byte 3 to byte 0 ((data << 8) & 0xff0000) | // move byte 1 to byte 2 ((data >> 8) & 0xff00) | // move byte 2 to byte 1 ((data << 24) & 0xff000000); // byte 0 to byte 3 } template <class Iter> std::uint32_t swap_endian(Iter begin) { return (static_cast<unsigned char>(*(begin + 3))) | ((static_cast<unsigned char>(*(begin + 2)) << 8) & 0xff00) | ((static_cast<unsigned char>(*(begin + 1)) << 16) & 0xff0000) | ((static_cast<unsigned char>(*(begin)) << 24) & 0xff000000); } inline bool is_valid_png(std::ifstream& ifs) { constexpr auto PNG_SIG = "\x89PNG\r\n\x1a\n"; std::array<char, sizeof(PNG_SIG)> sig{}; ifs.seekg(0); ifs.read(sig.data(), sig.size()); for (size_t i = 0; i < sig.size(); i++) { if (PNG_SIG[i] != sig[i]) { return false; } } ifs.seekg(0); return true; } template <typename T, std::enable_if_t<is_char_v<T>, std::nullptr_t> = nullptr> bool is_valid_png(const std::vector<T>& img) { constexpr auto PNG_SIG = "\x89PNG\r\n\x1a\n"; for (int i = 0; i < 8; i++) { if (PNG_SIG[i] != static_cast<char>(img[i])) { return false; } } return true; } template <typename T, std::enable_if_t<is_char_v<T>, std::nullptr_t> = nullptr> std::uint32_t read_size(typename std::vector<T>::const_iterator& begin) { auto length = swap_endian(begin); begin += 4; return length; } inline std::uint32_t read_size(std::ifstream& ifs) { std::array<char, 4> length{}; ifs.read(length.data(), length.size()); std::uint32_t ret = swap_endian(length.begin()); return ret; } template <typename T, std::enable_if_t<is_char_v<T>, std::nullptr_t> = nullptr> std::string read_string(typename std::vector<T>::const_iterator& begin, std::uint32_t length) { auto end = begin + length; std::string text; text.reserve(length); std::copy(begin, end, std::back_inserter(text)); begin = end; return text; } inline std::string read_string(std::ifstream& ifs, std::uint32_t length) { std::string text(4, '\0'); ifs.read(text.data(), length); return text; } // assume uncompressed template <typename T, std::enable_if_t<is_char_v<T>, std::nullptr_t> = nullptr> std::pair<std::string, std::string> read_key_value(typename std::vector<T>::const_iterator& begin, std::uint32_t length) { auto end = begin + length; auto first_null = std::find(begin, end, '\0'); auto begin_r = std::make_reverse_iterator(begin); auto delim_r = std::find(std::make_reverse_iterator(end), begin_r, '\0'); if (delim_r == begin_r || first_null == end) { throw("null character is not found"); } auto last_null = begin + std::distance(delim_r, begin_r); std::string key, value; std::copy(begin, first_null, std::back_inserter(key)); std::copy(last_null, end, std::back_inserter(value)); begin = end; return {key, value}; } template <typename T, std::enable_if_t<is_char_v<T>, std::nullptr_t> = nullptr> std::string read_chunk_name(typename std::vector<T>::const_iterator& begin) { auto ret = read_string<T>(begin, 4); return ret; } inline std::string read_chunk_name(std::ifstream& ifs) { auto ret = read_string(ifs, 4); return ret; } template <typename T> std::pair<std::string, std::uint32_t> read_chunk_name_size( typename std::vector<T>::const_iterator& begin) { auto length = read_size<T>(begin); auto name = read_chunk_name<T>(begin); return {name, length}; } inline std::pair<std::string, std::uint32_t> read_chunk_name_size(std::ifstream& ifs) { auto length = read_size(ifs); auto name = read_chunk_name(ifs); return {name, length}; } template <typename T, std::enable_if_t<is_char_v<T>, std::nullptr_t> = nullptr> void skip_content(typename std::vector<T>::const_iterator& begin, std::uint32_t length) { begin += length + 4; } inline void skip_content(std::ifstream& ifs, std::uint32_t length) { ifs.seekg(static_cast<size_t>(length + 4), std::ios_base::cur); } template <typename T, std::enable_if_t<is_char_v<T>, std::nullptr_t> = nullptr> std::pair<std::string, std::string> read_text_chunk(typename std::vector<T>::const_iterator& begin, std::uint32_t length) { constexpr auto size_type = 4; std::uint32_t crc_calculated = CRC::Calculate(&(*(begin - size_type)), length + size_type, CRC::CRC_32()); auto [key, value] = read_key_value<T>(begin, length); std::uint32_t crc = swap_endian(begin); if (crc != crc_calculated) { throw std::runtime_error("CRC doesn't match: from_data: " + std::to_string(crc_calculated) + ", actual: " + std::to_string(crc)); } begin += 4; return {key, value}; } inline std::pair<std::string, std::string> read_text_chunk(std::ifstream& ifs, std::uint32_t length) { constexpr auto size_type = 4; constexpr auto size_crc = 4; std::vector<char> content(length + size_type + size_crc); ifs.read(content.data(), content.size()); std::uint32_t crc_calculated = CRC::Calculate(content.data(), content.size() - size_crc, CRC::CRC_32()); auto it = (content.end() - size_crc); auto crc = swap_endian(it); if (crc != crc_calculated) { throw std::runtime_error("CRC doesn't match: from_data: " + std::to_string(crc_calculated) + ", actual: " + std::to_string(crc)); } auto begin = content.cbegin() + size_type; auto [key, value] = read_key_value<char>(begin, length); return {key, value}; } template <typename T, std::enable_if_t<is_char_v<T>, std::nullptr_t> = nullptr> std::vector<T> generate_text_chunk(const std::string& key_ascii, const std::string& val_ascii, bool utf8 = false) { constexpr auto size_length = 4; constexpr auto size_type = 4; constexpr auto size_crc = 4; if (key_ascii.size() == 0 || key_ascii.size() >= 80) { throw std::runtime_error("key size must be within 1~79"); } std::uint32_t length = static_cast<uint32_t>(key_ascii.size() + 1 + val_ascii.size()); if (utf8) { length += 4; } std::uint32_t length_swapped = swap_endian(length); std::vector<T> ret; ret.reserve(length + size_length + size_type + size_crc); T* len = reinterpret_cast<T*>(&length_swapped); for (int i = 0; i < 4; i++) { ret.push_back(len[i]); } constexpr std::array<T, 4> type_text = {'t', 'E', 'X', 't'}; constexpr std::array<T, 4> type_itext = {'i', 'T', 'X', 't'}; std::vector<T> content; content.reserve(length + size_type); if (utf8) { std::move(type_itext.begin(), type_itext.end(), std::back_inserter(content)); } else { std::move(type_text.begin(), type_text.end(), std::back_inserter(content)); } std::copy(key_ascii.begin(), key_ascii.end(), std::back_inserter(content)); content.push_back('\0'); // sep if (utf8) { content.push_back('\0'); // compresion flag content.push_back('\0'); // compresson type content.push_back('\0'); // sep content.push_back('\0'); // sep } std::copy(val_ascii.begin(), val_ascii.end(), std::back_inserter(content)); std::uint32_t crc = CRC::Calculate(content.data(), content.size(), CRC::CRC_32()); std::uint32_t crc_swapped = swap_endian(crc); T* crc_ = reinterpret_cast<T*>(&crc_swapped); std::move(content.begin(), content.end(), std::back_inserter(ret)); for (int i = 0; i < 4; i++) { ret.push_back(crc_[i]); } return ret; } template <typename T, std::enable_if_t<is_char_v<T>, std::nullptr_t> = nullptr> void insert_text_chunk(std::vector<T>& img, typename std::vector<T>::const_iterator& begin, const std::string& key_ascii, const std::string& val_ascii, bool utf8 = false) { auto text = generate_text_chunk<T>(key_ascii, val_ascii, utf8); auto size = text.size(); begin = img.insert(begin, std::make_move_iterator(text.begin()), std::make_move_iterator(text.end())); begin += size; } template <typename T, std::enable_if_t<is_char_v<T>, std::nullptr_t> = nullptr> std::vector<T> insert_text_chunks(std::vector<T>& img_data, const std::vector<KV>& kvs, bool utf8 = false, bool validity_check = true) { if (validity_check && !is_valid_png(img_data)) { throw std::runtime_error("png signature not found"); } auto begin = img_data.cbegin() + 8; while (begin != img_data.end()) { auto [name, length] = read_chunk_name_size<T>(begin); // std::cout << "chunk: " << name << ", len: " << length << std::endl; if (name == "IHDR") { skip_content<T>(begin, length); for (auto& [k, v] : kvs) { insert_text_chunk(img_data, begin, k, v, utf8); // std::cout << "insert: key: " << k << ", value: " << v << std::endl; } return img_data; } } throw std::runtime_error("IHDR cannot be found"); } template <typename T, std::enable_if_t<is_char_v<T>, std::nullptr_t> = nullptr> std::vector<T> insert_text_chunks(std::ifstream& ifs, const std::vector<KV>& kvs, bool utf8 = false, bool validity_check = true) { if (validity_check && !is_valid_png(ifs)) { throw std::runtime_error("png signature not found"); } ifs.seekg(0, std::ios::end); size_t img_size = ifs.tellg(); ifs.seekg(0); std::vector<T> img_data(img_size); ifs.read(reinterpret_cast<char*>(img_data.data()), img_size); // std::cout << "size = " << img_size << "\n"; return insert_text_chunks<T>(img_data, kvs, utf8, false); } template <typename T = char, std::enable_if_t<is_char_v<T>, std::nullptr_t> = nullptr> std::vector<T> insert_text_chunks(const std::string& filename, const std::vector<KV>& kvs) { std::ifstream ifs; ifs.open(filename, std::ios::out | std::ios::binary); if (ifs.fail()) { throw std::runtime_error("cannot open a file"); } return insert_text_chunks<T>(ifs, kvs); } std::unordered_map<std::string, std::string> extract_text_chunks(const std::string& filename, bool validity_check = true) { std::ifstream ifs; ifs.open(filename, std::ios::out | std::ios::binary); if (ifs.fail()) { throw std::runtime_error("cannot open a file"); } if (validity_check && !is_valid_png(ifs)) { throw std::runtime_error("png signature not found"); }; std::unordered_map<std::string, std::string> ret; ifs.seekg(8); while (!ifs.eof()) { auto [name, length] = read_chunk_name_size(ifs); // std::cout << "chunk: " << name << ", len: " << length << std::endl; if (name == "tEXt" || name == "iTXt") { auto [key, value] = read_text_chunk(ifs, length); // std::cout << " - key: " << key << ", value: " << value << std::endl; ret[std::move(key)] = std::move(value); } else if (name == "IEND") { break; } else { skip_content(ifs, length); } } return ret; } template <typename T = char, std::enable_if_t<is_char_v<T>, std::nullptr_t> = nullptr> std::unordered_map<std::string, std::string> extract_text_chunks(const std::vector<T>& img, bool validity_check = true) { if (validity_check && !is_valid_png<T>(img)) { throw std::runtime_error("png signature not found"); }; std::unordered_map<std::string, std::string> ret; auto begin = img.cbegin() + 8; while (begin != img.end()) { auto [name, length] = read_chunk_name_size<T>(begin); // std::cout << "chunk: " << name << ", len: " << length << std::endl; if (name == "tEXt" || name == "iTXt") { auto [key, value] = read_text_chunk<T>(begin, length); // std::cout << " - key: " << key << ", value: " << value << std::endl; ret[std::move(key)] = std::move(value); } else if (name == "IEND") { break; } else { skip_content<T>(begin, length); } } return ret; } } // namespace png_text_chunk
33.782967
101
0.640563
estshorter
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
3bdec6fe5b78550553da1c7acab0731c6012b54c
3,683
cpp
C++
src/qt/src/3rdparty/webkit/Source/WebCore/plugins/PluginViewNone.cpp
ant0ine/phantomjs
8114d44a28134b765ab26b7e13ce31594fa81253
[ "BSD-3-Clause" ]
46
2015-01-08T14:32:34.000Z
2022-02-05T16:48:26.000Z
src/qt/src/3rdparty/webkit/Source/WebCore/plugins/PluginViewNone.cpp
ant0ine/phantomjs
8114d44a28134b765ab26b7e13ce31594fa81253
[ "BSD-3-Clause" ]
7
2015-01-20T14:28:12.000Z
2017-01-18T17:21:44.000Z
src/qt/src/3rdparty/webkit/Source/WebCore/plugins/PluginViewNone.cpp
ant0ine/phantomjs
8114d44a28134b765ab26b7e13ce31594fa81253
[ "BSD-3-Clause" ]
14
2015-10-27T06:17:48.000Z
2020-03-03T06:15:50.000Z
/* * Copyright (C) 2008 Kevin Ollivier <kevino@theolliviers.com> All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "PluginView.h" #if USE(JSC) #include "BridgeJSC.h" #include <runtime/JSObject.h> #include <runtime/ScopeChain.h> #endif using namespace WTF; namespace WebCore { void PluginView::setFocus(bool) { } void PluginView::show() { } void PluginView::hide() { } void PluginView::paint(GraphicsContext*, const IntRect&) { } void PluginView::handleKeyboardEvent(KeyboardEvent*) { } void PluginView::handleMouseEvent(MouseEvent*) { } void PluginView::setParent(ScrollView*) { } void PluginView::setNPWindowRect(const IntRect&) { } #if ENABLE(NETSCAPE_PLUGIN_API) NPError PluginView::handlePostReadFile(Vector<char>&, uint32_t, const char*) { return 0; } bool PluginView::platformGetValue(NPNVariable, void*, NPError*) { return false; } bool PluginView::platformGetValueStatic(NPNVariable, void*, NPError*) { return false; } void PluginView::invalidateRect(NPRect*) { } #endif void PluginView::invalidateRect(const IntRect&) { } #if ENABLE(NETSCAPE_PLUGIN_API) void PluginView::invalidateRegion(NPRegion) { } #endif void PluginView::forceRedraw() { } bool PluginView::platformStart() { return true; } void PluginView::platformDestroy() { } void PluginView::setParentVisible(bool) { } void PluginView::updatePluginWidget() { } void PluginView::halt() { } void PluginView::restart() { } #if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API) void PluginView::handleFocusInEvent() { } void PluginView::handleFocusOutEvent() { } #endif // The functions below are for platforms that do not use PluginView for plugins // due to architectural differences. The plan is to eventually have all // ports using PluginView, but until then, if new functions like this are // added, please make sure they have the proper platform #ifs so that changes // do not break ports who compile both this file and PluginView.cpp. #if PLATFORM(MAC) || PLATFORM(CHROMIUM) || PLATFORM(EFL) || (OS(WINCE) && !PLATFORM(QT)) || (PLATFORM(QT) && !OS(WINCE)) || PLATFORM(BREWMP) #if ENABLE(NETSCAPE_PLUGIN_API) void PluginView::keepAlive(NPP) { } #endif #if USE(JSC) PassRefPtr<JSC::Bindings::Instance> PluginView::bindingInstance() { return 0; } #endif void PluginView::privateBrowsingStateChanged(bool) { } void PluginView::setJavaScriptPaused(bool) { } #endif } // namespace WebCore
21.664706
140
0.746674
ant0ine
3be0daeabdb6a61af6fda822e63e2d0129dbbc98
2,498
cpp
C++
USACOcontests/silver/2017.12/measurement.cpp
eyangch/competitive-programming
59839efcec72cb792e61b7d316f83ad54f16a166
[ "MIT" ]
14
2019-08-14T00:43:10.000Z
2021-12-16T05:43:31.000Z
USACOcontests/silver/2017.12/measurement.cpp
eyangch/competitive-programming
59839efcec72cb792e61b7d316f83ad54f16a166
[ "MIT" ]
null
null
null
USACOcontests/silver/2017.12/measurement.cpp
eyangch/competitive-programming
59839efcec72cb792e61b7d316f83ad54f16a166
[ "MIT" ]
6
2020-12-30T03:30:17.000Z
2022-03-11T03:40:02.000Z
#include <iostream> #include <fstream> #include <set> #include <unordered_map> #include <utility> #include <array> #include <algorithm> using namespace std; int main(){ ifstream fin("measurement.in"); ofstream fout("measurement.out"); set<array<int, 3>> m; unordered_map<int, int> ids; array<int, 100000> milkvalues; int N, G; fin >> N >> G; for(int i = 0; i < N; i++){ array<int, 3> tmp; fin >> tmp[0] >> tmp[1] >> tmp[2]; m.insert(tmp); ids.insert(make_pair(tmp[1], ids.size())); // Convert raw input id to scaled ID (ALWAYS USE SCALED ID) } fill(milkvalues.begin(), milkvalues.begin() + N, G); set<pair<int, int>> milkvalsorted; set<int> topcows; for(unsigned int i = 0; i < ids.size(); i++){ milkvalsorted.insert(make_pair(G, i)); //init sorted values topcows.insert(i); } int maxmilk = G; int changes = 0; for(set<array<int, 3>>::iterator it = m.begin(); it != m.end(); it++){ array<int, 3> today = *it; int scaledID = ids[today[1]]; milkvalsorted.erase(make_pair(milkvalues[scaledID], scaledID)); milkvalues[scaledID] += today[2]; milkvalsorted.insert(make_pair(milkvalues[scaledID], scaledID)); if(milkvalues[scaledID] > maxmilk){ if(topcows.size() != 1 || topcows.find(scaledID) == topcows.end() || maxmilk == G){ changes++; topcows.clear(); topcows.insert(scaledID); } maxmilk = milkvalues[scaledID]; }else if(milkvalues[scaledID] == maxmilk){ changes++; topcows.insert(scaledID); }else if(milkvalues[scaledID] < maxmilk && topcows.find(scaledID) != topcows.end()){ if(topcows.size() > 1){ topcows.erase(scaledID); changes++; }else{ topcows.clear(); int m = get<0>(*milkvalsorted.rbegin()); set<pair<int, int>>::reverse_iterator l = milkvalsorted.rbegin(); int newcows = 0; while(get<0>(*l) == m && l != milkvalsorted.rend()){ newcows++; topcows.insert(get<1>(*l)); l++; } l--; if(newcows > 1 || get<1>(*l) != scaledID) changes++; maxmilk = m; } } } fout << changes << endl; return 0; }
33.756757
110
0.510408
eyangch
3be648bbe2f8b104621974ea6e3454433d332b98
14,577
cpp
C++
server/rtree_map.cpp
TRHackerTR33/griddb_nosql
ff9d3c4f4bfe2529a0a045eea7c217d533161504
[ "Apache-2.0" ]
2
2021-06-25T09:41:47.000Z
2021-06-25T10:37:51.000Z
server/rtree_map.cpp
ouellani/griddb_nosql
2ccb037d7ea2d79d3b9ee5830cdcb209f8d6d612
[ "Apache-2.0" ]
null
null
null
server/rtree_map.cpp
ouellani/griddb_nosql
2ccb037d7ea2d79d3b9ee5830cdcb209f8d6d612
[ "Apache-2.0" ]
null
null
null
/* Copyright (c) 2017 TOSHIBA Digital Solutions Corporation This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /*! @file @brief Rtree map implementation */ #include "rtree_map.h" #include "util/type.h" #include "util/container.h" #include "TrTree.h" #include "collection.h" #include "data_store.h" #include "data_type.h" #include "gis_geometry.h" #include "gs_error.h" #include "qp_def.h" #include "time_series.h" #include "value.h" #include <iostream> /*! * @brief Initialize already memcpy-ed region * * @param txn TransactionContext * @param columnType COLUMN_TYPE_GEOMETRY * @param columnId ColumnId * @param metaAllocateStrategy AllocateStrategy for RtreeMapImage * @param isUnique specifies whether the key is unique * * @return 0 if succeeded. * @note returns void? */ int32_t RtreeMap::initialize(TransactionContext &txn, ColumnType columnType, ColumnId columnId, const AllocateStrategy &metaAllocateStrategy, bool isUnique) { if (columnType != COLUMN_TYPE_GEOMETRY) { GS_THROW_USER_ERROR(GS_ERROR_TQ_CONSTRAINT_CANNOT_MAKE_INDEX, "Cannot use RtreeMap with non-geometry column"); } rtreeMapImage_ = BaseObject::allocate<RtreeMapImage>(sizeof(RtreeMapImage), metaAllocateStrategy, getBaseOId(), OBJECT_TYPE_RTREE_MAP); rtreeMapImage_->columnId_ = columnId; rtreeMapImage_->isUnique_ = isUnique; rtreeMapImage_->size_ = 0; rtreeMapImage_->offset_ = 0; rtreeMapImage_->oId_ = TrIndex_new(txn, *getObjectManager()); return 0; } /*! * @brief Nothing to do * * @param txn Transaction Context * * @return void */ bool RtreeMap::finalize(TransactionContext &txn) { setDirty(); uint64_t removeNum = NUM_PER_EXEC; if (rtreeMapImage_->oId_ != UNDEF_OID) { TrIndex_destroy(txn, *getObjectManager(), rtreeMapImage_->oId_, removeNum); if (removeNum > 0) { rtreeMapImage_->oId_ = UNDEF_OID; rtreeMapImage_->size_ = 0; } } if (removeNum > 0) { BaseObject::finalize(); } return removeNum > 0; } /*! * @brief Returns size * * @return size */ uint64_t RtreeMap::size() { return rtreeMapImage_->size_; } /*! * @brief Get geometry object from OId * * @param txn Transaction Context * @param constKey Search key * * @return Found geometry */ Geometry *RtreeMap::getGeometry(TransactionContext &txn, const void *constKey) { if (constKey == NULL) { GS_THROW_USER_ERROR(GS_ERROR_CM_BAD_ADDRESS, "RtreeMap cannot obtain correct geometry object"); } void *key = const_cast<void *>(constKey); BinaryObject tmpVariant(reinterpret_cast<uint8_t *>(key)); return Geometry::deserialize(txn, tmpVariant.data(), tmpVariant.size()); } /*! * @brief Insert an oId into the index. * * @param txn Transaction Context * @param key Search key * @param oId an Object-ID of a row image * * @return -1 if failed, 0 otherwise */ int32_t RtreeMap::insert(TransactionContext &txn, const void *key, OId oId) { setDirty(); TrRectTag r; r = getGeometry(txn, key)->getBoundingRect(); TrIndex_insert(txn, *getObjectManager(), rtreeMapImage_->oId_, &r, oId); ++rtreeMapImage_ ->size_; return 0; } /*! * @brief Removes an oId from the index * * @param txn Transaction Context * @param key Search key * @param oId an Object-ID of a row image to delete * * @return -1 if failed, 0 otherwise */ int32_t RtreeMap::remove(TransactionContext &txn, const void *key, OId oId) { setDirty(); TrRectTag r; r = getGeometry(txn, key)->getBoundingRect(); if (TrIndex_delete_cmp(txn, *getObjectManager(), rtreeMapImage_->oId_, &r, oIdCmpCallback, &oId)) { --rtreeMapImage_->size_; } return 0; } /*! * @brief Changes an oId of the specified node in the index. * * @param txn Transaction Context * @param key Search key * @param oId old row-image * @param newOId new row-image * * @return -1 if failed. */ int32_t RtreeMap::update( TransactionContext &txn, const void *key, OId oId, OId newOId) { setDirty(); TrRectTag r; r = getGeometry(txn, key)->getBoundingRect(); TrIndex_delete_cmp(txn, *getObjectManager(), rtreeMapImage_->oId_, &r, oIdCmpCallback, &oId); TrIndex_insert(txn, *getObjectManager(), rtreeMapImage_->oId_, &r, newOId); return 0; } /*! * @brief Retrieves all data in the rtree index. * * @param txn Transaction Context * @param limit limit number * @param idList answer vector * * @return void */ int32_t RtreeMap::getAll( TransactionContext &txn, ResultSize limit, util::XArray<OId> &idList) { HitIntersectCallbackArg arg; arg.limit = limit; arg.oidList = &idList; arg.size = 0; TrIndex_all( txn, *getObjectManager(), rtreeMapImage_->oId_, hitAllCallback, &arg); return 0; } /*! * @brief Searches an oId, according to the key * * @param txn Transaction Context * @param key Non-empty geometry which has its bounding box * @param oId answer * * @return void */ int32_t RtreeMap::search( TransactionContext &txn, const void *key, OId &oId) { const Geometry *g = reinterpret_cast<const Geometry *>(key); HitIntersectCallbackArg arg; TrRectTag r = g->getBoundingRect(); arg.rect = &r; arg.limit = 1; arg.size = UINT64_MAX; arg.oidList = NULL; arg.oneOId = UNDEF_OID; TrIndex_search(txn, *getObjectManager(), rtreeMapImage_->oId_, checkCallback, &r, hitIntersectCallback, &arg); oId = arg.oneOId; return 0; } /*! * @brief Search the index according to the condition * * @param txn Transaction Context * @param sc search condition * @param oidList answer vector */ void RtreeMap::search(TransactionContext &txn, RtreeMap::SearchContext &sc, util::XArray<OId> &oidList, OutputOrder outputOrder) { TermCondition *cond = sc.getKeyCondition(); SearchContext::GeomeryCondition *geomCond = static_cast<SearchContext::GeomeryCondition *>( const_cast<void *>(cond->value_)); if (geomCond->valid_) { getAll(txn, sc.limit_, oidList); } else { switch (geomCond->relation_) { case GEOMETRY_INTERSECT: { HitIntersectCallbackArg arg; arg.rect = &(geomCond->rect_[0]); arg.limit = static_cast<ResultSize>(sc.limit_); arg.oidList = &oidList; arg.size = 0; TrIndex_search(txn, *getObjectManager(), rtreeMapImage_->oId_, checkCallback, arg.rect, hitIntersectCallback, &arg); break; } case GEOMETRY_INCLUDE: { HitIncludeCallbackArg arg; arg.rect = &(geomCond->rect_[0]); arg.limit = static_cast<ResultSize>(sc.limit_); arg.oidList = &oidList; arg.size = 0; TrIndex_search(txn, *getObjectManager(), rtreeMapImage_->oId_, checkCallback, arg.rect, hitIncludeCallback, &arg); break; } case GEOMETRY_DIFFERENTIAL: { HitDifferentialCallbackArg arg; arg.rect1 = &(geomCond->rect_[0]); arg.rect2 = &(geomCond->rect_[1]); arg.limit = static_cast<ResultSize>(sc.limit_); arg.oidList = &oidList; arg.size = 0; TrIndex_search(txn, *getObjectManager(), rtreeMapImage_->oId_, checkCallback, arg.rect1, hitDifferentialCallback, &arg); break; } case GEOMETRY_QSF_INTERSECT: { HitQsfIntersectCallbackArg arg; arg.pkey = &(geomCond->pkey_); arg.limit = static_cast<ResultSize>(sc.limit_); arg.oidList = &oidList; arg.size = 0; TrIndex_search_quad(txn, *getObjectManager(), rtreeMapImage_->oId_, arg.pkey, hitQsfIntersectCallback, &arg); break; } default: GS_THROW_USER_ERROR(GS_ERROR_TQ_INTERNAL_GIS_UNKNOWN_RELATIONSHIP, "Unknown relationship of RtreeMap."); } } } /*! * @brief TrIndex check callback for intersection. * * @param txn Transaction Context * @param r Rect to check * @param arg argument pointer (TrRect) * * @return 1 if search continues to the below (leaf), 0 if search returns to the * above */ int32_t RtreeMap::checkCallback(TransactionContext &, TrRect r, void *arg) { TrRect argRect = reinterpret_cast<TrRect>(arg); return (rectCheckIntersect(r, argRect)) ? 1 : 0; } /*! * @brief Hit callback to scan full data * * @param hitOId Data on leaf * @param arg_ pointer to HitIntersectCallbackArg * * @return 1 if search continues, 0 if search finishes */ int32_t RtreeMap::hitAllCallback( TransactionContext &, TrRect, OId hitOId, void *arg_) { HitIntersectCallbackArg *arg = reinterpret_cast<HitIntersectCallbackArg *>(arg_); if (arg->limit <= arg->size && arg->size != UINT64_MAX) { return 0; } if (arg->size == UINT64_MAX) { arg->oneOId = hitOId; arg->size = 1; return 0; } else { arg->size++; arg->oidList->push_back(hitOId); return 1; } } /*! * @brief Hit callback to check intersection * * @param r Key-rect on leaf * @param hitOId Data on leaf * @param arg_ pointer to HitIntersectCallbackArg * * @return 1 if search continues, 0 if search finishes */ int32_t RtreeMap::hitIntersectCallback( TransactionContext &, TrRect r, OId hitOId, void *arg_) { HitIntersectCallbackArg *arg = reinterpret_cast<HitIntersectCallbackArg *>(arg_); if (arg->limit <= arg->size && arg->size != UINT64_MAX) { return 0; } if (rectCheckIntersect(arg->rect, r)) { if (arg->size == UINT64_MAX) { arg->oneOId = hitOId; arg->size = 1; return 0; } else { arg->size++; arg->oidList->push_back(hitOId); } } return 1; } /*! * @brief Hit callback to check inclusion * * @param r Key-rect on leaf * @param hitOId Data on leaf * @param arg_ Pointer to HitIncludeCallbackArg * * @return 1 if search continues, 0 if search finishes */ int32_t RtreeMap::hitIncludeCallback( TransactionContext &, TrRect r, OId hitOId, void *arg_) { HitIncludeCallbackArg *arg = reinterpret_cast<HitIncludeCallbackArg *>(arg_); if (arg->limit <= arg->size && arg->size != UINT64_MAX) { return 0; } if (rectCheckInclude(arg->rect, r)) { if (arg->size == UINT64_MAX) { arg->oneOId = hitOId; arg->size = 1; return 0; } else { arg->size++; arg->oidList->push_back(hitOId); } } return 1; } /*! * @brief Hit callback for differentiality * * @param r Key-rect on leaf * @param hitOId Data on leaf * @param arg_ Pointer to HitDifferntialCallbackArg * * @return 1 if search continues, 0 if search finishes */ int32_t RtreeMap::hitDifferentialCallback( TransactionContext &, TrRect r, OId hitOId, void *arg_) { HitDifferentialCallbackArg *arg = reinterpret_cast<HitDifferentialCallbackArg *>(arg_); if (arg->limit <= arg->size && arg->size != UINT64_MAX) { return 0; } if (rectCheckIntersect(arg->rect1, r) && !rectCheckIntersect(arg->rect2, r)) { arg->size++; arg->oidList->push_back(hitOId); } return 1; } /*! * @brief Hit callback to check qsf intersection * * @param r Key-rect on leaf * @param hitOId Data on leaf * @param arg_ pointer to HitQsfIntersectCallbackArg * * @return 1 if search continues, 0 if search finishes */ int32_t RtreeMap::hitQsfIntersectCallback( TransactionContext &, TrRect r, OId hitOId, void *arg_) { HitQsfIntersectCallbackArg *arg = reinterpret_cast<HitQsfIntersectCallbackArg *>(arg_); if (arg->limit <= arg->size && arg->size != UINT64_MAX) { return 0; } TrPv3Key *qkey = arg->pkey; TrPv3Box box; box.p0[0] = r->xmin; box.p0[1] = r->ymin; box.p0[2] = r->zmin; box.p1[0] = r->xmax - r->xmin; box.p1[1] = r->ymax - r->ymin; box.p1[2] = r->zmax - r->zmin; if (TrPv3Test2(&box, qkey)) { arg->size++; arg->oidList->push_back(hitOId); } return 1; } /*! * @brief Callback to compare OId * * @param r not used * @param oId op1 to compare * @param arg pointer to op2 */ int32_t RtreeMap::oIdCmpCallback( TransactionContext &, TrRect, OId oId, void *arg) { OId *p = reinterpret_cast<OId *>(arg); return static_cast<int32_t>(*p == oId); } bool geomOperation(TransactionContext& txn, uint8_t const* p, uint32_t size1, uint8_t const* q, uint32_t size2) { Geometry *geom = Geometry::deserialize(txn, p, size1); const RtreeMap::SearchContext::GeomeryCondition *geomCond = reinterpret_cast<const RtreeMap::SearchContext::GeomeryCondition *>(q); assert(geom != NULL); bool isMatch = true; switch (geomCond->relation_) { case GEOMETRY_INTERSECT: if (geom->isEmpty()) { isMatch = false; } else { const TrRectTag &a = geomCond->rect_[0]; const TrRectTag &b = geom->getBoundingRect(); isMatch = ((a.xmin <= b.xmax) && (b.xmin <= a.xmax) && ((a.ymin <= b.ymax) && (b.ymin <= a.ymax)) && (geom->getDimension() <= 2 || ((a.zmin <= b.zmax) && (b.zmin <= a.zmax)))); } break; case GEOMETRY_INCLUDE: if (geom->isEmpty()) { isMatch = false; } else { const TrRectTag &out = geomCond->rect_[0]; const TrRectTag &in = geom->getBoundingRect(); isMatch = (out.xmin <= in.xmin && out.xmax >= in.xmax && out.ymin <= in.ymin && out.ymax >= in.ymax && (geom->getDimension() <= 2 || (out.zmin <= in.zmin && out.zmax >= in.zmax))); } break; case GEOMETRY_DIFFERENTIAL: if (geom->isEmpty()) { isMatch = false; } else { const TrRectTag &a = geomCond->rect_[0]; const TrRectTag &a2 = geomCond->rect_[1]; const TrRectTag &b = geom->getBoundingRect(); bool conditionFlag1 = ((a.xmin <= b.xmax) && (b.xmin <= a.xmax) && ((a.ymin <= b.ymax) && (b.ymin <= a.ymax)) && (geom->getDimension() <= 2 || ((a.zmin <= b.zmax) && (b.zmin <= a.zmax)))); bool conditionFlag2 = ((a2.xmin <= b.xmax) && (b.xmin <= a2.xmax) && ((a2.ymin <= b.ymax) && (b.ymin <= a2.ymax)) && (geom->getDimension() <= 2 || ((a2.zmin <= b.zmax) && (b.zmin <= a2.zmax)))); isMatch = conditionFlag1 && !conditionFlag2; } break; case GEOMETRY_QSF_INTERSECT: if (geom->isEmpty()) { isMatch = false; } else { const TrRectTag r = geom->getBoundingRect(); TrPv3Box box; box.p0[0] = r.xmin; box.p0[1] = r.ymin; box.p0[2] = r.zmin; box.p1[0] = r.xmax - r.xmin; box.p1[1] = r.ymax - r.ymin; box.p1[2] = r.zmax - r.zmin; isMatch = (TrPv3Test2(&box, const_cast<TrPv3Key *>(&(geomCond->pkey_))) != 0); } break; default: GS_THROW_USER_ERROR(GS_ERROR_TQ_INTERNAL_GIS_UNKNOWN_RELATIONSHIP, "Invalid relationship of Geometry is specified."); } return isMatch; }
25.891652
80
0.683474
TRHackerTR33
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 <emiel.bruijntjes@copernica.com> * @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
3be96210604bdcd4513e686045d0d1134ba31721
10,714
cpp
C++
dev/Code/CryEngine/CryAction/VehicleSystem/VehicleSystem_FactoryRegistration.cpp
crazyskateface/lumberyard
164512f8d415d6bdf37e195af319ffe5f96a8f0b
[ "AML" ]
5
2018-08-17T21:05:55.000Z
2021-04-17T10:48:26.000Z
dev/Code/CryEngine/CryAction/VehicleSystem/VehicleSystem_FactoryRegistration.cpp
JulianoCristian/Lumberyard-3
dc523dd780f3cd1874251181b7cf6848b8db9959
[ "AML" ]
null
null
null
dev/Code/CryEngine/CryAction/VehicleSystem/VehicleSystem_FactoryRegistration.cpp
JulianoCristian/Lumberyard-3
dc523dd780f3cd1874251181b7cf6848b8db9959
[ "AML" ]
5
2017-12-05T16:36:00.000Z
2021-04-27T06:33:54.000Z
/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ // Original file Copyright Crytek GMBH or its affiliates, used under license. #include "StdAfx.h" #include "VehicleSystem.h" #include "Vehicle.h" #include "VehicleDamageBehaviorAISignal.h" #include "VehicleDamageBehaviorDestroy.h" #include "VehicleDamageBehaviorDetachPart.h" #include "VehicleDamageBehaviorEffect.h" #include "VehicleDamageBehaviorGroup.h" #include "VehicleDamageBehaviorHitPassenger.h" #include "VehicleDamageBehaviorImpulse.h" #include "VehicleDamageBehaviorMovementNotification.h" #include "VehicleDamageBehaviorSink.h" #include "VehicleDamageBehaviorSpawnDebris.h" #include "VehicleDamageBehaviorIndicator.h" #include "VehicleDamageBehaviorDisableSeatAction.h" #include "VehiclePartBase.h" #include "VehiclePartAnimated.h" #include "VehiclePartAnimatedJoint.h" #include "VehiclePartLight.h" #include "VehiclePartPulsingLight.h" #include "VehiclePartMassBox.h" #include "VehiclePartStatic.h" #include "VehiclePartSubPart.h" #include "VehiclePartSubPartWheel.h" #include "VehiclePartSuspensionPart.h" #include "VehiclePartTread.h" #include "VehiclePartAttachment.h" #include "VehiclePartEntity.h" #include "VehiclePartEntityDelayedDetach.h" #include "VehiclePartParticleEffect.h" #include "VehiclePartAnimatedChar.h" #include "VehiclePartWaterRipplesGenerator.h" #include "VehiclePartDetachedEntity.h" #include "VehicleSeatSerializer.h" #include "VehicleSeatActionLights.h" #include "VehicleSeatActionMovement.h" #include "VehicleSeatActionPassengerIK.h" #include "VehicleSeatActionRotateTurret.h" #include "VehicleSeatActionSound.h" #include "VehicleSeatActionSteeringWheel.h" #include "VehicleSeatActionWeapons.h" #include "VehicleSeatActionWeaponsBone.h" #include "VehicleSeatActionAnimation.h" #include "VehicleSeatActionPassiveAnimation.h" #include "VehicleSeatActionOrientatePartToView.h" #include "VehicleSeatActionOrientateBoneToView.h" #include "VehicleSeatActionRotateBone.h" #include "VehicleSeatActionShakeParts.h" #include "VehicleUsableActionEnter.h" #include "VehicleUsableActionFlip.h" #include "VehicleViewActionThirdPerson.h" #include "VehicleViewFirstPerson.h" #include "VehicleViewFirstPerson_Bone.h" #include "VehicleViewThirdPerson.h" #include "VehicleViewThirdPerson_Bone.h" #include "CryAction.h" //------------------------------------------------------------------------ void CVehicleSystem::RegisterVehicles(IGameFramework* gameFramework) { IEntityClassRegistry::SEntityClassDesc serializerClass; serializerClass.sName = "VehicleSeatSerializer"; serializerClass.sScriptFile = ""; serializerClass.flags = ECLF_INVISIBLE; static IGameFramework::CGameObjectExtensionCreator<CVehicleSeatSerializer> createVehicleSeatSerializer; CCryAction::GetCryAction()->GetIGameObjectSystem()->RegisterExtension(serializerClass.sName, &createVehicleSeatSerializer, &serializerClass); // register the detached part entity IEntityClassRegistry::SEntityClassDesc detachedPartClass; detachedPartClass.sName = "VehiclePartDetached"; detachedPartClass.sScriptFile = "Scripts/Entities/Vehicles/VehiclePartDetached.lua"; detachedPartClass.flags = ECLF_INVISIBLE; static IGameFramework::CGameObjectExtensionCreator<CVehiclePartDetachedEntity> createVehicleDetachedPartEntity; CCryAction::GetCryAction()->GetIGameObjectSystem()->RegisterExtension(detachedPartClass.sName, &createVehicleDetachedPartEntity, &detachedPartClass); // register all the vehicles ICryPak* pack = gEnv->pCryPak; _finddata_t fd; int res; intptr_t handle; std::set<string> setVehicles; string sExt(".xml"); string sPath("Scripts/Entities/Vehicles/Implementations/Xml/"); if ((handle = pack->FindFirst(sPath + string("*") + sExt, &fd)) != -1) { do { if (XmlNodeRef root = GetISystem()->LoadXmlFromFile(sPath + string(fd.name))) { const char* name = root->getAttr("name"); if (name[0]) { // Allow the name to contain relative path, but use only the name part as class name. string className(PathUtil::GetFile(name)); // register only once std::pair<std::set<string>::iterator, bool> result = setVehicles.insert(className); if (result.second) { IEntityClassRegistry::SEntityClassDesc vehicleClass; vehicleClass.sName = className.c_str(); char scriptName[1024] = {0}; const char* isOld = root->getAttr("isOld"); if (!strcmp("1", isOld)) { sprintf_s(scriptName, "Scripts/Entities/Vehicles/Old/VehiclePool.lua"); } else { sprintf_s(scriptName, "Scripts/Entities/Vehicles/VehiclePool.lua"); } bool show = true; if (root->getAttr("show", show)) { if (!show && VehicleCVars().v_show_all == 0) { vehicleClass.flags |= ECLF_INVISIBLE; } } vehicleClass.sScriptFile = scriptName; static IGameFramework::CGameObjectExtensionCreator<CVehicle> vehicleCreator; CCryAction::GetCryAction()->GetIGameObjectSystem()->RegisterExtension(name, &vehicleCreator, &vehicleClass); m_classes.insert(TVehicleClassMap::value_type(name, &vehicleCreator)); } else { CryLog("Vehicle <%s> already registered", name); } } else { CryLog("VehicleSystem: %s is missing 'name' attribute, skipping", fd.name); } } res = pack->FindNext(handle, &fd); } while (res >= 0); pack->FindClose(handle); } #define REGISTER_VEHICLEOBJECT(name, obj) \ REGISTER_FACTORY((IVehicleSystem*)this, name, obj, false); \ obj::m_objectId = this->AssignVehicleObjectId(name); // register other factories // vehicle views REGISTER_VEHICLEOBJECT("ActionThirdPerson", CVehicleViewActionThirdPerson); REGISTER_VEHICLEOBJECT("FirstPerson", CVehicleViewFirstPerson); REGISTER_VEHICLEOBJECT("FirstPersonBone", CVehicleViewFirstPerson_Bone); REGISTER_VEHICLEOBJECT("ThirdPerson", CVehicleViewThirdPerson); REGISTER_VEHICLEOBJECT("ThirdPersonBone", CVehicleViewThirdPersonBone); // vehicle parts REGISTER_VEHICLEOBJECT("Base", CVehiclePartBase); REGISTER_VEHICLEOBJECT("Animated", CVehiclePartAnimated); REGISTER_VEHICLEOBJECT("AnimatedJoint", CVehiclePartAnimatedJoint); REGISTER_VEHICLEOBJECT("SuspensionPart", CVehiclePartSuspensionPart); REGISTER_VEHICLEOBJECT("Light", CVehiclePartLight); REGISTER_VEHICLEOBJECT("PulsingLight", CVehiclePartPulsingLight); REGISTER_VEHICLEOBJECT("MassBox", CVehiclePartMassBox); REGISTER_VEHICLEOBJECT("Static", CVehiclePartStatic); REGISTER_VEHICLEOBJECT("SubPart", CVehiclePartSubPart); REGISTER_VEHICLEOBJECT("SubPartWheel", CVehiclePartSubPartWheel); REGISTER_VEHICLEOBJECT("Tread", CVehiclePartTread); REGISTER_VEHICLEOBJECT("EntityAttachment", CVehiclePartEntityAttachment); REGISTER_VEHICLEOBJECT("Entity", CVehiclePartEntity); REGISTER_VEHICLEOBJECT("EntityDelayedDetach", CVehiclePartEntityDelayedDetach); REGISTER_VEHICLEOBJECT("ParticleEffect", CVehiclePartParticleEffect); REGISTER_VEHICLEOBJECT("AnimatedChar", CVehiclePartAnimatedChar); REGISTER_VEHICLEOBJECT("WaterRipplesGenerator", CVehiclePartWaterRipplesGenerator); // vehicle damage behaviors REGISTER_VEHICLEOBJECT("AISignal", CVehicleDamageBehaviorAISignal); REGISTER_VEHICLEOBJECT("Destroy", CVehicleDamageBehaviorDestroy); REGISTER_VEHICLEOBJECT("DetachPart", CVehicleDamageBehaviorDetachPart); REGISTER_VEHICLEOBJECT("Effect", CVehicleDamageBehaviorEffect); REGISTER_VEHICLEOBJECT("Group", CVehicleDamageBehaviorGroup); REGISTER_VEHICLEOBJECT("HitPassenger", CVehicleDamageBehaviorHitPassenger); REGISTER_VEHICLEOBJECT("Impulse", CVehicleDamageBehaviorImpulse); REGISTER_VEHICLEOBJECT("Indicator", CVehicleDamageBehaviorIndicator); REGISTER_VEHICLEOBJECT("MovementNotification", CVehicleDamageBehaviorMovementNotification); REGISTER_VEHICLEOBJECT("Sink", CVehicleDamageBehaviorSink); REGISTER_VEHICLEOBJECT("SpawnDebris", CVehicleDamageBehaviorSpawnDebris); REGISTER_VEHICLEOBJECT("DisableSeatAction", CVehicleDamageBehaviorDisableSeatAction); // seat actions REGISTER_VEHICLEOBJECT("Lights", CVehicleSeatActionLights); REGISTER_VEHICLEOBJECT("Movement", CVehicleSeatActionMovement); REGISTER_VEHICLEOBJECT("PassengerIK", CVehicleSeatActionPassengerIK); REGISTER_VEHICLEOBJECT("RotateTurret", CVehicleSeatActionRotateTurret); REGISTER_VEHICLEOBJECT("Sound", CVehicleSeatActionSound); REGISTER_VEHICLEOBJECT("SteeringWheel", CVehicleSeatActionSteeringWheel); REGISTER_VEHICLEOBJECT("Weapons", CVehicleSeatActionWeapons); REGISTER_VEHICLEOBJECT("WeaponsBone", CVehicleSeatActionWeaponsBone); REGISTER_VEHICLEOBJECT("Animation", CVehicleSeatActionAnimation); REGISTER_VEHICLEOBJECT("PassiveAnimation", CVehicleSeatActionPassiveAnimation); REGISTER_VEHICLEOBJECT("OrientatePartToView", CVehicleSeatActionOrientatePartToView); REGISTER_VEHICLEOBJECT("OrientateBoneToView", CVehicleSeatActionOrientateBoneToView); REGISTER_VEHICLEOBJECT("RotateBone", CVehicleSeatActionRotateBone); REGISTER_VEHICLEOBJECT("ShakeParts", CVehicleSeatActionShakeParts); // actions REGISTER_FACTORY((IVehicleSystem*)this, "Enter", CVehicleUsableActionEnter, false); REGISTER_FACTORY((IVehicleSystem*)this, "Flip", CVehicleUsableActionFlip, false); }
44.090535
153
0.714206
crazyskateface
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
3bf1b6cd246e2d80bb472d100b1e0f7e936a9eac
1,061
cpp
C++
deps/src/boost_1_65_1/libs/fusion/test/algorithm/move.cpp
shreyasvj25/turicreate
32e84ca16aef8d04aff3d49ae9984bd49326bffd
[ "BSD-3-Clause" ]
1
2018-12-15T20:03:51.000Z
2018-12-15T20:03:51.000Z
deps/src/boost_1_65_1/libs/fusion/test/algorithm/move.cpp
shreyasvj25/turicreate
32e84ca16aef8d04aff3d49ae9984bd49326bffd
[ "BSD-3-Clause" ]
3
2021-09-08T02:18:00.000Z
2022-03-12T00:39:44.000Z
deps/src/boost_1_65_1/libs/fusion/test/algorithm/move.cpp
shreyasvj25/turicreate
32e84ca16aef8d04aff3d49ae9984bd49326bffd
[ "BSD-3-Clause" ]
1
2019-06-01T18:49:28.000Z
2019-06-01T18:49:28.000Z
/*============================================================================= Copyright (c) 2014 Kohei Takahashi 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 <boost/config.hpp> #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #include <boost/core/lightweight_test.hpp> #include <boost/fusion/container/vector/vector.hpp> #include <boost/fusion/container/list/list.hpp> #include <boost/fusion/sequence/comparison.hpp> #include <boost/fusion/algorithm/auxiliary/move.hpp> #include <utility> int main() { { boost::fusion::vector<int, short, double> v(1, 2, 3); boost::fusion::list<int, short, double> l1 = v; boost::fusion::list<int, short, double> l2; boost::fusion::move(std::move(v), l2); BOOST_TEST(l1 == l2); } return boost::report_errors(); } #else int main() { // no thing to do } #endif
26.525
80
0.578699
shreyasvj25
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
3bf534e29fd50209aca0ab5f8fe8bc3491cf980a
11,297
cpp
C++
04_Sample/AngryNinjas/Source/TheStack.cpp
mcodegeeks/OpenKODE-Framework
d4382d781da7f488a0e7667362a89e8e389468dd
[ "MIT" ]
2
2017-08-03T07:15:00.000Z
2018-06-18T10:32:53.000Z
04_Sample/AngryNinjas/Source/TheStack.cpp
mcodegeeks/OpenKODE-Framework
d4382d781da7f488a0e7667362a89e8e389468dd
[ "MIT" ]
null
null
null
04_Sample/AngryNinjas/Source/TheStack.cpp
mcodegeeks/OpenKODE-Framework
d4382d781da7f488a0e7667362a89e8e389468dd
[ "MIT" ]
2
2019-03-04T22:57:42.000Z
2020-03-06T01:32:26.000Z
/* -------------------------------------------------------------------------- * * File TheStack.cpp * * Ported By Young-Hwan Mun * Contact xmsoft77@gmail.com * * -------------------------------------------------------------------------- * * Copyright (c) 2010-2013 XMSoft. * Copyright (c) CartoonSmart LLC. All rights reserved. * * -------------------------------------------------------------------------- * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library in the file COPYING.LIB; * if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * * -------------------------------------------------------------------------- */ #include "Precompiled.h" #include "TheStack.h" #include "TheLevel.h" #include "GameData.h" #include "StackObject.h" #include "Enemy.h" TheStack* TheStack::create ( b2World* pWorld ) { TheStack* pRet = new TheStack ( ); if ( pRet && pRet->initStackWithWorld ( pWorld ) ) { pRet->autorelease ( ); } else { CC_SAFE_DELETE ( pRet ); } return pRet; } KDbool TheStack::initStackWithWorld ( b2World* pWorld ) { if ( !CCNode::init ( ) ) { return KD_FALSE; } m_pWorld = pWorld; if ( TheLevel::sharedLevel ( )->IS_IPAD ) { m_nStackLocationX = 1400; // base X starting point for the entire stack on the iPhone (make further tweaks using the stackAdjustmentX var in the buildLevel function per level m_nStackLocationY = 100; // base Y starting point for the entire stack on the iPhone (make further tweaks using the stackAdjustmentY var in the buildLevel function per level } else { m_nStackLocationX = 900; // base X starting point for the entire stack on the iPhone (make further tweaks using the stackAdjustmentX var in the buildLevel function per level m_nStackLocationY = 35; // base Y starting point for the entire stack on the iPhone (make further tweaks using the stackAdjustmentY var in the buildLevel function per level } m_nCurrentLevel = GameData::sharedData ( )->getLevel ( ); if ( m_nCurrentLevel % 2 == 0 ) { this->buildLevel2 ( ); } else { this->buildLevel1 ( ); } return KD_TRUE; } KDvoid TheStack::buildLevel1 ( KDvoid ) { if ( TheLevel::sharedLevel ( )->IS_IPAD ) { m_nStackAdjustmentX = -350; // if you want to further adjust the stack's starting X location then change this value (iphone) m_nStackLocationX = m_nStackLocationX - m_nStackAdjustmentX; m_nStackAdjustmentY = 0; // if you want to further adjust the stack's starting X location then change this value (iphone) m_nStackLocationY = m_nStackLocationY - m_nStackAdjustmentY; } else { m_nStackAdjustmentX = -100; // if you want to further adjust the stack's starting X location then change this value (iphone) m_nStackLocationX = m_nStackLocationX - m_nStackAdjustmentX; m_nStackAdjustmentY = 0; // if you want to further adjust the stack's starting X location then change this value (iphone) m_nStackLocationY = m_nStackLocationY - m_nStackAdjustmentY; } this->addChild ( StackObject::create ( m_pWorld, ccp ( 0 + m_nStackLocationX, 65 + m_nStackLocationY ), "woodShape1" , KD_FALSE, KD_TRUE, KD_TRUE , KD_FALSE, 0.25f, ShapeOfSourceImage , 90, KD_FALSE, 100, SmokePuffs ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 95 + m_nStackLocationX, 65 + m_nStackLocationY ), "woodShape1" , KD_FALSE, KD_TRUE, KD_TRUE , KD_FALSE, 0.25f, ShapeOfSourceImage , 90, KD_FALSE, 100, SmokePuffs ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 47 + m_nStackLocationX, 145 + m_nStackLocationY ), "woodShape1" , KD_FALSE, KD_TRUE, KD_TRUE , KD_FALSE, 0.25f, ShapeOfSourceImage , 0, KD_FALSE, 100, Explosion ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 0 + m_nStackLocationX, 225 + m_nStackLocationY ), "woodShape1" , KD_FALSE, KD_TRUE, KD_TRUE , KD_FALSE, 0.25f, ShapeOfSourceImage , 90, KD_FALSE, 100, Explosion ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 95 + m_nStackLocationX, 225 + m_nStackLocationY ), "woodShape1" , KD_FALSE, KD_TRUE, KD_TRUE , KD_FALSE, 0.25f, ShapeOfSourceImage , 90, KD_FALSE, 100, Explosion ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 50 + m_nStackLocationX, 305 + m_nStackLocationY ), "woodShape1" , KD_FALSE, KD_TRUE, KD_TRUE , KD_FALSE, 0.25f, ShapeOfSourceImage , 0, KD_FALSE, 100, SmokePuffs ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 0 + m_nStackLocationX, 345 + m_nStackLocationY ), "triangleMedium" , KD_FALSE, KD_TRUE, KD_FALSE, KD_TRUE , 0.25f, Triangle , 0, KD_FALSE, 100, SmokePuffs ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 95 + m_nStackLocationX, 345 + m_nStackLocationY ), "triangleMedium" , KD_FALSE, KD_TRUE, KD_FALSE, KD_TRUE , 0.25f, Triangle , 0, KD_FALSE, 100, Explosion ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 50 + m_nStackLocationX, 350 + m_nStackLocationY ), "triangleLarge" , KD_FALSE, KD_TRUE, KD_FALSE, KD_TRUE , 0.25f, Triangle , 180, KD_FALSE, 500, SmokePuffs ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 25 + m_nStackLocationX, 394 + m_nStackLocationY ), "triangleSmall" , KD_FALSE, KD_TRUE, KD_FALSE, KD_FALSE, 0.25f, Triangle , 0, KD_FALSE, 100, Explosion ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 75 + m_nStackLocationX, 394 + m_nStackLocationY ), "triangleSmall" , KD_FALSE, KD_TRUE, KD_FALSE, KD_FALSE, 0.25f, Triangle , 0, KD_FALSE, 100, SmokePuffs ), DepthStack ); this->addChild ( Enemy ::create ( m_pWorld, ccp ( 45 + m_nStackLocationX, 200 + m_nStackLocationY ), "mutantPepper" , KD_TRUE , KD_TRUE, KD_TRUE , 1, KD_TRUE, 10, 1.0f, ShapeOfSourceImageButSlightlySmaller, 10000, SmokePuffs ), DepthStack ); } KDvoid TheStack::buildLevel2 ( KDvoid ) { if ( TheLevel::sharedLevel ( )->IS_IPAD ) { m_nStackAdjustmentX = 0; // if you want to further adjust the stack's starting X location then change this value (iphone) m_nStackLocationX = m_nStackLocationX - m_nStackAdjustmentX; m_nStackAdjustmentY = 0; // if you want to further adjust the stack's starting X location then change this value (iphone) m_nStackLocationY = m_nStackLocationY - m_nStackAdjustmentY; } else { m_nStackAdjustmentX = -100; // if you want to further adjust the stack's starting X location then change this value (iphone) m_nStackLocationX = m_nStackLocationX - m_nStackAdjustmentX; m_nStackAdjustmentY = 0; // if you want to further adjust the stack's starting X location then change this value (iphone) m_nStackLocationY = m_nStackLocationY - m_nStackAdjustmentY; } // marble this->addChild ( StackObject::create ( m_pWorld, ccp ( 40 + m_nStackLocationX, 40 + m_nStackLocationY ), "marbleSquare" , KD_FALSE, KD_FALSE, KD_FALSE, KD_FALSE, 0.25f, ShapeOfSourceImage , 90, KD_TRUE , 0, None ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 190 + m_nStackLocationX, 40 + m_nStackLocationY ), "marbleSquare" , KD_FALSE, KD_FALSE, KD_FALSE, KD_FALSE, 0.25f, ShapeOfSourceImage , 90, KD_TRUE , 0, None ), DepthStack ); // stone pillars this->addChild ( StackObject::create ( m_pWorld, ccp ( 9 + m_nStackLocationX, 125 + m_nStackLocationY ), "stonePillar" , KD_FALSE, KD_FALSE, KD_FALSE, KD_FALSE, 0.25f, ShapeOfSourceImage , 90, KD_TRUE, 0, None ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 27 + m_nStackLocationX, 220 + m_nStackLocationY ), "stonePillar" , KD_FALSE, KD_FALSE, KD_FALSE, KD_FALSE, 0.25f, ShapeOfSourceImage , 90, KD_TRUE, 0, None ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 45 + m_nStackLocationX, 210 + m_nStackLocationY ), "woodShape4" , KD_FALSE, KD_TRUE , KD_FALSE, KD_TRUE , 0.25f, ShapeOfSourceImage , 90, KD_TRUE, 100, Explosion ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 95 + m_nStackLocationX, 210 + m_nStackLocationY ), "woodShape4" , KD_FALSE, KD_TRUE , KD_FALSE, KD_TRUE , 0.25f, ShapeOfSourceImage , 90, KD_TRUE, 100, Explosion ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 145 + m_nStackLocationX, 210 + m_nStackLocationY ), "woodShape4" , KD_FALSE, KD_TRUE , KD_FALSE, KD_TRUE , 0.25f, ShapeOfSourceImage , 90, KD_TRUE, 100, Explosion ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 200 + m_nStackLocationX, 210 + m_nStackLocationY ), "woodShape4" , KD_FALSE, KD_TRUE , KD_FALSE, KD_TRUE , 0.25f, ShapeOfSourceImage , 90, KD_TRUE, 100, Explosion ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 80 + m_nStackLocationX, 250 + m_nStackLocationY ), "stonePillar" , KD_FALSE, KD_FALSE, KD_FALSE, KD_TRUE , 0.5f , ShapeOfSourceImage , 90, KD_TRUE, 0, None ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 180 + m_nStackLocationX, 250 + m_nStackLocationY ), "stonePillar" , KD_FALSE, KD_FALSE, KD_FALSE, KD_TRUE , 0.5f , ShapeOfSourceImage , 90, KD_TRUE, 0, None ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 95 + m_nStackLocationX, 285 + m_nStackLocationY ), "triangleMedium" , KD_FALSE, KD_TRUE , KD_FALSE, KD_TRUE , 0.25f, Triangle , 0, KD_TRUE, 100, Explosion ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 181 + m_nStackLocationX, 285 + m_nStackLocationY ), "triangleMedium" , KD_FALSE, KD_TRUE , KD_FALSE, KD_TRUE , 0.25f, Triangle , 0, KD_TRUE, 100, Explosion ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 138 + m_nStackLocationX, 280 + m_nStackLocationY ), "triangleSmall" , KD_FALSE, KD_TRUE , KD_FALSE, KD_TRUE , 0.25f, Triangle , 180, KD_TRUE, 500, Explosion ), DepthStack ); this->addChild ( StackObject::create ( m_pWorld, ccp ( 127 + m_nStackLocationX, 340 + m_nStackLocationY ), "stonePillar" , KD_FALSE, KD_FALSE, KD_FALSE, KD_TRUE , 0.5f , ShapeOfSourceImage , 0, KD_TRUE, 0, None ), DepthStack ); this->addChild ( Enemy ::create ( m_pWorld, ccp ( 118 + m_nStackLocationX, 45 + m_nStackLocationY ), "mutantPepper" , KD_TRUE , KD_FALSE, KD_TRUE , 3, KD_TRUE, 10, 1.0f, ShapeOfSourceImage , 10000, SmokePuffs ), DepthStack ); this->addChild ( Enemy ::create ( m_pWorld, ccp ( 185 + m_nStackLocationX, 120 + m_nStackLocationY ), "mutantPepper" , KD_FALSE, KD_TRUE , KD_TRUE , 3, KD_TRUE, 10, 1.0f, ShapeOfSourceImageButSlightlySmaller, 10000, SmokePuffs ), DepthStack ); }
67.646707
246
0.691423
mcodegeeks
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
0ec5f425a03ff57144517d93804227ac7851adca
5,563
cpp
C++
primesynth/src/midi_input.cpp
mosmeh/primesynth
dc5abf85ea19e7b29af547bdbeeaf8a05c242cd0
[ "MIT" ]
2
2020-03-09T08:45:07.000Z
2021-07-13T06:09:09.000Z
primesynth/src/midi_input.cpp
mosmeh/primasynth
dc5abf85ea19e7b29af547bdbeeaf8a05c242cd0
[ "MIT" ]
null
null
null
primesynth/src/midi_input.cpp
mosmeh/primasynth
dc5abf85ea19e7b29af547bdbeeaf8a05c242cd0
[ "MIT" ]
2
2018-12-28T19:48:26.000Z
2021-07-13T06:09:11.000Z
#include "midi_input.h" #include <iomanip> #include <iostream> #include <sstream> namespace primesynth { void checkMMResult(MMRESULT result) { if (result != MMSYSERR_NOERROR) { char msg[MAXERRORLENGTH]; midiInGetErrorTextA(result, msg, sizeof(msg)); std::ostringstream ss; ss << "MIDI: " << msg; throw std::runtime_error(ss.str()); } } void CALLBACK MidiInProc(HMIDIIN, UINT wMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD) { const auto sp = reinterpret_cast<MIDIInput::SharedParam*>(dwInstance); if (!sp->running) { return; } switch (wMsg) { case MIM_DATA: sp->synth.processShortMessage(static_cast<std::uint32_t>(dwParam1)); break; case MIM_LONGDATA: { const auto mh = reinterpret_cast<LPMIDIHDR>(dwParam1); sp->synth.processSysEx(mh->lpData, mh->dwBytesRecorded); // See "MidiInProc callback function" (https://msdn.microsoft.com/en-us/library/dd798460.aspx) // "Applications should not call any multimedia functions from inside the callback function, as doing so can // cause a deadlock" std::unique_lock<std::mutex> uniqueLock(sp->mutex); sp->addingBufferRequested = true; sp->cv.notify_one(); break; } } } void CALLBACK verboseMidiInProc(HMIDIIN hmi, UINT wMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD dwParam2) { const auto sp = reinterpret_cast<MIDIInput::SharedParam*>(dwInstance); if (!sp->running) { return; } switch (wMsg) { case MIM_DATA: { const auto param = static_cast<std::uint32_t>(dwParam1); const auto msg = reinterpret_cast<const std::uint8_t*>(&param); const auto status = static_cast<midi::MessageStatus>(msg[0] & 0xf0); const auto channel = msg[0] & 0xf; switch (status) { case midi::MessageStatus::NoteOff: std::cout << "Note off: channel=" << channel << " key=" << static_cast<int>(msg[1]) << std::endl; break; case midi::MessageStatus::NoteOn: std::cout << "Note on: channel=" << channel << " key=" << static_cast<int>(msg[1]) << " velocity=" << static_cast<int>(msg[2]) << std::endl; break; case midi::MessageStatus::KeyPressure: std::cout << "Key pressure: channel=" << channel << " key=" << static_cast<int>(msg[1]) << " value=" << static_cast<int>(msg[2]) << std::endl; break; case midi::MessageStatus::ControlChange: std::cout << "Control change: channel=" << channel << " controller=" << static_cast<int>(msg[1]) << " value=" << static_cast<int>(msg[2]) << std::endl; break; case midi::MessageStatus::ProgramChange: std::cout << "Program change: channel=" << channel << " program=" << static_cast<int>(msg[1]) << std::endl; break; case midi::MessageStatus::ChannelPressure: std::cout << "Channel pressure: channel=" << channel << " value=" << static_cast<int>(msg[1]) << std::endl; break; case midi::MessageStatus::PitchBend: std::cout << "Pitch bend: channel=" << channel << " value=" << midi::joinBytes(msg[2], msg[1]) << std::endl; break; } break; } case MIM_LONGDATA: { const auto mh = reinterpret_cast<LPMIDIHDR>(dwParam1); std::cout << "SysEx: "; const auto flags(std::cout.flags()); for (DWORD i = 0; i < mh->dwBytesRecorded; ++i) { std::cout << std::hex << std::setfill('0') << std::setw(2) << static_cast<int>(static_cast<unsigned char>(mh->lpData[i])) << " "; } std::cout.flags(flags); std::cout << std::endl; break; } } MidiInProc(hmi, wMsg, dwInstance, dwParam1, dwParam2); } MIDIInput::MIDIInput(Synthesizer& synth, UINT deviceID, bool verbose) : sysExBuffer_(512), mh_(), sharedParam_{synth, true, false} { MIDIINCAPS caps; checkMMResult(midiInGetDevCaps(deviceID, &caps, sizeof(caps))); std::wcout << "MIDI: opening " << caps.szPname << std::endl; checkMMResult(midiInOpen(&hmi_, deviceID, reinterpret_cast<DWORD_PTR>(verbose ? verboseMidiInProc : MidiInProc), reinterpret_cast<DWORD_PTR>(&sharedParam_), CALLBACK_FUNCTION)); mh_.lpData = sysExBuffer_.data(); mh_.dwBufferLength = static_cast<DWORD>(sysExBuffer_.size()); checkMMResult(midiInPrepareHeader(hmi_, &mh_, sizeof(mh_))); checkMMResult(midiInAddBuffer(hmi_, &mh_, sizeof(mh_))); bufferAddingThread_ = std::thread([&, &sp = sharedParam_ ] { while (true) { std::unique_lock<std::mutex> uniqueLock(sp.mutex); sp.cv.wait(uniqueLock, [&] { return sp.addingBufferRequested || !sp.running; }); if (sp.running) { checkMMResult(midiInAddBuffer(hmi_, &mh_, sizeof(mh_))); sp.addingBufferRequested = false; } else { break; } } }); checkMMResult(midiInStart(hmi_)); } MIDIInput::~MIDIInput() { sharedParam_.running = false; sharedParam_.cv.notify_all(); if (bufferAddingThread_.joinable()) { bufferAddingThread_.join(); } if (hmi_) { checkMMResult(midiInStop(hmi_)); checkMMResult(midiInReset(hmi_)); checkMMResult(midiInUnprepareHeader(hmi_, &mh_, sizeof(mh_))); checkMMResult(midiInClose(hmi_)); } } }
38.365517
120
0.594463
mosmeh
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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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, &params); 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
0ed2100907a3b11d91e9cf80903845a7a1bc1b31
4,012
cpp
C++
Cross Wars vs Onslaught/MissionScreen.cpp
GigaNova/CrossWars
62d22f1f45e28f4c4dbd7d37e2f760b223c1c988
[ "MIT" ]
2
2019-06-06T09:37:12.000Z
2019-07-23T15:04:07.000Z
Cross Wars vs Onslaught/MissionScreen.cpp
GigaNova/CrossWars
62d22f1f45e28f4c4dbd7d37e2f760b223c1c988
[ "MIT" ]
null
null
null
Cross Wars vs Onslaught/MissionScreen.cpp
GigaNova/CrossWars
62d22f1f45e28f4c4dbd7d37e2f760b223c1c988
[ "MIT" ]
null
null
null
#include "MissionScreen.h" #include "TextureManager.h" #include "Camera.h" #include "PlayerManager.h" #include "ResourceManager.h" #include "TextSanitizer.h" #include "MusicPlayer.h" #include "StateMachine.h" #include "Chapter.h" MissionScreen::MissionScreen(sf::RenderWindow* _pRenderWindow) : GameScreen(_pRenderWindow) { Background = std::make_shared<sf::Sprite>(*TextureManager::GetInstance()->LoadTexture("mission.png", Folders::MENU)); sf::Texture* ContainerTexture = TextureManager::GetInstance()->LoadTexture("missionContainer.png", Folders::MENU); pInactiveContainerSprite = new sf::Sprite(*ContainerTexture, sf::IntRect(0, 0, 494, 72)); pActiveContainerSprite = new sf::Sprite(*ContainerTexture, sf::IntRect(0, 72, 494, 72)); pCamera = new Camera(sf::FloatRect(0, 0, 512, 512)); pCamera->setViewport(sf::FloatRect(0, 0, 1, 1)); } MissionScreen::~MissionScreen() { } void MissionScreen::Start() { std::vector<PreloadChapter> Missions = PlayerManager::GetInstance()->GetAvailableMissions(); int y = 90; int i = 0; for(PreloadChapter Mission : Missions) { MissionContainer* Container = new MissionContainer; Container->ActiveContainerSprite = std::make_shared<sf::Sprite>(*pActiveContainerSprite); Container->ActiveContainerSprite->setPosition(9, y); Container->InactiveContainerSprite = std::make_shared<sf::Sprite>(*pInactiveContainerSprite); Container->InactiveContainerSprite->setPosition(9, y); Container->MissionName = std::make_shared<sf::Text>(); Container->MissionName->setFont(*ResourceManager::GetInstance()->GetAceFont()); Container->MissionName->setCharacterSize(16); Container->MissionName->setString(Mission.Name); TextSanitizer::CenterOrigin(Container->MissionName.get()); Container->MissionName->setPosition(256, y + 51); Container->ID = Mission.ID; Container->UnitLimit = Mission.UnitLimit; if(i == 0) { Container->Selected = true; } else { Container->Selected = false; } AvailableMissions.Insert(Container); y += 72; ++i; } } void MissionScreen::Draw() { pCamera->DrawUpdate(); pWindow->draw(*Background); for(MissionContainer* Container : AvailableMissions.GetInnerVector()) { if(Container->Selected) { pWindow->draw(*Container->ActiveContainerSprite); } else { pWindow->draw(*Container->InactiveContainerSprite); } pWindow->draw(*Container->MissionName); } } void MissionScreen::Unload() { } void MissionScreen::PollInput() { sf::Event event; while (pWindow->pollEvent(event)) { if (event.type == sf::Event::Closed) { CloseGame = true; } else if (event.type == sf::Event::KeyPressed) { if (event.key.code == sf::Keyboard::Up) { AvailableMissions.Front()->Selected = false; AvailableMissions.BackToFront(); AvailableMissions.Front()->Selected = true; SoundPlayer::GetInstance()->PlaySoundFromBuffer(SoundPlayer::GetInstance()->CursorSound, false); } else if (event.key.code == sf::Keyboard::Down) { AvailableMissions.Front()->Selected = false; AvailableMissions.FrontToBack(); AvailableMissions.Front()->Selected = true; SoundPlayer::GetInstance()->PlaySoundFromBuffer(SoundPlayer::GetInstance()->CursorSound, false); } else if (event.key.code == sf::Keyboard::Z) { SoundPlayer::GetInstance()->PlaySoundFromBuffer(SoundPlayer::GetInstance()->SelectSound, false); //StateMachine::GetInstance()->LoadChapter(LuaManager::GetInstance()->LoadChapter(AvailableMissions.Front()->ID)); ScreenManager::GetInstance()->GetBarracksScreen()->SetChapter(AvailableMissions.Front()->ID, AvailableMissions.Front()->MissionName->getString(), AvailableMissions.Front()->UnitLimit); AvailableMissions.Clear(); ScreenManager::GetInstance()->CloseScreen(); } else if (event.key.code == sf::Keyboard::X) { SoundPlayer::GetInstance()->PlaySoundFromBuffer(SoundPlayer::GetInstance()->CancelSound, false); AvailableMissions.Clear(); ScreenManager::GetInstance()->CloseScreen(); } } } }
29.5
188
0.718345
GigaNova
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
0ed572bf71f1e188c7fe575fba9ecb97641be576
747
cpp
C++
modules/core/PrimDummy.cpp
skn123/OpenRT
43c91db73e688ccd08396e1a6f68517ab702e636
[ "BSD-3-Clause" ]
null
null
null
modules/core/PrimDummy.cpp
skn123/OpenRT
43c91db73e688ccd08396e1a6f68517ab702e636
[ "BSD-3-Clause" ]
null
null
null
modules/core/PrimDummy.cpp
skn123/OpenRT
43c91db73e688ccd08396e1a6f68517ab702e636
[ "BSD-3-Clause" ]
null
null
null
#include "PrimDummy.h" #include <macroses.h> namespace rt { bool CPrimDummy::intersect(Ray &) const { RT_ASSERT_MSG(false, "This method should never be called. Aborting..."); } bool CPrimDummy::if_intersect(const Ray &) const { RT_ASSERT_MSG(false, "This method should never be called. Aborting..."); } void CPrimDummy::transform(const Mat &T) { RT_ASSERT_MSG(false, "This method should never be called. Aborting..."); } Vec3f CPrimDummy::getOrigin() const { RT_ASSERT_MSG(false, "This method should never be called. Aborting..."); } CBoundingBox CPrimDummy::getBoundingBox() const { RT_ASSERT_MSG(false, "This method should never be called. Aborting..."); } };
29.88
80
0.657296
skn123
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 (loucocito@gmail.com) // // 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
0edb876601997731980bc01bd467e9dde384da03
580
cpp
C++
2020/object-oriented-technology-and-methods/exp-4/custom_angle.cpp
Overloadlightning/BIT
de85cb74523d63b22b0118c26c65f854b7d2df86
[ "MIT" ]
6
2021-10-30T06:07:42.000Z
2022-03-02T15:24:57.000Z
2020/object-oriented-technology-and-methods/exp-4/custom_angle.cpp
Overloadlightning/BIT
de85cb74523d63b22b0118c26c65f854b7d2df86
[ "MIT" ]
null
null
null
2020/object-oriented-technology-and-methods/exp-4/custom_angle.cpp
Overloadlightning/BIT
de85cb74523d63b22b0118c26c65f854b7d2df86
[ "MIT" ]
1
2022-02-21T15:37:49.000Z
2022-02-21T15:37:49.000Z
#include "custom_angle.h" CustomAngle::CustomAngle() { this->degree = 0; } CustomAngle::CustomAngle(double degree_) : degree(degree_) { } CustomAngle::CustomAngle(CustomAngle &custom_angle) { this->degree = custom_angle.get_degree(); } double CustomAngle::get_degree() { return this->degree; } void CustomAngle::set_degree(double degree_) { this->degree = degree_; } double CustomAngle::GetSin() { return sin(this->degree); } double CustomAngle::GetCos() { return cos(this->degree); } double CustomAngle::GetTan() { return tan(this->degree); }
17.575758
60
0.693103
Overloadlightning
0edc4dcd41eac9d0feb653ad2ec3510d10a27c0b
5,672
cpp
C++
PIN.Branch.Monitor/Windows/PIN.Branch.Monitor.cpp
y11en/BranchMonitoringProject
5d3ca533338da919a1757562f3810d49296ebf48
[ "MIT" ]
122
2017-03-08T00:45:03.000Z
2022-03-01T03:05:21.000Z
PIN.Branch.Monitor/Windows/PIN.Branch.Monitor.cpp
y11en/BranchMonitoringProject
5d3ca533338da919a1757562f3810d49296ebf48
[ "MIT" ]
3
2017-03-08T01:16:54.000Z
2017-03-22T22:59:26.000Z
PIN.Branch.Monitor/Windows/PIN.Branch.Monitor.cpp
y11en/BranchMonitoringProject
5d3ca533338da919a1757562f3810d49296ebf48
[ "MIT" ]
42
2017-03-08T21:28:48.000Z
2022-02-20T15:24:46.000Z
/* Branch Monitoring Project * Marcus Botacin - UNICAMP - 2017 * PIN implementation of Branch Monitor * Used for simple comparisons and validation purposes * Inspired on PIN example: instcount0.cpp */ /* Include Block */ #include <iostream> #include <fstream> #include <sstream> #include <string> #include "pin.H" /* Output file */ ofstream OutFile; /* Last Branch Address Record */ void* last=0; /* Print Direct Branches * Direct Branches -> we can retrieve target address without indirect calculation * Just print Source and Target addresses and branch instruction disasm */ VOID print_direct_branch(VOID *Source, string * Target, string * instr) { OutFile << "From: " << Source << " To: "<< *Target << " Disasm of 1 instr: " << *instr << endl; } /* Print Indirect Branches * Can't calculate target address without additional effort * Return target could be calculated by using a Call Stack * Mostly used for RET instructions * Print Source and instr disasm without target address */ VOID print_indirect_branch(VOID *Source, string * str) { OutFile << "From: " << Source << " Disasm of 1 instr: " << *str << endl; } /* string_to_number * Convert string* to a pointer * Aux. function */ void* string_to_number(string * s) { return reinterpret_cast<void*>(_strtoul_l(s->c_str(),NULL,0,0)); } /* Given a buffer of instruction bytes, print them properly * byte buffer: values * number of bytes: n */ # define BYTEMASK 0xFF /* Mask to capture only one byte */ # define STARTING_VALUES 0 /* initial block and bytes */ # define NEXT_BYTE 8 /* bit shift */ VOID PrintBytes(ADDRINT *values, size_t n) { size_t i=STARTING_VALUES; /* number of printed bytes */ int block=STARTING_VALUES; /* byte block index -- each 8 bytes are stored on a single ADDRINT block entry */ /* fist byte block */ UINT64 byte = values[block]; /* each one of 8 bytes on a given block */ int inner_byte = STARTING_VALUES; /* byte to be printed */ UINT64 pbyte; pbyte = byte & BYTEMASK; OutFile << "0x"<<hex<<pbyte; byte = byte >> NEXT_BYTE; inner_byte++; i++; while(i<n) { if(inner_byte<8) { pbyte = byte & BYTEMASK; OutFile << " 0x"<<hex<<pbyte; byte = byte >> NEXT_BYTE; inner_byte++; i++; }else { inner_byte=STARTING_VALUES; block++; byte = values[block]; } } OutFile<<endl; } /* Disasm instruction block * starting at last address * until the current addr */ #define MAXIMUM_BYTES 0x30 #define MINIMUM_BYTES 0 VOID Disasm(void *last, void *current) { /* Block size calculation */ UINT64 bytes = (UINT64)current - (UINT64)last; size_t n; /* Disasm only small blocks/gadgets */ if(bytes > MINIMUM_BYTES && bytes < MAXIMUM_BYTES) { OutFile << "Disasm of 0x" << bytes << " bytes from " << last << ": "; /* Read memory to retrieve executed code (instruction bytes) */ ADDRINT values[MAXIMUM_BYTES]; /* if successfully read */ if((n=PIN_SafeCopy(&values, last, bytes))>0) { /* print instruction bytes */ PrintBytes(values,n); }else{ /* Otherwise, just print error message */ OutFile << "Disasm error" << endl; } } } /* handle direct branches * perform disasm + print */ VOID handle_direct_branch(VOID *Source, string * Target, string * instr) { void* current; current = Source; /* print branch information */ print_direct_branch(Source, Target, instr); /* Disasm previously executed block * starting on the previous ''last'' address * until the ''current'' address */ Disasm(last,current); /* set the new ''last'' branch */ last = string_to_number(Target); } /* Split string * Aux. function * Split into whitespace * Expected input: Instr' 'address * Expected Output: Instr on instr, address on addr string */ VOID split(string dis, string * instr, string * addr) { /* making string to be a stream */ istringstream iss(dis); string sub; /* Get instr */ iss >> sub; *instr = sub; /* Get address */ iss >> sub; *addr = sub; } /* Instrumentation function */ VOID Instruction(INS ins, VOID *v) { /* Only branch instructions, since we are emulating the branch monitor */ if(INS_IsBranchOrCall(ins)) { /* Direct Branch */ if(INS_IsDirectBranchOrCall(ins)) { /* I don't want to handle all branch types to get PIN parameters * PIN could provide branch target through IARGS * I opt for disasming the branch instruction and retrieving the address from the string */ /* Branch instruction disasm */ string dis = INS_Disassemble(ins); /* Spliting string into Instruction+Address */ string instr,addr; split(dis,&instr,&addr); /* Call handle_branch function with the proper parameters */ INS_InsertCall(ins, IPOINT_BEFORE, (AFUNPTR)handle_direct_branch, IARG_INST_PTR, IARG_PTR, new string(addr), IARG_PTR, new string(instr), IARG_END); } /* Indirect Branches */ else{ /* Just call indirect_print */ INS_InsertCall(ins, IPOINT_BEFORE, (AFUNPTR)print_indirect_branch, IARG_INST_PTR, IARG_PTR, new string(INS_Disassemble(ins)), IARG_END); } } } /* Original parameters */ KNOB<string> KnobOutputFile(KNOB_MODE_WRITEONCE, "pintool", "o", "inscount.out", "specify output file name"); /* At the end, close file */ VOID Fini(INT32 code, VOID *v) { OutFile.close(); } /* Entry Point */ int main(int argc, char * argv[]) { /* Initialize pin, no args except the binary */ if (PIN_Init(argc, argv)) return -1; /* Open log file */ OutFile.open(KnobOutputFile.Value().c_str()); /* instruction-level instrumentation */ INS_AddInstrumentFunction(Instruction, 0); /* Application exit callback */ PIN_AddFiniFunction(Fini, 0); /* Start the program */ PIN_StartProgram(); return 0; }
23.732218
151
0.686883
y11en
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
0ee347e9bf4c5bf2c252c2e2e8985a6bdf20f9e6
4,519
hpp
C++
Practica4/include/EventoHistorico.hpp
Cadiducho/UGR-Estructura-Datos
397e068aa80786e2758a7eed50d1390248492318
[ "MIT" ]
null
null
null
Practica4/include/EventoHistorico.hpp
Cadiducho/UGR-Estructura-Datos
397e068aa80786e2758a7eed50d1390248492318
[ "MIT" ]
null
null
null
Practica4/include/EventoHistorico.hpp
Cadiducho/UGR-Estructura-Datos
397e068aa80786e2758a7eed50d1390248492318
[ "MIT" ]
null
null
null
#ifndef EVENTOHISTORICO_HPP #define EVENTOHISTORICO_HPP #include <iostream> #include <string> #include <set> #include <cassert> #include <sstream> #include "Fecha.hpp" using namespace std; typedef string Suceso; class EventoHistorico { private: pair<Fecha, set<Suceso>> eventos; public: typedef set<Suceso>::iterator iterator; typedef set<Suceso>::const_iterator const_iterator; EventoHistorico() {} EventoHistorico(const Fecha& f) { setFecha(f); } EventoHistorico(const Fecha& f, const std::set<Suceso>& suc) { setFecha(f); setSucesos(suc); } Fecha getFecha() const { return eventos.first; } void setFecha(const Fecha& f) { assert(f.getYear() > 0); //usar EC eventos.first = f; } /** * Obtener el conjunto de sucesos * @return Sucesos */ set<Suceso> getSucesos() const { return eventos.second; } /** * Establecer el conjunto de sucesos * @param sucesos Conjunto de sucesos */ void setSucesos(const set<Suceso>& sucesos) { eventos.second = sucesos; } /** * Insertar un suceso en esta fecha * @param s Suceso * @return Verdadero si se ha insertado, falso si ya estbaa */ bool addSuceso(const Suceso& s) { return eventos.second.insert(s).second; } /** * Insertar un conjunto de sucesos * @param s Conjunto */ void addSucesos(const set<Suceso> s) { return eventos.second.insert(s.begin(), s.end()); } /** * Eliminar un suceso * @param s Suceso a eliminar * @return True si se ha eliminado */ bool removeSuceso(Suceso& s) { return eventos.second.erase(s) > 0; } /** * Eliminar un suceso * @param it Posicion donde está el suceso */ void removeSuceso(const_iterator it) { if (eventos.second.count(*it) > 0) { eventos.second.erase(it); } } //Busquedas y por clave /** * Comprobar si ese suceso está registrado * @param s Suceso * @return True si está en los eventos */ bool hasSuceso(const Suceso& s) { return eventos.second.count(s) > 0; } /** * Buscar por clave * @param key Clave * @return Conjunto de claves encontradas */ set<Suceso> searchByKey(const string& key) const { set<Suceso> sucesos; for (const_iterator it = begin(); it != end(); ++it) { if (it->find(key) != string::npos) { sucesos.insert(*it); } } return sucesos; } /** * Eliminar por clave * @param key Clave * @return numero de claves eliminadas */ int removeByKey(const string& key) { int i = 0; for (const_iterator it = begin(); it != end(); ++it) { if ((it->find(key)) != string::npos) { eventos.second.erase(it); i++; } } return i; } /** * Buscar suceso * @param s Suceso * @return Iterador de donde se encuentra */ const_iterator searchSuceso(const Suceso& s) const { return eventos.second.find(s); } //Codigo de los iteradores iterator begin() { return eventos.second.begin(); } iterator end() { return eventos.second.end(); } const_iterator begin() const { return eventos.second.begin(); } const_iterator end() const { return eventos.second.end(); } }; istream& operator>>(istream& is, EventoHistorico& e) { const char SPLIT = '#'; set<string> a; string aux; /*getline(is, aux, SPLIT); bool ec = stoi(aux);*/ getline(is, aux, SPLIT); int year = stoi(aux); //Fecha fecha(year, ec); Fecha fecha(year); getline(is, aux); istringstream ss(aux); while (getline(ss, aux, SPLIT)) { a.insert(aux); } if (is) { e.setFecha(fecha); e.setSucesos(a); } return is; } ostream& operator<<(ostream& os, const EventoHistorico& e) { os << e.getFecha() <<": " << endl; for (EventoHistorico::const_iterator it_ev = e.begin(); it_ev != e.end(); ++it_ev) { os << " ===> " << (*it_ev) << endl; } return os; } #endif
22.595
89
0.532861
Cadiducho
0ee4dc928011ae2657656b9628aee1c46bfd1538
81,176
cpp
C++
moos-ivp/ivp/src/lib_marineview/MarineViewer.cpp
EasternEdgeRobotics/2018
24df2fe56fa6d172ba3c34c1a97f249dbd796787
[ "MIT" ]
null
null
null
moos-ivp/ivp/src/lib_marineview/MarineViewer.cpp
EasternEdgeRobotics/2018
24df2fe56fa6d172ba3c34c1a97f249dbd796787
[ "MIT" ]
null
null
null
moos-ivp/ivp/src/lib_marineview/MarineViewer.cpp
EasternEdgeRobotics/2018
24df2fe56fa6d172ba3c34c1a97f249dbd796787
[ "MIT" ]
null
null
null
/*****************************************************************/ /* NAME: Michael Benjamin */ /* ORGN: Dept of Mechanical Eng / CSAIL, MIT Cambridge MA */ /* FILE: MarineViewer.cpp */ /* DATE: May 31st, 2005 */ /* */ /* This file is part of MOOS-IvP */ /* */ /* MOOS-IvP 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 */ /* 3 of the License, or (at your option) any later version. */ /* */ /* MOOS-IvP 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 MOOS-IvP. If not, see */ /* <http://www.gnu.org/licenses/>. */ /*****************************************************************/ #ifdef _WIN32 #include <windows.h> #include <GL/gl.h> #include "glext.h" // http://www.opengl.org/registry/api/glext.h //#include "tiffio.h" // CWG - TIFFIO Not needed #else #include <tiffio.h> #endif #include <iostream> #include <cstring> #include <cstdlib> #include <cmath> #include "MarineViewer.h" #include "MBUtils.h" #include "GeomUtils.h" #include "AngleUtils.h" #include "FColorMap.h" #include "ColorParse.h" #include "Shape_Ship.h" #include "Shape_Kayak.h" #include "Shape_WAMV.h" #include "Shape_AUV.h" #include "Shape_Glider.h" #include "Shape_MOKAI.h" #include "Shape_Gateway.h" #include "Shape_Diamond.h" #include "Shape_Circle.h" #include "Shape_Triangle.h" #include "Shape_EField.h" #include "Shape_Square.h" #include "Shape_Kelp.h" #include "XYFormatUtilsPoly.h" #include "BearingLine.h" using namespace std; MarineViewer::MarineViewer(int x, int y, int w, int h, const char *l) : Fl_Gl_Window(x,y,w,h,l) { m_zoom = 1.0; m_vshift_x = 0; m_vshift_y = 0; m_x_origin = 0; m_y_origin = 0; m_hash_shade = 0.65; m_fill_shade = 0.55; m_texture_set = 0; m_texture_init = false; m_textures = new GLuint[1]; m_back_img_b_ok = false; m_back_img_b_on = false; m_back_img_mod = false; m_geodesy_initialized = false; m_main_window = 0; // glGenTextures(1, m_textures); } //------------------------------------------------------------- MarineViewer::~MarineViewer() { delete [] m_textures; } //------------------------------------------------------------- // Procedure: handle() int MarineViewer::handle(int event) { int result; if(event == FL_MOUSEWHEEL) { if(Fl::event_dy () < 0) { setParam("zoom", 1.05); redraw(); } else if(Fl::event_dy () > 0) { setParam("zoom", 0.95); redraw(); } result = 1; } else { result = Fl_Gl_Window::handle (event); } return(result); } //------------------------------------------------------------- // Procedure: setParam bool MarineViewer::setParam(string param, string value) { string p = tolower(stripBlankEnds(param)); // For some, we want value without tolower performed. value = stripBlankEnds(value); string v = tolower(value); bool handled = false; if(p=="tiff_type") { m_back_img_mod = true; handled = setBooleanOnString(m_back_img_b_on, v); } else if(p=="tiff_file") handled = m_back_img.readTiff(value); else if(p=="tiff_file_b") { handled = m_back_img_b.readTiff(value); if(handled) m_back_img_b_ok = true; } // else if(p=="hash_viewable") // handled = setBooleanOnString(m_hash_offon, v); else if(p=="geodesy_init") handled = initGeodesy(v); else if(p=="zoom") { handled = (v=="reset"); if(handled) m_zoom = 1.0; } else if(param == "hash_delta") { // 1000, 500, 200, 100, 50 double dval = atof(value.c_str()); string hash_val; if(dval < 50) hash_val = "10"; else if(dval < 100) hash_val = "50"; else if(dval < 200) hash_val = "100"; else if(dval < 500) hash_val = "200"; else if(dval < 1000) hash_val = "500"; else hash_val = "1000"; handled = m_geo_settings.setParam("hash_delta", hash_val); } else if(p=="datum") { string lat = stripBlankEnds(biteString(value, ',')); string lon = stripBlankEnds(value); handled = false; if(isNumber(lat) && isNumber(lon)) { double d_lat = atof(lat.c_str()); double d_lon = atof(lon.c_str()); m_back_img.setDatumLatLon(d_lat, d_lon); handled = true; } } else { handled = handled || m_vehi_settings.setParam(p,v); handled = handled || m_geo_settings.setParam(p,v); handled = m_drop_points.setParam(p,v) || handled; } return(handled); } //------------------------------------------------------------- // Procedure: handleNoTiff void MarineViewer::handleNoTiff() { if(m_back_img.get_img_data() != 0) return; cout << "No Image Data found. Faking it...." << endl; double lat_north = 0; double lat_south = 0; double lon_east = 0; double lon_west = 0; bool ok1 = m_geodesy.LocalGrid2LatLong(400, 100, lat_north, lon_east); bool ok2 = m_geodesy.LocalGrid2LatLong(-100, -400, lat_south, lon_west); if(ok1 && ok2) m_back_img.readTiffInfoEmpty(lat_north, lat_south, lon_east, lon_west); } //------------------------------------------------------------- // Procedure: setParam bool MarineViewer::setParam(string param, double v) { param = tolower(stripBlankEnds(param)); bool handled = true; if(param == "hash_shade_mod") { m_hash_shade = vclip((m_hash_shade+v), 0, 1); cout << "hash_shade:" << m_hash_shade << endl; } else if(param == "hash_shade") { m_hash_shade = vclip(v, 0, 1); } else if(param == "back_shade_delta") { if(!m_geo_settings.viewable("tiff_viewable")) { if((m_fill_shade+v > 0) && (m_fill_shade+v <= 1.0)) m_fill_shade += v; } } else if(param == "back_shade") { if((v >= 0) && (v <= 1.0)) m_fill_shade = v; } else if(param == "zoom") { m_zoom *= v; if(m_zoom < 0.00001) m_zoom = 0.00001; cout << "zoom:" << m_zoom << endl; } else if(param == "pan_x") { double pix_shift = v * m_back_img.get_pix_per_mtr_x(); m_vshift_x += pix_shift; cout << "pan_x:" << m_vshift_x << endl; } else if(param == "set_pan_x") { m_vshift_x = v; cout << "set_pan_x:" << m_vshift_x << endl; } else if(param == "pan_y") { double pix_shift = v * m_back_img.get_pix_per_mtr_y(); m_vshift_y += pix_shift; cout << "pan_y:" << m_vshift_y << endl; } else if(param == "set_pan_y") { m_vshift_y = v; cout << "set_pan_y:" << m_vshift_y << endl; } else if(param == "set_zoom") { m_zoom = v; if(m_zoom < 0.00001) m_zoom = 0.00001; cout << "set_pan_y:" << m_vshift_y << endl; } else handled = false; return(handled); } // ---------------------------------------------------------- // Procedure: setTexture // Purpose: bool MarineViewer::setTexture() { //static bool texture_init; glEnable(GL_TEXTURE_2D); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); if(!m_texture_init) { glGenTextures(1, m_textures); m_texture_init = true; } glBindTexture(GL_TEXTURE_2D, m_textures[0]); if((m_texture_set <1) || m_back_img_mod) { unsigned char *img_data; unsigned int img_width; unsigned int img_height; if(m_back_img_b_ok && m_back_img_b_on) { img_data = m_back_img_b.get_img_data(); img_width = m_back_img_b.get_img_pix_width(); img_height = m_back_img_b.get_img_pix_height(); } else { img_data = m_back_img.get_img_data(); img_width = m_back_img.get_img_pix_width(); img_height = m_back_img.get_img_pix_height(); } glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img_width, img_height, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, (unsigned char *)img_data); m_texture_set++; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); m_back_img_mod = false; } return(true); } //------------------------------------------------------------- // Procedure: img2view double MarineViewer::img2view(char xy, double img_val) { double view_val = 0.0; double adj_img_width = (double)(m_back_img.get_img_pix_width()) * m_zoom; double adj_img_height = (double)(m_back_img.get_img_pix_height()) * m_zoom; if(xy == 'x') { double adj_img_pix_x = img_val * adj_img_width; view_val = adj_img_pix_x + m_x_origin + w()/2; } if(xy == 'y') { double adj_img_pix_y = img_val * adj_img_height; view_val = adj_img_pix_y + m_y_origin + h()/2; } return(view_val); } //------------------------------------------------------------- // Procedure: view2img // Note: Derived as from img2view above double MarineViewer::view2img(char xy, double view_val) { double img_val = 0.0; double adj_img_width = (double)(m_back_img.get_img_pix_width()) * m_zoom; double adj_img_height = (double)(m_back_img.get_img_pix_height()) * m_zoom; if(xy == 'x') { if(adj_img_width == 0) return(0); img_val = ((view_val - m_x_origin) - w()/2); img_val = img_val / (adj_img_width); } if(xy == 'y') { if(adj_img_height == 0) return(0); img_val = ((view_val - m_y_origin) - h()/2); img_val = img_val / (adj_img_height); } return(img_val); } //------------------------------------------------------------- // Procedure: meters2img double MarineViewer::meters2img(char xy, double meters_val) { double img_val = 0.0; if(xy == 'x') { double range = m_back_img.get_img_mtr_width(); if(range == 0) img_val = 0; else { double pct = (meters_val - m_back_img.get_x_at_img_ctr()) / range; img_val = pct + 0.5; } } else if(xy == 'y') { double range = m_back_img.get_img_mtr_height(); if(range == 0) img_val = 0; else { double pct = (meters_val - m_back_img.get_y_at_img_ctr()) / range; img_val = pct + 0.5; } } return(img_val); } // ---------------------------------------------------------- // Procedure: img2meters // Note: Derived as from meters2img above double MarineViewer::img2meters(char xy, double img_val) { double meters_val = 0.0; if(xy == 'x') { double range = (m_back_img.get_x_at_img_right() - m_back_img.get_x_at_img_left()); meters_val = (img_val - m_back_img.get_img_centx()) * range; } if(xy == 'y') { double range = (m_back_img.get_y_at_img_top() - m_back_img.get_y_at_img_bottom()); meters_val = (img_val - m_back_img.get_img_centy()) * range; } return(meters_val); } // ---------------------------------------------------------- // Procedure: draw // Purpose: This is the "root" drawing routine - it is typically // invoked in the draw routines of subclasses. void MarineViewer::draw() { double r = m_fill_shade; double g = m_fill_shade; double b = m_fill_shade + 0.1; if(b > 1.0) b = 1.0; glClearColor(r,g,b,0.0); glClear(GL_COLOR_BUFFER_BIT); glViewport(0, 0, w(), h()); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); unsigned int image_width = m_back_img.get_img_pix_width(); unsigned int image_height = m_back_img.get_img_pix_height(); double shape_width = image_width * m_zoom; double shape_height = image_height * m_zoom; double m_xx = m_vshift_x * m_zoom; double m_yy = m_vshift_y * m_zoom; m_x_origin = -shape_width/2 + m_xx; m_y_origin = -shape_height/2 + m_yy; // Draw the background image if the tiff flag is set if(m_geo_settings.viewable("tiff_viewable")) drawTiff(); if(m_main_window == 0) m_main_window = Fl_Window::current(); } // ---------------------------------------------------------- // Procedure: drawTiff void MarineViewer::drawTiff() { if(m_back_img.get_img_data() == 0) return; setTexture(); unsigned int image_width = m_back_img.get_img_pix_width(); unsigned int image_height = m_back_img.get_img_pix_height(); double shape_width = image_width * m_zoom; double shape_height = image_height * m_zoom; double lower_x = m_x_origin; double upper_x = m_x_origin + shape_width; double lower_y = m_y_origin; double upper_y = m_y_origin + shape_height; glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(w()/2, h()/2, 0); glEnable(GL_TEXTURE_2D); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex2f(lower_x, lower_y); glTexCoord2f(0.0f, 1.0f); glVertex2f(lower_x, upper_y); glTexCoord2f(1.0f, 1.0f); glVertex2f(upper_x, upper_y); glTexCoord2f(1.0f, 0.0f); glVertex2f(upper_x, lower_y); glEnd(); glDisable(GL_TEXTURE_2D); glPopMatrix(); glFlush(); } // ---------------------------------------------------------- // Procedure: drawHash // Purpose: Draw the hash marks based local coordinate positions // on the image. Due to the snapToStep, there should // always be a hash line exactly on the datum (0,0). void MarineViewer::drawHash(double xl, double xr, double yb, double yt) { if((xl>xr) || (yb>yt)) return; double r = m_hash_shade; double g = m_hash_shade; double b = m_hash_shade; double hash_delta = m_geo_settings.geosize("hash_delta"); // If specs not given use a default region defined by the image if((xl==0) && (xr==0) && (yb==0) && (yt==0)) { xl = m_back_img.get_x_at_img_left(); xr = m_back_img.get_x_at_img_right(); yb = m_back_img.get_y_at_img_bottom(); yt = m_back_img.get_y_at_img_top(); } if((xl>=xr) || (yb>=yt)) return; // Make sure the has region aspect ratio of 1.0 double xwid = xr - xl; double ywid = yt - yb; if(xwid > ywid) { yb -= ((xwid - ywid) / 2); yt += ((xwid - ywid) / 2); } else if(ywid > xwid) { xl -= ((ywid - xwid) / 2); xr += ((ywid - xwid) / 2); } double xw = xr-xl; double yw = yt-yb; double xlow = snapToStep((xl-(xw/2)), hash_delta); double xhgh = snapToStep((xr+(xw/2)), hash_delta); double ylow = snapToStep((yb-(yw/2)), hash_delta); double yhgh = snapToStep((yt+(yw/2)), hash_delta); for(double i=xlow; i<=xhgh; i+=hash_delta) drawSegment(i, ylow, i, yhgh, r, g, b); for(double j=ylow; j<=yhgh; j+=hash_delta) drawSegment(xlow, j, xhgh, j, r, g, b); } //------------------------------------------------------------- // Procedure: geosetting string MarineViewer::geosetting(const string& key) { return(m_geo_settings.strvalue(key)); } //------------------------------------------------------------- // Procedure: vehisetting string MarineViewer::vehisetting(const string& key) { return(m_vehi_settings.strvalue(key)); } //------------------------------------------------------------- // Procedure: drawGLPoly void MarineViewer::drawGLPoly(double *points, unsigned int numPoints, ColorPack cpack, double thickness, double scale, double alpha) { if(thickness<=0) { glEnable(GL_BLEND); glColor4f(cpack.red(), cpack.grn(), cpack.blu(), alpha); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_POLYGON); } else { glLineWidth(thickness); glBegin(GL_LINE_STRIP); glColor3f(cpack.red(), cpack.grn(), cpack.blu()); } unsigned int i; for(i=0; i<numPoints*2; i=i+2) glVertex2f(points[i]*scale, points[i+1]*scale); glEnd(); } //------------------------------------------------------------- // Procedure: drawCommonVehicle void MarineViewer::drawCommonVehicle(const NodeRecord& record_mikerb, const BearingLine& bng_line, const ColorPack& body_color, const ColorPack& vname_color, bool vname_draw, unsigned int outer_line) { NodeRecord record = record_mikerb; string vname = record.getName(); string vehibody = tolower(record.getType()); double vlength = record.getLength(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); double heading = record.getHeading(); bool thrust_mode_reverse = record.getThrustModeReverse(); if(thrust_mode_reverse) { heading = angle360(heading+180); } // Determine position in terms of image percentage double vehicle_ix = meters2img('x', record.getX()); double vehicle_iy = meters2img('y', record.getY()); // Determine position in terms of view percentage double vehicle_vx = img2view('x', vehicle_ix); double vehicle_vy = img2view('y', vehicle_iy); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(vehicle_vx, vehicle_vy, 0); // theses are in pixel units glScalef(m_zoom, m_zoom, m_zoom); glRotatef(-heading,0,0,1); ColorPack black(0,0,0); ColorPack gray(0.5, 0.5, 0.5); // The raw numerical values representing the shapes should be interpreted // as being in "meters". When passed to GLPoly, they are interpreted as // being in pixels. So There are two components to drawing the vehicle // as "actual size". First convert the pixels to meters and then multiply // by the (shapelength / length_in_meters). // Since we know pix_per_mtr first, set "factor" initially to that. // Then when we know what kind of vehicle we're drawing, adjust the // factor accordingly. double factor_x = m_back_img.get_pix_per_mtr_x(); double factor_y = m_back_img.get_pix_per_mtr_y(); if(vehibody == "kayak") { if(vlength > 0) { factor_x *= (vlength / g_kayakLength); factor_y *= (vlength / g_kayakLength); } double cx = g_kayakCtrX * factor_x; double cy = g_kayakCtrY * factor_y; glTranslatef(-cx, -cy, 0); drawGLPoly(g_kayakBody, g_kayakBodySize, body_color, 0, factor_x); if(outer_line) drawGLPoly(g_kayakBody, g_kayakBodySize, black, outer_line, factor_x); drawGLPoly(g_kayakMidOpen, g_kayakMidOpenSize, gray, 0, factor_x); glTranslatef(cx, cy, 0); } else if(vehibody == "mokai") { if(vlength > 0) { factor_x *= (vlength / g_mokaiLength); factor_y *= (vlength / g_mokaiLength); } double cx = g_mokaiCtrX * factor_x; double cy = g_mokaiCtrY * factor_y; glTranslatef(-cx, -cy, 0); drawGLPoly(g_mokaiStern, g_mokaiSternSize, body_color, 0, factor_x); drawGLPoly(g_mokaiSlice1, g_mokaiSlice1Size, body_color, 0, factor_x); drawGLPoly(g_mokaiSlice2, g_mokaiSlice2Size, body_color, 0, factor_x); drawGLPoly(g_mokaiSlice3, g_mokaiSlice3Size, body_color, 0, factor_x); drawGLPoly(g_mokaiBow, g_mokaiBowSize, body_color, 0, factor_x); if(outer_line) drawGLPoly(g_mokaiBody, g_mokaiBodySize, black, outer_line, factor_x); drawGLPoly(g_mokaiMidOpen, g_mokaiMidOpenSize, gray, 0, factor_x); glTranslatef(cx, cy, 0); } else if(vehibody == "wamv"){ if(vlength > 0) { factor_x *= (vlength / g_wamvLength); factor_y *= (vlength / g_wamvLength); } ColorPack blue = colorParse("blue"); double cx = (g_wamvCtrX + g_wamvBase/2) * factor_x; double cy = g_wamvCtrY * factor_y; glTranslatef(-cx, -cy, 0); drawGLPoly(g_wamvBody, g_wamvBodySize, body_color, 0, factor_x); drawGLPoly(g_wamvpropUnit, g_wamvpropUnitSize, blue, 0, factor_x); glTranslatef(2*cx, 0, 0); drawGLPoly(g_wamvBody, g_wamvBodySize, body_color, 0, factor_x); drawGLPoly(g_wamvpropUnit, g_wamvpropUnitSize, blue, 0, factor_x); drawGLPoly(g_wamvPontoonConnector, g_pontoonConnectorSize, gray, 0, factor_x); glTranslatef(-cx, cy, 0); } else if((vehibody == "auv") || (vehibody == "uuv")) { if(vlength > 0) { factor_x *= (vlength / g_auvLength); factor_y *= (vlength / g_auvLength); } ColorPack blue = colorParse("blue"); double cx = g_auvCtrX * factor_x; double cy = g_auvCtrY * factor_y; glTranslatef(-cx, -cy, 0); drawGLPoly(g_auvBody, g_auvBodySize, body_color, 0, factor_x); if(outer_line > 0) drawGLPoly(g_auvBody, g_auvBodySize, black, outer_line, factor_x); drawGLPoly(g_propUnit, g_propUnitSize, blue, 0, factor_x); glTranslatef(cx, cy, 0); } else if(vehibody == "glider") { if(vlength > 0) { factor_x *= (vlength / g_gliderLength); factor_y *= (vlength / g_gliderLength); } double cx = g_gliderCtrX * factor_x; double cy = g_gliderCtrY * factor_y; glTranslatef(-cx, -cy, 0); drawGLPoly(g_gliderWing, g_gliderWingSize, body_color, 0, factor_x); drawGLPoly(g_gliderWing, g_gliderWingSize, black, 1, factor_x); drawGLPoly(g_gliderBody, g_gliderBodySize, body_color, 0, factor_x); drawGLPoly(g_gliderBody, g_gliderBodySize, black, 1, factor_x); glTranslatef(cx, cy, 0); } else if(vehibody == "ship") { if(vlength > 0) { factor_x *= (vlength / g_shipLength); factor_y *= (vlength / g_shipLength); } double cx = g_shipCtrX * factor_x; double cy = g_shipCtrY * factor_y; glTranslatef(-cx, -cy, 0); drawGLPoly(g_shipBody, g_shipBodySize, body_color, 0, factor_x); if(outer_line > 0) drawGLPoly(g_shipBody, g_shipBodySize, black, outer_line, factor_x); glTranslatef(cx, cy, 0); } else if(vehibody == "track") { double cx = g_shipCtrX * factor_x; double cy = g_shipCtrY * factor_y; glTranslatef(-cx, -cy, 0); drawGLPoly(g_shipBody, g_shipBodySize, body_color, 0, factor_x); if(outer_line > 0) drawGLPoly(g_shipBody, g_shipBodySize, black, outer_line, factor_x); glTranslatef(cx, cy, 0); } else { // vehibody == "auv" is the default ColorPack blue("blue"); if(vlength > 0) { factor_x *= (vlength / g_auvLength); factor_y *= (vlength / g_auvLength); } double cx = g_auvCtrX * factor_x; double cy = g_auvCtrY * factor_y; glTranslatef(-cx, -cy, 0); drawGLPoly(g_auvBody, g_auvBodySize, body_color, 0, factor_x); if(outer_line > 0) drawGLPoly(g_auvBody, g_auvBodySize, blue, outer_line, factor_x); drawGLPoly(g_propUnit, g_propUnitSize, blue, 0, factor_x); glTranslatef(cx, cy, 0); } if(vname_draw) { glColor3f(vname_color.red(), vname_color.grn(), vname_color.blu()); gl_font(1, 10); if(m_zoom > 4) gl_font(1, 12); double offset = 3.0 * (1/m_zoom); glRasterPos3f(offset, offset,0); gl_draw_aux(vname); } if(bng_line.isValid() && m_vehi_settings.isViewableBearingLines()) { double pix_per_mtr_x = m_back_img.get_pix_per_mtr_x(); double pix_per_mtr_y = m_back_img.get_pix_per_mtr_y(); double pix_per_mtr = (pix_per_mtr_x + pix_per_mtr_y) / 2.0; double bearing = bng_line.getBearing(); double range = bng_line.getRange() * pix_per_mtr; double lwidth = bng_line.getVectorWidth(); bool absolute = bng_line.isBearingAbsolute(); string bcolor = bng_line.getVectorColor(); ColorPack vpack(bcolor); double bx, by; projectPoint(bearing, range, 0, 0, bx, by); if(absolute) glRotatef(heading,0,0,1); glLineWidth(lwidth); glBegin(GL_LINE_STRIP); glColor3f(vpack.red(), vpack.grn(), vpack.blu()); glVertex2f(0, 0); glVertex2f(bx, by); glEnd(); glLineWidth(1); } glPopMatrix(); } //------------------------------------------------------------- // Procedure: drawMarkers void MarineViewer::drawMarkers(const map<string, XYMarker>& markers) { // If the viewable parameter is set to false just return. In // querying the parameter the optional "true" argument means return // true if nothing is known about the parameter. if(m_geo_settings.viewable("marker_viewable_all", true) == false) return; map<string, XYMarker>::const_iterator p; for(p=markers.begin(); p!=markers.end(); p++) if(p->second.active()) drawMarker(p->second); } //------------------------------------------------------------- // Procedure: drawMarker void MarineViewer::drawMarker(const XYMarker& marker) { if(!marker.active()) return; if(!marker.valid()) return; double gscale = m_geo_settings.geosize("marker_scale"); ColorPack labelc("white"); vector<ColorPack> color_vector; string mtype = marker.get_type(); string label = marker.get_label(); string message = marker.get_msg(); double x = marker.get_vx(); double y = marker.get_vy(); double shape_width = marker.get_width() * gscale; double alpha = 1 - marker.get_transparency(); if(shape_width <= 0) return; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); // Determine position in terms of image percentage double marker_ix = meters2img('x', x); double marker_iy = meters2img('y', y); // Determine position in terms of view percentage double marker_vx = img2view('x', marker_ix); double marker_vy = img2view('y', marker_iy); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(marker_vx, marker_vy, 0); // theses are in pixel units glScalef(m_zoom, m_zoom, m_zoom); double factor_x = m_back_img.get_pix_per_mtr_x(); double factor_y = m_back_img.get_pix_per_mtr_y(); ColorPack cpack1 = marker.get_color("primary_color"); ColorPack cpack2 = marker.get_color("secondary_color"); unsigned int bw = 1; // border width ColorPack black(0,0,0); if(mtype == "gateway") { factor_x *= (shape_width / g_gatewayWidth); factor_y *= (shape_width / g_gatewayWidth); if(!cpack2.set()) cpack2 = black; if(!cpack1.set()) cpack1.setColor("green"); double cx = g_gatewayCtrX * factor_x; double cy = g_gatewayCtrY * factor_y; glTranslatef(-cx, -cy, 0); drawGLPoly(g_gatewayBody, g_gatewayBodySize, cpack1, 0, factor_x, alpha); drawGLPoly(g_gatewayBody, g_gatewayBodySize, black, bw, factor_x); drawGLPoly(g_gatewayMidBody, g_gatewayMidBodySize, cpack2, 0, factor_x); glTranslatef(cx, cy, 0); } else if(mtype == "efield") { factor_x *= (shape_width / g_efieldWidth); factor_y *= (shape_width / g_efieldWidth); if(!cpack2.set()) cpack2.setColor("1.0, 0.843, 0.0"); if(!cpack1.set()) cpack1 = black; double cx = g_efieldCtrX * factor_x; double cy = g_efieldCtrY * factor_y; glTranslatef(-cx, -cy, 0); drawGLPoly(g_efieldBody, g_efieldBodySize, cpack1, 0, factor_x, alpha); drawGLPoly(g_efieldMidBody, g_efieldMidBodySize, cpack2, 0, factor_x, alpha); drawGLPoly(g_efieldMidBody, g_efieldMidBodySize, black, bw, factor_x); glTranslatef(cx, cy, 0); } else if(mtype == "diamond") { factor_x *= (shape_width / g_diamondWidth); factor_y *= (shape_width / g_diamondWidth); if(!cpack1.set()) cpack1.setColor("orange"); double cx = g_diamondCtrX * factor_x; double cy = g_diamondCtrY * factor_y; glTranslatef(-cx, -cy, 0); drawGLPoly(g_diamondBody, g_diamondBodySize, cpack1, 0, factor_x, alpha); drawGLPoly(g_diamondBody, g_diamondBodySize, black, bw, factor_x); glTranslatef(cx, cy, 0); } else if(mtype == "circle") { factor_x *= (shape_width / g_circleWidth); factor_y *= (shape_width / g_circleWidth); if(!cpack1.set()) cpack1.setColor("orange"); double cx = g_circleCtrX * factor_x; double cy = g_circleCtrY * factor_y; glTranslatef(-cx, -cy, 0); drawGLPoly(g_circleBody, g_circleBodySize, cpack1, 0, factor_x, alpha); drawGLPoly(g_circleBody, g_circleBodySize, black, bw, factor_x); glTranslatef(cx, cy, 0); } else if(mtype == "triangle") { factor_x *= (shape_width / g_triangleWidth); factor_y *= (shape_width / g_triangleWidth); if(!cpack1.set()) cpack1.setColor("red"); double cx = g_triangleCtrX * factor_x; double cy = g_triangleCtrY * factor_y; glTranslatef(-cx, -cy, 0); drawGLPoly(g_triangleBody, g_triangleBodySize, cpack1, 0, factor_x, alpha); drawGLPoly(g_triangleBody, g_triangleBodySize, black, bw, factor_x); glTranslatef(cx, cy, 0); } else if(mtype == "square") { factor_x *= (shape_width / g_squareWidth); factor_y *= (shape_width / g_squareWidth); if(!cpack1.set()) cpack1.setColor("blue"); double cx = g_squareCtrX * factor_x; double cy = g_squareCtrY * factor_y; glTranslatef(-cx, -cy, 0); drawGLPoly(g_squareBody, g_squareBodySize, cpack1, 0, factor_x, alpha); drawGLPoly(g_squareBody, g_squareBodySize, black, bw, factor_x); glTranslatef(cx, cy, 0); } else if(mtype == "kelp") { factor_x *= (shape_width / g_kelpWidth); factor_y *= (shape_width / g_kelpWidth); if(!cpack1.set()) cpack1.setColor("0, 0.54, 0.54"); double cx = g_kelpCtrX * factor_x; double cy = g_kelpCtrY * factor_y; glTranslatef(-cx, -cy, 0); drawGLPoly(g_kelpBody, g_kelpBodySize, cpack1, 0, factor_x, alpha); drawGLPoly(g_kelpBody, g_kelpBodySize, black, bw, factor_y); glTranslatef(cx, cy, 0); } bool draw_labels = m_geo_settings.viewable("marker_viewable_labels"); if(draw_labels && ((label != "") || (message != ""))) { glColor3f(labelc.red(), labelc.grn(), labelc.blu()); gl_font(1, 10); if(m_zoom > 4) gl_font(1, 12); double offset = 4.0 * (1/m_zoom); glRasterPos3f(offset, offset, 0); if(message != "") gl_draw_aux(message); else gl_draw_aux(label); } glPopMatrix(); } //------------------------------------------------------------- // Procedure: drawDatum void MarineViewer::drawDatum(const OpAreaSpec& op_area) { if(m_geo_settings.viewable("datum_viewable")) { XYPoint datum_point; datum_point.set_vertex_size(m_geo_settings.geosize("datum_size")); //datum_point.set_color("vertex", op_area.getDatumColor().str()); datum_point.set_color("vertex", m_geo_settings.geocolor("datum_color")); drawPoint(datum_point); } } //------------------------------------------------------------- // Procedure: drawOpArea void MarineViewer::drawOpArea(const OpAreaSpec& op_area) { if(m_geo_settings.viewable("oparea_viewable_all") == false) return; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); double tx = meters2img('x', 0); double ty = meters2img('y', 0); double qx = img2view('x', tx); double qy = img2view('y', ty); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(qx, qy, 0); glScalef(m_zoom, m_zoom, m_zoom); unsigned int index = 0; unsigned int asize = op_area.size(); double line_shade = op_area.getLineShade(); //double label_shade = op_area.getLabelShade(); while(index < asize) { string group = op_area.getGroup(index); double lwidth = op_area.getLWidth(index); bool looped = op_area.getLooped(index); ColorPack lcolor = op_area.getLColor(index); ColorPack vcolor = op_area.getVColor(index); vector<double> xpos, ypos; vector<string> labels; bool done = false; while(!done) { double x = op_area.getXPos(index); double y = op_area.getYPos(index); string label = op_area.getLabel(index); index++; if((index >= asize) || (group != op_area.getGroup(index))) done = true; xpos.push_back(x); ypos.push_back(y); labels.push_back(label); } unsigned int i, vsize = xpos.size(); double pix_per_mtr_x = m_back_img.get_pix_per_mtr_x(); double pix_per_mtr_y = m_back_img.get_pix_per_mtr_y(); for(i=0; i<vsize; i++) { xpos[i] *= pix_per_mtr_x; ypos[i] *= pix_per_mtr_y; } // Draw the edges glLineWidth(lwidth); glColor3f(lcolor.red()*line_shade, lcolor.grn()*line_shade, lcolor.blu()*line_shade); if(looped) glBegin(GL_LINE_LOOP); else glBegin(GL_LINE_STRIP); for(i=0; i<vsize; i++) { glVertex2f(xpos[i], ypos[i]); } glEnd(); if(op_area.viewable("labels")) { glColor3f(lcolor.red(), lcolor.grn(), lcolor.blu()); gl_font(1, 10); for(i=0; i<vsize; i++) { double offset = 3.0 * (1/m_zoom); glRasterPos3f(xpos[i]+offset, ypos[i]+offset, 0); gl_draw_aux(labels[i]); } } glLineWidth(1); } glFlush(); glPopMatrix(); } //------------------------------------------------------------- // Procedure: initGeodesy // Note: A check on legal boundaries is made here since it // does not appear to be checked for in the MOOSGeodesy // initialization implementation. bool MarineViewer::initGeodesy(double lat, double lon) { if((lat > 90) || (lat < -90)) return(false); if((lon > 180) || (lon < -180)) return(false); bool initialized = m_geodesy.Initialise(lat, lon); if(initialized) m_geodesy_initialized = true; return(initialized); } //------------------------------------------------------------- // Procedure: initGeodesy // Note: After the double values are determined be legitimate // numbers, a call is made to the initGeodesy function // to check on the legal boundaries since it does not // appear to be checked for in the MOOSGeodesy // initialization implementation. bool MarineViewer::initGeodesy(const string& str) { vector<string> svector = parseString(str, ','); if(svector.size() != 2) return(false); string slat = stripBlankEnds(svector[0]); string slon = stripBlankEnds(svector[1]); if((!isNumber(slat)) || (!isNumber(slon))) return(false); double dlat = atof(slat.c_str()); double dlon = atof(slon.c_str()); bool initialized = m_geodesy.Initialise(dlat, dlon); if(initialized) m_geodesy_initialized = true; return(initialized); } //------------------------------------------------------------- // Procedure: drawPolygons void MarineViewer::drawPolygons(const vector<XYPolygon>& polys) { // If the viewable parameter is set to false just return. In // querying the parameter the optional "true" argument means return // true if nothing is known about the parameter. if(!m_geo_settings.viewable("polygon_viewable_all", true)) return; unsigned int i, vsize = polys.size(); for(i=0; i<vsize; i++) if(polys[i].active()) drawPolygon(polys[i]); } //------------------------------------------------------------- // Procedure: drawPolygon void MarineViewer::drawPolygon(const XYPolygon& poly) { ColorPack edge_c("aqua"); // default if no drawing hint ColorPack fill_c("invisible"); // default if no drawing hint ColorPack vert_c("red"); // default if no drawing hint ColorPack labl_c("white"); // default if no drawing hint double transparency = 0.2; // default if no drawing hint double line_width = 1; // default if no drawing hint double vertex_size = 2; // default if no drawing hint if(poly.color_set("label")) // label_color labl_c = poly.get_color("label"); if(poly.color_set("vertex")) // vertex_color vert_c = poly.get_color("vertex"); if(poly.color_set("edge")) // edge_color edge_c = poly.get_color("edge"); if(poly.color_set("fill")) // fill_color fill_c = poly.get_color("fill"); if(poly.transparency_set()) // transparency transparency = poly.get_transparency(); if(poly.edge_size_set()) // edge_size line_width = poly.get_edge_size(); if(poly.vertex_size_set()) // vertex_size vertex_size = poly.get_vertex_size(); unsigned int vsize = poly.size(); if(vsize < 1) return; unsigned int i, j; double *points = new double[2*vsize]; double pix_per_mtr_x = m_back_img.get_pix_per_mtr_x(); double pix_per_mtr_y = m_back_img.get_pix_per_mtr_y(); int pindex = 0; for(i=0; i<vsize; i++) { points[pindex] = poly.get_vx(i) * pix_per_mtr_x; points[pindex+1] = poly.get_vy(i) * pix_per_mtr_y; pindex += 2; } glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); double tx = meters2img('x', 0); double ty = meters2img('y', 0); double qx = img2view('x', tx); double qy = img2view('y', ty); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(qx, qy, 0); glScalef(m_zoom, m_zoom, m_zoom); // Fill in the interior of polygon if it is a valid polygon // with greater than two vertices. (Two vertex polygons are // "valid" too, but we decide here not to draw the interior if((vsize > 2) && poly.is_convex() && fill_c.visible()) { glEnable(GL_BLEND); glColor4f(fill_c.red(), fill_c.grn(), fill_c.blu(), transparency); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_POLYGON); for(i=0; i<vsize*2; i=i+2) { glVertex2f(points[i], points[i+1]); } glEnd(); glDisable(GL_BLEND); } // Now draw the edges - if the polygon is invalid, don't draw // the last edge. if((vsize > 1) && (line_width > 0) && edge_c.visible()) { glLineWidth(line_width); glColor3f(edge_c.red(), edge_c.grn(), edge_c.blu()); if(poly.is_convex()) glBegin(GL_LINE_LOOP); else glBegin(GL_LINE_STRIP); for(i=0; i<vsize*2; i=i+2) { glVertex2f(points[i], points[i+1]); } glEnd(); glLineWidth(1.0); } // If the polygon is just a single point, draw it big! if(vsize==1) { glPointSize(1.2 * m_zoom); // Draw the vertices with color coding for the first and last //glColor3f(0.7,0.13,0.13); // Firebrick red b2 22 22 glColor3f(0.13, 0.13, 0.7); // Blueish glEnable(GL_POINT_SMOOTH); glBegin(GL_POINTS); glVertex2f(points[0], points[1]); glEnd(); glDisable(GL_POINT_SMOOTH); } if(vertex_size > 0) { glEnable(GL_POINT_SMOOTH); glPointSize(vertex_size); glColor3f(vert_c.red(), vert_c.grn(), vert_c.blu()); glBegin(GL_POINTS); for(j=0; j<vsize; j++) glVertex2f(points[(j*2)], points[(j*2)+1]); glEnd(); glDisable(GL_POINT_SMOOTH); } // Draw the labels unless either the viewer has it shut off OR if // the publisher of the polygon requested it not to be viewed, by // setting the color to be "invisible". bool draw_labels = m_geo_settings.viewable("polygon_viewable_labels"); if(draw_labels && labl_c.visible()) { double cx = poly.get_avg_x() * m_back_img.get_pix_per_mtr_x(); //double cy = poly.get_avg_y() * m_back_img.get_pix_per_mtr(); double my = poly.get_max_y() * m_back_img.get_pix_per_mtr_y(); glTranslatef(cx, my, 0); glColor3f(labl_c.red(), labl_c.grn(), labl_c.blu()); gl_font(1, 10); string plabel = poly.get_msg(); if(plabel == "") plabel = poly.get_label(); if((plabel != "") && (plabel != "_null_")) { glRasterPos3f(0, 0, 0); gl_draw_aux(plabel.c_str()); } } //-------------------------------- perhaps draw poly label #if 0 //-------------------------------- perhaps draw poly vertex labels if(m_geo_settings.viewable("polygon_viewable_vertex_labels")) { glTranslatef(0, 0, 0); for(j=0; j<vsize; j++) { double cx = points[(j*2)]; double cy = points[(j*2)+1]; glColor3f(edge_c.red(), edge_c.grn(), edge_c.blu()); gl_font(1, 10); string vlabel = intToString(j); int slen = vlabel.length(); glRasterPos3f(cx, cy, 0); gl_draw_aux(vlabel.c_str()); } } //-------------------------------- perhaps draw poly vertex_labels #endif delete [] points; glFlush(); glPopMatrix(); } //------------------------------------------------------------- // Procedure: drawWedges void MarineViewer::drawWedges(const vector<XYWedge>& wedges) { // If the viewable parameter is set to false just return. In // querying the parameter the optional "true" argument means return // true if nothing is known about the parameter. if(!m_geo_settings.viewable("wedges_viewable_all", true)) return; for(unsigned int i=0; i<wedges.size(); i++) if(wedges[i].active()) drawWedge(wedges[i]); } //------------------------------------------------------------- // Procedure: drawWedge void MarineViewer::drawWedge(const XYWedge& wedge) { ColorPack edge_c("aqua"); // default if no drawing hint ColorPack fill_c("invisible"); // default if no drawing hint ColorPack labl_c("white"); // default if no drawing hint double transparency = 0.2; // default if no drawing hint double line_width = 1; // default if no drawing hint if(wedge.color_set("label")) // label_color labl_c = wedge.get_color("label"); if(wedge.color_set("edge")) // edge_color edge_c = wedge.get_color("edge"); if(wedge.color_set("fill")) // fill_color fill_c = wedge.get_color("fill"); if(wedge.transparency_set()) // transparency transparency = wedge.get_transparency(); if(wedge.edge_size_set()) // edge_size line_width = wedge.get_edge_size(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); double tx = meters2img('x', 0); double ty = meters2img('y', 0); double qx = img2view('x', tx); double qy = img2view('y', ty); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glLineWidth(1.0); glTranslatef(qx, qy, 0); glScalef(m_zoom, m_zoom, m_zoom); vector<double> draw_pts = wedge.getPointCache(); double pix_per_mtr_x = m_back_img.get_pix_per_mtr_x(); double pix_per_mtr_y = m_back_img.get_pix_per_mtr_y(); for(unsigned int i=0; i<draw_pts.size(); i++) { if((i%2)==0) draw_pts[i] *= pix_per_mtr_x; else draw_pts[i] *= pix_per_mtr_y; } // Draw the lines if(edge_c.visible()) { glLineWidth(line_width); glColor3f(edge_c.red(), edge_c.grn(), edge_c.blu()); glBegin(GL_LINE_LOOP); for(unsigned int i=0; i<draw_pts.size(); i=i+2) { glVertex2f(draw_pts[i], draw_pts[i+1]); } glEnd(); } // If filled option is on, draw the interior of the wedge if(fill_c.visible()) { glEnable(GL_BLEND); glColor4f(fill_c.red(), fill_c.grn(), fill_c.blu(), transparency); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_POLYGON); for(unsigned int i=0; i<draw_pts.size(); i=i+2) { glVertex2f(draw_pts[i], draw_pts[i+1]); } glEnd(); glDisable(GL_BLEND); } // Draw the labels unless either the viewer has it shut off OR if // the publisher of the point requested it not to be viewed, by // setting the color to be "invisible". bool draw_labels = m_geo_settings.viewable("wedge_viewable_labels"); if(!edge_c.visible() && !fill_c.visible()) draw_labels = false; if(draw_labels && labl_c.visible()) { glColor3f(labl_c.red(), labl_c.grn(), labl_c.blu()); gl_font(1, 10); double px = wedge.getX() * m_back_img.get_pix_per_mtr_x(); double py = wedge.getY() * m_back_img.get_pix_per_mtr_y(); string plabel = wedge.get_msg(); if(plabel == "") plabel = wedge.get_label(); if(plabel != "") { double offset = 3.0 * (1/m_zoom); glRasterPos3f(px+offset, py+offset, 0); gl_draw_aux(plabel); } } glFlush(); glPopMatrix(); } //------------------------------------------------------------- // Procedure: drawSegment // Note: points are given in meter in local coordinates. void MarineViewer::drawSegment(double x1, double y1, double x2, double y2, double red, double grn, double blu) { double pix_per_mtr_x = m_back_img.get_pix_per_mtr_x(); double pix_per_mtr_y = m_back_img.get_pix_per_mtr_y(); x1 *= pix_per_mtr_x; y1 *= pix_per_mtr_y; x2 *= pix_per_mtr_x; y2 *= pix_per_mtr_y; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); double tx = meters2img('x', 0); double ty = meters2img('y', 0); double qx = img2view('x', tx); double qy = img2view('y', ty); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(qx, qy, 0); glScalef(m_zoom, m_zoom, m_zoom); glColor3f(red, grn, blu); glBegin(GL_LINE_STRIP); glVertex2f(x1, y1); glVertex2f(x2, y2); glEnd(); glFlush(); glPopMatrix(); } //------------------------------------------------------------- // Procedure: drawSegLists() void MarineViewer::drawSegLists(const vector<XYSegList>& segls) { // If the viewable parameter is set to false just return. In // querying the parameter the optional "true" argument means return // true if nothing is known about the parameter. if(!m_geo_settings.viewable("seglist_viewable_all", "true")) return; for(unsigned int i=0; i<segls.size(); i++) if(segls[i].active()) drawSegList(segls[i]); } //------------------------------------------------------------- // Procedure: drawSegList void MarineViewer::drawSegList(const XYSegList& segl) { ColorPack edge_c("white"); // default if no drawing hint ColorPack vert_c("blue"); // default if no drawing hint ColorPack labl_c("white"); // default if no drawing hint double line_width = 1; // default if no drawing hint double vertex_size = 2; // default if no drawing hint if(segl.color_set("label")) // label_color labl_c = segl.get_color("label"); if(segl.color_set("vertex")) // vertex_color vert_c = segl.get_color("vertex"); if(segl.color_set("edge")) // edge_color edge_c = segl.get_color("edge"); if(segl.edge_size_set()) // edge_size line_width = segl.get_edge_size(); if(segl.vertex_size_set()) // vertex_size vertex_size = segl.get_vertex_size(); unsigned int vsize = segl.size(); unsigned int i, j; double *points = new double[2*vsize]; double pix_per_mtr_x = m_back_img.get_pix_per_mtr_x(); double pix_per_mtr_y = m_back_img.get_pix_per_mtr_y(); unsigned int pindex = 0; for(i=0; i<vsize; i++) { points[pindex] = segl.get_vx(i) * pix_per_mtr_x; points[pindex+1] = segl.get_vy(i) * pix_per_mtr_y; pindex += 2; } glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); double tx = meters2img('x', 0); double ty = meters2img('y', 0); double qx = img2view('x', tx); double qy = img2view('y', ty); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(qx, qy, 0); glScalef(m_zoom, m_zoom, m_zoom); // First draw the edges if((vsize >= 2) && edge_c.visible() && (line_width > 0)) { glLineWidth(line_width); glColor3f(edge_c.red(), edge_c.grn(), edge_c.blu()); glBegin(GL_LINE_STRIP); for(i=0; i<vsize*2; i=i+2) { glVertex2f(points[i], points[i+1]); } glEnd(); glLineWidth(1.0); } // If the seglist is just a single point, draw it bigger (x 1.5) if(vert_c.visible()) { if(vsize==1) { glEnable(GL_POINT_SMOOTH); glPointSize(vertex_size * 1.5); // Draw the vertices with color coding for the first and last glColor3f(vert_c.red(), vert_c.grn(), vert_c.blu()); glBegin(GL_POINTS); glVertex2f(points[0], points[1]); glEnd(); glDisable(GL_POINT_SMOOTH); } else { if(vertex_size > 0) { glPointSize(vertex_size); // Draw the vertices in between the first and last ones glColor3f(vert_c.red(), vert_c.grn(), vert_c.blu()); glEnable(GL_POINT_SMOOTH); glBegin(GL_POINTS); for(j=0; j<vsize; j++) { glVertex2f(points[(j*2)], points[(j*2)+1]); } glEnd(); glDisable(GL_POINT_SMOOTH); } } } // Draw the labels unless either the viewer has it shut off OR if // the publisher of the seglist requested it not to be viewed, by // setting the color to be "invisible". bool draw_labels = m_geo_settings.viewable("seglist_viewable_labels"); if(draw_labels && labl_c.visible()) { double cx = segl.get_avg_x() * m_back_img.get_pix_per_mtr_x(); //double cy = poly.get_avg_y() * m_back_img.get_pix_per_mtr(); double my = segl.get_max_y() * m_back_img.get_pix_per_mtr_y(); glTranslatef(cx, my, 0); glColor3f(labl_c.red(), labl_c.grn(), labl_c.blu()); gl_font(1, 10); string plabel = segl.get_msg(); if(plabel == "") plabel = segl.get_label(); if(plabel != "") { glRasterPos3f(0, 0, 0); gl_draw_aux(plabel); } } //-------------------------------- perhaps draw seglist label delete [] points; glFlush(); glPopMatrix(); } //------------------------------------------------------------- // Procedure: drawSeglrs() void MarineViewer::drawSeglrs(const vector<XYSeglr>& seglrs) { // If the viewable parameter is set to false just return. In // querying the parameter the optional "true" argument means return // true if nothing is known about the parameter. if(!m_geo_settings.viewable("seglr_viewable_all", "true")) return; for(unsigned int i=0; i<seglrs.size(); i++) if(seglrs[i].active()) drawSeglr(seglrs[i]); } //------------------------------------------------------------- // Procedure: drawSeglr void MarineViewer::drawSeglr(const XYSeglr& seglr) { ColorPack edge_c("white"); // default if no drawing hint ColorPack vert_c("blue"); // default if no drawing hint ColorPack labl_c("white"); // default if no drawing hint double line_width = 1; // default if no drawing hint double vertex_size = 2; // default if no drawing hint double transparency = 0.5; // default if no drawing hint if(seglr.color_set("label")) // label_color labl_c = seglr.get_color("label"); if(seglr.color_set("vertex")) // vertex_color vert_c = seglr.get_color("vertex"); if(seglr.color_set("edge")) // edge_color edge_c = seglr.get_color("edge"); if(seglr.edge_size_set()) // edge_size line_width = seglr.get_edge_size(); if(seglr.vertex_size_set()) // vertex_size vertex_size = seglr.get_vertex_size(); if(seglr.transparency_set()) // transparency transparency = seglr.get_transparency(); unsigned int vsize = seglr.size(); unsigned int i, j; double *points = new double[2*vsize]; double pix_per_mtr_x = m_back_img.get_pix_per_mtr_x(); double pix_per_mtr_y = m_back_img.get_pix_per_mtr_y(); unsigned int pindex = 0; for(i=0; i<vsize; i++) { points[pindex] = seglr.getVX(i) * pix_per_mtr_x; points[pindex+1] = seglr.getVY(i) * pix_per_mtr_y; pindex += 2; } glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); double tx = meters2img('x', 0); double ty = meters2img('y', 0); double qx = img2view('x', tx); double qy = img2view('y', ty); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(qx, qy, 0); glScalef(m_zoom, m_zoom, m_zoom); // First draw the edges if((vsize >= 2) && edge_c.visible()) { glLineWidth(line_width); glColor4f(edge_c.red(), edge_c.grn(), edge_c.blu(), transparency); glBegin(GL_LINE_STRIP); for(i=0; i<vsize*2; i=i+2) { glVertex2f(points[i], points[i+1]); } glEnd(); glLineWidth(1.0); } // If the seglr has just a single point, draw it bigger (x 1.5) if(vert_c.visible()) { if(vsize==1) { glEnable(GL_POINT_SMOOTH); glPointSize(vertex_size * 1.5); // Draw the vertices with color coding for the first and last glColor3f(vert_c.red(), vert_c.grn(), vert_c.blu()); glBegin(GL_POINTS); glVertex2f(points[0], points[1]); glEnd(); glDisable(GL_POINT_SMOOTH); } else { if(vertex_size > 0) { glPointSize(vertex_size); // Draw the vertices in between the first and last ones glColor3f(vert_c.red(), vert_c.grn(), vert_c.blu()); glEnable(GL_POINT_SMOOTH); glBegin(GL_POINTS); for(j=0; j<vsize; j++) { glVertex2f(points[(j*2)], points[(j*2)+1]); } glEnd(); glDisable(GL_POINT_SMOOTH); } } } //---------------------------------------------------------------- // Draw the vector double *vpoints = new double[8]; //double pix_per_mtr_x = m_back_img.get_pix_per_mtr_x(); //double pix_per_mtr_y = m_back_img.get_pix_per_mtr_y(); double vang = seglr.getRayAngle(); double ovang = angle360(vang-180); double vmag = seglr.getRayLen(); double vbase_x = seglr.getRayBaseX(); double vbase_y = seglr.getRayBaseY(); cout << "vbase_x: " << vbase_x << endl; cout << "vbase_y: " << vbase_y << endl; // First determine the point on the end of the vector double hx, hy; projectPoint(vang, vmag, vbase_x, vbase_y, hx, hy); double head_size = seglr.getHeadSize(); if(head_size < 0) head_size = 4.0; // Then determine the head points double hx1, hx2, hy1, hy2; projectPoint(ovang+30, head_size, hx, hy, hx1, hy1); projectPoint(ovang-30, head_size, hx, hy, hx2, hy2); vpoints[0] = vbase_x * pix_per_mtr_x; vpoints[1] = vbase_y * pix_per_mtr_y; vpoints[2] = hx * pix_per_mtr_x; vpoints[3] = hy * pix_per_mtr_y; vpoints[4] = hx1 * pix_per_mtr_x; vpoints[5] = hy1 * pix_per_mtr_y; vpoints[6] = hx2 * pix_per_mtr_x; vpoints[7] = hy2 * pix_per_mtr_y; glColor4f(edge_c.red(), edge_c.grn(), edge_c.blu(), transparency); glLineWidth(line_width); glBegin(GL_LINE_STRIP); glVertex2f(vpoints[0], vpoints[1]); glVertex2f(vpoints[2], vpoints[3]); glLineWidth(1.0); glEnd(); // Then draw the vector head glBegin(GL_POLYGON); glVertex2f(vpoints[4], vpoints[5]); glVertex2f(vpoints[6], vpoints[7]); glVertex2f(vpoints[2], vpoints[3]); glEnd(); glLineWidth(1.0); //---------------------------------------------------------------- // Draw the labels unless either the viewer has it shut off OR if // the publisher of the seglist requested it not to be viewed, by // setting the color to be "invisible". bool draw_labels = m_geo_settings.viewable("seglr_viewable_labels"); if(draw_labels && labl_c.visible()) { double cx, cy; projectPoint(vang, head_size+4, hx, hy, cx, cy); cx *= m_back_img.get_pix_per_mtr_x(); cy *= m_back_img.get_pix_per_mtr_x(); //double cx = seglr.getAvgX() * m_back_img.get_pix_per_mtr_x(); //double cy = poly.get_avg_y() * m_back_img.get_pix_per_mtr(); //double my = seglr.getMaxY() * m_back_img.get_pix_per_mtr_y(); glTranslatef(cx, cy, 0); glColor3f(labl_c.red(), labl_c.grn(), labl_c.blu()); gl_font(1, 10); string plabel = seglr.get_msg(); if(plabel != "") { glRasterPos3f(0, 0, 0); gl_draw_aux(plabel); } } delete [] points; glFlush(); glPopMatrix(); } //------------------------------------------------------------- // Procedure: drawVectors() void MarineViewer::drawVectors(const vector<XYVector>& vects) { // If the viewable parameter is set to false just return. In // querying the parameter the optional "true" argument means return // true if nothing is known about the parameter. if(!m_geo_settings.viewable("vector_viewable_all", "true")) return; unsigned int i, vsize = vects.size(); for(i=0; i<vsize; i++) if(vects[i].active()) drawVector(vects[i]); } //------------------------------------------------------------- // Procedure: drawVector void MarineViewer::drawVector(const XYVector& vect) { // Determine the color properties ColorPack edge_c, vert_c, labl_c; edge_c = m_geo_settings.geocolor("vector_edge_color", "yellow"); vert_c = m_geo_settings.geocolor("vector_vertex_color", "white"); labl_c = m_geo_settings.geocolor("vector_label_color", "white"); if(vect.color_set("label")) labl_c = vect.get_color("label"); if(vect.color_set("vertex")) vert_c = vect.get_color("vertex"); if(vect.color_set("edge")) edge_c = vect.get_color("edge"); // Determine the size properties double line_width = 1; // default if no drawing hints provided double vertex_size = 2; // default if no drawing hints provided if(vect.edge_size_set()) line_width = vect.get_edge_size(); if(vect.vertex_size_set()) vertex_size = vect.get_vertex_size(); // Do the drawing double *points = new double[8]; double pix_per_mtr_x = m_back_img.get_pix_per_mtr_x(); double pix_per_mtr_y = m_back_img.get_pix_per_mtr_y(); double vang = vect.ang(); double ovang = angle360(vang-180); double vzoom = m_geo_settings.geosize("vector_length_zoom", 2); double vmag = vect.mag() * vzoom; // First determine the point on the end of the vector double hx, hy; projectPoint(vang, vmag, vect.xpos(), vect.ypos(), hx, hy); double head_size = vect.headsize(); if(head_size < 0) head_size = 4.0; // Then determine the head points double hx1, hx2, hy1, hy2; projectPoint(ovang+30, head_size, hx, hy, hx1, hy1); projectPoint(ovang-30, head_size, hx, hy, hx2, hy2); points[0] = vect.xpos() * pix_per_mtr_x; points[1] = vect.ypos() * pix_per_mtr_y; points[2] = hx * pix_per_mtr_x; points[3] = hy * pix_per_mtr_y; points[4] = hx1 * pix_per_mtr_x; points[5] = hy1 * pix_per_mtr_y; points[6] = hx2 * pix_per_mtr_x; points[7] = hy2 * pix_per_mtr_y; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); double tx = meters2img('x', 0); double ty = meters2img('y', 0); double qx = img2view('x', tx); double qy = img2view('y', ty); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(qx, qy, 0); glScalef(m_zoom, m_zoom, m_zoom); // First draw the vector stem glLineWidth(line_width); glColor3f(edge_c.red(), edge_c.grn(), edge_c.blu()); glBegin(GL_LINE_STRIP); glVertex2f(points[0], points[1]); glVertex2f(points[2], points[3]); glEnd(); // Draw the vector vertex point glEnable(GL_POINT_SMOOTH); glPointSize(vertex_size); glColor3f(vert_c.red(), vert_c.grn(), vert_c.blu()); glBegin(GL_POINTS); glVertex2f(points[0], points[1]); glEnd(); glDisable(GL_POINT_SMOOTH); // Then draw the vector head glBegin(GL_POLYGON); glVertex2f(points[4], points[5]); glVertex2f(points[6], points[7]); glVertex2f(points[2], points[3]); glEnd(); glLineWidth(1.0); // Draw the labels unless either the viewer has it shut off OR if // the publisher of the vector requested it not to be viewed, by // setting the color to be "invisible". bool draw_labels = m_geo_settings.viewable("vector_viewable_labels"); if(draw_labels && labl_c.visible()) { double cx = vect.xpos() * m_back_img.get_pix_per_mtr_x(); double cy = vect.ypos() * m_back_img.get_pix_per_mtr_y(); glTranslatef(cx, cy, 0); glColor3f(labl_c.red(), labl_c.grn(), labl_c.blu()); gl_font(1, 10); string plabel = vect.get_msg(); if(plabel == "") plabel = vect.get_label(); if(plabel != "") { glRasterPos3f(0, 0, 0); gl_draw_aux(plabel); } } //-----------------------------end perhaps draw vect label delete [] points; glFlush(); glPopMatrix(); } //------------------------------------------------------------- // Procedure: drawHexagons() void MarineViewer::drawHexagons() { #if 0 unsigned int i, hsize = m_geoshapes.sizeHexagons(); for(i=0; i<hsize; i++) if(m_geoshapes.getHexagon(i).active()) drawPolygon(m_geoshapes.getHexagon(i), false, false); #endif } //------------------------------------------------------------- // Procedure: drawGrids void MarineViewer::drawGrids(const vector<XYGrid>& grids) { if(m_geo_settings.viewable("grid_viewable_all", true) == false) return; unsigned int i, vsize = grids.size(); for(i=0; i<vsize; i++) drawGrid(grids[i]); } //------------------------------------------------------------- // Procedure: drawGrid void MarineViewer::drawGrid(const XYGrid& grid) { FColorMap cmap; unsigned int gsize = grid.size(); if(gsize == 0) return; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); double tx = meters2img('x', 0); double ty = meters2img('y', 0); double qx = img2view('x', tx); double qy = img2view('y', ty); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glLineWidth(1.0); // added dec1306 glTranslatef(qx, qy, 0); glScalef(m_zoom, m_zoom, m_zoom); unsigned int i; double px[4]; double py[4]; double min_eval = grid.getMinUtilPoss(); double max_eval = grid.getMaxUtilPoss(); for(i=0; i<gsize; i++) { XYSquare element = grid.getElement(i); double eval = grid.getUtil(i); double pct = (eval-min_eval)/(max_eval-min_eval); double r = cmap.getIRVal(pct); double g = cmap.getIGVal(pct); double b = cmap.getIBVal(pct); px[0] = element.getVal(0,0); py[0] = element.getVal(1,0); px[1] = element.getVal(0,1); py[1] = element.getVal(1,0); px[2] = element.getVal(0,1); py[2] = element.getVal(1,1); px[3] = element.getVal(0,0); py[3] = element.getVal(1,1); glEnable(GL_BLEND); glColor4f(r,g,b,1); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_POLYGON); for(int j=0; j<4; j++) glVertex2f(px[j], py[j]); glEnd(); glDisable(GL_BLEND); glColor3f(0.9,0.9,0.9); glBegin(GL_LINE_LOOP); for(int k=0; k<4; k++) glVertex2f(px[k], py[k]); glEnd(); } glFlush(); glPopMatrix(); } //------------------------------------------------------------- // Procedure: drawConvexGrids void MarineViewer::drawConvexGrids(const vector<XYConvexGrid>& grids) { if(m_geo_settings.viewable("grid_viewable_all", true) == false) return; unsigned int i, vsize = grids.size(); for(i=0; i<vsize; i++) drawConvexGrid(grids[i]); } //------------------------------------------------------------- // Procedure: drawConvexGrid void MarineViewer::drawConvexGrid(const XYConvexGrid& grid) { FColorMap cmap; unsigned int gsize = grid.size(); if(gsize == 0) return; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); double tx = meters2img('x', 0); double ty = meters2img('y', 0); double qx = img2view('x', tx); double qy = img2view('y', ty); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glLineWidth(0.5); // added dec1306 glTranslatef(qx, qy, 0); glScalef(m_zoom, m_zoom, m_zoom); unsigned int i; double px[4]; double py[4]; double min_eval, max_eval, range = 0; //cout << "min_limited:" << grid.cellVarMinLimited() << endl; //cout << "max_limited:" << grid.cellVarMaxLimited() << endl << endl; if(grid.cellVarMaxLimited() && grid.cellVarMinLimited()) { min_eval = grid.getMinLimit(); max_eval = grid.getMaxLimit(); range = max_eval - min_eval; } else { min_eval = grid.getMin(); max_eval = grid.getMax(); range = max_eval - min_eval; } double cell_opaqueness = m_geo_settings.opaqueness("grid_opaqueness", 0.3); double edge_opaqueness = cell_opaqueness * 0.6; for(i=0; i<gsize; i++) { XYSquare element = grid.getElement(i); px[0] = element.getVal(0,0) * m_back_img.get_pix_per_mtr_x(); py[0] = element.getVal(1,0) * m_back_img.get_pix_per_mtr_y(); px[1] = element.getVal(0,1) * m_back_img.get_pix_per_mtr_x(); py[1] = element.getVal(1,0) * m_back_img.get_pix_per_mtr_y(); px[2] = element.getVal(0,1) * m_back_img.get_pix_per_mtr_x(); py[2] = element.getVal(1,1) * m_back_img.get_pix_per_mtr_y(); px[3] = element.getVal(0,0) * m_back_img.get_pix_per_mtr_x(); py[3] = element.getVal(1,1) * m_back_img.get_pix_per_mtr_y(); // Draw the internal parts of the cells if range is nonzero. if(range > 0) { double eval = grid.getVal(i); double pct = (eval-min_eval)/(range); double r = cmap.getIRVal(pct); double g = cmap.getIGVal(pct); double b = cmap.getIBVal(pct); glEnable(GL_BLEND); //glColor4f(r,g,b,0.3); glColor4f(r,g,b,cell_opaqueness); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_POLYGON); for(int j=0; j<4; j++) glVertex2f(px[j], py[j]); glEnd(); glDisable(GL_BLEND); } // Begin Draw the cell edges glEnable(GL_BLEND); glColor4f(0.6,0.6,0.6,edge_opaqueness); glBegin(GL_LINE_LOOP); for(int k=0; k<4; k++) glVertex2f(px[k], py[k]); glEnd(); glDisable(GL_BLEND); // End Draw the cell edges } glFlush(); glPopMatrix(); } //------------------------------------------------------------- // Procedure: drawCircles void MarineViewer::drawCircles(const map<string, XYCircle>& circles, double timestamp) { // If the viewable parameter is set to false just return. In // querying the parameter the optional "true" argument means return // true if nothing is known about the parameter. if(!m_geo_settings.viewable("circle_viewable_all", true)) return; map<string, XYCircle>::const_iterator p; for(p=circles.begin(); p!=circles.end(); p++) if(p->second.active()) drawCircle(p->second, timestamp); } //------------------------------------------------------------- // Procedure: drawCircle void MarineViewer::drawCircle(const XYCircle& circle, double timestamp) { if(timestamp != 0) { double circle_duration = circle.getDuration(); if(circle_duration > 0) { double elapsed = timestamp - circle.get_time(); if(elapsed > circle_duration) return; } } ColorPack edge_c("blue"); ColorPack labl_c("white"); ColorPack fill_c("invisible"); double line_width = 1; double transparency = 0.2; if(circle.color_set("edge")) // edge_color edge_c = circle.get_color("edge"); if(circle.color_set("label")) // label_color labl_c = circle.get_color("label"); if(circle.color_set("fill")) // fill_color fill_c = circle.get_color("fill"); if(circle.transparency_set()) // transparency transparency = circle.get_transparency(); if(circle.edge_size_set()) // edge_size line_width = circle.get_edge_size(); // If neither edges or circle-fill are visible, just quit now! if(!edge_c.visible() && !fill_c.visible()) return; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); double tx = meters2img('x', 0); double ty = meters2img('y', 0); double qx = img2view('x', tx); double qy = img2view('y', ty); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glLineWidth(1.0); glTranslatef(qx, qy, 0); glScalef(m_zoom, m_zoom, m_zoom); vector<double> draw_pts = circle.getPointCache(); double pix_per_mtr_x = m_back_img.get_pix_per_mtr_x(); double pix_per_mtr_y = m_back_img.get_pix_per_mtr_y(); for(unsigned int i=0; i<draw_pts.size(); i++) { if((i%2)==0) draw_pts[i] *= pix_per_mtr_x; else draw_pts[i] *= pix_per_mtr_y; } if(edge_c.visible()) { glLineWidth(line_width); glColor3f(edge_c.red(), edge_c.grn(), edge_c.blu()); glBegin(GL_LINE_LOOP); for(unsigned int i=0; i<draw_pts.size(); i=i+2) { glVertex2f(draw_pts[i], draw_pts[i+1]); } glEnd(); } // If filled option is on, draw the interior of the circle if(fill_c.visible()) { glEnable(GL_BLEND); glColor4f(fill_c.red(), fill_c.grn(), fill_c.blu(), transparency); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_POLYGON); for(unsigned int i=0; i<draw_pts.size(); i=i+2) { glVertex2f(draw_pts[i], draw_pts[i+1]); } glEnd(); glDisable(GL_BLEND); } // Draw the labels unless either the viewer has it shut off OR if // the publisher of the point requested it not to be viewed, by // setting the color to be "invisible". bool draw_labels = m_geo_settings.viewable("circle_viewable_labels"); if(!edge_c.visible() && !fill_c.visible()) draw_labels = false; if(draw_labels && labl_c.visible()) { glColor3f(labl_c.red(), labl_c.grn(), labl_c.blu()); gl_font(1, 10); double px = circle.getX() * m_back_img.get_pix_per_mtr_x(); double py = circle.get_max_y() * m_back_img.get_pix_per_mtr_y(); string plabel = circle.get_msg(); if(plabel == "") plabel = circle.get_label(); if(plabel != "") { double offset = 3.0 * (1/m_zoom); glRasterPos3f(px+offset, py+offset, 0); gl_draw_aux(plabel); } } glFlush(); glPopMatrix(); } //------------------------------------------------------------- // Procedure: drawRangePulses void MarineViewer::drawRangePulses(const vector<XYRangePulse>& pulses, double timestamp) { // If the viewable parameter is set to false just return. In // querying the parameter the optional "true" argument means return // true if nothing is known about the parameter. if(!m_geo_settings.viewable("pulses_viewable_all", true)) return; unsigned int i, vsize = pulses.size(); for(i=0; i<vsize; i++) if(pulses[i].active()) drawRangePulse(pulses[i], timestamp); } //------------------------------------------------------------- // Procedure: drawRangePulse void MarineViewer::drawRangePulse(const XYRangePulse& pulse, double timestamp) { ColorPack edge_c("blue"); ColorPack fill_c("light_blue"); if(pulse.color_set("edge")) // edge_color edge_c = pulse.get_color("edge"); if(pulse.color_set("fill")) // fill_color fill_c = pulse.get_color("fill"); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); double tx = meters2img('x', 0); double ty = meters2img('y', 0); double qx = img2view('x', tx); double qy = img2view('y', ty); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glLineWidth(1.0); glTranslatef(qx, qy, 0); glScalef(m_zoom, m_zoom, m_zoom); vector<double> points = pulse.get_circle(timestamp, 90); unsigned int vsize = points.size(); unsigned int i, pcnt = vsize; double pix_per_mtr_x = m_back_img.get_pix_per_mtr_x(); double pix_per_mtr_y = m_back_img.get_pix_per_mtr_y(); for(i=0; i<pcnt; i=i+2) { points[i] *= pix_per_mtr_x; points[i+1] *= pix_per_mtr_y; } // Draw the circle line glColor3f(edge_c.red(), edge_c.grn(), edge_c.blu()); glBegin(GL_LINE_LOOP); for(i=0; i<pcnt; i=i+2) glVertex2f(points[i], points[i+1]); glEnd(); // Determine the fill degree [0,1]. 1 is completely opaque double fill_degree = pulse.get_fill(timestamp); // If filled option is on, draw the interior of the circle if((fill_degree > 0) && fill_c.visible()) { glEnable(GL_BLEND); glColor4f(fill_c.red(), fill_c.grn(), fill_c.blu(), fill_degree); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_POLYGON); for(i=0; i<pcnt; i=i+2) glVertex2f(points[i], points[i+1]); glEnd(); glDisable(GL_BLEND); } glFlush(); glPopMatrix(); } //------------------------------------------------------------- // Procedure: drawCommsPulses void MarineViewer::drawCommsPulses(const vector<XYCommsPulse>& pulses, double timestamp) { // If the viewable parameter is set to false just return. In // querying the parameter the optional "true" argument means return // true if nothing is known about the parameter. if(!m_geo_settings.viewable("comms_pulse_viewable_all", true)) return; unsigned int i, vsize = pulses.size(); for(i=0; i<vsize; i++) if(pulses[i].active()) drawCommsPulse(pulses[i], timestamp); } //------------------------------------------------------------- // Procedure: drawCommsPulse void MarineViewer::drawCommsPulse(const XYCommsPulse& pulse, double timestamp) { ColorPack fill_c("light_blue"); if(pulse.color_set("fill")) // fill_color fill_c = pulse.get_color("fill"); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); double tx = meters2img('x', 0); double ty = meters2img('y', 0); double qx = img2view('x', tx); double qy = img2view('y', ty); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glLineWidth(1.0); glTranslatef(qx, qy, 0); glScalef(m_zoom, m_zoom, m_zoom); vector<double> points = pulse.get_triangle(timestamp); unsigned int vsize = points.size(); unsigned int i, pcnt = vsize; double pix_per_mtr_x = m_back_img.get_pix_per_mtr_x(); double pix_per_mtr_y = m_back_img.get_pix_per_mtr_y(); for(i=0; i<pcnt; i=i+2) { points[i] *= pix_per_mtr_x; points[i+1] *= pix_per_mtr_y; } #if 0 // Draw the triangle line glColor3f(fill_c.red(), fill_c.grn(), fill_c.blu()); glBegin(GL_LINE_LOOP); for(i=0; i<pcnt; i=i+2) glVertex2f(points[i], points[i+1]); glEnd(); #endif // Determine the fill degree [0,1]. 1 is completely opaque double fill_degree = pulse.get_fill(timestamp); // If filled option is on, draw the interior of the triangle if((fill_degree > 0) && fill_c.visible()) { glEnable(GL_BLEND); glColor4f(fill_c.red(), fill_c.grn(), fill_c.blu(), fill_degree); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_POLYGON); for(i=0; i<pcnt; i=i+2) glVertex2f(points[i], points[i+1]); glEnd(); glDisable(GL_BLEND); } glFlush(); glPopMatrix(); } #if 0 //------------------------------------------------------------- // Procedure: drawPoints void MarineViewer::drawPoints(const map<string, XYPoint>& points) { // If the viewable parameter is set to false just return. In // querying the parameter the optional "true" argument means return // true if nothing is known about the parameter. if(!m_geo_settings.viewable("point_viewable_all", true)) return; map<string, XYPoint>::const_iterator p; for(p=points.begin(); p!=points.end(); p++) { if(p->second.active()) drawPoint(p->second); } } #endif //------------------------------------------------------------- // Procedure: drawPoint void MarineViewer::drawPoint(const XYPoint& point) { ColorPack vert_c("red"); // default if no drawing hint ColorPack labl_c("aqua_marine"); // default if no drawing hint double vertex_size = 2; // default if no drawing hint if(point.color_set("label")) labl_c = point.get_color("label"); if(point.color_set("vertex")) vert_c = point.get_color("vertex"); if(point.vertex_size_set()) vertex_size = point.get_vertex_size(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); double tx = meters2img('x', 0); double ty = meters2img('y', 0); double qx = img2view('x', tx); double qy = img2view('y', ty); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(qx, qy, 0); glScalef(m_zoom, m_zoom, m_zoom); double px = point.get_vx() * m_back_img.get_pix_per_mtr_x(); double py = point.get_vy() * m_back_img.get_pix_per_mtr_y(); if(vert_c.visible()) { glPointSize(vertex_size); glColor3f(vert_c.red(), vert_c.grn(), vert_c.blu()); glEnable(GL_POINT_SMOOTH); glBegin(GL_POINTS); glVertex2f(px, py); glEnd(); glDisable(GL_POINT_SMOOTH); } // Draw the labels unless either the viewer has it shut off OR if // the publisher of the point requested it not to be viewed, by // setting the color to be "invisible". bool draw_labels = m_geo_settings.viewable("point_viewable_labels"); if(draw_labels && labl_c.visible()) { glColor3f(labl_c.red(), labl_c.grn(), labl_c.blu()); gl_font(1, 12); string plabel = point.get_msg(); if(plabel == "") plabel = point.get_label(); if(plabel != "") { double offset = 3.0 * (1/m_zoom); glRasterPos3f(px+offset, py+offset, 0); gl_draw_aux(plabel); } } glFlush(); glPopMatrix(); } //------------------------------------------------------------- // Procedure: drawPoints void MarineViewer::drawPoints(const map<string, XYPoint>& points) { // If the viewable parameter is set to false just return. In // querying the parameter the optional "true" argument means return // true if nothing is known about the parameter. if(!m_geo_settings.viewable("point_viewable_all", true)) return; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); double tx = meters2img('x', 0); double ty = meters2img('y', 0); double qx = img2view('x', tx); double qy = img2view('y', ty); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(qx, qy, 0); glScalef(m_zoom, m_zoom, m_zoom); ColorPack default_vert_color("red"); ColorPack default_labl_color("aqua_marine"); bool draw_labels = m_geo_settings.viewable("point_viewable_labels"); map<string, XYPoint>::const_iterator p; for(p=points.begin(); p!=points.end(); p++) { if(p->second.active()) { XYPoint point = p->second; // Set defaults if no drawing hints found ColorPack vert_c = default_vert_color; ColorPack labl_c = default_labl_color; double vertex_size = 2; if(point.color_set("label")) labl_c = point.get_color("label"); if(point.color_set("vertex")) vert_c = point.get_color("vertex"); if(point.vertex_size_set()) vertex_size = point.get_vertex_size(); double px = point.get_vx() * m_back_img.get_pix_per_mtr_x(); double py = point.get_vy() * m_back_img.get_pix_per_mtr_y(); if(vert_c.visible()) { glPointSize(vertex_size); glColor3f(vert_c.red(), vert_c.grn(), vert_c.blu()); glEnable(GL_POINT_SMOOTH); glBegin(GL_POINTS); glVertex2f(px, py); glEnd(); glDisable(GL_POINT_SMOOTH); } // Draw the labels unless either the viewer has it shut off OR if // the publisher of the point set the color to "invisible". if(draw_labels && labl_c.visible()) { glColor3f(labl_c.red(), labl_c.grn(), labl_c.blu()); gl_font(1, 10); string plabel = point.get_msg(); if(plabel == "") plabel = point.get_label(); if(plabel != "") { double offset = 3.0 * (1/m_zoom); glRasterPos3f(px+offset, py+offset, 0); gl_draw_aux(plabel); } } } } glFlush(); glPopMatrix(); } //------------------------------------------------------------- // Procedure: drawDropPoints void MarineViewer::drawDropPoints() { // If the viewable parameter is set to false just return. In // querying the parameter the optional "true" argument means return // true if nothing is known about the parameter. if(!m_geo_settings.viewable("drop_point_viewable_all", true)) return; //if(!m_drop_points.viewable()) // return; unsigned int i, vsize = m_drop_points.size(); for(i=0; i<vsize; i++) drawPoint(m_drop_points.point(i)); } //------------------------------------------------------------- // Procedure: drawText void MarineViewer::drawText(double px, double py, const string& text, const ColorPack& font_c, double font_size) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); double tx = meters2img('x', 0); double ty = meters2img('y', 0); double qx = img2view('x', tx); double qy = img2view('y', ty); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(qx, qy, 0); glScalef(m_zoom, m_zoom, m_zoom); px *= m_back_img.get_pix_per_mtr_x(); py *= m_back_img.get_pix_per_mtr_y(); if(font_c.visible()) { glColor3f(font_c.red(), font_c.grn(), font_c.blu()); gl_font(1, font_size); glRasterPos3f(px, py, 0); gl_draw_aux(text); } glFlush(); glPopMatrix(); } //------------------------------------------------------------- // Procedure: drawTextX void MarineViewer::drawTextX(double px, double py, const string& text, const ColorPack& font_c, double font_size) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w(), 0, h(), -1 ,1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); if(font_c.visible()) { glColor3f(font_c.red(), font_c.grn(), font_c.blu()); gl_font(1, font_size); glRasterPos3f(px, py, 0); gl_draw_aux(text); } glFlush(); glPopMatrix(); } //------------------------------------------------------------- // Procedure: gl_draw_aux() void MarineViewer::gl_draw_aux(const string text) { // To manage an FLTK 1.3.4 bug (?) check that the "current" drawing // window the same as the current window upon startup. Otherwis we // may see a crash in FLTK/src/gl_draw() as Fl_Window::curent() // returns a bad pointer. if(Fl_Window::current() == m_main_window) gl_draw(text.c_str()); }
29.337188
82
0.61889
EasternEdgeRobotics
0ee894ea808a002a8bda23f3932a6fccd11f3ea9
25,803
cxx
C++
Filters/ParallelDIY2/vtkDIYAggregateDataSetFilter.cxx
txwhhny/vtk
854d9aa87b944bc9079510515996406b98b86f7c
[ "BSD-3-Clause" ]
2
2021-07-07T22:53:19.000Z
2021-07-31T19:29:35.000Z
Filters/ParallelDIY2/vtkDIYAggregateDataSetFilter.cxx
txwhhny/vtk
854d9aa87b944bc9079510515996406b98b86f7c
[ "BSD-3-Clause" ]
2
2020-11-18T16:50:34.000Z
2022-01-21T13:31:47.000Z
Filters/ParallelDIY2/vtkDIYAggregateDataSetFilter.cxx
txwhhny/vtk
854d9aa87b944bc9079510515996406b98b86f7c
[ "BSD-3-Clause" ]
5
2020-10-02T10:14:35.000Z
2022-03-10T07:50:22.000Z
/*========================================================================= Program: Visualization Toolkit Module: vtkDIYAggregateDataSetFilter.cxx Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #include "vtkDIYAggregateDataSetFilter.h" #include "vtkCellData.h" #include "vtkExtentTranslator.h" #include "vtkExtractGrid.h" #include "vtkExtractRectilinearGrid.h" #include "vtkExtractVOI.h" #include "vtkIdList.h" #include "vtkImageData.h" #include "vtkInformation.h" #include "vtkInformationVector.h" #include "vtkMPI.h" #include "vtkMPICommunicator.h" #include "vtkMPIController.h" #include "vtkNew.h" #include "vtkObjectFactory.h" #include "vtkPointData.h" #include "vtkPoints.h" #include "vtkRectilinearGrid.h" #include "vtkSmartPointer.h" #include "vtkStreamingDemandDrivenPipeline.h" #include "vtkStructuredData.h" #include "vtkStructuredGrid.h" #include "vtkXMLImageDataReader.h" #include "vtkXMLImageDataWriter.h" #include "vtkXMLRectilinearGridReader.h" #include "vtkXMLRectilinearGridWriter.h" #include "vtkXMLStructuredGridReader.h" #include "vtkXMLStructuredGridWriter.h" #include <map> #include <set> // clang-format off #include "vtk_diy2.h" // must include this before any diy header #include VTK_DIY2(diy/assigner.hpp) #include VTK_DIY2(diy/link.hpp) #include VTK_DIY2(diy/master.hpp) #include VTK_DIY2(diy/mpi.hpp) #include VTK_DIY2(diy/reduce.hpp) #include VTK_DIY2(diy/partners/swap.hpp) #include VTK_DIY2(diy/decomposition.hpp) // clang-format on vtkStandardNewMacro(vtkDIYAggregateDataSetFilter); namespace { //------------------------------------------------------------------------------ inline diy::mpi::communicator GetDiyCommunicator(vtkMPIController* controller) { vtkMPICommunicator* vtkcomm = vtkMPICommunicator::SafeDownCast(controller->GetCommunicator()); return diy::mpi::communicator(*vtkcomm->GetMPIComm()->GetHandle()); } struct Block { // if we got more sophisticated with our use of DIY we'd take advantage of this // Block struct but for now we just leave it in as is. // The full input to the filter // vtkSmartPointer<vtkDataSet> OriginalPiece; // If we have non-empty output, these are the pieces that will be combined into FinalPiece // std::vector<vtkSmartPointer<vtkDataSet> > ReceivedPieces; // The full output from the filter vtkSmartPointer<vtkDataSet> FinalPiece; }; } //------------------------------------------------------------------------------ vtkDIYAggregateDataSetFilter::vtkDIYAggregateDataSetFilter() { this->OutputInitialized = false; } //------------------------------------------------------------------------------ vtkDIYAggregateDataSetFilter::~vtkDIYAggregateDataSetFilter() = default; //------------------------------------------------------------------------------ int vtkDIYAggregateDataSetFilter::RequestInformation( vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector) { vtkInformation* inputInfo = inputVector[0]->GetInformationObject(0); vtkInformation* outputInfo = outputVector->GetInformationObject(0); if (inputInfo->Has(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())) { int wholeExtent[6]; inputInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), wholeExtent); // Overwrite the whole extent if there's an input whole extent is set. This is needed // for distributed structured data. outputInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), wholeExtent, 6); } // We assume that whoever sets up the input handles partitioned data properly. // For structured data, this means setting up WHOLE_EXTENT as above. For // unstructured data, nothing special is required outputInfo->Set(CAN_HANDLE_PIECE_REQUEST(), 1); return 1; } //------------------------------------------------------------------------------ int vtkDIYAggregateDataSetFilter::RequestData( vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector) { vtkDataSet* input = nullptr; vtkDataSet* output = vtkDataSet::GetData(outputVector, 0); if (inputVector[0]->GetNumberOfInformationObjects() > 0) { input = vtkDataSet::GetData(inputVector[0], 0); } vtkMultiProcessController* controller = vtkMultiProcessController::GetGlobalController(); int numberOfProcesses = controller->GetNumberOfProcesses(); int myRank = controller->GetLocalProcessId(); if (numberOfProcesses == this->NumberOfTargetProcesses) { if (input) { output->ShallowCopy(input); } return 1; } if (input->IsA("vtkUnstructuredGrid") || input->IsA("vtkPolyData")) { // the superclass handles unstructured grids and polydata return this->Superclass::RequestData(request, inputVector, outputVector); } // mark that the output grid hasn't been touched yet this->OutputInitialized = false; // DIY bounds are really just based on extents vtkInformation* outputInfo = outputVector->GetInformationObject(0); int wholeExtent[6] = { 0, -1, 0, -1, 0, -1 }; // empty by default outputInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), wholeExtent); int outputExtent[6] = { 0, -1, 0, -1, 0, -1 }; // empty by default vtkNew<vtkExtentTranslator> extentTranslator; int targetProcessId = this->GetTargetProcessId(myRank, numberOfProcesses); if (targetProcessId != -1) { extentTranslator->PieceToExtentThreadSafe(targetProcessId, this->GetNumberOfTargetProcesses(), 0, wholeExtent, outputExtent, vtkExtentTranslator::BLOCK_MODE, 0); } if (vtkImageData* idOutput = vtkImageData::SafeDownCast(output)) { idOutput->SetExtent(outputExtent); } else if (vtkRectilinearGrid* rgOutput = vtkRectilinearGrid::SafeDownCast(output)) { rgOutput->SetExtent(outputExtent); } else if (vtkStructuredGrid* sgOutput = vtkStructuredGrid::SafeDownCast(output)) { sgOutput->SetExtent(outputExtent); } // map from the process rank to the serialized datasets that we'll be sending out via DIY std::map<int, std::string> serializedDataSets; int dimensions[3] = { 0, 0, 0 }; for (int i = 0; i < 3; i++) { if (wholeExtent[2 * i] < wholeExtent[2 * i + 1]) { dimensions[i] = 1; } } int inputExtent[6]; this->GetExtent(input, inputExtent); for (int proc = 0; proc < numberOfProcesses; proc++) { targetProcessId = this->GetTargetProcessId(proc, numberOfProcesses); if (targetProcessId != -1) { int targetProcessOutputExtent[6]; extentTranslator->PieceToExtentThreadSafe(targetProcessId, this->GetNumberOfTargetProcesses(), 0, wholeExtent, targetProcessOutputExtent, vtkExtentTranslator::BLOCK_MODE, 0); int overlappingExtent[6]; if (this->DoExtentsOverlap( inputExtent, targetProcessOutputExtent, dimensions, overlappingExtent)) { if (output->IsA("vtkImageData")) { vtkNew<vtkExtractVOI> imageDataExtractVOI; imageDataExtractVOI->SetVOI(overlappingExtent); imageDataExtractVOI->SetInputDataObject(input); if (proc == myRank) { imageDataExtractVOI->Update(); this->ExtractDataSetInformation(imageDataExtractVOI->GetOutput(), output); } else { vtkNew<vtkXMLImageDataWriter> writer; writer->SetInputConnection(imageDataExtractVOI->GetOutputPort()); writer->WriteToOutputStringOn(); writer->Write(); serializedDataSets[proc] = writer->GetOutputString(); } } else if (output->IsA("vtkRectilinearGrid")) { vtkNew<vtkExtractRectilinearGrid> rectilinearGridExtractVOI; rectilinearGridExtractVOI->SetVOI(overlappingExtent); rectilinearGridExtractVOI->SetInputDataObject(input); if (proc == myRank) { rectilinearGridExtractVOI->Update(); this->ExtractDataSetInformation(rectilinearGridExtractVOI->GetOutput(), output); } else { vtkNew<vtkXMLRectilinearGridWriter> writer; writer->SetInputConnection(rectilinearGridExtractVOI->GetOutputPort()); writer->WriteToOutputStringOn(); writer->Write(); serializedDataSets[proc] = writer->GetOutputString(); } } else if (output->IsA("vtkStructuredGrid")) { vtkNew<vtkExtractGrid> structuredGridExtractVOI; structuredGridExtractVOI->SetVOI(overlappingExtent); structuredGridExtractVOI->SetInputDataObject(input); if (proc == myRank) { structuredGridExtractVOI->Update(); this->ExtractDataSetInformation(structuredGridExtractVOI->GetOutput(), output); } else { vtkNew<vtkXMLStructuredGridWriter> writer; writer->SetInputConnection(structuredGridExtractVOI->GetOutputPort()); writer->WriteToOutputStringOn(); writer->Write(); serializedDataSets[proc] = writer->GetOutputString(); } } } } } std::vector<std::string> receivedDataSets; int retVal = this->MoveData(inputExtent, wholeExtent, outputExtent, serializedDataSets, receivedDataSets); // if we want to try using DIY to move the data we would just use the line below. when it was // tested // before there was an issue with the serialized imagedata string with DIY so due to time // constraints // we did an implementation with just using direct MPI data movement instead and left the DIY // around // in case others wanted to try using that without starting from scratch. // int retVal = this->MoveDataWithDIY(inputExtent, wholeExtent, outputExtent, serializedDataSets, // output); for (auto it : receivedDataSets) { vtkSmartPointer<vtkDataSet> tempDataSet = nullptr; if (output->IsA("vtkImageData")) { vtkNew<vtkXMLImageDataReader> reader; reader->ReadFromInputStringOn(); reader->SetInputString(it); reader->Update(); tempDataSet = reader->GetOutput(); } else if (output->IsA("vtkRectilinearGrid")) { vtkNew<vtkXMLRectilinearGridReader> reader; reader->ReadFromInputStringOn(); reader->SetInputString(it); reader->Update(); tempDataSet = reader->GetOutput(); } else if (output->IsA("vtkStructuredGrid")) { vtkNew<vtkXMLStructuredGridReader> reader; reader->ReadFromInputStringOn(); reader->SetInputString(it); reader->Update(); tempDataSet = reader->GetOutput(); } else { vtkErrorMacro("Cannot handle dataset type " << output->GetClassName()); return 0; } this->ExtractDataSetInformation(tempDataSet, output); } return retVal; } //------------------------------------------------------------------------------ int vtkDIYAggregateDataSetFilter::MoveDataWithDIY(int inputExtent[6], int wholeExtent[6], int outputExtent[6], std::map<int, std::string>& serializedDataSets, std::vector<std::string>& receivedDataSets) { vtkMultiProcessController* controller = vtkMultiProcessController::GetGlobalController(); int myRank = controller->GetLocalProcessId(); vtkNew<vtkIdList> processesIReceiveFrom; this->ComputeProcessesIReceiveFrom(inputExtent, wholeExtent, outputExtent, processesIReceiveFrom); diy::mpi::communicator comm = GetDiyCommunicator(vtkMPIController::SafeDownCast(controller)); diy::Master master(comm, 1); diy::RoundRobinAssigner assigner(comm.size(), comm.size()); Block block; diy::Link* link = new diy::Link; // master will delete this automatically for (auto it : serializedDataSets) { // processes I send data to diy::BlockID neighbor; neighbor.gid = it.first; neighbor.proc = assigner.rank(neighbor.gid); link->add_neighbor(neighbor); } for (vtkIdType i = 0; i < processesIReceiveFrom->GetNumberOfIds(); i++) { // processes I receive data from diy::BlockID neighbor; neighbor.gid = processesIReceiveFrom->GetId(i); neighbor.proc = assigner.rank(neighbor.gid); link->add_neighbor(neighbor); } master.add(myRank, &block, link); int counter = 0; for (auto it : serializedDataSets) { // processes I send data to master.proxy(0).enqueue(master.proxy(0).link()->target(counter), it.second); counter++; } master.exchange(); // does the communication const diy::Master::ProxyWithLink proxyWithLink = master.proxy(0); std::vector<int> in; proxyWithLink.incoming(in); receivedDataSets.clear(); for (size_t i = 0; i < in.size(); ++i) { if (proxyWithLink.incoming(in[i])) { receivedDataSets.push_back(""); proxyWithLink.dequeue(in[i], receivedDataSets.back()); // now deserialize... } } return 1; } //------------------------------------------------------------------------------ int vtkDIYAggregateDataSetFilter::MoveData(int inputExtent[6], int wholeExtent[6], int outputExtent[6], std::map<int, std::string>& serializedDataSets, std::vector<std::string>& receivedDataSets) { vtkMPIController* controller = vtkMPIController::SafeDownCast(vtkMultiProcessController::GetGlobalController()); vtkNew<vtkIdList> processesIReceiveFrom; this->ComputeProcessesIReceiveFrom(inputExtent, wholeExtent, outputExtent, processesIReceiveFrom); // map to keep track of the size of data I receive from each process std::vector<int> receiveSizes(processesIReceiveFrom->GetNumberOfIds(), 0); std::vector<vtkMPICommunicator::Request> sizeReceiveRequests( processesIReceiveFrom->GetNumberOfIds()); for (vtkIdType i = 0; i < processesIReceiveFrom->GetNumberOfIds(); i++) { controller->NoBlockReceive( receiveSizes.data() + i, 1, processesIReceiveFrom->GetId(i), 9318, sizeReceiveRequests[i]); } std::vector<vtkMPICommunicator::Request> sizeSendRequests(serializedDataSets.size()); int counter = 0; for (auto it : serializedDataSets) { int size = static_cast<int>(it.second.size()); controller->NoBlockSend(&size, 1, it.first, 9318, sizeSendRequests[counter]); counter++; } controller->WaitAll(static_cast<int>(sizeReceiveRequests.size()), sizeReceiveRequests.data()); std::vector<vtkMPICommunicator::Request> dataReceiveRequests( processesIReceiveFrom->GetNumberOfIds()); std::vector<unsigned char*> dataArrays; for (vtkIdType i = 0; i < processesIReceiveFrom->GetNumberOfIds(); i++) { int size = receiveSizes[i]; dataArrays.push_back(new unsigned char[size + 1]); dataArrays.back()[size] = '\0'; controller->NoBlockReceive( dataArrays.back(), size, processesIReceiveFrom->GetId(i), 9319, dataReceiveRequests[i]); } std::vector<vtkMPICommunicator::Request> dataSendRequests(serializedDataSets.size()); counter = 0; // deal with problems with not being able to get direct access to the string's memory. // in the future we may want to look at ways to make this more memory efficient. for // now it's not too bad though in that it really only has 2 copies of the sent data // to a single process since it clears out the string after it copies it over // to sendData. std::vector<std::vector<unsigned char>> sendData(serializedDataSets.size()); for (auto it : serializedDataSets) { int size = static_cast<int>(it.second.size()); sendData[counter].resize(size); for (int i = 0; i < size; i++) { sendData[counter][i] = static_cast<unsigned char>(it.second[i]); } it.second.clear(); // clear out the data controller->NoBlockSend( sendData[counter].data(), size, it.first, 9319, dataSendRequests[counter]); counter++; } controller->WaitAll(static_cast<int>(dataReceiveRequests.size()), dataReceiveRequests.data()); receivedDataSets.resize(processesIReceiveFrom->GetNumberOfIds()); for (vtkIdType i = 0; i < processesIReceiveFrom->GetNumberOfIds(); i++) { receivedDataSets[i].assign(reinterpret_cast<const char*>(dataArrays[i]), receiveSizes[i]); if (receivedDataSets[i].size() != static_cast<size_t>(receiveSizes[i])) { vtkErrorMacro("Problem deserializing dataset onto target process. Data from " << processesIReceiveFrom->GetId(i) << " should be size " << receiveSizes[i] << " but is size " << receivedDataSets[i].size()); return 0; } delete[] dataArrays[i]; } // wait on messages to make sure that we don't interfere with any future use of this filter controller->WaitAll(static_cast<int>(sizeSendRequests.size()), sizeSendRequests.data()); controller->WaitAll(static_cast<int>(dataSendRequests.size()), dataSendRequests.data()); return 1; } //------------------------------------------------------------------------------ void vtkDIYAggregateDataSetFilter::ComputeProcessesIReceiveFrom( int inputExtent[6], int wholeExtent[6], int outputExtent[6], vtkIdList* processesIReceiveFrom) { vtkMultiProcessController* controller = vtkMultiProcessController::GetGlobalController(); int myRank = controller->GetLocalProcessId(); int numberOfProcesses = controller->GetNumberOfProcesses(); int dimensions[3] = { 0, 0, 0 }; processesIReceiveFrom->SetNumberOfIds(0); for (int i = 0; i < 3; i++) { if (wholeExtent[2 * i] < wholeExtent[2 * i + 1]) { dimensions[i] = 1; } } // share the input extents so that we can figure out who we receive from int tempInputExtent[6]; std::copy(inputExtent, inputExtent + 6, tempInputExtent); std::vector<int> inputExtentsGlobal(6 * numberOfProcesses); controller->AllGather(tempInputExtent, inputExtentsGlobal.data(), 6); if (this->GetTargetProcessId(myRank, numberOfProcesses) != -1) { for (int proc = 0; proc < numberOfProcesses; proc++) { if (proc != myRank && this->DoExtentsOverlap(outputExtent, &inputExtentsGlobal[proc * 6], dimensions, nullptr)) { processesIReceiveFrom->InsertNextId(proc); } } } } //------------------------------------------------------------------------------ int vtkDIYAggregateDataSetFilter::GetTargetProcessId(int sourceProcessId, int numberOfProcesses) { if (this->GetNumberOfTargetProcesses() == 1) { return (sourceProcessId == 0 ? 0 : -1); } int spacing = numberOfProcesses / this->GetNumberOfTargetProcesses(); if ((sourceProcessId + 1) % spacing == 0) { return sourceProcessId / spacing; } return -1; } //------------------------------------------------------------------------------ bool vtkDIYAggregateDataSetFilter::DoExtentsOverlap( int extent1[6], int extent2[6], int dimensions[3], int* overlappingExtent) { for (int i = 0; i < 3; i++) { if (dimensions[i] != 0) { if (extent1[2 * i] >= extent2[2 * i + 1] || extent1[2 * i + 1] <= extent2[2 * i]) { return false; } } if (overlappingExtent) { overlappingExtent[2 * i] = std::max(extent1[2 * i], extent2[2 * i]); overlappingExtent[2 * i + 1] = std::min(extent1[2 * i + 1], extent2[2 * i + 1]); } } return true; } //------------------------------------------------------------------------------ void vtkDIYAggregateDataSetFilter::GetExtent(vtkDataSet* dataSet, int extent[6]) { if (vtkImageData* id = vtkImageData::SafeDownCast(dataSet)) { id->GetExtent(extent); } else if (vtkRectilinearGrid* rg = vtkRectilinearGrid::SafeDownCast(dataSet)) { rg->GetExtent(extent); } else if (vtkStructuredGrid* sg = vtkStructuredGrid::SafeDownCast(dataSet)) { sg->GetExtent(extent); } else { vtkErrorMacro("Unknown grid type " << dataSet->GetClassName()); } } //------------------------------------------------------------------------------ void vtkDIYAggregateDataSetFilter::ExtractDataSetInformation(vtkDataSet* source, vtkDataSet* target) { if (!source) { return; } int sourceExtent[6], targetExtent[6]; this->GetExtent(source, sourceExtent); this->GetExtent(target, targetExtent); if (!this->OutputInitialized) { target->GetFieldData()->ShallowCopy(source->GetFieldData()); if (vtkImageData* idSource = vtkImageData::SafeDownCast(source)) { vtkImageData* idTarget = vtkImageData::SafeDownCast(target); idTarget->SetOrigin(idSource->GetOrigin()); idTarget->SetSpacing(idSource->GetSpacing()); } else if (vtkRectilinearGrid* rgSource = vtkRectilinearGrid::SafeDownCast(source)) { vtkRectilinearGrid* rgTarget = vtkRectilinearGrid::SafeDownCast(target); vtkDataArray* xCoordinates = rgSource->GetXCoordinates()->NewInstance(); rgTarget->SetXCoordinates(xCoordinates); xCoordinates->SetNumberOfTuples(targetExtent[1] - targetExtent[0] + 1); xCoordinates->FastDelete(); vtkDataArray* yCoordinates = rgSource->GetYCoordinates()->NewInstance(); rgTarget->SetYCoordinates(yCoordinates); yCoordinates->SetNumberOfTuples(targetExtent[3] - targetExtent[2] + 1); yCoordinates->FastDelete(); vtkDataArray* zCoordinates = rgSource->GetZCoordinates()->NewInstance(); rgTarget->SetZCoordinates(zCoordinates); zCoordinates->SetNumberOfTuples(targetExtent[5] - targetExtent[4] + 1); zCoordinates->FastDelete(); } else if (vtkStructuredGrid* sgSource = vtkStructuredGrid::SafeDownCast(source)) { vtkStructuredGrid* sgTarget = vtkStructuredGrid::SafeDownCast(target); vtkNew<vtkPoints> points; points->SetDataType(sgSource->GetPoints()->GetDataType()); points->SetNumberOfPoints(vtkStructuredData::GetNumberOfPoints(targetExtent)); sgTarget->SetPoints(points); } else { vtkErrorMacro("Unknown dataset type " << source->GetClassName()); return; } } if (vtkRectilinearGrid* rgSource = vtkRectilinearGrid::SafeDownCast(source)) { vtkRectilinearGrid* rgTarget = vtkRectilinearGrid::SafeDownCast(target); vtkDataArray* sourceXCoordinates = rgSource->GetXCoordinates(); vtkDataArray* targetXCoordinates = rgTarget->GetXCoordinates(); this->ExtractRectilinearGridCoordinates( sourceExtent, targetExtent, sourceXCoordinates, targetXCoordinates); vtkDataArray* sourceYCoordinates = rgSource->GetYCoordinates(); vtkDataArray* targetYCoordinates = rgTarget->GetYCoordinates(); this->ExtractRectilinearGridCoordinates( sourceExtent + 2, targetExtent + 2, sourceYCoordinates, targetYCoordinates); vtkDataArray* sourceZCoordinates = rgSource->GetZCoordinates(); vtkDataArray* targetZCoordinates = rgTarget->GetZCoordinates(); this->ExtractRectilinearGridCoordinates( sourceExtent + 4, targetExtent + 4, sourceZCoordinates, targetZCoordinates); } else if (vtkStructuredGrid* sgSource = vtkStructuredGrid::SafeDownCast(source)) { vtkStructuredGrid* sgTarget = vtkStructuredGrid::SafeDownCast(target); vtkPoints* sourcePoints = sgSource->GetPoints(); vtkPoints* targetPoints = sgTarget->GetPoints(); for (int k = sourceExtent[4]; k <= sourceExtent[5]; k++) { if (targetExtent[4] <= k && k <= targetExtent[5]) { for (int j = sourceExtent[2]; j <= sourceExtent[3]; j++) { if (targetExtent[2] <= j + sourceExtent[2] && j <= targetExtent[3]) { for (int i = sourceExtent[0]; i <= sourceExtent[1]; i++) { if (targetExtent[0] <= i && i <= targetExtent[1]) { int ijk[3] = { i, j, k }; vtkIdType sourcePointId = vtkStructuredData::ComputePointIdForExtent(sourceExtent, ijk); vtkIdType targetPointId = vtkStructuredData::ComputePointIdForExtent(targetExtent, ijk); double coord[3]; sourcePoints->GetPoint(sourcePointId, coord); targetPoints->SetPoint(targetPointId, coord); } } } } } } } if (this->OutputInitialized) { target->GetPointData()->SetupForCopy(source->GetPointData()); target->GetCellData()->SetupForCopy(source->GetCellData()); } else { target->GetPointData()->CopyAllocate(source->GetPointData()); target->GetCellData()->CopyAllocate(source->GetCellData()); } target->GetPointData()->CopyStructuredData( source->GetPointData(), sourceExtent, targetExtent, !this->OutputInitialized); sourceExtent[1]--; sourceExtent[3]--; sourceExtent[5]--; targetExtent[1]--; targetExtent[3]--; targetExtent[5]--; target->GetCellData()->CopyStructuredData( source->GetCellData(), sourceExtent, targetExtent, !this->OutputInitialized); this->OutputInitialized = true; } //------------------------------------------------------------------------------ void vtkDIYAggregateDataSetFilter::ExtractRectilinearGridCoordinates(int* sourceExtent, int* targetExtent, vtkDataArray* sourceCoordinates, vtkDataArray* targetCoordinates) { for (int i = sourceExtent[0]; i <= sourceExtent[1]; i++) { if (targetExtent[0] <= i && i <= targetExtent[1]) { targetCoordinates->SetTuple1( i - targetExtent[0], sourceCoordinates->GetTuple1(i - sourceExtent[0])); } } } //------------------------------------------------------------------------------ void vtkDIYAggregateDataSetFilter::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os, indent); os << indent << "OutputInitialized: " << this->OutputInitialized << endl; }
37.180115
100
0.66252
txwhhny
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
0eec9613d28c91c9b291a0a14075471b9299f16f
32,922
cpp
C++
src/appleseed/renderer/meta/tests/test_transformsequence.cpp
PaulDoessel/appleseed
142908e05609cd802b3ab937ff27ef2b73dd3088
[ "MIT" ]
null
null
null
src/appleseed/renderer/meta/tests/test_transformsequence.cpp
PaulDoessel/appleseed
142908e05609cd802b3ab937ff27ef2b73dd3088
[ "MIT" ]
null
null
null
src/appleseed/renderer/meta/tests/test_transformsequence.cpp
PaulDoessel/appleseed
142908e05609cd802b3ab937ff27ef2b73dd3088
[ "MIT" ]
null
null
null
// // This source file is part of appleseed. // Visit http://appleseedhq.net/ for additional information and resources. // // This software is released under the MIT license. // // Copyright (c) 2010-2013 Francois Beaune, Jupiter Jazz Limited // Copyright (c) 2014-2016 Francois Beaune, The appleseedhq Organization // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // // appleseed.renderer headers. #include "renderer/utility/transformsequence.h" // appleseed.foundation headers. #include "foundation/math/aabb.h" #include "foundation/math/matrix.h" #include "foundation/math/scalar.h" #include "foundation/math/transform.h" #include "foundation/math/vector.h" #include "foundation/utility/iostreamop.h" #include "foundation/utility/test.h" #include "foundation/utility/vpythonfile.h" using namespace foundation; using namespace renderer; TEST_SUITE(Renderer_Utility_TransformSequence) { TEST_CASE(Clear_GivenSequenceWithOneTransform_RemovesTransform) { TransformSequence sequence; sequence.set_transform(1.0f, Transformd::identity()); sequence.clear(); EXPECT_TRUE(sequence.empty()); } TEST_CASE(SetTransform_GivenTimeAtWhichNoTransformExists_AddsTransform) { const Transformd ExpectedTransform( Transformd::from_local_to_parent( Matrix4d::make_translation(Vector3d(1.0, 2.0, 3.0)))); TransformSequence sequence; sequence.set_transform(1.0f, ExpectedTransform); float time; Transformd transform; sequence.get_transform(0, time, transform); EXPECT_EQ(1.0f, time); EXPECT_EQ(ExpectedTransform, transform); } TEST_CASE(SetTransform_GivenTimeOfExistingTransform_ReplacesTransform) { const Transformd OldTransform( Transformd::from_local_to_parent( Matrix4d::make_translation(Vector3d(1.0, 2.0, 3.0)))); const Transformd NewTransform( Transformd::from_local_to_parent( Matrix4d::make_translation(Vector3d(4.0, 5.0, 6.0)))); TransformSequence sequence; sequence.set_transform(1.0f, OldTransform); sequence.set_transform(1.0f, NewTransform); float time; Transformd transform; sequence.get_transform(0, time, transform); EXPECT_EQ(1.0f, time); EXPECT_EQ(NewTransform, transform); } TEST_CASE(GetEarliestTransform_EmptySequence_ReturnsIdentity) { const TransformSequence sequence; EXPECT_EQ(Transformd::identity(), sequence.get_earliest_transform()); } TEST_CASE(GetEarliestTransform_EarliestTransformIsFirst) { const Transformd Transform1( Transformd::from_local_to_parent( Matrix4d::make_translation(Vector3d(1.0, 2.0, 3.0)))); const Transformd Transform2( Transformd::from_local_to_parent( Matrix4d::make_translation(Vector3d(4.0, 5.0, 6.0)))); TransformSequence sequence; sequence.set_transform(1.0f, Transform1); sequence.set_transform(2.0f, Transform2); EXPECT_EQ(Transform1, sequence.get_earliest_transform()); } TEST_CASE(GetEarliestTransform_EarliestTransformIsLast) { const Transformd Transform1( Transformd::from_local_to_parent( Matrix4d::make_translation(Vector3d(1.0, 2.0, 3.0)))); const Transformd Transform2( Transformd::from_local_to_parent( Matrix4d::make_translation(Vector3d(4.0, 5.0, 6.0)))); TransformSequence sequence; sequence.set_transform(2.0f, Transform2); sequence.set_transform(1.0f, Transform1); EXPECT_EQ(Transform1, sequence.get_earliest_transform()); } TEST_CASE(Empty_GivenDefaultConstructedSequence_ReturnsTrue) { TransformSequence sequence; EXPECT_TRUE(sequence.empty()); } TEST_CASE(Empty_AfterSettingOneTransform_ReturnsFalse) { TransformSequence sequence; sequence.set_transform(1.0f, Transformd::identity()); EXPECT_FALSE(sequence.empty()); } TEST_CASE(Size_GivenDefaultConstructedSequence_ReturnsZero) { TransformSequence sequence; EXPECT_EQ(0, sequence.size()); } TEST_CASE(Size_AfterSettingOneTransform_ReturnsOne) { TransformSequence sequence; sequence.set_transform(1.0f, Transformd::identity()); EXPECT_EQ(1, sequence.size()); } TEST_CASE(Size_AfterSettingTwoTransformsAtDistinctTimes_ReturnsTwo) { TransformSequence sequence; sequence.set_transform(1.0f, Transformd::identity()); sequence.set_transform(3.0f, Transformd::identity()); EXPECT_EQ(2, sequence.size()); } TEST_CASE(Size_AfterSettingTwoTransformsAtSameTime_ReturnsOne) { TransformSequence sequence; sequence.set_transform(1.0f, Transformd::identity()); sequence.set_transform(1.0f, Transformd::identity()); EXPECT_EQ(1, sequence.size()); } static const Transformd A = Transformd::identity(); static const Transformd B = Transformd::from_local_to_parent( Matrix4d::make_translation(Vector3d(1.0, 2.0, 3.0))); float get_time(const TransformSequence& sequence, const size_t index) { float time; Transformd transform; sequence.get_transform(index, time, transform); return time; } Transformd get_transform(const TransformSequence& sequence, const size_t index) { float time; Transformd transform; sequence.get_transform(index, time, transform); return transform; } TEST_CASE(Optimize_GivenEmptySequence_DoesNothing) { TransformSequence sequence; sequence.optimize(); EXPECT_TRUE(sequence.empty()); } TEST_CASE(Optimize_GivenA_DoesNothing) { TransformSequence sequence; sequence.set_transform(1.0f, A); sequence.optimize(); ASSERT_EQ(1, sequence.size()); EXPECT_EQ(A, get_transform(sequence, 0)); } TEST_CASE(Optimize_GivenAB_DoesNothing) { TransformSequence sequence; sequence.set_transform(1.0f, A); sequence.set_transform(2.0f, B); sequence.optimize(); ASSERT_EQ(2, sequence.size()); EXPECT_EQ(A, get_transform(sequence, 0)); EXPECT_EQ(B, get_transform(sequence, 1)); } TEST_CASE(Optimize_GivenAA_CollapsesToA) { TransformSequence sequence; sequence.set_transform(1.0f, A); sequence.set_transform(2.0f, A); sequence.optimize(); ASSERT_EQ(1, sequence.size()); EXPECT_EQ(A, get_transform(sequence, 0)); EXPECT_EQ(2.0f, get_time(sequence, 0)); } TEST_CASE(Optimize_GivenAAB_CollapsesToAB) { TransformSequence sequence; sequence.set_transform(1.0f, A); sequence.set_transform(2.0f, A); sequence.set_transform(3.0f, B); sequence.optimize(); ASSERT_EQ(2, sequence.size()); EXPECT_EQ(A, get_transform(sequence, 0)); EXPECT_EQ(2.0f, get_time(sequence, 0)); EXPECT_EQ(B, get_transform(sequence, 1)); EXPECT_EQ(3.0f, get_time(sequence, 1)); } TEST_CASE(Optimize_GivenBAA_CollapsesToBA) { TransformSequence sequence; sequence.set_transform(1.0f, B); sequence.set_transform(2.0f, A); sequence.set_transform(3.0f, A); sequence.optimize(); ASSERT_EQ(2, sequence.size()); EXPECT_EQ(B, get_transform(sequence, 0)); EXPECT_EQ(1.0f, get_time(sequence, 0)); EXPECT_EQ(A, get_transform(sequence, 1)); EXPECT_EQ(2.0f, get_time(sequence, 1)); } TEST_CASE(Optimize_GivenABBA_DoesNothing) { TransformSequence sequence; sequence.set_transform(1.0f, A); sequence.set_transform(2.0f, B); sequence.set_transform(3.0f, B); sequence.set_transform(4.0f, A); sequence.optimize(); ASSERT_EQ(4, sequence.size()); EXPECT_EQ(A, get_transform(sequence, 0)); EXPECT_EQ(B, get_transform(sequence, 1)); EXPECT_EQ(B, get_transform(sequence, 2)); EXPECT_EQ(A, get_transform(sequence, 3)); } TEST_CASE(Prepare_GivenEmptySequence_ReturnsTrue) { TransformSequence sequence; const bool success = sequence.prepare(); EXPECT_TRUE(success); } TEST_CASE(Evaluate_GivenNoTransform_ReturnsIdentityTransformRegardlessOfTime) { const Transformd ExpectedTransform(Transformd::identity()); TransformSequence sequence; sequence.prepare(); EXPECT_EQ(ExpectedTransform, sequence.evaluate(0.0)); EXPECT_EQ(ExpectedTransform, sequence.evaluate(1.0)); EXPECT_EQ(ExpectedTransform, sequence.evaluate(2.0)); } TEST_CASE(Evaluate_GivenSingleTransform_ReturnsTransformRegardlessOfTime) { const Transformd ExpectedTransform( Transformd::from_local_to_parent( Matrix4d::make_translation(Vector3d(1.0, 2.0, 3.0)))); TransformSequence sequence; sequence.set_transform(1.0f, ExpectedTransform); sequence.prepare(); EXPECT_EQ(ExpectedTransform, sequence.evaluate(0.0)); EXPECT_EQ(ExpectedTransform, sequence.evaluate(1.0)); EXPECT_EQ(ExpectedTransform, sequence.evaluate(2.0)); } struct TwoTransformsFixture { const Transformd m_expected_first_transform; const Transformd m_expected_second_transform; TransformSequence m_sequence; TwoTransformsFixture() : m_expected_first_transform( Transformd::from_local_to_parent( Matrix4d::make_translation(Vector3d(1.0, 2.0, 3.0)))) , m_expected_second_transform( Transformd::from_local_to_parent( Matrix4d::make_translation(Vector3d(4.0, 5.0, 6.0)))) { m_sequence.set_transform(1.0f, m_expected_first_transform); m_sequence.set_transform(3.0f, m_expected_second_transform); m_sequence.prepare(); } }; TEST_CASE_F(CopyConstructor_CopiesTransformInterpolators, TwoTransformsFixture) { TransformSequence copy(m_sequence); EXPECT_EQ(m_expected_first_transform, copy.evaluate(0.0)); } TEST_CASE_F(Evaluate_GivenTwoTransforms_WhenTimeBeforeFirstTransform_ReturnsFirstTransform, TwoTransformsFixture) { EXPECT_EQ(m_expected_first_transform, m_sequence.evaluate(0.0)); } TEST_CASE_F(Evaluate_GivenTwoTransforms_WhenTimeAfterLastTransform_ReturnsLastTransform, TwoTransformsFixture) { EXPECT_EQ(m_expected_second_transform, m_sequence.evaluate(4.0)); } TEST_CASE_F(Evaluate_GivenTwoTransforms_WhenTimeBetweenTwoTransforms_ReturnsInterpolatedTransform, TwoTransformsFixture) { const TransformInterpolatord interpolator( m_expected_first_transform, m_expected_second_transform); Transformd expected; interpolator.evaluate(0.5, expected); EXPECT_FEQ(expected, m_sequence.evaluate(2.0)); } TEST_CASE(Evaluate_GivenTwoTransformsSetInReverseOrder_ReturnsCorrectlyInterpolatedTransform) { const Transformd ExpectedFirstTransform( Transformd::from_local_to_parent( Matrix4d::make_translation(Vector3d(1.0, 2.0, 3.0)))); const Transformd ExpectedSecondTransform( Transformd::from_local_to_parent( Matrix4d::make_translation(Vector3d(4.0, 5.0, 6.0)))); TransformSequence sequence; sequence.set_transform(3.0f, ExpectedSecondTransform); sequence.set_transform(1.0f, ExpectedFirstTransform); sequence.prepare(); const TransformInterpolatord interpolator( ExpectedFirstTransform, ExpectedSecondTransform); Transformd expected; interpolator.evaluate(0.5, expected); EXPECT_FEQ(expected, sequence.evaluate(2.0)); } TEST_CASE(CompositionOperator_GivenTwoEmptyTransformSequences_ReturnsEmptyTransformSequence) { TransformSequence seq1, seq2; const TransformSequence result = seq1 * seq2; EXPECT_TRUE(result.empty()); } TEST_CASE(CompositionOperator_GivenEmptyAndNonEmptyTransformSequences_ReturnsNonEmptyTransformSequence) { TransformSequence seq1; seq1.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_translation(Vector3d(1.0, 2.0, 3.0)))); TransformSequence seq2; const TransformSequence result = seq1 * seq2; ASSERT_EQ(1, result.size()); float time; Transformd transform; result.get_transform(0, time, transform); EXPECT_EQ(1.0f, time); EXPECT_EQ( Transformd::from_local_to_parent(Matrix4d::make_translation(Vector3d(1.0, 2.0, 3.0))), transform); } TEST_CASE(CompositionOperator_GivenTwoNonEmptyTransformSequencesWithCoincidentTimes_ReturnsTransformSequenceWithSameNumberOfTransforms) { TransformSequence seq1; seq1.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(1.0, 0, 0), HalfPi<double>()))); TransformSequence seq2; seq2.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_translation(Vector3d(1.0, 2.0, 3.0)))); const TransformSequence result = seq1 * seq2; ASSERT_EQ(1, result.size()); float time; Transformd transform; result.get_transform(0, time, transform); EXPECT_EQ(1.0f, time); EXPECT_EQ( Transformd::from_local_to_parent(Matrix4d::make_rotation(Vector3d(1.0, 0, 0), HalfPi<double>())) * Transformd::from_local_to_parent(Matrix4d::make_translation(Vector3d(1.0, 2.0, 3.0))), transform); } TEST_CASE(CompositionOperator_GivenTwoNonEmptyTransformSequencesWithDistinctTimes_ReturnsTransformSequenceWithCumulatedNumberOfTransforms) { TransformSequence seq1; seq1.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(1.0, 0, 0), HalfPi<double>()))); TransformSequence seq2; seq2.set_transform( 2.0f, Transformd::from_local_to_parent( Matrix4d::make_translation(Vector3d(1.0, 2.0, 3.0)))); const TransformSequence result = seq1 * seq2; ASSERT_EQ(2, result.size()); { float time; Transformd transform; result.get_transform(0, time, transform); EXPECT_EQ(1.0f, time); EXPECT_EQ( Transformd::from_local_to_parent(Matrix4d::make_rotation(Vector3d(1.0, 0, 0), HalfPi<double>())) * Transformd::from_local_to_parent(Matrix4d::make_translation(Vector3d(1.0, 2.0, 3.0))), transform); } { float time; Transformd transform; result.get_transform(1, time, transform); EXPECT_EQ(2.0f, time); EXPECT_EQ( Transformd::from_local_to_parent(Matrix4d::make_rotation(Vector3d(1.0, 0, 0), HalfPi<double>())) * Transformd::from_local_to_parent(Matrix4d::make_translation(Vector3d(1.0, 2.0, 3.0))), transform); } } TEST_CASE(ToParent_SmallPositiveRotation) { TransformSequence sequence; sequence.set_transform( 0.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), 0.0))); sequence.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), Pi<double>() / 8))); sequence.prepare(); const AABB3d bbox(Vector3d(1.0, 1.0, 0.0), Vector3d(1.0, 1.0, 0.0)); const AABB3d motion_bbox = sequence.to_parent(bbox); EXPECT_FEQ_EPS(AABB3d(Vector3d(0.54119610014619690, 1.0, 0.0), Vector3d(1.0, 1.3065629648763766, 0.0)), motion_bbox, 1.0e-3); } TEST_CASE(ToParent_SmallNegativeRotation) { TransformSequence sequence; sequence.set_transform( 0.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), 0.0))); sequence.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), -Pi<double>() / 8))); sequence.prepare(); const AABB3d bbox(Vector3d(1.0, 1.0, 0.0), Vector3d(1.0, 1.0, 0.0)); const AABB3d motion_bbox = sequence.to_parent(bbox); EXPECT_FEQ_EPS(AABB3d(Vector3d(1.0, 0.54119610014619690, 0.0), Vector3d(1.3065629648763766, 1.0, 0.0)), motion_bbox, 1.0e-3); } TEST_CASE(ToParent_LargePositiveRotation) { TransformSequence sequence; sequence.set_transform( 0.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), 0.0))); sequence.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), Pi<double>() - Pi<double>() / 8))); sequence.prepare(); const AABB3d bbox(Vector3d(1.0, 1.0, 0.0), Vector3d(1.0, 1.0, 0.0)); const AABB3d motion_bbox = sequence.to_parent(bbox); EXPECT_FEQ_EPS(AABB3d(Vector3d(-1.4142135623730949, -0.54119610014619690, 0.0), Vector3d(1.0, 1.4142135623730949, 0.0)), motion_bbox, 1.0e-3); } TEST_CASE(ToParent_LargeNegativeRotation) { TransformSequence sequence; sequence.set_transform( 0.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), 0.0))); sequence.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), -Pi<double>() + Pi<double>() / 8))); sequence.prepare(); const AABB3d bbox(Vector3d(1.0, 1.0, 0.0), Vector3d(1.0, 1.0, 0.0)); const AABB3d motion_bbox = sequence.to_parent(bbox); EXPECT_FEQ_EPS(AABB3d(Vector3d(-0.54119610014619690, -1.4142135623730951, 0.0), Vector3d(1.4142135623730949, 1.0, 0.0)), motion_bbox, 1.0e-3); } void visualize( const char* filename, const TransformSequence& sequence, const AABB3d& bbox) { const double Width = 0.01; const size_t Steps = 10; const AABB3d motion_bbox = sequence.to_parent(bbox); VPythonFile file(filename); file.draw_axes(Width); for (size_t i = 0; i < Steps; ++i) { const float t = fit<size_t, float>(i, 0, Steps - 1, 0.0f, 1.0f); const Transformd transform = sequence.evaluate(t); const char* color = i == 0 ? "color.yellow" : i == Steps - 1 ? "color.white" : "color.blue"; file.draw_aabb(transform.to_parent(bbox), color, Width); file.draw_arrow(Vector3d(0.0), transform.point_to_parent(bbox.center()), color, Width); } file.draw_aabb(motion_bbox, "color.magenta", Width); } TEST_CASE(ToParent_GivenPoint_VisualizeSmallPositiveRotation) { TransformSequence sequence; sequence.set_transform( 0.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), 0.0))); sequence.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), Pi<double>() / 8))); sequence.prepare(); const AABB3d bbox(Vector3d(1.0, 1.0, 0.0), Vector3d(1.0, 1.0, 0.0)); visualize( "unit tests/outputs/test_transformsequence_toparent_givenpoint_smallpositiverotation.py", sequence, bbox); } TEST_CASE(ToParent_GivenPoint_VisualizeSmallNegativeRotation) { TransformSequence sequence; sequence.set_transform( 0.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), 0.0))); sequence.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), -Pi<double>() / 8))); sequence.prepare(); const AABB3d bbox(Vector3d(1.0, 1.0, 0.0), Vector3d(1.0, 1.0, 0.0)); visualize( "unit tests/outputs/test_transformsequence_toparent_givenpoint_smallnegativerotation.py", sequence, bbox); } TEST_CASE(ToParent_GivenPoint_VisualizeLargePositiveRotation) { TransformSequence sequence; sequence.set_transform( 0.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), 0.0))); sequence.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), Pi<double>() - Pi<double>() / 8))); sequence.prepare(); const AABB3d bbox(Vector3d(-1.0, -1.0, 0.0), Vector3d(-1.0, -1.0, 0.0)); visualize( "unit tests/outputs/test_transformsequence_toparent_givenpoint_largepositiverotation.py", sequence, bbox); } TEST_CASE(ToParent_GivenPoint_VisualizeLargeNegativeRotation) { TransformSequence sequence; sequence.set_transform( 0.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), 0.0))); sequence.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), -Pi<double>() + Pi<double>() / 8))); sequence.prepare(); const AABB3d bbox(Vector3d(-1.0, -1.0, 0.0), Vector3d(-1.0, -1.0, 0.0)); visualize( "unit tests/outputs/test_transformsequence_toparent_givenpoint_largenegativerotation.py", sequence, bbox); } TEST_CASE(ToParent_GivenAABB_VisualizeLargePositiveRotationWithUnitScaling) { TransformSequence sequence; sequence.set_transform( 0.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), 0.0))); sequence.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), Pi<double>() - Pi<double>() / 8))); sequence.prepare(); const AABB3d bbox(Vector3d(-2.0, -2.0, -0.5), Vector3d(-1.0, -1.0, 0.5)); visualize( "unit tests/outputs/test_transformsequence_toparent_givenaabb_largepositiverotationwithunitscaling.py", sequence, bbox); } TEST_CASE(ToParent_GivenAABB_VisualizeLargePositiveRotationWithConstantScaling) { TransformSequence sequence; sequence.set_transform( 0.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), 0.0) * Matrix4d::make_scaling(Vector3d(0.2)))); sequence.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), Pi<double>() - Pi<double>() / 8) * Matrix4d::make_scaling(Vector3d(0.2)))); sequence.prepare(); const AABB3d bbox(Vector3d(-20.0, -20.0, -5.0), Vector3d(-10.0, -10.0, 5.0)); visualize( "unit tests/outputs/test_transformsequence_toparent_givenaabb_largepositiverotationwithconstantscaling.py", sequence, bbox); } TEST_CASE(ToParent_GivenAABB_VisualizeLargePositiveRotationWithVaryingScaling) { TransformSequence sequence; sequence.set_transform( 0.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), 0.0) * Matrix4d::make_scaling(Vector3d(0.1)))); sequence.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), Pi<double>() - Pi<double>() / 8) * Matrix4d::make_scaling(Vector3d(0.2)))); sequence.prepare(); const AABB3d bbox(Vector3d(-20.0, -20.0, -5.0), Vector3d(-10.0, -10.0, 5.0)); visualize( "unit tests/outputs/test_transformsequence_toparent_givenaabb_largepositiverotationwithvaryingscaling.py", sequence, bbox); } TEST_CASE(ToParent_GivenAABB_VisualizeLargePositiveRotationWithVaryingScalingAndTranslation) { TransformSequence sequence; sequence.set_transform( 0.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), 0.0) * Matrix4d::make_scaling(Vector3d(0.1)))); sequence.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_translation(Vector3d(20.0, 0.0, 0.0)) * Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), Pi<double>() - Pi<double>() / 8) * Matrix4d::make_scaling(Vector3d(0.2)))); sequence.prepare(); const AABB3d bbox(Vector3d(-20.0, -20.0, -5.0), Vector3d(-10.0, -10.0, 5.0)); visualize( "unit tests/outputs/test_transformsequence_toparent_givenaabb_largepositiverotationwithvaryingscalingandtranslation.py", sequence, bbox); } TEST_CASE(ToParent_GivenAABB_VisualizeLargeNegativeRotationWithUnitScaling) { TransformSequence sequence; sequence.set_transform( 0.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), 0.0))); sequence.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), -Pi<double>() + Pi<double>() / 8))); sequence.prepare(); const AABB3d bbox(Vector3d(-2.0, -2.0, -0.5), Vector3d(-1.0, -1.0, 0.5)); visualize( "unit tests/outputs/test_transformsequence_toparent_givenaabb_largenegativerotationwithunitscaling.py", sequence, bbox); } TEST_CASE(ToParent_GivenAABB_VisualizeLargeNegativeRotationWithConstantScaling) { TransformSequence sequence; sequence.set_transform( 0.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), 0.0) * Matrix4d::make_scaling(Vector3d(0.2)))); sequence.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), -Pi<double>() + Pi<double>() / 8) * Matrix4d::make_scaling(Vector3d(0.2)))); sequence.prepare(); const AABB3d bbox(Vector3d(-20.0, -20.0, -5.0), Vector3d(-10.0, -10.0, 5.0)); visualize( "unit tests/outputs/test_transformsequence_toparent_givenaabb_largenegativerotationwithconstantscaling.py", sequence, bbox); } TEST_CASE(ToParent_GivenAABB_VisualizeLargeNegativeRotationWithVaryingScaling) { TransformSequence sequence; sequence.set_transform( 0.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), 0.0) * Matrix4d::make_scaling(Vector3d(0.1)))); sequence.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_rotation(Vector3d(0.0, 0.0, 1.0), -Pi<double>() + Pi<double>() / 8) * Matrix4d::make_scaling(Vector3d(0.2)))); sequence.prepare(); const AABB3d bbox(Vector3d(-20.0, -20.0, -5.0), Vector3d(-10.0, -10.0, 5.0)); visualize( "unit tests/outputs/test_transformsequence_toparent_givenaabb_largenegativerotationwithvaryingscaling.py", sequence, bbox); } TEST_CASE(ToParent_GivenAABB_VisualizeVaryingScalingOnly) { TransformSequence sequence; sequence.set_transform( 0.0f, Transformd::from_local_to_parent( Matrix4d::make_scaling(Vector3d(0.1)))); sequence.set_transform( 1.0f, Transformd::from_local_to_parent( Matrix4d::make_scaling(Vector3d(0.2)))); sequence.prepare(); const AABB3d bbox(Vector3d(-20.0, -20.0, -5.0), Vector3d(-10.0, -10.0, 5.0)); visualize( "unit tests/outputs/test_transformsequence_toparent_givenaabb_scalingonly.py", sequence, bbox); } TEST_CASE(TestSwapsHandednessNegativeScale1Axis) { TransformSequence sequence; Matrix4d m = Matrix4d::make_rotation_x(Pi<double>() / 4.0) * Matrix4d::make_scaling(Vector3d(1.0, 1.0, 0.5)); sequence.set_transform( 0.0f, Transformd::from_local_to_parent(m)); m = Matrix4d::make_rotation_x(Pi<double>() / 2.0) * Matrix4d::make_scaling(Vector3d(2.0, -3.0, 0.5)); sequence.set_transform( 1.0f, Transformd::from_local_to_parent(m)); sequence.prepare(); EXPECT_TRUE(sequence.can_swap_handedness()); const Transformd xform = sequence.evaluate(0.5); EXPECT_EQ(xform.swaps_handedness(), sequence.swaps_handedness(xform)); } TEST_CASE(TestSwapsHandednessNegativeScale2Axes) { TransformSequence sequence; Matrix4d m = Matrix4d::make_rotation_y(Pi<double>() / 2.0) * Matrix4d::make_scaling(Vector3d(-1.0, -2.0, 0.5)); sequence.set_transform( 0.0f, Transformd::from_local_to_parent(m)); m = Matrix4d::make_rotation_z(Pi<double>() / 3.0) * Matrix4d::make_scaling(Vector3d(-1.0, -1.0, 1.5)); sequence.set_transform( 1.0f, Transformd::from_local_to_parent(m)); sequence.prepare(); EXPECT_FALSE(sequence.can_swap_handedness()); const Transformd xform = sequence.evaluate(0.5); EXPECT_EQ(xform.swaps_handedness(), sequence.swaps_handedness(xform)); } TEST_CASE(TestSwapsHandednessPositiveAndNegativeScales) { TransformSequence sequence; Matrix4d m = Matrix4d::make_rotation_y(Pi<double>() / 2.0) * Matrix4d::make_scaling(Vector3d(1.0, 2.0, 0.5)); sequence.set_transform( 0.0f, Transformd::from_local_to_parent(m)); m = Matrix4d::make_rotation_z(Pi<double>() / 3.0) * Matrix4d::make_scaling(Vector3d(-1.0, 1.0, 1.5)); sequence.set_transform( 1.0f, Transformd::from_local_to_parent(m)); sequence.prepare(); EXPECT_TRUE(sequence.can_swap_handedness()); const Transformd xform = sequence.evaluate(0.5); EXPECT_EQ(xform.swaps_handedness(), sequence.swaps_handedness(xform)); } }
34.509434
150
0.630156
PaulDoessel
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
0eefe8f35b6b6cd9afdac061e2402b7b8c4d1cc0
2,834
cc
C++
third_party/blink/renderer/platform/loader/fetch/cached_metadata.cc
chromium/chromium
df46e572c3449a4b108d6e02fbe4f6d24cf98381
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
14,668
2015-01-01T01:57:10.000Z
2022-03-31T23:33:32.000Z
third_party/blink/renderer/platform/loader/fetch/cached_metadata.cc
chromium/chromium
df46e572c3449a4b108d6e02fbe4f6d24cf98381
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
86
2015-10-21T13:02:42.000Z
2022-03-14T07:50:50.000Z
third_party/blink/renderer/platform/loader/fetch/cached_metadata.cc
chromium/chromium
df46e572c3449a4b108d6e02fbe4f6d24cf98381
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
5,941
2015-01-02T11:32:21.000Z
2022-03-31T16:35:46.000Z
// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "third_party/blink/renderer/platform/loader/fetch/cached_metadata.h" #include "third_party/blink/renderer/platform/loader/fetch/url_loader/cached_metadata_handler.h" namespace blink { scoped_refptr<CachedMetadata> CachedMetadata::CreateFromSerializedData( const uint8_t* data, size_t size) { if (size > std::numeric_limits<wtf_size_t>::max()) return nullptr; Vector<uint8_t> copied_data; copied_data.Append(data, static_cast<wtf_size_t>(size)); return CreateFromSerializedData(std::move(copied_data)); } scoped_refptr<CachedMetadata> CachedMetadata::CreateFromSerializedData( Vector<uint8_t> data) { // Ensure the data is big enough, otherwise discard the data. if (data.size() < kCachedMetaDataStart) return nullptr; // Ensure the marker matches, otherwise discard the data. if (*reinterpret_cast<const uint32_t*>(data.data()) != CachedMetadataHandler::kSingleEntry) { return nullptr; } return base::AdoptRef(new CachedMetadata(std::move(data))); } scoped_refptr<CachedMetadata> CachedMetadata::CreateFromSerializedData( mojo_base::BigBuffer data) { // Ensure the data is big enough, otherwise discard the data. if (data.size() < kCachedMetaDataStart) return nullptr; // Ensure the marker matches, otherwise discard the data. if (*reinterpret_cast<const uint32_t*>(data.data()) != CachedMetadataHandler::kSingleEntry) { return nullptr; } return base::AdoptRef(new CachedMetadata(std::move(data))); } CachedMetadata::CachedMetadata(Vector<uint8_t> data) { // Serialized metadata should have non-empty data. DCHECK_GT(data.size(), kCachedMetaDataStart); DCHECK(!data.IsEmpty()); // Make sure that the first int in the data is the single entry marker. CHECK_EQ(*reinterpret_cast<const uint32_t*>(data.data()), CachedMetadataHandler::kSingleEntry); vector_ = std::move(data); } CachedMetadata::CachedMetadata(uint32_t data_type_id, const uint8_t* data, wtf_size_t size) { // Don't allow an ID of 0, it is used internally to indicate errors. DCHECK(data_type_id); DCHECK(data); vector_ = CachedMetadata::GetSerializedDataHeader(data_type_id, size); vector_.Append(data, size); } CachedMetadata::CachedMetadata(mojo_base::BigBuffer data) { // Serialized metadata should have non-empty data. DCHECK_GT(data.size(), kCachedMetaDataStart); // Make sure that the first int in the data is the single entry marker. CHECK_EQ(*reinterpret_cast<const uint32_t*>(data.data()), CachedMetadataHandler::kSingleEntry); buffer_ = std::move(data); } } // namespace blink
35.425
96
0.728652
chromium
0ef01f4c9a0210e673f49641c079f533949b22b4
674
cpp
C++
main/c++-stl/c++-stl-set5-queue.cpp
EliahKagan/old-practice-snapshot
1b53897eac6902f8d867c8f154ce2a489abb8133
[ "0BSD" ]
null
null
null
main/c++-stl/c++-stl-set5-queue.cpp
EliahKagan/old-practice-snapshot
1b53897eac6902f8d867c8f154ce2a489abb8133
[ "0BSD" ]
null
null
null
main/c++-stl/c++-stl-set5-queue.cpp
EliahKagan/old-practice-snapshot
1b53897eac6902f8d867c8f154ce2a489abb8133
[ "0BSD" ]
null
null
null
/*You are required to complete below methods*/ /*inserts an element x at the back of the queue q */ void push(queue<int> &q,int x) { q.push(x); } /*pop out the front element from the queue q and returns it */ int pop(queue<int> &q) { if (q.empty()) return -1; const auto x = q.front(); q.pop(); return x; } /*returns the size of the queue q */ int getSize(queue<int> &q) { return q.size(); } /*returns the last element of the queue */ int getBack(queue<int> &q) { if (q.empty()) return -1; return q.back(); } /*returns the first element of the queue */ int getFront(queue<int> &q) { if (q.empty()) return -1; return q.front(); }
16.85
46
0.61276
EliahKagan
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: russ@q12.org 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
0efcabbab25896492010675aa3cb37b796bfe7b9
3,095
hpp
C++
src/subset_relrate_updater.hpp
plewis/hpd-histogram
4cc35206e0505127bffe9db6f650852f07bb7f63
[ "MIT" ]
1
2021-06-17T17:07:24.000Z
2021-06-17T17:07:24.000Z
src/subset_relrate_updater.hpp
plewis/hpd-histogram
4cc35206e0505127bffe9db6f650852f07bb7f63
[ "MIT" ]
null
null
null
src/subset_relrate_updater.hpp
plewis/hpd-histogram
4cc35206e0505127bffe9db6f650852f07bb7f63
[ "MIT" ]
null
null
null
#pragma once #include "dirichlet_updater.hpp" namespace lorad { class SubsetRelRateUpdater : public DirichletUpdater { public: typedef std::shared_ptr< SubsetRelRateUpdater > SharedPtr; SubsetRelRateUpdater(Model::SharedPtr model); ~SubsetRelRateUpdater(); virtual double calcLogPrior(); #if defined(POLGSS) virtual double calcLogRefDist(); #endif private: void pullFromModel(); void pushToModel(); Model::SharedPtr _model; }; inline SubsetRelRateUpdater::SubsetRelRateUpdater(Model::SharedPtr model) { DirichletUpdater::clear(); _name = "Subset Relative Rates"; _model = model; } inline SubsetRelRateUpdater::~SubsetRelRateUpdater() { } inline double SubsetRelRateUpdater::calcLogPrior() { Model::subset_sizes_t & subset_sizes = _model->getSubsetSizes(); double log_num_sites = std::log(_model->getNumSites()); unsigned num_subsets = _model->getNumSubsets(); double log_prior = DirichletUpdater::calcLogPrior(); for (unsigned i = 0; i < num_subsets-1; i++) { log_prior += std::log(subset_sizes[i]) - log_num_sites; } return log_prior; } #if defined(POLGSS) inline double SubsetRelRateUpdater::calcLogRefDist() { Model::subset_sizes_t & subset_sizes = _model->getSubsetSizes(); unsigned num_subsets = (unsigned)subset_sizes.size(); double log_num_sites = std::log(_model->getNumSites()); double log_refdist = DirichletUpdater::calcLogRefDist(); for (unsigned i = 0; i < num_subsets-1; i++) { log_refdist += std::log(subset_sizes[i]) - log_num_sites; } return log_refdist; } #endif inline void SubsetRelRateUpdater::pullFromModel() { Model::subset_relrate_vect_t & relative_rates = _model->getSubsetRelRates(); Model::subset_sizes_t & subset_sizes = _model->getSubsetSizes(); unsigned num_sites = _model->getNumSites(); unsigned num_subsets = _model->getNumSubsets(); assert(subset_sizes.size() == num_subsets); assert(relative_rates.size() == num_subsets); _curr_point.resize(num_subsets); for (unsigned i = 0; i < num_subsets; i++) { _curr_point[i] = relative_rates[i]*subset_sizes[i]/num_sites; } } inline void SubsetRelRateUpdater::pushToModel() { Model::subset_sizes_t & subset_sizes = _model->getSubsetSizes(); unsigned num_sites = _model->getNumSites(); unsigned num_subsets = _model->getNumSubsets(); point_t tmp(num_subsets); for (unsigned i = 0; i < num_subsets; i++) { tmp[i] = _curr_point[i]*num_sites/subset_sizes[i]; } _model->setSubsetRelRates(tmp, false); } }
35.988372
89
0.590307
plewis
0efe1f8d63e70f2f1ef6335b54d4bc5480a34c6d
30,889
cpp
C++
utility/util/thread.cpp
TRHackerTR33/griddb_nosql
ff9d3c4f4bfe2529a0a045eea7c217d533161504
[ "Apache-2.0" ]
4
2020-01-25T14:24:21.000Z
2022-03-09T08:53:51.000Z
utility/util/thread.cpp
ouellani/griddb_nosql
2ccb037d7ea2d79d3b9ee5830cdcb209f8d6d612
[ "Apache-2.0" ]
4
2021-09-15T02:50:12.000Z
2021-09-15T02:50:32.000Z
utility/util/thread.cpp
ouellani/griddb_nosql
2ccb037d7ea2d79d3b9ee5830cdcb209f8d6d612
[ "Apache-2.0" ]
3
2019-05-29T02:39:31.000Z
2020-07-19T11:01:33.000Z
/* Copyright (c) 2017 TOSHIBA Digital Solutions Corporation This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* Copyright (c) 2008, Yubin Lim(purewell@gmail.com). All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Purewell nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "util/thread.h" #include "util/code.h" #include "util/time.h" #include "util/os.h" #ifdef _WIN32 #include <process.h> #else #include <sys/syscall.h> #endif #include <assert.h> #define UTIL_WIN_COND_CHANGE namespace util { struct Condition::Data { #ifdef UTIL_HAVE_POSIX_CONDITION pthread_cond_t cond_; pthread_mutex_t mutex_; clockid_t clockId_; #else #ifndef UTIL_WIN_COND_CHANGE bool lastSingnalWasBroadcast_; HANDLE mutex_; uint32_t waitersCount_; CRITICAL_SECTION waitersCountLock_; HANDLE waitBarrier_; HANDLE waitBarrierClearSignal_; Data() { lastSingnalWasBroadcast_ = false; mutex_ = CreateEvent(NULL, FALSE, TRUE, NULL); waitersCount_ = 0; InitializeCriticalSection(&waitersCountLock_); waitBarrier_ = CreateSemaphore(NULL, 0, LONG_MAX, NULL); waitBarrierClearSignal_ = CreateEvent(NULL, FALSE, FALSE, NULL); if (mutex_ == NULL || waitBarrier_ == NULL || waitBarrierClearSignal_ == NULL) { if (mutex_ == NULL) { CloseHandle(mutex_); } DeleteCriticalSection(&waitersCountLock_); if (waitBarrier_ == NULL) { CloseHandle(waitBarrier_); } if (waitBarrierClearSignal_ == NULL) { CloseHandle(waitBarrierClearSignal_); } UTIL_THROW_UTIL_ERROR_CODED(CODE_INVALID_STATUS); } } ~Data() { CloseHandle(mutex_); DeleteCriticalSection(&waitersCountLock_); CloseHandle(waitBarrier_); CloseHandle(waitBarrierClearSignal_); } #else HANDLE cond_; Mutex mutex_; Data() { #ifdef UTIL_COND_MANUAL_RESET cond_ = CreateEvent(NULL, true, false, NULL); #else cond_ = CreateEvent(NULL, false, false, NULL); #endif if (cond_ == NULL) UTIL_THROW_PLATFORM_ERROR(NULL); } ~Data() { CloseHandle(cond_); } #endif #endif }; struct ConditionAttribute::Data { #ifdef UTIL_HAVE_POSIX_CONDITION pthread_condattr_t attr_; #endif }; Condition::Condition(const ConditionAttribute *attr) : data_(new Data) { #ifdef UTIL_HAVE_POSIX_CONDITION ConditionAttribute defaultAttr; pthread_condattr_t &selectedAttr = (attr == NULL ? &defaultAttr : attr)->data_->attr_; if (0 != pthread_condattr_getclock(&selectedAttr, &data_->clockId_)) { UTIL_THROW_PLATFORM_ERROR(NULL); } if (0 != pthread_cond_init(&data_->cond_, &selectedAttr)) { UTIL_THROW_PLATFORM_ERROR(NULL); } if (0 != pthread_mutex_init(&data_->mutex_, NULL)) { pthread_cond_destroy(&data_->cond_); UTIL_THROW_PLATFORM_ERROR(NULL); } #endif } Condition::~Condition() { #ifdef UTIL_HAVE_POSIX_CONDITION pthread_cond_destroy(&data_->cond_); pthread_mutex_destroy(&data_->mutex_); #endif } void Condition::signal(void) { #ifdef UTIL_HAVE_POSIX_CONDITION pthread_cond_signal(&data_->cond_); #else #ifndef UTIL_WIN_COND_CHANGE EnterCriticalSection(&data_->waitersCountLock_); bool have_waiters = data_->waitersCount_ > 0; LeaveCriticalSection(&data_->waitersCountLock_); if (have_waiters) { ReleaseSemaphore(data_->waitBarrier_, 1, NULL); } #else SetEvent(data_->cond_); #endif #endif } void Condition::broadcast(void) { #ifdef UTIL_HAVE_POSIX_CONDITION pthread_cond_broadcast(&data_->cond_); #else #ifndef UTIL_WIN_COND_CHANGE EnterCriticalSection(&data_->waitersCountLock_); if (data_->waitersCount_ > 0) { data_->lastSingnalWasBroadcast_ = true; ReleaseSemaphore(data_->waitBarrier_, data_->waitersCount_, 0); LeaveCriticalSection(&data_->waitersCountLock_); WaitForSingleObject(data_->waitBarrierClearSignal_, INFINITE); data_->lastSingnalWasBroadcast_ = false; } else { LeaveCriticalSection(&data_->waitersCountLock_); } #else SetEvent(data_->cond_); #endif #endif } void Condition::lock(void) { #ifdef UTIL_HAVE_POSIX_CONDITION if (0 != pthread_mutex_lock(&data_->mutex_)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #else #ifndef UTIL_WIN_COND_CHANGE const DWORD result = WaitForSingleObjectEx(data_->mutex_, INFINITE, TRUE); if (result != WAIT_OBJECT_0 && result != WAIT_ABANDONED) { UTIL_THROW_PLATFORM_ERROR(NULL); } #else data_->mutex_.lock(); #endif #endif } void Condition::unlock(void) { #ifdef UTIL_HAVE_POSIX_CONDITION if (0 != pthread_mutex_unlock(&data_->mutex_)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #else #ifndef UTIL_WIN_COND_CHANGE if (0 == SetEvent(data_->mutex_)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #else data_->mutex_.unlock(); #endif #endif } void Condition::wait() { #ifdef UTIL_HAVE_POSIX_CONDITION if (0 != pthread_cond_wait(&data_->cond_, &data_->mutex_)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #else #ifndef UTIL_WIN_COND_CHANGE if (!wait(INFINITE)) { UTIL_THROW_UTIL_ERROR_CODED(CODE_INVALID_STATUS); } #else data_->mutex_.unlock(); WaitForSingleObject(data_->cond_, INFINITE); #ifdef UTIL_COND_MANUAL_RESET ResetEvent(data_->cond_); #endif data_->mutex_.lock(); #endif #endif } bool Condition::wait(struct timespec &ts) { (void) &ts; UTIL_THROW_NOIMPL_UTIL(); } bool Condition::wait(uint32_t timeoutMillis) { #if defined(UTIL_HAVE_POSIX_CONDITION) timespec ts = FileLib::calculateTimeoutSpec(data_->clockId_, timeoutMillis); const int result = pthread_cond_timedwait( &data_->cond_, &data_->mutex_, &ts); if (0 != result) { if (result == ETIMEDOUT) { return false; } UTIL_THROW_PLATFORM_ERROR(NULL); } return true; #else #ifndef UTIL_WIN_COND_CHANGE EnterCriticalSection(&data_->waitersCountLock_); data_->waitersCount_++; LeaveCriticalSection(&data_->waitersCountLock_); DWORD result = SignalObjectAndWait(data_->mutex_, data_->waitBarrier_, static_cast<DWORD>(timeoutMillis), FALSE); if (result == WAIT_OBJECT_0) { EnterCriticalSection(&data_->waitersCountLock_); data_->waitersCount_--; const bool lastWaiter = (data_->lastSingnalWasBroadcast_ && data_->waitersCount_ == 0); LeaveCriticalSection(&data_->waitersCountLock_); if (lastWaiter) { result = SignalObjectAndWait(data_->waitBarrierClearSignal_, data_->mutex_, INFINITE, FALSE); return (result == WAIT_OBJECT_0); } else { result = WaitForSingleObjectEx(data_->mutex_, INFINITE, TRUE); if (result != WAIT_OBJECT_0 && result != WAIT_ABANDONED) { UTIL_THROW_PLATFORM_ERROR(NULL); } return true; } } else { EnterCriticalSection(&data_->waitersCountLock_); data_->waitersCount_--; LeaveCriticalSection(&data_->waitersCountLock_); return false; } #else DWORD tv = static_cast<DWORD>(timeoutMillis); data_->mutex_.unlock(); DWORD res = WaitForSingleObject(data_->cond_, tv); #ifdef UTIL_COND_MANUAL_RESET ResetEvent(data_->cond_); #endif data_->mutex_.lock(); if (res == WAIT_TIMEOUT) return false; return true; #endif #endif } ConditionAttribute::ConditionAttribute() : data_(new Data) { #ifdef UTIL_HAVE_POSIX_CONDITION if (0 != pthread_condattr_init(&data_->attr_)) { UTIL_THROW_PLATFORM_ERROR(NULL); } if (0 != pthread_condattr_setclock(&data_->attr_, CLOCK_MONOTONIC)) { pthread_condattr_destroy(&data_->attr_); UTIL_THROW_PLATFORM_ERROR(NULL); } #endif } ConditionAttribute::~ConditionAttribute() { #ifdef UTIL_HAVE_POSIX_CONDITION pthread_condattr_destroy(&data_->attr_); #endif } #ifndef _WIN32 UTIL_FLAG_TYPE UTIL_MUTEX_DEFAULT = PTHREAD_MUTEX_DEFAULT; UTIL_FLAG_TYPE UTIL_MUTEX_FAST = PTHREAD_MUTEX_NORMAL; UTIL_FLAG_TYPE UTIL_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE; UTIL_FLAG_TYPE UTIL_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK; #else UTIL_FLAG_TYPE UTIL_MUTEX_DEFAULT = 0; UTIL_FLAG_TYPE UTIL_MUTEX_FAST = 0; UTIL_FLAG_TYPE UTIL_MUTEX_RECURSIVE = 0; UTIL_FLAG_TYPE UTIL_MUTEX_ERRORCHECK = 0; #endif struct Mutex::Data { #ifdef UTIL_HAVE_POSIX_MUTEX Data(const pthread_mutexattr_t *attr); #else Data(); #endif ~Data(); #ifdef UTIL_HAVE_POSIX_MUTEX pthread_mutex_t mutex_; #else CRITICAL_SECTION cs_; #endif }; struct MutexAttribute::Data { #ifdef UTIL_HAVE_POSIX_MUTEX pthread_mutexattr_t attr_; #endif }; #ifdef UTIL_HAVE_POSIX_MUTEX Mutex::Data::Data(const pthread_mutexattr_t *attr) { if (0 != pthread_mutex_init(&mutex_, attr)) { UTIL_THROW_PLATFORM_ERROR(NULL); } } #else Mutex::Data::Data() { InitializeCriticalSection(&cs_); } #endif Mutex::Data::~Data() { #ifdef UTIL_HAVE_POSIX_MUTEX pthread_mutex_destroy(&mutex_); #else DeleteCriticalSection(&cs_); #endif } Mutex::Mutex(int type) { #ifdef UTIL_HAVE_POSIX_MUTEX MutexAttribute attr; attr.setType(type); data_.reset(new Data(&attr.data_->attr_)); #else data_.reset(new Data()); #endif } Mutex::Mutex(const MutexAttribute *attr) { #ifdef UTIL_HAVE_POSIX_MUTEX const pthread_mutexattr_t *baseAttr = NULL; if (attr != NULL) { baseAttr = &attr->data_->attr_; } data_.reset(new Data(baseAttr)); #else data_.reset(new Data()); #endif } Mutex::~Mutex() { } void Mutex::lock(void) { #ifdef UTIL_HAVE_POSIX_MUTEX pthread_mutex_lock(&data_->mutex_); #else EnterCriticalSection(&data_->cs_); #endif } void Mutex::unlock(void) { #ifdef UTIL_HAVE_POSIX_MUTEX pthread_mutex_unlock(&data_->mutex_); #else LeaveCriticalSection(&data_->cs_); #endif } bool Mutex::tryLock(void) { #ifdef UTIL_HAVE_POSIX_MUTEX return (0 == pthread_mutex_trylock(&data_->mutex_)); #else return (TryEnterCriticalSection(&data_->cs_) ? true : false); #endif } bool Mutex::tryLock(uint32_t msec) { (void) msec; UTIL_THROW_NOIMPL_UTIL(); } MutexAttribute::MutexAttribute() : data_(new Data()) { #ifdef UTIL_HAVE_POSIX_MUTEX if (0 != pthread_mutexattr_init(&data_->attr_)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #endif } MutexAttribute::~MutexAttribute() { #ifdef UTIL_HAVE_POSIX_MUTEX pthread_mutexattr_destroy(&data_->attr_); #endif } void MutexAttribute::setType(int type) { #ifdef UTIL_HAVE_POSIX_MUTEX if (0 != pthread_mutexattr_settype(&data_->attr_, type)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #else UTIL_THROW_NOIMPL_UTIL(); #endif } void MutexAttribute::getType(int &type) const { #ifdef UTIL_HAVE_POSIX_MUTEX if (0 != pthread_mutexattr_gettype(&data_->attr_, &type)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #else UTIL_THROW_NOIMPL_UTIL(); #endif } void MutexAttribute::setShared(bool shared) { #ifdef UTIL_HAVE_POSIX_MUTEX if (0 != pthread_mutexattr_setpshared(&data_->attr_, shared ? PTHREAD_PROCESS_SHARED : PTHREAD_PROCESS_PRIVATE)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #else UTIL_THROW_NOIMPL_UTIL(); #endif } void MutexAttribute::getShared(bool &shared) const { #ifdef UTIL_HAVE_POSIX_MUTEX int type; if (0 != pthread_mutexattr_getpshared(&data_->attr_, &type)) { UTIL_THROW_PLATFORM_ERROR(NULL); } shared = (type == PTHREAD_PROCESS_SHARED); #else UTIL_THROW_NOIMPL_UTIL(); #endif } struct RWLock::Data { #ifdef UTIL_HAVE_POSIX_MUTEX Data(const pthread_rwlockattr_t *attr); #else Data(); void unlock(); void addWriter(); void removeWriter(); #endif ~Data(); void close(); #ifdef UTIL_HAVE_POSIX_MUTEX pthread_rwlock_t rwlock_; #else HANDLE mutex_; HANDLE readEvent_; HANDLE writeEvent_; size_t readerCount_; size_t waitingWriterCount_; size_t writerCount_; #endif }; struct RWLockAttribute::Data { #ifdef UTIL_HAVE_POSIX_MUTEX pthread_rwlockattr_t attr_; #endif }; #ifdef UTIL_HAVE_POSIX_MUTEX RWLock::Data::Data(const pthread_rwlockattr_t *attr) { if (0 != pthread_rwlock_init(&rwlock_, attr)) { UTIL_THROW_PLATFORM_ERROR(NULL); } } #else RWLock::Data::Data() { readerCount_ = 0; waitingWriterCount_ = 0; writerCount_ = 0; mutex_ = NULL; readEvent_ = NULL; writeEvent_ = NULL; try { mutex_ = CreateMutexW(NULL, FALSE, NULL); if (mutex_ == NULL) { UTIL_THROW_PLATFORM_ERROR(NULL); } readEvent_ = CreateEventW(NULL, TRUE, TRUE, NULL); if (readEvent_ == NULL) { UTIL_THROW_PLATFORM_ERROR(NULL); } writeEvent_ = CreateEventW(NULL, TRUE, TRUE, NULL); if (writeEvent_ == NULL) { UTIL_THROW_PLATFORM_ERROR(NULL); } } catch (...) { close(); throw; } } #endif #ifndef UTIL_HAVE_POSIX_MUTEX void RWLock::Data::unlock() { switch (WaitForSingleObject(mutex_, INFINITE)) { case WAIT_OBJECT_0: if (readerCount_ == 0) { ReleaseMutex(mutex_); UTIL_THROW_UTIL_ERROR(CODE_ILLEGAL_OPERATION, "Not locked"); } writerCount_ = 0; if (waitingWriterCount_ == 0) { SetEvent(readEvent_); } if ((--readerCount_) == 0) { SetEvent(writeEvent_); } ReleaseMutex(mutex_); break; case WAIT_FAILED: UTIL_THROW_PLATFORM_ERROR(NULL); default: UTIL_THROW_UTIL_ERROR_CODED(CODE_INVALID_STATUS); } } #endif #ifndef UTIL_HAVE_POSIX_MUTEX void RWLock::Data::addWriter() { switch (WaitForSingleObject(mutex_, INFINITE)) { case WAIT_OBJECT_0: if (++waitingWriterCount_ == 1) { ResetEvent(readEvent_); } ReleaseMutex(mutex_); break; case WAIT_FAILED: UTIL_THROW_PLATFORM_ERROR(NULL); default: UTIL_THROW_UTIL_ERROR_CODED(CODE_INVALID_STATUS); } } #endif #ifndef UTIL_HAVE_POSIX_MUTEX void RWLock::Data::removeWriter() { switch (WaitForSingleObject(mutex_, INFINITE)) { case WAIT_OBJECT_0: if (--waitingWriterCount_ == 0 && writerCount_ == 0) { SetEvent(readEvent_); } ReleaseMutex(mutex_); break; case WAIT_FAILED: UTIL_THROW_PLATFORM_ERROR(NULL); default: UTIL_THROW_UTIL_ERROR_CODED(CODE_INVALID_STATUS); } } #endif RWLock::Data::~Data() { close(); } void RWLock::Data::close() { #ifdef UTIL_HAVE_POSIX_MUTEX pthread_rwlock_destroy(&rwlock_); #else if (mutex_ != NULL) { CloseHandle(mutex_); } if (readEvent_ != NULL) { CloseHandle(readEvent_); } if (writeEvent_ != NULL) { CloseHandle(writeEvent_); } #endif } RWLock::RWLock(const RWLockAttribute *attr) : readLock_(newData(attr)), writeLock_(readLock_.data_) { } RWLock::RWLock() : readLock_(newData(NULL)), writeLock_(readLock_.data_) { } RWLock::~RWLock() { delete readLock_.data_; } RWLock::Data* RWLock::newData(const RWLockAttribute *attr) { #ifdef UTIL_HAVE_POSIX_MUTEX const pthread_rwlockattr_t *baseAttr = NULL; if (attr != NULL) { baseAttr = &attr->data_->attr_; } return new Data(baseAttr); #else return new Data(); #endif } void RWLock::ReadLock::lock(void) { #ifdef UTIL_HAVE_POSIX_MUTEX pthread_rwlock_rdlock(&data_->rwlock_); #else HANDLE handles[] = { data_->mutex_, data_->readEvent_ }; switch (WaitForMultipleObjects(2, handles, TRUE, INFINITE)) { case WAIT_OBJECT_0: case (WAIT_OBJECT_0 + 1): data_->readerCount_++; ResetEvent(data_->writeEvent_); ReleaseMutex(data_->mutex_); break; case WAIT_FAILED: UTIL_THROW_PLATFORM_ERROR(NULL); default: UTIL_THROW_UTIL_ERROR_CODED(CODE_INVALID_STATUS); } #endif } bool RWLock::ReadLock::tryLock(void) { #ifdef UTIL_HAVE_POSIX_MUTEX return (0 == pthread_rwlock_tryrdlock(&data_->rwlock_)); #else return tryLock(1); #endif } bool RWLock::ReadLock::tryLock(uint32_t msec) { #ifdef UTIL_HAVE_POSIX_MUTEX timespec ts = FileLib::calculateTimeoutSpec(CLOCK_REALTIME, msec); return (0 == pthread_rwlock_timedrdlock(&data_->rwlock_, &ts)); #else HANDLE handles[] = { data_->mutex_, data_->readEvent_ }; switch (WaitForMultipleObjects(2, handles, TRUE, msec)) { case WAIT_OBJECT_0: case (WAIT_OBJECT_0 + 1): data_->readerCount_++; assert (data_->writerCount_ == 0); assert (data_->waitingWriterCount_ == 0); ResetEvent(data_->writeEvent_); ReleaseMutex(data_->mutex_); return true; case WAIT_TIMEOUT: return false; case WAIT_FAILED: UTIL_THROW_PLATFORM_ERROR(NULL); default: UTIL_THROW_UTIL_ERROR_CODED(CODE_INVALID_STATUS); } #endif } void RWLock::ReadLock::unlock(void) { #ifdef UTIL_HAVE_POSIX_MUTEX pthread_rwlock_unlock(&data_->rwlock_); #else data_->unlock(); #endif } void RWLock::WriteLock::lock(void) { #ifdef UTIL_HAVE_POSIX_MUTEX pthread_rwlock_wrlock(&data_->rwlock_); #else if (!tryLock(INFINITE)) { UTIL_THROW_UTIL_ERROR_CODED(CODE_INVALID_STATUS); } #endif } bool RWLock::WriteLock::tryLock(void) { #ifdef UTIL_HAVE_POSIX_MUTEX return (0 == pthread_rwlock_trywrlock(&data_->rwlock_)); #else return tryLock(1); #endif } bool RWLock::WriteLock::tryLock(uint32_t msec) { #ifdef UTIL_HAVE_POSIX_MUTEX timespec ts = FileLib::calculateTimeoutSpec(CLOCK_REALTIME, msec); return (0 == pthread_rwlock_timedwrlock(&data_->rwlock_, &ts)); #else data_->addWriter(); HANDLE handles[] = { data_->mutex_, data_->writeEvent_ }; switch (WaitForMultipleObjects(2, handles, TRUE, msec)) { case WAIT_OBJECT_0: case (WAIT_OBJECT_0 + 1): data_->waitingWriterCount_--; data_->readerCount_++; data_->writerCount_++; ResetEvent(data_->readEvent_); ResetEvent(data_->writeEvent_); ReleaseMutex(data_->mutex_); return true; case WAIT_TIMEOUT: data_->removeWriter(); return false; case WAIT_FAILED: data_->removeWriter(); UTIL_THROW_PLATFORM_ERROR(NULL); default: data_->removeWriter(); UTIL_THROW_UTIL_ERROR_CODED(CODE_INVALID_STATUS); } #endif } void RWLock::WriteLock::unlock(void) { #ifdef UTIL_HAVE_POSIX_MUTEX pthread_rwlock_unlock(&data_->rwlock_); #else data_->unlock(); #endif } RWLockAttribute::RWLockAttribute() : data_(new Data()) { #ifdef UTIL_HAVE_POSIX_MUTEX if (0 != pthread_rwlockattr_init(&data_->attr_)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #endif } RWLockAttribute::~RWLockAttribute() { #ifdef UTIL_HAVE_POSIX_MUTEX pthread_rwlockattr_destroy(&data_->attr_); #endif } void RWLockAttribute::setShared(bool shared) { #ifdef UTIL_HAVE_POSIX_MUTEX if (0 != pthread_rwlockattr_setpshared(&data_->attr_, shared ? PTHREAD_PROCESS_SHARED : PTHREAD_PROCESS_PRIVATE)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #else UTIL_THROW_NOIMPL_UTIL(); #endif } void RWLockAttribute::getShared(bool &shared) const { #ifdef UTIL_HAVE_POSIX_MUTEX int type; if (0 != pthread_rwlockattr_getpshared(&data_->attr_, &type)) { UTIL_THROW_PLATFORM_ERROR(NULL); } shared = (type == PTHREAD_PROCESS_SHARED); #else UTIL_THROW_NOIMPL_UTIL(); #endif } struct Semaphore::Data { #ifdef _WIN32 HANDLE handle_; #else enum Type { TYPE_NAMED, TYPE_UNNAMED }; struct Named; struct Unnamed; Type type_; sem_t* getKey(); const char* getName(); #endif }; #ifndef _WIN32 struct Semaphore::Data::Named : public Semaphore::Data { sem_t *key_; std::string name_; Named() : key_(NULL) { type_ = TYPE_NAMED; } }; struct Semaphore::Data::Unnamed : public Semaphore::Data { sem_t key_; Unnamed() { type_ = TYPE_UNNAMED; } }; sem_t* Semaphore::Data::getKey() { if (type_ == TYPE_NAMED) { return static_cast<Named*>(this)->key_; } else { return &static_cast<Unnamed*>(this)->key_; } } const char* Semaphore::Data::getName() { if (type_ == TYPE_NAMED) { return static_cast<Named*>(this)->name_.c_str(); } return NULL; } #endif Semaphore::Semaphore(uint32_t value) { #ifdef _WIN32 data_ = new Data(); try { const HANDLE handle = CreateSemaphoreW(NULL, 0, LONG_MAX, NULL); if (handle == NULL) { UTIL_THROW_PLATFORM_ERROR(NULL); } data_->handle_ = handle; } catch (...) { delete data_; throw; } #else Data::Unnamed *data = new Data::Unnamed(); try { if (-1 == sem_init(&(data->key_), 0, value)) { UTIL_THROW_PLATFORM_ERROR(NULL); } data_ = data; } catch (...) { delete data; throw; } #endif } Semaphore::Semaphore( const char8_t *name, FileFlag flags, FilePermission perm, uint32_t value) { #ifdef _WIN32 data_ = new Data(); try { std::wstring wideNameStr; CodeConverter(Code::UTF8, Code::WCHAR_T)(name, wideNameStr); const HANDLE handle = CreateSemaphoreW(NULL, 0, LONG_MAX, wideNameStr.c_str()); if (handle == NULL) { UTIL_THROW_PLATFORM_ERROR(NULL); } data_->handle_ = handle; } catch (...) { delete data_; throw; } #else Data::Named *data = new Data::Named(); try { CodeConverter(Code::UTF8, Code::CHAR)(name, data->name_); if (flags & O_CREAT) { data->key_ = sem_open(data->getName(), flags); } else { data->key_ = sem_open( data->getName(), flags, static_cast<int>(perm), value); } if (SEM_FAILED == data->key_) { UTIL_THROW_PLATFORM_ERROR(NULL); } data_ = data; } catch (...) { delete data; throw; } #endif } Semaphore::~Semaphore() { #ifdef _WIN32 CloseHandle(data_->handle_); delete data_; #else if (data_->type_ == Data::TYPE_NAMED) { Data::Named *namedData = static_cast<Data::Named*>(data_); sem_close(namedData->key_); delete namedData; } else { Data::Unnamed *unnamedData = static_cast<Data::Unnamed*>(data_); sem_destroy(&unnamedData->key_); delete unnamedData; } #endif } void Semaphore::lock(void) { #ifdef _WIN32 WaitForSingleObjectEx(data_->handle_, INFINITE, TRUE); #else sem_wait(data_->getKey()); #endif } bool Semaphore::tryLock(void) { #ifdef _WIN32 const DWORD result = WaitForSingleObjectEx(data_->handle_, 0, TRUE); return (result == WAIT_OBJECT_0 || result == WAIT_ABANDONED); #else return (-1 != sem_trywait(data_->getKey())); #endif } bool Semaphore::tryLock(uint32_t msec) { #ifdef _WIN32 const DWORD result = WaitForSingleObjectEx( data_->handle_, static_cast<DWORD>(msec), TRUE); return (result == WAIT_OBJECT_0 || result == WAIT_ABANDONED); #else timespec ts = FileLib::calculateTimeoutSpec(CLOCK_REALTIME, msec); return (-1 != sem_timedwait(data_->getKey(), &ts)); #endif } void Semaphore::unlock(void) { #ifdef _WIN32 ReleaseSemaphore(data_->handle_, 1, NULL); #else sem_post(data_->getKey()); #endif } bool Semaphore::unlink(const char8_t *name) { #ifdef _WIN32 UTIL_THROW_NOIMPL_UTIL(); #else std::string nameStr; CodeConverter(Code::UTF8, Code::CHAR)(name, nameStr); return (0 == sem_unlink(nameStr.c_str())); #endif } bool Semaphore::unlink(void) const { #ifdef _WIN32 UTIL_THROW_NOIMPL_UTIL(); #else return (0 == sem_unlink(data_->getName())); #endif } void Semaphore::getValue(size_t &value) const { #ifdef _WIN32 UTIL_THROW_NOIMPL_UTIL(); #else int intValue; if (0 != sem_getvalue(const_cast<Data*>(data_)->getKey(), &intValue)) { UTIL_THROW_PLATFORM_ERROR(NULL); } value = static_cast<size_t>(intValue); #endif } struct SpinLock::Data { Data(); ~Data(); #ifdef UTIL_HAVE_POSIX_SPIN pthread_spinlock_t mutex_; #else static const DWORD SPIN_COUNT = 2000; CRITICAL_SECTION cs_; #endif }; SpinLock::Data::Data() { #ifdef UTIL_HAVE_POSIX_SPIN if (0 != pthread_spin_init(&mutex_, PTHREAD_PROCESS_PRIVATE)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #else if (!InitializeCriticalSectionAndSpinCount(&cs_, SPIN_COUNT)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #endif } SpinLock::Data::~Data() { #ifdef UTIL_HAVE_POSIX_SPIN pthread_spin_destroy(&mutex_); #else DeleteCriticalSection(&cs_); #endif } SpinLock::SpinLock() : data_(new Data()) { } SpinLock::~SpinLock() { } void SpinLock::lock(void) { #ifdef UTIL_HAVE_POSIX_SPIN pthread_spin_lock(&data_->mutex_); #else EnterCriticalSection(&data_->cs_); #endif } void SpinLock::unlock(void) { #ifdef UTIL_HAVE_POSIX_SPIN pthread_spin_unlock(&data_->mutex_); #else LeaveCriticalSection(&data_->cs_); #endif } bool SpinLock::tryLock(void) { #ifdef UTIL_HAVE_POSIX_SPIN return (0 == pthread_spin_trylock(&data_->mutex_)); #else return (TryEnterCriticalSection(&data_->cs_) ? true : false); #endif } bool SpinLock::tryLock(uint32_t msec) { (void) msec; UTIL_THROW_NOIMPL_UTIL(); } struct Thread::Data { #ifdef _WIN32 HANDLE handle_; #else pthread_t threadId_; #endif Data() : #ifdef _WIN32 handle_(NULL) #else threadId_(0) #endif { } }; struct ThreadAttribute::Data { #ifdef _WIN32 #else pthread_attr_t attr_; #endif }; ThreadRunner::~ThreadRunner() { } Thread::Thread() : data_(new Data()) { } Thread::~Thread() { close(); } void Thread::start(ThreadRunner *runner, const ThreadAttribute *attr) { if (!isClosed()) { UTIL_THROW_UTIL_ERROR_CODED(CODE_ILLEGAL_OPERATION); } if (runner == NULL) { runner = this; } #ifdef _WIN32 const uintptr_t result = _beginthreadex(NULL, 0, threadProc, runner, 0, NULL); if (result == 0) { UTIL_THROW_PLATFORM_ERROR(NULL); } data_->handle_ = reinterpret_cast<HANDLE>(result); #else pthread_attr_t *pthreadAttr = (attr ? &attr->data_->attr_ : NULL); if (0 != pthread_create( &data_->threadId_, pthreadAttr, threadProc, runner)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #endif } void Thread::close() { if (!isClosed()) { #ifdef _WIN32 CloseHandle(data_->handle_); data_->handle_ = NULL; #else if (data_->threadId_ != 0) { pthread_detach(data_->threadId_); data_->threadId_ = 0; } #endif } } void Thread::join() { if (isClosed()) { return; } #ifdef _WIN32 if (WaitForSingleObject(data_->handle_, INFINITE) == WAIT_FAILED) { UTIL_THROW_PLATFORM_ERROR(NULL); } #else pthread_join(data_->threadId_, NULL); data_->threadId_ = 0; #endif } void Thread::sleep(uint32_t millisecTime) { #ifdef _WIN32 Sleep(millisecTime); #else timespec spec; spec.tv_sec = millisecTime / 1000; spec.tv_nsec = (millisecTime % 1000) * 1000 * 1000; nanosleep(&spec, NULL); #endif } void Thread::yield() { Thread::sleep(0); } uint64_t Thread::getSelfId() { #ifdef _WIN32 return GetCurrentThreadId(); #else return syscall(SYS_gettid); #endif } void Thread::run() { } bool Thread::isClosed() { #ifdef _WIN32 return (data_->handle_ == NULL); #else return (data_->threadId_ == 0); #endif } #ifdef _WIN32 unsigned int Thread::threadProc(void *param) { ThreadRunner *runner = static_cast<ThreadRunner*>(param); runner->run(); return 0; } #else void* Thread::threadProc(void *param) { ThreadRunner *runner = static_cast<ThreadRunner*>(param); runner->run(); return NULL; } #endif ThreadAttribute::ThreadAttribute() : data_(new Data()) { #ifdef _WIN32 #else if (0 != pthread_attr_init(&data_->attr_)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #endif } ThreadAttribute::~ThreadAttribute() { #ifdef _WIN32 #else pthread_attr_destroy(&data_->attr_); #endif } void ThreadAttribute::setScope(int type) { #ifdef _WIN32 UTIL_THROW_NOIMPL_UTIL(); #else if (0 != pthread_attr_setscope(&data_->attr_, type)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #endif } void ThreadAttribute::getScope(int &type) const { #ifdef _WIN32 UTIL_THROW_NOIMPL_UTIL(); #else if (0 != pthread_attr_getscope(&data_->attr_, &type)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #endif } void ThreadAttribute::setDetach(bool detached) { #ifdef _WIN32 UTIL_THROW_NOIMPL_UTIL(); #else const int type = (detached ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE); if (0 != pthread_attr_setdetachstate(&data_->attr_, type)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #endif } void ThreadAttribute::getDetach(bool &detached) const { #ifdef _WIN32 UTIL_THROW_NOIMPL_UTIL(); #else int type; if (0 != pthread_attr_getdetachstate(&data_->attr_, &type)) { UTIL_THROW_PLATFORM_ERROR(NULL); } detached = (type == PTHREAD_CREATE_DETACHED); #endif } void ThreadAttribute::setGuardSize(size_t size) { #ifdef _WIN32 UTIL_THROW_NOIMPL_UTIL(); #else if (0 != pthread_attr_setguardsize(&data_->attr_, size)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #endif } void ThreadAttribute::getGuardSize(size_t &size) const { #ifdef _WIN32 UTIL_THROW_NOIMPL_UTIL(); #else if (0 != pthread_attr_getguardsize(&data_->attr_, &size)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #endif } void ThreadAttribute::setStack(void *stack, size_t size) { #ifdef _WIN32 UTIL_THROW_NOIMPL_UTIL(); #else if (0 != pthread_attr_setstack(&data_->attr_, stack, size)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #endif } void ThreadAttribute::getStack(void *&stack, size_t &size) const { #ifdef _WIN32 UTIL_THROW_NOIMPL_UTIL(); #else if (0 != pthread_attr_getstack(&data_->attr_, &stack, &size)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #endif } void ThreadAttribute::setStackSize(size_t size) { #ifdef _WIN32 UTIL_THROW_NOIMPL_UTIL(); #else if (0 != pthread_attr_setstacksize(&data_->attr_, size)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #endif } void ThreadAttribute::getStackSize(size_t &size) const { #ifdef _WIN32 UTIL_THROW_NOIMPL_UTIL(); #else if (0 != pthread_attr_getstacksize(&data_->attr_, &size)) { UTIL_THROW_PLATFORM_ERROR(NULL); } #endif } ConflictionDetector::ConflictionDetector() { } ConflictionDetector::~ConflictionDetector() { } void ConflictionDetector::enter() { if (++counter_ != 1) { assert(false); UTIL_THROW_UTIL_ERROR(CODE_ILLEGAL_OPERATION, "Internal error by critical section confliction"); } } void ConflictionDetector::leave() { if (--counter_ != 0) { assert(false); UTIL_THROW_UTIL_ERROR(CODE_ILLEGAL_OPERATION, "Internal error by wrong confliction detector usage"); } } ConflictionDetectorScope::ConflictionDetectorScope( ConflictionDetector &detector, bool entering) : detector_(detector), entering_(entering) { if (entering_) { detector_.enter(); } else { detector_.leave(); } } ConflictionDetectorScope::~ConflictionDetectorScope() try { if (entering_) { detector_.leave(); } else { detector_.enter(); } } catch (...) { } }
21.66129
77
0.731749
TRHackerTR33
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
160130e0ff0520d905ee28b5bb289e9d66caf729
296
cpp
C++
sources/im1_im2/src/CompositeCmd/Leafs/AsmCmd.cpp
tsu-iscd/lyapas-lcc
12962e8953deaac43a23a35b09f64481b59a0964
[ "BSD-3-Clause" ]
4
2017-12-09T08:18:30.000Z
2018-05-18T10:43:02.000Z
sources/im1_im2/src/CompositeCmd/Leafs/AsmCmd.cpp
tsu-iscd/lyapas-lcc
12962e8953deaac43a23a35b09f64481b59a0964
[ "BSD-3-Clause" ]
79
2017-01-14T13:25:24.000Z
2018-11-24T06:43:04.000Z
sources/im1_im2/src/CompositeCmd/Leafs/AsmCmd.cpp
tsu-iscd/lyapas-lcc
12962e8953deaac43a23a35b09f64481b59a0964
[ "BSD-3-Clause" ]
null
null
null
#include "AsmCmd.h" AsmCmd::AsmCmd(Json::Value json) : LeafCmd(json) { } Json::Value AsmCmd::toJson() { Json::Value result; result[fieldName::type] = "cmd"; result[fieldName::cmd] = "asm"; result[fieldName::args].append(_cmdJson[fieldName::command]); return result; }
16.444444
65
0.641892
tsu-iscd
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
1604e14f060b44c65918294f1ec208fee9215114
3,090
cc
C++
HLTrigger/Egamma/src/HLTPMDocaFilter.cc
pasmuss/cmssw
566f40c323beef46134485a45ea53349f59ae534
[ "Apache-2.0" ]
null
null
null
HLTrigger/Egamma/src/HLTPMDocaFilter.cc
pasmuss/cmssw
566f40c323beef46134485a45ea53349f59ae534
[ "Apache-2.0" ]
null
null
null
HLTrigger/Egamma/src/HLTPMDocaFilter.cc
pasmuss/cmssw
566f40c323beef46134485a45ea53349f59ae534
[ "Apache-2.0" ]
null
null
null
/** \class HLTPMDocaFilter * * Original Author: Jeremy Werner * Institution: Princeton University, USA * Contact: Jeremy.Werner@cern.ch * Date: February 21, 2007 * */ #include "HLTrigger/Egamma/interface/HLTPMDocaFilter.h" #include "DataFormats/Common/interface/Handle.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/EgammaCandidates/interface/Electron.h" #include "DataFormats/EgammaCandidates/interface/ElectronFwd.h" // // constructors and destructor // HLTPMDocaFilter::HLTPMDocaFilter(const edm::ParameterSet& iConfig) : HLTFilter(iConfig) { candTag_ = iConfig.getParameter< edm::InputTag > ("candTag"); docaDiffPerpCutHigh_ = iConfig.getParameter<double> ("docaDiffPerpCutHigh"); docaDiffPerpCutLow_ = iConfig.getParameter<double> ("docaDiffPerpCutLow"); nZcandcut_ = iConfig.getParameter<int> ("nZcandcut"); candToken_ = consumes<trigger::TriggerFilterObjectWithRefs>(candTag_); } HLTPMDocaFilter::~HLTPMDocaFilter()= default; void HLTPMDocaFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; makeHLTFilterDescription(desc); desc.add<edm::InputTag>("candTag",edm::InputTag("HltZeePMMassFilter")); desc.add<double>("docaDiffPerpCutHigh",0.055691); desc.add<double>("docaDiffPerpCutLow",0.0); desc.add<int>("nZcandcut",1); descriptions.add("hltPMDocaFilter",desc); } // ------------ method called to produce the data ------------ bool HLTPMDocaFilter::hltFilter(edm::Event& iEvent, const edm::EventSetup& iSetup, trigger::TriggerFilterObjectWithRefs & filterproduct) const { using namespace std; using namespace edm; using namespace reco; using namespace trigger; // Ref to Candidate object to be recorded in filter object edm::Ref<reco::ElectronCollection> ref; edm::Handle<trigger::TriggerFilterObjectWithRefs> PrevFilterOutput; iEvent.getByToken (candToken_,PrevFilterOutput); std::vector<edm::Ref<reco::ElectronCollection> > electrons; PrevFilterOutput->getObjects(TriggerElectron, electrons); int n = 0; unsigned int size = electrons.size(); std::vector<double> vx(size); std::vector<double> vy(size); for (unsigned int i=0; i< size; i++) { ref = electrons[i]; vx[i]=ref->vx(); vy[i]=ref->vy(); } for(unsigned int jj=0;jj<size;jj++){ for(unsigned int ii=jj+1;ii<size;ii++){ double docaDiffPerp = sqrt( (vx[jj]-vx[ii])*(vx[jj]-vx[ii])+(vy[jj]-vy[ii])*(vy[jj]-vy[ii])); // std::cout<<"docaDiffPerp= "<<docaDiffPerp<<std::endl; if((docaDiffPerp>=docaDiffPerpCutLow_) && (docaDiffPerp<= docaDiffPerpCutHigh_)){ n++; ref = electrons[ii]; filterproduct.addObject(TriggerElectron, ref); ref = electrons[jj]; filterproduct.addObject(TriggerElectron, ref); } } } // filter decision bool accept(n>=nZcandcut_); return accept; }
31.530612
140
0.707767
pasmuss
16086c117988c646473c2aad7c041b9d6143a591
977
cpp
C++
Dataset/Leetcode/test/20/556.cpp
kkcookies99/UAST
fff81885aa07901786141a71e5600a08d7cb4868
[ "MIT" ]
null
null
null
Dataset/Leetcode/test/20/556.cpp
kkcookies99/UAST
fff81885aa07901786141a71e5600a08d7cb4868
[ "MIT" ]
null
null
null
Dataset/Leetcode/test/20/556.cpp
kkcookies99/UAST
fff81885aa07901786141a71e5600a08d7cb4868
[ "MIT" ]
null
null
null
class Solution { public: bool XXX(string s) { int l = s.size(); if (l%2==1) return false; string p; char c,a; for(int i = 0;i<l;i++) { a = s[i]; if(a=='(')p.push_back('('); else if (a=='[')p.push_back('['); else if (a=='{')p.push_back('{'); else if (a=='}'&&p.size()>0) { c = p[p.size()-1]; p.pop_back(); if(c!='{') return false; } else if (a==']'&&p.size()>0) { c = p[p.size()-1]; p.pop_back(); if(c!='[') return false; } else if (a ==')'&&p.size()>0) { c = p[p.size()-1]; p.pop_back(); if(c!='(') return false; } else return false; } if(p.size()>0)return false; return true; } };
24.425
45
0.315251
kkcookies99
160a25139ed5a9ce27e5594a4553cb88bb5c20c3
14,574
cxx
C++
Qt/Core/pqServer.cxx
trickyMan/paraview_view
3b38670e8259b688093e0d7ba2fe2edd7c5d57a7
[ "Apache-2.0", "BSD-3-Clause" ]
null
null
null
Qt/Core/pqServer.cxx
trickyMan/paraview_view
3b38670e8259b688093e0d7ba2fe2edd7c5d57a7
[ "Apache-2.0", "BSD-3-Clause" ]
null
null
null
Qt/Core/pqServer.cxx
trickyMan/paraview_view
3b38670e8259b688093e0d7ba2fe2edd7c5d57a7
[ "Apache-2.0", "BSD-3-Clause" ]
null
null
null
/*========================================================================= Program: ParaView Module: pqServer.cxx Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc. All rights reserved. ParaView is a free software; you can redistribute it and/or modify it under the terms of the ParaView license version 1.2. See License_v1.2.txt for the full ParaView license. A copy of this license can be obtained by contacting Kitware Inc. 28 Corporate Drive Clifton Park, NY 12065 USA THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #include "pqServer.h" #include "pqApplicationCore.h" #include "pqCoreUtilities.h" #include "pqOptions.h" #include "pqServerManagerModel.h" #include "pqSettings.h" #include "pqTimeKeeper.h" #include "pqView.h" #include "vtkClientServerStream.h" #include "vtkEventQtSlotConnect.h" #include "vtkMapper.h" // Needed for VTK_RESOLVE_SHIFT_ZBUFFER #include "vtkNetworkAccessManager.h" #include "vtkNew.h" #include "vtkObjectFactory.h" #include "vtkPVOptions.h" #include "vtkPVServerInformation.h" #include "vtkProcessModule.h" #include "vtkSMCollaborationManager.h" #include "vtkSMMessage.h" #include "vtkSMParaViewPipelineController.h" #include "vtkSMProperty.h" #include "vtkSMPropertyHelper.h" #include "vtkSMProxy.h" #include "vtkSMProxyManager.h" #include "vtkSMProxySelectionModel.h" #include "vtkSMSession.h" #include "vtkSMSessionClient.h" #include "vtkSMSessionProxyManager.h" #include "vtkSMViewProxy.h" #include "vtkToolkits.h" // Qt includes. #include <QColor> #include <QCoreApplication> #include <QDir> #include <QStringList> #include <QTimer> #include <QtDebug> class pqServer::pqInternals { public: QPointer<pqTimeKeeper> TimeKeeper; // Used to send an heart beat message to the server to avoid // inactivity timeouts. QTimer HeartbeatTimer; int IdleServerMessageCounter; vtkNew<vtkEventQtSlotConnect> VTKConnect; vtkWeakPointer<vtkSMCollaborationManager> CollaborationCommunicator; }; ///////////////////////////////////////////////////////////////////////////////////////////// // pqServer //----------------------------------------------------------------------------- pqServer::pqServer(vtkIdType connectionID, vtkPVOptions* options, QObject* _parent) : pqServerManagerModelItem(_parent) { this->Internals = new pqInternals; this->ConnectionID = connectionID; this->Options = options; this->Session = vtkSMSession::SafeDownCast(vtkProcessModule::GetProcessModule()->GetSession(connectionID)); vtkPVServerInformation* serverInfo = this->getServerInformation(); if (this->isRemote() && serverInfo && serverInfo->GetTimeout() > 0) { int timeout = serverInfo->GetTimeout(); if (timeout > 5) { // 5 minute warning is shown only if timeout > 5. QTimer::singleShot((timeout - 5) * 60 * 1000, this, SIGNAL(fiveMinuteTimeoutWarning())); } // 1 minute warning. QTimer::singleShot((timeout - 1) * 60 * 1000, this, SIGNAL(finalTimeoutWarning())); } QObject::connect(&this->Internals->HeartbeatTimer, SIGNAL(timeout()), this, SLOT(heartBeat())); this->setHeartBeatTimeout(pqServer::getHeartBeatTimeoutSetting()); // Setup idle Timer for collaboration in order to get server notification this->IdleCollaborationTimer.setInterval(100); this->IdleCollaborationTimer.setSingleShot(true); QObject::connect( &this->IdleCollaborationTimer, SIGNAL(timeout()), this, SLOT(processServerNotification())); // Monitor server crash for better error management this->Internals->VTKConnect->Connect(this->Session, vtkPVSessionBase::ConnectionLost, this, SLOT(onConnectionLost(vtkObject*, ulong, void*, void*))); // In case of Multi-clients connection, the client has to listen // server notification so collaboration could happen if (this->session()->IsMultiClients()) { vtkSMSessionClient* currentSession = vtkSMSessionClient::SafeDownCast(this->session()); if (currentSession) { // Initialise the CollaborationManager to listen server notification this->Internals->CollaborationCommunicator = currentSession->GetCollaborationManager(); this->Internals->VTKConnect->Connect(currentSession->GetCollaborationManager(), vtkCommand::AnyEvent, this, SLOT(onCollaborationCommunication(vtkObject*, ulong, void*, void*))); } this->setMonitorServerNotifications(true); } } //----------------------------------------------------------------------------- pqServer::~pqServer() { // Close the connection. /* It's not good to disonnect when the object is destroyed, since the connection was not created when the object was created. Let who ever created the connection, close it. */ /* if (this->ConnectionID != vtkProcessModuleConnectionManager::GetNullConnectionID() && this->ConnectionID != vtkProcessModuleConnectionManager::GetSelfConnectionID()) { vtkProcessModule::GetProcessModule()->Disconnect(this->ConnectionID); } */ this->ConnectionID = 0; this->Session = NULL; delete this->Internals; } //----------------------------------------------------------------------------- void pqServer::setMonitorServerNotifications(bool val) { if (val) { this->IdleCollaborationTimer.start(); } else { this->IdleCollaborationTimer.stop(); } } //----------------------------------------------------------------------------- pqTimeKeeper* pqServer::getTimeKeeper() const { if (!this->Internals->TimeKeeper) { vtkNew<vtkSMParaViewPipelineController> controller; vtkSMProxy* proxy = controller->FindTimeKeeper(this->session()); pqServerManagerModel* smmodel = pqApplicationCore::instance()->getServerManagerModel(); this->Internals->TimeKeeper = smmodel->findItem<pqTimeKeeper*>(proxy); } return this->Internals->TimeKeeper; } //----------------------------------------------------------------------------- vtkSMSession* pqServer::session() const { return this->Session.GetPointer(); } //----------------------------------------------------------------------------- vtkSMProxySelectionModel* pqServer::activeSourcesSelectionModel() const { vtkSMSessionProxyManager* pxm = this->proxyManager(); return pxm->GetSelectionModel("ActiveSources"); } //----------------------------------------------------------------------------- vtkSMProxySelectionModel* pqServer::activeViewSelectionModel() const { vtkSMSessionProxyManager* pxm = this->proxyManager(); return pxm->GetSelectionModel("ActiveView"); } //----------------------------------------------------------------------------- const pqServerResource& pqServer::getResource() { return this->Resource; } //----------------------------------------------------------------------------- vtkIdType pqServer::GetConnectionID() const { return this->ConnectionID; } //----------------------------------------------------------------------------- int pqServer::getNumberOfPartitions() { return this->Session->GetNumberOfProcesses( vtkPVSession::DATA_SERVER | vtkPVSession::RENDER_SERVER); } //----------------------------------------------------------------------------- bool pqServer::isRemote() const { return this->Session->IsA("vtkSMSessionClient"); } //----------------------------------------------------------------------------- bool pqServer::isMaster() const { if (this->session()->IsMultiClients()) { vtkSMSessionClient* currentSession = vtkSMSessionClient::SafeDownCast(this->session()); if (currentSession) { return currentSession->GetCollaborationManager()->IsMaster(); } } return true; } //----------------------------------------------------------------------------- bool pqServer::isRenderServerSeparate() { if (this->isRemote()) { return this->Session->GetController(vtkPVSession::DATA_SERVER_ROOT) != this->Session->GetController(vtkPVSession::RENDER_SERVER_ROOT); } return false; } //----------------------------------------------------------------------------- void pqServer::setResource(const pqServerResource& server_resource) { this->Resource = server_resource; emit this->nameChanged(this); } //----------------------------------------------------------------------------- vtkPVOptions* pqServer::getOptions() const { return this->Options; } //----------------------------------------------------------------------------- vtkPVServerInformation* pqServer::getServerInformation() const { return this->Session->GetServerInformation(); } //----------------------------------------------------------------------------- bool pqServer::isProgressPending() const { return (this->Session && this->Session->GetPendingProgress()); } //----------------------------------------------------------------------------- void pqServer::setHeartBeatTimeout(int msec) { // no need to set heart beats if not a remote connection. if (this->isRemote()) { if (msec <= 0) { this->Internals->HeartbeatTimer.stop(); } else { this->heartBeat(); this->Internals->HeartbeatTimer.start(msec); } } } //----------------------------------------------------------------------------- void pqServer::heartBeat() { // Send random stream to all processes to produce some traffic and prevent // automatic disconnection if (this->Session && !this->Session->GetPendingProgress()) { vtkClientServerStream stream; stream << vtkClientServerStream::Invoke << "HeartBeat" << vtkClientServerStream::End; this->Session->ExecuteStream(vtkPVSession::SERVERS, stream, true); } } //----------------------------------------------------------------------------- const char* pqServer::HEARBEAT_TIME_SETTING_KEY() { return "/server/HeartBeatTime"; } //----------------------------------------------------------------------------- void pqServer::setHeartBeatTimeoutSetting(int msec) { pqApplicationCore* core = pqApplicationCore::instance(); pqSettings* settings = core->settings(); if (settings) { settings->setValue(pqServer::HEARBEAT_TIME_SETTING_KEY(), QVariant(msec)); } // update all current servers. pqServerManagerModel* smmodel = core->getServerManagerModel(); QList<pqServer*> servers = smmodel->findItems<pqServer*>(); foreach (pqServer* server, servers) { server->setHeartBeatTimeout(msec); } } //----------------------------------------------------------------------------- int pqServer::getHeartBeatTimeoutSetting() { pqApplicationCore* core = pqApplicationCore::instance(); pqSettings* settings = core->settings(); if (settings && settings->contains(pqServer::HEARBEAT_TIME_SETTING_KEY())) { bool ok; int timeout = settings->value(pqServer::HEARBEAT_TIME_SETTING_KEY()).toInt(&ok); if (ok) { return timeout; } } return 1 * 60 * 1000; // 1 minutes. } //----------------------------------------------------------------------------- vtkSMSessionProxyManager* pqServer::proxyManager() const { return this->Session->GetSessionProxyManager(); } //----------------------------------------------------------------------------- void pqServer::processServerNotification() { vtkSMSessionClient* sessionClient = vtkSMSessionClient::SafeDownCast(this->Session); if ((sessionClient && !sessionClient->IsNotBusy()) || this->isProgressPending()) { // try again later. this->IdleCollaborationTimer.start(); return; } // process all server-notification events. vtkNetworkAccessManager* nam = vtkProcessModule::GetProcessModule()->GetNetworkAccessManager(); while (nam->ProcessEvents(1) == 1) { } foreach (pqView* view, pqApplicationCore::instance()->findChildren<pqView*>()) { vtkSMViewProxy* viewProxy = view->getViewProxy(); if (viewProxy && viewProxy->HasDirtyRepresentation()) { view->render(); } } this->IdleCollaborationTimer.start(); } //----------------------------------------------------------------------------- void pqServer::onCollaborationCommunication( vtkObject* vtkNotUsed(src), unsigned long event_, void* vtkNotUsed(method), void* data) { int userId; QString userName; switch (event_) { case vtkSMCollaborationManager::UpdateUserName: userId = *reinterpret_cast<int*>(data); userName = this->Internals->CollaborationCommunicator->GetUserLabel(userId); emit triggeredUserName(userId, userName); break; case vtkSMCollaborationManager::UpdateUserList: emit triggeredUserListChanged(); break; case vtkSMCollaborationManager::UpdateMasterUser: userId = *reinterpret_cast<int*>(data); emit triggeredMasterUser(userId); break; case vtkSMCollaborationManager::FollowUserCamera: userId = *reinterpret_cast<int*>(data); emit triggerFollowCamera(userId); break; case vtkSMCollaborationManager::CollaborationNotification: vtkSMMessage* msg = reinterpret_cast<vtkSMMessage*>(data); emit sentFromOtherClient(this, msg); break; } } //----------------------------------------------------------------------------- void pqServer::onConnectionLost(vtkObject*, unsigned long, void*, void*) { emit serverSideDisconnected(); } //----------------------------------------------------------------------------- void pqServer::sendToOtherClients(vtkSMMessage* msg) { if (this->Internals->CollaborationCommunicator) { this->Internals->CollaborationCommunicator->SendToOtherClients(msg); } } //----------------------------------------------------------------------------- bool pqServer::isProcessingPending() const { // check with the network access manager if there are any messages to receive // from the server. bool retVal = vtkProcessModule::GetProcessModule()->GetNetworkAccessManager()->GetNetworkEventsAvailable(); return retVal; }
32.604027
97
0.609236
trickyMan
160b31462b4174fd7bbc4b77f9649702e9566f29
670
hpp
C++
wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/img_data.hpp
QuoZer/MYNT-EYE-S-SDK
77145e29a733331ed0fb0a59e8ea7e6fad19c716
[ "Apache-2.0" ]
188
2018-11-08T12:06:26.000Z
2022-03-01T07:22:52.000Z
wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/img_data.hpp
QuoZer/MYNT-EYE-S-SDK
77145e29a733331ed0fb0a59e8ea7e6fad19c716
[ "Apache-2.0" ]
115
2018-11-17T07:44:28.000Z
2022-03-31T11:28:25.000Z
wrappers/android/mynteye/libmynteye/src/main/cpp/mynteye/cpp/img_data.hpp
QuoZer/MYNT-EYE-S-SDK
77145e29a733331ed0fb0a59e8ea7e6fad19c716
[ "Apache-2.0" ]
128
2018-11-14T21:16:43.000Z
2022-01-27T14:14:56.000Z
// AUTOGENERATED FILE - DO NOT MODIFY! // This file generated by Djinni from mynteye_types.djinni #pragma once #include <cstdint> #include <utility> namespace mynteye_jni { /** Image data */ struct ImgData final { /** Image frame id */ int64_t frame_id; /** Image timestamp in 1us */ int64_t timestamp; /** Image exposure time, virtual value in [1, 480] */ int64_t exposure_time; ImgData(int64_t frame_id_, int64_t timestamp_, int64_t exposure_time_) : frame_id(std::move(frame_id_)) , timestamp(std::move(timestamp_)) , exposure_time(std::move(exposure_time_)) {} }; } // namespace mynteye_jni
22.333333
58
0.661194
QuoZer
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
160c4a573131ff8f14d5debcaaee017226e87356
11,317
cpp
C++
fxjs/xfa/cjx_instancemanager.cpp
TinkerBoard2-Android/external-pdfium
28a4b160ec7f645f5fa83318c798abb611b37419
[ "Apache-2.0" ]
142
2019-11-12T02:20:39.000Z
2022-03-30T05:45:26.000Z
fxjs/xfa/cjx_instancemanager.cpp
TinkerBoard2-Android/external-pdfium
28a4b160ec7f645f5fa83318c798abb611b37419
[ "Apache-2.0" ]
3
2020-10-22T10:40:55.000Z
2022-02-19T10:00:51.000Z
fxjs/xfa/cjx_instancemanager.cpp
TinkerBoard2-Android/external-pdfium
28a4b160ec7f645f5fa83318c798abb611b37419
[ "Apache-2.0" ]
28
2019-12-24T09:30:32.000Z
2022-03-30T05:46:29.000Z
// Copyright 2017 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. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "fxjs/xfa/cjx_instancemanager.h" #include <algorithm> #include <vector> #include "fxjs/js_resources.h" #include "fxjs/xfa/cfxjse_engine.h" #include "fxjs/xfa/cfxjse_value.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_instancemanager.h" #include "xfa/fxfa/parser/cxfa_occur.h" const CJX_MethodSpec CJX_InstanceManager::MethodSpecs[] = { {"addInstance", addInstance_static}, {"insertInstance", insertInstance_static}, {"moveInstance", moveInstance_static}, {"removeInstance", removeInstance_static}, {"setInstances", setInstances_static}}; CJX_InstanceManager::CJX_InstanceManager(CXFA_InstanceManager* mgr) : CJX_Node(mgr) { DefineMethods(MethodSpecs); } CJX_InstanceManager::~CJX_InstanceManager() {} bool CJX_InstanceManager::DynamicTypeIs(TypeTag eType) const { return eType == static_type__ || ParentType__::DynamicTypeIs(eType); } int32_t CJX_InstanceManager::SetInstances(int32_t iDesired) { CXFA_Occur* occur = GetXFANode()->GetOccurIfExists(); int32_t iMin = occur ? occur->GetMin() : CXFA_Occur::kDefaultMin; if (iDesired < iMin) { ThrowTooManyOccurancesException(L"min"); return 1; } int32_t iMax = occur ? occur->GetMax() : CXFA_Occur::kDefaultMax; if (iMax >= 0 && iDesired > iMax) { ThrowTooManyOccurancesException(L"max"); return 2; } int32_t iCount = GetXFANode()->GetCount(); if (iDesired == iCount) return 0; if (iDesired < iCount) { WideString wsInstManagerName = GetCData(XFA_Attribute::Name); WideString wsInstanceName = WideString( wsInstManagerName.IsEmpty() ? wsInstManagerName : wsInstManagerName.Last(wsInstManagerName.GetLength() - 1)); uint32_t dInstanceNameHash = FX_HashCode_GetW(wsInstanceName.AsStringView(), false); CXFA_Node* pPrevSibling = iDesired == 0 ? GetXFANode() : GetXFANode()->GetItemIfExists(iDesired - 1); if (!pPrevSibling) { // TODO(dsinclair): Better error? ThrowIndexOutOfBoundsException(); return 0; } while (iCount > iDesired) { CXFA_Node* pRemoveInstance = pPrevSibling->GetNextSibling(); if (pRemoveInstance->GetElementType() != XFA_Element::Subform && pRemoveInstance->GetElementType() != XFA_Element::SubformSet) { continue; } if (pRemoveInstance->GetElementType() == XFA_Element::InstanceManager) { NOTREACHED(); break; } if (pRemoveInstance->GetNameHash() == dInstanceNameHash) { GetXFANode()->RemoveItem(pRemoveInstance, true); iCount--; } } } else { while (iCount < iDesired) { CXFA_Node* pNewInstance = GetXFANode()->CreateInstanceIfPossible(true); if (!pNewInstance) return 0; GetXFANode()->InsertItem(pNewInstance, iCount, iCount, false); ++iCount; CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) return 0; pNotify->RunNodeInitialize(pNewInstance); } } GetDocument()->GetLayoutProcessor()->AddChangedContainer( ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); return 0; } int32_t CJX_InstanceManager::MoveInstance(int32_t iTo, int32_t iFrom) { int32_t iCount = GetXFANode()->GetCount(); if (iFrom > iCount || iTo > iCount - 1) { ThrowIndexOutOfBoundsException(); return 1; } if (iFrom < 0 || iTo < 0 || iFrom == iTo) return 0; CXFA_Node* pMoveInstance = GetXFANode()->GetItemIfExists(iFrom); if (!pMoveInstance) { ThrowIndexOutOfBoundsException(); return 1; } GetXFANode()->RemoveItem(pMoveInstance, false); GetXFANode()->InsertItem(pMoveInstance, iTo, iCount - 1, true); GetDocument()->GetLayoutProcessor()->AddChangedContainer( ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); return 0; } CJS_Result CJX_InstanceManager::moveInstance( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { CXFA_Document* doc = static_cast<CFXJSE_Engine*>(runtime)->GetDocument(); if (doc->GetFormType() != FormType::kXFAFull) return CJS_Result::Failure(JSMessage::kNotSupportedError); if (params.size() != 2) return CJS_Result::Failure(JSMessage::kParamError); int32_t iFrom = runtime->ToInt32(params[0]); int32_t iTo = runtime->ToInt32(params[1]); MoveInstance(iTo, iFrom); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) return CJS_Result::Success(); CXFA_Node* pToInstance = GetXFANode()->GetItemIfExists(iTo); if (pToInstance && pToInstance->GetElementType() == XFA_Element::Subform) pNotify->RunSubformIndexChange(pToInstance); CXFA_Node* pFromInstance = GetXFANode()->GetItemIfExists(iFrom); if (pFromInstance && pFromInstance->GetElementType() == XFA_Element::Subform) { pNotify->RunSubformIndexChange(pFromInstance); } return CJS_Result::Success(); } CJS_Result CJX_InstanceManager::removeInstance( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { CXFA_Document* doc = static_cast<CFXJSE_Engine*>(runtime)->GetDocument(); if (doc->GetFormType() != FormType::kXFAFull) return CJS_Result::Failure(JSMessage::kNotSupportedError); if (params.size() != 1) return CJS_Result::Failure(JSMessage::kParamError); int32_t iIndex = runtime->ToInt32(params[0]); int32_t iCount = GetXFANode()->GetCount(); if (iIndex < 0 || iIndex >= iCount) return CJS_Result::Failure(JSMessage::kInvalidInputError); CXFA_Occur* occur = GetXFANode()->GetOccurIfExists(); int32_t iMin = occur ? occur->GetMin() : CXFA_Occur::kDefaultMin; if (iCount - 1 < iMin) return CJS_Result::Failure(JSMessage::kTooManyOccurances); CXFA_Node* pRemoveInstance = GetXFANode()->GetItemIfExists(iIndex); if (!pRemoveInstance) return CJS_Result::Failure(JSMessage::kParamError); GetXFANode()->RemoveItem(pRemoveInstance, true); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (pNotify) { for (int32_t i = iIndex; i < iCount - 1; i++) { CXFA_Node* pSubformInstance = GetXFANode()->GetItemIfExists(i); if (pSubformInstance && pSubformInstance->GetElementType() == XFA_Element::Subform) { pNotify->RunSubformIndexChange(pSubformInstance); } } } GetDocument()->GetLayoutProcessor()->AddChangedContainer( ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); return CJS_Result::Success(); } CJS_Result CJX_InstanceManager::setInstances( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { CXFA_Document* doc = static_cast<CFXJSE_Engine*>(runtime)->GetDocument(); if (doc->GetFormType() != FormType::kXFAFull) return CJS_Result::Failure(JSMessage::kNotSupportedError); if (params.size() != 1) return CJS_Result::Failure(JSMessage::kParamError); SetInstances(runtime->ToInt32(params[0])); return CJS_Result::Success(); } CJS_Result CJX_InstanceManager::addInstance( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { CXFA_Document* doc = static_cast<CFXJSE_Engine*>(runtime)->GetDocument(); if (doc->GetFormType() != FormType::kXFAFull) return CJS_Result::Failure(JSMessage::kNotSupportedError); if (!params.empty() && params.size() != 1) return CJS_Result::Failure(JSMessage::kParamError); bool fFlags = true; if (params.size() == 1) fFlags = runtime->ToBoolean(params[0]); int32_t iCount = GetXFANode()->GetCount(); CXFA_Occur* occur = GetXFANode()->GetOccurIfExists(); int32_t iMax = occur ? occur->GetMax() : CXFA_Occur::kDefaultMax; if (iMax >= 0 && iCount >= iMax) return CJS_Result::Failure(JSMessage::kTooManyOccurances); CXFA_Node* pNewInstance = GetXFANode()->CreateInstanceIfPossible(fFlags); if (!pNewInstance) return CJS_Result::Success(runtime->NewNull()); GetXFANode()->InsertItem(pNewInstance, iCount, iCount, false); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (pNotify) { pNotify->RunNodeInitialize(pNewInstance); GetDocument()->GetLayoutProcessor()->AddChangedContainer( ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); } CFXJSE_Value* value = GetDocument()->GetScriptContext()->GetOrCreateJSBindingFromMap( pNewInstance); return CJS_Result::Success( value->DirectGetValue().Get(runtime->GetIsolate())); } CJS_Result CJX_InstanceManager::insertInstance( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { CXFA_Document* doc = static_cast<CFXJSE_Engine*>(runtime)->GetDocument(); if (doc->GetFormType() != FormType::kXFAFull) return CJS_Result::Failure(JSMessage::kNotSupportedError); if (params.size() != 1 && params.size() != 2) return CJS_Result::Failure(JSMessage::kParamError); int32_t iIndex = runtime->ToInt32(params[0]); bool bBind = false; if (params.size() == 2) bBind = runtime->ToBoolean(params[1]); int32_t iCount = GetXFANode()->GetCount(); if (iIndex < 0 || iIndex > iCount) return CJS_Result::Failure(JSMessage::kInvalidInputError); CXFA_Occur* occur = GetXFANode()->GetOccurIfExists(); int32_t iMax = occur ? occur->GetMax() : CXFA_Occur::kDefaultMax; if (iMax >= 0 && iCount >= iMax) return CJS_Result::Failure(JSMessage::kInvalidInputError); CXFA_Node* pNewInstance = GetXFANode()->CreateInstanceIfPossible(bBind); if (!pNewInstance) return CJS_Result::Success(runtime->NewNull()); GetXFANode()->InsertItem(pNewInstance, iIndex, iCount, true); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (pNotify) { pNotify->RunNodeInitialize(pNewInstance); GetDocument()->GetLayoutProcessor()->AddChangedContainer( ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); } CFXJSE_Value* value = GetDocument()->GetScriptContext()->GetOrCreateJSBindingFromMap( pNewInstance); return CJS_Result::Success( value->DirectGetValue().Get(runtime->GetIsolate())); } void CJX_InstanceManager::max(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { ThrowInvalidPropertyException(); return; } CXFA_Occur* occur = GetXFANode()->GetOccurIfExists(); pValue->SetInteger(occur ? occur->GetMax() : CXFA_Occur::kDefaultMax); } void CJX_InstanceManager::min(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { ThrowInvalidPropertyException(); return; } CXFA_Occur* occur = GetXFANode()->GetOccurIfExists(); pValue->SetInteger(occur ? occur->GetMin() : CXFA_Occur::kDefaultMin); } void CJX_InstanceManager::count(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { SetInstances(pValue->ToInteger()); return; } pValue->SetInteger(GetXFANode()->GetCount()); }
33.78209
80
0.688257
TinkerBoard2-Android
161014f4147af3d66bd7a7a4f476dca61f764bf9
1,108
cc
C++
garnet/examples/fidl/echo_client_cpp_synchronous/echo_client.cc
zhangpf/fuchsia-rs
903568f28ddf45f09157ead36d61b50322c9cf49
[ "BSD-3-Clause" ]
null
null
null
garnet/examples/fidl/echo_client_cpp_synchronous/echo_client.cc
zhangpf/fuchsia-rs
903568f28ddf45f09157ead36d61b50322c9cf49
[ "BSD-3-Clause" ]
5
2020-09-06T09:02:06.000Z
2022-03-02T04:44:22.000Z
garnet/examples/fidl/echo_client_cpp_synchronous/echo_client.cc
ZVNexus/fuchsia
c5610ad15208208c98693618a79c705af935270c
[ "BSD-3-Clause" ]
null
null
null
// Copyright 2019 The Fuchsia 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 <fidl/examples/echo/cpp/fidl.h> #include <lib/async-loop/cpp/loop.h> #include <lib/async/default.h> #include <lib/sys/cpp/component_context.h> #include <lib/zx/process.h> #include <zircon/processargs.h> #include "echo_client_app.h" int main(int argc, const char** argv) { std::string server_url = "fuchsia-pkg://fuchsia.com/echo_server_cpp#meta/echo_server_cpp.cmx"; std::string msg = "hello synchronous world"; for (int i = 1; i < argc - 1; ++i) { if (!strcmp("--server", argv[i])) { server_url = argv[++i]; } else if (!strcmp("-m", argv[i])) { msg = argv[++i]; } } async::Loop loop(&kAsyncLoopConfigAttachToThread); echo::EchoClientApp app; app.Start(server_url); ::fidl::StringPtr result; app.echo_sync()->EchoString(msg, &result); if (result) { printf("***** Sync Response: %s\n", result->data()); } else { printf("***** Sync Response: none\n"); } return 0; }
27.02439
75
0.650722
zhangpf
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
1615989d73459a7848ee3442e316901762180701
10,160
cpp
C++
zircon/system/dev/audio/intel-hda/controller/intel-dsp-ipc.cpp
yanyushr/fuchsia
98e70672a81a206d235503e398f37b7b65581f79
[ "BSD-3-Clause" ]
1
2019-10-09T10:50:57.000Z
2019-10-09T10:50:57.000Z
zircon/system/dev/audio/intel-hda/controller/intel-dsp-ipc.cpp
bootingman/fuchsia2
04012f0aa1edd1d4108a2ac647a65e59730fc4c2
[ "BSD-3-Clause" ]
null
null
null
zircon/system/dev/audio/intel-hda/controller/intel-dsp-ipc.cpp
bootingman/fuchsia2
04012f0aa1edd1d4108a2ac647a65e59730fc4c2
[ "BSD-3-Clause" ]
null
null
null
// Copyright 2018 The Fuchsia 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 <fbl/alloc_checker.h> #include <fbl/auto_call.h> #include <fbl/auto_lock.h> #include <string.h> #include "intel-dsp-ipc.h" #include "intel-dsp.h" namespace audio { namespace intel_hda { IntelDspIpc::IntelDspIpc(IntelDsp* dsp) : dsp_(dsp) { snprintf(log_prefix_, sizeof(log_prefix_), "IHDA DSP IPC (unknown BDF)"); } void IntelDspIpc::SetLogPrefix(const char* new_prefix) { snprintf(log_prefix_, sizeof(log_prefix_), "%s IPC", new_prefix); } void IntelDspIpc::Shutdown() { fbl::AutoLock ipc_lock(&ipc_lock_); // Fail all pending IPCs while (!ipc_queue_.is_empty()) { sync_completion_signal(&ipc_queue_.pop_front()->completion); } } void IntelDspIpc::SendIpc(const Txn& txn) { // Copy tx data to outbox if (txn.tx_size > 0) { dsp_->IpcMailboxWrite(txn.tx_data, txn.tx_size); } dsp_->SendIpcMessage(txn.request); } zx_status_t IntelDspIpc::SendIpcWait(Txn* txn) { { // Add to the pending queue and start the ipc if necessary fbl::AutoLock ipc_lock(&ipc_lock_); bool needs_start = ipc_queue_.is_empty(); ipc_queue_.push_back(txn); if (needs_start) { SendIpc(ipc_queue_.front()); } } // Wait for completion zx_status_t res = sync_completion_wait(&txn->completion, ZX_MSEC(300)); if (res != ZX_OK) { dsp_->DeviceShutdown(); } // TODO(yky): ZX-2261: Figure out why this is needed and eliminate it. zx_nanosleep(zx_deadline_after(ZX_MSEC(1))); return res; } zx_status_t IntelDspIpc::InitInstance(uint16_t module_id, uint8_t instance_id, ProcDomain proc_domain, uint8_t core_id, uint8_t ppl_instance_id, uint16_t param_block_size, const void* param_data) { LOG(DEBUG1, "INIT_INSTANCE (mod %u inst %u)\n", module_id, instance_id); Txn txn(IPC_PRI(MsgTarget::MODULE_MSG, MsgDir::MSG_REQUEST, ModuleMsgType::INIT_INSTANCE, instance_id, module_id), IPC_INIT_INSTANCE_EXT(proc_domain, core_id, ppl_instance_id, param_block_size), param_data, param_block_size, nullptr, 0); zx_status_t res = SendIpcWait(&txn); if (res != ZX_OK) { LOG(ERROR, "IPC error (res %d)\n", res); return res; } if (txn.reply.status() != MsgStatus::IPC_SUCCESS) { LOG(ERROR, "INIT_INSTANCE (mod %u inst %u) failed (err %d)\n", module_id, instance_id, to_underlying(txn.reply.status())); } else { LOG(DEBUG1, "INIT_INSTANCE (mod %u inst %u) success\n", module_id, instance_id); } return dsp_to_zx_status(txn.reply.status()); } zx_status_t IntelDspIpc::LargeConfigGet(Txn* txn, uint16_t module_id, uint8_t instance_id, uint8_t large_param_id, uint32_t data_off_size) { ZX_DEBUG_ASSERT(txn->rx_data != nullptr); ZX_DEBUG_ASSERT(txn->rx_size > 0); LOG(DEBUG1, "LARGE_CONFIG_GET (mod %u inst %u large_param_id %u)\n", module_id, instance_id, large_param_id); txn->request.primary = IPC_PRI(MsgTarget::MODULE_MSG, MsgDir::MSG_REQUEST, ModuleMsgType::LARGE_CONFIG_GET, instance_id, module_id); txn->request.extension = IPC_LARGE_CONFIG_EXT(true, false, large_param_id, data_off_size); zx_status_t res = SendIpcWait(txn); if (res != ZX_OK) { LOG(ERROR, "IPC error (res %d)\n", res); return res; } LOG(DEBUG1, "LARGE_CONFIG_GET (mod %u inst %u large_param_id %u) status %d\n", module_id, instance_id, large_param_id, to_underlying(txn->reply.status())); return dsp_to_zx_status(txn->reply.status()); } zx_status_t IntelDspIpc::Bind(uint16_t src_module_id, uint8_t src_instance_id, uint8_t src_queue, uint16_t dst_module_id, uint8_t dst_instance_id, uint8_t dst_queue) { LOG(DEBUG1, "BIND (mod %u inst %u -> mod %u inst %u)\n", src_module_id, src_instance_id, dst_module_id, dst_instance_id); Txn txn(IPC_PRI(MsgTarget::MODULE_MSG, MsgDir::MSG_REQUEST, ModuleMsgType::BIND, src_instance_id, src_module_id), IPC_BIND_UNBIND_EXT(dst_module_id, dst_instance_id, dst_queue, src_queue), nullptr, 0, nullptr, 0); zx_status_t res = SendIpcWait(&txn); if (res != ZX_OK) { LOG(ERROR, "IPC error (res %d)\n", res); return res; } if (txn.reply.status() != MsgStatus::IPC_SUCCESS) { LOG(ERROR, "BIND (mod %u inst %u -> mod %u inst %u) failed (err %d)\n", src_module_id, src_instance_id, dst_module_id, dst_instance_id, to_underlying(txn.reply.status())); } else { LOG(DEBUG1, "BIND (mod %u inst %u -> mod %u inst %u) success\n", src_module_id, src_instance_id, dst_module_id, dst_instance_id); } return dsp_to_zx_status(txn.reply.status()); } zx_status_t IntelDspIpc::CreatePipeline(uint8_t instance_id, uint8_t ppl_priority, uint16_t ppl_mem_size, bool lp) { LOG(DEBUG1, "CREATE_PIPELINE (inst %u)\n", instance_id); Txn txn(IPC_CREATE_PIPELINE_PRI(instance_id, ppl_priority, ppl_mem_size), IPC_CREATE_PIPELINE_EXT(lp), nullptr, 0, nullptr, 0); zx_status_t res = SendIpcWait(&txn); if (res != ZX_OK) { LOG(ERROR, "IPC error (res %d)\n", res); return res; } if (txn.reply.status() != MsgStatus::IPC_SUCCESS) { LOG(ERROR, "CREATE_PIPELINE (inst %u) failed (err %d)\n", instance_id, to_underlying(txn.reply.status())); } else { LOG(DEBUG1, "CREATE_PIPELINE (inst %u) success\n", instance_id); } return dsp_to_zx_status(txn.reply.status()); } zx_status_t IntelDspIpc::SetPipelineState(uint8_t ppl_id, PipelineState state, bool sync_stop_start) { LOG(DEBUG1, "SET_PIPELINE_STATE (inst %u)\n", ppl_id); Txn txn(IPC_SET_PIPELINE_STATE_PRI(ppl_id, state), IPC_SET_PIPELINE_STATE_EXT(false, sync_stop_start), nullptr, 0, nullptr, 0); zx_status_t res = SendIpcWait(&txn); if (res != ZX_OK) { LOG(ERROR, "IPC error (res %d)\n", res); return res; } if (txn.reply.status() != MsgStatus::IPC_SUCCESS) { LOG(ERROR, "SET_PIPELINE_STATE (inst %u) failed (err %d)\n", ppl_id, to_underlying(txn.reply.status())); } else { LOG(DEBUG1, "SET_PIPELINE_STATE (inst %u) success\n", ppl_id); } return dsp_to_zx_status(txn.reply.status()); } void IntelDspIpc::ProcessIpc(const IpcMessage& message) { if (message.is_notif()) { ProcessIpcNotification(message); } else if (message.is_reply()) { ProcessIpcReply(message); } } void IntelDspIpc::ProcessIpcNotification(const IpcMessage& notif) { switch (notif.notif_type()) { case NotificationType::FW_READY: LOG(TRACE, "firmware ready\n"); sync_completion_signal(&fw_ready_completion_); break; case NotificationType::RESOURCE_EVENT: { ResourceEventData data; dsp_->IpcMailboxRead(&data, sizeof(data)); #if 0 LOG(INFO, "resource event type %u id %u event %u\n", data.resource_type, data.resource_id, data.event_type); #endif break; } default: LOG(INFO, "got notification type %u\n", to_underlying(notif.notif_type())); break; } } void IntelDspIpc::ProcessIpcReply(const IpcMessage& reply) { fbl::AutoLock ipc_lock(&ipc_lock_); if (ipc_queue_.is_empty()) { LOG(INFO, "got spurious reply message\n"); return; } Txn& pending = ipc_queue_.front(); // Check if the reply matches the pending request. IpcMessage* req = &pending.request; if ((req->msg_tgt() != reply.msg_tgt()) || (req->type() != reply.type())) { LOG(INFO, "reply msg mismatch, got pri 0x%08x ext 0x%08x, expect pri 0x%08x ext 0x%08x\n", reply.primary, reply.extension, req->primary, req->extension); return; } // The pending txn is done ipc_queue_.pop_front(); pending.reply = reply; pending.done = true; LOG(DEBUG1, "got reply (status %u) for pending msg, pri 0x%08x ext 0x%08x\n", to_underlying(reply.status()), reply.primary, reply.extension); if (reply.msg_tgt() == MsgTarget::MODULE_MSG) { ModuleMsgType type = static_cast<ModuleMsgType>(reply.type()); switch (type) { case ModuleMsgType::LARGE_CONFIG_GET: ProcessLargeConfigGetReply(&pending); break; default: break; } } sync_completion_signal(&pending.completion); // Send the next ipc in the queue if (!ipc_queue_.is_empty()) { SendIpc(ipc_queue_.front()); } } void IntelDspIpc::ProcessLargeConfigGetReply(Txn* txn) { ZX_DEBUG_ASSERT_MSG(txn->request.large_param_id() == txn->reply.large_param_id(), "large_param_id mismatch, expected %u got %u\n", txn->request.large_param_id(), txn->reply.large_param_id()); LOG(DEBUG1, "got LARGE_CONFIG_GET reply, id %u init_block %d final_block %d data_off_size %u\n", txn->reply.large_param_id(), txn->reply.init_block(), txn->reply.final_block(), txn->reply.data_off_size()); if (txn->reply.status() == MsgStatus::IPC_SUCCESS) { // Only support single reads for now. uint32_t size = txn->reply.data_off_size(); ZX_DEBUG_ASSERT(txn->reply.init_block()); ZX_DEBUG_ASSERT(txn->reply.final_block()); ZX_DEBUG_ASSERT(size > 0); ZX_DEBUG_ASSERT(size <= txn->rx_size); dsp_->IpcMailboxRead(txn->rx_data, size); txn->rx_actual = size; } else { txn->rx_actual = 0; } } } // namespace intel_hda } // namespace audio
35.649123
100
0.626772
yanyushr
1619673d46a476b904da8524f204e7eeb9000d54
696
cpp
C++
multimedia/dshow/vidctl/msvidctl/dvbslocator.cpp
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
multimedia/dshow/vidctl/msvidctl/dvbslocator.cpp
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
multimedia/dshow/vidctl/msvidctl/dvbslocator.cpp
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
///////////////////////////////////////////////////////////////////////////////////// // DVBSLocator.cpp : Implementation of CDVBSLocator // Copyright (c) Microsoft Corporation 1999-2000. #include "stdafx.h" #include "Tuner.h" #include "DVBSLocator.h" DEFINE_EXTERN_OBJECT_ENTRY(CLSID_DVBSLocator, CDVBSLocator) ///////////////////////////////////////////////////////////////////////////// // CDVBSLocator STDMETHODIMP CDVBSLocator::InterfaceSupportsErrorInfo(REFIID riid) { static const IID* arr[] = { &IID_IDVBSLocator }; for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++) { if (InlineIsEqualGUID(*arr[i],riid)) return S_OK; } return S_FALSE; }
24.857143
86
0.524425
npocmaka
16197941daf8eabbf85fc5e1c22eaf040fb83c41
5,406
cpp
C++
shell/services/lpc/queue.cpp
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
shell/services/lpc/queue.cpp
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
shell/services/lpc/queue.cpp
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
// -------------------------------------------------------------------------- // Module Name: Queue.cpp // // Copyright (c) 1999-2000, Microsoft Corporation // // This file contains a class to handle a queue element and a class to handle // a queue of queue elements. // // History: 1999-11-07 vtan created // 2000-08-25 vtan moved from Neptune to Whistler // -------------------------------------------------------------------------- #include "StandardHeader.h" #include "Queue.h" #include "SingleThreadedExecution.h" // -------------------------------------------------------------------------- // CQueueElement::CQueueElement // // Arguments: <none> // // Returns: <none> // // Purpose: Constructor for CQueueElement. // // History: 1999-11-07 vtan created // 2000-08-25 vtan moved from Neptune to Whistler // -------------------------------------------------------------------------- CQueueElement::CQueueElement (void) : _pNextElement(NULL) { } // -------------------------------------------------------------------------- // CQueueElement::~CQueueElement // // Arguments: <none> // // Returns: <none> // // Purpose: Destructor for CQueueElement. // // History: 1999-11-07 vtan created // 2000-08-25 vtan moved from Neptune to Whistler // -------------------------------------------------------------------------- CQueueElement::~CQueueElement (void) { } // -------------------------------------------------------------------------- // CQueue::CQueue // // Arguments: <none> // // Returns: <none> // // Purpose: Constructor for CQueue. // // History: 1999-11-07 vtan created // 2000-08-25 vtan moved from Neptune to Whistler // -------------------------------------------------------------------------- CQueue::CQueue (void) : _pQueue(NULL) { } // -------------------------------------------------------------------------- // CQueue::~CQueue // // Arguments: <none> // // Returns: <none> // // Purpose: Destructor for CQueue. // // History: 1999-11-07 vtan created // 2000-08-25 vtan moved from Neptune to Whistler // -------------------------------------------------------------------------- CQueue::~CQueue (void) { while (_pQueue != NULL) { CQueueElement *pNextElement; pNextElement = _pQueue->_pNextElement; delete _pQueue; _pQueue = pNextElement; } } // -------------------------------------------------------------------------- // CQueue::Add // // Arguments: pQueueElement = CQueueElement to add to the queue. // // Returns: <none> // // Purpose: Adds the CQueueElement to the queue. Queue manipulation is // guarded by a critical section because one thread may be // queuing elements while another thread is processesing them. // // You must provide a dynamically created CQueueElement object. // // History: 1999-11-07 vtan created // 2000-08-25 vtan moved from Neptune to Whistler // -------------------------------------------------------------------------- void CQueue::Add (CQueueElement *pQueueElement) { if (pQueueElement != NULL) { CQueueElement *pCurrentElement, *pLastElement; CSingleThreadedExecution queueLock(_lock); pLastElement = pCurrentElement = _pQueue; while (pCurrentElement != NULL) { pLastElement = pCurrentElement; pCurrentElement = pCurrentElement->_pNextElement; } if (pLastElement != NULL) { pLastElement->_pNextElement = pQueueElement; } else { _pQueue = pQueueElement; } } } // -------------------------------------------------------------------------- // CQueue::Remove // // Arguments: <none> // // Returns: <none> // // Purpose: Removes the first element from the queue. The queue is a // standard FIFO structure. The CQueueElement is deleted. There // is no reference counting because these are internal items. // // History: 1999-11-07 vtan created // 2000-08-25 vtan moved from Neptune to Whistler // -------------------------------------------------------------------------- void CQueue::Remove (void) { CSingleThreadedExecution queueLock(_lock); if (_pQueue != NULL) { CQueueElement *pNextElement; pNextElement = _pQueue->_pNextElement; delete _pQueue; _pQueue = pNextElement; } } // -------------------------------------------------------------------------- // CQueue::Get // // Arguments: <none> // // Returns: CQueueElement* // // Purpose: Returns the first CQueueElement in the queue. // // History: 1999-11-07 vtan created // 2000-08-25 vtan moved from Neptune to Whistler // -------------------------------------------------------------------------- CQueueElement* CQueue::Get (void) const { return(_pQueue); }
28.303665
79
0.431003
npocmaka
161e75e0be224922c0ca3c358c5ccf83bf090f6c
40
cpp
C++
state_machine_cpp/src/builder/builder_layers.cpp
hlefebvr/state_machine_cpp
53186f1e434f53944585195195ce150c3c6a5a0e
[ "Apache-2.0" ]
1
2021-04-28T15:17:10.000Z
2021-04-28T15:17:10.000Z
state_machine_cpp/src/builder/builder_layers.cpp
hlefebvr/state_machine_cpp
53186f1e434f53944585195195ce150c3c6a5a0e
[ "Apache-2.0" ]
null
null
null
state_machine_cpp/src/builder/builder_layers.cpp
hlefebvr/state_machine_cpp
53186f1e434f53944585195195ce150c3c6a5a0e
[ "Apache-2.0" ]
null
null
null
// // Created by henri on 27/04/21. //
8
32
0.55
hlefebvr
161f5296aa0b98e37b6914155c71f3c50b18192a
1,284
cc
C++
c/n1ql-create-primary-index.cc
RichardSmedley/devguide-examples
604d7a03bf7f8dbceed71cb0784b5558ed92b5cf
[ "Apache-2.0" ]
60
2015-10-08T02:58:03.000Z
2021-08-08T17:01:27.000Z
c/n1ql-create-primary-index.cc
RichardSmedley/devguide-examples
604d7a03bf7f8dbceed71cb0784b5558ed92b5cf
[ "Apache-2.0" ]
10
2015-10-29T21:00:20.000Z
2018-06-28T11:07:00.000Z
c/n1ql-create-primary-index.cc
RichardSmedley/devguide-examples
604d7a03bf7f8dbceed71cb0784b5558ed92b5cf
[ "Apache-2.0" ]
50
2015-10-07T20:39:12.000Z
2021-07-12T15:53:26.000Z
#include <libcouchbase/couchbase.h> #include <libcouchbase/ixmgmt.h> static void ixmgmt_callback(lcb_t, int, const lcb_RESPN1XMGMT *resp) { if (resp->rc == LCB_SUCCESS) { printf("Operation successful!\n"); } else if (resp->rc == LCB_KEY_EEXISTS) { printf("Index already exists!\n"); } else { printf("Operation failed: %s\n", lcb_strerror(NULL, resp->rc)); } } int main(int, char **) { lcb_t instance; lcb_create_st crst = {}; crst.version = 3; crst.v.v3.connstr = "couchbase://127.0.0.1/default"; crst.v.v3.username = "testuser"; crst.v.v3.passwd = "password"; lcb_create(&instance, &crst); lcb_connect(instance); lcb_wait(instance); if (lcb_get_bootstrap_status(instance) != LCB_SUCCESS) { printf("Couldn't bootstrap: %s\n", lcb_strerror(NULL, lcb_get_bootstrap_status(instance))); exit(EXIT_FAILURE); } const char *bktname; lcb_cntl(instance, LCB_CNTL_GET, LCB_CNTL_BUCKETNAME, &bktname); lcb_CMDN1XMGMT cmd = {}; cmd.spec.flags = LCB_N1XSPEC_F_PRIMARY; cmd.spec.keyspace = bktname; cmd.spec.nkeyspace = strlen(bktname); cmd.callback = ixmgmt_callback; lcb_n1x_create(instance, NULL, &cmd); lcb_wait(instance); lcb_destroy(instance); }
28.533333
99
0.6581
RichardSmedley
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
1620ab840a14c3a5d102a1a6b299dc0224591b45
4,183
cc
C++
src/fastertransformer/models/swin/swin_gemm.cc
hieuhoang/FasterTransformer
440695ccac874574b1d2e1121788e8fa674b4381
[ "Apache-2.0" ]
null
null
null
src/fastertransformer/models/swin/swin_gemm.cc
hieuhoang/FasterTransformer
440695ccac874574b1d2e1121788e8fa674b4381
[ "Apache-2.0" ]
null
null
null
src/fastertransformer/models/swin/swin_gemm.cc
hieuhoang/FasterTransformer
440695ccac874574b1d2e1121788e8fa674b4381
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2020-2022, NVIDIA CORPORATION. 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 "src/fastertransformer/utils/gemm_test/swin_gemm_func.h" #include "src/fastertransformer/utils/gemm_test/swin_igemm_func.h" #include "src/fastertransformer/utils/memory_utils.h" namespace ft = fastertransformer; int main(int argc, char* argv[]) { if (argc != 8) { printf( "[ERROR] swin_gemm batch_img image_width window_width head_num(of the first block) size_per_head data_type is_int8\n"); printf("e.g. ./bin/swin_gemm 32 224 7 3 32 0 1\n"); return 0; } const int batch_img = atoi(argv[1]); const int image_width = atoi(argv[2]); const int window_width = atoi(argv[3]); const int head_num = atoi(argv[4]); const int size_per_head = atoi(argv[5]); const ft::CublasDataType data_type = static_cast<ft::CublasDataType>(atoi(argv[6])); // 0 FP32, 1 FP16, 2 BF 16 const int is_int8 = atoi(argv[7]); printf("[INFO] arguments: \n"); printf(" batch_img: %d \n", batch_img); printf(" image_width: %d \n", image_width); printf(" window_width: %d \n", window_width); printf(" head_num: %d \n", head_num); printf(" size_per_head: %d \n", size_per_head); printf(" data_type: %d \n", data_type); printf(" is_int8: %d \n", is_int8); std::cout << std::endl; const int patch_width = 4; const int batch_size = batch_img * (image_width / (patch_width * window_width)) * (image_width / (patch_width * window_width)); const int seq_len = window_width * window_width; const int inter_size = 4 * head_num * size_per_head; void* gemm_test_buf; size_t buf_size_in_byte = ft::calGemmTestBufSizeInByte( batch_size, seq_len, head_num, size_per_head, inter_size, 0, 1, ft::FLOAT_DATATYPE); int batch_tmp = batch_size; int head_num_tmp = head_num; for (int i = 1; i < 4; i++) { batch_tmp /= 4; head_num_tmp *= 2; size_t buf_size_tmp = ft::calGemmTestBufSizeInByte( batch_tmp, seq_len, head_num_tmp, size_per_head, 4 * head_num_tmp * size_per_head, 0, is_int8, data_type); if (buf_size_tmp > buf_size_in_byte) { buf_size_in_byte = buf_size_tmp; } } size_t total, free; ft::check_cuda_error(cudaMemGetInfo(&free, &total)); if (free < buf_size_in_byte + 10 * 1024 * 1024) { printf("[ERROR] There is no enough device memory for gemm test!\n" " %ld Bytes is needed, but only %ld Bytes is free.\n", buf_size_in_byte, free); gemm_test_buf = NULL; return -1; } else { ft::deviceMalloc(reinterpret_cast<char**>(&gemm_test_buf), buf_size_in_byte, true); } if (is_int8 != 0) { ft::generate_swin_igemm_config(batch_size, seq_len, head_num, size_per_head, gemm_test_buf, false); } else if (data_type == ft::FLOAT_DATATYPE) { ft::generate_swin_gemm_config<float>(batch_size, seq_len, head_num, size_per_head, gemm_test_buf, false); } else if (data_type == ft::HALF_DATATYPE) { ft::generate_swin_gemm_config<half>(batch_size, seq_len, head_num, size_per_head, gemm_test_buf, false); } #ifdef ENABLE_BF16 else if (data_type == ft::BFLOAT16_DATATYPE) { ft::generate_swin_gemm_config<__nv_bfloat16>( batch_size, seq_len, head_num, size_per_head, gemm_test_buf, false); } #endif else { printf("[ERROR] data type only supports fp32(0), fp16(1), bf16(2). \n"); return -1; } ft::check_cuda_error(cudaFree(gemm_test_buf)); return 0; }
38.731481
131
0.660292
hieuhoang
162127ceffb507d6d7e48319d25efc0df6928620
1,483
cpp
C++
problems/complex_number_multiplication/solution.cpp
sauravchandra1/Leetcode
be89c7d8d93083326a94906a28bfad2342aa1dfe
[ "MIT" ]
null
null
null
problems/complex_number_multiplication/solution.cpp
sauravchandra1/Leetcode
be89c7d8d93083326a94906a28bfad2342aa1dfe
[ "MIT" ]
null
null
null
problems/complex_number_multiplication/solution.cpp
sauravchandra1/Leetcode
be89c7d8d93083326a94906a28bfad2342aa1dfe
[ "MIT" ]
null
null
null
class Solution { public: string complexNumberMultiply(string num1, string num2) { /* (a + ib) * (c + id) = (ac - bd) + i(bc + ad); */ int l1 = num1.size(), l2 = num2.size(); int a = 1, b = 1, c = 1, d = 1; auto isInt = [](char c) { return (c < '0' || c > '9') ? false : true; }; bool ok = true; int i = 0; auto get = [&]() { int t = 0; if (ok) { while (i < l1 && isInt(num1[i])) { t = t * 10 + (num1[i] - '0'); i++; } } else { while (i < l2 && isInt(num2[i])) { t = t * 10 + (num2[i] - '0'); i++; } } return t; }; if (num1[i] == '-') { a = -1; i++; } a = a * get(); i++; if (num1[i] == '-') { b = -1; i++; } b = b * get(); i = 0; ok = false; if (num2[i] == '-') { c = -1; i++; } c = c * get(); i++; if (num2[i] == '-') { d = -1; i++; } d = d * get(); int e = a * c - b * d; int f = b * c + a * d; return to_string(e) + "+" + to_string(f) + "i"; } };
22.815385
60
0.2441
sauravchandra1
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
16274314a21fc4a0d34373c841c76488abef211a
2,407
cc
C++
chrome/browser/ash/account_manager/account_apps_availability_factory.cc
chromium/chromium
df46e572c3449a4b108d6e02fbe4f6d24cf98381
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
14,668
2015-01-01T01:57:10.000Z
2022-03-31T23:33:32.000Z
chrome/browser/ash/account_manager/account_apps_availability_factory.cc
chromium/chromium
df46e572c3449a4b108d6e02fbe4f6d24cf98381
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
86
2015-10-21T13:02:42.000Z
2022-03-14T07:50:50.000Z
chrome/browser/ash/account_manager/account_apps_availability_factory.cc
chromium/chromium
df46e572c3449a4b108d6e02fbe4f6d24cf98381
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
5,941
2015-01-02T11:32:21.000Z
2022-03-31T16:35:46.000Z
// Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ash/account_manager/account_apps_availability_factory.h" #include "base/files/file_path.h" #include "base/no_destructor.h" #include "chrome/browser/ash/account_manager/account_apps_availability.h" #include "chrome/browser/ash/account_manager/account_manager_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/identity_manager_factory.h" #include "components/account_manager_core/chromeos/account_manager_facade_factory.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h" #include "components/keyed_service/core/keyed_service.h" #include "content/public/browser/browser_context.h" namespace ash { // static AccountAppsAvailabilityFactory* AccountAppsAvailabilityFactory::GetInstance() { static base::NoDestructor<AccountAppsAvailabilityFactory> factory; return factory.get(); } // static AccountAppsAvailability* AccountAppsAvailabilityFactory::GetForProfile( Profile* profile) { return static_cast<AccountAppsAvailability*>( GetInstance()->GetServiceForBrowserContext(profile, true)); } AccountAppsAvailabilityFactory::AccountAppsAvailabilityFactory() : BrowserContextKeyedServiceFactory( "AccountAppsAvailability", BrowserContextDependencyManager::GetInstance()) { DependsOn(IdentityManagerFactory::GetInstance()); } AccountAppsAvailabilityFactory::~AccountAppsAvailabilityFactory() = default; KeyedService* AccountAppsAvailabilityFactory::BuildServiceInstanceFor( content::BrowserContext* context) const { Profile* profile = Profile::FromBrowserContext(context); DCHECK(profile); if (!IsAccountManagerAvailable(profile)) return nullptr; if (!AccountAppsAvailability::IsArcAccountRestrictionsEnabled()) return nullptr; return new AccountAppsAvailability( ::GetAccountManagerFacade(profile->GetPath().value()), IdentityManagerFactory::GetForProfile(profile), profile->GetPrefs()); } bool AccountAppsAvailabilityFactory::ServiceIsCreatedWithBrowserContext() const { // To ensure the class is always tracking accounts in Account Manager. return true; } } // namespace ash
37.030769
84
0.803074
chromium
1627fe740399b21f7288aa94cc6fc75475ff541a
8,679
cpp
C++
Modules/ThirdParty/OssimPlugins/src/ossim/ossimTerraSarXSarSensorModel.cpp
qingswu/otb
ed903b6a5e51a27a3d04786e4ad1637cf6b2772e
[ "Apache-2.0" ]
1
2019-09-12T00:53:05.000Z
2019-09-12T00:53:05.000Z
Modules/ThirdParty/OssimPlugins/src/ossim/ossimTerraSarXSarSensorModel.cpp
qingswu/otb
ed903b6a5e51a27a3d04786e4ad1637cf6b2772e
[ "Apache-2.0" ]
null
null
null
Modules/ThirdParty/OssimPlugins/src/ossim/ossimTerraSarXSarSensorModel.cpp
qingswu/otb
ed903b6a5e51a27a3d04786e4ad1637cf6b2772e
[ "Apache-2.0" ]
1
2020-10-15T09:37:30.000Z
2020-10-15T09:37:30.000Z
/* * Copyright (C) 2005-2019 by Centre National d'Etudes Spatiales (CNES) * * This file is licensed under MIT license: * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include <ossimTerraSarXSarSensorModel.h> #include <ossim/base/ossimXmlDocument.h> #include "ossim/ossimXmlTools.h" namespace {// Anonymous namespace const ossimString attTimeUTC = "timeUTC"; const ossimString attPosX = "posX"; const ossimString attPosY = "posY"; const ossimString attPosZ = "posZ"; const ossimString attVelX = "velX"; const ossimString attVelY = "velY"; const ossimString attVelZ = "velZ"; const ossimString attT = "t"; const ossimString attTau = "tau"; const ossimString attCol = "col"; const ossimString attRow = "row"; const ossimString attLat = "lat"; const ossimString attLon = "lon"; const ossimString attHeight = "height"; }// Anonymous namespace void ossimplugins::ossimTerraSarXSarSensorModel::readAnnotationFile(const std::string & annotationXml, const std::string & geoXml) { ossimRefPtr<ossimXmlDocument> xmlDoc = new ossimXmlDocument(annotationXml); const ossimXmlNode & xmlRoot = *xmlDoc->getRoot(); //isGRD parse variant? std::string const& product_type = getTextFromFirstNode(xmlRoot, "productInfo/productVariantInfo/productVariant"); std::cout << "type " << product_type << '\n'; theProductType = ProductType(product_type); // First, lookup position/velocity records std::vector<ossimRefPtr<ossimXmlNode> > xnodes; xmlDoc->findNodes("/level1Product/platform/orbit/stateVec",xnodes); std::cout << "Number of states " << xnodes.size() << '\n'; for(std::vector<ossimRefPtr<ossimXmlNode> >::iterator itNode = xnodes.begin(); itNode!=xnodes.end();++itNode) { OrbitRecordType orbitRecord; // Retrieve acquisition time orbitRecord.azimuthTime = getTimeFromFirstNode(**itNode, attTimeUTC); // Retrieve ECEF position orbitRecord.position[0] = getDoubleFromFirstNode(**itNode, attPosX); orbitRecord.position[1] = getDoubleFromFirstNode(**itNode, attPosY); orbitRecord.position[2] = getDoubleFromFirstNode(**itNode, attPosZ); // Retrieve ECEF velocity orbitRecord.velocity[0] = getDoubleFromFirstNode(**itNode, attVelX); orbitRecord.velocity[1] = getDoubleFromFirstNode(**itNode, attVelY); orbitRecord.velocity[2] = getDoubleFromFirstNode(**itNode, attVelZ); //Add one orbits record std::cout << "Add theOrbitRecords\n"; theOrbitRecords.push_back(orbitRecord); } //Parse the near range time (in seconds) theNearRangeTime = getDoubleFromFirstNode(xmlRoot, "productInfo/sceneInfo/rangeTime/firstPixel"); std::cout << "theNearRangeTime " << theNearRangeTime << '\n'; //Parse the range sampling rate theRangeSamplingRate = getDoubleFromFirstNode(xmlRoot, "instrument/settings/RSF"); std::cout << "theRangeSamplingRate " << theRangeSamplingRate << '\n'; //Parse the range resolution theRangeResolution = getDoubleFromFirstNode(xmlRoot, "productSpecific/complexImageInfo/slantRangeResolution"); std::cout << "theRangeResolution " << theRangeResolution << '\n'; //Parse the radar frequency theRadarFrequency = getDoubleFromFirstNode(xmlRoot, "instrument/settings/settingRecord/PRF"); std::cout << "theRadarFrequency " << theRadarFrequency << '\n'; //Manage only strip map product for now (one burst) //Parse azimuth time start/stop const TimeType azimuthTimeStart = getTimeFromFirstNode(xmlRoot, "productInfo/sceneInfo/start/timeUTC"); std::cout << "azimuthTimeStart " << azimuthTimeStart << '\n'; const TimeType azimuthTimeStop = getTimeFromFirstNode(xmlRoot, "productInfo/sceneInfo/stop/timeUTC"); std::cout << "azimuthTimeStop " << azimuthTimeStop << '\n'; const DurationType td = azimuthTimeStop - azimuthTimeStart; // numberOfRows unsigned int numberOfRows = xmlRoot.findFirstNode("productInfo/imageDataInfo/imageRaster/numberOfRows")->getText().toUInt16(); std::cout << "numberOfRows " << numberOfRows << '\n'; //Compute azimuth time interval theAzimuthTimeInterval = td / static_cast<double> (numberOfRows); std::cout << "theAzimuthTimeInterval " << theAzimuthTimeInterval.total_microseconds() << " and 1/prf: " << (1 / theRadarFrequency) * 1000000 << '\n'; //For Terrasar-X only 1 burst is supported for now BurstRecordType burstRecord; burstRecord.startLine = 0; burstRecord.azimuthStartTime = azimuthTimeStart; burstRecord.azimuthStopTime = azimuthTimeStop; burstRecord.endLine = numberOfRows - 1; theBurstRecords.push_back(burstRecord); //GRD (detected product) if(isGRD()) { //Retrieve Slant Range to Ground range coeddifcients CoordinateConversionRecordType coordRecord; //Get azimuth time start (again) coordRecord.azimuthTime = azimuthTimeStart; //Set ground range origin to 0 (FIXME?) coordRecord.rg0 = 0.; //Read coefficients xnodes.clear(); const unsigned int polynomialDegree = xmlRoot.findFirstNode("productSpecific/projectedImageInfo/slantToGroundRangeProjection/polynomialDegree")->getText().toUInt16(); std::cout << "Number of coefficients " << polynomialDegree << '\n'; ossimString path = "/level1Product/productSpecific/projectedImageInfo/slantToGroundRangeProjection/coefficient"; const ossimString EXP = "exponent"; ossimString s; xmlDoc->findNodes(path, xnodes); if ( xnodes.size() ) { for (unsigned int i = 0; i < xnodes.size(); ++i) { if (xnodes[i].valid()) { xnodes[i]->getAttributeValue(s, EXP); const double coeff = xnodes[i]->getText().toDouble(); coordRecord.coefs.push_back(coeff); std::cout << "Coef number " << i << " value: " << coeff << '\n'; } } } assert(!coordRecord.coefs.empty()&&"The srgr record has empty coefs vector."); theSlantRangeToGroundRangeRecords.push_back(coordRecord); } //Parse GCPs ossimRefPtr<ossimXmlDocument> xmlGeo = new ossimXmlDocument(geoXml); xnodes.clear(); xmlGeo->findNodes("/geoReference/geolocationGrid/gridPoint",xnodes); std::cout<<"Found "<<xnodes.size()<<" GCPs\n"; for(std::vector<ossimRefPtr<ossimXmlNode> >::iterator itNode = xnodes.begin(); itNode!=xnodes.end();++itNode) { GCPRecordType gcpRecord; // Get delta acquisition time const double deltaAzimuth = getDoubleFromFirstNode(**itNode, attT); #if defined(USE_BOOST_TIME) using boost::posix_time::microseconds; #else using ossimplugins::time::microseconds; #endif gcpRecord.azimuthTime = azimuthTimeStart + microseconds(deltaAzimuth * 1000000); //Get delta range time gcpRecord.slantRangeTime = theNearRangeTime + getDoubleFromFirstNode(**itNode, attTau); gcpRecord.imPt.x = getDoubleFromFirstNode(**itNode, attCol) - 1.; gcpRecord.imPt.y = getDoubleFromFirstNode(**itNode, attRow) - 1.; ossimGpt geoPoint; gcpRecord.worldPt.lat = getDoubleFromFirstNode(**itNode, attLat); gcpRecord.worldPt.lon = getDoubleFromFirstNode(**itNode, attLon); gcpRecord.worldPt.hgt = getDoubleFromFirstNode(**itNode, attHeight); theGCPRecords.push_back(gcpRecord); } this->optimizeTimeOffsetsFromGcps(); }
38.919283
174
0.687176
qingswu
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
162b18c8e9254b5e34c42ca3ac28de3216511ab1
20,454
cpp
C++
Input/amplGenStochInput_AddSlack.cpp
jalving/PIPS
62f664237447c7ce05a62552952c86003d90e68f
[ "BSD-3-Clause-LBNL" ]
65
2016-02-04T18:03:39.000Z
2022-03-24T08:59:38.000Z
Input/amplGenStochInput_AddSlack.cpp
jalving/PIPS
62f664237447c7ce05a62552952c86003d90e68f
[ "BSD-3-Clause-LBNL" ]
34
2015-11-17T04:26:51.000Z
2020-09-24T16:00:22.000Z
Input/amplGenStochInput_AddSlack.cpp
jalving/PIPS
62f664237447c7ce05a62552952c86003d90e68f
[ "BSD-3-Clause-LBNL" ]
26
2015-10-15T20:27:52.000Z
2021-07-14T08:13:34.000Z
/* PIPS-NLP * * Authors: Nai-Yuan Chiang * * (C) 2015 Argonne National Laboratory */ #include "amplGenStochInput_AddSlack.hpp" #include "AmplData_NL.hpp" #include <iostream> #include <string> #include <fstream> #include <limits> #include <sstream> #include "asl.h" #include "asl_pfgh.h" #include "getstub.h" #include <climits> #include "mpi.h" using namespace std; extern int gUseReducedSpace; extern int gNP_Alg; // solve problem as // min 1/s f(x_s) // st g(x_s) = 0 // T_sx_s = x_0 // // this input is differenent from the amplGenStochInput one. // In amplGenStochInput, we do split/reorder the Hessian and Jacobian in this case. // Here we need to add dummy variable/constraint template <typename T> void FreeAll( T & t ) { T tmp; t.swap( tmp ); } amplGenStochInput_AddSlack::amplGenStochInput_AddSlack(const string &datarootname_in, int overrideScenarioNumber, MPI_Comm comm) { useInputDate = 1; unsigned filelen; char *filedataArgv[2]; stringstream fname; std::string strTemp; haveRootNL=false; datarootname=datarootname_in; MPI_Comm_rank(comm,&mype_); // Add the suffix AmplSuffix *amplSuffix = new AmplSuffix(); amplSuffix->DefineSuffix("pipsNLP_1stStageVar_in", Suffix_Var, Suffix_Int); // no reduced space and graph partitioning if (gUseReducedSpace!=0 || gNP_Alg!=0) assert("adding slack setting is not available in reduced space setting."); nFirstStageCons_ = 0; nFirstStageVars_ = 0; { fname << datarootname << "0.nl"; ifstream f(fname.str().c_str()); if (!f.is_open()) { haveRootNL=false; } else{ haveRootNL=true; cout << " Found " << fname.str() << " from processes " << mype_ << endl; } f.close(); assert(haveRootNL==false); if(mype_==1) cout << " No first stage NL file! "<< endl; fname.str(""); fname.clear(); } nScenarios_ = overrideScenarioNumber; ObjScale = 1./nScenarios_; localData.resize(nScenarios_); asl_i.resize(nScenarios_); nSecondStageVars_.resize(nScenarios_); nSecondStageCons_.resize(nScenarios_); LocGloVarMap.resize(nScenarios_); LocGloVarIdx.resize(nScenarios_); LocLocVarMap.resize(nScenarios_); map<int,int>::iterator it; // read 1st stage info int scen = 0; // if(mype_==scen) { fname << datarootname << scen+1 << ".nl"; ifstream f(fname.str().c_str()); if (!f.is_open()) { cout << " Unable to open " << fname.str() << " from process " << mype_ << endl; MPI_Abort(MPI_COMM_WORLD,1); }else{ cout << " Found " << fname.str() << " from processes " << mype_ << endl; } f.close(); filelen = fname.str().length()+1; filedataArgv[0] = new char[9]; filedataArgv[1] = new char[filelen]; memcpy(filedataArgv[0],"pips_nlp",9); memcpy(filedataArgv[1],fname.str().c_str(),filelen); filedataArgv[2]=NULL; // Allocate the ampl solver library (ASL) context. asl_i[scen] = localData[scen].initASL(filedataArgv, amplSuffix); fname.str(""); fname.clear(); localData[scen].didLoad=true; LocGloVarIdx[scen] = NULL; LocGloVarIdx[scen] = amplSuffix->GetSuffixVal_Int(asl_i[scen], "pipsNLP_1stStageVar_in", Suffix_Var); //we must have 1st stage variable assert(LocGloVarIdx[scen]); //find correct index in C: in ampl model, index of 1st stage var starts from 1, here we correct it as zero; for (int j=0; j<asl_i[scen]->i.n_var_; j++){ LocGloVarIdx[scen][j] -= 1; } //count number of 1st stage variables and creat variable map int n1stVarTemp=0, n2ndVarTemp=0; for (int j=0; j<asl_i[scen]->i.n_var_; j++){ if(LocGloVarIdx[scen][j]!=-1){ LocGloVarMap[scen].insert( pair<int,int>(j,LocGloVarIdx[scen][j])); n1stVarTemp++; }else{ n2ndVarTemp++; } } // set 1st var ub & lb to inf nFirstStageVars_ = n1stVarTemp; assert(nFirstStageCons_==0); firstStageData.initialize(nFirstStageVars_,nFirstStageCons_); for(int j=0; j<nFirstStageVars_; j++){ firstStageData.collb[j] = -1e25; firstStageData.colub[j] = 1e25; firstStageData.objGrad[j] = 0; } // allocate space for 2nd stages assert(asl_i[scen]->i.n_var_ == n2ndVarTemp + nFirstStageVars_); nSecondStageVars_[scen] = asl_i[scen]->i.n_var_; nSecondStageCons_[scen] = asl_i[scen]->i.n_con_ + nFirstStageVars_; localData[scen].initialize(nSecondStageVars_[scen],nSecondStageCons_[scen]); // get 2nd var ub lb for(int j=0; j<asl_i[scen]->i.n_var_; j++){ localData[scen].collb[j] = asl_i[scen]->i.LUv_[j]; localData[scen].colub[j] = asl_i[scen]->i.Uvx_[j]; localData[scen].objGrad[j] = 1; } // reset 1st stage var bounds from 2nd var ub lb for(it=LocGloVarMap[scen].begin(); it!=LocGloVarMap[scen].end(); it++){ firstStageData.collb[it->second] = localData[scen].collb[it->first]; firstStageData.colub[it->second] = localData[scen].colub[it->first]; } // get 2nd con ub lb for(int j=0; j<asl_i[scen]->i.n_con_; j++){ localData[scen].rowlb[j] = asl_i[scen]->i.LUrhs_[j]; localData[scen].rowub[j] = asl_i[scen]->i.Urhsx_[j]; } // for dummy constraint for(int j=asl_i[scen]->i.n_con_; j<nSecondStageCons_[scen]; j++){ localData[scen].rowlb[j] = 0; localData[scen].rowub[j] = 0; } } //********************************************************************// LocWmatJacGoffMap.resize(nScenarios_); LocTmatJacGoffMap.resize(nScenarios_); Tmat.resize(nScenarios_); Wmat.resize(nScenarios_); LocQAmatHesGoffMap.resize(nScenarios_); LocQWmatHesGoffMap.resize(nScenarios_); LocQTmatHesGoffMap.resize(nScenarios_); QTmat.resize(nScenarios_); QWmat.resize(nScenarios_); nnzQ2nd.resize(nScenarios_); nnzQCross2nd.resize(nScenarios_); //********************************************************************// nnzEqJac1st=0; nnzIneqJac1st=0; assert(nFirstStageCons_==0); amplRowMap1st = new int[nFirstStageCons_]; nnzEqJac2nd.resize(nScenarios_); nnzIneqJac2nd.resize(nScenarios_); amplRowMap2nd.resize(nScenarios_); //********************************************************************// nnzA1st=0; nnzC1st=0; assert(nFirstStageCons_==0); assert(!firstStageData.locASL); nnzA2nd.resize(nScenarios_); nnzC2nd.resize(nScenarios_); nnzALink2nd.resize(nScenarios_,0); nnzCLink2nd.resize(nScenarios_,0); nnzALoc2nd.resize(nScenarios_,0); nnzCLoc2nd.resize(nScenarios_,0); JacALinkGoff2nd.resize(nScenarios_); JacCLinkGoff2nd.resize(nScenarios_); JacALocGoff2nd.resize(nScenarios_); JacCLocGoff2nd.resize(nScenarios_); splitMatrices(0); getRowMap(0); getJacGoffMap(0); // set the root nl = NULL firstStageData.locASL = asl_i[0]; dimsEqual = true; // initialize the number of vars/cons in 2nd stage for (int scen = 1; scen < nScenarios_; scen++) { nSecondStageCons_[scen] = 0; nSecondStageVars_[scen] = 0; } delete amplSuffix; } // split matrices to Amat and Wmat void amplGenStochInput_AddSlack::splitMatrices(const int scen) { ASL_pfgh * asl; int amplNz=0, Wnnz = 0, Tnnz = 0, Annz = 0, QWnnz = 0, QTnnz = 0, QAnnzFromScen=0; int tempNz = 0; vector<int> starts1stStTemp, starts2ndSt, startsLink; vector<int> rowIdx2ndSt, rowIdx1stSt, rowIdxLink; vector<double> elts2ndSt, elts1stSt, eltsLink; vector<int> amplGoffRowIdx; vector<double> amplGoffColIdx; vector<int> amplGoffColStarts; vector<int> amplGoffColLength; vector<double> amplGoffElts; vector<int> jColStart; vector<int> kRowIDX; vector<double> kelts; cgrad *cg; map<int,int>::iterator itVar, itVar_Row; int wrk1stGoff=0, wrk2ndGoff=0, wrkLinkGoff=0; int wrkGoff=0; int wrkGoffStart=0, addDummyCon=0, nextSearchVar=0; if(0==scen){ //////////////////////////// build Amat //////////////////////////////////////////////////////// // set empty Amat. This is the matrix difined by 1st stage cons --- this is empty in Curl's setting assert(nFirstStageCons_==0); jColStart.resize(nFirstStageVars_+1); for (int j = 0; j <= nFirstStageVars_; j++) { jColStart[j] = 0; } Amat.copyOf (true, nFirstStageCons_, nFirstStageVars_, 0, 0, 0, &jColStart[0], 0); //////////////////////////// build QAmat //////////////////////////////////////////////////////// jColStart.clear(); jColStart.resize(nFirstStageVars_+1,0); QAmat.copyOf(true, nFirstStageVars_, nFirstStageVars_, 0, 0, 0, &jColStart[0], 0); } // set sparse structure of 2nd stage Jac and linking Jac asl = localData[scen].locASL; Wnnz = 0; Tnnz = 0; QWnnz = 0; QTnnz = 0; QAnnzFromScen=0; wrk1stGoff=0; wrk2ndGoff=0; wrkLinkGoff=0; wrkGoff=0; //////////////////////////// build Wmat //////////////////////////////////////////////////////// amplNz = nzc; Wnnz = amplNz + nFirstStageVars_; jColStart.clear(); jColStart.resize(nSecondStageVars_[scen]+1,0); kRowIDX.resize(Wnnz); kelts.resize(Wnnz); amplGoffRowIdx.clear(); amplGoffRowIdx.resize(amplNz,0); amplGoffElts.clear(); amplGoffElts.resize(amplNz,0.); amplGoffColStarts.clear(); amplGoffColStarts.resize(n_var+1,0); assert(nSecondStageVars_[scen]==n_var); // get info from ampl for( int j=0; j < n_con; j++){ for(cg = Cgrad[j]; cg; cg = cg->next){ amplGoffRowIdx[cg->goff] = j; amplGoffElts[cg->goff] = cg->coef; amplGoffColStarts[cg->varno+1]++; } } for(int j=1; j < n_var+1; j++){ amplGoffColStarts[j] += amplGoffColStarts[j-1]; } assert(amplGoffColStarts[n_var]==amplNz); wrkGoffStart=0; wrkGoff=0; addDummyCon=0; nextSearchVar=0; for(itVar=LocGloVarMap[scen].begin(); itVar!=LocGloVarMap[scen].end(); itVar++){ for(int j=wrkGoffStart; j<amplGoffColStarts[itVar->first+1]; j++){ kelts[wrkGoff] = amplGoffElts[j]; kRowIDX[wrkGoff] = amplGoffRowIdx[j]; LocWmatJacGoffMap[scen].insert( pair<int,int>(wrkGoff,j)); wrkGoff++; } // correct col start for(int j=nextSearchVar; j<itVar->first+1; j++){ jColStart[j] = amplGoffColStarts[j] + addDummyCon; } //add elt of the additional constraint; kelts[wrkGoff] = 1; kRowIDX[wrkGoff] = n_con + addDummyCon; wrkGoff++; addDummyCon++; // correct next col start nextSearchVar = itVar->first+1; wrkGoffStart = amplGoffColStarts[itVar->first+1]; } assert(addDummyCon == nFirstStageVars_); if(wrkGoffStart!=amplNz){ for(int j=wrkGoffStart; j<amplNz; j++){ kelts[wrkGoff] = amplGoffElts[j]; kRowIDX[wrkGoff] = amplGoffRowIdx[j]; LocWmatJacGoffMap[scen].insert( pair<int,int>(wrkGoff,j)); wrkGoff++; } } for(int j=nextSearchVar; j<n_var+1; j++, nextSearchVar++){ jColStart[j] = amplGoffColStarts[j] + addDummyCon; } assert(wrkGoff == Wnnz); assert(jColStart[n_var] == Wnnz); assert(nextSearchVar == n_var+1); Wmat[scen].copyOf(true, nSecondStageCons_[scen], nSecondStageVars_[scen], Wnnz, &kelts[0], &kRowIDX[0], &jColStart[0], 0); //////////////////////////// build Tmat //////////////////////////////////////////////////////// Tnnz = nFirstStageVars_; jColStart.clear(); jColStart.resize(nFirstStageVars_+1,0); kRowIDX.clear(); kRowIDX.resize(Tnnz); kelts.clear(); kelts.resize(Tnnz); addDummyCon=0; for(int j=0; j<nFirstStageVars_+1; j++){ jColStart[j] = j; } for(int j=0; j<Tnnz; j++){ kelts[j] = -1; } for(itVar=LocGloVarMap[scen].begin(); itVar!=LocGloVarMap[scen].end(); itVar++){ kRowIDX[itVar->second] = n_con + addDummyCon++; } assert(addDummyCon == nFirstStageVars_); Tmat[scen].copyOf(true, nSecondStageCons_[scen], nFirstStageVars_, Tnnz, &kelts[0], &kRowIDX[0], &jColStart[0], 0); //////////////////////////// build QTmat //////////////////////////////////////////////////////// jColStart.clear(); jColStart.resize(nFirstStageVars_+1,0); QTmat[scen].copyOf(true, nSecondStageVars_[scen], nFirstStageVars_, 0, 0, 0, &jColStart[0], 0); nnzQCross2nd[scen] = 0; //////////////////////////// build QWmat //////////////////////////////////////////////////////// QWnnz = localData[scen].Ampl_nnz_Hessian_Tri(); jColStart.clear(); jColStart.resize( nSecondStageVars_[scen]+1,0); kRowIDX.clear(); kRowIDX.resize(QWnnz); kelts.clear(); kelts.resize(QWnnz,0); amplGoffRowIdx.clear(); amplGoffRowIdx.resize(QWnnz); amplGoffColIdx.clear(); amplGoffColIdx.resize(QWnnz); amplGoffElts.clear(); amplGoffColStarts.clear(); amplGoffColStarts.resize(nSecondStageVars_[scen]+1,0); for(int j=0; j<QWnnz;j++){ amplGoffRowIdx[j] = sputinfo->hrownos[j]; } for(int j=0; j<nSecondStageVars_[scen]+1;j++){ amplGoffColStarts[j] = sputinfo->hcolstarts[j]; } int findQele=0; int *defineEleID = new int[ nSecondStageVars_[scen]]; // ampl use upper triangle, but transpose to lower triangle for OOQP, both require col-wise form for( int j = 0; j < nSecondStageVars_[scen]; j++ ) { for( int k = amplGoffColStarts[j]; k < amplGoffColStarts[j+1]; k++ ) { int QrowIDX = amplGoffRowIdx[k]; // use only the upper triangle part assert(QrowIDX <= j); jColStart[QrowIDX+1]++; findQele++; } } assert(findQele==QWnnz); for(int j=1; j < nSecondStageVars_[scen]+1; j++){ jColStart[j] += jColStart[j-1]; defineEleID[j-1] = jColStart[j-1]; } assert(jColStart[nSecondStageVars_[scen]]==QWnnz); for( int j = 0; j < nSecondStageVars_[scen]; j++ ) { for( int k = amplGoffColStarts[j]; k < amplGoffColStarts[j+1]; k++ ) { int GoffInLowerPart = defineEleID[amplGoffRowIdx[k]]; kRowIDX[GoffInLowerPart] = j; LocQWmatHesGoffMap[scen].insert( pair<int,int>(GoffInLowerPart,k)); defineEleID[amplGoffRowIdx[k]]++; } } delete [] defineEleID; QWmat[scen].copyOf(true, nSecondStageVars_[scen], nSecondStageVars_[scen], QWnnz, &kelts[0], &kRowIDX[0], &jColStart[0], 0); nnzQ2nd[scen] = QWnnz; amplGoffRowIdx.clear(); amplGoffColStarts.clear(); if(scen == 0){ nnzQ1st = QAnnzFromScen; } ////////////////////////////////////////////////////////////////////////////////////////// FreeAll(starts2ndSt); FreeAll(starts1stStTemp); FreeAll(startsLink); FreeAll(rowIdx2ndSt); FreeAll(rowIdx1stSt); FreeAll(rowIdxLink); FreeAll(elts2ndSt); FreeAll(elts1stSt); FreeAll(eltsLink); FreeAll(amplGoffRowIdx); FreeAll(amplGoffColIdx); FreeAll(amplGoffColStarts); FreeAll(amplGoffColLength); FreeAll(amplGoffElts); } void amplGenStochInput_AddSlack::getRowMap(const int scen) { int loc_my=0, loc_mz=0; amplRowMap2nd[scen] = new int[asl_i[scen]->i.n_con_]; for( int i = 0; i < asl_i[scen]->i.n_con_; i++ ) { if ( localData[scen].rowlb[i] == localData[scen].rowub[i] ) { amplRowMap2nd[scen][i] = - (loc_my + 1); // Negative values indicate an equality loc_my++; } else { amplRowMap2nd[scen][i] = loc_mz; loc_mz++; } } } void amplGenStochInput_AddSlack::getJacGoffMap(const int scen) { ASL_pfgh * asl; cgrad *cg; int amplNz; map<int,int>::iterator itVar; asl = localData[scen].locASL; amplNz = nzc; for(int j=0; j<n_con;j++){ if( amplRowMap2nd[scen][j] < 0){ for(cg = Cgrad[j]; cg; cg = cg->next){ nnzA2nd[scen]++; } }else{ for(cg = Cgrad[j]; cg; cg = cg->next){ nnzC2nd[scen]++; } } } int Tnnz = Tmat[scen].getNumElements(); int Wnnz = Wmat[scen].getNumElements(); const int* tRowIDX = Tmat[scen].getIndices(); const int* wRowIDX = Wmat[scen].getIndices(); int rowID; for( int k = 0; k < Tnnz; k++ ) { rowID = tRowIDX[k]; if(rowID<n_con){ if( amplRowMap2nd[scen][rowID] < 0){ nnzALink2nd[scen]++; }else{ nnzCLink2nd[scen]++; } } } for( int k = 0; k < Wnnz; k++ ) { rowID = wRowIDX[k]; if(rowID<n_con){ if( amplRowMap2nd[scen][rowID] < 0){ nnzALoc2nd[scen]++; }else{ nnzCLoc2nd[scen]++; } } } assert( amplNz == nnzALoc2nd[scen] + nnzCLoc2nd[scen]); // add eles from dummy constraint nnzALoc2nd[scen] += nFirstStageVars_; nnzALink2nd[scen] += nFirstStageVars_; int kA = 0, kC = 0, rowIdx=0; for(int j=0; j<n_con;j++){ if( amplRowMap2nd[scen][j] < 0){ for(cg = Cgrad[j]; cg; cg = cg->next){ JacALocGoff2nd[scen].insert( pair<int,int>(cg->goff,kA++)); } }else{ for(cg = Cgrad[j]; cg; cg = cg->next){ JacCLocGoff2nd[scen].insert( pair<int,int>(cg->goff,kC++)); } } } assert( kA == nnzA2nd[scen] ); assert( kC == nnzC2nd[scen] ); assert( kA+kC==amplNz); nnzA2nd[scen]+= nFirstStageVars_; } void amplGenStochInput_AddSlack:: loadLocalNLdata(int scen) { if (localData[scen].didLoad) return; localData[scen].didLoad=true; // Add the suffix AmplSuffix *amplSuffix = new AmplSuffix(); amplSuffix->DefineSuffix("pipsNLP_1stStageVar_in", Suffix_Var, Suffix_Int); stringstream fname; char *filedataArgv[2]; filedataArgv[0] = new char[9]; memcpy(filedataArgv[0],"pips_nlp",9); unsigned filelen; map<int,int>::iterator it; std::string strTemp; fname << datarootname << scen+1 << ".nl"; ifstream f(fname.str().c_str()); // cout << "Try to find " << fname.str() << " from processes " << mype_ << endl; if (!f.is_open()) { cout << " Unable to open " << fname.str() << " from process " << mype_ << endl; MPI_Abort(MPI_COMM_WORLD,1); }else{ cout << " Found " << fname.str() << " from processes " << mype_ << endl; } f.close(); filelen = fname.str().length()+1; filedataArgv[1] = new char[filelen]; memcpy(filedataArgv[1],fname.str().c_str(),filelen); filedataArgv[2]=NULL; // Allocate the ampl solver library (ASL) context. asl_i[scen] = localData[scen].initASL(filedataArgv, amplSuffix); fname.str(""); fname.clear(); LocGloVarIdx[scen] = NULL; LocGloVarIdx[scen] = amplSuffix->GetSuffixVal_Int(asl_i[scen], "pipsNLP_1stStageVar_in", Suffix_Var); //we must have 1st stage variable assert(LocGloVarIdx[scen]); //find correct index in C: in ampl model, index of 1st stage var starts from 1, here we correct it as zero; for (int j=0; j<asl_i[scen]->i.n_var_; j++){ LocGloVarIdx[scen][j] -= 1; } //creat variable map int n1stVarTemp=0, n2ndVarTemp=0; for (int j=0; j<asl_i[scen]->i.n_var_; j++){ if(LocGloVarIdx[scen][j]!=-1){ //creat local NL to global var map LocGloVarMap[scen].insert( pair<int,int>(j,LocGloVarIdx[scen][j])); n1stVarTemp++; }else{ n2ndVarTemp++; } } // allocate space for 2nd stages assert(nFirstStageVars_ == n1stVarTemp); nSecondStageVars_[scen] = asl_i[scen]->i.n_var_; nSecondStageCons_[scen] = asl_i[scen]->i.n_con_ + nFirstStageVars_; if(dimsEqual==true){ if(nSecondStageVars_[scen]!=nSecondStageVars_[0] || nSecondStageCons_[scen]!=nSecondStageCons_[0]) dimsEqual=false; } localData[scen].initialize(nSecondStageVars_[scen],nSecondStageCons_[scen]); // get 2nd var ub lb for(int j=0; j<asl_i[scen]->i.n_var_; j++){ localData[scen].collb[j] = asl_i[scen]->i.LUv_[j]; localData[scen].colub[j] = asl_i[scen]->i.Uvx_[j]; localData[scen].objGrad[j] = 1; } // get 2nd con ub lb for(int j=0; j<asl_i[scen]->i.n_con_; j++){ localData[scen].rowlb[j] = asl_i[scen]->i.LUrhs_[j]; localData[scen].rowub[j] = asl_i[scen]->i.Urhsx_[j]; } // for dummy constraint for(int j=asl_i[scen]->i.n_con_; j<nSecondStageCons_[scen]; j++){ localData[scen].rowlb[j] = 0; localData[scen].rowub[j] = 0; } splitMatrices(scen); getRowMap(scen); getJacGoffMap(scen); delete amplSuffix; } void amplGenStochInput_AddSlack::doNetworkPart(const int scen, AmplSuffix* amplSuffix ) { assert("not done" &&0); }
28.930693
119
0.610198
jalving
162d6694e2e8ed2635b1b0afd9f33e83c379122e
9,629
cpp
C++
Terminal/Include/Lobster/blt.cpp
tommyettinger/BearLibTerminal
78ded45d4527817b75f5de9d641d15a7f2db6367
[ "MIT" ]
42
2016-04-30T11:02:34.000Z
2022-03-23T20:05:32.000Z
Terminal/Include/Lobster/blt.cpp
tommyettinger/BearLibTerminal
78ded45d4527817b75f5de9d641d15a7f2db6367
[ "MIT" ]
3
2015-11-06T00:10:06.000Z
2021-11-06T06:38:48.000Z
Terminal/Include/Lobster/blt.cpp
tommyettinger/BearLibTerminal
78ded45d4527817b75f5de9d641d15a7f2db6367
[ "MIT" ]
7
2015-04-27T15:08:36.000Z
2022-03-04T14:11:50.000Z
// Copyright 2014 Tommy Ettinger. 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. //Until Lobster gets an FFI, this must be compiled into the Lobster engine. //Copy the C include file into dev/include/BearLibTerminal/ and the //.lib into dev/lib/ , and the .lobster file in this directory should go //in lobster/include , since it isn't needed in the engine. #include "stdafx.h" #include "vmdata.h" #include "natreg.h" #include "BearLibTerminal/BearLibTerminal.h" using namespace lobster; void AddBLTOps() { STARTDECL(blt_open) () { return Value(terminal_open() == 0); } ENDDECL0(blt_open, "", "", "I", "opens the terminal. returns 1 on failure, to comply with lobster's fatal(). use blt_set to set options."); STARTDECL(blt_close) () { terminal_close(); return Value(); } ENDDECL0(blt_close, "", "", "", "closes the terminal."); STARTDECL(blt_set) (Value &params) { params.DECRT(); return Value(terminal_set8((int8_t*)(params.sval->str()))); } ENDDECL1(blt_set, "params", "S", "I", "sets options. this is a truly massive function inside, and you should consult the docs."); STARTDECL(blt_get) (Value &key, Value& fallback) { key.DECRT(); fallback.DECRT(); char* cs = (char*)terminal_get8((int8_t*)(key.sval->str()), (int8_t*)(fallback.sval->str())); Value v = Value(g_vm->NewString(cs, strlen(cs))); return v; } ENDDECL2(blt_get, "key,fallback", "SS", "S", "gets options from the config file."); STARTDECL(blt_refresh) () { terminal_refresh(); return Value(); } ENDDECL0(blt_refresh, "", "", "", "refreshes the display."); STARTDECL(blt_clear) () { terminal_clear(); return Value(); } ENDDECL0(blt_clear, "", "", "", "clears all layers of the terminal, filling with the current background color."); STARTDECL(blt_clear_area) (Value& x, Value& y, Value& w, Value& h) { terminal_clear_area(x.ival, y.ival, w.ival, h.ival); return Value(); } ENDDECL4(blt_clear_area, "x,y,w,h", "IIII", "", "closes the terminal."); STARTDECL(blt_crop) (Value& x, Value& y, Value& w, Value& h) { terminal_crop(x.ival, y.ival, w.ival, h.ival); return Value(); } ENDDECL4(blt_crop, "x,y,w,h", "IIII", "", "closes the terminal."); STARTDECL(blt_layer) (Value& layer) { terminal_layer(layer.ival); return Value(); } ENDDECL1(blt_layer, "layer", "I", "", "selects the current layer to draw upon."); STARTDECL(blt_color) (Value& rgba) { uint32_t clr = 0xff000000u; switch (rgba.vval->len) { case 3: { clr |= (((int)(rgba.vval->at(0).fval * 255)) & 255) << 16; clr |= (((int)(rgba.vval->at(1).fval * 255)) & 255) << 8; clr |= (((int)(rgba.vval->at(2).fval * 255)) & 255); } break; case 4: { clr = (((int)(rgba.vval->at(3).fval * 255)) & 255) << 24; clr |= (((int)(rgba.vval->at(0).fval * 255)) & 255) << 16; clr |= (((int)(rgba.vval->at(1).fval * 255)) & 255) << 8; clr |= (((int)(rgba.vval->at(2).fval * 255)) & 255); } break; default: break; } rgba.DECRT(); terminal_color(clr); return Value(); } ENDDECL1(blt_color, "rgba", "V", "", "sets the foreground color with a 3-element rgb vector of floats or a 4-element argb vector of floats."); STARTDECL(blt_bkcolor) (Value& rgba) { uint32_t clr = 0xff000000u; switch (rgba.vval->len) { case 3: { clr |= (((int)(rgba.vval->at(0).fval * 255)) & 255) << 16; clr |= (((int)(rgba.vval->at(1).fval * 255)) & 255) << 8; clr |= (((int)(rgba.vval->at(2).fval * 255)) & 255); } break; case 4: { clr = (((int)(rgba.vval->at(3).fval * 255)) & 255) << 24; clr |= (((int)(rgba.vval->at(0).fval * 255)) & 255) << 16; clr |= (((int)(rgba.vval->at(1).fval * 255)) & 255) << 8; clr |= (((int)(rgba.vval->at(2).fval * 255)) & 255); } break; default: break; } rgba.DECRT(); terminal_bkcolor(clr); return Value(); } ENDDECL1(blt_bkcolor, "rgba", "V", "", "sets the background color with a 3-element rgb vector of floats or a 4-element rgba vector of floats."); STARTDECL(blt_composition) (Value& mode) { terminal_composition(mode.ival); return Value(); } ENDDECL1(blt_composition, "mode", "I", "", "selects the current same-cell composition mode."); STARTDECL(blt_put) (Value& x, Value& y, Value& code) { terminal_put(x.ival, y.ival, code.ival); return Value(); } ENDDECL3(blt_put, "x,y,code", "III", "", "puts a character with a given code at the specified x and y coordinates."); STARTDECL(blt_put_ext) (Value& x, Value& y, Value& dx, Value& dy, Value& code) { terminal_put_ext(x.ival, y.ival, dx.ival, dy.ival, code.ival); return Value(); } ENDDECL5(blt_put_ext, "x,y,dx,dy,code", "IIIII", "", "puts a character with a given code at the specified x and y coordinates, with a difference in x and y position of dx and dy pixels."); STARTDECL(blt_pick) (Value& x, Value& y, Value& index) { return terminal_pick(x.ival, y.ival, index.ival); } ENDDECL3(blt_pick, "x,y,code", "III", "I", "finds what character is drawn in the current layer at the specified x and y coordinates, and at the specified index within that cell (0 if composition is disabled)."); STARTDECL(blt_pick_color) (Value& x, Value& y, Value& index) { color_t clr = terminal_pick_color(x.ival, y.ival, index.ival); auto v = g_vm->NewVector(4, V_VECTOR); for (int i = 16; i >= 0; i -= 8) { v->push(Value(((clr >> i) & 255) / 255.0f)); } v->push(Value(((clr >> 24) & 255) / 255.0f)); return Value(v); } ENDDECL3(blt_pick_color, "x,y,code", "III", "F]", "finds what color is used (returns rgba as a 4-element float vector) for the foreground in the current layer at the specified x and y coordinates, and at the specified index within that cell (0 if composition is disabled)."); STARTDECL(blt_pick_bkcolor) (Value& x, Value& y) { color_t clr = terminal_pick_bkcolor(x.ival, y.ival); auto v = g_vm->NewVector(4, V_VECTOR); for (int i = 16; i >= 0; i -= 8) { v->push(Value(((clr >> i) & 255) / 255.0f)); } v->push(Value(((clr >> 24) & 255) / 255.0f)); return Value(v); } ENDDECL2(blt_pick_bkcolor, "x,y", "II", "F]", "finds what color is drawn for the background at the specified x and y coordinates."); STARTDECL(blt_print) (Value& x, Value& y, Value &s) { s.DECRT(); return Value(terminal_print8(x.ival, y.ival, (int8_t*)(s.sval->str()))); } ENDDECL3(blt_print, "x,y,s", "IIS", "I", "prints a string at the given x and y coordinates."); STARTDECL(blt_measure) (Value &s) { s.DECRT(); return Value(terminal_measure8((int8_t*)(s.sval->str()))); } ENDDECL1(blt_measure, "s", "S", "I", "measures the width in pixels (or something) of a string."); STARTDECL(blt_has_input) () { return Value(terminal_has_input()); } ENDDECL0(blt_has_input, "", "", "I", "returns logical true if a call to blt_read will have input available to it, avoiding a blockage."); STARTDECL(blt_state) (Value& code) { return Value(terminal_state(code.ival)); } ENDDECL1(blt_state, "code", "I", "I", "returns an aspect of the current input state, specified by a code (usually, you should use a predefined constant)."); STARTDECL(blt_read) () { return Value(terminal_read()); } ENDDECL0(blt_read, "", "", "I", "returns the current input code if there is one, otherwise blocks(!) until some input is received."); STARTDECL(blt_read_str) (Value& x, Value& y, Value& max) { auto buf = new char[max.ival]; memset(buf, 0, max.ival); auto r = terminal_read_str(x.ival, y.ival, buf, max.ival); g_vm->Push(Value(g_vm->NewString(buf, r))); delete[] buf; return Value(r); } ENDDECL3(blt_read_str, "x,y,max", "III", "SI", "This function does a simple blocking read of a string without any parsing. User input is displayed at specified coordinates " "and also limited to specified length so it can be used in game interface. The function displays user input within current " "layer and restores the scene before return. It is an application's responsibility to keep the result on screen. " "It returns a string and the length of that string, without the enter key that terminates it. IF INPUT WAS CANCELLED, THE " "STRING WILL BE ENTIRELY FILLED TO THE LENGTH GIVEN BY max WITH THE CHARACTER THAT HAS CODEPOINT 0."); STARTDECL(blt_peek) () { return Value(terminal_peek()); } ENDDECL0(blt_peek, "", "", "I", "peeks at input without blocking or consuming the input."); STARTDECL(blt_delay) (Value& period) { terminal_delay(period.ival); return Value(); } ENDDECL1(blt_delay, "code", "I", "", "suspends the program for a number of milliseconds given by period."); STARTDECL(blt_color_from_name) (Value& name) { color_t clr = color_from_name8((int8_t*)(name.sval->str())); auto v = g_vm->NewVector(4, V_VECTOR); for (int i = 16; i >= 0; i -= 8) { v->push(Value(((clr >> i) & 255) / 255.0f)); } v->push(Value(((clr >> 24) & 255) / 255.0f)); return Value(v); } ENDDECL1(blt_color_from_name, "name", "S", "F]", "get a color by name, with similar names to libtcod's hue-and-brightness style."); } AutoRegister __ablt("blt", AddBLTOps);
30.568254
227
0.653027
tommyettinger
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
162e9242c49d79fa9e551c9f32e18ab8bbe34f52
9,608
cpp
C++
Shared/src/ExpandStringItemVector.cpp
wayfinder/Wayfinder-Server
a688546589f246ee12a8a167a568a9c4c4ef8151
[ "BSD-3-Clause" ]
4
2015-08-17T20:12:22.000Z
2020-05-30T19:53:26.000Z
Shared/src/ExpandStringItemVector.cpp
wayfinder/Wayfinder-Server
a688546589f246ee12a8a167a568a9c4c4ef8151
[ "BSD-3-Clause" ]
null
null
null
Shared/src/ExpandStringItemVector.cpp
wayfinder/Wayfinder-Server
a688546589f246ee12a8a167a568a9c4c4ef8151
[ "BSD-3-Clause" ]
null
null
null
/* Copyright (c) 1999 - 2010, Vodafone Group Services Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Vodafone Group Services Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "ExpandStringItemVector.h" #include "DeleteHelpers.h" #define MAX_SMS_LENGTH 160 #define MAX_CONCATENATED_SMS_SIZE 152 #define MAX_SMS_ITEM_LENGTH 140 #define TMP_LENGTH 255 ExpandStringItemVector::ExpandStringItemVector(uint32 nbrItems) { m_items.reserve( nbrItems ); } ExpandStringItemVector::~ExpandStringItemVector() { } bool ExpandStringItemVector:: getRouteAsSMS( vector<char*>& destVector, uint32 totRouteLength, uint32 totRouteTime, uint32 totRouteStandStillTime, StringTable::languageCode language, UserConstants::EOLType eol, int maxLineLength, bool concatinatedSMS, const char* preText, const char* postText) { vector<char*> allStrings; allStrings.reserve( m_items.size() ); vector<size_t> allStringSize; allStringSize.reserve( m_items.size() ); // Create footer char* footerText = new char[ strlen( StringTable::getString( StringTable::ROUTE_CONTINUES, language ) )*3 + 1 ]; SMSStringUtility::printSMSString( footerText, StringTable::getString( StringTable::ROUTE_CONTINUES, language), language, eol , maxLineLength, 0, 1, true); const uint32 footerSize = strlen(footerText); // Create header const char* routeText = StringTable::getString(StringTable::ROUTE, language); char* header = new char[ strlen( routeText ) + 14 + 2 + 1 ]; int headerSize = sprintf(header, "%s %u/NN", routeText, 1); headerSize += SMSStringUtility::writeEol(header, headerSize, eol, 5); header[headerSize] = '\0'; const uint32 maxInStringLength = (concatinatedSMS ? MAX_CONCATENATED_SMS_SIZE : (MAX_SMS_LENGTH - footerSize - headerSize) ); cerr << "maxInStringLength " << maxInStringLength << endl; // Add the preText if ( (preText != NULL) && (strlen(preText) > 0) ) { // FIXME: Replace all endlines with EOL in text, make sure < MAX_SIZE char* tmpStr = new char[MAX_SMS_LENGTH + 1]; strncpy( tmpStr, preText, maxInStringLength ); tmpStr[ maxInStringLength ] = '\0'; allStrings.push_back( tmpStr ); allStringSize.push_back( strlen( tmpStr ) ); } // Add all stringItems uint32 i; for (i=0; i < m_items.size(); i++) { ExpandStringItem* curItem = m_items[ i ]; if (curItem != NULL) { char* tmpStr = new char[MAX_SMS_LENGTH + 1]; int tmpLen = curItem->getRouteDescriptionSMS(language, eol, maxLineLength, tmpStr, MAX_SMS_ITEM_LENGTH); if (tmpLen > 0) { allStrings.push_back(tmpStr); allStringSize.push_back(tmpLen); } } } // Add the postText if ( (postText != NULL) && (strlen(postText) > 0) ) { // FIXME: Replace all endlines with EOL in text, make sure < MAX_SIZE char* tmpStr = new char[MAX_SMS_LENGTH + 1]; strncpy( tmpStr, postText, maxInStringLength ); tmpStr[ maxInStringLength ] = '\0'; allStrings.push_back( tmpStr ); allStringSize.push_back( strlen( tmpStr ) ); } // Split the strings in allString into some route-SMS:es // Fist calculate total length to se if only one SMS uint32 totLength = 0; for ( i=0; i < allStrings.size(); i++){ totLength += allStringSize[ i ]; } if (totLength < MAX_SMS_LENGTH) { // All text fits into one SMS, no header och footer necessary! char* curSMS = new char[totLength+1]; curSMS[0] = '\0'; for (uint32 i=0; i < m_items.size(); i++){ strcat(curSMS, allStrings[ i ]); } destVector.push_back(curSMS); delete [] footerText; delete [] header; STLUtility::deleteArrayValues( allStrings ); return (true); } else if( concatinatedSMS ){ // More than one SMS necessary, but no headers and footers... // Create the SMSes and insert them into the outparameter (destVector) uint32 i=0; while( i < allStrings.size() ){ uint32 totLength = allStringSize[ i ]; char* curSMS = new char[MAX_SMS_LENGTH + 1]; curSMS[0] = '\0'; while( totLength <= MAX_CONCATENATED_SMS_SIZE && i < allStrings.size() ) { strcat(curSMS, allStrings[i]); i++; if ( i < allStrings.size() ) { totLength += allStringSize[ i ]; } } destVector.push_back(curSMS); } delete [] footerText; delete [] header; STLUtility::deleteArrayValues( allStrings ); return (true); } else { // More than one SMS necessary, create headers and footers... vector<uint32> headerPositions; // Create the first header and insert into allStrings allStrings.insert(allStrings.begin(), header); allStringSize.insert(allStringSize.begin(), strlen(header)); headerPositions.push_back(0); // Insert headers and footers without totNbr (NN) uint32 curSize = headerSize; uint32 curSMSNumber = 1; uint32 i=0; while (i < allStrings.size()) { if ( (curSize + allStringSize[ i ]) > (MAX_SMS_LENGTH-footerSize) ) { // Add footer char* footer = StringUtility::newStrDup(footerText); allStrings.insert( allStrings.begin() + i, footer); allStringSize.insert( allStringSize.begin() + i, footerSize); i++; // Add header char* header = new char[ strlen( routeText ) + 14 + 2 + 1 ]; int headerPos = sprintf(header, "%s %u/NN", routeText, curSMSNumber+1 ); headerPos += SMSStringUtility::writeEol( header, headerPos, eol, 5 ); header[headerPos] = '\0'; allStrings.insert( allStrings.begin() + i, header); allStringSize.insert( allStringSize.begin() + i, strlen(header)); headerPositions.push_back(i); // Update variables curSMSNumber++; curSize = headerSize; } else { curSize += allStringSize[ i ]; } i++; } // Change all the "NN" to the total number of SMSes (curSMSNumber+1) for (i=0; i<headerPositions.size(); i++) { // Write the number to a temporary str char nbrStr[ 11 ]; sprintf(nbrStr,"%u", curSMSNumber); char* header = allStrings[ headerPositions[i] ]; char* nnPos = strchr(header, '/')+1; if (strlen(nbrStr) < 3) { unsigned int j; for (j=0; j<strlen(nbrStr); j++) { nnPos[j] = nbrStr[j]; } for (j=strlen(nbrStr); j<3; j++) { nnPos[j] = ' '; } } } // Add the last string to headerPos... headerPositions.push_back(allStrings.size()); // Create the SMSes and insert them into the outparameter (destVector) for (i=0; i<headerPositions.size()-1; i++) { char* curSMS = new char[MAX_SMS_LENGTH + 1]; curSMS[0] = '\0'; for (uint32 j=headerPositions[i]; j<headerPositions[i+1]; j++) { strcat(curSMS, allStrings[j]); } destVector.push_back(curSMS); } delete [] footerText; STLUtility::deleteArrayValues( allStrings ); return (true); } delete [] footerText; STLUtility::deleteArrayValues( allStrings ); // Not possible to get here... return (false); } void ExpandStringItemVector::deleteAllObjs() { STLUtility::deleteValues( m_items ); }
37.53125
755
0.596586
wayfinder
1630feb25eed9cd62666bec74c584312f85fe8be
949
cpp
C++
test/std/iterators/iterator.primitives/iterator.traits/volatile_pointer.pass.cpp
AOSiP/platform_external_libcxx
eb2115113f10274c0d25523ba44c3c7373ea3209
[ "MIT" ]
2,151
2020-04-18T07:31:17.000Z
2022-03-31T08:39:18.000Z
test/std/iterators/iterator.primitives/iterator.traits/volatile_pointer.pass.cpp
AOSiP/platform_external_libcxx
eb2115113f10274c0d25523ba44c3c7373ea3209
[ "MIT" ]
395
2020-04-18T08:22:18.000Z
2021-12-08T13:04:49.000Z
test/std/iterators/iterator.primitives/iterator.traits/volatile_pointer.pass.cpp
AOSiP/platform_external_libcxx
eb2115113f10274c0d25523ba44c3c7373ea3209
[ "MIT" ]
338
2020-04-18T08:03:10.000Z
2022-03-29T12:33:22.000Z
//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <iterator> // template<class T> // struct iterator_traits<const T*> #include <iterator> #include <type_traits> struct A {}; int main() { typedef std::iterator_traits<volatile A*> It; static_assert((std::is_same<It::difference_type, std::ptrdiff_t>::value), ""); static_assert((std::is_same<It::value_type, A>::value), ""); static_assert((std::is_same<It::pointer, volatile A*>::value), ""); static_assert((std::is_same<It::reference, volatile A&>::value), ""); static_assert((std::is_same<It::iterator_category, std::random_access_iterator_tag>::value), ""); }
32.724138
101
0.557429
AOSiP
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
16319ef06341384124a576075914934061e264e4
1,233
cpp
C++
C++/06_Dl/UniqueAndStaticVar/gatewaySDK/src/ParameterAPI.cpp
zhenkunhe/Developer-Tutorial
6e4e4e36364fd8081a68ebf43bf6ab433add613e
[ "MIT" ]
null
null
null
C++/06_Dl/UniqueAndStaticVar/gatewaySDK/src/ParameterAPI.cpp
zhenkunhe/Developer-Tutorial
6e4e4e36364fd8081a68ebf43bf6ab433add613e
[ "MIT" ]
null
null
null
C++/06_Dl/UniqueAndStaticVar/gatewaySDK/src/ParameterAPI.cpp
zhenkunhe/Developer-Tutorial
6e4e4e36364fd8081a68ebf43bf6ab433add613e
[ "MIT" ]
null
null
null
/** * @file ParameterHandle.cpp * @author alex * @date 2017年2月20日 * @version 1.0 * * @brief <brief> * * @section DESCRIPTION * * Your description * */ #include <gateway/ParameterAPI.h> #include <gateway/ParameterHandler.hpp> #include "gateway/Gateway.hpp" #include "json/json.hpp" #include "zmq/zmq.hpp" #include "zmq/zmsg.hpp" using json = nlohmann::json; using namespace zmq; char* HandleParameter( const char* action , const char* parameterName , const char* parameterValue ) { socket_t client( *Gateway::GetContext() , ZMQ_REQ ); client.connect( PARAMETER_INPROC_CLIENTS_PATH ); json jsonMsg; jsonMsg[PARAMETER_ACTION] = (action == NULL ? "" : action); jsonMsg[PARAMETER_NAME] = (parameterName == NULL ? "" : parameterName); jsonMsg[PARAMETER_VALUE] = (parameterValue == NULL ? "" : parameterValue); zmsg msg( jsonMsg.dump().c_str() ); msg.send( client ); msg.recv( client ); return msg.body(); } void SetParameter( const char* parameterName , const char* parameterValue ) { HandleParameter( PARAMETER_ACTION_SET , parameterName , parameterValue ); } char* GetParameter( const char* parameterName ) { return HandleParameter( PARAMETER_ACTION_GET , parameterName , NULL ); }
23.264151
100
0.702352
zhenkunhe
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
16348a6d21c19851811ab3ff9f12badeef2d491e
3,029
cc
C++
content/browser/renderer_host/render_process_host_mojo_impl.cc
shaochangbin/chromium-crosswalk
634d34e4cf82b4f7400357c53ec12efaffe94add
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
2
2019-01-16T03:57:28.000Z
2021-01-23T15:29:45.000Z
content/browser/renderer_host/render_process_host_mojo_impl.cc
shaochangbin/chromium-crosswalk
634d34e4cf82b4f7400357c53ec12efaffe94add
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
content/browser/renderer_host/render_process_host_mojo_impl.cc
shaochangbin/chromium-crosswalk
634d34e4cf82b4f7400357c53ec12efaffe94add
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
1
2017-03-15T13:21:38.000Z
2017-03-15T13:21:38.000Z
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "content/browser/renderer_host/render_process_host_mojo_impl.h" #include "base/platform_file.h" #include "content/common/mojo/mojo_channel_init.h" #include "content/common/mojo/mojo_messages.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_process_host.h" #include "mojo/embedder/platform_channel_pair.h" namespace content { namespace { base::PlatformFile PlatformFileFromScopedPlatformHandle( mojo::embedder::ScopedPlatformHandle handle) { #if defined(OS_POSIX) return handle.release().fd; #elif defined(OS_WIN) return handle.release().handle; #endif } } // namespace struct RenderProcessHostMojoImpl::PendingHandle { PendingHandle() : view_routing_id(0) {} int32 view_routing_id; mojo::ScopedMessagePipeHandle handle; }; RenderProcessHostMojoImpl::RenderProcessHostMojoImpl(RenderProcessHost* host) : host_(host) { } RenderProcessHostMojoImpl::~RenderProcessHostMojoImpl() { } void RenderProcessHostMojoImpl::SetWebUIHandle( int32 view_routing_id, mojo::ScopedMessagePipeHandle handle) { base::ProcessHandle process = host_->GetHandle(); if (process != base::kNullProcessHandle) { CreateMojoChannel(process); // Does nothing if already connected. if (!render_process_mojo_.is_null()) { render_process_mojo_->SetWebUIHandle(view_routing_id, handle.Pass()); return; } } // Remember the request, we'll attempt to reconnect once the child process is // launched. pending_handle_.reset(new PendingHandle); pending_handle_->view_routing_id = view_routing_id; pending_handle_->handle = handle.Pass(); } void RenderProcessHostMojoImpl::OnProcessLaunched() { if (pending_handle_) { scoped_ptr<PendingHandle> handle(pending_handle_.Pass()); SetWebUIHandle(handle->view_routing_id, handle->handle.Pass()); } } void RenderProcessHostMojoImpl::CreateMojoChannel( base::ProcessHandle process_handle) { if (mojo_channel_init_.get()) return; mojo::embedder::PlatformChannelPair channel_pair; mojo_channel_init_.reset(new MojoChannelInit); mojo_channel_init_->Init( PlatformFileFromScopedPlatformHandle(channel_pair.PassServerHandle()), BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); if (!mojo_channel_init_->is_handle_valid()) return; base::PlatformFile client_file = PlatformFileFromScopedPlatformHandle(channel_pair.PassClientHandle()); host_->Send(new MojoMsg_ChannelCreated( IPC::GetFileHandleForProcess(client_file, process_handle, true))); ScopedRenderProcessMojoHandle render_process_handle( RenderProcessMojoHandle( mojo_channel_init_->bootstrap_message_pipe().release().value())); render_process_mojo_.reset(render_process_handle.Pass(), this); } } // namespace content
32.223404
79
0.756685
shaochangbin
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
16386c63361765cca62cc71a12c704df21b77dc2
79,156
cxx
C++
PWGHF/vertexingHF/AliAnalysisTaskSEXic0Semileptonic.cxx
maroozm/AliPhysics
22ec256928cfdf8f800e05bfc1a6e124d90b6eaf
[ "BSD-3-Clause" ]
2
2017-08-01T11:53:34.000Z
2018-12-19T13:20:54.000Z
PWGHF/vertexingHF/AliAnalysisTaskSEXic0Semileptonic.cxx
maroozm/AliPhysics
22ec256928cfdf8f800e05bfc1a6e124d90b6eaf
[ "BSD-3-Clause" ]
null
null
null
PWGHF/vertexingHF/AliAnalysisTaskSEXic0Semileptonic.cxx
maroozm/AliPhysics
22ec256928cfdf8f800e05bfc1a6e124d90b6eaf
[ "BSD-3-Clause" ]
1
2019-05-21T08:47:05.000Z
2019-05-21T08:47:05.000Z
/************************************************************************** * Copyright(c) 1998-2018, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ // Comment describing what this class does needed! //================================================================== // Xi_c^0 analysis // by Jinjoo Seo //================================================================== #include "AliAnalysisTaskSEXic0Semileptonic.h" #include "AliAODcascade.h" #include "AliAODHandler.h" #include "AliAODInputHandler.h" #include "AliAODMCHeader.h" #include "AliAODMCParticle.h" #include "AliAODPidHF.h" #include "AliAODRecoCascadeHF.h" #include "AliAODRecoDecay.h" #include "AliAODRecoDecayHF.h" #include "AliAODVertex.h" #include "AliAODTrack.h" #include <AliAnalysisDataContainer.h> #include <AliAnalysisDataSlot.h> #include "AliAnalysisManager.h" #include "AliAnalysisTaskSE.h" #include "AliESDVertex.h" #include "AliESDtrack.h" #include "AliESDtrackCuts.h" #include "AliExternalTrackParam.h" #include "AliInputEventHandler.h" #include "AliMCEvent.h" #include "AliMultSelection.h" #include "AliPIDResponse.h" #include "AliPIDCombined.h" #include "AliPPVsMultUtils.h" #include "AliRDHFCuts.h" #include "AliTOFPIDResponse.h" #include <TDatabasePDG.h> #include <TH1F.h> #include <TH2F.h> #include <THnSparse.h> #include <TLorentzVector.h> #include <TParticle.h> #include <TParticlePDG.h> #include "TROOT.h" #include <TSystem.h> #include <TTree.h> const Double_t pi = TMath::Pi(); enum {kPN=1, kPP, kNN, kMixing, kAllType}; //P=Positive charge, N=Negative AliAnalysisTaskSEXic0RunTable::AliAnalysisTaskSEXic0RunTable() : fCollisionType(kUnknownCollType) {;} //defult constructor AliAnalysisTaskSEXic0RunTable::AliAnalysisTaskSEXic0RunTable(Int_t fRunNumber) : fCollisionType(kUnknownCollType) { //if (fRunNumber>=256504 && fRunNumber<=260014) fCollisionType=kPP; //LHC16kl //else if (fRunNumber>=254604 && fRunNumber<=255467) fCollisionType=kPP; //LHC16h fCollisionType=kPP; } AliAnalysisTaskSEXic0RunTable::~AliAnalysisTaskSEXic0RunTable() {;} //---------------------------------------------------------------------- AliAnalysisTaskSEXic0Semileptonic::AliAnalysisTaskSEXic0Semileptonic() : AliAnalysisTaskSE("AliAnalysisTaskSEXic0Semileptonic"), fOption() { fMCXicTreeVariable = 0; fPaireXiTreeVariable = 0; fMCTreeVariable = 0; fEventTreeVariable = 0; fMCXicTree = 0; fPaireXiTree = 0; fMCTree = 0; fEventTree = 0; fCounter = 0; DefineOutput(1, TDirectory::Class()); DefineOutput(2, TList::Class()); DefineOutput(3, TTree::Class()); DefineOutput(4, TTree::Class()); DefineOutput(5, TTree::Class()); DefineOutput(6, TTree::Class()); DefineOutput(7, AliNormalizationCounter::Class()); DefineOutput( 8, AliNormalizationCounter::Class()); fCounter_MB_0to100 = 0; DefineOutput( 9, AliNormalizationCounter::Class()); fCounter_MB_0p1to30 = 0; DefineOutput(10, AliNormalizationCounter::Class()); fCounter_MB_30to100 = 0; DefineOutput(11, AliNormalizationCounter::Class()); fCounter_HMV0_0to0p1 = 0; DefineOutput(12, AliNormalizationCounter::Class()); fCntINEL0_MB_0to100 = 0; DefineOutput(13, AliNormalizationCounter::Class()); fCntINEL0_MB_0p1to30 = 0; DefineOutput(14, AliNormalizationCounter::Class()); fCntINEL0_MB_30to100 = 0; DefineOutput(15, AliNormalizationCounter::Class()); fCntINEL0_HMV0_0to0p1 = 0; } //---------------------------------------------------------------------------------------------------------- AliAnalysisTaskSEXic0Semileptonic::AliAnalysisTaskSEXic0Semileptonic(const char *name, const char *option) : AliAnalysisTaskSE(name), fOption(option) { fMCXicTreeVariable = 0; fPaireXiTreeVariable = 0; fMCTreeVariable = 0; fEventTreeVariable = 0; fMCXicTree = 0; fPaireXiTree = 0; fMCTree = 0; fEventTree = 0; fCounter = 0; DefineOutput(1, TDirectory::Class()); DefineOutput(2, TList::Class()); DefineOutput(3, TTree::Class()); DefineOutput(4, TTree::Class()); DefineOutput(5, TTree::Class()); DefineOutput(6, TTree::Class()); DefineOutput(7, AliNormalizationCounter::Class()); DefineOutput( 8, AliNormalizationCounter::Class()); fCounter_MB_0to100 = 0; DefineOutput( 9, AliNormalizationCounter::Class()); fCounter_MB_0p1to30 = 0; DefineOutput(10, AliNormalizationCounter::Class()); fCounter_MB_30to100 = 0; DefineOutput(11, AliNormalizationCounter::Class()); fCounter_HMV0_0to0p1 = 0; DefineOutput(12, AliNormalizationCounter::Class()); fCntINEL0_MB_0to100 = 0; DefineOutput(13, AliNormalizationCounter::Class()); fCntINEL0_MB_0p1to30 = 0; DefineOutput(14, AliNormalizationCounter::Class()); fCntINEL0_MB_30to100 = 0; DefineOutput(15, AliNormalizationCounter::Class()); fCntINEL0_HMV0_0to0p1 = 0; } //------------------------------------------------------------------- AliAnalysisTaskSEXic0Semileptonic::AliAnalysisTaskSEXic0Semileptonic( const AliAnalysisTaskSEXic0Semileptonic& ap) : AliAnalysisTaskSE("AliAnalysisTaskSEXic0Semileptonic"), fOption(ap.fOption) {;} //------------------------------------------------------------------------------ AliAnalysisTaskSEXic0Semileptonic& AliAnalysisTaskSEXic0Semileptonic::operator = (const AliAnalysisTaskSEXic0Semileptonic& ap) { //assignment operator this->~AliAnalysisTaskSEXic0Semileptonic(); new(this) AliAnalysisTaskSEXic0Semileptonic(ap); return *this; } //--------------------------------------------------------------------- AliAnalysisTaskSEXic0Semileptonic::~AliAnalysisTaskSEXic0Semileptonic() { delete fOutput; delete fMCXicTree; delete fPaireXiTree; delete fHistos; delete fMCTree; delete fMCXicTree; delete fPaireXiTree; delete fEventTree; delete fTrackCuts; delete fPIDResponse; delete fRunTable; delete fCounter; delete fEvtCuts; delete fMCXicTreeVariable; delete fPaireXiTreeVariable; delete fMCTreeVariable; delete fEventTreeVariable; delete fEvtCuts_HMV0; delete fCounter_MB_0to100; delete fCounter_MB_0p1to30; delete fCounter_MB_30to100; delete fCounter_HMV0_0to0p1; delete fCntINEL0_MB_0to100; delete fCntINEL0_MB_0p1to30; delete fCntINEL0_MB_30to100; delete fCntINEL0_HMV0_0to0p1; } //================================================================================================= //--------------------------------------------------------------- void AliAnalysisTaskSEXic0Semileptonic::UserCreateOutputObjects() { fTrackCuts = new AliESDtrackCuts(); { //fTrackCuts->SetMinNClustersTPC(fNClustersTPCMin); //tpc cluster fTrackCuts->SetRequireTPCRefit(kTRUE); //tpc refit fTrackCuts->SetRequireITSRefit(kTRUE); //its refit fTrackCuts->SetMinNClustersITS(fNClustersITSMin); //its cluster fTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kBoth); fTrackCuts->SetMaxDCAToVertexXY(1.0); fTrackCuts->SetMaxDCAToVertexZ(2.0); fTrackCuts->SetDCAToVertex2D(kTRUE); fTrackCuts->SetMaxChi2PerClusterITS(36); } fEvtCuts = new AliRDHFCutsXictoeleXifromAODtracks(); fEvtCuts->SetUsePhysicsSelection(kTRUE); fEvtCuts->SetTriggerClass(""); fEvtCuts->SetUseInt7TriggerPP2012(); fEvtCuts->SetTriggerMask(AliVEvent::kINT7); fEvtCuts->SetOptPileup(AliRDHFCuts::kRejectMVPileupEvent); // multi vertexer pileup rejection //fEvtCuts->ResetMaskAndEnableMBTrigger(); fEvtCuts_HMV0 = new AliRDHFCutsXictoeleXifromAODtracks(); fEvtCuts_HMV0->SetUsePhysicsSelection(kTRUE); fEvtCuts_HMV0->SetTriggerClass(""); //kimc: keep this - otherwise floating point exception occur fEvtCuts_HMV0->SetTriggerMask(AliVEvent::kHighMultV0); fEvtCuts_HMV0->SetOptPileup(AliRDHFCuts::kRejectMVPileupEvent); // multi vertexer pileup rejection //******************************************* cout <<endl; fTargetTriggers.clear(); if (fUsekINT7) { fTargetTriggers.push_back(AliVEvent::kINT7); cout <<Form("Adding trigger: kINT7 (BIT %i)", AliVEvent::kINT7) <<endl; } if (fUsekHMV0) { fTargetTriggers.push_back(AliVEvent::kHighMultV0); cout <<Form("Adding trigger: kHighMultV0 (BIT %i)", AliVEvent::kHighMultV0) <<endl; } if (fUsekHMSPD) { fTargetTriggers.push_back(AliVEvent::kHighMultSPD); cout <<Form("Adding trigger: kHighMultSPD (BIT %i)", AliVEvent::kHighMultSPD) <<endl; } if (fTargetTriggers.size() > 1) cout <<"* Multiple triggers are being used: creating EventTree->fTrigBit\n"; cout <<endl; //******************************************* fHistos = new THistManager("histogram"); vector<TString> Event = { "All", "ProperB", "RDHCCutsSel", "Sel", "MB", "PSpileup_SPD", "PSpileup_MV", "Goodz","Goodzcut", "HMV0", "HMSPD" }; auto hEventCount = fHistos->CreateTH1("hEventNumbers", "", Event.size(), 0, Event.size()); for (auto i=0u; i<Event.size(); i++) hEventCount->GetXaxis()->SetBinLabel(i+1, Event.at(i).Data()); Double_t bin[8] = {1, 2, 3, 4, 5, 6, 8, 12}; Double_t bin_old[8] = {0, 1, 2, 3.2, 4.4, 6, 8, 12}; Double_t rapbin[21] = {-1, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1}; Double_t widebin[11] = {0, 1, 2, 3, 4, 5, 6, 8, 12, 16, 20}; fHistos->CreateTH1("Centrality","",100,0,100,"s"); fHistos->CreateTH1("NumOfEvtperRun","", (295000-252000),252000,295000,"s"); //kimc fHistos->CreateTH1("NumOfe","", (295000-252000),252000,295000,"s"); //kimc fHistos->CreateTH1("NumOfXi","", (295000-252000),252000,295000,"s"); //kimc //kimc, check effect of INEL>0, June 22 //MB, MB_0to100, MB_0p1to30, MB_30to100, HMV0, and HMV0_0to0p1 if (IsMC == false) fHistos->CreateTH1("hINELLgt0_0", "", 6, 0, 6, "s"); if (IsMC == false) fHistos->CreateTH1("hINELLgt0_1", "", 6, 0, 6, "s"); //kimc, check pileup cuts' effect on combinations: 3 cuts x 5 cases (Oct. 6, 2021) //3 cuts: oldSPD (fixed SPD contributors), newSPD (varying SPD contributors), and MV if (IsMC == false) { vector<const char*> hPUCut = { "MB_old", "MB_new", "MB_MV", "MB_old_0to100", "MB_new_0to100", "MB_MV_0to100", "MB_old_0p1to30", "MB_new_0p1to30", "MB_MV_0p1to30", "MB_old_30to100", "MB_new_30to100", "MB_MV_30to100", "HMV0_old_0to0p1", "HMV0_new_0to0p1", "HMV0_MV_0to0p1" }; auto hPileupEffect = fHistos->CreateTH1("hPileupEffect", "", hPUCut.size(), 0, hPUCut.size(), "s"); for (UInt_t a=0; a<hPUCut.size(); a++) hPileupEffect->GetXaxis()->SetBinLabel(a+1, hPUCut[a]); } fHistos->CreateTH1("hNonPromptXicRap","",500,-5,5,"s"); fHistos->CreateTH1("hPromptXicRap","",500,-5,5,"s"); fHistos->CreateTH1("hXicRap","",500,-5,5,"s"); fHistos->CreateTH2("nSigmaTPCvsPt","",10,0.,5.,200,-10.,10.,"s"); fHistos->CreateTH2("nSigmaTOFvsPt","",50,0.,5.,15,-5.,5.,"s"); fHistos->CreateTH1("DSElectronPair","",100,0.,0.5,"s"); fHistos->CreateTH1("SSElectronPair","",100,0.,0.5,"s"); fHistos->CreateTH1("hXimass","",100,1.26,1.38,"s"); fHistos->CreateTH1("hXimass_total","",2000,0,3,"s"); fHistos->CreateTH2("hXimassvsPt","",100,1.29,1.35,10,0.,10.,"s"); fHistos->CreateTH1("hEleXiMassRS","",10,1.3,3.3,"s"); fHistos->CreateTH1("hEleXiMassWS","",10,1.3,3.3,"s"); fHistos->CreateTH1("hEleXiPtRS","",10,widebin,"s"); fHistos->CreateTH1("hEleXiPtWS","",10,widebin,"s"); fHistos->CreateTH1("hEleXiPtRS_SameSign","",10,widebin,"s"); fHistos->CreateTH1("hEleXiPtWS_SameSign","",10,widebin,"s"); fHistos->CreateTH1("hLooseEleXiPtRS","",10,widebin,"s"); fHistos->CreateTH1("hLooseEleXiPtWS","",10,widebin,"s"); fHistos->CreateTH1("eXiFromXib","",10,widebin,"s"); fHistos->CreateTH1("Xib","",10,widebin,"s"); fHistos->CreateTH2("XibvseXiRPM","",10,widebin,10,widebin,"s"); fHistos->CreateTH1("eXiFromXibGen","",10,widebin,"s"); fHistos->CreateTH1("XibGen","",10,widebin,"s"); fHistos->CreateTH1("XibGen05","",10,widebin,"s"); fHistos->CreateTH2("XibvseXiRPMGen","",10,widebin,10,widebin,"s"); fHistos->CreateTH2("hXicPtRap","",10,widebin,20,rapbin,"s"); fHistos->CreateTH1("hTrueXic0","",10,widebin,"s"); fHistos->CreateTH1("hTrueXic0_oldbin","",7,bin_old,"s"); fHistos->CreateTH1("hTrueXic0_rap8","",10,widebin,"s"); fHistos->CreateTH1("hTrueXic0_oldbin_rap8","",7,bin_old,"s"); fHistos->CreateTH1("hTruePaireXi","",10,widebin,"s"); fHistos->CreateTH1("hGenXic0PtFromXib","",10,widebin,"s"); fHistos->CreateTH1("hGenXic0PtFromXic","",10,widebin,"s"); fHistos->CreateTH1("hXic0PtFromBottom1","",10,widebin,"s"); fHistos->CreateTH1("hXic0PtFromBottom2","",10,widebin,"s"); fHistos->CreateTH1("hXic0PtFromCharm1","",10,widebin,"s"); fHistos->CreateTH1("hXic0PtFromCharm2","",10,widebin,"s"); fHistos->CreateTH1("hElectronFromXic0","",10,widebin,"s"); fHistos->CreateTH1("hCascadeFromXic0","",10,widebin,"s"); fHistos->CreateTH1("hMCXic0AllRap","",12,0,12,"s"); fHistos->CreateTH2("hMCXic0vsPair","",10,widebin,10,widebin,"s"); fHistos->CreateTH2("hXic0vseXiRPM","",10,widebin,10,widebin,"s"); fHistos->CreateTH1("hGenXic0Pt","",10,widebin,"s"); fHistos->CreateTH1("hGenXic0Pt1","",10,widebin,"s"); fHistos->CreateTH1("hGenXic0Pt2","",10,widebin,"s"); fHistos->CreateTH1("hRecoPairPt","",10,widebin,"s"); vector<TString> DecayChannel ={"e&Xi","!e&Xi","e&!Xi","!e&!Xi"}; auto hMCXic0Decays = fHistos->CreateTH1("hMCXic0Decays","",DecayChannel.size(), 0, DecayChannel.size()); for(auto i=0u; i<DecayChannel.size(); i++) hMCXic0Decays->GetXaxis()->SetBinLabel(i+1,DecayChannel.at(i).Data()); //---------------------------CUT STUDY (MC Xi from Xic0)---------------------------// vector <TString> ent6 ={"all","DCAV0Pr_c","DCAV0Pi_c","DCABach_c","DCAV0_c","COS1_c","COS2_c","DLXi_c","DLV0_c"}; auto h6 = fHistos->CreateTH1("C_flag","",ent6.size(), 0, ent6.size()); for(auto i=0u; i<ent6.size(); i++) h6->GetXaxis()->SetBinLabel(i+1,ent6.at(i).Data()); vector <TString> ent7 ={"all","DCAV0Pr_b","DCAV0Pi_b","DCABach_b","DCAV0_b","COS1_b","COS2_b","DLXi_b","DLV0_b"}; auto h7 = fHistos->CreateTH1("B_flag","",ent7.size(), 0, ent7.size()); for(auto i=0u; i<ent7.size(); i++) h7->GetXaxis()->SetBinLabel(i+1,ent7.at(i).Data()); vector <TString> ent8 ={"all","DLXi_c","DCABach_c","DCAV0Pi_c","DCAV0Pr_c","DCAV0_c","COS1_c","COS2_c","DLV0_c"}; auto h8 = fHistos->CreateTH1("Ccut_flag","",ent8.size(), 0, ent8.size()); for(auto i=0u; i<ent8.size(); i++) h8->GetXaxis()->SetBinLabel(i+1,ent8.at(i).Data()); vector <TString> ent9 ={"all","DLXi_b","DCABach_b","DCAV0Pi_b","DCAV0Pr_b","DCAV0_b","COS1_b","COS2_b","DLV0_b"}; auto h9 = fHistos->CreateTH1("Bcut_flag","",ent9.size(), 0, ent9.size()); for(auto i=0u; i<ent9.size(); i++) h9->GetXaxis()->SetBinLabel(i+1,ent9.at(i).Data()); vector <TString> ent10 ={"all","Filterbit_c","TrackCut_c","pT_c","eta_c","TOF_c","TPC_c","prefilter_c"}; auto h10 = fHistos->CreateTH1("e_c_flag","",ent10.size(), 0, ent10.size()); for(auto i=0u; i<ent10.size(); i++) h10->GetXaxis()->SetBinLabel(i+1,ent10.at(i).Data()); vector <TString> ent11 ={"all","Filterbit_b","TrackCut_b","pT_b","eta_b","TOF_b","TPC_b","prefilter_b"}; auto h11 = fHistos->CreateTH1("e_b_flag","",ent11.size(), 0, ent11.size()); for(auto i=0u; i<ent11.size(); i++) h11->GetXaxis()->SetBinLabel(i+1,ent11.at(i).Data()); fHistos->CreateTH1("hDCAV0PrToPrimVertex","",2500,0.,5.,"s"); fHistos->CreateTH1("hDCAV0PiToPrimVertex","",2500,0.,5.,"s"); fHistos->CreateTH1("hDCABachToPrimVertex","",2500,0.,5.,"s"); fHistos->CreateTH1("hDCAV0ToPrimVertex","",2500,0.,5.,"s"); fHistos->CreateTH1("hV0CosineOfPoiningAngleXi","",500,0.,1.,"s"); fHistos->CreateTH1("hV0CosineOfPoiningAngleV0Xi","",500,0.,1.,"s"); fHistos->CreateTH1("hCascDecayLength","",1000,0.,20.,"s"); fHistos->CreateTH1("hDecayLengthV0","",1000,0.,20.,"s"); fHistos->CreateTH1("hDCAV0PrToPrimVertex_b","",2500,0.,5.,"s"); fHistos->CreateTH1("hDCAV0PiToPrimVertex_b","",2500,0.,5.,"s"); fHistos->CreateTH1("hDCABachToPrimVertex_b","",2500,0.,5.,"s"); fHistos->CreateTH1("hDCAV0ToPrimVertex_b","",2500,0.,5.,"s"); fHistos->CreateTH1("hV0CosineOfPoiningAngleXi_b","",500,0.,1.,"s"); fHistos->CreateTH1("hV0CosineOfPoiningAngleV0Xi_b","",500,0.,1.,"s"); fHistos->CreateTH1("hCascDecayLength_b","",1000,0.,20.,"s"); fHistos->CreateTH1("hDecayLengthV0_b","",1000,0.,20.,"s"); fHistos->CreateTH1("hDCAV0PrToPrimVertex_c","",2500,0.,5.,"s"); fHistos->CreateTH1("hDCAV0PiToPrimVertex_c","",2500,0.,5.,"s"); fHistos->CreateTH1("hDCABachToPrimVertex_c","",2500,0.,5.,"s"); fHistos->CreateTH1("hDCAV0ToPrimVertex_c","",2500,0.,5.,"s"); fHistos->CreateTH1("hV0CosineOfPoiningAngleXi_c","",500,0.,1.,"s"); fHistos->CreateTH1("hV0CosineOfPoiningAngleV0Xi_c","",500,0.,1.,"s"); fHistos->CreateTH1("hCascDecayLength_c","",1000,0.,20.,"s"); fHistos->CreateTH1("hDecayLengthV0_c","",1000,0.,20.,"s"); PostData(1, fHistos); PostData(2, fTrackCuts); DefineMCXicTree(); PostData(3, fMCXicTree); DefinePaireXiTree(); PostData(4, fPaireXiTree); DefineMCPaireXiTree(); PostData(5, fMCTree); DefineEventTree(); PostData(6, fEventTree); fCounter = new AliNormalizationCounter("NormalizationCounter"); fCounter->SetStudyMultiplicity(kTRUE, 1.); fCounter->Init(); PostData(7, fCounter); //kimc, Mar. 18, 2021 fCounter_MB_0to100 = new AliNormalizationCounter("ANC_MB_0to100"); fCounter_MB_0p1to30 = new AliNormalizationCounter("ANC_MB_0p1to30"); fCounter_MB_30to100 = new AliNormalizationCounter("ANC_MB_30to100"); fCounter_HMV0_0to0p1 = new AliNormalizationCounter("ANC_HMV0_0to0p1"); fCounter_MB_0to100 ->SetStudyMultiplicity(kTRUE, 1.); fCounter_MB_0p1to30 ->SetStudyMultiplicity(kTRUE, 1.); fCounter_MB_30to100 ->SetStudyMultiplicity(kTRUE, 1.); fCounter_HMV0_0to0p1->SetStudyMultiplicity(kTRUE, 1.); fCounter_MB_0to100 ->Init(); fCounter_MB_0p1to30 ->Init(); fCounter_MB_30to100 ->Init(); fCounter_HMV0_0to0p1->Init(); PostData( 8, fCounter_MB_0to100); PostData( 9, fCounter_MB_0p1to30); PostData(10, fCounter_MB_30to100); PostData(11, fCounter_HMV0_0to0p1); //kimc, Mar. 18, 2021 fCntINEL0_MB_0to100 = new AliNormalizationCounter("ANCINEL0_MB_0to100"); fCntINEL0_MB_0p1to30 = new AliNormalizationCounter("ANCINEL0_MB_0p1to30"); fCntINEL0_MB_30to100 = new AliNormalizationCounter("ANCINEL0_MB_30to100"); fCntINEL0_HMV0_0to0p1 = new AliNormalizationCounter("ANCINEL0_HMV0_0to0p1"); fCntINEL0_MB_0to100 ->SetStudyMultiplicity(kTRUE, 1.); fCntINEL0_MB_0p1to30 ->SetStudyMultiplicity(kTRUE, 1.); fCntINEL0_MB_30to100 ->SetStudyMultiplicity(kTRUE, 1.); fCntINEL0_HMV0_0to0p1->SetStudyMultiplicity(kTRUE, 1.); fCntINEL0_MB_0to100 ->Init(); fCntINEL0_MB_0p1to30 ->Init(); fCntINEL0_MB_30to100 ->Init(); fCntINEL0_HMV0_0to0p1->Init(); PostData(12, fCntINEL0_MB_0to100); PostData(13, fCntINEL0_MB_0p1to30); PostData(14, fCntINEL0_MB_30to100); PostData(15, fCntINEL0_HMV0_0to0p1); return; }//UserCreateOutputObjects //--------------------------------------------------------- void AliAnalysisTaskSEXic0Semileptonic::UserExec(Option_t*) { //Pointer to a event AliVEvent *event = InputEvent(); if (!event) { Printf("ERROR: Could not retrieve event"); return; } //Return 1 //AOD Analysis Start event->IsA()==AliESDEvent::Class() ? fEvt = dynamic_cast<AliESDEvent*>(event) : fEvt = dynamic_cast<AliAODEvent*>(event); if (!fEvt) return; //Return 2 fHistos->FillTH1("hEventNumbers", "All", 1); //Check B-field fBzkG = (Double_t)fEvt->GetMagneticField(); if (TMath::Abs(fBzkG) < 0.001) return; //Return 3 fHistos->FillTH1("hEventNumbers", "ProperB", 1); //Check run # fRunNumber = fEvt->GetRunNumber(); if (fRunNumber<252000 || fRunNumber>295000) return; //Discard events w/ invalid run numbers (RUN2), Return 4 fRunTable = new AliAnalysisTaskSEXic0RunTable(fRunNumber); //Retrieve centrality info fCentrality = -999; //kimC fCentralSPD = -999; //kimC fNSPDTracklets = -999; //kimc AliMultSelection *MultSelection = 0x0; MultSelection = (AliMultSelection*)fEvt->FindListObject("MultSelection"); if (!MultSelection) { //If you get this warning (and lPercentiles -999) //please check that the AliMultSelectionTask actually ran (before your task) AliWarning("AliMultSelection object not found!"); } else { if (IsPA) { fCentrality = MultSelection->GetMultiplicityPercentile("V0A"); } else { fCentrality = MultSelection->GetMultiplicityPercentile("V0M"); } fCentralSPD = MultSelection->GetMultiplicityPercentile("SPDTracklets"); fNSPDTracklets = MultSelection->GetEstimator("SPDTracklets")->GetValue(); //SPD efficiency problem? Sometimes both values are 0 - NOT makes sense at all if ( fCentralSPD == 0. && fNSPDTracklets == 0. ) fCentralSPD = fNSPDTracklets = -999; } //AliRDHFCuts check: by doing this the cut is being activated (Oct. 15, 2021, kimc) bool IsValid_MB = fEvtCuts ->IsEventSelected(fEvt); bool IsValid_HMV0 = fEvtCuts_HMV0->IsEventSelected(fEvt); //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //Load InputHandler for each event AliInputEventHandler* inputHandler = (AliInputEventHandler*)AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler(); //Check if pID available fPIDResponse = (AliPIDResponse*) inputHandler->GetPIDResponse(); if (!fPIDResponse) printf("AliAnalysisTaskSEXic0Semileptonic No PIDd\n"); fHistos->FillTH1("hEventNumbers", "All", 1); //kimc: "flag for event selected" - is this an event-wise cut? if (fEvtCuts->IsEventSelected(fEvt)) fHistos->FillTH1("hEventNumbers", "RDHCCutsSel", 1); //Physics Selection if (!(inputHandler->IsEventSelected())) return; //Return 5 fHistos->FillTH1("hEventNumbers", "Sel", 1); //Check trigger //***************************************************** if (fTargetTriggers.size() == 0) AliFatal("WARNING: target trigger container is empty! Stop."); Bool_t IsTrigFired = false; Bool_t IsTrigFired_MB = false; Bool_t IsTrigFired_HMV0 = false; for (unsigned int a=0; a<fTargetTriggers.size(); a++) { if (inputHandler->IsEventSelected() & fTargetTriggers[a]) IsTrigFired = true; //LHC16k and l are CD dedicated runs! CD-online-trigger is used if (fOption.Contains("LHC16k") || fOption.Contains("LHC16l")) { TString firedTriggerClasses = fEvt->GetFiredTriggerClasses(); if ( (fTargetTriggers[a] == AliVEvent::kINT7) && (firedTriggerClasses.Contains("CINT7-B-NOPF-CENT")) ) IsTrigFired = true; } } if (IsTrigFired == false) return; //No trigger fired, Return 6 else { if (inputHandler->IsEventSelected() & AliVEvent::kINT7) { IsTrigFired_MB = true; fHistos->FillTH1("hEventNumbers", "MB", 1); } if (inputHandler->IsEventSelected() & AliVEvent::kHighMultV0) { IsTrigFired_HMV0 = true; fHistos->FillTH1("hEventNumbers", "HMV0", 1); } } //INEL > 0 check, for data //***************************************************** fIsINELLgtZERO = false; if (IsMC==false && AliPPVsMultUtils::IsINELgtZERO(fEvt)==true) fIsINELLgtZERO = true; //INEL>0 effect check histograms if (IsMC == false) { for (int a=0; a<2; a++) { const char* fHistName = Form("hINELLgt0_%i", a); if (a==1 && fIsINELLgtZERO==false) continue; if (IsTrigFired_MB) { fHistos->FillTH1(fHistName, 0.); if (fCentrality >= 0.0 && fCentrality <= 100.0) fHistos->FillTH1(fHistName, 1.); if (fCentrality >= 0.1 && fCentrality <= 30.0) fHistos->FillTH1(fHistName, 2.); if (fCentrality >= 30.0 && fCentrality <= 100.0) fHistos->FillTH1(fHistName, 3.); } if (IsTrigFired_HMV0) { fHistos->FillTH1(fHistName, 4.); if (fCentrality >= 0.0 && fCentrality <= 0.1) fHistos->FillTH1(fHistName, 5.); } }//a, trig and trig+INEL>0 }//data only //Pileup check //***************************************************** //Reject pile-up events by using SPD ( https://twiki.cern.ch/twiki/bin/viewauth/ALICE/AliDPGtoolsPileup ) Int_t nContributor = -999; if (IsPA) nContributor = 5; //For pA, but there's a NOTE at above link - PLEASE CHECK else { if ( fNSPDTracklets < 20 ) nContributor = 3; //Conventional, valid for low multiplicity pp else if ( fNSPDTracklets < 50 ) nContributor = 4; //20 ~ 50 else nContributor = 5; //>= 50, valid for high multiplicity pp and p-Pb } if (nContributor == -999) cout <<"ERROR in pileup cut!\n"; //if (!IsMC && fEvt->IsPileupFromSPD(nContributor, 0.8, 3., 2., 5.)) return; //if (!IsMC && fEvt->IsPileupFromSPD(3.,0.8,3.,2.,5.)) return; //Conventional setting before Sep. 17, 2021 //Old pileup cuts based on SPD: true means this event is piled up bool pileup_SPD_old = (!IsMC && fEvt->IsPileupFromSPD(3, 0.8, 3., 2., 5.)) ? true:false; bool pileup_SPD_new = (!IsMC && fEvt->IsPileupFromSPD(nContributor, 0.8, 3., 2., 5.)) ? true:false; //New pileup cuts based on multi vertex: depends on trigger, true means piled up bool pileup_MV_MB = fEvtCuts ->IsEventRejectedDueToPileup(); bool pileup_MV_HMV0 = fEvtCuts_HMV0->IsEventRejectedDueToPileup(); //xCheck if (IsMC == false) { if (IsTrigFired_MB) { //Jinjoo's xCheck if (pileup_SPD_new == false) fHistos->FillTH1("hEventNumbers", "PSpileup_SPD", 1); if (pileup_MV_MB == false) fHistos->FillTH1("hEventNumbers", "PSpileup_MV", 1); //kimc if (pileup_SPD_old == false) { fHistos->FillTH1("hPileupEffect", "MB_old", 1); if (fCentrality>= 0.0 && fCentrality<=100.0) fHistos->FillTH1("hPileupEffect", "MB_old_0to100", 1); if (fCentrality>= 0.1 && fCentrality<= 30.0) fHistos->FillTH1("hPileupEffect", "MB_old_0p1to30", 1); if (fCentrality>=30.0 && fCentrality<=100.0) fHistos->FillTH1("hPileupEffect", "MB_old_30to100", 1); } if (pileup_SPD_new == false) { fHistos->FillTH1("hPileupEffect", "MB_new", 1); if (fCentrality>= 0.0 && fCentrality<=100.0) fHistos->FillTH1("hPileupEffect", "MB_new_0to100", 1); if (fCentrality>= 0.1 && fCentrality<= 30.0) fHistos->FillTH1("hPileupEffect", "MB_new_0p1to30", 1); if (fCentrality>=30.0 && fCentrality<=100.0) fHistos->FillTH1("hPileupEffect", "MB_new_30to100", 1); } if (pileup_MV_MB == false) { fHistos->FillTH1("hPileupEffect", "MB_MV", 1); if (fCentrality>= 0.0 && fCentrality<=100.0) fHistos->FillTH1("hPileupEffect", "MB_MV_0to100", 1); if (fCentrality>= 0.1 && fCentrality<= 30.0) fHistos->FillTH1("hPileupEffect", "MB_MV_0p1to30", 1); if (fCentrality>=30.0 && fCentrality<=100.0) fHistos->FillTH1("hPileupEffect", "MB_MV_30to100", 1); } }//MB trigger fired //kimc if (IsTrigFired_HMV0 && fCentrality>=0.0 && fCentrality<=0.1) { if (pileup_SPD_old == false) fHistos->FillTH1("hPileupEffect", "HMV0_old_0to0p1", 1); if (pileup_SPD_new == false) fHistos->FillTH1("hPileupEffect", "HMV0_new_0to0p1", 1); if (pileup_MV_HMV0 == false) fHistos->FillTH1("hPileupEffect", "HMV0_MV_0to0p1", 1); } }//Pileup QA fPileupStat = 9999; if (!IsMC && pileup_MV_MB==true && pileup_MV_HMV0==true) return; //Pileup in both triggers: discard it, Return 7 else { if (!IsMC && pileup_MV_MB==false && pileup_MV_HMV0==false) fPileupStat = 0; if (!IsMC && pileup_MV_MB==false && pileup_MV_HMV0==true) fPileupStat = 1; if (!IsMC && pileup_MV_MB==true && pileup_MV_HMV0==false) fPileupStat = 2; } //***************************************************** //Primary Vertex Selection fVtxZ = 9999; //kimc const AliVVertex* Vtx = fEvt->GetPrimaryVertex(); if (!Vtx || Vtx->GetNContributors() < 1) return; //Return 8 fHistos->FillTH1("hEventNumbers", "Goodz", 1); //AliNormalizationCounter: store events for later normalization if (IsTrigFired_MB && pileup_MV_MB==false) { fCounter->StoreEvent(fEvt, fEvtCuts, IsMC); //Original, by Jinjoo if (fCentrality >= 0.0 && fCentrality <= 100.0) { fCounter_MB_0to100->StoreEvent(fEvt, fEvtCuts, IsMC); if (fIsINELLgtZERO) fCntINEL0_MB_0to100->StoreEvent(fEvt, fEvtCuts, IsMC); } if (fCentrality >= 0.1 && fCentrality <= 30.0) { fCounter_MB_0p1to30->StoreEvent(fEvt, fEvtCuts, IsMC); if (fIsINELLgtZERO) fCntINEL0_MB_0p1to30->StoreEvent(fEvt, fEvtCuts, IsMC); } if (fCentrality >= 30.0 && fCentrality <= 100.0) { fCounter_MB_30to100->StoreEvent(fEvt, fEvtCuts, IsMC); if (fIsINELLgtZERO) fCntINEL0_MB_30to100->StoreEvent(fEvt, fEvtCuts, IsMC); } }//MB triggered, w/o pileup if (IsTrigFired_HMV0 && pileup_MV_HMV0==false && fCentrality >= 0.0 && fCentrality <= 0.1) { fCounter_HMV0_0to0p1->StoreEvent(fEvt, fEvtCuts_HMV0, IsMC); if (fIsINELLgtZERO) fCntINEL0_HMV0_0to0p1->StoreEvent(fEvt, fEvtCuts_HMV0, IsMC); }//HMV0, w/o pileup, 0 <= Centrality <= 0.1 //***************************************************** //Apply vtx Z cut if (!(fabs(Vtx->GetZ())<10.)) return; //Retun 9 fHistos->FillTH1("hEventNumbers", "Goodzcut", 1); fVtxZ = Vtx->GetZ(); //kimc if (IsHighMul) { if (!AliPPVsMultUtils::IsMinimumBias(fEvt)) return; if (!AliPPVsMultUtils::IsINELgtZERO(fEvt)) return; //INEL>0 if (!AliPPVsMultUtils::IsAcceptedVertexPosition(fEvt)) return; if (!AliPPVsMultUtils::IsNotPileupSPDInMultBins(fEvt)) return; if (!AliPPVsMultUtils::HasNoInconsistentSPDandTrackVertices(fEvt)) return; } //------------------------------------------------------------------------ //---------------------- Event Selection End ----------------------------- //------------------------------------------------------------------------ fHistos->FillTH1("Centrality", fCentrality); fHistos->FillTH1("NumOfEvtperRun", fRunNumber); //MC if (IsMC && fEvt->IsA()==AliAODEvent::Class()) { fMC = inputHandler->MCEvent(); AliAODMCHeader *mcHeader = (AliAODMCHeader*)fEvt->GetList()->FindObject(AliAODMCHeader::StdBranchName()); Double_t zMCVertex = mcHeader->GetVtxZ(); if (!(fabs(zMCVertex)<10.)) return; fVtxZ = zMCVertex; //kimc for (Int_t iTracks=0; iTracks<(fMC->GetNumberOfTracks()); iTracks++) { AliAODMCParticle* MCparticle = (AliAODMCParticle*)fMC->GetTrack(iTracks); if (!MCparticle) continue; FillMCXic0(MCparticle); if (FillMCXib(MCparticle)) continue; //INEL > 0 judgment for MC - kimc, update at Mar. 18, 2021 if ( MCparticle->IsPhysicalPrimary() && MCparticle->Charge() != 0 && fabs(MCparticle->Eta() < 1.0) ) fIsINELLgtZERO = true; } } auto nTracks = fEvt->GetNumberOfTracks(); for (Int_t itrk=0; itrk<nTracks; itrk++) //Filling histogram { AliAODTrack *trk = (AliAODTrack*) fEvt->GetTrack(itrk); if (!trk) continue; if (!(FilterTrack(trk, 100))) continue; Double_t mass; Double_t mass_ss; Bool_t DrawElectron = FilterElectron(trk,mass,mass_ss,0,0,100); } fNeXiPair = 0; //kimc! auto nCascs = fEvt->GetNumberOfCascades(); for (int icasc=0; icasc<nCascs; icasc++) { AliAODcascade *casc = ((AliAODEvent*)fEvt)->GetCascade(icasc); if (!casc) continue; if (!(casc->GetSecondaryVtx())) continue; if (!(casc->GetDecayVertexXi())) continue; if (!FilterCascade(casc)) continue; //cascade cut for (Int_t itrk=0; itrk<nTracks; itrk++) { AliAODTrack *trk = (AliAODTrack*) fEvt->GetTrack(itrk); if (!trk) continue; if (!(FilterTrack(trk,1))) continue; //track cut //***************************************************** //Fill event tree, rearranged variables' order by kimc - updated at Sep. 2 for (int a=0; a<7; a++) fEventTreeVariable[a] = -999; //Reset fEventTreeVariable[0] = fRunNumber; fEventTreeVariable[1] = fCentrality; fEventTreeVariable[2] = fCentralSPD; fEventTreeVariable[3] = (Float_t)fNSPDTracklets; fEventTreeVariable[4] = (Float_t)fNeXiPair; fEventTreeVariable[5] = (Float_t)fVtxZ; fEventTreeVariable[6] = (Float_t)fPileupStat; fEventTreeVarTrig = 0; //Reset if (!IsMC) fEventTreeVarTrig = inputHandler->IsEventSelected(); //fEventTree->Fill(); //Move this inside FillPairEleXi, to sync entries FillPairEleXi(casc, trk); } } PostData(1, fHistos->GetListOfHistograms()); PostData(2, fTrackCuts); PostData(3, fMCXicTree); PostData(4, fPaireXiTree); PostData(5, fMCTree); PostData(6, fEventTree); PostData(7, fCounter); PostData( 8, fCounter_MB_0to100); PostData( 9, fCounter_MB_0p1to30); PostData(10, fCounter_MB_30to100); PostData(11, fCounter_HMV0_0to0p1); PostData(12, fCntINEL0_MB_0to100); PostData(13, fCntINEL0_MB_0p1to30); PostData(14, fCntINEL0_MB_30to100); PostData(15, fCntINEL0_HMV0_0to0p1); return; }//UserExec //================================================================================================= //Filtering //---------------------------------------------------------------------------------------------- Bool_t AliAnalysisTaskSEXic0Semileptonic::FilterTrack(AliAODTrack * track, Int_t FillHistosFlag) { if (!track) return kFALSE; Bool_t b_flag = kFALSE; Bool_t c_flag = kFALSE; if (IsMC) { Int_t e_label = track->GetLabel(); if (e_label>0) { AliAODMCParticle* mc_e = (AliAODMCParticle*) fMC->GetTrack(e_label); Int_t mother_e_label = mc_e->GetMother(); if (mother_e_label>0) { AliAODMCParticle* mcXic0 = (AliAODMCParticle*) fMC->GetTrack(mother_e_label); if (TMath::Abs(mcXic0->GetPdgCode())==4132) CheckOrigin(fMC,mcXic0,kTRUE,c_flag,b_flag); } } }//IsMC if (IsMC && FillHistosFlag==100 && c_flag) fHistos->FillTH1("e_c_flag","all",1); if (IsMC && FillHistosFlag==100 && b_flag) fHistos->FillTH1("e_b_flag","all",1); if (!((AliAODTrack*)track)->TestFilterMask(AliAODTrack::kTrkGlobalNoDCA)) return kFALSE; //filterbit 4 if (IsMC && FillHistosFlag==100 && c_flag) fHistos->FillTH1("e_c_flag","Filterbit_c",1); if (IsMC && FillHistosFlag==100 && b_flag) fHistos->FillTH1("e_b_flag","Filterbit_b",1); AliAODTrack *aodt = dynamic_cast<AliAODTrack*>(track); const AliVVertex* Vtx = fEvt->GetPrimaryVertex(); Double_t pos[3]; Vtx->GetXYZ(pos); Double_t cov[3]; Vtx->GetCovarianceMatrix(cov); const AliESDVertex vESD(pos,cov,100.,100); AliESDtrack copyTrack(aodt); copyTrack.SetTPCClusterMap(aodt->GetTPCClusterMap()); copyTrack.SetTPCSharedMap(aodt->GetTPCSharedMap()); copyTrack.SetTPCPointsF(aodt->GetTPCNclsF()); copyTrack.RelateToVertex(&vESD,0.,3.); if (!(fTrackCuts->IsSelected(&copyTrack))) return kFALSE; /* if(track->GetTPCNclsF() > 0) { Float_t tpcratio = (Float_t)track->GetTPCncls()/(Float_t)track->GetTPCNclsF(); if (tpcratio < fProdTrackTPCNclsRatioMin) return kFALSE; //ratio of findable cluster } */ if (track->GetTPCsignalN() < fSetProdTrackTPCNclsPID) return kFALSE; if (IsMC && FillHistosFlag==100 && c_flag) fHistos->FillTH1("e_c_flag","TrackCut_c",1); if (IsMC && FillHistosFlag==100 && b_flag) fHistos->FillTH1("e_b_flag","TrackCut_b",1); if (track->Pt() < fPtCut) return kFALSE; //pt cut if (IsMC && FillHistosFlag==100 && c_flag) fHistos->FillTH1("e_c_flag","pT_c",1); if (IsMC && FillHistosFlag==100 && b_flag) fHistos->FillTH1("e_b_flag","pT_b",1); if (fabs(track->Eta()) > fEtaCut) return kFALSE; //eta cut if (IsMC && FillHistosFlag==100 && c_flag) fHistos->FillTH1("e_c_flag","eta_c",1); if (IsMC && FillHistosFlag==100 && b_flag) fHistos->FillTH1("e_b_flag","eta_b",1); return kTRUE; }//FilterTrack //------------------------------------------------------- Bool_t AliAnalysisTaskSEXic0Semileptonic::FilterElectron( AliAODTrack *etrk, Double_t &minmass, Double_t &minmass_ss, Bool_t IsSameSign, Bool_t IsLoose, Int_t FillHistosFlag ) { Double_t nSigmaTOF = -9999.; Double_t nSigmaTPC = -9999.; minmass = 9999; minmass_ss = 9999; AliAODcascade *casc = ((AliAODEvent*)fEvt)->GetCascade(1); //tmp cascasde Bool_t b_flag = kFALSE; Bool_t c_flag = kFALSE; if (IsMC) { Int_t e_label = etrk->GetLabel(); if (e_label>0) { AliAODMCParticle* mc_e = (AliAODMCParticle*) fMC->GetTrack(e_label); Int_t mother_e_label = mc_e->GetMother(); if (mother_e_label>0) { AliAODMCParticle* mcXic0 = (AliAODMCParticle*) fMC->GetTrack(mother_e_label); if (TMath::Abs(mcXic0->GetPdgCode())==4132) CheckOrigin(fMC,mcXic0,kTRUE,c_flag,b_flag); } } } nSigmaTOF = fPIDResponse->NumberOfSigmasTOF(etrk,AliPID::kElectron); if ((FillHistosFlag==100) && StandardCutFlag(etrk,casc,1,0,0,0)) { fHistos->FillTH2("nSigmaTOFvsPt",etrk->Pt(),nSigmaTOF); } if (fabs(fPIDResponse->NumberOfSigmasTOF(etrk,AliPID::kElectron))>3) return kFALSE; if (IsMC && FillHistosFlag==100 && c_flag) fHistos->FillTH1("e_c_flag","TOF_c",1); if (IsMC && FillHistosFlag==100 && b_flag) fHistos->FillTH1("e_b_flag","TOF_b",1); Double_t e_pt = etrk->Pt(); Double_t cut_tpc = -4.3+(1.17*e_pt)-(0.094*e_pt*e_pt); nSigmaTPC = fPIDResponse->NumberOfSigmasTPC(etrk,AliPID::kElectron); if ((FillHistosFlag==100) && StandardCutFlag(etrk,casc,1,0,0,0)) { fHistos->FillTH2("nSigmaTPCvsPt",etrk->Pt(),nSigmaTPC); } if (fPIDResponse->NumberOfSigmasTPC(etrk,AliPID::kElectron)>3) return kFALSE; if (fPIDResponse->NumberOfSigmasTPC(etrk,AliPID::kElectron)<cut_tpc) return kFALSE; if (e_pt>5 && fPIDResponse->NumberOfSigmasTPC(etrk,AliPID::kElectron)<(-4.3+(1.17*5)-(0.094*5*5))) return kFALSE; if (IsMC && FillHistosFlag==100 && c_flag && StandardCutFlag(etrk,casc,1,1,0,0)) { fHistos->FillTH1("e_c_flag","TPC_c",1); } if (IsMC && FillHistosFlag==100 && b_flag && StandardCutFlag(etrk,casc,1,1,0,0)) { fHistos->FillTH1("e_b_flag","TPC_b",1); } if ((FillHistosFlag==100) && StandardCutFlag(etrk,casc,1,1,0,0)) fHistos->FillTH1("NumOfe", fRunNumber); //kimc Int_t trkid = etrk->GetID(); Double_t px1 = etrk->Px(); Double_t py1 = etrk->Py(); Double_t pz1 = etrk->Pz(); Double_t fE1 = sqrt(px1*px1+py1*py1+pz1*pz1+0.000510998928*0.000510998928); Double_t Pt = 9999.; Double_t Pt_ss = 9999.; auto nTracks = fEvt->GetNumberOfTracks(); for (Int_t it=0; it<nTracks; it++) { AliAODTrack *trk = (AliAODTrack*) fEvt->GetTrack(it); //////trk = loose cut if (!trk) continue; if (!((AliAODTrack*)trk)->TestFilterMask(AliAODTrack::kTrkGlobalNoDCA)) continue; if (fabs(fPIDResponse->NumberOfSigmasTPC(trk,AliPID::kElectron))>5) continue; Int_t trkid2 = trk->GetID(); if (fabs(trkid)==fabs(trkid2)) continue; Double_t px2 = trk->Px(); Double_t py2 = trk->Py(); Double_t pz2 = trk->Pz(); Double_t fE2 = sqrt(px2*px2+py2*py2+pz2*pz2+0.000510998928*0.000510998928); Double_t mass = sqrt(pow(fE1+fE2,2)-pow(px1+px2,2)-pow(py1+py2,2)-pow(pz1+pz2,2)); Double_t tmp_pt = sqrt(pow(px1+px2,2)+pow(py1+py2,2)); if ((FillHistosFlag==100) && StandardCutFlag(etrk,casc,1,1,0,0) && trk->Charge()*etrk->Charge()>0) { fHistos->FillTH1("SSElectronPair",mass); } if ((FillHistosFlag==100) && StandardCutFlag(etrk,casc,1,1,0,0) && trk->Charge()*etrk->Charge()<0) { fHistos->FillTH1("DSElectronPair",mass); } if (trk->Charge()*etrk->Charge()>0 && mass<minmass_ss) { minmass_ss = mass; Pt_ss = tmp_pt; } if (trk->Charge()*etrk->Charge()<0 && mass<minmass) { minmass = mass; Pt = tmp_pt; } } if (IsMC && (FillHistosFlag==100) && c_flag && minmass>0.05 && StandardCutFlag(etrk,casc,1,1,0,0)) { fHistos->FillTH1("e_c_flag","prefilter_c",1); } if (IsMC && (FillHistosFlag==100) && b_flag && minmass>0.05 && StandardCutFlag(etrk,casc,1,1,0,0)) { fHistos->FillTH1("e_b_flag","prefilter_b",1); } if (!IsLoose && !IsSameSign) return kTRUE; ///0.05 is Conversion Mass Max. if (!IsLoose && IsSameSign) return kTRUE; if (IsLoose) return kTRUE; return kFALSE; }//FilterElectron //-------------------------------------------------------------------------- Bool_t AliAnalysisTaskSEXic0Semileptonic::FilterCascade(AliAODcascade *casc) { Bool_t isparticle = kTRUE; if (casc->ChargeXi()>0) isparticle = kFALSE; AliAODTrack *pion = (AliAODTrack*)(casc->GetDaughter(0)); //positive AliAODTrack *proton = (AliAODTrack*)(casc->GetDaughter(1)); //negative AliAODTrack *b_pion = (AliAODTrack*)(casc->GetDecayVertexXi()->GetDaughter(0)); if (!pion || !proton || !b_pion) return kFALSE; if (pion->Charge()<0 && proton->Charge()>0) { pion = (AliAODTrack*)casc->GetDaughter(1); proton = (AliAODTrack*)casc->GetDaughter(0); } Double_t pxxi = casc->MomXiX(); Double_t pyxi = casc->MomXiY(); Double_t ptxi = sqrt(pxxi*pxxi+pyxi*pyxi); if (ptxi<0.|| ptxi>9999.) return kFALSE; Double_t momegaPDG = TDatabasePDG::Instance()->GetParticle(3334)->Mass(); Double_t massOmega = casc->MassOmega(); if (TMath::Abs(massOmega-momegaPDG)<0.0) return kFALSE; /* if (pion->GetTPCClusterInfo(2,1)<fNClusterTPCMinXi) return kFALSE; if (proton->GetTPCClusterInfo(2,1)<fNClusterTPCMinXi) return kFALSE; if (b_pion->GetTPCClusterInfo(2,1)<fNClusterTPCMinXi) return kFALSE; */ if (isparticle) { if (fabs(fPIDResponse->NumberOfSigmasTPC(pion,AliPID::kProton))>4) return kFALSE; //4 if (fabs(fPIDResponse->NumberOfSigmasTPC(proton,AliPID::kPion))>4) return kFALSE; //4 if (fabs(fPIDResponse->NumberOfSigmasTPC(b_pion,AliPID::kPion))>4) return kFALSE; //4 } else { if (fabs(fPIDResponse->NumberOfSigmasTPC(proton,AliPID::kProton))>4) return kFALSE; //4 if (fabs(fPIDResponse->NumberOfSigmasTPC(pion,AliPID::kPion))>4) return kFALSE; //4 if (fabs(fPIDResponse->NumberOfSigmasTPC(b_pion,AliPID::kPion))>4) return kFALSE; //4 } Double_t mLPDG = TDatabasePDG::Instance()->GetParticle(3122)->Mass(); Double_t mxiPDG = TDatabasePDG::Instance()->GetParticle(3312)->Mass(); Double_t massLambda = casc->MassLambda(); Double_t massAntiLambda = casc->MassAntiLambda(); Double_t massXi = casc->MassXi(); if (TMath::Abs(massLambda-mLPDG)>MassTolLambda && TMath::Abs(massAntiLambda-mLPDG)>MassTolLambda) return kFALSE; Double_t lPosXi[3]; lPosXi[0] = casc->DecayVertexXiX(); lPosXi[1] = casc->DecayVertexXiY(); lPosXi[2] = casc->DecayVertexXiZ(); Double_t decayvertXi = TMath::Sqrt(lPosXi[0]*lPosXi[0]+lPosXi[1]*lPosXi[1]); if(decayvertXi>9999.) return kFALSE; Double_t lPosV0[3]; lPosV0[0] = casc->DecayVertexV0X(); lPosV0[1] = casc->DecayVertexV0Y(); lPosV0[2] = casc->DecayVertexV0Z(); Double_t decayvertV0 = TMath::Sqrt(lPosV0[0]*lPosV0[0]+lPosV0[1]*lPosV0[1]); if(decayvertV0>9999.) return kFALSE; const AliVVertex* Vtx = fEvt->GetPrimaryVertex(); Double_t primvert[3]; Vtx->GetXYZ(primvert); Double_t ptotxi = TMath::Sqrt(pow(casc->MomXiX(),2)+pow(casc->MomXiY(),2)+pow(casc->MomXiZ(),2)); Double_t properdl = casc->DecayLengthXi(primvert[0],primvert[1],primvert[2])*mxiPDG/ptotxi; if(properdl>9999.) return kFALSE; Double_t lDcaXiDaughters = casc->DcaXiDaughters(); Double_t lDcaV0Daughters = casc->DcaV0Daughters(); if(lDcaXiDaughters > 1.68) return kFALSE; if(lDcaV0Daughters > 1.68) return kFALSE; FillXiHistFromPromptNonPrompt(IsMC,casc); Double_t lDcaPosToPrimVertex = casc->DcaPosToPrimVertex(); Double_t lDcaNegToPrimVertex = casc->DcaNegToPrimVertex(); Double_t lDcaBachToPrimVertex = casc->DcaBachToPrimVertex(); Double_t lDcaV0ToPrimVertex = casc->DcaV0ToPrimVertex(); Double_t lXiCosineOfPointingAngle = casc->CosPointingAngleXi(primvert[0],primvert[1],primvert[2]); Double_t lV0CosineOfPointingAngleXi = casc->CosPointingAngle(lPosXi); if (isparticle) { if (lDcaPosToPrimVertex < DCAV0PrToPrimVertexMin) return kFALSE; if (lDcaNegToPrimVertex < DCAV0PiToPrimVertexMin) return kFALSE; } else { if (lDcaPosToPrimVertex < DCAV0PiToPrimVertexMin) return kFALSE; if (lDcaNegToPrimVertex < DCAV0PrToPrimVertexMin) return kFALSE; } if (lDcaBachToPrimVertex < DCABachToPrimVertexMin) return kFALSE; if (lDcaV0ToPrimVertex < DCAV0ToPrimVertexMin) return kFALSE; if (lXiCosineOfPointingAngle < V0CosineOfPoiningAngleXiMin) return kFALSE; if (lV0CosineOfPointingAngleXi < V0CosineOfPoiningAngleXiMin) return kFALSE; if (decayvertV0< DecayLengthV0) return kFALSE; if (decayvertXi < CascDecayLengthMin) return kFALSE; if ((fabs(massXi-mxiPDG)<0.025) && StandardCutFlag(pion,casc,0,0,1,1)) { fHistos->FillTH1("NumOfXi",fRunNumber); //kimc } if (StandardCutFlag(pion,casc,0,0,1,1)) { Double_t px = casc->MomXiX(); Double_t py = casc->MomXiY(); fHistos -> FillTH1 ("hXimass_total",casc->MassXi()); fHistos -> FillTH1("hXimass",casc->MassXi()); fHistos -> FillTH2("hXimassvsPt",casc->MassXi(),sqrt(px*px+py*py)); } if(fabs(massXi-mxiPDG)>MassTolXi) return kFALSE; return kTRUE; }//FilterCascade //-------------------------------------------------------------------------- void AliAnalysisTaskSEXic0Semileptonic::FillMCXic0(AliAODMCParticle *mcpart) { if (!(TMath::Abs(mcpart->GetPdgCode())==4132)) return; Bool_t e_flag = kFALSE; //electron Bool_t xi_flag = kFALSE; //Xi- Bool_t c_flag = kFALSE; //Xi- Bool_t b_flag = kFALSE; //Xi- for (int i=0; i<8; i++) fMCXicTreeVariable[i] = -9999.; //Reset AliAODMCParticle *MCe = 0; AliAODMCParticle *MCcasc = 0; for(Int_t idau=mcpart->GetDaughterFirst(); idau<mcpart->GetDaughterLast()+1; idau++) { if(idau<0) break; AliAODMCParticle* mcdau = (AliAODMCParticle*) fMC->GetTrack(idau); if(!mcdau) continue; if(TMath::Abs(mcdau->GetPdgCode())==11) { e_flag = kTRUE; MCe = mcdau; } if(TMath::Abs(mcdau->GetPdgCode())==3312) { xi_flag = kTRUE; MCcasc = mcdau; } } if ( e_flag&& xi_flag) fHistos->FillTH1("hMCXic0Decays","e&Xi",1); if (!e_flag&& xi_flag) fHistos->FillTH1("hMCXic0Decays","!e&Xi",1); if ( e_flag&&!xi_flag) fHistos->FillTH1("hMCXic0Decays","e&!Xi",1); if (!e_flag&&!xi_flag) fHistos->FillTH1("hMCXic0Decays","!e&!Xi",1); if(e_flag && xi_flag) { CheckOrigin(fMC,mcpart,kTRUE,c_flag,b_flag); if (b_flag) { if (MCe->Charge()>0 && MCcasc->Charge()<0 && fabs(mcpart->Y())<0.5) { fHistos->FillTH1("hXic0PtFromBottom1",mcpart->Pt()); } if (MCe->Charge()<0 && MCcasc->Charge()>0 && fabs(mcpart->Y())<0.5) { fHistos->FillTH1("hXic0PtFromBottom2",mcpart->Pt()); } fHistos->FillTH1("hNonPromptXicRap",mcpart->Y()); b_flag = kTRUE; } if(c_flag) { if (MCe->Charge()>0 && MCcasc->Charge()<0 && fabs(mcpart->Y())<0.5) { fHistos->FillTH1("hXic0PtFromCharm1",mcpart->Pt()); } if (MCe->Charge()<0 && MCcasc->Charge()>0 && fabs(mcpart->Y())<0.5) { fHistos->FillTH1("hXic0PtFromCharm2",mcpart->Pt()); } fHistos->FillTH1("hPromptXicRap",mcpart->Y()); } } fHistos->FillTH1("hMCXic0AllRap", mcpart->Pt()); if (e_flag&&xi_flag) { Double_t pxe = MCe->Px(); Double_t pye = MCe->Py(); Double_t pxv = MCcasc->Px(); Double_t pyv = MCcasc->Py(); Double_t eXi = sqrt(pow(pxe+pxv,2)+pow(pye+pyv,2)); fHistos->FillTH1("hXicRap",mcpart->Y()); fHistos->FillTH2("hXicPtRap",mcpart->Pt(),mcpart->Y()); fMCXicTreeVariable[0] = mcpart->Pt(); fMCXicTreeVariable[1] = MCe->Pt(); fMCXicTreeVariable[2] = MCcasc->Pt(); fMCXicTreeVariable[3] = mcpart->Y(); fMCXicTreeVariable[4] = MCe->Y(); fMCXicTreeVariable[5] = MCcasc->Y(); fMCXicTreeVariable[6] = c_flag; fMCXicTreeVariable[7] = b_flag; fMCXicTree->Fill(); if (fabs(mcpart->Y())<0.5) { fHistos->FillTH2("hMCXic0vsPair",mcpart->Pt(),eXi); fHistos->FillTH1("hTruePaireXi",eXi); fHistos->FillTH1("hTrueXic0",mcpart->Pt()); fHistos->FillTH1("hTrueXic0_oldbin",mcpart->Pt()); fHistos->FillTH1("hElectronFromXic0",MCe->Pt()); fHistos->FillTH1("hCascadeFromXic0",MCcasc->Pt()); } if (fabs(mcpart->Y())<0.8) { fHistos->FillTH1("hTrueXic0_rap8",mcpart->Pt()); fHistos->FillTH1("hTrueXic0_oldbin_rap8",mcpart->Pt()); } } return; }//FillMCXic0 //--------------------------------------------------------------------------- Bool_t AliAnalysisTaskSEXic0Semileptonic::FillMCXib(AliAODMCParticle *mcpart) { if ((TMath::Abs(mcpart->GetPdgCode())==5132) || (TMath::Abs(mcpart->GetPdgCode())==5232)) ///Xib- Xib0 { Bool_t e_flag = kFALSE; Bool_t xic_flag = kFALSE; Bool_t xi_flag = kFALSE; AliAODMCParticle *MCe = 0; AliAODMCParticle *MCXic = 0; //Xic0 Xic+ AliAODMCParticle *MCXi = 0; //Xi- for (Int_t idau=mcpart->GetDaughterFirst(); idau<mcpart->GetDaughterLast()+1; idau++) { if (idau<0) break; AliAODMCParticle *mcdau = (AliAODMCParticle*) fMC->GetTrack(idau); if (!mcdau) continue; if(TMath::Abs(mcdau->GetPdgCode())==4132 || TMath::Abs(mcdau->GetPdgCode())==4232 ) { xic_flag = kTRUE; MCXic = mcdau; } if(TMath::Abs(mcdau->GetPdgCode())==11) { e_flag = kTRUE; MCe = mcdau; } } if (xic_flag) { for(Int_t idau=MCXic->GetDaughterFirst(); idau<MCXic->GetDaughterLast()+1; idau++) { if (idau<0) break; AliAODMCParticle *mcdau = (AliAODMCParticle*) fMC->GetTrack(idau); if (!mcdau) continue; if (TMath::Abs(mcdau->GetPdgCode())==3312) { xi_flag = kTRUE; MCXi = mcdau; } } } if (e_flag && xi_flag) { Double_t pxe = MCe->Px(); Double_t pye = MCe->Py(); Double_t pxv = MCXi->Px(); Double_t pyv = MCXi->Py(); Double_t eXi = sqrt(pow(pxe+pxv,2)+pow(pye+pyv,2)); fHistos->FillTH2("XibvseXiRPMGen",mcpart->Pt(), eXi); fHistos->FillTH1("XibGen",mcpart->Pt()); if (fabs(mcpart->Y())<0.5) fHistos->FillTH1("XibGen05",mcpart->Pt()); fHistos->FillTH1("eXiFromXibGen",eXi); } return kTRUE; } return kFALSE; }//FillMCXib //------------------------------------------------------------- void AliAnalysisTaskSEXic0Semileptonic::FillBottomContribution( AliAODMCParticle *mcpart, AliAODcascade *casc, AliAODTrack *trk) { Double_t pxe = trk->Px(); Double_t pye = trk->Py(); Double_t pxv = casc->MomXiX(); Double_t pyv = casc->MomXiY(); Double_t eXi = sqrt(pow(pxe+pxv,2)+pow(pye+pyv,2)); fHistos->FillTH2("XibvseXiRPM",mcpart->Pt(), eXi); fHistos->FillTH1("Xib",mcpart->Pt()); fHistos->FillTH1("eXiFromXib",eXi); return; } //------------------------------------------------------------------------------------------ void AliAnalysisTaskSEXic0Semileptonic::FillPairEleXi(AliAODcascade *casc, AliAODTrack *trk) { for (Int_t i=0; i<38; i++) fPaireXiTreeVariable[i] = -9999.; for (Int_t i=0; i<12; i++) fMCTreeVariable[i] = -9999.; Double_t mcpxe = -9999.; Double_t mcpye = -9999.; Double_t mcpxv = -9999.; Double_t mcpyv = -9999.; Double_t mcPt = -9999.; Bool_t c_flag = kFALSE; Bool_t b_flag = kFALSE; Double_t mass; Double_t mass_ss; Double_t pxe = trk->Px(); Double_t pye = trk->Py(); Double_t pze = trk->Pz(); Double_t mome = sqrt(pxe*pxe+pye*pye+pze*pze); Double_t Ee = sqrt(mome*mome+0.000510998928*0.000510998928); Double_t pxv = casc->MomXiX(); Double_t pyv = casc->MomXiY(); Double_t pzv = casc->MomXiZ(); Double_t momv = sqrt(pxv*pxv+pyv*pyv+pzv*pzv); Double_t Ev = sqrt(momv*momv+1.32171*1.32171); Double_t cosoa = (pxe*pxv+pye*pyv+pze*pzv)/mome/momv; Double_t echarge = trk->Charge(); Double_t vcharge = casc->ChargeXi(); Double_t In_Mass = sqrt(pow(Ee+Ev,2)-pow(pxe+pxv,2)-pow(pye+pyv,2)-pow(pze+pzv,2)); Double_t Pt = sqrt(pow(pxe+pxv,2)+pow(pye+pyv,2)); AliAODTrack *pion = (AliAODTrack*) casc->GetDaughter(0); AliAODTrack *proton = (AliAODTrack*) casc->GetDaughter(1); AliAODTrack *b_pion = (AliAODTrack*) casc->GetDecayVertexXi()->GetDaughter(0); Bool_t isparticle = kTRUE; if (vcharge>0) isparticle = kFALSE; if (pion->Charge()<0 && proton->Charge()>0) { pion = (AliAODTrack*) casc->GetDaughter(1); proton = (AliAODTrack*) casc->GetDaughter(0); } Double_t lDcaPosToPrimVertex = casc->DcaPosToPrimVertex(); Double_t lDcaNegToPrimVertex = casc->DcaNegToPrimVertex(); Double_t lPosXi[3]; lPosXi[0] = casc->DecayVertexXiX(); lPosXi[1] = casc->DecayVertexXiY(); lPosXi[2] = casc->DecayVertexXiZ(); Double_t decayvertXi = TMath::Sqrt(lPosXi[0]*lPosXi[0]+lPosXi[1]*lPosXi[1]); Double_t lPosV0[3]; lPosV0[0] = casc->DecayVertexV0X(); lPosV0[1] = casc->DecayVertexV0Y(); lPosV0[2] = casc->DecayVertexV0Z(); Double_t decayvertV0 = TMath::Sqrt(lPosV0[0]*lPosV0[0]+lPosV0[1]*lPosV0[1]); Double_t V0CosineOfPointingAngleXi = casc->CosPointingAngle(lPosXi); const AliVVertex* Vtx = fEvt->GetPrimaryVertex(); Double_t primvert[3]; Vtx->GetXYZ(primvert); Double_t XiCosineOfPointingAngle = casc->CosPointingAngleXi(primvert[0],primvert[1],primvert[2]); if (FilterElectron(trk,mass,mass_ss,0,1,1)) { fPaireXiTreeVariable[ 0] = pxe*pxe+pye*pye; fPaireXiTreeVariable[ 1] = echarge; fPaireXiTreeVariable[ 2] = fPIDResponse->NumberOfSigmasTOF(trk,AliPID::kElectron); fPaireXiTreeVariable[ 3] = fPIDResponse->NumberOfSigmasTPC(trk,AliPID::kElectron); fPaireXiTreeVariable[ 4] = trk->GetTPCsignalN(); fPaireXiTreeVariable[ 5] = trk->GetITSNcls(); fPaireXiTreeVariable[ 6] = trk->GetTPCNCrossedRows(); fPaireXiTreeVariable[ 7] = trk->GetTPCNclsF(); fPaireXiTreeVariable[ 8] = trk->Phi(); fPaireXiTreeVariable[ 9] = trk->Y(); fPaireXiTreeVariable[10] = mass; fPaireXiTreeVariable[11] = mass_ss; fPaireXiTreeVariable[12] = pxv*pxv+pyv*pyv; fPaireXiTreeVariable[13] = vcharge; fPaireXiTreeVariable[14] = casc->MassXi(); fPaireXiTreeVariable[15] = casc->MassLambda(); fPaireXiTreeVariable[16] = casc->MassAntiLambda(); fPaireXiTreeVariable[17] = decayvertV0; fPaireXiTreeVariable[18] = decayvertXi; fPaireXiTreeVariable[19] = casc->DcaBachToPrimVertex(); if (isparticle) { fPaireXiTreeVariable[21] = lDcaPosToPrimVertex; fPaireXiTreeVariable[20] = lDcaNegToPrimVertex; } else { fPaireXiTreeVariable[20] = lDcaPosToPrimVertex; fPaireXiTreeVariable[21] = lDcaNegToPrimVertex; } fPaireXiTreeVariable[22] = V0CosineOfPointingAngleXi; fPaireXiTreeVariable[23] = XiCosineOfPointingAngle; fPaireXiTreeVariable[24] = casc->DcaV0ToPrimVertex(); fPaireXiTreeVariable[25] = casc->RapXi(); fPaireXiTreeVariable[26] = pion->GetTPCNCrossedRows(); fPaireXiTreeVariable[27] = pion->GetTPCNclsF(); fPaireXiTreeVariable[28] = proton->GetTPCNCrossedRows(); fPaireXiTreeVariable[29] = proton->GetTPCNclsF(); fPaireXiTreeVariable[30] = b_pion->GetTPCNCrossedRows(); fPaireXiTreeVariable[31] = b_pion->GetTPCNclsF(); fPaireXiTreeVariable[32] = pion->Pt(); fPaireXiTreeVariable[33] = proton->Pt(); fPaireXiTreeVariable[34] = b_pion->Pt(); fPaireXiTreeVariable[35] = cosoa; fPaireXiTreeVariable[36] = In_Mass; fPaireXiTreeVariable[37] = Pt; if (!IsMC) { fPaireXiTree->Fill(); fNeXiPair++; //kimc fEventTree->Fill(); //kimc } if (IsMC) { Int_t MCXiblab = MatchToMCXib(casc, trk); if (MCXiblab>-1) { AliAODMCParticle* mcXib = (AliAODMCParticle*) fMC->GetTrack(MCXiblab); /*if (StandardCutFlag(trk,casc,1,1,1,1))*/ FillBottomContribution(mcXib,casc,trk); //kimc: newly added, updated in Aug. 19 fMCTreeVariable[9] = mcXib->Pt(); fMCTreeVariable[10] = Pt; fMCTreeVariable[11] = mcXib->GetCalcMass(); } Int_t MCXic0lab = MatchToMCXic0(casc, trk); if (MCXic0lab>-1) { AliAODMCParticle* mcXic0 = (AliAODMCParticle*) fMC->GetTrack(MCXic0lab); Double_t mcXic0_Pt = mcXic0->Pt(); Int_t elab = MatchToMCele(trk); Int_t Xilab = MatchToMCXi(casc); if(elab>0 && Xilab>0) { CheckOrigin(fMC,mcXic0,kTRUE,c_flag,b_flag); AliAODMCParticle* mcXi = (AliAODMCParticle*) fMC->GetTrack(Xilab); AliAODMCParticle* mce = (AliAODMCParticle*) fMC->GetTrack(elab); Double_t eCharge = mce->Charge(); Double_t XiCharge = mcXi->Charge(); mcpxe = mce->Px(); mcpye = mce->Py(); mcpxv = mcXi->Px(); mcpyv = mcXi->Py(); mcPt = sqrt(pow(mcpxe+mcpxv,2)+pow(mcpye+mcpyv,2)); Double_t eXi = sqrt(pow(pxe+pxv,2)+pow(pye+pyv,2)); fMCTreeVariable[ 0] = mcpxe*mcpxe+mcpye*mcpye; fMCTreeVariable[ 1] = eCharge; fMCTreeVariable[ 2] = mcpxv*mcpxv+mcpyv*mcpyv; fMCTreeVariable[ 3] = XiCharge; fMCTreeVariable[ 4] = mcXic0->Pt(); fMCTreeVariable[ 5] = mcPt; fMCTreeVariable[ 6] = mcXic0->M(); fMCTreeVariable[ 7] = c_flag; fMCTreeVariable[ 8] = b_flag; fHistos->FillTH2("hXic0vseXiRPM",mcXic0_Pt,eXi); fHistos->FillTH1("hGenXic0Pt",mcXic0_Pt); //MC Pt of Xic0 fHistos->FillTH1("hRecoPairPt",eXi); //Reco Pt of eXi if(eCharge>0 && XiCharge<0) fHistos->FillTH1("hGenXic0Pt1",mcXic0_Pt); if(eCharge<0 && XiCharge>0) fHistos->FillTH1("hGenXic0Pt2",mcXic0_Pt); if(b_flag) fHistos->FillTH1("hGenXic0PtFromXib",mcXic0_Pt); if(c_flag) fHistos->FillTH1("hGenXic0PtFromXic",mcXic0_Pt); }//e_flag && Xi_flag }//Xic0 fPaireXiTree->Fill(); fMCTree->Fill(); fNeXiPair++; //kimc fEventTree->Fill(); //kimc }//IsMC if (cosoa>0 && echarge*vcharge<0 && StandardCutFlag(trk,casc,1,1,1,1)) { fHistos->FillTH1("hEleXiMassRS",In_Mass); if(In_Mass<=2.5) fHistos->FillTH1("hEleXiPtRS",Pt); } if (cosoa>0 && echarge*vcharge>0 && StandardCutFlag(trk,casc,1,1,1,1)) { fHistos->FillTH1("hEleXiMassWS",In_Mass); if(In_Mass<=2.5) fHistos->FillTH1("hEleXiPtWS",Pt); } }// FilterElectron if (FilterElectron(trk,mass,mass_ss,1,0,1) && StandardCutFlag(trk,casc,1,1,1,1)) //same sign prefilter { if(echarge*vcharge<0 && In_Mass<=2.5 && cosoa>=0) fHistos->FillTH1("hEleXiPtRS_SameSign",Pt); if(echarge*vcharge>0 && In_Mass<=2.5 && cosoa>=0) fHistos->FillTH1("hEleXiPtWS_SameSign",Pt); } if (FilterElectron(trk,mass,mass_ss,0,1,1) && StandardCutFlag(trk,casc,1,1,1,1)) //no prefilter { if(cosoa>0 && echarge*vcharge<0 && In_Mass<=2.5) { fHistos->FillTH1("hLooseEleXiPtRS",Pt); fHistos->FillTH1("hLooseEleXiPtWS",Pt); } } return; }//FillPairEleXi //----------------------------------------------------------------------------------------------------- void AliAnalysisTaskSEXic0Semileptonic::FillXiHistFromPromptNonPrompt(Bool_t IsMC, AliAODcascade *casc) { if (!IsMC) return; Bool_t isparticle = kTRUE; if (casc->ChargeXi()>0) isparticle = kFALSE; AliAODTrack *pion = (AliAODTrack*)(casc->GetDaughter(0)); //positive AliAODTrack *proton = (AliAODTrack*)(casc->GetDaughter(1)); //negative AliAODTrack *b_pion = (AliAODTrack*)(casc->GetDecayVertexXi()->GetDaughter(0)); if (pion->Charge()<0 && proton->Charge()>0) { pion = (AliAODTrack*)casc->GetDaughter(1); proton = (AliAODTrack*)casc->GetDaughter(0); } Double_t lPosXi[3]; lPosXi[0] = casc->DecayVertexXiX(); lPosXi[1] = casc->DecayVertexXiY(); lPosXi[2] = casc->DecayVertexXiZ(); Double_t decayvertXi = TMath::Sqrt(lPosXi[0]*lPosXi[0]+lPosXi[1]*lPosXi[1]); Double_t lPosV0[3]; lPosV0[0] = casc->DecayVertexV0X(); lPosV0[1] = casc->DecayVertexV0Y(); lPosV0[2] = casc->DecayVertexV0Z(); Double_t decayvertV0 = TMath::Sqrt(lPosV0[0]*lPosV0[0]+lPosV0[1]*lPosV0[1]); const AliVVertex* Vtx = fEvt->GetPrimaryVertex(); Double_t primvert[3]; Vtx->GetXYZ(primvert); Double_t lDcaXiDaughters = casc->DcaXiDaughters(); Double_t lDcaV0Daughters = casc->DcaV0Daughters(); Bool_t Xib_flag = kFALSE; Bool_t Xic_flag = kFALSE; Bool_t Total_Xic0_flag = kFALSE; Double_t Xic0_label = MatchToMCXic0(casc); if (Xic0_label==-1) return; AliAODMCParticle* mcXic0 = (AliAODMCParticle*) fMC->GetTrack(Xic0_label); Total_Xic0_flag = kTRUE; Bool_t e_flag = kFALSE; //electron Bool_t xi_flag = kFALSE; //Xi- for (Int_t idau=mcXic0->GetDaughterFirst(); idau<mcXic0->GetDaughterLast()+1; idau++) { if (idau<0) break; AliAODMCParticle* mcdau = (AliAODMCParticle*) fMC->GetTrack(idau); if (!mcdau) continue; if (TMath::Abs(mcdau->GetPdgCode())==11) e_flag = kTRUE; if (TMath::Abs(mcdau->GetPdgCode())==3312) xi_flag = kTRUE; } if (e_flag && xi_flag) CheckOrigin(fMC,mcXic0,kTRUE,Xic_flag,Xib_flag); Double_t lDcaPosToPrimVertex = casc->DcaPosToPrimVertex(); if (Total_Xic0_flag) fHistos->FillTH1("hDCAV0PrToPrimVertex",lDcaPosToPrimVertex); if (Xib_flag) fHistos->FillTH1("hDCAV0PrToPrimVertex_b",lDcaPosToPrimVertex); if (Xic_flag) fHistos->FillTH1("hDCAV0PrToPrimVertex_c",lDcaPosToPrimVertex); Double_t lDcaNegToPrimVertex = casc->DcaNegToPrimVertex(); if (Total_Xic0_flag) fHistos->FillTH1("hDCAV0PiToPrimVertex",lDcaNegToPrimVertex); if (Xib_flag) fHistos->FillTH1("hDCAV0PiToPrimVertex_b",lDcaNegToPrimVertex); if (Xic_flag) fHistos->FillTH1("hDCAV0PiToPrimVertex_c",lDcaNegToPrimVertex); Double_t lDcaBachToPrimVertex = casc->DcaBachToPrimVertex(); if (Total_Xic0_flag) fHistos->FillTH1("hDCABachToPrimVertex",lDcaBachToPrimVertex); if (Xib_flag) fHistos->FillTH1("hDCABachToPrimVertex_b",lDcaBachToPrimVertex); if (Xic_flag) fHistos->FillTH1("hDCABachToPrimVertex_c",lDcaBachToPrimVertex); Double_t lDcaV0ToPrimVertex = casc->DcaV0ToPrimVertex(); if (Total_Xic0_flag) fHistos->FillTH1("hDCAV0ToPrimVertex",lDcaV0ToPrimVertex); if (Xib_flag) fHistos->FillTH1("hDCAV0ToPrimVertex_b",lDcaV0ToPrimVertex); if (Xic_flag) fHistos->FillTH1("hDCAV0ToPrimVertex_c",lDcaV0ToPrimVertex); Double_t lXiCosineOfPointingAngle = casc->CosPointingAngleXi(primvert[0],primvert[1],primvert[2]); Double_t lV0CosineOfPointingAngleXi = casc->CosPointingAngle(lPosXi); if (Total_Xic0_flag) fHistos->FillTH1("hV0CosineOfPoiningAngleXi",lXiCosineOfPointingAngle); if (Xib_flag) fHistos->FillTH1("hV0CosineOfPoiningAngleXi_b",lXiCosineOfPointingAngle); if (Xic_flag) fHistos->FillTH1("hV0CosineOfPoiningAngleXi_c",lXiCosineOfPointingAngle); if (Total_Xic0_flag) fHistos->FillTH1("hV0CosineOfPoiningAngleV0Xi",lV0CosineOfPointingAngleXi); if (Xib_flag) fHistos->FillTH1("hV0CosineOfPoiningAngleV0Xi_b",lV0CosineOfPointingAngleXi); if (Xic_flag) fHistos->FillTH1("hV0CosineOfPoiningAngleV0Xi_c",lV0CosineOfPointingAngleXi); if (Total_Xic0_flag) fHistos->FillTH1("hCascDecayLength",decayvertXi); if (Xib_flag) fHistos->FillTH1("hCascDecayLength_b",decayvertXi); if (Xic_flag) fHistos->FillTH1("hCascDecayLength_c",decayvertXi); if (Total_Xic0_flag) fHistos->FillTH1("hDecayLengthV0",decayvertV0); if (Xib_flag) fHistos->FillTH1("hDecayLengthV0_b",decayvertV0); if (Xic_flag) fHistos->FillTH1("hDecayLengthV0_c",decayvertV0); if (Xib_flag) fHistos->FillTH1("B_flag","all",1); if (Xic_flag) fHistos->FillTH1("C_flag","all",1); if (Xib_flag) fHistos->FillTH1("Bcut_flag","all",1); if (Xic_flag) fHistos->FillTH1("Ccut_flag","all",1); if (isparticle) { if (lDcaPosToPrimVertex > 0.073) //kicm: 0.073? { if(Xib_flag) fHistos->FillTH1("B_flag","DCAV0Pr_b",1); if(Xic_flag) fHistos->FillTH1("C_flag","DCAV0Pr_c",1); if(Xib_flag) fHistos->FillTH1("Bcut_flag","DCAV0Pr_b",1); if(Xic_flag) fHistos->FillTH1("Ccut_flag","DCAV0Pr_c",1); } if (lDcaNegToPrimVertex > 0.073) { if(Xib_flag) fHistos->FillTH1("B_flag","DCAV0Pi_b",1); if(Xic_flag) fHistos->FillTH1("C_flag","DCAV0Pi_c",1); if(Xib_flag) fHistos->FillTH1("Bcut_flag","DCAV0Pi_b",1); if(Xic_flag) fHistos->FillTH1("Ccut_flag","DCAV0Pi_c",1); } } else { if (lDcaPosToPrimVertex > 0.073) { if(Xib_flag) fHistos->FillTH1("B_flag","DCAV0Pi_b",1); if(Xic_flag) fHistos->FillTH1("C_flag","DCAV0Pi_c",1); if(Xib_flag) fHistos->FillTH1("Bcut_flag","DCAV0Pi_b",1); if(Xic_flag) fHistos->FillTH1("Ccut_flag","DCAV0Pi_c",1); } if (lDcaNegToPrimVertex > 0.073) { if(Xib_flag) fHistos->FillTH1("B_flag","DCAV0Pr_b",1); if(Xic_flag) fHistos->FillTH1("C_flag","DCAV0Pr_c",1); if(Xib_flag) fHistos->FillTH1("Bcut_flag","DCAV0Pr_b",1); if(Xic_flag) fHistos->FillTH1("Ccut_flag","DCAV0Pr_c",1); } } if (lDcaBachToPrimVertex > 0.0204) { if(Xib_flag) fHistos->FillTH1("B_flag","DCABach_b",1); if(Xic_flag) fHistos->FillTH1("C_flag","DCABach_c",1); if(Xib_flag) fHistos->FillTH1("Bcut_flag","DCABach_b",1); if(Xic_flag) fHistos->FillTH1("Ccut_flag","DCABach_c",1); } if (lDcaV0ToPrimVertex > 0.03) { if(Xib_flag) fHistos->FillTH1("B_flag","DCAV0_b",1); if(Xic_flag) fHistos->FillTH1("C_flag","DCAV0_c",1); if(Xib_flag) fHistos->FillTH1("Bcut_flag","DCAV0_b",1); if(Xic_flag) fHistos->FillTH1("Ccut_flag","DCAV0_c",1); } if (lXiCosineOfPointingAngle > 0.983) { if(Xib_flag) fHistos->FillTH1("B_flag","COS1_b",1); if(Xic_flag) fHistos->FillTH1("C_flag","COS1_c",1); if(Xib_flag) fHistos->FillTH1("Bcut_flag","COS1_b",1); if(Xic_flag) fHistos->FillTH1("Ccut_flag","COS1_c",1); } if (lV0CosineOfPointingAngleXi > 0.983) { if(Xib_flag) fHistos->FillTH1("B_flag","COS2_b",1); if(Xic_flag) fHistos->FillTH1("C_flag","COS2_c",1); if(Xib_flag) fHistos->FillTH1("Bcut_flag","COS2_b",1); if(Xic_flag) fHistos->FillTH1("Ccut_flag","COS2_c",1); } if (decayvertXi > 0.38) { if(Xib_flag) fHistos->FillTH1("B_flag","DLXi_b",1); if(Xic_flag) fHistos->FillTH1("C_flag","DLXi_c",1); if(Xib_flag) fHistos->FillTH1("Bcut_flag","DLXi_b",1); if(Xic_flag) fHistos->FillTH1("Ccut_flag","DLXi_c",1); } if (decayvertV0 > 2.67) { if(Xib_flag) fHistos->FillTH1("B_flag","DLV0_b",1); if(Xic_flag) fHistos->FillTH1("C_flag","DLV0_c",1); if(Xib_flag) fHistos->FillTH1("Bcut_flag","DLV0_b",1); if(Xic_flag) fHistos->FillTH1("Ccut_flag","DLV0_c",1); } return; }//FillXiHistFromPromptNonPrompt //------------------------------------------------------------------------------------------ Int_t AliAnalysisTaskSEXic0Semileptonic::MatchToMCXib(AliAODcascade *casc, AliAODTrack *trk) { Int_t Xi_label = MatchToMCXi(casc); if (!Xi_label) return -1; AliAODMCParticle* mcXi = (AliAODMCParticle*) fMC->GetTrack(Xi_label); Int_t e_label = MatchToMCele(trk); if (!e_label) return -1; AliAODMCParticle* mc_e = (AliAODMCParticle*) fMC->GetTrack(e_label); Int_t mother_Xi_label = mcXi->GetMother(); if (mother_Xi_label<0) return -1; Int_t mother_e_label = mc_e->GetMother(); if (mother_e_label<0) return -1; AliAODMCParticle* mcXic = (AliAODMCParticle*) fMC->GetTrack(mother_Xi_label); if ((TMath::Abs(mcXic->GetPdgCode())==4132) == (TMath::Abs(mcXic->GetPdgCode())==4232)) return -1; Int_t mother_Xic_label = mcXic->GetMother(); if (mother_Xic_label<0) return -1; AliAODMCParticle* mcXib_Xi = (AliAODMCParticle*) fMC->GetTrack(mother_Xic_label); if ((TMath::Abs(mcXib_Xi->GetPdgCode())==5132) == (TMath::Abs(mcXib_Xi->GetPdgCode())==5232)) return -1; AliAODMCParticle* mcXib_e = (AliAODMCParticle*) fMC->GetTrack(mother_e_label); if ((TMath::Abs(mcXib_e->GetPdgCode())==5132) || (TMath::Abs(mcXib_e->GetPdgCode())==5232)) return mother_e_label; return -1; }//MatchToMCXib //------------------------------------------------------------------------------------------- Int_t AliAnalysisTaskSEXic0Semileptonic::MatchToMCXic0(AliAODcascade *casc, AliAODTrack *trk) { Int_t Xi_label = MatchToMCXi(casc); if(!Xi_label) return -1; AliAODMCParticle* mcXi = (AliAODMCParticle*) fMC->GetTrack(Xi_label); Int_t e_label = MatchToMCele(trk); if(!e_label) return -1; AliAODMCParticle* mc_e = (AliAODMCParticle*) fMC->GetTrack(e_label); Int_t mother_Xi_label = mcXi->GetMother(); //Xic0 if(mother_Xi_label<0) return -1; Int_t mother_e_label = mc_e->GetMother(); //Xic0 if(!(mother_e_label==mother_Xi_label)) return -1; AliAODMCParticle* mcXic0 = (AliAODMCParticle*) fMC->GetTrack(mother_Xi_label); if(TMath::Abs(mcXic0->GetPdgCode())==4132) return mother_Xi_label; return -1; }//MatchToMCXic0 //------------------------------------------------------------------------- Int_t AliAnalysisTaskSEXic0Semileptonic::MatchToMCXic0(AliAODcascade *casc) { Int_t Xi_label = MatchToMCXi(casc); if (!Xi_label) return -1; AliAODMCParticle* mcXi = (AliAODMCParticle*) fMC->GetTrack(Xi_label); Int_t mother_Xi_label = mcXi->GetMother(); //Xic0 if (mother_Xi_label<0) return -1; AliAODMCParticle* mcXic0 = (AliAODMCParticle*) fMC->GetTrack(mother_Xi_label); if (TMath::Abs(mcXic0->GetPdgCode())==4132) return mother_Xi_label; return -1; } //----------------------------------------------------------------------- Int_t AliAnalysisTaskSEXic0Semileptonic::MatchToMCXi(AliAODcascade* casc) { AliAODTrack *pion = (AliAODTrack*) casc->GetDaughter(0); if (!pion) return 0; AliAODTrack *proton = (AliAODTrack*) casc->GetDaughter(1); if (!proton) return 0; AliAODTrack *b_pion = (AliAODTrack*) casc->GetDecayVertexXi()->GetDaughter(0); if (!b_pion) return 0; Int_t b_pion_label = TMath::Abs(b_pion->GetLabel()); if (b_pion_label<0) return 0; Int_t pion_label = TMath::Abs(pion->GetLabel()); if (pion_label<0) return 0; Int_t proton_label = TMath::Abs(proton->GetLabel()); if (proton_label<0) return 0; AliAODMCParticle* mc_b_pion = (AliAODMCParticle*) fMC->GetTrack(b_pion_label); AliAODMCParticle* mc_pion = (AliAODMCParticle*) fMC->GetTrack(pion_label); AliAODMCParticle* mc_proton = (AliAODMCParticle*) fMC->GetTrack(proton_label); if (TMath::Abs(mc_b_pion->GetPdgCode())!=211) return 0; if ((TMath::Abs(mc_proton->GetPdgCode())==211) == (TMath::Abs(mc_proton->GetPdgCode())==2212)) return 0; if ((TMath::Abs(mc_pion->GetPdgCode())==211) == (TMath::Abs(mc_pion->GetPdgCode())==2212)) return 0; Int_t mother_b_pion_label = mc_b_pion->GetMother(); Int_t mother_pion_label = mc_pion->GetMother(); Int_t mother_proton_label = mc_proton->GetMother(); if (mother_pion_label!=mother_proton_label) return 0; if (mother_b_pion_label==mother_pion_label) return 0; if (mother_b_pion_label<0) return 0; if (mother_proton_label<0) return 0; AliAODMCParticle* mcXi = (AliAODMCParticle*) fMC->GetTrack(mother_b_pion_label); AliAODMCParticle* mother_proton = (AliAODMCParticle*) fMC->GetTrack(mother_proton_label); if (TMath::Abs(mcXi->GetPdgCode())!=3312) return 0; Int_t mother_lambda_label = mother_proton->GetMother(); if (mother_lambda_label<0) return 0; if (mother_lambda_label != mother_b_pion_label) return 0; return mother_b_pion_label; }//MatchToMCXi //--------------------------------------------------------------------- Int_t AliAnalysisTaskSEXic0Semileptonic::MatchToMCele(AliAODTrack* trk) { Int_t e_label = trk->GetLabel(); if(e_label<0) return 0; AliAODMCParticle* mc_e = (AliAODMCParticle*) fMC->GetTrack(e_label); //if(!(TMath::Abs(mc_e->GetPdgCode())==11)) return 0; return e_label; } //-------------------------------------------------------- Bool_t AliAnalysisTaskSEXic0Semileptonic::StandardCutFlag( AliAODTrack *track, AliAODcascade *casc, Bool_t e_reco, Bool_t e_pid, Bool_t Xi_reco, Bool_t Xi_pid ) { //Electron //---------------------------------------------------------- if (e_reco) { AliESDtrackCuts* miniTrackCuts = new AliESDtrackCuts(); //miniTrackCuts->SetMinNClustersTPC(e_cut[0]); //tpc cluster miniTrackCuts->SetMinNClustersITS(3); //its cluster AliAODTrack* aodt = dynamic_cast<AliAODTrack*>(track); AliESDtrack copyTrack(aodt); copyTrack.SetTPCClusterMap(aodt->GetTPCClusterMap()); copyTrack.SetTPCSharedMap(aodt->GetTPCSharedMap()); copyTrack.SetTPCPointsF(aodt->GetTPCNclsF()); if (!(miniTrackCuts->IsSelected(&copyTrack))) return kFALSE; if (track->GetTPCsignalN()<50) return kFALSE; // number of TPC PID cluster if (!(track->GetTPCNclsF()==0) && track->GetTPCNCrossedRows()/track->GetTPCNclsF()<=0.8) return kFALSE; if (track->GetTPCNCrossedRows()<=70) return kFALSE; delete miniTrackCuts; } Double_t e_pt = track->Pt(); //kimc: ?? if (e_pid) //Stand { Double_t cut_tpc = -3.9+(1.17*e_pt)-(0.094*e_pt*e_pt); if (fPIDResponse->NumberOfSigmasTPC(track,AliPID::kElectron)<cut_tpc) return kFALSE; if (e_pt>5 && fPIDResponse->NumberOfSigmasTPC(track,AliPID::kElectron)<(-3.9+(1.17*5)-(0.094*5*5))) { return kFALSE; } } //Cascade //---------------------------------------------------------- if (Xi_reco) { if (!casc) return kFALSE; if (!(casc->GetSecondaryVtx())) return kFALSE; if (!(casc->GetDecayVertexXi())) return kFALSE; AliAODTrack *pion = (AliAODTrack*)(casc->GetDaughter(0)); //positive AliAODTrack *proton = (AliAODTrack*)(casc->GetDaughter(1)); //negative AliAODTrack *b_pion = (AliAODTrack*)(casc->GetDecayVertexXi()->GetDaughter(0)); if (!pion || !proton || !b_pion) return kFALSE; if (pion->GetTPCNCrossedRows()<=70) return kFALSE; if (proton->GetTPCNCrossedRows()<=70) return kFALSE; if (b_pion->GetTPCNCrossedRows()<=70) return kFALSE; if (!(pion->GetTPCNclsF()==0) && pion->GetTPCNCrossedRows()/pion->GetTPCNclsF()<=0.77) return kFALSE; if (!(proton->GetTPCNclsF()==0) && proton->GetTPCNCrossedRows()/proton->GetTPCNclsF()<=0.77) return kFALSE; if (!(b_pion->GetTPCNclsF()==0) && b_pion->GetTPCNCrossedRows()/b_pion->GetTPCNclsF()<=0.77) return kFALSE; } if (Xi_pid) { if (!casc) return kFALSE; if (!(casc->GetSecondaryVtx())) return kFALSE; if (!(casc->GetDecayVertexXi())) return kFALSE; AliAODTrack *pion = (AliAODTrack*)(casc->GetDaughter(0)); //positive AliAODTrack *proton = (AliAODTrack*)(casc->GetDaughter(1)); //negative AliAODTrack *b_pion = (AliAODTrack*)(casc->GetDecayVertexXi()->GetDaughter(0)); if (!pion || !proton || !b_pion) return kFALSE; if (casc->DcaPosToPrimVertex() <= 0.073) return kFALSE; if (casc->DcaNegToPrimVertex() <= 0.073) return kFALSE; if (casc->DcaBachToPrimVertex() <= 0.0204) return kFALSE; if (casc->DcaV0ToPrimVertex() <= 0.03) return kFALSE; const AliVVertex* Vtx = fEvt->GetPrimaryVertex(); Double_t primvert[3]; Vtx->GetXYZ(primvert); Double_t lPosXi[3]; lPosXi[0] = casc->DecayVertexXiX(); lPosXi[1] = casc->DecayVertexXiY(); lPosXi[2] = casc->DecayVertexXiZ(); Double_t decayvertXi = TMath::Sqrt(lPosXi[0]*lPosXi[0]+lPosXi[1]*lPosXi[1]); if (decayvertXi <=0.38) return kFALSE; Double_t lPosV0[3]; lPosV0[0] = casc->DecayVertexV0X(); lPosV0[1] = casc->DecayVertexV0Y(); lPosV0[2] = casc->DecayVertexV0Z(); Double_t decayvertV0 = TMath::Sqrt(lPosV0[0]*lPosV0[0]+lPosV0[1]*lPosV0[1]); if (decayvertV0 <= 2.67) return kFALSE; Double_t lV0CosineOfPointingAngleXi = casc->CosPointingAngle(lPosXi); Double_t lXiCosineOfPointingAngle = casc->CosPointingAngleXi(primvert[0],primvert[1],primvert[2]); if (lXiCosineOfPointingAngle <= 0.983) return kFALSE; if (lV0CosineOfPointingAngleXi <= 0.983) return kFALSE; } return kTRUE; }//MatchToMCele void AliAnalysisTaskSEXic0Semileptonic::FinishTaskOutput() {} //fOutput->Write(); void AliAnalysisTaskSEXic0Semileptonic::Terminate(Option_t*) {} //================================================================================================= //------------------------------------------------------------------- //-------------------- Define Tree Valuable ------------------------- //------------------------------------------------------------------- //------------------------------------------------------- void AliAnalysisTaskSEXic0Semileptonic::DefineMCXicTree() { fMCXicTree = new TTree("MCXicTree","MCXicTree"); vector<TString> fTreeVariableName = { "Xic0_pT","e_pT","Xi_pT","Xic0_rap","e_rap","Xi_rap","c_flag","b_flag" }; fMCXicTreeVariable = new Float_t [fTreeVariableName.size()]; for (Int_t ivar=0; ivar<(Float_t)fTreeVariableName.size(); ivar++) { fMCXicTree->Branch(fTreeVariableName[ivar].Data(), &fMCXicTreeVariable[ivar], Form("%s/F",fTreeVariableName[ivar].Data()) ); } return; }//DefineMCCutTree //--------------------------------------------------------- void AliAnalysisTaskSEXic0Semileptonic::DefinePaireXiTree() { fPaireXiTree = new TTree("eXiTree","eXiTree"); vector<TString> fTreeVariableName = { "pTe", "echarge", "TOFnSigma", "TPCnSigma", "TPCPID","ITS", "e_crossedrows", "e_findable", "phi","erap", "e_minmass", "e_minmass_ss", "pTv", "vcharge", "Massv", "MassLambda", "MassAntiLambda", "V0DecayLength", "CascDecayLength", "DCABachToPrimVertex", "DCAV0NegToPrimVertex", "DCAV0PosToPrimVertex", "V0CosineOfPoiningAngleXi", "XiCosineOfPoiningAngle", "DCAV0ToPrimVertex", "Xirap", "pion_crossedrows", "pion_findable", "proton_crossedrows", "proton_findable", "bpion_crossedratio", "bpion_findable", "pTpion", "pTproton", "pTbach", "cosoa", "In_Mass", "eXiPt" }; fPaireXiTreeVariable = new Float_t [fTreeVariableName.size()]; for (Int_t ivar=0; ivar<(Float_t)fTreeVariableName.size(); ivar++) { fPaireXiTree->Branch(fTreeVariableName[ivar].Data(), &fPaireXiTreeVariable[ivar], Form("%s/F",fTreeVariableName[ivar].Data()) ); } return; }//DefinePaireXiTree //----------------------------------------------------------- void AliAnalysisTaskSEXic0Semileptonic::DefineMCPaireXiTree() { fMCTree = new TTree("MCTree","MCTree"); vector<TString> fTreeVariableName = { "mcpTe", "mcecharge", "mcpTv", "mcvcharge", "mcpTXic0", "mcpTeXi", "mcXicMass", "c_flag", "b_flag", //Conventional "mcpTXib", "mceXipTb", "mcXibMass" //Newly added by J. Seo: modified by kimc in Aug. 19 }; fMCTreeVariable = new Float_t [fTreeVariableName.size()]; for (Int_t ivar=0; ivar<(Float_t)fTreeVariableName.size(); ivar++) { fMCTree->Branch(fTreeVariableName[ivar].Data(), &fMCTreeVariable[ivar], Form("%s/F",fTreeVariableName[ivar].Data()) ); } return; } //------------------------------------------------------- void AliAnalysisTaskSEXic0Semileptonic::DefineEventTree() { fEventTree = new TTree("EventTree", "EventTree"); const Int_t nVar = 7; fEventTreeVariable = new Float_t[nVar]; TString * fTreeVariableNames = new TString[nVar]; fTreeVariableNames[0] = "fRunNumber"; fTreeVariableNames[1] = "fCentrality"; //Centrality, by V0M fTreeVariableNames[2] = "fCentralSPD"; //Centrality, by SPD fTreeVariableNames[3] = "fNSPDTracklets"; //# of SPD tracklets fTreeVariableNames[4] = "fNeXiPair"; //# of saved pairs for the event: NOT 0 if more than pair saved fTreeVariableNames[5] = "fVtxZ"; fTreeVariableNames[6] = "fPileup"; //pileup in both MB/HMV0), 1 (MB pileup, HMV0 ok), and 2 (MB ok, HMV0 pileup) for (Int_t iVar=0; iVar<nVar; iVar++) { fEventTree->Branch(fTreeVariableNames[iVar].Data(), &fEventTreeVariable[iVar], Form("%s/F", fTreeVariableNames[iVar].Data()) ); } const Int_t nTargetTrig = fTargetTriggers.size(); if (nTargetTrig > 1) fEventTree->Branch("fTrigBit", &fEventTreeVarTrig, "fTrigBit/i"); fEventTree->Branch("fINEL", &fIsINELLgtZERO, "fINEL/O"); //The letter O. NOT a zero: boolean return; }//DefineEventTree void AliAnalysisTaskSEXic0Semileptonic::CheckOrigin( AliMCEvent* mcEvent, AliAODMCParticle *mcPart, Bool_t searchUpToQuark, Bool_t &c_flag, Bool_t &b_flag) { //from AliVertexingHFUtils //checking whether the mother of the particles come from a charm or a bottom quark Int_t mother = 0; mother = mcPart->GetMother(); Int_t pdgGranma = 0; Int_t istep = 0; Int_t abspdgGranma =0; Bool_t isFromB=kFALSE; Bool_t isQuarkFound=kFALSE; c_flag = kFALSE; b_flag = kFALSE; while (mother >=0 ) { istep++; AliAODMCParticle* mcGranma = (AliAODMCParticle*)mcEvent->GetTrack(mother); if (mcGranma) { pdgGranma = mcGranma->GetPdgCode(); abspdgGranma = TMath::Abs(pdgGranma); if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) isFromB=kTRUE; if (abspdgGranma==4 || abspdgGranma==5) isQuarkFound=kTRUE; mother = mcGranma->GetMother(); } else { printf("CheckOrigin: Failed casting the mother particle!"); break; } } if (searchUpToQuark && !isQuarkFound) return; if (isFromB) b_flag = kTRUE; else c_flag = kTRUE; return; }
38.350775
115
0.675249
maroozm
1638bd52a234823f0d27f6e5ea6c9805d442720b
2,481
cpp
C++
lab1/tests/tst_test1.cpp
Raikils/K-28_Ivan_Murzin_lab_second_term
7ab87fd55beef33335afe847ca47b119501ef752
[ "MIT" ]
null
null
null
lab1/tests/tst_test1.cpp
Raikils/K-28_Ivan_Murzin_lab_second_term
7ab87fd55beef33335afe847ca47b119501ef752
[ "MIT" ]
null
null
null
lab1/tests/tst_test1.cpp
Raikils/K-28_Ivan_Murzin_lab_second_term
7ab87fd55beef33335afe847ca47b119501ef752
[ "MIT" ]
null
null
null
#include <QtTest> #include <QCoreApplication> #include "plot.h" #include "qcustomplot.h" #include "createplot.h" #include "mainwindow.h" class Test1 : public QObject { Q_OBJECT public: Test1(); ~Test1(); private slots: void test_plot(); void test_createplot(); private: Plot p; CreatePlot *crpl; }; Test1::Test1() { } Test1::~Test1() { } void Test1::test_plot() { p.setName("chart"); p.setBackground(QColor(0,0,0)); p.setColor_bars({QColor(0,0,255),QColor(0,0,255),QColor(0,0,255)}); p.setData({{0,1,2},{3,4,5},{6,7,8}}); p.setLast(2); p.setLegend(true); p.setListWidgetItem(NULL); p.setMain_x(true); p.setName_bars({"one","two","three"}); p.setNum(3); p.setTicker({1,2,3}); p.setTicks_name({"1","2","3"}); p.setXAxis("x"); p.setYAxis("y"); QCustomPlot *chart = new QCustomPlot; p.build(chart); QVERIFY(chart->xAxis->label() == "x"); QVERIFY(chart->yAxis->label() == "y"); QVERIFY(p._bars.size() == 3); QVERIFY(p._bars[0]->width() == 0.15); QVERIFY(p._bars[1]->width() == 0.15); QVERIFY(p._bars[2]->width() == 0.15); QVERIFY(p._bars[0]->name() == "one"); QVERIFY(p._bars[1]->name() == "two"); QVERIFY(p._bars[2]->name() == "three"); QVERIFY(p._bars[0]->parentPlot() == chart); QVERIFY(p._bars[1]->parentPlot() == chart); QVERIFY(p._bars[2]->parentPlot() == chart); QVERIFY(!p._bars[0]->data()->isEmpty()); QVERIFY(!p._bars[1]->data()->isEmpty()); QVERIFY(!p._bars[2]->data()->isEmpty()); QVERIFY(p._bars[0]->data()->size() == 3); QVERIFY(p._bars[1]->data()->size() == 3); QVERIFY(p._bars[2]->data()->size() == 3); QVERIFY(!p._group->isEmpty()); QVERIFY(p._group->size() == 3); QVERIFY(p._group->bars(0) == p._bars[0]); QVERIFY(p._group->bars(1) == p._bars[1]); QVERIFY(p._group->bars(2) == p._bars[2]); } void Test1::test_createplot() { crpl = new CreatePlot; crpl->plot = p; crpl->on_checkBox_legend_stateChanged(0); crpl->on_lineEdit_xAxis_textChanged("X"); crpl->on_lineEdit_yAxis_textChanged("Y"); crpl->on_spinBox_num_bars_valueChanged(4); crpl->on_comboBox_backcolor_currentIndexChanged("red"); QVERIFY(!crpl->plot.legend()); QVERIFY(crpl->plot.xAxis() == "X"); QVERIFY(crpl->plot.yAxis() == "Y"); QVERIFY(crpl->plot.num() == 4); QVERIFY(crpl->plot.background() == QColor(255,0,0)); } QTEST_MAIN(Test1) #include "tst_test1.moc"
24.81
71
0.594518
Raikils
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
163dd08984c29b99ce3dee0b944f68ae1a5c6802
808
cc
C++
SimTracker/SiStripDigitizer/plugins/SiPileUpSignals.cc
ckamtsikis/cmssw
ea19fe642bb7537cbf58451dcf73aa5fd1b66250
[ "Apache-2.0" ]
852
2015-01-11T21:03:51.000Z
2022-03-25T21:14:00.000Z
SimTracker/SiStripDigitizer/plugins/SiPileUpSignals.cc
ckamtsikis/cmssw
ea19fe642bb7537cbf58451dcf73aa5fd1b66250
[ "Apache-2.0" ]
30,371
2015-01-02T00:14:40.000Z
2022-03-31T23:26:05.000Z
SimTracker/SiStripDigitizer/plugins/SiPileUpSignals.cc
ckamtsikis/cmssw
ea19fe642bb7537cbf58451dcf73aa5fd1b66250
[ "Apache-2.0" ]
3,240
2015-01-02T05:53:18.000Z
2022-03-31T17:24:21.000Z
#include "SimTracker/SiStripDigitizer/interface/SiPileUpSignals.h" #include "SimDataFormats/TrackingHit/interface/PSimHit.h" void SiPileUpSignals::resetSignals() { signal_.clear(); } void SiPileUpSignals::add(uint32_t detID, const std::vector<float>& locAmpl, const size_t& firstChannelWithSignal, const size_t& lastChannelWithSignal) { SignalMapType& theSignal = signal_[detID]; for (size_t iChannel = firstChannelWithSignal; iChannel < lastChannelWithSignal; ++iChannel) { if (locAmpl[iChannel] != 0.0) { if (theSignal.find(iChannel) == theSignal.end()) { theSignal.insert(std::make_pair(iChannel, locAmpl[iChannel])); } else { theSignal[iChannel] += locAmpl[iChannel]; } } } }
38.47619
96
0.65099
ckamtsikis
163e6f39aff10b4b17409b35c8b1bbe4f350bb1a
2,252
hpp
C++
pwiz/data/common/Index.hpp
austinkeller/pwiz
aa8e575cb40fd5e97cc7d922e4d8da44c9277cca
[ "Apache-2.0" ]
8
2018-05-23T14:37:31.000Z
2022-02-04T23:48:38.000Z
pwiz/data/common/Index.hpp
austinkeller/pwiz
aa8e575cb40fd5e97cc7d922e4d8da44c9277cca
[ "Apache-2.0" ]
9
2019-08-31T08:17:45.000Z
2022-02-11T20:58:06.000Z
pwiz/data/common/Index.hpp
austinkeller/pwiz
aa8e575cb40fd5e97cc7d922e4d8da44c9277cca
[ "Apache-2.0" ]
4
2018-04-25T01:39:38.000Z
2020-05-20T19:25:07.000Z
// // $Id$ // // // Original author: Matt Chambers <matt.chambers .@. vanderbilt.edu> // // Copyright 2009 Vanderbilt University - Nashville, TN 37232 // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #ifndef _INDEX_HPP_ #define _INDEX_HPP_ #include "pwiz/utility/misc/Export.hpp" #include <string> #include <vector> #include <boost/iostreams/positioning.hpp> #include <boost/shared_ptr.hpp> #include <boost/cstdint.hpp> namespace pwiz { namespace data { /// generic interface for creating and using an index on a stream of serialized objects class PWIZ_API_DECL Index { public: typedef boost::iostreams::stream_offset stream_offset; /// generic type identifying an indexed item by string id, ordinal index, and stream offset struct PWIZ_API_DECL Entry { std::string id; boost::uint64_t index; stream_offset offset; }; typedef boost::shared_ptr<Entry> EntryPtr; /// create the index from specified list of entries; /// the list is non-const because the index implementation may resort the list virtual void create(std::vector<Entry>& entries) = 0; /// returns the number of entries in the index virtual size_t size() const = 0; /// returns the entry for the specified string id, or null if the id is not in the index virtual EntryPtr find(const std::string& id) const = 0; /// returns the entry for the specified ordinal index, or null if the ordinal is not in the index virtual EntryPtr find(size_t index) const = 0; virtual ~Index() {} }; typedef boost::shared_ptr<Index> IndexPtr; } // namespace data } // namespace pwiz #endif // _INDEX_HPP_
28.15
102
0.687389
austinkeller
16405281649ea073dc4270d3eba43f949125eecd
2,920
cc
C++
cdn/src/model/DescribeCdnDomainByCertificateResult.cc
iamzken/aliyun-openapi-cpp-sdk
3c991c9ca949b6003c8f498ce7a672ea88162bf1
[ "Apache-2.0" ]
89
2018-02-02T03:54:39.000Z
2021-12-13T01:32:55.000Z
cdn/src/model/DescribeCdnDomainByCertificateResult.cc
iamzken/aliyun-openapi-cpp-sdk
3c991c9ca949b6003c8f498ce7a672ea88162bf1
[ "Apache-2.0" ]
89
2018-03-14T07:44:54.000Z
2021-11-26T07:43:25.000Z
cdn/src/model/DescribeCdnDomainByCertificateResult.cc
aliyun/aliyun-openapi-cpp-sdk
0cf5861ece17dfb0bb251f13bf3fbdb39c0c6e36
[ "Apache-2.0" ]
69
2018-01-22T09:45:52.000Z
2022-03-28T07:58:38.000Z
/* * Copyright 2009-2017 Alibaba Cloud 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 <alibabacloud/cdn/model/DescribeCdnDomainByCertificateResult.h> #include <json/json.h> using namespace AlibabaCloud::Cdn; using namespace AlibabaCloud::Cdn::Model; DescribeCdnDomainByCertificateResult::DescribeCdnDomainByCertificateResult() : ServiceResult() {} DescribeCdnDomainByCertificateResult::DescribeCdnDomainByCertificateResult(const std::string &payload) : ServiceResult() { parse(payload); } DescribeCdnDomainByCertificateResult::~DescribeCdnDomainByCertificateResult() {} void DescribeCdnDomainByCertificateResult::parse(const std::string &payload) { Json::Reader reader; Json::Value value; reader.parse(payload, value); setRequestId(value["RequestId"].asString()); auto allCertInfosNode = value["CertInfos"]["CertInfo"]; for (auto valueCertInfosCertInfo : allCertInfosNode) { CertInfo certInfosObject; if(!valueCertInfosCertInfo["Issuer"].isNull()) certInfosObject.issuer = valueCertInfosCertInfo["Issuer"].asString(); if(!valueCertInfosCertInfo["CertType"].isNull()) certInfosObject.certType = valueCertInfosCertInfo["CertType"].asString(); if(!valueCertInfosCertInfo["CertSubjectCommonName"].isNull()) certInfosObject.certSubjectCommonName = valueCertInfosCertInfo["CertSubjectCommonName"].asString(); if(!valueCertInfosCertInfo["CertExpireTime"].isNull()) certInfosObject.certExpireTime = valueCertInfosCertInfo["CertExpireTime"].asString(); if(!valueCertInfosCertInfo["CertStartTime"].isNull()) certInfosObject.certStartTime = valueCertInfosCertInfo["CertStartTime"].asString(); if(!valueCertInfosCertInfo["DomainNames"].isNull()) certInfosObject.domainNames = valueCertInfosCertInfo["DomainNames"].asString(); if(!valueCertInfosCertInfo["DomainList"].isNull()) certInfosObject.domainList = valueCertInfosCertInfo["DomainList"].asString(); if(!valueCertInfosCertInfo["CertExpired"].isNull()) certInfosObject.certExpired = valueCertInfosCertInfo["CertExpired"].asString(); if(!valueCertInfosCertInfo["CertCaIsLegacy"].isNull()) certInfosObject.certCaIsLegacy = valueCertInfosCertInfo["CertCaIsLegacy"].asString(); certInfos_.push_back(certInfosObject); } } std::vector<DescribeCdnDomainByCertificateResult::CertInfo> DescribeCdnDomainByCertificateResult::getCertInfos()const { return certInfos_; }
39.459459
117
0.786986
iamzken
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