blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 2 247 | content_id stringlengths 40 40 | detected_licenses listlengths 0 57 | license_type stringclasses 2 values | repo_name stringlengths 4 111 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 58 | visit_date timestamp[ns]date 2015-07-25 18:16:41 2023-09-06 10:45:08 | revision_date timestamp[ns]date 1970-01-14 14:03:36 2023-09-06 06:22:19 | committer_date timestamp[ns]date 1970-01-14 14:03:36 2023-09-06 06:22:19 | github_id int64 3.89k 689M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 25 values | gha_event_created_at timestamp[ns]date 2012-06-07 00:51:45 2023-09-14 21:58:52 ⌀ | gha_created_at timestamp[ns]date 2008-03-27 23:40:48 2023-08-24 19:49:39 ⌀ | gha_language stringclasses 159 values | src_encoding stringclasses 34 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 7 10.5M | extension stringclasses 111 values | filename stringlengths 1 195 | text stringlengths 7 10.5M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f7b6d6f25ee3de8397a0f8093e62bed1fbfbf88f | 1f2de6e26f22d21b47df0840b57462a98f4611a3 | /Lab ten(10)/HeapSort.cpp | 3222bc49f5d7cedf0c4bc774ccb796b1afd70d6e | [] | no_license | Akash-Shrivastava11/ADA-Lab | 36b2119b03f2b8ffdd6bfeb7be1d5e6182766408 | 9b981e254a058434ad3f5b99b184cfd4c9502e79 | refs/heads/main | 2023-06-18T03:05:08.808471 | 2021-07-07T19:01:14 | 2021-07-07T19:01:14 | 358,145,808 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,788 | cpp | HeapSort.cpp | #include <iostream>
#include <bits/stdc++.h>
#include<unistd.h>
#include <time.h>
using namespace std;
int arr[1000];
void heapify(int arr[], int n, int i)
{
int largest = i;
int l = 2*i + 1;
int r = 2*i + 2;
if (l < n && arr[l] > arr[largest])
largest = l;
if (r < n && arr[r] > arr[largest])
largest = r;
if (largest != i)
{
swap(arr[i], arr[largest]);
heapify(arr, n, largest);
}
}
void buildheap(int arr[],int n){
for (int i = n / 2 - 1; i >= 0; i--)
heapify(arr, n, i);
}
void heapSort(int arr[], int n)
{
buildheap(arr,n);
for (int i=n-1; i>0; i--)
{
swap(arr[0], arr[i]);
heapify(arr, i, 0);
}
}
void printArray(int arr[], int n)
{
for (int i=0; i<n; ++i)
cout << arr[i] << " ";
cout << "\n";
}
int main()
{
int x;
cout<<"Enter 1 to enter elements manually, 2 to check for random elements"<<endl;
cin>>x;
if(x==1){
int n;
cout<<"Enter size of array"<<endl;
cin>>n;
int arr[n];
cout<<"Enter array elements"<<endl;
for(int &i:arr)
cin>>i;
clock_t c1,c2;
c1=clock();
for(int i=0;i<100;i++)
{usleep(10);}
heapSort(arr,n);
c2=clock();
cout<<"Time elapsed for N = "<<n<<" "<<(float(c2-c1)/float(CLK_TCK))<<endl;
cout<<"Array after sorting:"<<endl;
for(int i:arr)
cout<<i<<" ";
cout<<endl;
}
else{
int n=50;
while(n<=500){
int arr[n];
for(int &i:arr)
i= rand() % INT_MAX;
clock_t c1,c2;
c1=clock();
for(int i=0;i<100;i++)
{usleep(10);}
heapSort(arr,n);
c2=clock();
cout<<"Time elapsed for N = "<<n<<" "<<(float(c2-c1)/float(CLK_TCK))<<endl;
n+=50;
}
}
} |
57711744798f27e9924e303e2032fe1664224c00 | 802a8f80cefc39644979cf2038356f63de866398 | /Server Lib/Game Server/GAME/lobby.cpp | fe0343918d25c1e235a42fc75ce7301c4224e6fa | [
"MIT"
] | permissive | Acrisio-Filho/SuperSS-Dev | 3a3b78e15e0ec8edc9aae0ca1a632eb02be5d19c | 9b1bdd4a2536ec13de50b11e6feb63e5c351559b | refs/heads/master | 2023-08-03T13:00:07.280725 | 2023-07-05T00:24:18 | 2023-07-05T00:24:18 | 418,925,124 | 32 | 30 | MIT | 2022-11-03T23:15:37 | 2021-10-19T12:58:05 | C++ | UTF-8 | C++ | false | false | 497 | cpp | lobby.cpp | // Arquivo lobby.cpp
// Criado em 24/12/2017 por Acrisio
// Implementação da classe lobby
#if defined(_WIN32)
#pragma pack(1)
#endif
#if defined(_WIN32)
#include <WinSock2.h>
#endif
#include "lobby.h"
using namespace stdA;
lobby::lobby() {
};
lobby::~lobby() {
while (!v_sessions.empty()) {
v_sessions.erase(v_sessions.begin());
v_sessions.shrink_to_fit();
}
while (!v_rooms.empty()) {
delete v_rooms.front();
v_rooms.erase(v_rooms.begin());
v_rooms.shrink_to_fit();
}
};
|
d0e24c905c1b75fa81faa495fdb00ee10489ac60 | 6207df7b5e4acc14b5811edacb99ceca4950b451 | /A_Card_Game.cpp | 4ce0421e62a2dcbbfb7ab4092f8cd9e90a7bc0be | [] | no_license | Nirbhay007/cp-solve | 733e16984b6c3c14b758ef3d803d4381e7ad3109 | 5c1e43263ce7a272bbe8898522645f64e7b8617f | refs/heads/master | 2023-08-11T21:27:15.628071 | 2021-09-20T04:26:05 | 2021-09-20T04:26:05 | 408,309,243 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 649 | cpp | A_Card_Game.cpp | #include <bits/stdc++.h>
using namespace std;
int main()
{
char type;
cin >> type;
string first, second;
cin >> first >> second;
map<char, int> m{
{'6', 6},
{'7', 7},
{'8', 8},
{'9', 9},
{'T', 10},
{'J', 11},
{'Q', 12},
{'K', 13},
{'A', 14}};
char first_type = first.at(1);
char first_rank = first.at(0);
char second_type = second.at(1);
char second_rank = second.at(0);
if (first_type == second_type)
{
if (m[first_rank] > m[second_rank])
{
cout << "YES";
}
else
{
cout << "NO";
}
}
else if (first_type == type)
{
cout << "YES";
}
else
{
cout << "NO";
}
} |
47730fbe8ce4368d7af0f7e46fc6d0e9824d0054 | 304ff6d39a8eaa896317a34ec31787606a71656f | /P154PROC_ROUND_4C.cpp | 1e36007a44855d4949144390ed6c2ff9e8ff8172 | [] | no_license | S4ltF1sh/SPOJ | 4ed70e86d47371f436efd4080991bfc8ed3a9e65 | b7694fb770d973649e7804def0352dc075c822c8 | refs/heads/main | 2023-06-01T19:10:05.737305 | 2021-06-22T11:09:46 | 2021-06-22T11:09:46 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,393 | cpp | P154PROC_ROUND_4C.cpp | //P154PROC - ROUND 4C - Về quê
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
using namespace std;
int main()
{
int n;
cin >> n;
char Bus[4][11];
for (int j = 0; j < 11; j++)
{
for (int i = 0; i < 4; i++)
{
if (j == 0)
{
if (n > 0)
{
Bus[i][j] = 'O';
n--;
}
else
Bus[i][j] = '#';
}
else
{
if (n > 0 && i != 2)
{
Bus[i][j] = 'O';
n--;
}
else if (i == 2)
Bus[i][j] = '.';
else
Bus[i][j] = '#';
}
}
}
cout << "+------------------------+\n";
for (int i = 0; i < 4; i++)
{
cout << "|";
for (int j = 0; j < 11; j++)
{
cout << Bus[i][j] << ".";
}
if (i == 0)
cout << "|D|)";
else if (i == 3)
cout << "|.|)";
else if (i == 1)
cout << "|.|";
else
cout << "..|";
cout << endl;
}
cout << "+------------------------+";
}
|
8f0997fd0ddba8b3f58f5913889ce85116e0321d | 04d347517097edeb24de7ed91914042a62830c9f | /RemoteWorkStation/src/Commands/FileHandler.cpp | fe76c7e952153c41906ab51e8d574d32be68b780 | [] | no_license | PivProggers/IncludeBeer | 24b8423e56353a41a1386859a5434830ccd0fe8c | 2a133984e2cedfad4d7a6ba4d718cf5b635fc8d9 | refs/heads/master | 2022-09-19T10:57:51.166224 | 2022-09-04T13:35:28 | 2022-09-04T13:35:28 | 216,859,863 | 0 | 0 | null | 2019-12-18T14:21:14 | 2019-10-22T16:29:14 | C++ | UTF-8 | C++ | false | false | 2,915 | cpp | FileHandler.cpp | #include "pch.h"
#include "Command.h"
using namespace std;
#define BUF_STD_SIZE 256
#ifndef OS_WIN
#include <stdio.h>
#include "fcntl.h"
#include "sys/types.h"
#include "dirent.h"
#define fopen_s(pFile,filename,mode) ((*(pFile))=fopen((filename), (mode)))==NULL
#endif
string FileHandler::SendFile(const char* name)
{
// File to read
FILE* fin;
string buf;
if (!fopen_s(&fin, name, "rb")) {
// The end of the file
fseek(fin, 0, SEEK_END);
// Get size of the file
unsigned int m_file_size = ftell(fin);
// Go to start
rewind(fin);
unsigned int BLOCK_SIZE;
size_t CountOfRead = 0;
// Read and write by "BLOCK_SIZE" bytes
for (unsigned int i = 0; i < m_file_size; )
{
if (BUF_STD_SIZE > m_file_size)
BLOCK_SIZE = m_file_size;
else
BLOCK_SIZE = BUF_STD_SIZE;
char* buffer = new char[BLOCK_SIZE];
// Read "BLOCK_SIZE" bytes to buffer
CountOfRead = fread(buffer, sizeof(unsigned char), BLOCK_SIZE, fin);
i += CountOfRead;
// Write "BLOCK_SIZE" bytes
buf.append(buffer, CountOfRead);
delete buffer;
}
fclose(fin);
_error_report = "Succesfully read file";
return buf;
}
else
{
_error_report = "Failed with reading the file";
buf.clear();
return buf;
}
}
string FileHandler::RecieveFile(string fileReadBuf, const char* name)
{
// File to write
FILE* fout;
string result;
int countOfCycles = 0;
if (!fopen_s(&fout, name, "wb"))
{
unsigned int BLOCK_SIZE;
size_t CountOfWrite = 0;
unsigned int fileSize = fileReadBuf.size();
// Write by "BLOCK_SIZE" bytes
for (unsigned int i = 0; i < fileSize; )
{
if (BUF_STD_SIZE > fileReadBuf.size() - i)
BLOCK_SIZE = fileReadBuf.size() - i;
else
BLOCK_SIZE = BUF_STD_SIZE;
CountOfWrite = fwrite(fileReadBuf.substr(countOfCycles * BUF_STD_SIZE, BLOCK_SIZE).c_str(), sizeof(unsigned char), BLOCK_SIZE, fout);
i += CountOfWrite;
++countOfCycles;
}
fclose(fout);
result = "0";
_error_report = "Succesfully writting file";
}
else
{
result = "-1";
_error_report = "Failed with writting the file";
}
return result;
}
#ifndef OS_WIN
bool directoryexists(const char* path)
{
const char* a = strrchr(path, '/');
char* clearpath = new char[a - path + 1];
clearpath[a - path] = '\0';
memcpy(clearpath, path, a - path);
string res = clearpath;
delete clearpath;
if (res.c_str() == null) return false;
dir* dir;
bool exists = false;
dir = opendir(res.c_str());
if (dir != null)
{
exists = true;
(void)closedir(dir);
}
return exists;
}
#endif |
69d1bd76744ec0cf430c1542f932e6449047f315 | 29d85beff4e016770caa65e5cfff4ec095d859c0 | /clipboard/cpb_win_napi.cc | d3d2b6ff939fbae6107af24ce374d60280c85ab2 | [] | no_license | edeink/clipboard-file | 5e3d96021f17a4bd12906a6f671367eacf5ee267 | f16d071a87e9c4af89adbe184687cef55a464749 | refs/heads/master | 2022-10-24T13:41:36.310346 | 2019-02-23T10:07:27 | 2019-02-23T10:07:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,517 | cc | cpb_win_napi.cc | #include <node_api.h>
#include <oleidl.h>
#include <comdef.h>
#include <vector>
#include <string>
#include <iostream>
std::vector<std::wstring> GetPaths() {
std::vector<std::wstring> path_list;
// 打开剪切板
if (::OpenClipboard(NULL))
{
HDROP hDrop = HDROP(::GetClipboardData(CF_HDROP));
if (hDrop != NULL)
{
WCHAR szFilePathName[MAX_PATH + 1] = { 0 };
UINT nNumOfFiles = DragQueryFileW(hDrop, 0xFFFFFFFF, NULL, 0);
for (UINT nIndex = 0; nIndex < nNumOfFiles; ++nIndex)
{
// 获取文件名
memset(szFilePathName, 0, sizeof(WCHAR)*(MAX_PATH + 1));
DragQueryFileW(hDrop, nIndex, szFilePathName, MAX_PATH);
path_list.push_back(szFilePathName);
}
}
::CloseClipboard();
}
return path_list;
}
// 转码:Unicode -> utf-8
char* UnicodeToUtf8(const wchar_t* unicode)
{
int len;
len = WideCharToMultiByte(CP_UTF8, 0, unicode, -1, NULL, 0, NULL, NULL);
char *szUtf8 = (char*)malloc(len + 1);
memset(szUtf8, 0, len + 1);
WideCharToMultiByte(CP_UTF8, 0, unicode, -1, szUtf8, len, NULL, NULL);
return szUtf8;
}
// n-api
napi_value GetFunction(napi_env env, napi_callback_info info) {
napi_value array;
std::vector<std::wstring> fileVec = GetPaths();
napi_create_array_with_length(env, fileVec.size(), &array);
for (int i=0; i<fileVec.size(); i++) {
napi_value tempStr;
const char* szFilePath = UnicodeToUtf8(fileVec[i].c_str());
napi_create_string_utf8(env, szFilePath, strlen(szFilePath), &tempStr);
napi_get_element(env, tempStr, i, &array);
}
return array;
// napi_value test;
// HDROP hDrop = HDROP(::GetClipboardData(CF_HDROP));
// WCHAR szFilePathName[MAX_PATH + 1] = { 0 };
// UINT nNumOfFiles = DragQueryFileW(hDrop, 0xFFFFFFFF, NULL, 0);
// napi_get_boolean(env, hDrop == NULL, &test);
// napi_create_int32(env, nNumOfFiles, &test);
// napi_get_boolean(env, ::OpenClipboard(NULL), &test);
// napi_create_string_utf8(env, 'hello', NAPI_AUTO_LENGTH, &test);
// napi_create_int32(env, fileVec.size(), &test);
// return test;
}
#define DECLARE_NAPI_METHOD(name, func) \
{ name, 0, func, 0, 0, 0, napi_default, 0 }
napi_value Init(napi_env env, napi_value exports) {
napi_property_descriptor desc = DECLARE_NAPI_METHOD("getClipboardFiles", GetFunction);
napi_define_properties(env, exports, 1, &desc);
return exports;
}
NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)
|
f38f18424e008c788e6120a7a78acc0f75cddd70 | 67c6ecdb4c861114877b3ebcf34675c41274924d | /tree_exception.h | b1491ebbad5ac47c3d50070c5c7b23926eb70e29 | [] | no_license | astarianka/Labs | f0c180844339f67bca3d9650e8ecafdd9e68e530 | 5410c745912ebb925cfaeb72a8d8e594de937310 | refs/heads/master | 2021-04-15T05:06:24.068250 | 2018-04-16T17:04:45 | 2018-04-16T17:04:45 | 126,454,611 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 422 | h | tree_exception.h | #ifndef TREE_EXCEPTION_INCLUDED
#define TREE_EXCEPTION_INCLUDED
#include <exception>
class EmptyTree: public std::exception
{
public:
virtual const char* what() const throw();
};
class NegativeIndex: public std::exception
{
public:
virtual const char* what() const throw();
};
class OutOfRange: public std::exception
{
public:
virtual const char* what() const throw();
};
#endif // TREE_EXCEPTION_INCLUDED
|
80f36b29e163f2d43c629fa061bcbc45c54cf486 | 975cb839f100255dcc2412a230943c054dc8473e | /transfer-plugins/bittorrent/advanceddetails/iwfiletreemodel.cpp | a2c3c1fc7480aab1c3d2da28e622b60a96d25944 | [] | no_license | mfuchs/kget-gsoc | 50fe81d398aeadac729644c51531a66c003ee6e9 | 67b5cb0ea15df835e4692acbb185b2eb0062fee6 | refs/heads/master | 2021-01-01T15:23:18.191242 | 2009-08-10T16:20:51 | 2009-08-10T16:20:51 | 186,307 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,299 | cpp | iwfiletreemodel.cpp | /***************************************************************************
* Copyright (C) 2007 by Joris Guisson and Ivan Vasic *
* joris.guisson@gmail.com *
* ivasic@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include "iwfiletreemodel.h"
#include <math.h>
#include <klocale.h>
#include <kglobal.h>
#include <util/functions.h>
#include <interfaces/torrentinterface.h>
#include <interfaces/torrentfileinterface.h>
using namespace bt;
namespace kt
{
IWFileTreeModel::IWFileTreeModel(bt::TorrentInterface* tc,QObject* parent)
: TorrentFileTreeModel(tc,KEEP_FILES,parent)
{
mmfile = IsMultimediaFile(tc->getStats().output_path);
preview = false;
percentage = 0;
if (root)
{
BitSet d = tc->downloadedChunksBitSet();
d -= tc->onlySeedChunksBitSet();
root->initPercentage(tc,d);
}
}
IWFileTreeModel::~IWFileTreeModel()
{
}
int IWFileTreeModel::columnCount(const QModelIndex & /*parent*/) const
{
return 5;
}
QVariant IWFileTreeModel::headerData(int section, Qt::Orientation orientation,int role) const
{
if (role != Qt::DisplayRole || orientation != Qt::Horizontal)
return QVariant();
if (section < 2)
return TorrentFileTreeModel::headerData(section,orientation,role);
switch (section)
{
case 2: return i18n("Priority");
case 3: return i18n("Preview");
// xgettext: no-c-format
case 4: return i18nc("Percent of File Downloaded", "% Complete");
default: return QVariant();
}
}
static QString PriorityString(const bt::TorrentFileInterface* file)
{
switch(file->getPriority())
{
case FIRST_PRIORITY: return i18nc("Download first", "First");
case LAST_PRIORITY: return i18nc("Download last", "Last");
case ONLY_SEED_PRIORITY:
case EXCLUDED:
case PREVIEW_PRIORITY:
return QString();
default:return i18nc("Download normally(not as first or last)", "Normal");
}
}
QVariant IWFileTreeModel::data(const QModelIndex & index, int role) const
{
Node* n = 0;
if (index.column() < 2 && role != Qt::ForegroundRole)
return TorrentFileTreeModel::data(index,role);
if (!index.isValid() || !(n = (Node*)index.internalPointer()))
return QVariant();
if (role == Qt::ForegroundRole && index.column() == 2 && tc->getStats().multi_file_torrent && n->file)
{
const bt::TorrentFileInterface* file = n->file;
switch (file->getPriority())
{
/*case FIRST_PRIORITY:
return InfoWidgetPluginSettings::firstColor();
case LAST_PRIORITY:
return InfoWidgetPluginSettings::lastColor();
case NORMAL_PRIORITY:
return InfoWidgetPluginSettings::normalColor();
case ONLY_SEED_PRIORITY:
case EXCLUDED:
case PREVIEW_PRIORITY:
default:*/
return QVariant();
}
}
if (role == Qt::DisplayRole)
return displayData(n,index);
else if (role == Qt::UserRole)
return sortData(n,index);
return QVariant();
}
QVariant IWFileTreeModel::displayData(Node* n,const QModelIndex & index) const
{
if (tc->getStats().multi_file_torrent && n->file)
{
const bt::TorrentFileInterface* file = n->file;
switch (index.column())
{
case 2: return PriorityString(file);
case 3:
if (file->isMultimedia())
{
if (file->isPreviewAvailable())
return i18nc("preview available", "Available");
else
return i18nc("Preview pending", "Pending");
}
else
return i18nc("No preview available", "No");
case 4:
if (file->getPriority() == ONLY_SEED_PRIORITY || file->getPriority() == EXCLUDED)
return QVariant();
else
return ki18n("%1 %").subs(n->percentage, 0, 'f', 2).toString();
default: return QVariant();
}
}
else if (!tc->getStats().multi_file_torrent)
{
switch (index.column())
{
case 2: return QVariant();
case 3:
if (mmfile)
{
if (tc->readyForPreview())
return i18nc("Preview available", "Available");
else
return i18nc("Preview pending", "Pending");
}
else
return i18nc("No preview available", "No");
case 4:
return ki18n("%1 %").subs(bt::Percentage(tc->getStats()), 0, 'f', 2).toString();
default: return QVariant();
}
}
else if (tc->getStats().multi_file_torrent && index.column() == 4)
{
return ki18n("%1 %").subs(n->percentage, 0, 'f', 2).toString();
}
return QVariant();
}
QVariant IWFileTreeModel::sortData(Node* n,const QModelIndex & index) const
{
if (tc->getStats().multi_file_torrent && n->file)
{
const bt::TorrentFileInterface* file = n->file;
switch (index.column())
{
case 2: return (int)file->getPriority();
case 3:
if (file->isMultimedia())
{
if (file->isPreviewAvailable())
return 3;
else
return 2;
}
else
return 1;
case 4:
return n->percentage;
}
}
else if (!tc->getStats().multi_file_torrent)
{
switch (index.column())
{
case 2: return QVariant();
case 3:
if (mmfile)
{
if (tc->readyForPreview())
return 3;
else
return 2;
}
else
return 1;
case 4:
return bt::Percentage(tc->getStats());
}
}
else if (tc->getStats().multi_file_torrent && index.column() == 4)
{
return n->percentage;
}
return QVariant();
}
bool IWFileTreeModel::setData(const QModelIndex & index, const QVariant & value, int role)
{
if (role == Qt::CheckStateRole)
return TorrentFileTreeModel::setData(index,value,role);
if (!index.isValid() || role != Qt::UserRole)
return false;
Node* n = static_cast<Node*>(index.internalPointer());
if (!n)
return false;
if (!n->file)
{
for (int i = 0;i < n->children.count();i++)
{
// recurse down the tree
setData(index.child(i,0),value,role);
}
}
else
{
bt::TorrentFileInterface* file = n->file;
Priority prio = (bt::Priority)value.toInt();
Priority old = file->getPriority();
if (prio != old)
{
file->setPriority(prio);
dataChanged(createIndex(index.row(),0),createIndex(index.row(),4));
QModelIndex parent = index.parent();
if (parent.isValid())
dataChanged(parent,parent); // parent needs to be updated to
}
}
return true;
}
void IWFileTreeModel::filePercentageChanged(bt::TorrentFileInterface* file,float percentage)
{
Q_UNUSED(percentage);
update(index(0,0,QModelIndex()),file,4);
}
void IWFileTreeModel::filePreviewChanged(bt::TorrentFileInterface* file,bool preview)
{
Q_UNUSED(preview);
update(index(0,0,QModelIndex()),file,3);
}
void IWFileTreeModel::update(const QModelIndex & idx,bt::TorrentFileInterface* file,int col)
{
Node* n = (Node*)idx.internalPointer();
if (n->file && n->file == file)
{
QModelIndex i = createIndex(idx.row(),col,n);
emit dataChanged(i,i);
if(col == 4)
{
// update percentages along the tree
// this will go back up the tree and update the percentage of
// all directories involved
BitSet d = tc->downloadedChunksBitSet();
d -= tc->onlySeedChunksBitSet();
n->updatePercentage(d);
// emit necessary signals
QModelIndex parent = idx.parent();
while (parent.isValid())
{
Node* nd = (Node*)parent.internalPointer();
i = createIndex(parent.row(),4,nd);
emit dataChanged(i,i);
parent = parent.parent();
}
}
}
else
{
for (int i = 0;i < n->children.count();i++)
{
// recurse down the tree
update(idx.child(i,0),file,col);
}
}
}
void IWFileTreeModel::update()
{
if (!tc->getStats().multi_file_torrent)
{
bool changed = false;
bool np = mmfile && tc->readyForPreview();
if (preview != np)
{
preview = np;
changed = true;
}
double perc = bt::Percentage(tc->getStats());
if (fabs(perc - percentage) > 0.01)
{
percentage = perc;
changed = true;
}
if (changed)
dataChanged(createIndex(0,2),createIndex(0,4));
}
}
}
#include "iwfiletreemodel.moc"
|
63f57bcf3efd9b67ad6dba1a2dea44d51acf543f | b845fe9be69e6ad69ebf59fea0f2782d308c0bc9 | /链式表/main.cpp | 2d5babd205541545457b6716282b6bc57514d77d | [] | no_license | SJX516/DataStructureCppCode | a2bd27cbb2a770cfe8a9bcf7e558322374d8ebe3 | 942a96b340a990058c249f84cace447668e2f28a | refs/heads/master | 2020-07-17T21:00:45.177524 | 2016-11-16T14:03:51 | 2016-11-16T14:03:51 | 73,925,188 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 365 | cpp | main.cpp | #include <iostream>
#include "ListStack.h"
using namespace std;
int main()
{
int temp;
LinkStack<int> a(4);
a.Push(0);
a.Push(1);
a.Push(2);
a.Push(3);
a.Push(4);
a.Top(temp);
cout<<"当前栈顶元素为"<<temp<<endl;
a.Pop(temp);
a.Top(temp);
cout<<"当前栈顶元素为"<<temp<<endl;
a.Clear();
return 0;
}
|
edc0d647212ec7ae6b26d5fc2854d050b7e2a711 | 5d96eb241e9f1e285c725e51d5f2ea87b7b41ae2 | /esp_side/esp_side.ino | 80d96888ffc19dce0267ca68e37cb63c594b9866 | [] | no_license | SoravitYK/Project-ComProgramming | 245daecd0d7ec6c4bcb92e9bdd1e2d895b6a64f8 | f82c85452f29bd5b4e468d50fcfd8d08ffdf5ebd | refs/heads/master | 2020-05-18T13:27:23.387421 | 2019-05-02T09:38:25 | 2019-05-02T09:38:25 | 184,437,809 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,093 | ino | esp_side.ino | #include <string.h>
#include <MPU9250.h>
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
#include <WiFiClient.h>
MPU9250 IMU(Wire,0x68);
int status;
WiFiServer server(26);
WiFiClient client;
String message_na;
//gets called when WiFiManager enters configuration mode
void configModeCallback (WiFiManager *myWiFiManager) {
//Serial.println("Entered config mode");
//Serial.println(WiFi.softAPIP());
//if you used auto generated SSID, print it
//Serial.println(myWiFiManager->getConfigPortalSSID());
//entered config mode, make led toggle faster
}
void setup(void) {
//Serial.begin(115200);
//pinMode(BUILTIN_LED, OUTPUT);
pinMode(3, INPUT_PULLUP);
//WiFiManager
//Local intialization. Once its business is done, there is no need to keep it around
WiFiManager wifiManager;
//reset settings - for testing
//wifiManager.resetSettings();
//set callback that gets called when connecting to previous WiFi fails, and enters Access Point mode
wifiManager.setAPCallback(configModeCallback);
if (!wifiManager.autoConnect(">>I'm HERE!!<<", "hahahahaha")) {
//Serial.println("failed to connect and hit timeout");
//reset and try again, or maybe put it to deep sleep
ESP.reset();
delay(1000);
}
//if you get here you have connected to the WiFi
//Serial.println("connected...yeey :)");
server.begin();
//keep LED off
//digitalWrite(BUILTIN_LED, HIGH);
Wire.begin();
// start communication with IMU
status = IMU.begin();
if (status < 0) {
//Serial.println("Couldnt start1");
while(1);
}
//Serial.println("MPU9250 found!");
}
void loop() {
client = server.available();
if (client){
Serial.println("Client connected");
while (client.connected()){
IMU.readSensor();
/* Display the results (acceleration is measured in m/s^2) */
// Send the distance to the client, along with a break to separate our messages
message_na = String("");
message_na += String(IMU.getAccelX_mss());
message_na += String(",");
message_na += String(IMU.getAccelY_mss());
message_na += String(",");
message_na += String(IMU.getAccelZ_mss());
message_na += String(",");
message_na += String(IMU.getGyroX_rads());
message_na += String(",");
message_na += String(IMU.getGyroY_rads());
message_na += String(",");
message_na += String(IMU.getGyroZ_rads());
message_na += String(",");
message_na += String(IMU.getMagX_uT());
message_na += String(",");
message_na += String(IMU.getMagY_uT());
message_na += String(",");
message_na += String(IMU.getMagZ_uT());
message_na += String(",");
message_na += String(IMU.getTemperature_C());
message_na += String(",");
message_na += String(digitalRead(3));
client.print(message_na);
client.print("\r");
// Delay before the next reading
delay(10);
}
}
}
|
fa9b2ded98345c239e0fa2c46dd0292a189abe85 | 87a972e42adedb5a5fc498b446a1da2ed41628e1 | /3rdparty/libfaad2/bits.cpp | 8cd343099df4aa787620cf4e863b84fddfe69c33 | [] | no_license | gabest11/homesys | 4649f6eb697284dd445f2c8d557a4771e32c2d62 | 3645dd0d142d6332e5ece43ac2402058f2fb8198 | refs/heads/main | 2022-07-29T20:33:58.685388 | 2022-03-30T16:07:46 | 2022-03-30T16:07:46 | 467,268,398 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,029 | cpp | bits.cpp | /*
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
** Any non-GPL usage of this software or parts of this software is strictly
** forbidden.
**
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** $Id: bits.c,v 1.39 2004/09/04 14:56:27 menno Exp $
**/
#include "stdafx.h"
#include "common.h"
#include "structs.h"
#include "bits.h"
/* initialize buffer, call once before first getbits or showbits */
void faad_initbits(bitfile *ld, const void *_buffer, const uint32_t buffer_size)
{
uint32_t tmp;
if (ld == NULL)
return;
memset(ld, 0, sizeof(bitfile));
if (buffer_size == 0 || _buffer == NULL)
{
ld->error = 1;
ld->no_more_reading = 1;
return;
}
ld->buffer = faad_malloc((buffer_size+12)*sizeof(uint8_t));
memset(ld->buffer, 0, (buffer_size+12)*sizeof(uint8_t));
memcpy(ld->buffer, _buffer, buffer_size*sizeof(uint8_t));
ld->buffer_size = buffer_size;
tmp = getdword((uint32_t*)ld->buffer);
ld->bufa = tmp;
tmp = getdword((uint32_t*)ld->buffer + 1);
ld->bufb = tmp;
ld->start = (uint32_t*)ld->buffer;
ld->tail = ((uint32_t*)ld->buffer + 2);
ld->bits_left = 32;
ld->bytes_used = 0;
ld->no_more_reading = 0;
ld->error = 0;
}
void faad_endbits(bitfile *ld)
{
if (ld)
{
if (ld->buffer)
{
faad_free(ld->buffer);
ld->buffer = NULL;
}
}
}
uint32_t faad_get_processed_bits(bitfile *ld)
{
return (uint32_t)(8 * (4*(ld->tail - ld->start) - 4) - (ld->bits_left));
}
uint8_t faad_byte_align(bitfile *ld)
{
uint8_t remainder = (uint8_t)((32 - ld->bits_left) % 8);
if (remainder)
{
faad_flushbits(ld, 8 - remainder);
return (8 - remainder);
}
return 0;
}
void faad_flushbits_ex(bitfile *ld, uint32_t bits)
{
uint32_t tmp;
ld->bufa = ld->bufb;
if (ld->no_more_reading == 0)
{
tmp = getdword(ld->tail);
ld->tail++;
} else {
tmp = 0;
}
ld->bufb = tmp;
ld->bits_left += (32 - bits);
ld->bytes_used += 4;
if (ld->bytes_used == ld->buffer_size)
ld->no_more_reading = 1;
if (ld->bytes_used > ld->buffer_size)
ld->error = 1;
}
/* rewind to beginning */
void faad_rewindbits(bitfile *ld)
{
uint32_t tmp;
tmp = ld->start[0];
#ifndef ARCH_IS_BIG_ENDIAN
BSWAP(tmp);
#endif
ld->bufa = tmp;
tmp = ld->start[1];
#ifndef ARCH_IS_BIG_ENDIAN
BSWAP(tmp);
#endif
ld->bufb = tmp;
ld->bits_left = 32;
ld->tail = &ld->start[2];
ld->bytes_used = 0;
ld->no_more_reading = 0;
}
uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits
DEBUGDEC)
{
uint16_t i;
uint8_t temp;
uint16_t bytes = (uint16_t)bits / 8;
uint8_t remainder = (uint8_t)bits % 8;
uint8_t *buffer = (uint8_t*)faad_malloc((bytes+1)*sizeof(uint8_t));
for (i = 0; i < bytes; i++)
{
buffer[i] = (uint8_t)faad_getbits(ld, 8 DEBUGVAR(print,var,dbg));
}
if (remainder)
{
temp = (uint8_t)faad_getbits(ld, remainder DEBUGVAR(print,var,dbg)) << (8-remainder);
buffer[bytes] = temp;
}
return buffer;
}
#ifdef DRM
/* return the original data buffer */
void *faad_origbitbuffer(bitfile *ld)
{
return (void*)ld->start;
}
/* return the original data buffer size */
uint32_t faad_origbitbuffer_size(bitfile *ld)
{
return ld->buffer_size;
}
#endif
/* reversed bit reading routines, used for RVLC and HCR */
void faad_initbits_rev(bitfile *ld, void *buffer,
uint32_t bits_in_buffer)
{
uint32_t tmp;
int32_t index;
ld->buffer_size = bit2byte(bits_in_buffer);
index = (bits_in_buffer+31)/32 - 1;
ld->start = (uint32_t*)buffer + index - 2;
tmp = getdword((uint32_t*)buffer + index);
ld->bufa = tmp;
tmp = getdword((uint32_t*)buffer + index - 1);
ld->bufb = tmp;
ld->tail = (uint32_t*)buffer + index;
ld->bits_left = bits_in_buffer % 32;
if (ld->bits_left == 0)
ld->bits_left = 32;
ld->bytes_used = 0;
ld->no_more_reading = 0;
ld->error = 0;
}
|
24187845a2290202eaa888c29f0b53902abccaa9 | 0440fcb4ff56e43c4faf855e441e70a99a30186a | /busmaster/Sources/UDS_Protocol/MainPanel.cpp | 0261cc3778eb5fba27c24465b4a78c4924a413f5 | [] | no_license | MarcSerraLear/UDS_Busmaster | 0383d1d1349dc3d0e29762c1457821807f530b5d | 9f624aa11ebc4041d6048088ac02960f38a80293 | refs/heads/master | 2020-05-17T12:35:02.189914 | 2014-04-14T13:44:27 | 2014-04-14T13:44:27 | 12,892,058 | 5 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 9,740 | cpp | MainPanel.cpp | #include "MainPanel.h"
#include "Panel.h"
#include "Node.h"
#include "PanelAndNode.h"
#include "Panel_DME.h"
#include "PanelAbs.h"
//#include "UDS_Protocol.h"
//#include "UDS_Resource.h"
//#include "DIL_Interface/BaseDIL_CAN.h"
//#include "DIL_Interface/DIL_Interface_extern.h"
#define TRUE 1
#define FALSE 0
static DWORD g_dwClientID = 0;
static CBaseDIL_CAN* Panel_DIL_CAN_Interface;
CUDS_Protocol* UDSP;
CMainPanel* CMainPanel::m_spodInstance = NULL;
//CUDS_Protocol* UDSP;
CUDSMainWnd* UDSMW;
CPanelAndNode* PanelAndNode1;
CPanelDme* PanelDme;
CPanelAbs* PanelAbs;
CMainPanel* MaiPai;
HANDLE timer;
BOOL flagEnvio;
bool FKombi;
bool FKombiInit;
bool FAbs;
bool FAbsInit;
bool FDme;
bool FDmeInit;
mPSTXSELMSGDATA psTxCanMsgUds = new mSTXSELMSGDATA;
IMPLEMENT_DYNAMIC(CMainPanel, CDialog)
CMainPanel::CMainPanel( CWnd* pParent)
:CDialog(CMainPanel::IDD, pParent)
{
//Init
vInitializeMainPanel();
MaiPai=this;
StartTimer();
FKombi=FALSE;
FKombiInit=FALSE;
FAbs=FALSE;
FAbsInit=FALSE;
}
CMainPanel::~CMainPanel(void)
{
}
BEGIN_MESSAGE_MAP(CMainPanel, CDialog)
ON_BN_CLICKED(IDC_BUTTON_TO_ABS, OnBnClickedOpenAbsPanel)
ON_BN_CLICKED(IDC_BUTTON_TO_KOMBI, OnBnClickedOpenKombiPanel)
ON_BN_CLICKED(IDC_BUTTON_TO_DME, OnBnClickedOpenDmePanel)
ON_BN_CLICKED(IDC_CHECK_ABS, OnCheckAbsNode)
ON_BN_CLICKED(IDC_CHECK_DME, OnCheckDmeNode)
ON_BN_CLICKED(IDC_CHECK_KOMBI, OnCheckKombiNode)
END_MESSAGE_MAP()
BOOL CMainPanel::OnInitDialog(){
CDialog::OnInitDialog();
if ( UDSP == NULL)
{
UDSP = new CUDS_Protocol();
}
if ( UDSMW == NULL)
{
UDSMW = new CUDSMainWnd(UDSP->SourceAddress, UDSP->TargetAddress, UDSP->fInterface,UDSP->MsgID,this);
}
//vSetDILInterfacePtr();
//NodeAux=new CNode();
return TRUE;
}
void CMainPanel::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_BUTTON_TO_ABS, m_omButtonToAbsPanel);
DDX_Control(pDX, IDC_BUTTON_TO_DME, m_omButtonToDmePanel);
DDX_Control(pDX, IDC_BUTTON_TO_KOMBI, m_omButtonToKombiPanel);
DDX_Control(pDX, IDC_CHECK_ABS, m_omCheckAbsNode);
DDX_Control(pDX, IDC_CHECK_DME, m_omCheckDmeNode);
DDX_Control(pDX, IDC_CHECK_KOMBI, m_omCheckKombiNode);
}
void CMainPanel::vInitializeMainPanel(){
DIL_GetInterface(CAN, (void**)&Panel_DIL_CAN_Interface);
Panel_DIL_CAN_Interface->DILC_RegisterClient(TRUE, g_dwClientID, _T("CAN_MONITOR"));
}
void CMainPanel::EvaluatePanelsMessage(STCAN_MSG Mensaje ){
PanelAbs->EvaluateMessageReceived(Mensaje);
PanelAndNode1->EvaluateMessageReceived(Mensaje);
PanelDme->EvaluateMessageReceived(Mensaje);
}
/***********************************************************************************************************/
void CMainPanel::SendPanelsMessage(mPSTXSELMSGDATA sMessage)
{
//CUDS_NegRespMng UDSNRM= new CUDS_NegRespMng(omManagerPtr);
//DIL_GetInterface(CAN, (void**)&g_pouDIL_CAN_Interface);
//g_pouDIL_CAN_Interface->DILC_RegisterClient(TRUE, g_dwClientID, _T("CAN_MONITOR"));
int nReturn = Panel_DIL_CAN_Interface->DILC_SendMsg(g_dwClientID, sMessage->m_psTxMsg[0]);
//UDSMW->SendSimpleDiagnosticMessagePanels(sMessage);
}
/***********************************************************************************************************/
void CMainPanel::OnBnClickedOpenAbsPanel(){
AFX_MANAGE_STATE(AfxGetStaticModuleState());
INT_PTR nRet = -1;
CWnd objParent;
//objParent.Attach(this);
//CMainPanel* MPAux = this;
if ( PanelAbs == NULL)
{
PanelAbs = new CPanelAbs(&objParent, this);
//omMainPanel->TotalChannel = TotalChannels;
PanelAbs->Create(IDD_Panel);
//NegRespManager = new CUDS_NegRespMng(omManagerPtr);
FAbs = TRUE;
FAbsInit = FALSE;
m_omCheckAbsNode.SetCheck(1);
}
PanelAbs->ShowWindow(SW_SHOW);
//CWinThread* pomThread = NULL ;
//pomThread = AfxBeginThread( Node1->ContinousMessagesSend);
//objParent.Detach();
//return 0;
//Node1->ContinousMessagesSend();
//Panel1 = new CPanel();
}
/***********************************************************************************************************/
void CMainPanel::OnBnClickedOpenKombiPanel(){
AFX_MANAGE_STATE(AfxGetStaticModuleState());
INT_PTR nRet = -1;
CWnd objParent;
//objParent.Attach(this);
//CMainPanel* MPAux = this;
if ( PanelAndNode1 == NULL)
{
PanelAndNode1 = new CPanelAndNode(&objParent, this);
//omMainPanel->TotalChannel = TotalChannels;
PanelAndNode1->Create(IDD_Panel_Kombi);
//NegRespManager = new CUDS_NegRespMng(omManagerPtr);
FKombi = TRUE;
FKombiInit = FALSE;
m_omCheckKombiNode.SetCheck(1);
}
PanelAndNode1->ShowWindow(SW_SHOW);
//CWinThread* pomThread = NULL ;
//pomThread = AfxBeginThread( Node1->ContinousMessagesSend);
//objParent.Detach();
//return 0;
//Node1->ContinousMessagesSend();
//Panel1 = new CPanel();
}
///////////////////////////////////////////////////////
void CMainPanel::OnBnClickedOpenDmePanel(){
AFX_MANAGE_STATE(AfxGetStaticModuleState());
INT_PTR nRet = -1;
CWnd objParent;
//objParent.Attach(this);
//CMainPanel* MPAux = this;
if ( PanelDme == NULL)
{
PanelDme = new CPanelDme(&objParent, this);
//omMainPanel->TotalChannel = TotalChannels;
PanelDme->Create(IDD_Panel_Dme);
//NegRespManager = new CUDS_NegRespMng(omManagerPtr);
FDme = TRUE;
FDmeInit = FALSE;
m_omCheckDmeNode.SetCheck(1);
}
PanelDme->ShowWindow(SW_SHOW);
//CWinThread* pomThread = NULL ;
//pomThread = AfxBeginThread( Node1->ContinousMessagesSend);
//objParent.Detach();
//return 0;
//Node1->ContinousMessagesSend();
//Panel1 = new CPanel();
}
/**********************************************************************************************************
Function Name :
Description :
Member of : CPanelAndNode
Author(s) : Marc Serra
Date Created : 11.06.2013
**********************************************************************************************************/
unsigned __stdcall TimerFunction(void* a) {
CMainPanel* b = (CMainPanel*) a;
b->currentTime = b->nCalculateCurrTime(FALSE) ;
b->initialTimeRel = b->currentTime;
b->initialTimeSpeed = b->currentTime;
//flagEnvio = TRUE;
//flagEnvio for now... igual es canvia
while (b->flagEnvio){
//Actualize time
b->currentTime = b->nCalculateCurrTime(FALSE);
b->currentTime = b->nCalculateCurrTime(TRUE);
//Falta Cridar a les funcions OnTimerMileRel i OnTimerSpeed
if (FKombi == TRUE){
if(FKombiInit != TRUE){
PanelAndNode1->InitTimers(b->currentTime);
FKombiInit = TRUE;
}else{
PanelAndNode1->TimersCheck(b->currentTime);
/*
if((b->currentTime - b->initialTimeRel) > 100 - 1){
PanelAndNode1->OnTimerKmbi();
//b->initialTimeRel = b->currentTime;
//b->MainP->SendPanelsMessage(b->MessageNode);
}
if((b->currentTime - b->initialTimeSpeed) > 50 - 1 ){
PanelAndNode1->OnTimerInSwcl();
//b->initialTimeSpeed = b->currentTime;
//b->MainP->SendPanelsMessage(b->MessageNode);
}*/
}
}
if (FAbs == TRUE){
if(FAbsInit != TRUE){
PanelAbs->InitTimers(b->currentTime);
FAbsInit = TRUE;
}else{
PanelAbs->TimersCheck(b->currentTime);
/*
if((b->currentTime - b->initialTimeRel) > 100 - 1){
PanelAndNode1->OnTimerKmbi();
//b->initialTimeRel = b->currentTime;
//b->MainP->SendPanelsMessage(b->MessageNode);
}
if((b->currentTime - b->initialTimeSpeed) > 50 - 1 ){
PanelAndNode1->OnTimerInSwcl();
//b->initialTimeSpeed = b->currentTime;
//b->MainP->SendPanelsMessage(b->MessageNode);
}*/
}
}
if (FDme == TRUE){
if(FDmeInit != TRUE){
PanelDme->InitTimers(b->currentTime);
FDmeInit = TRUE;
}else{
PanelDme->TimersCheck(b->currentTime);
/*
if((b->currentTime - b->initialTimeRel) > 100 - 1){
PanelAndNode1->OnTimerKmbi();
//b->initialTimeRel = b->currentTime;
//b->MainP->SendPanelsMessage(b->MessageNode);
}
if((b->currentTime - b->initialTimeSpeed) > 50 - 1 ){
PanelAndNode1->OnTimerInSwcl();
//b->initialTimeSpeed = b->currentTime;
//b->MainP->SendPanelsMessage(b->MessageNode);
}*/
}
}
}
return 0;
}
/////////////////////////////////////////////////////////////////////////
UINT CMainPanel::StartTimer(){
//int id1=11;
flagEnvio= TRUE;
timer = (HANDLE) _beginthreadex(NULL, 0, TimerFunction, this, 0, 0);
//StopTimer();
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
unsigned int CMainPanel::nCalculateCurrTime(BOOL bFromDIL) // Calculates the differential time in sec
{
SYSTEMTIME CurrSysTimes;
UINT64 c_TimeStamp;
if (bFromDIL == FALSE)
{
GetLocalTime(&CurrSysTimes);
}
else
{
//MainP->Panel_DIL_CAN_Interface->DILC_GetTimeModeMapping(CurrSysTimes, c_TimeStamp);
}
unsigned int nResult = (CurrSysTimes.wHour * 3600000 + CurrSysTimes.wMinute * 60000
+ CurrSysTimes.wSecond) * 1000 + CurrSysTimes.wMilliseconds;
return nResult; // Milliseconds
}
/***********************************************************************************************************/
void CMainPanel::OnCheckAbsNode(){
if(m_omCheckAbsNode.GetCheck()==0){
FAbs = false;
}else{
FAbs = true;
}
}
/***********************************************************************************************************/
void CMainPanel::OnCheckDmeNode(){
if(m_omCheckDmeNode.GetCheck()==0){
FDme = false;
}else{
FDme = true;
}
}
/***********************************************************************************************************/
void CMainPanel::OnCheckKombiNode(){
if(m_omCheckKombiNode.GetCheck()==0){
FKombi = false;
}else{
FKombi = true;
}
}
|
223fd3cab466c53eea994124e682f375edbe3651 | 5ca8d2e40aaa9679401721c8ca153c27aeeb8c28 | /AI/Source/AStar.inl | 824c627fe9c9230c71c6f09a3554944902625911 | [] | no_license | HenIsTheMan/AI_A2 | ff33feaaea57228bc2bb6803f627c89dd65e9c44 | 204cae32a07f336c074a6662cd96682bf7bf614d | refs/heads/main | 2023-02-25T11:19:58.070841 | 2021-01-31T15:38:10 | 2021-01-31T15:38:10 | 330,821,076 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,762 | inl | AStar.inl | namespace Algs{
template <class T, typename Type>
struct CreateAStarNodeParams final{
AStarNodeType type = AStarNodeType::Accessible;
std::string tag = std::string();
Type cost = Type();
T pos = T();
};
template <class T, typename Type>
AStar<T, Type>::AStar():
start(nullptr),
end(nullptr),
toVisit(),
visited(),
shortestPath()
{
}
template <class T, typename Type>
AStar<T, Type>::~AStar(){
Reset();
}
template <class T, typename Type>
AStarNode<T, Type>* AStar<T, Type>::CreateNode(const CreateAStarNodeParams<T, Type>& params){
AStarNode<T, Type>* const node = new AStarNode<T, Type>();
node->accessible = !(params.type == AStarNodeType::Inaccessible);
node->tag = params.tag;
node->cost = params.cost;
node->pos = params.pos;
toVisit.emplace_back(node);
return node;
}
template <class T, typename Type>
bool AStar<T, Type>::CalcShortestPath(){
if(!start){
//puts("No start node in path!");
return false;
}
if(!end){
//puts("No end node in path!");
return false;
}
if(toVisit.empty()){
//puts("No nodes in path!");
return false;
}
if(!start->accessible){
return false;
}
if(!end->accessible){
return false;
}
start->gCost = (Type)0;
return ICalcShortestPath();
}
template <class T, typename Type>
void AStar<T, Type>::PrintPath(){
std::string pathText;
const size_t mySize = shortestPath.size();
for(size_t i = 0; i < mySize; ++i){
pathText += shortestPath[i]->tag + '\n';
}
std::cout << pathText << '\n';
}
template <class T, typename Type>
void AStar<T, Type>::Reset(){
size_t i;
const size_t size0 = toVisit.size();
for(i = 0; i < size0; ++i){
AStarNode<T, Type>*& node = toVisit[i];
if(node){
delete node;
node = nullptr;
}
}
start = nullptr;
end = nullptr;
toVisit.clear();
visited.clear();
shortestPath.clear();
}
template <class T, typename Type>
const std::vector<AStarNode<T, Type>*>& AStar<T, Type>::GetShortestPath() const{
return shortestPath;
}
template <class T, typename Type>
bool AStar<T, Type>::ICalcShortestPath(){
std::vector<AStarNode<T, Type>*> open;
open.reserve(toVisit.size());
visited.reserve(toVisit.size());
open.emplace_back(start);
while(true){
AStarNode<T, Type>* curr = nullptr;
for(AStarNode<T, Type>* const element: open){
if(!curr || (curr && element->fCost < curr->fCost)){
curr = element;
}
}
if(curr == nullptr){
return false;
}
open.erase(std::find(open.begin(), open.end(), curr));
visited.emplace_back(curr);
if(curr == end){
return FormShortestPath();
}
const size_t amtOfNeighbours = curr->neighbours.size();
for(size_t i = 0; i < amtOfNeighbours; ++i){
AStarNode<T, Type>* const neighbour = curr->neighbours[i];
if(!neighbour->accessible || std::find(visited.begin(), visited.end(), neighbour) != visited.end()){
continue;
}
const Type gCostNew = curr->gCost + (curr->pos - neighbour->pos).Length() + curr->cost + neighbour->cost;
if(gCostNew < neighbour->gCost || std::find(open.begin(), open.end(), neighbour) == open.end()){
neighbour->gCost = gCostNew;
neighbour->fCost = neighbour->gCost + (end->pos - neighbour->pos).Length() + end->cost + neighbour->cost;
neighbour->parent = curr;
if(std::find(open.begin(), open.end(), neighbour) == open.end()){
open.emplace_back(neighbour);
}
}
}
}
//while(!toVisit.empty()){
// AStarNode<T, Type>* node = toVisit.front();
// if(node == end){
// return FormShortestPath();
// }
// toVisit.erase(toVisit.begin());
// visited.emplace_back(node);
// const size_t amtOfNeighbours = node->neighbours.size();
// for(size_t i = 0; i < amtOfNeighbours; ++i){
// AStarNode<T, Type>* const neighbour = node->neighbours[i];
// const Type gCostNew = node->gCost + (node->pos - neighbour->pos).Length();
// const auto notInToVisit = std::find(toVisit.begin(), toVisit.end(), neighbour) == toVisit.end();
// if((neighbour->accessible && std::find(visited.begin(), visited.end(), neighbour) == visited.end()) && (gCostNew <= neighbour->gCost || notInToVisit)){
// neighbour->gCost = gCostNew;
// neighbour->fCost = neighbour->gCost + (end->pos - neighbour->pos).Length();
// neighbour->parent = node;
// if(notInToVisit){
// toVisit.emplace_back(neighbour);
// }
// }
// }
//}
//return false;
}
template <class T, typename Type>
bool AStar<T, Type>::FormShortestPath(){
if(!end->parent){
return false;
}
AStarNode<T, Type>* curr = end;
while(curr){
shortestPath.emplace_back(curr);
curr = curr->parent;
}
std::reverse(shortestPath.begin(), shortestPath.end());
return true;
}
} |
b9201271cfa6b1963b2f98251f021240a0aaabd6 | deeaa410468f8d0647ddd0c0ba08d80ce9707b9b | /frameworks/C++/drogon/drogon_benchmark/controllers/QueriesCtrlRaw.cc | 4d056a91cbff65f8a3d72ea9f8fa70f4f4e83fb2 | [
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | matt-42/FrameworkBenchmarks | efd8030c3c05dbbebc2ddf9e35e199d560106c1c | a89fe52bbfdc5571dfe29c1f496ec7f5a8814799 | refs/heads/master | 2022-06-20T15:31:11.955582 | 2019-12-20T21:44:41 | 2019-12-20T21:44:41 | 229,323,186 | 1 | 0 | BSD-3-Clause | 2019-12-20T19:20:18 | 2019-12-20T19:20:18 | null | UTF-8 | C++ | false | false | 2,340 | cc | QueriesCtrlRaw.cc | #include "QueriesCtrlRaw.h"
using namespace drogon::orm;
void QueriesCtrlRaw::asyncHandleHttpRequest(
const HttpRequestPtr &req,
std::function<void(const HttpResponsePtr &)> &&callback)
{
// write your application logic here
static std::once_flag once;
std::call_once(once, []() { srand(time(NULL)); });
int queries = 1;
auto ¶meter = req->getParameter("queries");
if (!parameter.empty())
{
queries = atoi(parameter.c_str());
if (queries > 500)
queries = 500;
else if (queries < 1)
queries = 1;
}
auto callbackPtr =
std::make_shared<std::function<void(const HttpResponsePtr &)>>(
std::move(callback));
auto counter = std::make_shared<int>(queries);
if (!*_dbClient)
{
*_dbClient = drogon::app().getFastDbClient();
}
auto jsonStr = std::make_shared<std::string>();
jsonStr->reserve(queries * 36);
jsonStr->append("[", 1);
for (int i = 0; i < queries; i++)
{
int id = rand() % 10000 + 1;
**_dbClient << "select * from world where id=$1" << id >>
[callbackPtr, counter, jsonStr, id](const Result &r) mutable {
(*counter)--;
if (r.size() > 0)
{
char json[64];
auto size = sprintf(json,
"{\"id\":%d,\"randomnumber\":%s}",
id,
r[0][1ul].c_str());
jsonStr->append(json, size);
}
if ((*counter) == 0)
{
jsonStr->append("]", 1);
auto resp = HttpResponse::newHttpResponse();
resp->setContentTypeCode(ContentType::CT_APPLICATION_JSON);
resp->setBody(std::move(*jsonStr));
(*callbackPtr)(resp);
}
else
{
jsonStr->append(",");
}
} >>
[callbackPtr](const DrogonDbException &e) {
Json::Value ret;
ret["result"] = "error!";
auto resp = HttpResponse::newHttpJsonResponse(ret);
(*callbackPtr)(resp);
};
}
} |
674843f7e40e44fe0ca309414c4e7b3f2ff84e82 | 5c7bb681a819c61270556fcd27c8b9cddf1a278a | /stdafx.h | 814fa05658d48343fa5083daefa52753ffbae243 | [] | no_license | Leveltlab/matinterface | 47be68e45955f9153927aa714c2bd404c4de1c4b | a6e065c75dfca16f9ff29d484290e342da5d1c79 | refs/heads/master | 2022-03-26T23:09:29.866033 | 2022-02-09T13:03:13 | 2022-02-09T13:03:13 | 136,925,543 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 318 | h | stdafx.h | #pragma once
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <d3d11.h>
#include <d3dcompiler.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
using namespace std;
#include <DirectXMath.h>
using namespace DirectX;
#include "mytypes.h" |
6396d1def894c03f85a27e5d88b123dcd9914a0a | c990ba64b77b7b4034772fb15a5520a28f1ea5e7 | /copasi/qlayout/CQAnimationControls.h | cdd22968d9aa60ba815356c436849cd87017366f | [
"LicenseRef-scancode-other-copyleft",
"Artistic-2.0",
"LicenseRef-scancode-proprietary-license"
] | permissive | copasi/COPASI | a3fb515b4d9c667519ad756c52d8b82747a26e64 | 3ddf61e95191f2db09256dddc013f12041719a2c | refs/heads/develop | 2023-09-01T19:32:39.004552 | 2023-06-02T15:01:23 | 2023-06-02T15:01:23 | 4,810,881 | 75 | 34 | Artistic-2.0 | 2022-09-14T13:13:20 | 2012-06-27T16:35:48 | Component Pascal | UTF-8 | C++ | false | false | 1,589 | h | CQAnimationControls.h | // Copyright (C) 2019 by Pedro Mendes, Rector and Visitors of the
// University of Virginia, University of Heidelberg, and University
// of Connecticut School of Medicine.
// All rights reserved.
// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.
// Copyright (C) 2013 - 2016 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.
#ifndef QANIMATION_CONTROLS_H
#define QANIMATION_CONTROLS_H
#include <QWidget>
#include <copasi/qlayout/ui_CQAnimationControls.h>
class QTimer;
class CQAnimationControls : public QWidget, public Ui::CQAnimationControls
{
Q_OBJECT
public:
CQAnimationControls(QWidget* parent = NULL);
virtual ~CQAnimationControls();
void setNumSteps(size_t numSteps);
void setCurrentStep(size_t currentStep);
bool isPlaying() const;
public slots:
void slotChangeInterval(int);
void slotBack();
void slotForward();
void slotTogglePlayPause();
void slotStepBack();
void slotStepForward();
void slotStop();
void slotShowStep(int);
signals:
void play();
void pause();
void stop();
void forward();
void backward();
void step_forward();
void step_backward();
void showStep(int);
protected:
size_t mNumSteps;
size_t mCurrentStep;
bool mShouldLoop;
QTimer *mpTimer;
void updateButtons();
void updateActions();
void createActions();
};
#endif // QANIMATION_CONTROLS_H
|
32931e22b9769a2a2b9fa42fd9dbf9d785fc5872 | 1be3169f0dcbdffe20dafe1f438e4cb384db2c99 | /ServoUDPServer/src/server.cpp | 9455d7dbed7f980bc84ee3211f2c369c3bc26c58 | [
"MIT"
] | permissive | noctisilva/Oculus-Rift-Telepresence | a963d3ea08cdb714a30cb6299c3148eba0ff9e83 | 7407897927052ccb8c5f1309bce4ff3aacece1b5 | refs/heads/master | 2021-01-16T20:29:31.617975 | 2015-04-22T13:10:59 | 2015-04-22T13:10:59 | 40,293,117 | 2 | 0 | null | 2015-08-06T08:14:56 | 2015-08-06T08:14:56 | null | UTF-8 | C++ | false | false | 1,433 | cpp | server.cpp | #include "server.h"
#include "servoHandler/servoHandler.h"
#include <boost/atomic.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/asio.hpp>
#include <boost/thread.hpp>
using boost::asio::ip::udp;
using namespace std;
using namespace boost;
boost::atomic<bool> done;
server::server(string servoX, string servoY, int port) {
this->servoX = servoHandler(servoX);
this->servoY = servoHandler(servoY);
this->port=port;
this->maxLength=1024;
this->debug = false;
done = false;
//Start the motors
this->servoX.turnOn();
this->servoY.turnOn();
}
void server::run() {
asio::io_service io_service;
udp::socket sock(io_service, udp::endpoint(udp::v4(), port));
char rawData[maxLength];
while(!done) {
//Receive the packet
udp::endpoint sender_endpoint;
size_t length = sock.receive_from(asio::buffer(rawData, maxLength), sender_endpoint);
//Split the UDP datagrams in floats
vector<string> data;
string strRawData(rawData,length);
split(data,strRawData,is_any_of("/"),token_compress_on);
if(debug)
cout << "X: " << data[0] << " Y: " << data[1] << endl;
servoX.setDuty(atoi(data[0].c_str()));
servoY.setDuty(atoi(data[1].c_str()));
}
}
void server::stop() {
done = true;
servoX.turnOff();
servoY.turnOff();
}
void server::switchDebug() {
this->debug = !debug;
} |
9ea569a0eb3d1676f133809c77ba23098036fdfa | fc8c5c7a93c913a1f1a081441cf5286465a037ec | /DAT205/src/CPUTimer.h | b2cb2cd2f1b2df8fb19082e02c8f536aa03e947d | [
"Apache-2.0"
] | permissive | krabbstek/DAT205 | 4ba5677cf858b37b034f01b27ea1c077efc24607 | c35d03af1737cb1552d98c7ea541273381184170 | refs/heads/master | 2020-04-12T16:59:13.379803 | 2019-06-03T11:58:00 | 2019-06-03T11:58:00 | 162,630,600 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 319 | h | CPUTimer.h | #pragma once
#include "Timer.h"
#include <chrono>
class CPUTimer : public Timer
{
public:
CPUTimer();
~CPUTimer();
void Start() override;
void Stop() override;
void GetTime() override;
private:
std::chrono::high_resolution_clock::time_point m_Start;
std::chrono::high_resolution_clock::time_point m_Stop;
}; |
d5aaa2ed78cd0cea5108e82f843fcf04b5cebce0 | 1580f024f6717a96b5d70edc52aa94f4953b4fcb | /acqu_core/AcquDAQ/src/TDAQexperiment.cc | 66fbfc55e8d2e2e7252d61cafa4b1f93bf570c1f | [] | no_license | A2-Collaboration/acqu | 7531a981cfe98603a14dfef4304312177f2a4072 | b7571696ec72e2b08d64d7640f9ed5a39eddb9f6 | refs/heads/master | 2023-05-01T07:30:06.743357 | 2019-04-03T16:18:35 | 2019-04-03T16:18:35 | 9,445,853 | 1 | 15 | null | 2022-09-09T08:44:08 | 2013-04-15T10:05:39 | C++ | UTF-8 | C++ | false | false | 41,172 | cc | TDAQexperiment.cc | //--Author JRM Annand 30th Sep 2005 Start AcquDAQ
//--Rev JRM Annand... 1st Oct 2005 New DAQ software
//--Rev JRM Annand...10th Feb 2006 1st hardware test version
//--Rev JRM Annand....1st Feb 2007 Integrate with Acqu++
//--Rev JRM Annand...17th May 2007 Virtual Module
//--Rev JRM Annand...29th May 2007 StoreBuffer: ensure buff ptr reset
//--Rev JRM Annand....9th Jun 2007 AddModule SetIndex()
//--Rev JRM Annand....2nd Dec 2007 Link AcquRoot
//--Rev JRM Annand...11th Jan 2008 AddModule procedure, new hardware
//--Rev JRM Annand... 3rd Jun 2008...const Char_t*...gcc 4.3
//--Rev B Oussena 18th Mar 2010 Add modules for Fastbus
//--Rev B Oussena 13th Jul 2010 Add LRS4413SPILL start/stop ctrl
//--Rev JRM Annand...19th Jul 2010..Mods for slave mode and start ctrl
//--Rev JRM Annand... 2nd Sep 2010..Check slave mode RunIRQ, Mk1/2 stuff
//--Rev JRM Annand... 5th Sep 2010..Event Synchronisation module
//--Rev JRM Annand... 6th Sep 2010..Start/trigger mod to superviser
// Implement event ID synch stuff
//--Rev JRM Annand... 7th Sep 2010..Call ResetTrigCtrl end scaler read
//--Rev JRM Annand... 8th Sep 2010..CATCH list for general spy reset
// after TCS reset
//--Rev JRM Annand... 9th Sep 2010..fStartSettleDelay after CATCH reset
// implement PostReset(), add fCtrl
//--Rev JRM Annand...11th Sep 2010..Add class TCAMAC_4413DAQEnable
// and ELRS_2323
//--Rev JRM Annand...12th Sep 2010..NetSlave superviser mode
// Mk1/2 format scaler block
//--Rev JRM Annand... 5th Feb 2011..Flush text buffer StartExperiment
// StoreBuffer() update
//--Rev JRM Annand...12th May 2011..ADC/Scaler error counters
// Local GUI ctrl...part of main prog.
//--Rev JRM Annand... 6th Jul 2011..gcc4.6-x86_64 warning fix
//--Rev B.Oussena .. 24th Nov 2011 correct a bug in AddModule
// at add LRS2323 call
//--Rev JRM Annand... 9th Jan 2012..Baya's bug find..check fNScaler
//--Rev JRM Annand 25th Jan 2012 add GSI 4800 scaler
//--Rev JRM Annand 19th May 2012 add VUPROM
//--Rev JRM Annand 21st May 2012 StoreEvent() mod for nostore mode
// Move TCS reset slow ctrl loop
//--Rev JRM Annand 2nd Sep 2012 Add fEventSendMod..event ID send
//--Rev B. Oussena 9th Nov 2012 sleep(1) after launching data store
//--Rev JRM Annand 9th Jan 2013 add CAEN V874 TAPS module
//--Rev K Livingston..7th Feb 2013 Support for writing EPICS buffers
//--Rev JRM Annand 2nd Mar 2013 EPICS read in conditional block
//--Rev JRM Annand 6th Jul 2013 Add V965 QDC
//--Rev JRM Annand 3rd Sep 2013 Add VITEC interrupt/event-ID card
//--Rev JRM Annand 9th Sep 2013 Add event-ID master functionality
//--Rev JRM Annand 22nd Sep 2013 Add VUPROMT, remove SlowCtrl thread
//--Rev JRM Annand 24nd Sep 2013 Don't start ctrl thread if slave
// End-run scaler read for slaves
//--Rev JRM Annand 29nd Mar 2014 Slave ev-ID read before scaler read
//--Rev JRM Annand 14th Oct 2016 Add TDAQ_VP2ExX86_64
//--Rev JRM Annand 3rd Nov 2016 Add TVME_V785
//--Update JRM Annand 19th Oct 2017 Ensure add TVME_V1290,TDAQ_SIS1100
//
//--Description
// *** AcquDAQ++ <-> Root ***
// DAQ for Sub-Atomic Physics Experiments.
//
// TDAQexperiment
// Container for a complete DAQ session.
// Lists of hardware, configurations methods
// Starts separate threads for event-driven readout, scaler readout
// Slow-control monitoring and control of the experiment
#include "TDAQexperiment.h"
#include "TAcquRoot.h"
#include "ModuleIndex.h"
#include "TDAQguiCtrl.h"
//
#include "TDAQ_V2718.h"
#include "TDAQ_KPhI686.h"
#include "TDAQ_VPE2xX86_64.h" // Concurrent VP2 X86_64 SBC
#include "TDAQ_VPE2xX86_64A.h" // Concurrent VP2 X86_64 SBC
#include "TDAQ_SIS1100.h" // SIS 1100/3100
#include "TVME_CBD8210.h"
#include "TVME_V792.h"
#include "TVME_V775.h"
#include "TVME_V785.h"
#include "TVME_V874.h"
#include "TVME_V1190.h"
#include "TVME_V1290.h"
#include "TCAMACmodule.h"
#include "TCAMAC_4508.h"
#include "TCAMAC_2373.h"
#include "TCAMAC_2323.h" // <--- Nov 24th/11 Baya
#include "TCAMAC_4413SPILL.h" // < ---Jul 13/10 Baya
#include "TCAMAC_4413DAQEnable.h"
#include "TCAMAC_GSI4800.h"
#include "TVME_CATCH_TDC.h"
#include "TVME_CATCH_Scaler.h"
#include "TVME_CATCH_TCS.h"
#include "TVME_GeSiCA.h"
#include "TVME_KPhSMI.h"
#include "TFBmodule.h"
#include "TFB_1821SMI.h"
#include "TFB_LRS1800.h"
#include "TFB_STR200.h"
#include "TVirtualModule.h"
#include "TVME_VUPROM.h"
#include "TVME_VUPROMT.h"
#include "TVME_VUPROM_Scaler.h"
#include "TVME_VUPROM_Moeller.h"
#include "TVME_VUPROM_Pattern.h"
#include "TVME_SIS3820.h"
#include "TEPICSmodule.h"
#include "TVME_V965.h"
#include "TVME_VITEC.h"
// recognised setup keywords
enum { EExpModule, EExpControl, EExpIRQCtrl, EExpStartCtrl, EExpDescription,
EExpDataOut, EExpEvCnt, EExpDesc, EExpFName, EExpRunStart,
EExpLocalAR, EExpMk1DataFormat, EExpSynchCtrl, EExpResetCtrl,
EExpEventIDSend, EExpEventIDMaster, EExpEndTimeOut };
static Map_t kExpKeys[] = {
{"Control:", EExpControl}, // mode of operator control
{"Module:", EExpModule}, // add electronic module
{"IRQ-Ctrl:", EExpIRQCtrl}, // specify trigger control module
{"Start-Ctrl:", EExpStartCtrl}, // specify trigger control module
{"Event-Counters:",EExpEvCnt}, // event counters
{"Description:", EExpDesc}, // DAQ description
{"File-Name:", EExpFName}, // file name basis
{"Start-Run:", EExpRunStart}, // start run number
{"Local-AR:", EExpLocalAR}, // special for GUI control
{"Mk1-Format:", EExpMk1DataFormat}, // switch to Mk1 data format
{"Synch-Ctrl:", EExpSynchCtrl}, // event-number synchronisation
{"Reset-Ctrl:", EExpResetCtrl}, // reset current control module
{"EventID-Send:", EExpEventIDSend}, // module to send event ID to remote
{"EventID-Master:",EExpEventIDMaster}, // has control of the event ID
{"RunEndTimeOut:", EExpEndTimeOut}, //
//--Update JRM Annand 24th Sep 2013 set fIRQMod from exp->PostInit()
{NULL, -1}
};
//-----------------------------------------------------------------------------
TDAQexperiment::TDAQexperiment( const Char_t* name, const Char_t* input, const Char_t* log,
TAcquRoot* ar, Int_t initLevel):
TA2System( name, kExpKeys, input, log )
{
// Base initialisation of DAQ object
// Setup input config stream if file name supplied
// Save log output stream....use standard out (tty) if not supplied
//
fAR = ar;
fSupervise = NULL;
fStore = NULL;
fOutBuff = NULL;
fEventBuff = NULL;
fModuleList = new TList;
fADCList = new TList;
fScalerList = new TList;
fCtrlList = new TList;
fSlowCtrlList = new TList;
fCATCHList = NULL;
fEPICSList = new TList;
fEPICSTimedList = new TList;
fEPICSCountedList = new TList;
fEPICSTriggeredList = new TList;
fIRQModName = fStartModName = fSynchModName = fEventSendModName = NULL;
fIRQMod = fStartMod = fSynchMod = fCtrlMod = fEventSendMod = NULL;
fSynchIndex = -1;
fStartSettleDelay = 0;
fNModule = fNADC = fNScaler = fNCtrl = fNSlowCtrl =
fNEPICS = fNEPICSTimed = fNEPICSCounted = fNEPICSTriggered = 0;
fDataOutMode = EStoreDOUndef;
fScReadFreq = 0;
fSlCtrlFreq = 0;
fRingSize = fRecLen = fNRec = fNRecMax = 0;
fDataHeader = EMk2DataBuff;
fIsSwap = fIsSlowCtrl = fIsCtrl = fIsStore = fIsLocalAR =
fIsEvIDMaster = kFALSE;
fInitLevel = initLevel;
fNADCError = fNScalerError = 0;
// fIsTrigCtrl = kFALSE;
// default strings
strcpy( fRunDesc, "AcquDAQ Experimental Data, in MkII format\n" );
strcpy( fFileName, "AcquDAQ" );
fIRQThread = NULL; // ensure thread pointers NULLed
fSlowCtrlThread = NULL;
fDAQCtrlThread = NULL;
fStoreDataThread = NULL;
fRunStart = -1;
fTimeOut = 0; // don't apply any timeout
fNEvent = 0;
}
//-----------------------------------------------------------------------------
TDAQexperiment::~TDAQexperiment()
{
// Tidy up memory and opened files
// incomplete...
if( fLogStream ) fclose(fLogStream);
if( fModuleList ){
TIter next( fModuleList );
TDAQmodule* mod;
while( ( mod = (TDAQmodule*)next() ) ) delete mod;
delete fModuleList;
}
}
//-----------------------------------------------------------------------------
void TDAQexperiment::SetConfig(Char_t* line, Int_t key )
{
// DAQ configuration from a line of text (file or tty)
// The line is already parsed for a keyword, which sets key
Char_t mode[32];
switch( key ){
case EExpControl:
// Decide on mode of control...local keyboard, network etc.
if( sscanf( line,"%s",mode ) < 1 ){
PrintError( line,"<Parse superviser I/O mode>",EErrFatal);
}
if( !fSupervise ){
if( !strcmp( mode, "GUI-Net" ) )
fSupervise = new TGUIsupervise((Char_t*)"GUI-superviser",this,line);
else
fSupervise = new TDAQsupervise((Char_t*)"DAQ-superviser",this,line);
}
fIsCtrl = !(fSupervise->IsSlave()); // Control enabled if not a slave
break;
case EExpModule:
// add hardware to the experiment
AddModule(line);
break;
case EExpIRQCtrl:
// Interrupt control module
if( sscanf( line,"%s",mode ) < 1 ){
PrintError( line,"<Parse IRQ module>",EErrFatal);
}
fIRQModName = BuildName( mode );
break;
case EExpStartCtrl:
// Trigger start/stop control module
if( sscanf( line,"%s%d",mode, &fStartSettleDelay ) < 2 ){
PrintError( line,"<Parse Trigger-Start/Stop module>",EErrFatal);
}
fStartModName = BuildName( mode );
break;
case EExpSynchCtrl:
// Event number synchronisation control module and synch value index
if( sscanf( line,"%s%d",mode, &fSynchIndex ) < 2 ){
PrintError( line,"<Parse Event Synch module & Index>",EErrFatal);
}
fSynchModName = BuildName( mode );
break;
case EExpResetCtrl:
// Reset current control module...module must already be declared
if( sscanf( line,"%s",mode ) < 1 ){
PrintError( line,"<Parse reset current control module>",EErrFatal);
}
fCtrlMod = (TDAQmodule*)( fModuleList->FindObject( mode ) );
if( !fCtrlMod )
PrintError(fIRQModName,"<Reset control module hardware not found>",
EErrFatal);
break;
case EExpEventIDSend:
// Module to send event ID
if( sscanf( line,"%s",mode ) < 1 ){
PrintError( line,"<Parse event ID send module>",EErrFatal);
}
fEventSendModName = BuildName( mode );
break;
case EExpEventIDMaster:
// This class has control of the event ID, rather than extern hardware
if( sscanf( line,"%d",&fSynchIndex ) < 1 ){
PrintError( line,"<Parse Event Synch Index for Master>",EErrFatal);
}
fIsEvIDMaster = kTRUE;
break;
case EExpEvCnt:
// event counters
if( sscanf( line,"%d%d", &fScReadFreq,&fSlCtrlFreq ) < 2 ){
PrintError( line,"<Parse Event Counters>",EErrFatal);
}
if( fSlCtrlFreq ) fIsSlowCtrl = kTRUE;
break;
case EExpDesc:
// one-line description of the experiment
for(Int_t i=0; i<EMk2SizeDesc; i++) fRunDesc[i] = 0;
strcpy(fRunDesc, line);
break;
case EExpFName:
// file name basis, assume data storage if this command given
for(Int_t i=0; i<EMk2SizeFName; i++) fFileName[i] = 0;
if( sscanf( line,"%s%d%d%d",fFileName, &fRingSize,
&fNRecMax, &fRecLen ) < 4 )
PrintError(line, "<Data output file name not parsed>", EErrFatal);
if( !fIsLocalAR )
fStore = new TDAQstore((Char_t*)"DAQ-storage", NULL, fLogStream, line);
fIsStore = fStore->IsStore();
break;
case EExpRunStart:
// starting run number
if( sscanf(line,"%d",&fRunStart) != 1 )
PrintError(line,"<Parse start run number line>");
break;
case EExpLocalAR:
// flag that DAQ is run as a thread of AcquRoot analyser
fIsLocalAR = kTRUE;
break;
case EExpMk1DataFormat:
// Switch data format to AcquRoot Mk1. Default is Mk2 AcquRoot
fDataHeader = EDataBuff;
break;
case EExpEndTimeOut:
// set Supervisor timeout (in usleep() to wait for end condition
// apply when running single DAQ node to avoid end-run lockup
if( sscanf(line,"%d",&fTimeOut) != 1 )
PrintError(line,"<Parse Time Out specification");
break;
default:
PrintError(line,"<Unrecognised configuration keyword>");
break;
}
}
//-----------------------------------------------------------------------------
void TDAQexperiment::PostInit( )
{
// Call PostInit procedures of all modules (if any)
// Check for interrupt and trigger start/stop modules
// Setup DAQ supervisor and data storage
if( !fNModule ) return;
if( fModuleList ){
TIter next( fModuleList );
TDAQmodule* mod;
while( ( mod = (TDAQmodule*)next() ) ) mod->PostInit();
}
if (fInitLevel != 2) //<<------------------------------- Baya
{
// Interrupt controller
if( !fIRQModName )
PrintError("","<Trigger (IRQ) hardware not specified>",EErrFatal);
fIRQMod = (TDAQmodule*)( fModuleList->FindObject( fIRQModName ) );
if( !fIRQMod )
PrintError(fIRQModName,"<Trigger (IRQ) hardware not found>",EErrFatal);
// DAQ start/stop controller
if( fStartModName ){
fStartMod = (TDAQmodule*)( fModuleList->FindObject( fStartModName ) );
if( !fStartMod )
PrintError(fIRQModName,"<DAQ Start/Stop hardware not found>",EErrFatal);
}
// Check if DAQ synch is by a number supplied by external hardware
if( fSynchModName ){
fSynchMod = (TDAQmodule*)( fModuleList->FindObject( fSynchModName ) );
if( !fSynchMod )
PrintError(fIRQModName,"<DAQ Event Synchronisation hardware not found>",
EErrFatal);
}
// check if event ID has to be sent explicitly to a remote system
if( fEventSendModName ){
fEventSendMod =
(TDAQmodule*)( fModuleList->FindObject( fEventSendModName ) );
if( !fEventSendMod )
PrintError(fIRQModName,"<DAQ Event ID send hardware not found>",
EErrFatal);
if(fSynchMod) fSynchMod->SetEventSendMod( fEventSendMod );
}
// If this class determines the event ID number then there must be a
// module defined to send it to the rest of the DAQ system
// If fSynchMod has been defined then undefine it, as it will screw up
// what the mast sends
if( fIsEvIDMaster ){
if( !fEventSendMod ){
PrintError("TDAQexperiment","<EvID master: no Event ID send hardware>",
EErrFatal);
}
if( fSynchMod ){
PrintError(fSynchModName,"<EVID master: fSynchMod set NULL>");
fSynchMod = NULL;
}
}
// DAQ supervisor....it may already be created...
// if so ensure that it has trigger control (if this exists)
// also ensure that it has the IRQ module
if( !fSupervise ){
fSupervise = new TDAQsupervise((Char_t*)"DAQ-superviser",this,
(Char_t*)"Local 0 0");
}
if( fStartMod ) fSupervise->SetTrigMod( fStartMod );
if( fIRQMod ) fSupervise->SetIRQMod( fIRQMod );
if( fTimeOut ) fSupervise->SetTimeOut( fTimeOut );
// Data storage
if( fStore ) fStore->PostInit();
fOutBuff = new TA2RingBuffer( fRecLen, fRingSize );
if( fStore ) fStore->SetOutBuff( fOutBuff );
fOutBuff->WaitEmpty();
fEventBuff = new Char_t[fOutBuff->GetLenBuff()];
} //<<------------------------------------------Baya
}
//-----------------------------------------------------------------------------
void TDAQexperiment::AddModule( Char_t* line )
{
// Setup software control of particular piece of hardware
// Add it to the experimental list
Char_t module[128];
Char_t name[128];
Char_t file[128];
if( sscanf( line, "%s%s%s", module, name, file ) != 3 ){
PrintError( line, "<Parse hardware module>" );
return;
}
Int_t key = Map2Key( module, (Map_t*)kExpModules );
if( key == -1 ){
PrintError( module, "<Unknown hardware module>" );
return;
}
TDAQmodule* mod;
switch( key ){
case ECAEN_V2718:
// PCI - VMEbus controller (primary controller)
mod = new TDAQ_V2718( name, file, fLogStream, line);
break;
case EKPH_I686:
// KPH, Pentium M based, SBC VMEbus controller (primary controller)
mod = new TDAQ_KPhI686( name, file, fLogStream, line);
break;
case EVPE2xX86_64:
// Concurrent quad X86_64, SBC VMEbus controller (primary controller)
mod = new TDAQ_VPE2xX86_64( name, file, fLogStream, line);
break;
case EVPE2xX86_64A:
// Concurrent quad X86_64, SBC VMEbus controller (primary controller)
mod = new TDAQ_VPE2xX86_64A( name, file, fLogStream, line);
break;
case ESIS_1100:
// SIS 1100/3100 Optical PCI - VME link
mod = new TDAQ_SIS1100( name, file, fLogStream, line);
break;
case EVMEbus:
// Generic VMEbus module
mod = new TVMEmodule( name, file, fLogStream, line);
break;
case ECBD_8210:
// VMEbus - CAMAC parallel branch driver (secondary controller)
mod = new TVME_CBD8210( name, file, fLogStream, line );
break;
case EKPH_SMI:
// VMEbus to Fastbus SMI register map
mod = new TVME_KPhSMI( name, file, fLogStream, line );
break;
case EKPH_VITEC:
// Interrupt and event-ID handler
mod = new TVME_VITEC( name, file, fLogStream, line );
break;
case ECAEN_V792:
// VMEbus - CAEN 32 channel QDC
mod = new TVME_V792( name, file, fLogStream, line );
break;
case ECAEN_V965:
// VMEbus - CAEN 16 channel dual-range QDC
mod = new TVME_V965( name, file, fLogStream, line );
break;
case ECAEN_V775:
// VMEbus - CAEN 32 channel TDC
mod = new TVME_V775( name, file, fLogStream, line );
break;
case ECAEN_V785:
// VMEbus - CAEN 32 channel VDC
mod = new TVME_V785( name, file, fLogStream, line );
break;
case ECAEN_V874:
// VMEbus - CAEN 4 channel TAPS module
mod = new TVME_V874( name, file, fLogStream, line );
break;
case ECAEN_V1190:
// VMEbus - CAEN 128 channel, multi-hit TDC, 100 ps resolution
mod = new TVME_V1190( name, file, fLogStream, line );
break;
case ECAEN_V1290:
// VMEbus - CAEN 32 channel, multi-hit TDC, 25 ps resolution
mod = new TVME_V1290( name, file, fLogStream, line );
break;
case ECATCH_TDC:
// VMEbus/CATCH - 128 channel, multi-hit TDC
if( !fCATCHList ) fCATCHList = new TList();
mod = new TVME_CATCH_TDC( name, file, fLogStream, line );
fCATCHList->AddLast( mod ); // add to list
break;
case ECATCH_SCA:
// VMEbus/CATCH - 128 channel scaler
if( !fCATCHList ) fCATCHList = new TList();
mod = new TVME_CATCH_Scaler( name, file, fLogStream, line );
fCATCHList->AddLast( mod ); // add to list
break;
case ECATCH_TCS:
// VMEbus/CATCH - Trigger Controller
mod = new TVME_CATCH_TCS( name, file, fLogStream, line );
break;
case EGeSiCA:
// VMEbus/CATCH - Trigger Controller
mod = new TVME_GeSiCA( name, file, fLogStream, line );
break;
case EGSI_VUPROM:
// VMEbus/CATCH - Trigger Controller
mod = new TVME_VUPROM( name, file, fLogStream, line );
break;
case EGSI_VUPROMT:
// VMEbus/CATCH - Trigger Controller (TAPS version)
mod = new TVME_VUPROMT( name, file, fLogStream, line );
break;
case EGSI_VUPROM_Scaler:
// VUPROM Simple scaler module
mod = new TVME_VUPROM_Scaler( name, file, fLogStream, line );
break;
case EGSI_VUPROM_Moeller:
// VUPROM Moeller module
mod = new TVME_VUPROM_Moeller( name, file, fLogStream, line );
break;
case EGSI_VUPROM_Pattern:
// VUPROM Simple Pattern module
mod = new TVME_VUPROM_Pattern( name, file, fLogStream, line );
break;
case ESIS_3820:
// SIS 3820 I/O register and scaler
mod = new TVME_SIS3820( name, file, fLogStream, line );
break;
case ECAMAC:
// General CAMAC module. No specialist initialisation or read out
mod = new TCAMACmodule( name, file, fLogStream, line );
break;
case ELRS_4508:
// LeCroy 4508 MLU
mod = new TCAMAC_4508( name, file, fLogStream, line );
break;
case ELRS_2373:
// LeCroy 2373 MLU
mod = new TCAMAC_2373( name, file, fLogStream, line );
break;
case ELRS_2323:
// LeCroy 2323 Gate and Delay
mod = new TCAMAC_2323( name, file, fLogStream, line ); //<<--- baya was TCAMAC_2373
break;
case ELRS_4413SPILL:
// LeCroy 4413 discriminator...special for trigger start/stop operations
mod = new TCAMAC_4413SPILL( name, file, fLogStream, line );
break;
case ELRS_4413DAQEnable:
// LeCroy 4413 discriminator...special for trigger start/stop operations
mod = new TCAMAC_4413DAQEnable( name, file, fLogStream, line );
break;
case EGSI_4800:
// GSI 4800 48 channel CAMAC scaler
mod = new TCAMAC_GSI4800( name, file, fLogStream, line );
break;
case ELRS_1821:
// Fastbus- LRS1821 Segment Manager Interface
mod = new TFB_1821SMI( name, file, fLogStream, line );
break;
case ELRS_1800:
// Fastbus- LRS18XX QDCs TDCs
mod = new TFB_LRS1800( name, file, fLogStream, line );
break;
/*
case ELRS_1875:
// Fastbus- LRS1875 TDC
mod = new TFB_LRS1875( name, file, fLogStream, line );
break;
*/
case ESTR_200:
// Fastbus- STRUCK 200 SCALER
mod = new TFB_STR200( name, file, fLogStream, line );
break;
case EDAQ_Virtual:
// Virtual Module...input line contains type (ADC, scaler etc.)
mod = new TVirtualModule( name, file, fLogStream, line );
break;
case EDAQ_Epics:
// Epics Module...input line contains type (ADC, scaler etc.)
if(!IsMk2Format()){ //Exit if trying to include EPICS with mk1 format.
PrintError( module, "EPICS modules can only be used in Mk2 format",EErrFatal);
}
else{
mod = new TEPICSmodule( name, file, fLogStream, line);
}
break;
default:
PrintError( module, "<Unknown hardware module>" );
return;
}
// Save ID and index
mod->SetID( key ); // AcquDAQ ID
mod->SetIndex( fNModule ); // module list index
mod->SetInitLevel( fInitLevel ); // level hardware initialisation
mod->SetDAQexperiment( this ); // link back to this
// Check if module if controller or interface
// If not save pointer to its immediate controller
if( mod->IsType( EDAQ_Ctrl ) ){
fCtrlMod = mod; // primary controller
fCtrlList->AddLast( mod ); // add to list
fNCtrl++;
}
if( mod->IsType( EDAQ_SCtrl ) ){ // secondary controller
mod->SetCtrl( fCtrlMod ); // save upper controller
fCtrlMod = mod; // and reset self as ctrl
fCtrlList->AddLast( mod );
fNCtrl++;
}
else mod->SetCtrl( fCtrlMod ); // slave store immediate ctrl
// Configure Module from file
mod->FileConfig( file ); // parameters from file
if( mod->IsType( EDAQ_ADC ) ){ // ADC module
fADCList->AddLast( mod );
fNADC++;
}
if( mod->IsType( EDAQ_Scaler ) ){ // Scaler module
fScalerList->AddLast( mod );
fNScaler++;
}
if( mod->IsType( EDAQ_SlowCtrl ) ){ // Slow control module
fSlowCtrlList->AddLast( mod );
fNSlowCtrl++;
}
if( mod->GetType() == EDAQ_Epics){ // EPICS module
fEPICSList->AddLast( mod );
((TEPICSmodule *)mod)->SetEpicsIndex(fNEPICS++);
if( ((TEPICSmodule *)mod)->IsTimed()){
fEPICSTimedList->AddLast( mod );
fNEPICSTimed++;
}
else if(((TEPICSmodule *)mod)->IsCounted()){
fEPICSCountedList->AddLast( mod );
fNEPICSCounted++;
}
else if(((TEPICSmodule *)mod)->IsTriggered()){
fEPICSTriggeredList->AddLast( mod );
fNEPICSTriggered++;
}
}
fModuleList->AddLast( mod ); // all modules
fNModule++;
}
//---------------------------------------------------------------------------
void TDAQexperiment::StartExperiment()
{
// Start the various threads which comprise the DAQ system running
// but may produce an occasional message.
// 1st data storage (if enabled)
// 2nd slow-control functions (if enabled)
// 3rd interrupt-driven readout (if enabled)
// Then start the superviser command loop for control of the DAQ
fflush(fLogStream);
if( fNModule ){
// Data storage
if( fIsStore && (!fIsLocalAR) ){
if( !fStore ){
PrintError("","<Start data-store thread before TDAQstore initialised>");
return;
}
if( fStoreDataThread ){
printf(" Warning...deleting old StoreDataThread and starting new one\n");
fStoreDataThread->Delete();
}
fStoreDataThread = new TThread( "RunStoreDataThread",
(void(*) (void*))&(RunStoreDataThread),
(void*)this );
fStoreDataThread->Run();
sleep(1); // Inserted by Baya....otherwise seg. fault problems
}
// Slow-control procedures....removed 22/9/13...was doing nothing
/*
if( fIsSlowCtrl ){
if( fSlowCtrlThread ){
printf(" Warning...deleting old SlowCtrlThread and starting new one\n");
fSlowCtrlThread->Delete();
}
fSlowCtrlThread = new TThread( "RunSlowCtrlThread",
(void(*) (void*))&(RunSlowCtrlThread),
(void*)this );
fSlowCtrlThread->Run();
}
*/
// Interrupt-driven readout
if( fIRQMod ){
if( fIRQThread ){
printf(" Warning...deleting old IRQThread and starting new one\n");
fIRQThread->Delete();
}
fIRQThread = new TThread( "RunIRQThread",
(void(*) (void*))&(RunIRQThread),
(void*)this );
fIRQThread->Run();
}
}
// DAQ control command loop
if( fSupervise->GetExpCtrlMode() == EExpCtrlGUILocal )
fSupervise->CommandLoop();
else if(fSupervise->GetExpCtrlMode() != EExpCtrlSlave){
if( fDAQCtrlThread ){
printf(" Warning...deleting old IRQThread and starting new one\n");
fDAQCtrlThread->Delete();
}
fDAQCtrlThread = new TThread("RunDAQCtrlThread",
(void(*) (void*))&(RunDAQCtrlThread),
(void*)this );
fDAQCtrlThread->Run();
}
return;
}
//---------------------------------------------------------------------------
void TDAQexperiment::RunIRQ()
{
// Event-by-event readout of data
// 1/9/10 if running slave mode call fSupervise->ExecAutoStart()
//
if( !(fNADC + fNScaler) ){
printf("Warning: <RunIRQ: no IRQ modules loaded>\n");
}
TIter nexta( fADCList );
TIter nexts( fScalerList );
TIter nextc( fSlowCtrlList );
TIter nexte( fEPICSList );
TIter nextet( fEPICSTimedList );
TIter nextec( fEPICSCountedList );
TIter nextetr( fEPICSTriggeredList );
TDAQmodule* mod;
void* out; // output buffer pointer
Int_t scCnt = 0;
Int_t slCtrlCnt = 0;
Int_t* scLen;
Bool_t scEpicsFlag = kFALSE; //for epics to know it was a scaler read.
Int_t* evLen; // place to put event length
Int_t adcEnd; // index of last adc in event buffer
UShort_t* evID; // place to put event ID info
fIsRunTerm = kFALSE; // ensure run terminated flag off
// If in slave mode run the autostart procedure, bypass any local control
if( (fSupervise->GetExpCtrlMode() == EExpCtrlSlave) ||
(fSupervise->GetExpCtrlMode() == EExpCtrlNetSlave) )
fSupervise->ExecAutoStart();
UInt_t nevID = 0;
UInt_t nevIDprev = 0;
UInt_t readoutPatternOffset = fSynchMod ?
fSynchMod->GetReadoutPatternOffset() :
0;
for( ; ; ){
fIRQMod->WaitIRQ();
out = fEventBuff;
BuffStore(&out, fNEvent);
// Mk2 data format only
if( IsMk2Format() ){
evLen = (Int_t*)out;
out = evLen + 1;
}
// If this class controls the event ID
// send it off before doing anything else
// If end-of-run detected set msb of event ID
if( fIsEvIDMaster ){
if( fSupervise->IsRunTerm() && fIsStore ){ // end of run detected?
fIsRunTerm = kTRUE; // local end-of-run flag
nevID |= EExpEvIDEnd; // set the msb
scCnt = fScReadFreq - 1; // force a scaler read
}
fEventSendMod->SendEventID(nevID);
evID = (UShort_t*)out;
*evID = fSynchIndex; evID++; // save event ID index
*evID = nevID; evID++; // save event ID number
out = evID;
nevID++;
if(nevID > 0xffff) nevID = nevIDprev = 0; // reset the event ID
}
// Space for synchronisation event ID (if this is defined)
// and readout pattern
else if( fSynchMod ){
evID = (UShort_t*)out;
if(readoutPatternOffset>0) {
out = evID + 8; // four 16bit ADC indeces and values
}
else {
out = evID + 2; // three 16bit ADC index and value
}
}
scCnt++;
slCtrlCnt++;
nexta.Reset();
while( ( mod = (TDAQmodule*)nexta() ) ) mod->ReadIRQ(&out);
adcEnd = (Int_t)((Char_t*)out - fEventBuff);
// Move slave event ID stuff here before scaler and EPICS read
// so that detection of end-of-run in the slave event ID can trigger
// a scaler read etc.
// JRMA 29/3/14
if( fSynchMod ){
// event id
*evID = fSynchIndex; evID++;
nevID = fSynchMod->GetEventID();
*evID = nevID;
// readout bitpattern (for TAPS only)
if(readoutPatternOffset>0) {
// move to the next 16bit word
evID++;
UInt_t status = fSynchMod->GetReadoutPatternStatus();
UInt_t readoutPattern = fSynchMod->GetReadoutPattern();
*evID = readoutPatternOffset+fSynchIndex+0; evID++;
*evID = status & 0xffff; evID++; // status reg
*evID = readoutPatternOffset+fSynchIndex+1; evID++;
*evID = readoutPattern & 0xffff; evID++; // lower 16bit
*evID = readoutPatternOffset+fSynchIndex+2; evID++;
*evID = (readoutPattern >> 16) & 0xffff; // upper 16 bit
// evID++ not needed here, it's the last 16bit word
}
// Check if end-of-run marker supplied and data storage enabled
if((nevID & EExpEvIDEnd) && fIsStore ){
fIsRunTerm = kTRUE;
scCnt = fScReadFreq; // force a scaler read
}
}
// Check if scaler read due. If so loop round linked list of scaler modules
// If a trigger control module is defined run its ResetTrigCtrl method
// after the scaler read is performed
// JRMA add check on fNScaler 9/2/12
if( (scCnt == fScReadFreq) && (fNScaler) ){
BuffStore(&out, EScalerBuffer); // scaler-buffer marker
if( IsMk2Format() ){
scLen = (Int_t*)out; // scaler-buffer size Mk2 only
out = scLen + 1; // update buffer ptr
}
nexts.Reset();
while( ( mod = (TDAQmodule*)nexts() ) ) mod->ReadIRQScaler(&out);
// Scaler-block length & end of scaler block marker Mk2 data format only
if( IsMk2Format() ){
*scLen = (Char_t*)out - (Char_t*)scLen; // save buffer size
BuffStore(&out, EScalerBuffer);// scaler-end marker
}
scCnt = 0; // reset scaler counter
scEpicsFlag=kTRUE; // flag for epics that this was a scaler read event
}
if( (slCtrlCnt == fSlCtrlFreq) && (fNSlowCtrl) ){
nextc.Reset();
while( ( mod = (TDAQmodule*)nextc() ) ) mod->ReadIRQSlow(&out);
slCtrlCnt = 0;
// If there is a TCS reset it. After that do any other necessary resetting
// e.g. any CATCH TDCs or scaler must also have their spy buffers reset
if( fStartMod ){
fStartMod->ResetTrigCtrl(); // trigger control reset
}
}
//------------------------------------------------------------------------
// Start of EPICS stuff
// Check if any timed EPICS reads due - a separate buffer for each
// If there's more than one due (unlikely but possible)
// We'll only be here if it's Mk2 format, otherwise exited earlier fatally.
// Enter this block only if there is some EPICS in the system
if( fNEPICS ){
//if 1st event, read all EPICS modules then start timers & counters
if(fNEvent==0){
nexte.Reset();
while( ( mod = (TDAQmodule*)nexte() ) ){ // loop all epics modules
BuffStore(&out, EEPICSBuffer); // epics-buffer marker
((TEPICSmodule*)mod)->WriteEPICS(&out); // write
}
//start any EPICS timers / counters
nextet.Reset(); // ones timed in ms
while( ( mod = (TDAQmodule*)nextet() ) ){
((TEPICSmodule*)mod)->Start();
}
nextec.Reset(); // ones counted in scaler reads
while( ( mod = (TDAQmodule*)nextec() ) ){
((TEPICSmodule*)mod)->Start();
}
}
//
nextetr.Reset();
while( ( mod = (TDAQmodule*)nextetr() ) ){ // loop triggered epics modules
if(fNEvent>0){ // already recorded for event 0
if(((TEPICSmodule*)mod)->IsTriggeredOut(fEventBuff,adcEnd)){ // Check if read is triggered
BuffStore(&out, EEPICSBuffer); // epics-buffer marker
((TEPICSmodule*)mod)->WriteEPICS(&out); // write
}
}
}
//
nextet.Reset();
while( ( mod = (TDAQmodule*)nextet() ) ){ // loop timed epics modules
if(((TEPICSmodule*)mod)->IsTimedOut()){ // Check if read is due
BuffStore(&out, EEPICSBuffer); // epics-buffer marker
((TEPICSmodule*)mod)->WriteEPICS(&out); // write
((TEPICSmodule*)mod)->Start(); // restart the timer
}
}
//
//Now if it was a scaler event, see in any scaler counted EPICS reads
if( (scEpicsFlag) && (fNScaler) ){
nextec.Reset();
while( ( mod = (TDAQmodule*)nextec() ) ){
((TEPICSmodule*)mod)->Count(); // increment EPICS counter
if(((TEPICSmodule*)mod)->IsCountedOut()){ // if counted out
BuffStore(&out, EEPICSBuffer);// epics-buffer marker
((TEPICSmodule*)mod)->WriteEPICS(&out); // write
((TEPICSmodule*)mod)->Start(); // restart the counter
}
}
scEpicsFlag=kFALSE; //reset the flag
}
}
//-end of EPICS block
//-----------------------------------------------------------------------
if( IsMk2Format() ) *evLen = (Char_t*)out - (Char_t*)evLen;
// Event ID determined by external hardware...get the ID from that module
// Move this block upstream JRMA 29/3/14
/*
if( fSynchMod ){
// event id
*evID = fSynchIndex; evID++;
nevID = fSynchMod->GetEventID();
*evID = nevID;
// readout bitpattern (for TAPS only)
if(readoutPatternOffset>0) {
// move to the next 16bit word
evID++;
UInt_t status = fSynchMod->GetReadoutPatternStatus();
UInt_t readoutPattern = fSynchMod->GetReadoutPattern();
*evID = readoutPatternOffset+fSynchIndex+0; evID++;
*evID = status & 0xffff; evID++; // status reg
*evID = readoutPatternOffset+fSynchIndex+1; evID++;
*evID = readoutPattern & 0xffff; evID++; // lower 16bit
*evID = readoutPatternOffset+fSynchIndex+2; evID++;
*evID = (readoutPattern >> 16) & 0xffff; // upper 16 bit
// evID++ not needed here, it's the last 16bit word
}
// Check if end-of-run marker supplied and data storage enabled
if((nevID & EExpEvIDEnd) && fIsStore ){
fIsRunTerm = kTRUE;
// if there are scaler on the system do a scaler read
//
//if(fNScaler){
// BuffStore(&out, EScalerBuffer); // scaler-buffer marker
// if( IsMk2Format() ){
// scLen = (Int_t*)out; // scaler-buffer size Mk2 only
// out = scLen + 1; // update buffer ptr
// }
// nexts.Reset();
// while( ( mod = (TDAQmodule*)nexts() ) ) mod->ReadIRQScaler(&out);
// Scaler-block length & end of scaler block marker Mk2 data format
// if( IsMk2Format() ){
// *scLen = (Char_t*)out - (Char_t*)scLen; // save buffer size
// BuffStore(&out, EScalerBuffer); // scaler-end marker
// }
// scCnt = 0; // reset scaler counter
// scEpicsFlag=kTRUE;// flag for epics that this was a scaler read event
// }
}
}
*/
if(nevID>0 && nevID != (nevIDprev+1) )
printf("nevID=%d nevIDprev=%d\n",nevID,nevIDprev);
nevIDprev = nevID;
BuffStore(&out, EEndEvent);
StoreEvent( (Char_t*)(out) );
// Check file length
// End run is greater than max number data buffers
// Start new run if on automatic file change
if( fNRec > fNRecMax ){
fNRec = 0;
// GUI controller
if( fSupervise->IsGUI() ){
fSupervise->GetGUICtrl()->AutoEnd();
if( fSupervise->IsAuto() ) fSupervise->GetGUICtrl()->AutoRun();
}
// Text window controller
else{
fSupervise->ExecEnd();
if( fSupervise->IsAuto() ) fSupervise->ExecRun();
}
}
fNEvent++;
fIRQMod->ResetIRQ();
}
}
//---------------------------------------------------------------------------
void* RunIRQThread( void* exp )
{
// Threaded running of event-by-event data readout
// so that other tasks may be performed
// Check that exp points to a TDAQexperiment object 1st
// ADC/Scaler modules must already be loaded into TDAQexperiment
/*
if( !((TObject*)exp)->InheritsFrom("TDAQexperiment") ){
TThread::Printf("<RunIRQ: TDAQexperiment class not supplied>\n");
return NULL;
}
*/
TDAQexperiment* ex = (TDAQexperiment*)exp;
ex->RunIRQ();
return NULL;
}
//---------------------------------------------------------------------------
void TDAQexperiment::RunSlowCtrl()
{
// Event-by-event readout of data
fIsSlowCtrl = kTRUE;
TIter next( fSlowCtrlList );
// TDAQmodule* mod;
// void* out; // output buffer pointer
// out = fOutBuff;
for(;;){
// while( ( mod = (TDAQmodule*)next() ) ) mod->EventRead(out);
}
}
//---------------------------------------------------------------------------
void* RunSlowCtrlThread( void* exp )
{
// Threaded running of event-by-event data readout
// so that other tasks may be performed
// Check that exp points to a TDAQexperiment object 1st
// ADC/Scaler modules must already be loaded into TDAQexperiment
if( !((TObject*)exp)->InheritsFrom("TDAQexperiment") ){
TThread::Printf("<RunSlowCtrl: TDAQexperiment class not supplied>\n");
return NULL;
}
TDAQexperiment* ex = (TDAQexperiment*)exp;
if( !(ex->GetNADC() + ex->GetNScaler()) ){
TThread::Printf("<RunSlowCtrl: no SlowCtrl modules loaded>\n");
return NULL;
}
ex->RunSlowCtrl();
return NULL;
}
//---------------------------------------------------------------------------
void TDAQexperiment::RunDAQCtrl()
{
// Command loop
// fIsCtrl = kTRUE;
fSupervise->CommandLoop();
}
//---------------------------------------------------------------------------
void* RunDAQCtrlThread( void* exp )
{
// Threaded running of event-by-event data readout
// so that other tasks may be performed
// Check that exp points to a TDAQexperiment object 1st
// ADC/Scaler modules must already be loaded into TDAQexperiment
if( !((TObject*)exp)->InheritsFrom("TDAQexperiment") ){
TThread::Printf("<RunDAQCtrl: TDAQexperiment class not supplied>\n");
return NULL;
}
TDAQexperiment* ex = (TDAQexperiment*)exp;
ex->RunDAQCtrl();
return NULL;
}
//---------------------------------------------------------------------------
void TDAQexperiment::RunStoreData()
{
// Storage of data buffers.
// Set flag for storage running
fIsStore = kTRUE;
fStore->Run();
}
//---------------------------------------------------------------------------
void* RunStoreDataThread( void* exp )
{
// Threaded running of data storage
// so that other tasks may be performed
// Check that exp points to a TDAQexperiment object 1st
// if( !((TObject*)exp)->InheritsFrom("TDAQexperiment") ){
// TThread::Printf("<RunStoreData: TDAQexperiment class not supplied>\n");
// return NULL;
// }
TDAQexperiment* ex = (TDAQexperiment*)exp;
ex->RunStoreData();
return NULL;
}
//---------------------------------------------------------------------------
void TDAQexperiment::PostReset( )
{
// Perform any necessary actions after a general reset of the system
// e.g. reset of the trigger control system, or after starting run
// Check 1st for CATCH stuff
if( fCATCHList ){
TIter nextC( fCATCHList ); // iterate throught CATCH mods
TDAQmodule* mod;
while( (mod = (TDAQmodule*)nextC()) )
((TVME_CATCH*)mod)->SpyReset(); // reset spy buffer
usleep(fStartSettleDelay); // settle time
}
// anything else here
}
ClassImp(TDAQexperiment)
|
82ae1f89336517156c60e271be319cbf443f741c | b20aae53ff2fb176c7008f32a71f7af52fa99750 | /src/database/vehicles/flowTable.cpp | 6ce96d8ed29f0ad5812fe450e0ebc223c62153a2 | [] | no_license | palvarezlopez/eNetEditor | 601f086945106cb26b7bf77e2c1b6e67df21051e | 0019466ad06390ebc11a90122f6b3285cab7b236 | refs/heads/master | 2021-09-06T01:54:16.860724 | 2018-02-01T13:04:15 | 2018-02-01T13:04:15 | 108,637,209 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 872 | cpp | flowTable.cpp | #include "flowTable.h"
// main
#include "../../dialogs/main/eNetEditorMainWindow.h"
// Database
#include "../../database/eNetEditorDatabase.h"
// Project
#include "../../project/eNetEditorProject.h"
// Scene
#include "../../project/eNetEditorScene.h"
// Configuration
#include "../../configuration/main/eNetEditorMainConfiguration.h"
#include "../../configuration/project/eNetEditorProjectConfiguration.h"
#include "../../configuration/items/vehicles/flowItemConfiguration.h"
// Items
#include "../../items/vehicles/flowItem.h"
#include "../../items/vehicleTypeItem.h"
#include "../../items/routeItem.h"
flowTable::flowTable(const QString &newNameOfTable, flowItemConfiguration *flowItemC, eNetEditorDatabase *newDatabase) : abstractVehicleTable(newNameOfTable, flowItemC, newDatabase)
{
// Nothing to do
}
flowTable::~flowTable()
{
// Nothing to erase
}
|
adceee05b9da3118df90444da69e1aca629497ca | 3996ee7a44dba67f8b5035ca78b01d21c619fc1a | /compound.cpp | 927b4020ff6d34c6dff655058f3f5eec920a5cc9 | [] | no_license | agrawalshivam66/C-programming | e3e2024f21ac548f402b0eeeac5f0f93f670f232 | 4c3d7a3aa6c5af576c29345c934d86e2b353484d | refs/heads/master | 2020-03-08T12:11:22.798794 | 2018-09-22T05:51:00 | 2018-09-22T05:51:00 | 128,120,177 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 338 | cpp | compound.cpp | #include<stdio.h>
int main()
{
float p=0,r=0,t=0,i=0,l;
printf("enter the principle amount ");
scanf("%f",&p);
printf("enter the time in years ");
scanf("%f",&t);
printf("enter the anual rate ");
scanf("%f",&r);
for(l=0;l<=t;l++)
{
p=p+i;
i=(p*r*1)/100;
}
printf("the compount intrest is %f",i);
printf("\nthe total amount is %f",p);
}
|
3c3208575b682a56af57f7df896117164e2f6abd | c2c1e39f643741771de3807a7dc1f036a1e40cb4 | /src/libtriton/bindings/python/namespaces/initRegNamespace.cpp | 4fb0a4adee651d1001f0eb6861f01e99d09eda92 | [
"BSD-2-Clause"
] | permissive | sjcappella/Triton | c9eee61dc3e89c85304bdbe82edd94b8850bb047 | c5346438c14d300a58f05a2c6700a74f06bc20db | refs/heads/master | 2021-01-13T05:29:54.914549 | 2017-01-28T04:02:36 | 2017-01-28T04:02:36 | 80,265,212 | 1 | 0 | null | 2017-01-28T03:58:13 | 2017-01-28T03:58:13 | null | UTF-8 | C++ | false | false | 52,634 | cpp | initRegNamespace.cpp | //! \file
/*
** Copyright (C) - Triton
**
** This program is under the terms of the BSD License.
*/
#ifdef TRITON_PYTHON_BINDINGS
#include <api.hpp>
#include <architecture.hpp>
#include <pythonBindings.hpp>
#include <pythonObjects.hpp>
#include <x86Specifications.hpp>
/*! \page py_REG_page REG
\brief [**python api**] All information about the REG python namespace.
\tableofcontents
\section REG_py_description Description
<hr>
According to the CPU architecture, the REG namespace contains all kinds of register.
\section REG_py_api Python API - Items of the REG namespace
<hr>
\subsection REG_X86_py_api x86 registers
- **REG.EAX**
- **REG.AX**
- **REG.AH**
- **REG.AL**
- **REG.EBX**
- **REG.BX**
- **REG.BH**
- **REG.BL**
- **REG.ECX**
- **REG.CX**
- **REG.CH**
- **REG.CL**
- **REG.EDX**
- **REG.DX**
- **REG.DH**
- **REG.DL**
- **REG.EDI**
- **REG.DI**
- **REG.DIL**
- **REG.ESI**
- **REG.SI**
- **REG.SIL**
- **REG.ESP**
- **REG.SP**
- **REG.SPL**
- **REG.EBP**
- **REG.BP**
- **REG.BPL**
- **REG.EIP**
- **REG.IP**
- **REG.EFLAGS**
- **REG.MM0**
- **REG.MM1**
- **REG.MM2**
- **REG.MM3**
- **REG.MM4**
- **REG.MM5**
- **REG.MM6**
- **REG.MM7**
- **REG.XMM0**
- **REG.XMM1**
- **REG.XMM2**
- **REG.XMM3**
- **REG.XMM4**
- **REG.XMM5**
- **REG.XMM6**
- **REG.XMM7**
- **REG.YMM0**
- **REG.YMM1**
- **REG.YMM2**
- **REG.YMM3**
- **REG.YMM4**
- **REG.YMM5**
- **REG.YMM6**
- **REG.YMM7**
- **REG.MXCSR**
- **REG.CR0**
- **REG.CR1**
- **REG.CR2**
- **REG.CR3**
- **REG.CR4**
- **REG.CR5**
- **REG.CR6**
- **REG.CR7**
- **REG.CR8**
- **REG.CR9**
- **REG.CR10**
- **REG.CR11**
- **REG.CR12**
- **REG.CR13**
- **REG.CR14**
- **REG.CR15**
- **REG.IE**
- **REG.DE**
- **REG.ZE**
- **REG.OE**
- **REG.UE**
- **REG.PE**
- **REG.DAZ**
- **REG.IM**
- **REG.DM**
- **REG.ZM**
- **REG.OM**
- **REG.UM**
- **REG.PM**
- **REG.RL**
- **REG.RH**
- **REG.FZ**
- **REG.AF**
- **REG.CF**
- **REG.DF**
- **REG.IF**
- **REG.OF**
- **REG.PF**
- **REG.SF**
- **REG.TF**
- **REG.ZF**
- **REG.CS**
- **REG.DS**
- **REG.ES**
- **REG.FS**
- **REG.GS**
- **REG.SS**
\subsection REG_X8664_py_api x86-64 registers
- **REG.RAX**
- **REG.RBX**
- **REG.RCX**
- **REG.RDX**
- **REG.RDI**
- **REG.RSI**
- **REG.RSP**
- **REG.RBP**
- **REG.RIP**
- **REG.EFLAGS**
- **REG.R8**
- **REG.R8D**
- **REG.R8W**
- **REG.R8B**
- **REG.R9**
- **REG.R9D**
- **REG.R9W**
- **REG.R9B**
- **REG.R10**
- **REG.R10D**
- **REG.R10W**
- **REG.R10B**
- **REG.R11**
- **REG.R11D**
- **REG.R11W**
- **REG.R11B**
- **REG.R12**
- **REG.R12D**
- **REG.R12W**
- **REG.R12B**
- **REG.R13**
- **REG.R13D**
- **REG.R13W**
- **REG.R13B**
- **REG.R14**
- **REG.R14D**
- **REG.R14W**
- **REG.R14B**
- **REG.R15**
- **REG.R15D**
- **REG.R15W**
- **REG.R15B**
- **REG.EAX**
- **REG.AX**
- **REG.AH**
- **REG.AL**
- **REG.EBX**
- **REG.BX**
- **REG.BH**
- **REG.BL**
- **REG.ECX**
- **REG.CX**
- **REG.CH**
- **REG.CL**
- **REG.EDX**
- **REG.DX**
- **REG.DH**
- **REG.DL**
- **REG.EDI**
- **REG.DI**
- **REG.DIL**
- **REG.ESI**
- **REG.SI**
- **REG.SIL**
- **REG.ESP**
- **REG.SP**
- **REG.SPL**
- **REG.EBP**
- **REG.BP**
- **REG.BPL**
- **REG.EIP**
- **REG.IP**
- **REG.MM0**
- **REG.MM1**
- **REG.MM2**
- **REG.MM3**
- **REG.MM4**
- **REG.MM5**
- **REG.MM6**
- **REG.MM7**
- **REG.XMM0**
- **REG.XMM1**
- **REG.XMM2**
- **REG.XMM3**
- **REG.XMM4**
- **REG.XMM5**
- **REG.XMM6**
- **REG.XMM7**
- **REG.XMM8**
- **REG.XMM9**
- **REG.XMM10**
- **REG.XMM11**
- **REG.XMM12**
- **REG.XMM13**
- **REG.XMM14**
- **REG.XMM15**
- **REG.YMM0**
- **REG.YMM1**
- **REG.YMM2**
- **REG.YMM3**
- **REG.YMM4**
- **REG.YMM5**
- **REG.YMM6**
- **REG.YMM7**
- **REG.YMM8**
- **REG.YMM9**
- **REG.YMM10**
- **REG.YMM11**
- **REG.YMM12**
- **REG.YMM13**
- **REG.YMM14**
- **REG.YMM15**
- **REG.ZMM0**
- **REG.ZMM1**
- **REG.ZMM2**
- **REG.ZMM3**
- **REG.ZMM4**
- **REG.ZMM5**
- **REG.ZMM6**
- **REG.ZMM7**
- **REG.ZMM8**
- **REG.ZMM9**
- **REG.ZMM10**
- **REG.ZMM11**
- **REG.ZMM12**
- **REG.ZMM13**
- **REG.ZMM14**
- **REG.ZMM15**
- **REG.ZMM16**
- **REG.ZMM17**
- **REG.ZMM18**
- **REG.ZMM19**
- **REG.ZMM20**
- **REG.ZMM21**
- **REG.ZMM22**
- **REG.ZMM23**
- **REG.ZMM24**
- **REG.ZMM25**
- **REG.ZMM26**
- **REG.ZMM27**
- **REG.ZMM28**
- **REG.ZMM29**
- **REG.ZMM30**
- **REG.ZMM31**
- **REG.MXCSR**
- **REG.CR0**
- **REG.CR1**
- **REG.CR2**
- **REG.CR3**
- **REG.CR4**
- **REG.CR5**
- **REG.CR6**
- **REG.CR7**
- **REG.CR8**
- **REG.CR9**
- **REG.CR10**
- **REG.CR11**
- **REG.CR12**
- **REG.CR13**
- **REG.CR14**
- **REG.CR15**
- **REG.IE**
- **REG.DE**
- **REG.ZE**
- **REG.OE**
- **REG.UE**
- **REG.PE**
- **REG.DAZ**
- **REG.IM**
- **REG.DM**
- **REG.ZM**
- **REG.OM**
- **REG.UM**
- **REG.PM**
- **REG.RL**
- **REG.RH**
- **REG.FZ**
- **REG.AF**
- **REG.CF**
- **REG.DF**
- **REG.IF**
- **REG.OF**
- **REG.PF**
- **REG.SF**
- **REG.TF**
- **REG.ZF**
- **REG.CS**
- **REG.DS**
- **REG.ES**
- **REG.FS**
- **REG.GS**
- **REG.SS**
*/
namespace triton {
namespace bindings {
namespace python {
void initRegNamespace(void) {
if (!triton::bindings::python::initialized)
return;
PyDict_Clear(triton::bindings::python::registersDict);
switch (api.getArchitecture()) {
case triton::arch::ARCH_X86_64:
PyDict_SetItemString(triton::bindings::python::registersDict, "AF", PyRegister(TRITON_X86_REG_AF, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "AH", PyRegister(TRITON_X86_REG_AH, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "AL", PyRegister(TRITON_X86_REG_AL, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "AX", PyRegister(TRITON_X86_REG_AX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "BH", PyRegister(TRITON_X86_REG_BH, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "BL", PyRegister(TRITON_X86_REG_BL, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "BP", PyRegister(TRITON_X86_REG_BP, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "BPL", PyRegister(TRITON_X86_REG_BPL, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "BX", PyRegister(TRITON_X86_REG_BX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CF", PyRegister(TRITON_X86_REG_CF, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CH", PyRegister(TRITON_X86_REG_CH, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CL", PyRegister(TRITON_X86_REG_CL, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR0", PyRegister(TRITON_X86_REG_CR0, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR1", PyRegister(TRITON_X86_REG_CR1, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR10", PyRegister(TRITON_X86_REG_CR10, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR11", PyRegister(TRITON_X86_REG_CR11, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR12", PyRegister(TRITON_X86_REG_CR12, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR13", PyRegister(TRITON_X86_REG_CR13, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR14", PyRegister(TRITON_X86_REG_CR14, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR15", PyRegister(TRITON_X86_REG_CR15, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR2", PyRegister(TRITON_X86_REG_CR2, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR3", PyRegister(TRITON_X86_REG_CR3, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR4", PyRegister(TRITON_X86_REG_CR4, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR5", PyRegister(TRITON_X86_REG_CR5, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR6", PyRegister(TRITON_X86_REG_CR6, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR7", PyRegister(TRITON_X86_REG_CR7, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR8", PyRegister(TRITON_X86_REG_CR8, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR9", PyRegister(TRITON_X86_REG_CR9, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CS", PyRegister(TRITON_X86_REG_CS, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CX", PyRegister(TRITON_X86_REG_CX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DAZ", PyRegister(TRITON_X86_REG_DAZ, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DE", PyRegister(TRITON_X86_REG_DE, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DF", PyRegister(TRITON_X86_REG_DF, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DH", PyRegister(TRITON_X86_REG_DH, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DI", PyRegister(TRITON_X86_REG_DI, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DIL", PyRegister(TRITON_X86_REG_DIL, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DL", PyRegister(TRITON_X86_REG_DL, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DM", PyRegister(TRITON_X86_REG_DM, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DS", PyRegister(TRITON_X86_REG_DS, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DX", PyRegister(TRITON_X86_REG_DX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "EAX", PyRegister(TRITON_X86_REG_EAX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "EBP", PyRegister(TRITON_X86_REG_EBP, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "EBX", PyRegister(TRITON_X86_REG_EBX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ECX", PyRegister(TRITON_X86_REG_ECX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "EDI", PyRegister(TRITON_X86_REG_EDI, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "EDX", PyRegister(TRITON_X86_REG_EDX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "EFLAGS", PyRegister(TRITON_X86_REG_EFLAGS, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "EIP", PyRegister(TRITON_X86_REG_EIP, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ES", PyRegister(TRITON_X86_REG_ES, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ESI", PyRegister(TRITON_X86_REG_ESI, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ESP", PyRegister(TRITON_X86_REG_ESP, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "FS", PyRegister(TRITON_X86_REG_FS, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "FZ", PyRegister(TRITON_X86_REG_FZ, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "GS", PyRegister(TRITON_X86_REG_GS, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "IE", PyRegister(TRITON_X86_REG_IE, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "IF", PyRegister(TRITON_X86_REG_IF, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "IM", PyRegister(TRITON_X86_REG_IM, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "IP", PyRegister(TRITON_X86_REG_IP, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "MM0", PyRegister(TRITON_X86_REG_MM0, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "MM1", PyRegister(TRITON_X86_REG_MM1, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "MM2", PyRegister(TRITON_X86_REG_MM2, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "MM3", PyRegister(TRITON_X86_REG_MM3, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "MM4", PyRegister(TRITON_X86_REG_MM4, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "MM5", PyRegister(TRITON_X86_REG_MM5, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "MM6", PyRegister(TRITON_X86_REG_MM6, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "MM7", PyRegister(TRITON_X86_REG_MM7, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "MXCSR", PyRegister(TRITON_X86_REG_MXCSR, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "OE", PyRegister(TRITON_X86_REG_OE, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "OF", PyRegister(TRITON_X86_REG_OF, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "OM", PyRegister(TRITON_X86_REG_OM, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "PE", PyRegister(TRITON_X86_REG_PE, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "PF", PyRegister(TRITON_X86_REG_PF, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "PM", PyRegister(TRITON_X86_REG_PM, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R10", PyRegister(TRITON_X86_REG_R10, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R10B", PyRegister(TRITON_X86_REG_R10B, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R10D", PyRegister(TRITON_X86_REG_R10D, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R10W", PyRegister(TRITON_X86_REG_R10W, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R11", PyRegister(TRITON_X86_REG_R11, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R11B", PyRegister(TRITON_X86_REG_R11B, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R11D", PyRegister(TRITON_X86_REG_R11D, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R11W", PyRegister(TRITON_X86_REG_R11W, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R12", PyRegister(TRITON_X86_REG_R12, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R12B", PyRegister(TRITON_X86_REG_R12B, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R12D", PyRegister(TRITON_X86_REG_R12D, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R12W", PyRegister(TRITON_X86_REG_R12W, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R13", PyRegister(TRITON_X86_REG_R13, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R13B", PyRegister(TRITON_X86_REG_R13B, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R13D", PyRegister(TRITON_X86_REG_R13D, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R13W", PyRegister(TRITON_X86_REG_R13W, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R14", PyRegister(TRITON_X86_REG_R14, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R14B", PyRegister(TRITON_X86_REG_R14B, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R14D", PyRegister(TRITON_X86_REG_R14D, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R14W", PyRegister(TRITON_X86_REG_R14W, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R15", PyRegister(TRITON_X86_REG_R15, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R15B", PyRegister(TRITON_X86_REG_R15B, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R15D", PyRegister(TRITON_X86_REG_R15D, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R15W", PyRegister(TRITON_X86_REG_R15W, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R8", PyRegister(TRITON_X86_REG_R8, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R8B", PyRegister(TRITON_X86_REG_R8B, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R8D", PyRegister(TRITON_X86_REG_R8D, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R8W", PyRegister(TRITON_X86_REG_R8W, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R9", PyRegister(TRITON_X86_REG_R9, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R9B", PyRegister(TRITON_X86_REG_R9B, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R9D", PyRegister(TRITON_X86_REG_R9D, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "R9W", PyRegister(TRITON_X86_REG_R9W, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "RAX", PyRegister(TRITON_X86_REG_RAX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "RBP", PyRegister(TRITON_X86_REG_RBP, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "RBX", PyRegister(TRITON_X86_REG_RBX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "RCX", PyRegister(TRITON_X86_REG_RCX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "RDI", PyRegister(TRITON_X86_REG_RDI, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "RDX", PyRegister(TRITON_X86_REG_RDX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "RH", PyRegister(TRITON_X86_REG_RH, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "RIP", PyRegister(TRITON_X86_REG_RIP, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "RL", PyRegister(TRITON_X86_REG_RL, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "RSI", PyRegister(TRITON_X86_REG_RSI, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "RSP", PyRegister(TRITON_X86_REG_RSP, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "SF", PyRegister(TRITON_X86_REG_SF, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "SI", PyRegister(TRITON_X86_REG_SI, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "SIL", PyRegister(TRITON_X86_REG_SIL, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "SP", PyRegister(TRITON_X86_REG_SP, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "SPL", PyRegister(TRITON_X86_REG_SPL, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "SS", PyRegister(TRITON_X86_REG_SS, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "TF", PyRegister(TRITON_X86_REG_TF, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "UE", PyRegister(TRITON_X86_REG_UE, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "UM", PyRegister(TRITON_X86_REG_UM, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM0", PyRegister(TRITON_X86_REG_XMM0, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM1", PyRegister(TRITON_X86_REG_XMM1, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM10", PyRegister(TRITON_X86_REG_XMM10, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM11", PyRegister(TRITON_X86_REG_XMM11, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM12", PyRegister(TRITON_X86_REG_XMM12, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM13", PyRegister(TRITON_X86_REG_XMM13, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM14", PyRegister(TRITON_X86_REG_XMM14, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM15", PyRegister(TRITON_X86_REG_XMM15, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM2", PyRegister(TRITON_X86_REG_XMM2, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM3", PyRegister(TRITON_X86_REG_XMM3, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM4", PyRegister(TRITON_X86_REG_XMM4, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM5", PyRegister(TRITON_X86_REG_XMM5, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM6", PyRegister(TRITON_X86_REG_XMM6, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM7", PyRegister(TRITON_X86_REG_XMM7, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM8", PyRegister(TRITON_X86_REG_XMM8, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM9", PyRegister(TRITON_X86_REG_XMM9, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM0", PyRegister(TRITON_X86_REG_YMM0, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM1", PyRegister(TRITON_X86_REG_YMM1, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM10", PyRegister(TRITON_X86_REG_YMM10, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM11", PyRegister(TRITON_X86_REG_YMM11, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM12", PyRegister(TRITON_X86_REG_YMM12, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM13", PyRegister(TRITON_X86_REG_YMM13, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM14", PyRegister(TRITON_X86_REG_YMM14, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM15", PyRegister(TRITON_X86_REG_YMM15, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM2", PyRegister(TRITON_X86_REG_YMM2, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM3", PyRegister(TRITON_X86_REG_YMM3, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM4", PyRegister(TRITON_X86_REG_YMM4, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM5", PyRegister(TRITON_X86_REG_YMM5, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM6", PyRegister(TRITON_X86_REG_YMM6, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM7", PyRegister(TRITON_X86_REG_YMM7, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM8", PyRegister(TRITON_X86_REG_YMM8, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM9", PyRegister(TRITON_X86_REG_YMM9, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZE", PyRegister(TRITON_X86_REG_ZE, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZF", PyRegister(TRITON_X86_REG_ZF, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZM", PyRegister(TRITON_X86_REG_ZM, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM0", PyRegister(TRITON_X86_REG_ZMM0, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM1", PyRegister(TRITON_X86_REG_ZMM1, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM10", PyRegister(TRITON_X86_REG_ZMM10, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM11", PyRegister(TRITON_X86_REG_ZMM11, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM12", PyRegister(TRITON_X86_REG_ZMM12, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM13", PyRegister(TRITON_X86_REG_ZMM13, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM14", PyRegister(TRITON_X86_REG_ZMM14, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM15", PyRegister(TRITON_X86_REG_ZMM15, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM16", PyRegister(TRITON_X86_REG_ZMM16, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM17", PyRegister(TRITON_X86_REG_ZMM17, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM18", PyRegister(TRITON_X86_REG_ZMM18, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM19", PyRegister(TRITON_X86_REG_ZMM19, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM2", PyRegister(TRITON_X86_REG_ZMM2, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM20", PyRegister(TRITON_X86_REG_ZMM20, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM21", PyRegister(TRITON_X86_REG_ZMM21, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM22", PyRegister(TRITON_X86_REG_ZMM22, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM23", PyRegister(TRITON_X86_REG_ZMM23, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM24", PyRegister(TRITON_X86_REG_ZMM24, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM25", PyRegister(TRITON_X86_REG_ZMM25, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM26", PyRegister(TRITON_X86_REG_ZMM26, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM27", PyRegister(TRITON_X86_REG_ZMM27, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM28", PyRegister(TRITON_X86_REG_ZMM28, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM29", PyRegister(TRITON_X86_REG_ZMM29, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM3", PyRegister(TRITON_X86_REG_ZMM3, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM30", PyRegister(TRITON_X86_REG_ZMM30, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM31", PyRegister(TRITON_X86_REG_ZMM31, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM4", PyRegister(TRITON_X86_REG_ZMM4, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM5", PyRegister(TRITON_X86_REG_ZMM5, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM6", PyRegister(TRITON_X86_REG_ZMM6, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM7", PyRegister(TRITON_X86_REG_ZMM7, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM8", PyRegister(TRITON_X86_REG_ZMM8, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZMM9", PyRegister(TRITON_X86_REG_ZMM9, 0x00, triton::arch::IMMUTABLE_REGISTER));
break;
case triton::arch::ARCH_X86:
PyDict_SetItemString(triton::bindings::python::registersDict, "AF", PyRegister(TRITON_X86_REG_AF, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "AH", PyRegister(TRITON_X86_REG_AH, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "AL", PyRegister(TRITON_X86_REG_AL, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "AX", PyRegister(TRITON_X86_REG_AX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "BH", PyRegister(TRITON_X86_REG_BH, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "BL", PyRegister(TRITON_X86_REG_BL, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "BP", PyRegister(TRITON_X86_REG_BP, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "BPL", PyRegister(TRITON_X86_REG_BPL, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "BX", PyRegister(TRITON_X86_REG_BX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CF", PyRegister(TRITON_X86_REG_CF, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CH", PyRegister(TRITON_X86_REG_CH, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CL", PyRegister(TRITON_X86_REG_CL, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR0", PyRegister(TRITON_X86_REG_CR0, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR1", PyRegister(TRITON_X86_REG_CR1, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR10", PyRegister(TRITON_X86_REG_CR10, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR11", PyRegister(TRITON_X86_REG_CR11, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR12", PyRegister(TRITON_X86_REG_CR12, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR13", PyRegister(TRITON_X86_REG_CR13, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR14", PyRegister(TRITON_X86_REG_CR14, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR15", PyRegister(TRITON_X86_REG_CR15, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR2", PyRegister(TRITON_X86_REG_CR2, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR3", PyRegister(TRITON_X86_REG_CR3, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR4", PyRegister(TRITON_X86_REG_CR4, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR5", PyRegister(TRITON_X86_REG_CR5, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR6", PyRegister(TRITON_X86_REG_CR6, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR7", PyRegister(TRITON_X86_REG_CR7, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR8", PyRegister(TRITON_X86_REG_CR8, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CR9", PyRegister(TRITON_X86_REG_CR9, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CS", PyRegister(TRITON_X86_REG_CS, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "CX", PyRegister(TRITON_X86_REG_CX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DAZ", PyRegister(TRITON_X86_REG_DAZ, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DE", PyRegister(TRITON_X86_REG_DE, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DF", PyRegister(TRITON_X86_REG_DF, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DH", PyRegister(TRITON_X86_REG_DH, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DI", PyRegister(TRITON_X86_REG_DI, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DIL", PyRegister(TRITON_X86_REG_DIL, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DL", PyRegister(TRITON_X86_REG_DL, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DM", PyRegister(TRITON_X86_REG_DM, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DS", PyRegister(TRITON_X86_REG_DS, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "DX", PyRegister(TRITON_X86_REG_DX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "EAX", PyRegister(TRITON_X86_REG_EAX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "EBP", PyRegister(TRITON_X86_REG_EBP, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "EBX", PyRegister(TRITON_X86_REG_EBX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ECX", PyRegister(TRITON_X86_REG_ECX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "EDI", PyRegister(TRITON_X86_REG_EDI, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "EDX", PyRegister(TRITON_X86_REG_EDX, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "EFLAGS", PyRegister(TRITON_X86_REG_EFLAGS, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "EIP", PyRegister(TRITON_X86_REG_EIP, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ES", PyRegister(TRITON_X86_REG_ES, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ESI", PyRegister(TRITON_X86_REG_ESI, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ESP", PyRegister(TRITON_X86_REG_ESP, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "FS", PyRegister(TRITON_X86_REG_FS, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "FZ", PyRegister(TRITON_X86_REG_FZ, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "GS", PyRegister(TRITON_X86_REG_GS, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "IE", PyRegister(TRITON_X86_REG_IE, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "IF", PyRegister(TRITON_X86_REG_IF, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "IM", PyRegister(TRITON_X86_REG_IM, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "IP", PyRegister(TRITON_X86_REG_IP, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "MM0", PyRegister(TRITON_X86_REG_MM0, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "MM1", PyRegister(TRITON_X86_REG_MM1, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "MM2", PyRegister(TRITON_X86_REG_MM2, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "MM3", PyRegister(TRITON_X86_REG_MM3, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "MM4", PyRegister(TRITON_X86_REG_MM4, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "MM5", PyRegister(TRITON_X86_REG_MM5, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "MM6", PyRegister(TRITON_X86_REG_MM6, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "MM7", PyRegister(TRITON_X86_REG_MM7, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "MXCSR", PyRegister(TRITON_X86_REG_MXCSR, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "OE", PyRegister(TRITON_X86_REG_OE, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "OF", PyRegister(TRITON_X86_REG_OF, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "OM", PyRegister(TRITON_X86_REG_OM, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "PE", PyRegister(TRITON_X86_REG_PE, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "PF", PyRegister(TRITON_X86_REG_PF, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "PM", PyRegister(TRITON_X86_REG_PM, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "RH", PyRegister(TRITON_X86_REG_RH, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "RL", PyRegister(TRITON_X86_REG_RL, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "SF", PyRegister(TRITON_X86_REG_SF, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "SI", PyRegister(TRITON_X86_REG_SI, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "SIL", PyRegister(TRITON_X86_REG_SIL, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "SP", PyRegister(TRITON_X86_REG_SP, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "SPL", PyRegister(TRITON_X86_REG_SPL, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "SS", PyRegister(TRITON_X86_REG_SS, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "TF", PyRegister(TRITON_X86_REG_TF, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "UE", PyRegister(TRITON_X86_REG_UE, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "UM", PyRegister(TRITON_X86_REG_UM, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM0", PyRegister(TRITON_X86_REG_XMM0, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM1", PyRegister(TRITON_X86_REG_XMM1, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM2", PyRegister(TRITON_X86_REG_XMM2, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM3", PyRegister(TRITON_X86_REG_XMM3, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM4", PyRegister(TRITON_X86_REG_XMM4, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM5", PyRegister(TRITON_X86_REG_XMM5, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM6", PyRegister(TRITON_X86_REG_XMM6, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "XMM7", PyRegister(TRITON_X86_REG_XMM7, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM0", PyRegister(TRITON_X86_REG_YMM0, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM1", PyRegister(TRITON_X86_REG_YMM1, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM2", PyRegister(TRITON_X86_REG_YMM2, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM3", PyRegister(TRITON_X86_REG_YMM3, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM4", PyRegister(TRITON_X86_REG_YMM4, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM5", PyRegister(TRITON_X86_REG_YMM5, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM6", PyRegister(TRITON_X86_REG_YMM6, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "YMM7", PyRegister(TRITON_X86_REG_YMM7, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZE", PyRegister(TRITON_X86_REG_ZE, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZF", PyRegister(TRITON_X86_REG_ZF, 0x00, triton::arch::IMMUTABLE_REGISTER));
PyDict_SetItemString(triton::bindings::python::registersDict, "ZM", PyRegister(TRITON_X86_REG_ZM, 0x00, triton::arch::IMMUTABLE_REGISTER));
break;
} /* switch */
}
}; /* python namespace */
}; /* bindings namespace */
}; /* triton namespace */
#endif /* TRITON_PYTHON_BINDINGS */
|
e3480dd8ea3ede5efd1b3dafb074d8b0973312b4 | 46f98a92935ec0d309c83d57f1dd8a1a52d8e4ff | /NeuralNetGitHub/Cell.h | 52ddfa6bc1aae6b043228df96501e73fbc568402 | [] | no_license | TheLargeCactus/NeuralNetProject | 33627e087d8a433561b3392a596588e07b84eb3b | d9721d1ba159ebd53c4d696b1a4abbf1aa4c73cd | refs/heads/master | 2020-03-16T00:17:04.744808 | 2018-05-07T06:35:34 | 2018-05-07T06:35:34 | 132,412,658 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 805 | h | Cell.h | #pragma once
#include <vector>
#include <set>
#include <algorithm>
#include <random>
#include <stdint.h>
#include "Lib.h"
class Cell {
protected:
int offset;
int slope;
std::set<Cell *> in;
public:
std::uint8_t state;
//constructors
//default
Cell();
//other call constructor
Cell(const int inSlope, const int inOffset);
//copy constructor
Cell(const Cell & rhs);
//operator functions
const Cell & operator=(const Cell & rhs);
//member functions
//function to transform input into output
virtual uint64_t transform() const;
//get offset from cell
const int getOffset() const;
//get slope from cell
const int getSlope() const;
//function to add cell to input vector
bool pushCell(Cell * src);
//function to remove cell from input vector
bool popCell(Cell * tgt);
}; |
ea295a4b96768c2508266ec7fb0767aaf75ec1ca | d63676b2bdaded08f7e9e905087e2c10051b5476 | /clu/Operators/SkipOperator.cpp | 399df00e6ed70baa6abd3b139e7cfc78c21b456f | [
"MIT"
] | permissive | ShaiRoitman/clu | 9e39f8edcedde5bb97e2253d0ec91b897d2b910d | c8816455a78ed70d1885fa23f6442d1d2a823a16 | refs/heads/master | 2021-11-03T00:26:50.125205 | 2021-09-12T12:39:30 | 2021-09-12T12:39:30 | 77,403,581 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 644 | cpp | SkipOperator.cpp | #include "Utils.h"
#include "InputFileOperator.h"
#include "CommandLineHandlers/SingleCommandLineHandler.h"
#include <boost/algorithm/string/trim.hpp>
USING_NAMESPACE(std);
USING_NAMESPACE(clu);
class SkipFilter : public InputFileOperator {
public:
SkipFilter(int startCounter) : m_start(startCounter), m_count(0) {}
virtual bool OnLineRead(string& line)
{
if (m_count >= m_start)
m_OutputHandler->OutputLineFeed(line);
m_count++;
return true;
}
virtual void OnEnd()
{
m_count = 0;
}
protected:
int m_start;
int m_count;
};
REGISTER_SINGLE_INTEGER("skip", SkipFilter)->SetHelp("Skip - Skips the first n lines");
|
741d17080b689684923caff6606c8be146532c4e | f739df1f252d7c961ed881be3b8babaf62ff4170 | /softs/SCADAsoft/5.3.1/ACE_Wrappers/TAO/TAO_IDL/be_include/be_visitor_enum/cdr_op_cs.h | c8cd7bbf93e4d20a35767a9eef92ba76bfe8ce62 | [] | no_license | billpwchan/SCADA-nsl | 739484691c95181b262041daa90669d108c54234 | 1287edcd38b2685a675f1261884f1035f7f288db | refs/heads/master | 2023-04-30T09:15:49.104944 | 2021-01-10T21:53:10 | 2021-01-10T21:53:10 | 328,486,982 | 0 | 0 | null | 2023-04-22T07:10:56 | 2021-01-10T21:53:19 | C++ | UTF-8 | C++ | false | false | 991 | h | cdr_op_cs.h | /* -*- C++ -*- */
//
// $Id: cdr_op_cs.h 14 2007-02-01 15:49:12Z mitza $
//
// ============================================================================
//
// = LIBRARY
// TAO IDL
//
// = FILENAME
// cdr_op_cs.h
//
// = DESCRIPTION
// Concrete visitor for Enums generating code for the CDR operators
//
// = AUTHOR
// Aniruddha Gokhale
//
// ============================================================================
#ifndef _BE_VISITOR_ENUM_CDR_OP_CS_H_
#define _BE_VISITOR_ENUM_CDR_OP_CS_H_
class be_visitor_enum_cdr_op_cs : public be_visitor_decl
{
//
// = TITLE
// be_visitor_enum_cdr_op_cs
//
// = DESCRIPTION
// This is a concrete visitor for enum that generates the CDR operator
// implementations
//
public:
be_visitor_enum_cdr_op_cs (be_visitor_context *ctx);
// constructor
~be_visitor_enum_cdr_op_cs (void);
// destructor
virtual int visit_enum (be_enum *node);
// visit enum
};
#endif /* _BE_VISITOR_ENUM_CDR_OP_CS_H_ */
|
593ab99950bf7a389864fd50c3d9a481adb82ab4 | 246469bbd9254f21f939cd254d66e85daf6e6fc5 | /J.Todo/Pods/Realm/core/realm-monorepo.xcframework/watchos-armv7k_arm64_32/Headers/realm/obj.hpp | 688d0054deb049a7e8ca7fc76912b45dc5a5cccc | [] | no_license | LeeJinYoung91/J.TodoApp | b7e3461c527e33637e67b2e0c65a6405716714d0 | ea634b9b38dda54be306f2025673676d4f95f20c | refs/heads/master | 2023-04-19T08:26:54.330218 | 2021-04-29T01:48:07 | 2021-04-29T01:48:07 | 198,178,471 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 130 | hpp | obj.hpp | version https://git-lfs.github.com/spec/v1
oid sha256:58f8600f1c53556e005ecdfb104e18fa94f6fb703bd40d3daa43ee3d2deea0f1
size 17597
|
22dfbb7df225156ce878533520195c1aa4378df0 | e803c16a505aa73cb3facbb15caab5f5b12063c2 | /ddr3-efficiency/gcu_trg_check/gcu_trg_check.cxx | a4a5df49288981909ff885b30f99559e7925d4cc | [] | no_license | trRiccardo/juno-efficiency-tests | 55bd1c4822523f5149060a19a78c8cda4d14b49b | 9ecf4d3fd30a11cc88c77c1445241b11040bf0a3 | refs/heads/main | 2023-08-29T03:28:07.024835 | 2021-10-15T19:54:48 | 2021-10-15T19:54:48 | 417,584,181 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,873 | cxx | gcu_trg_check.cxx | #include <iostream>
#include <fstream>
#include <algorithm>
#include <sstream>
#include <stdint.h>
#include <vector>
#include <functional>
#include <cstring>
#include "Constants.hpp"
using namespace std;
void usage();
inline uint16_t swap_word( uint16_t word ) {
return ( ( word << 8 ) & 0xFF00 ) | ( ( word >> 8 ) & 0x00FF );
}
int main(int argc, char* argv[]) {
//declare useful variables
fstream file_in;
ofstream file_out;
ofstream file_check;
uint16_t val, trg_w, tmp = 0;
const unsigned int buffer_is = 500;
vector<uint16_t> buffer(buffer_is);
vector<uint16_t>::iterator it;
vector<uint64_t> trg_c;
trg_c.reserve(100000);
unsigned int i = 0, of = 0;
int a_ev, e_ev, win, m = 1;
bool found, debug = false;
//some checks on input line
if ( argc < 2 ) {
cout << "Wrong usage!" << endl;
usage();
return -1;
}
if( (!strcmp( argv[1], "--help" )) || (!strcmp( argv[1], "-h" )) ) {
usage();
return 0;
}
if( argc > 3 ) {
if( argc == 4 && !strcmp( argv[3], "-d" ) )
debug = true;
else if( argc > 6 && !(strcmp( argv[3], "-o" ) || strcmp( argv[5], "-x" )) ) {
if( argc > 7 && !strcmp( argv[7], "-d" ) )
debug = true;
file_out.open(argv[4], ios::app);
}
else {
cout << "Wrong usage!" << endl;
usage();
return -1;
}
}
win = atoi(argv[2]);
file_in.open(argv[1], ios::in|ios::binary);
if(debug)
file_check.open("check.txt", ios::out);
if(!file_in.is_open())
cout << "Error opening input file" << endl;
double conversion = 2.0 / sizeof(char);
if(debug)
cout << "conversion: " <<conversion << endl;
//skip first not valid data
file_in.ignore(conversion*(win+16)*1000);
//seek for next trailer
do {
found = true;
//check if reading too much
if ( m > 10 ) {
cout << "First trailer not found" << endl;
return -1;
}
if(debug){
cout << "Searching for first trailer, attempt " << m << endl;
file_check << "--Searching for first trailer--" << endl;
}
//fill buffer with first m*buffer_is words
while ( i < buffer.size() ) {
file_in.read( reinterpret_cast<char*>( &buffer[i] ), sizeof( uint16_t ) );
++i;
}
if(debug) {
for( auto c : buffer )
file_check << swap_word(c) << endl;
file_check << endl;
}
//search for trailer start sequence
it = search( buffer.begin(), buffer.end(),
boyer_moore_searcher(Constants::trailer::start, Constants::trailer::start + 6 ) );
//if not found retry with bigger buffer size
if( it == buffer.end() ){
found = false;
buffer.resize((++m)*buffer_is);
}
}while(!found);
cout << "First trailer found!" << endl;
//set reading position to end of first useful trailer
file_in.seekg( conversion*( it - buffer.begin() + (win+16)*1000 ) );
file_in.ignore( conversion*8.0);
if(debug)
file_check << "----------Reading data----------" << endl;
//read file after first trailer
while( file_in.read( reinterpret_cast<char*>( &val ), sizeof( val ) ) ) {
if( swap_word( val ) != Constants::header::m1 ) {
cout << "File corrupted at trg count: " << (*(trg_c.end()-1) ? *(trg_c.end()-1) : 0) << endl;
}
file_in.ignore( conversion*1.0 );
//getting trigger window
file_in.read( reinterpret_cast<char*>( &val ), sizeof( val ) );
trg_w = swap_word( val );
if(debug)
file_check << trg_w << endl;
//getting trigger count
file_in.read( reinterpret_cast<char*>( &val ), sizeof( val ) );
val = swap_word( val );
trg_c.push_back( val );
if(trg_w != win)
cout << "Trg_win mismatch at trg_c: " << val << endl;
//counting overflows
if( val < tmp )
++of;
tmp = val;
if(debug)
file_check << *(trg_c.end()-1) << endl;
//set position to next header
if(debug)
for(int k = 0; k < (trg_w - 1)*8 + 4; ++k) {
file_in.read( reinterpret_cast<char*>( &val ), sizeof( val ) );
file_check << swap_word(val) << endl;
}
else
file_in.ignore( conversion*( (trg_w - 1)*8 + 4) );
}
if(debug) {
file_check << "-----trigger counts found------" << endl;
for( auto c : trg_c )
file_check << c << endl;
file_check.close();
}
//close input file
file_in.close();
//print results on screen
a_ev = trg_c.size();
e_ev = *(trg_c.end()-1) + of*65536 - *trg_c.begin() + 1;
cout << "Actual read events:\t" << a_ev << endl;
cout << "Expected events:\t" << e_ev << endl;
cout << "Efficiency:\t\t"
<< a_ev*100.0 / e_ev << "%" << endl;
i = 0;
//print results on file if open
if(file_out.is_open()) {
file_out << atoi(argv[6]) << '\t'
<< e_ev << '\t' << a_ev << '\t' << a_ev*100.0 / e_ev << endl;
file_out.close();
}
return 0;
}
|
01604c6622802624649d5c3cd86531df58fe112e | 332e0c3c2189c73c51a9422ab4f9e07ed7d5134e | /141.cpp | 6d3a2581b915be733d3982bc90403134f02672a0 | [] | no_license | ksaveljev/UVa-online-judge | 352a05c9d12440337c2a0ba5a5f1c8aa1dc72357 | 006961a966004f744f5780a6a81108c0b79c3c18 | refs/heads/master | 2023-05-24T23:08:48.502908 | 2023-05-16T10:37:37 | 2023-05-16T10:37:37 | 1,566,701 | 112 | 80 | null | 2017-01-10T14:55:46 | 2011-04-04T11:43:53 | C++ | UTF-8 | C++ | false | false | 2,125 | cpp | 141.cpp | #include <iostream>
#include <map>
using namespace std;
void rotate(bool sq[][50], int b)
{
bool** tmp;
tmp = new bool*[b];
for (int i = 0; i < b; i++) {
tmp[i] = new bool[b];
}
for (int i = 0; i < b; i++) {
for (int j = 0; j < b; j++) {
tmp[i][j] = sq[i][j];
}
}
for (int i = 0; i < b; i++) {
for (int j = b-1; j >= 0; j--) {
sq[i][b-j-1] = tmp[j][i];
}
}
for (int i = 0; i < b; i++) {
delete [] tmp[i];
}
delete [] tmp;
}
unsigned int jenkins_one_at_a_time_hash(bool sq[][50], int n)
{
unsigned int hash = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
hash += (sq[i][j] == true ? '1' : '0');
hash += (hash << 10);
hash ^= (hash >> 6);
}
}
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
return hash;
}
int main(void)
{
int n, a, b;
char c;
int player, counter;
bool field[50][50];
unsigned int hash;
map<unsigned int, bool> visited;
while (cin >> n) {
if (!n)
break;
visited.clear();
player = 1;
counter = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
field[i][j] = false;
}
}
visited.insert(make_pair(jenkins_one_at_a_time_hash(field, n), true));
pair<int,int> winner;
winner.first = -1;
for (int i = 0; i < 2*n; i++) {
cin >> a >> b >> c;
counter++;
if (winner.first > 0)
continue;
field[a-1][b-1] = (field[a-1][b-1] ? false : true);
for (int j = 0; j < 4; j++) {
rotate(field, n);
hash = jenkins_one_at_a_time_hash(field, n);
if (visited.find(hash) != visited.end()) {
winner.first = (player == 1 ? 2 : 1);
winner.second = counter;
}
}
visited.insert(make_pair(hash, true));
player = (player == 1 ? 2 : 1);
}
switch (winner.first) {
case -1:
cout << "Draw" << endl;
break;
case 1:
case 2:
cout << "Player " << winner.first << " wins on move " << winner.second << endl;
break;
}
}
return 0;
}
|
a4588dc2b325aa998f15fbd410e2ca410f4879b9 | b257139eaec4c592feaada3a4f95a713aefd58c6 | /ga.cpp | 1f050651776cd47ac782e53341a9ad88b9dc08b4 | [] | no_license | dr-rahul-dubey/Parallel-Genetic-Algorithm | 4c5e75f61b16ac3d6238fe4419ca6ae6e2ba45ac | c292ec2273b83735076850590ebfbb4f718b49e8 | refs/heads/master | 2023-07-07T03:27:59.421282 | 2020-02-25T03:20:39 | 2020-02-25T03:20:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,593 | cpp | ga.cpp |
#include <iostream>
#include <unistd.h>
#include <fstream>
#include <string>
#include <assert.h>
#include <gaMpi.h>
#include <stdlib.h>
#include "utils.h"
#include "population.h"
#include "individual.h"
#include <evaluate.h>
#include "ga.h"
#include "random.h"
using namespace std;
using namespace ga;
MPIInfo initMPI(int argc, char *argv[]){
MPIInfo info;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &(info.numProcs));
MPI_Comm_rank(MPI_COMM_WORLD, &(info.myId));
int namelen;
char processorName[MPI_MAX_PROCESSOR_NAME];
MPI_Get_processor_name(processorName, &namelen);
info.processorName = string(processorName);
return info;
}
void evalWithRank(int rank, Individual *ent){
MPI_Request request;
MPI_Status status;
MPI_Isend(ent->chrom, ent->length, MPI_DOUBLE, rank, 0, MPI_COMM_WORLD, &request);
//MPI_Request_free(&request); // Does this need to be MPI_Wait?
MPI_Wait(&request,&status);
}
const int DIE_TAG = 101;
void SetupSlaves(int chromLength, int nCriteria){
cout << "Hello world from " << info.processorName << " with rank " << info.myId << " out of " << info.numProcs << endl;
flush(cout);
Individual *ent = new Individual(chromLength, nCriteria);
MPI_Status status;
while(1 == 1){
MPI_Recv(ent->chrom, ent->length, MPI_DOUBLE, 0, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
if(status.MPI_TAG == DIE_TAG) break;
EvalSim(ent, info.myId, 5);
//paretoEval(ent, info.myId);
usleep(10);
//MPI_Send(ent->fitness, MAX_CRITERIA, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD);
MPI_Send(ent->fitness, nCriteria, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD);
}
}
void KillSlaves(int n){
for (int rank = 1; rank < n; rank++){
MPI_Request req;
MPI_Isend(&rank, 0, MPI_INT, rank, DIE_TAG, MPI_COMM_WORLD, &req);
MPI_Request_free(&req);
}
}
int GA::sendInitialEnts(Population *p, int start, int end, int numProcs){
int rank = 1;
int nsent = 0;
for(int i = start; i < start + numProcs - 1 && i < end && rank < numProcs; i++){
RankToPopIndexMap[rank] = i;
evalWithRank(rank, p->pop[i]);
rank++;
nsent++;
}
return nsent;
}
void GA::extractFitnesses(double *fitness, Individual *ent){
ent->fit = 0;
for(int i = 0; i < options.nCriteria; i++){
ent->fitness[i] = fitness[i];
ent->fit += fitness[i];
}
ent->fit = ent->fit/options.nCriteria;
}
void GA::parEval(Population *p, int start, int end){
assert(start >= 0 && start < end);
int nreceived = 0;
int nsent = sendInitialEnts(p, start, end, info.numProcs);
int sendIndex = start + nsent;
double fitness[options.nCriteria];
MPI_Status status;
int entIndex = -1;
while(nreceived < options.popSize) {
MPI_Recv(&fitness, options.nCriteria, MPI_DOUBLE, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &status);
entIndex = RankToPopIndexMap[status.MPI_SOURCE]; //slave with rank status.MPI_SOURCE finished AND is free for more work
extractFitnesses(fitness, p->pop[entIndex]);
//cout << info.myId << ": Index: " << entIndex << " Fitness: " << p->pop[entIndex]->fit << endl;
nreceived++;
if(nsent < options.popSize && sendIndex < end){
RankToPopIndexMap[status.MPI_SOURCE] = sendIndex;
evalWithRank(status.MPI_SOURCE, p->pop[sendIndex]); //send free slave work
sendIndex++; // next member of pop to send
nsent++;
}
}
}
int main(int argc, char *argv[]) {
srand(atoi(argv[3]));
info = initMPI(argc, argv);
GA pga = GA(argc, argv);
cout<<atoi(argv[3])<<" -------------- "<<endl;
if(info.myId != 0)
SetupSlaves(pga.options.chromLength, pga.options.nCriteria);
if(info.myId == 0){
pga.init();
pga.run();
pga.report();
KillSlaves(info.numProcs);
}
MPI_Finalize();
return 0;
}
GA::GA(int argc, char *argv[]){
setupOptions(argc, argv);
srand(options.randomSeed);
ofstream ofs(options.outfile, std::ofstream::out | std::ofstream::trunc);
ofs.close();
ofstream pofs(options.phenotypeFile, std::ofstream::out | std::ofstream::trunc);
pofs.close();
maxFitGen = 0;
this->bestIndividualSoFar = new Individual(options.chromLength, 1);
bestFitnessSoFar = -1;
}
void GA::init(){
bool done = false;
parent = new Population(options);
child = new Population(options);
parEval(parent, 0, options.popSize);
parent->statistics(parent);
parent->report(0, parent);
updateProgress(0, parent);
}
void GA::run(){//chc
Population *tmp;
for (unsigned int i = 1; i < options.maxgens; i++){
parent->generation(parent);
parEval(parent, options.popSize, options.popSize * options.lambda);
parent->copyChild(parent, child);
child->statistics(child);
child->report(i, child);
updateProgress(i, child);
for(int j=0; j<options.popSize; j++ ){
cout<<child->pop[j]->fit <<" ";
}
cout<<endl;
tmp = parent;
parent = child;
child = tmp;
}
}
/**
* Update and save the best ever individual
*/
void GA::updateProgress(unsigned int gen, Population *p){
if (p->max > bestFitnessSoFar){
bestFitnessSoFar = p->max;
maxFitGen = gen;
bestIndividualSoFar->copy(p->pop[p->maxi]);
char printbuf[1024];
char chromString[MAX_CHROM_LENGTH+1];
chromToString(bestIndividualSoFar->chrom, bestIndividualSoFar->length, chromString);
sprintf(printbuf, "%4i \t %f \t %s\n", maxFitGen, bestFitnessSoFar, chromString);
writeBufToFile(printbuf, options.phenotypeFile);
}
}
void GA::report(){
//parent->report(options.maxgens);
cout << *(parent->pop[parent->maxi]) << endl;
}
void GA::configure(){
ifstream ifs(options.infile);
if(ifs.good()){
ifs >> options.popSize;
ifs >> options.chromLength;
ifs >> options.maxgens;
ifs >> options.px;
ifs >> options.pm;
ifs >> options.scaler;
ifs >> options.lambda;
}
ifs.close();
}
void GA::setupOptions(int argc, char *argv[]){
options.randomSeed = 189;
options.infile = string("infile");
options.outfile = string("outfile_189");// append randomseed to output file names
options.popSize = 10;
options.chromLength = 10;
options.maxgens = 10;
options.px = 0.7f;
options.pm = 0.001f;
options.scaler = 1.05;
options.lambda = 2;
options.nCriteria = 1;
options.mutator = Mutator::Flip;
options.xover = Xover::UX;
options.selector = Selector::Proportionate;
if(argc == 4){
options.infile = string(argv[1]);
options.outfile = string(argv[2]);
options.randomSeed = atoi(argv[3]);
configure();
}
//derived values go after configure() above
options.phenotypeFile = string(options.outfile + ".pheno"); //derived from options.outfile
options.outfile = string(options.outfile);// append randomseed to output file names
//options.maxgens = options.popSize * 1.5;
}
|
b798c69f5ac58fd2452096733d83ebef0976b653 | f1561abc3f4cf1a1e9a2ebf75a8ddb5e5ebefb10 | /SmartFaireLib/MP3.cpp | 810c5626b33c70b4f8d91e8f9d4127ad0c68a6dc | [] | no_license | vrosnet/smartfaire | cf36302cd79e9b29707a08ef3acdac706282b159 | a6a3b4681f46aa7733fb5dff6a853fb617632a57 | refs/heads/master | 2021-01-23T06:34:07.571042 | 2016-07-01T21:49:40 | 2016-07-01T21:49:40 | 93,027,358 | 1 | 0 | null | 2017-06-01T07:08:37 | 2017-06-01T07:08:37 | null | UTF-8 | C++ | false | false | 8,350 | cpp | MP3.cpp | /*
4-28-2011
Spark Fun Electronics 2011
Nathan Seidle
This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
This example code plays a MP3 from the SD card called 'track001.mp3'. The theory is that you can load a
microSD card up with a bunch of MP3s and then play a given 'track' depending on some sort of input such
as which pin is pulled low.
It relies on the sdfatlib from Bill Greiman:
http://code.google.com/p/sdfatlib/
You will need to download and install his library. To compile, you MUST change Sd2PinMap.h of the SDfatlib!
The default SS_PIN = 10;. You must change this line under the ATmega328/Arduino area of code to
uint8_t const SS_PIN = 9;. This will cause the sdfatlib to use pin 9 as the 'chip select' for the
microSD card on pin 9 of the Arduino so that the layout of the shield works.
Attach the shield to an Arduino. Load code (after editing Sd2PinMap.h) then open the terminal at 57600bps. This
example shows that it takes ~30ms to load up the VS1053 buffer. We can then do whatever we want for ~100ms
before we need to return to filling the buffer (for another 30ms).
This code is heavily based on the example code I wrote to control the MP3 shield found here:
http://www.sparkfun.com/products/9736
This example code extends the previous example by reading the MP3 from an SD card and file rather than from internal
memory of the ATmega. Because the current MP3 shield does not have a microSD socket, you will need to add the microSD
shield to your Arduino stack.
The main gotcha from all of this is that you have to make sure your CS pins for each device on an SPI bus is carefully
declared. For the SS pin (aka CS) on the SD FAT libaray, you need to correctly set it within Sd2PinMap.h. The default
pin in Sd2PinMap.h is 10. If you're using the SparkFun microSD shield with the SparkFun MP3 shield, the SD CS pin
is pin 9.
Four pins are needed to control the VS1503:
DREQ
CS
DCS
Reset (optional but good to have access to)
Plus the SPI bus
Only the SPI bus pins and another CS pin are needed to control the microSD card.
What surprised me is the fact that with a normal MP3 we can do other things for up to 100ms while the MP3 IC crunches
through it's fairly large buffer of 2048 bytes. As long as you keep your sensor checks or serial reporting to under
100ms and leave ~30ms to then replenish the MP3 buffer, you can do quite a lot while the MP3 is playing glitch free.
*/
#include "windows.h"
#include "arduino.h"
#include <SPI.h>
#include "MP3.h"
//MP3 Player Shield pin mapping. See the schematic
const int VS1053_XCS = 6; //Control Chip Select Pin (for accessing SPI Control/Status registers)
const int VS1053_XDCS = 7; //Data Chip Select / BSYNC Pin
const int VS1053_DREQ = 2; //Data Request Pin: Player asks for more data
const int VS1053_RESET = 8; //Reset is active low
const int VS1053_GPIO1 = 4;
//VS10xx SCI Registers
#define SCI_MODE 0x00
#define SCI_STATUS 0x01
#define SCI_BASS 0x02
#define SCI_CLOCKF 0x03
#define SCI_DECODE_TIME 0x04
#define SCI_AUDATA 0x05
#define SCI_WRAM 0x06
#define SCI_WRAMADDR 0x07
#define SCI_HDAT0 0x08
#define SCI_HDAT1 0x09
#define SCI_AIADDR 0x0A
#define SCI_VOL 0x0B
#define SCI_AICTRL0 0x0C
#define SCI_AICTRL1 0x0D
#define SCI_AICTRL2 0x0E
#define SCI_AICTRL3 0x0F
void playMP3(char* fileName);
void Mp3WriteRegister(unsigned char addressbyte, unsigned char highbyte, unsigned char lowbyte);
unsigned int Mp3ReadRegister(unsigned char addressbyte);
void Mp3SetVolume(unsigned char leftchannel, unsigned char rightchannel);
MP3::MP3()
{
}
MP3::~MP3()
{
}
void MP3::Init()
{
pinMode(VS1053_DREQ, INPUT);
pinMode(VS1053_XCS, OUTPUT);
pinMode(VS1053_XDCS, OUTPUT);
pinMode(VS1053_RESET, OUTPUT);
pinMode(VS1053_GPIO1, OUTPUT);
digitalWrite(VS1053_XCS, HIGH); //Deselect Control
digitalWrite(VS1053_XDCS, HIGH); //Deselect Data
digitalWrite(VS1053_RESET, LOW); //Put VS1053 into hardware reset
digitalWrite(VS1053_GPIO1, LOW); // Set to MP3 mode
SPI.begin();
//From page 12 of datasheet, max SCI reads are CLKI/7. Input clock is 12.288MHz.
//Internal clock multiplier is 1.0x after power up.
//Therefore, max SPI speed is 1.75MHz. We will use 1MHz to be safe.
SPI.setClockDivider(SPI_CLOCK_DIV16); //Set SPI bus speed to 1MHz (16MHz / 16 = 1MHz)
SPI.transfer(0xFF); //Throw a dummy byte at the bus
//Initialize VS1053 chip
delay(10);
digitalWrite(VS1053_RESET, HIGH); //Bring up VS1053
Mp3SetVolume(40, 40); //Set initial volume (20 = -10dB) Manageable
//Now that we have the VS1053 up and running, increase the internal clock multiplier and up our SPI rate
Mp3WriteRegister(SCI_CLOCKF, 0x60, 0x00); //Set multiplier to 3.0x
//From page 12 of datasheet, max SCI reads are CLKI/7. Input clock is 12.288MHz.
//Internal clock multiplier is now 3x.
//Therefore, max SPI speed is 5MHz. 4MHz will be safe.
SPI.setClockDivider(SPI_CLOCK_DIV4); //Set SPI bus speed to 4MHz (16MHz / 4 = 4MHz)
}
//PlayMP3 pulls 32 byte chunks from the SD card and throws them at the VS1053
//We monitor the DREQ (data request pin). If it goes low then we determine if
//we need new data or not. If yes, pull new from SD card. Then throw the data
//at the VS1053 until it is full.
void MP3::PlayFileSync(const char* FileName)
{
HANDLE hFile = CreateFileA(FileName, GENERIC_READ, NULL, NULL, OPEN_EXISTING, NULL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
Log("Failed to open %s\r\n", FileName);
return;
}
Log("Track open\r\n");
Log("Start MP3 decoding\r\n");
bool done = false;
while (!done)
{
while (digitalRead(VS1053_DREQ))
{
//Log("+");
// Buffer has space. Feed it.
uint8_t mp3DataBuffer[32]; //Buffer of 32 bytes. VS1053 can take 32 bytes at a go.
DWORD cbRead = 0;
if (!ReadFile(hFile, mp3DataBuffer, sizeof(mp3DataBuffer), &cbRead, NULL) || cbRead == 0)
{
//Oh no! There is no data left to read!
//Time to exit
done = true;
break;
}
digitalWrite(VS1053_XDCS, LOW); //Select Data
for (int y = 0; y < sizeof(mp3DataBuffer); y++)
{
SPI.transfer(mp3DataBuffer[y]); // Send SPI byte
}
digitalWrite(VS1053_XDCS, HIGH); //Deselect Data
}
// Buffer was full. Sleep for a while before trying again.
Log(".");
Sleep(100);
}
Log("\r\n");
while (!digitalRead(VS1053_DREQ)); //Wait for DREQ to go high indicating transfer is complete
digitalWrite(VS1053_XDCS, HIGH); //Deselect Data
CloseHandle(hFile);
Log("Track %s done!\r\n", FileName);
}
//Write to VS10xx register
//SCI: Data transfers are always 16bit. When a new SCI operation comes in
//DREQ goes low. We then have to wait for DREQ to go high again.
//XCS should be low for the full duration of operation.
void MP3::Mp3WriteRegister(unsigned char addressbyte, unsigned char highbyte, unsigned char lowbyte)
{
while (!digitalRead(VS1053_DREQ)); //Wait for DREQ to go high indicating IC is available
digitalWrite(VS1053_XCS, LOW); //Select control
//SCI consists of instruction byte, address byte, and 16-bit data word.
SPI.transfer(0x02); //Write instruction
SPI.transfer(addressbyte);
SPI.transfer(highbyte);
SPI.transfer(lowbyte);
while (!digitalRead(VS1053_DREQ)); //Wait for DREQ to go high indicating command is complete
digitalWrite(VS1053_XCS, HIGH); //Deselect Control
}
//Read the 16-bit value of a VS10xx register
unsigned int MP3::Mp3ReadRegister(unsigned char addressbyte)
{
while (!digitalRead(VS1053_DREQ)); //Wait for DREQ to go high indicating IC is available
digitalWrite(VS1053_XCS, LOW); //Select control
//SCI consists of instruction byte, address byte, and 16-bit data word.
SPI.transfer(0x03); //Read instruction
SPI.transfer(addressbyte);
char response1 = (char)SPI.transfer(0xFF); //Read the first byte
while (!digitalRead(VS1053_DREQ)); //Wait for DREQ to go high indicating command is complete
char response2 = (char)SPI.transfer(0xFF); //Read the second byte
while (!digitalRead(VS1053_DREQ)); //Wait for DREQ to go high indicating command is complete
digitalWrite(VS1053_XCS, HIGH); //Deselect Control
int resultvalue = response1 << 8;
resultvalue |= response2;
return resultvalue;
}
//Set VS10xx Volume Register
void MP3::Mp3SetVolume(unsigned char leftchannel, unsigned char rightchannel)
{
Mp3WriteRegister(SCI_VOL, leftchannel, rightchannel);
}
|
c5ae68fdc7c39a8e4f66d7d65d264196e3e5a8fc | 264e7b7f82a06e06b3ba98ee50f3d2498d21b3c5 | /src/rshell_main.cpp | 928b4dab6117aef65f5e2a191b24055882f0b2ff | [
"BSD-3-Clause"
] | permissive | WendyLiDev/rshell | 655756cb03cc0be44dd705b26ec83f9e12c59b53 | 1d46adb7ece6e384ce94d31d00cf98e3161193ce | refs/heads/master | 2023-04-27T05:20:04.683883 | 2016-12-02T06:25:04 | 2016-12-02T06:25:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,120 | cpp | rshell_main.cpp | /* David Swanson CS100 Fall 2016 */
#include<iostream>
#include <string>
using namespace std;
#include "../header/Parser.h"
#include "../header/RShell.h"
string prompt( string cwd ){
/* Output bash-style prompt, with current directory */
cout << cwd << " $ ";
string str;
getline(cin, str);
return str;
}
int main( int argc, char* argv[] ){
/* Dirs is array length 3:
0=current working directory
1=previous directory
2=home directory
*/
string dirs[]={ "", "", UT::getHomeDir() };
UT::updateDirs( dirs );
/* Accept command line args or console input:
First check for args
*/
if ( argc > 1 ){
Composite* C=new Composite( UT::cmdLineToStr( argc, argv ), dirs );
if( !C->execute() ){
cout << C->getErrTxt();
}
delete C;
}
else{
do{
/* Get user input and send it to new Composite */
Composite* C=new Composite( prompt( dirs[0] ), dirs );
if( !C->execute() ){
cout << C->getErrTxt();
}
delete C;
UT::updateDirs( dirs );//see if cd was used
}
while( true );//let exit command call exit( 0 );
}
return 0;
}
|
a133c9e721dc980204ff5fe3ffcf4a5182088b0d | 25eda555548d8eb83f0f407dae3b8bb317912d5a | /experiments/unrolled_sizing/outputs/unrolled_8_6_6_500.cpp | f1e9677fd67d59ca8590198d06389c9a808bc181 | [] | no_license | nathanwbrei/matmatmult | 56d741358a09980a639d7a77cd411bef46e1df9a | 57ca841c082e42d52bad670d859474134b22af54 | refs/heads/master | 2021-09-26T08:32:46.610435 | 2018-10-27T22:34:28 | 2018-10-27T22:34:28 | 107,045,930 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 134,513 | cpp | unrolled_8_6_6_500.cpp | void unrolled_8_6_6 (const double* A, const double* B, double* C) {
__asm__ __volatile__(
"movq %0, %%rdi\n\t"
"movq %1, %%rsi\n\t"
"movq %2, %%rdx\n\t"
// unrolled_96x96x96
// for r12 <- 0:1:12)
"movq $0, %%r12\r\n"
"LOOP_TOP_40_%=:\r\n"
// Unrolling over bn and bk
// Load C register block @ (d=0,r=0)
"vmovapd 0(%%rdx), %%zmm26\r\n" // C [0,0] [0,0]
"vmovapd 768(%%rdx), %%zmm27\r\n" // C [0,0] [0,1]
"vmovapd 1536(%%rdx), %%zmm28\r\n" // C [0,0] [0,2]
"vmovapd 2304(%%rdx), %%zmm29\r\n" // C [0,0] [0,3]
"vmovapd 3072(%%rdx), %%zmm30\r\n" // C [0,0] [0,4]
"vmovapd 3840(%%rdx), %%zmm31\r\n" // C [0,0] [0,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=0)
"vmovapd 1536(%%rdi), %%zmm2\r\n" // A [0,0] [0,2]
"vmovapd 2304(%%rdi), %%zmm3\r\n" // A [0,0] [0,3]
"vfmadd231pd 0(%%rsi)%{1to8%}, %%zmm2, %%zmm28\r\n" // C[0:8,2] += A[0:8,2]*B[0,0][2,2]
"vfmadd231pd 8(%%rsi)%{1to8%}, %%zmm2, %%zmm30\r\n" // C[0:8,4] += A[0:8,2]*B[0,0][2,4]
"vfmadd231pd 16(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[0,0][3,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=1)
"vmovapd 8448(%%rdi), %%zmm5\r\n" // A [0,1] [0,5]
"vfmadd231pd 24(%%rsi)%{1to8%}, %%zmm5, %%zmm30\r\n" // C[0:8,4] += A[0:8,5]*B[1,0][5,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=2)
"vmovapd 9984(%%rdi), %%zmm1\r\n" // A [0,2] [0,1]
"vmovapd 10752(%%rdi), %%zmm2\r\n" // A [0,2] [0,2]
"vfmadd231pd 32(%%rsi)%{1to8%}, %%zmm1, %%zmm27\r\n" // C[0:8,1] += A[0:8,1]*B[2,0][1,1]
"vfmadd231pd 48(%%rsi)%{1to8%}, %%zmm1, %%zmm28\r\n" // C[0:8,2] += A[0:8,1]*B[2,0][1,2]
"vfmadd231pd 40(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[2,0][2,1]
"vfmadd231pd 56(%%rsi)%{1to8%}, %%zmm2, %%zmm30\r\n" // C[0:8,4] += A[0:8,2]*B[2,0][2,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=3)
"vmovapd 14592(%%rdi), %%zmm1\r\n" // A [0,3] [0,1]
"vmovapd 16128(%%rdi), %%zmm3\r\n" // A [0,3] [0,3]
"vfmadd231pd 64(%%rsi)%{1to8%}, %%zmm1, %%zmm26\r\n" // C[0:8,0] += A[0:8,1]*B[3,0][1,0]
"vfmadd231pd 80(%%rsi)%{1to8%}, %%zmm1, %%zmm30\r\n" // C[0:8,4] += A[0:8,1]*B[3,0][1,4]
"vfmadd231pd 72(%%rsi)%{1to8%}, %%zmm3, %%zmm27\r\n" // C[0:8,1] += A[0:8,3]*B[3,0][3,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=5)
"vmovapd 23040(%%rdi), %%zmm0\r\n" // A [0,5] [0,0]
"vfmadd231pd 88(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[5,0][0,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=6)
"vmovapd 28416(%%rdi), %%zmm1\r\n" // A [0,6] [0,1]
"vmovapd 29184(%%rdi), %%zmm2\r\n" // A [0,6] [0,2]
"vmovapd 31488(%%rdi), %%zmm5\r\n" // A [0,6] [0,5]
"vfmadd231pd 112(%%rsi)%{1to8%}, %%zmm1, %%zmm30\r\n" // C[0:8,4] += A[0:8,1]*B[6,0][1,4]
"vfmadd231pd 104(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[6,0][2,3]
"vfmadd231pd 96(%%rsi)%{1to8%}, %%zmm5, %%zmm28\r\n" // C[0:8,2] += A[0:8,5]*B[6,0][5,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=8)
"vmovapd 38400(%%rdi), %%zmm2\r\n" // A [0,8] [0,2]
"vmovapd 39936(%%rdi), %%zmm4\r\n" // A [0,8] [0,4]
"vfmadd231pd 120(%%rsi)%{1to8%}, %%zmm2, %%zmm28\r\n" // C[0:8,2] += A[0:8,2]*B[8,0][2,2]
"vfmadd231pd 128(%%rsi)%{1to8%}, %%zmm4, %%zmm30\r\n" // C[0:8,4] += A[0:8,4]*B[8,0][4,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=9)
"vmovapd 41472(%%rdi), %%zmm0\r\n" // A [0,9] [0,0]
"vmovapd 44544(%%rdi), %%zmm4\r\n" // A [0,9] [0,4]
"vfmadd231pd 144(%%rsi)%{1to8%}, %%zmm0, %%zmm29\r\n" // C[0:8,3] += A[0:8,0]*B[9,0][0,3]
"vfmadd231pd 136(%%rsi)%{1to8%}, %%zmm4, %%zmm26\r\n" // C[0:8,0] += A[0:8,4]*B[9,0][4,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=10)
"vmovapd 49152(%%rdi), %%zmm4\r\n" // A [0,10] [0,4]
"vmovapd 49920(%%rdi), %%zmm5\r\n" // A [0,10] [0,5]
"vfmadd231pd 160(%%rsi)%{1to8%}, %%zmm4, %%zmm30\r\n" // C[0:8,4] += A[0:8,4]*B[10,0][4,4]
"vfmadd231pd 152(%%rsi)%{1to8%}, %%zmm5, %%zmm27\r\n" // C[0:8,1] += A[0:8,5]*B[10,0][5,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=11)
"vmovapd 50688(%%rdi), %%zmm0\r\n" // A [0,11] [0,0]
"vmovapd 52992(%%rdi), %%zmm3\r\n" // A [0,11] [0,3]
"vfmadd231pd 168(%%rsi)%{1to8%}, %%zmm0, %%zmm27\r\n" // C[0:8,1] += A[0:8,0]*B[11,0][0,1]
"vfmadd231pd 184(%%rsi)%{1to8%}, %%zmm0, %%zmm30\r\n" // C[0:8,4] += A[0:8,0]*B[11,0][0,4]
"vfmadd231pd 176(%%rsi)%{1to8%}, %%zmm3, %%zmm27\r\n" // C[0:8,1] += A[0:8,3]*B[11,0][3,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=13)
"vmovapd 59904(%%rdi), %%zmm0\r\n" // A [0,13] [0,0]
"vmovapd 60672(%%rdi), %%zmm1\r\n" // A [0,13] [0,1]
"vmovapd 62976(%%rdi), %%zmm4\r\n" // A [0,13] [0,4]
"vmovapd 63744(%%rdi), %%zmm5\r\n" // A [0,13] [0,5]
"vfmadd231pd 208(%%rsi)%{1to8%}, %%zmm0, %%zmm28\r\n" // C[0:8,2] += A[0:8,0]*B[13,0][0,2]
"vfmadd231pd 192(%%rsi)%{1to8%}, %%zmm1, %%zmm26\r\n" // C[0:8,0] += A[0:8,1]*B[13,0][1,0]
"vfmadd231pd 200(%%rsi)%{1to8%}, %%zmm1, %%zmm27\r\n" // C[0:8,1] += A[0:8,1]*B[13,0][1,1]
"vfmadd231pd 216(%%rsi)%{1to8%}, %%zmm1, %%zmm30\r\n" // C[0:8,4] += A[0:8,1]*B[13,0][1,4]
"vfmadd231pd 232(%%rsi)%{1to8%}, %%zmm1, %%zmm31\r\n" // C[0:8,5] += A[0:8,1]*B[13,0][1,5]
"vfmadd231pd 224(%%rsi)%{1to8%}, %%zmm4, %%zmm30\r\n" // C[0:8,4] += A[0:8,4]*B[13,0][4,4]
"vfmadd231pd 240(%%rsi)%{1to8%}, %%zmm5, %%zmm31\r\n" // C[0:8,5] += A[0:8,5]*B[13,0][5,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=14)
"vmovapd 65280(%%rdi), %%zmm1\r\n" // A [0,14] [0,1]
"vmovapd 68352(%%rdi), %%zmm5\r\n" // A [0,14] [0,5]
"vfmadd231pd 248(%%rsi)%{1to8%}, %%zmm1, %%zmm27\r\n" // C[0:8,1] += A[0:8,1]*B[14,0][1,1]
"vfmadd231pd 256(%%rsi)%{1to8%}, %%zmm1, %%zmm30\r\n" // C[0:8,4] += A[0:8,1]*B[14,0][1,4]
"vfmadd231pd 264(%%rsi)%{1to8%}, %%zmm5, %%zmm30\r\n" // C[0:8,4] += A[0:8,5]*B[14,0][5,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=15)
"vmovapd 69888(%%rdi), %%zmm1\r\n" // A [0,15] [0,1]
"vmovapd 70656(%%rdi), %%zmm2\r\n" // A [0,15] [0,2]
"vmovapd 72192(%%rdi), %%zmm4\r\n" // A [0,15] [0,4]
"vmovapd 72960(%%rdi), %%zmm5\r\n" // A [0,15] [0,5]
"vfmadd231pd 304(%%rsi)%{1to8%}, %%zmm1, %%zmm31\r\n" // C[0:8,5] += A[0:8,1]*B[15,0][1,5]
"vfmadd231pd 272(%%rsi)%{1to8%}, %%zmm2, %%zmm26\r\n" // C[0:8,0] += A[0:8,2]*B[15,0][2,0]
"vfmadd231pd 296(%%rsi)%{1to8%}, %%zmm2, %%zmm30\r\n" // C[0:8,4] += A[0:8,2]*B[15,0][2,4]
"vfmadd231pd 288(%%rsi)%{1to8%}, %%zmm4, %%zmm27\r\n" // C[0:8,1] += A[0:8,4]*B[15,0][4,1]
"vfmadd231pd 280(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[15,0][5,0]
// Store C register block @ (d=0,r=0)
"vmovapd %%zmm26, 0(%%rdx)\r\n" // C [0,0] [0,0]
"vmovapd %%zmm27, 768(%%rdx)\r\n" // C [0,0] [0,1]
"vmovapd %%zmm28, 1536(%%rdx)\r\n" // C [0,0] [0,2]
"vmovapd %%zmm29, 2304(%%rdx)\r\n" // C [0,0] [0,3]
"vmovapd %%zmm30, 3072(%%rdx)\r\n" // C [0,0] [0,4]
"vmovapd %%zmm31, 3840(%%rdx)\r\n" // C [0,0] [0,5]
"addq $4608, %%rdx\r\n" // Move C to (d=0,r=1)
// Load C register block @ (d=0,r=0)
"vmovapd 0(%%rdx), %%zmm26\r\n" // C [0,0] [0,0]
"vmovapd 768(%%rdx), %%zmm27\r\n" // C [0,0] [0,1]
"vmovapd 1536(%%rdx), %%zmm28\r\n" // C [0,0] [0,2]
"vmovapd 2304(%%rdx), %%zmm29\r\n" // C [0,0] [0,3]
"vmovapd 3072(%%rdx), %%zmm30\r\n" // C [0,0] [0,4]
"vmovapd 3840(%%rdx), %%zmm31\r\n" // C [0,0] [0,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=0)
"vmovapd 2304(%%rdi), %%zmm3\r\n" // A [0,0] [0,3]
"vmovapd 3840(%%rdi), %%zmm5\r\n" // A [0,0] [0,5]
"vfmadd231pd 320(%%rsi)%{1to8%}, %%zmm3, %%zmm29\r\n" // C[0:8,3] += A[0:8,3]*B[0,1][3,3]
"vfmadd231pd 312(%%rsi)%{1to8%}, %%zmm5, %%zmm28\r\n" // C[0:8,2] += A[0:8,5]*B[0,1][5,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=1)
"vmovapd 4608(%%rdi), %%zmm0\r\n" // A [0,1] [0,0]
"vfmadd231pd 328(%%rsi)%{1to8%}, %%zmm0, %%zmm27\r\n" // C[0:8,1] += A[0:8,0]*B[1,1][0,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=2)
"vmovapd 9216(%%rdi), %%zmm0\r\n" // A [0,2] [0,0]
"vmovapd 13056(%%rdi), %%zmm5\r\n" // A [0,2] [0,5]
"vfmadd231pd 336(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[2,1][0,0]
"vfmadd231pd 344(%%rsi)%{1to8%}, %%zmm0, %%zmm27\r\n" // C[0:8,1] += A[0:8,0]*B[2,1][0,1]
"vfmadd231pd 352(%%rsi)%{1to8%}, %%zmm5, %%zmm31\r\n" // C[0:8,5] += A[0:8,5]*B[2,1][5,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=3)
"vmovapd 15360(%%rdi), %%zmm2\r\n" // A [0,3] [0,2]
"vmovapd 16896(%%rdi), %%zmm4\r\n" // A [0,3] [0,4]
"vfmadd231pd 360(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[3,1][2,1]
"vfmadd231pd 368(%%rsi)%{1to8%}, %%zmm4, %%zmm27\r\n" // C[0:8,1] += A[0:8,4]*B[3,1][4,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=5)
"vmovapd 23040(%%rdi), %%zmm0\r\n" // A [0,5] [0,0]
"vfmadd231pd 376(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[5,1][0,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=6)
"vmovapd 27648(%%rdi), %%zmm0\r\n" // A [0,6] [0,0]
"vfmadd231pd 384(%%rsi)%{1to8%}, %%zmm0, %%zmm27\r\n" // C[0:8,1] += A[0:8,0]*B[6,1][0,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=7)
"vmovapd 34560(%%rdi), %%zmm3\r\n" // A [0,7] [0,3]
"vmovapd 35328(%%rdi), %%zmm4\r\n" // A [0,7] [0,4]
"vfmadd231pd 392(%%rsi)%{1to8%}, %%zmm3, %%zmm30\r\n" // C[0:8,4] += A[0:8,3]*B[7,1][3,4]
"vfmadd231pd 400(%%rsi)%{1to8%}, %%zmm4, %%zmm31\r\n" // C[0:8,5] += A[0:8,4]*B[7,1][4,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=8)
"vmovapd 39168(%%rdi), %%zmm3\r\n" // A [0,8] [0,3]
"vfmadd231pd 408(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[8,1][3,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=9)
"vmovapd 41472(%%rdi), %%zmm0\r\n" // A [0,9] [0,0]
"vmovapd 42240(%%rdi), %%zmm1\r\n" // A [0,9] [0,1]
"vmovapd 43776(%%rdi), %%zmm3\r\n" // A [0,9] [0,3]
"vfmadd231pd 416(%%rsi)%{1to8%}, %%zmm0, %%zmm27\r\n" // C[0:8,1] += A[0:8,0]*B[9,1][0,1]
"vfmadd231pd 424(%%rsi)%{1to8%}, %%zmm0, %%zmm28\r\n" // C[0:8,2] += A[0:8,0]*B[9,1][0,2]
"vfmadd231pd 440(%%rsi)%{1to8%}, %%zmm1, %%zmm29\r\n" // C[0:8,3] += A[0:8,1]*B[9,1][1,3]
"vfmadd231pd 432(%%rsi)%{1to8%}, %%zmm3, %%zmm28\r\n" // C[0:8,2] += A[0:8,3]*B[9,1][3,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=10)
"vmovapd 47616(%%rdi), %%zmm2\r\n" // A [0,10] [0,2]
"vmovapd 49920(%%rdi), %%zmm5\r\n" // A [0,10] [0,5]
"vfmadd231pd 456(%%rsi)%{1to8%}, %%zmm2, %%zmm30\r\n" // C[0:8,4] += A[0:8,2]*B[10,1][2,4]
"vfmadd231pd 448(%%rsi)%{1to8%}, %%zmm5, %%zmm28\r\n" // C[0:8,2] += A[0:8,5]*B[10,1][5,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=11)
"vmovapd 50688(%%rdi), %%zmm0\r\n" // A [0,11] [0,0]
"vfmadd231pd 464(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[11,1][0,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=12)
"vmovapd 55296(%%rdi), %%zmm0\r\n" // A [0,12] [0,0]
"vmovapd 56064(%%rdi), %%zmm1\r\n" // A [0,12] [0,1]
"vmovapd 57600(%%rdi), %%zmm3\r\n" // A [0,12] [0,3]
"vmovapd 58368(%%rdi), %%zmm4\r\n" // A [0,12] [0,4]
"vfmadd231pd 472(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[12,1][0,0]
"vfmadd231pd 480(%%rsi)%{1to8%}, %%zmm1, %%zmm28\r\n" // C[0:8,2] += A[0:8,1]*B[12,1][1,2]
"vfmadd231pd 496(%%rsi)%{1to8%}, %%zmm3, %%zmm30\r\n" // C[0:8,4] += A[0:8,3]*B[12,1][3,4]
"vfmadd231pd 488(%%rsi)%{1to8%}, %%zmm4, %%zmm29\r\n" // C[0:8,3] += A[0:8,4]*B[12,1][4,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=14)
"vmovapd 66816(%%rdi), %%zmm3\r\n" // A [0,14] [0,3]
"vfmadd231pd 504(%%rsi)%{1to8%}, %%zmm3, %%zmm26\r\n" // C[0:8,0] += A[0:8,3]*B[14,1][3,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=15)
"vmovapd 69888(%%rdi), %%zmm1\r\n" // A [0,15] [0,1]
"vfmadd231pd 512(%%rsi)%{1to8%}, %%zmm1, %%zmm30\r\n" // C[0:8,4] += A[0:8,1]*B[15,1][1,4]
// Store C register block @ (d=0,r=0)
"vmovapd %%zmm26, 0(%%rdx)\r\n" // C [0,0] [0,0]
"vmovapd %%zmm27, 768(%%rdx)\r\n" // C [0,0] [0,1]
"vmovapd %%zmm28, 1536(%%rdx)\r\n" // C [0,0] [0,2]
"vmovapd %%zmm29, 2304(%%rdx)\r\n" // C [0,0] [0,3]
"vmovapd %%zmm30, 3072(%%rdx)\r\n" // C [0,0] [0,4]
"vmovapd %%zmm31, 3840(%%rdx)\r\n" // C [0,0] [0,5]
"addq $4608, %%rdx\r\n" // Move C to (d=0,r=1)
// Load C register block @ (d=0,r=0)
"vmovapd 0(%%rdx), %%zmm26\r\n" // C [0,0] [0,0]
"vmovapd 768(%%rdx), %%zmm27\r\n" // C [0,0] [0,1]
"vmovapd 1536(%%rdx), %%zmm28\r\n" // C [0,0] [0,2]
"vmovapd 2304(%%rdx), %%zmm29\r\n" // C [0,0] [0,3]
"vmovapd 3072(%%rdx), %%zmm30\r\n" // C [0,0] [0,4]
"vmovapd 3840(%%rdx), %%zmm31\r\n" // C [0,0] [0,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=0)
"vmovapd 1536(%%rdi), %%zmm2\r\n" // A [0,0] [0,2]
"vfmadd231pd 520(%%rsi)%{1to8%}, %%zmm2, %%zmm28\r\n" // C[0:8,2] += A[0:8,2]*B[0,2][2,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=1)
"vmovapd 5376(%%rdi), %%zmm1\r\n" // A [0,1] [0,1]
"vmovapd 6144(%%rdi), %%zmm2\r\n" // A [0,1] [0,2]
"vmovapd 7680(%%rdi), %%zmm4\r\n" // A [0,1] [0,4]
"vmovapd 8448(%%rdi), %%zmm5\r\n" // A [0,1] [0,5]
"vfmadd231pd 552(%%rsi)%{1to8%}, %%zmm1, %%zmm29\r\n" // C[0:8,3] += A[0:8,1]*B[1,2][1,3]
"vfmadd231pd 536(%%rsi)%{1to8%}, %%zmm2, %%zmm28\r\n" // C[0:8,2] += A[0:8,2]*B[1,2][2,2]
"vfmadd231pd 528(%%rsi)%{1to8%}, %%zmm4, %%zmm26\r\n" // C[0:8,0] += A[0:8,4]*B[1,2][4,0]
"vfmadd231pd 544(%%rsi)%{1to8%}, %%zmm5, %%zmm28\r\n" // C[0:8,2] += A[0:8,5]*B[1,2][5,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=2)
"vmovapd 9984(%%rdi), %%zmm1\r\n" // A [0,2] [0,1]
"vfmadd231pd 560(%%rsi)%{1to8%}, %%zmm1, %%zmm31\r\n" // C[0:8,5] += A[0:8,1]*B[2,2][1,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=3)
"vmovapd 16896(%%rdi), %%zmm4\r\n" // A [0,3] [0,4]
"vfmadd231pd 568(%%rsi)%{1to8%}, %%zmm4, %%zmm28\r\n" // C[0:8,2] += A[0:8,4]*B[3,2][4,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=4)
"vmovapd 18432(%%rdi), %%zmm0\r\n" // A [0,4] [0,0]
"vmovapd 19200(%%rdi), %%zmm1\r\n" // A [0,4] [0,1]
"vmovapd 20736(%%rdi), %%zmm3\r\n" // A [0,4] [0,3]
"vmovapd 21504(%%rdi), %%zmm4\r\n" // A [0,4] [0,4]
"vfmadd231pd 592(%%rsi)%{1to8%}, %%zmm0, %%zmm31\r\n" // C[0:8,5] += A[0:8,0]*B[4,2][0,5]
"vfmadd231pd 576(%%rsi)%{1to8%}, %%zmm1, %%zmm29\r\n" // C[0:8,3] += A[0:8,1]*B[4,2][1,3]
"vfmadd231pd 584(%%rsi)%{1to8%}, %%zmm3, %%zmm29\r\n" // C[0:8,3] += A[0:8,3]*B[4,2][3,3]
"vfmadd231pd 600(%%rsi)%{1to8%}, %%zmm4, %%zmm31\r\n" // C[0:8,5] += A[0:8,4]*B[4,2][4,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=5)
"vmovapd 25344(%%rdi), %%zmm3\r\n" // A [0,5] [0,3]
"vfmadd231pd 608(%%rsi)%{1to8%}, %%zmm3, %%zmm26\r\n" // C[0:8,0] += A[0:8,3]*B[5,2][3,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=6)
"vmovapd 27648(%%rdi), %%zmm0\r\n" // A [0,6] [0,0]
"vfmadd231pd 616(%%rsi)%{1to8%}, %%zmm0, %%zmm31\r\n" // C[0:8,5] += A[0:8,0]*B[6,2][0,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=7)
"vmovapd 33024(%%rdi), %%zmm1\r\n" // A [0,7] [0,1]
"vmovapd 35328(%%rdi), %%zmm4\r\n" // A [0,7] [0,4]
"vmovapd 36096(%%rdi), %%zmm5\r\n" // A [0,7] [0,5]
"vfmadd231pd 624(%%rsi)%{1to8%}, %%zmm1, %%zmm27\r\n" // C[0:8,1] += A[0:8,1]*B[7,2][1,1]
"vfmadd231pd 632(%%rsi)%{1to8%}, %%zmm4, %%zmm27\r\n" // C[0:8,1] += A[0:8,4]*B[7,2][4,1]
"vfmadd231pd 640(%%rsi)%{1to8%}, %%zmm5, %%zmm30\r\n" // C[0:8,4] += A[0:8,5]*B[7,2][5,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=9)
"vmovapd 43008(%%rdi), %%zmm2\r\n" // A [0,9] [0,2]
"vmovapd 44544(%%rdi), %%zmm4\r\n" // A [0,9] [0,4]
"vmovapd 45312(%%rdi), %%zmm5\r\n" // A [0,9] [0,5]
"vfmadd231pd 656(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[9,2][2,1]
"vfmadd231pd 664(%%rsi)%{1to8%}, %%zmm4, %%zmm30\r\n" // C[0:8,4] += A[0:8,4]*B[9,2][4,4]
"vfmadd231pd 648(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[9,2][5,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=10)
"vmovapd 46080(%%rdi), %%zmm0\r\n" // A [0,10] [0,0]
"vmovapd 47616(%%rdi), %%zmm2\r\n" // A [0,10] [0,2]
"vmovapd 48384(%%rdi), %%zmm3\r\n" // A [0,10] [0,3]
"vfmadd231pd 672(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[10,2][0,0]
"vfmadd231pd 712(%%rsi)%{1to8%}, %%zmm0, %%zmm31\r\n" // C[0:8,5] += A[0:8,0]*B[10,2][0,5]
"vfmadd231pd 688(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[10,2][2,1]
"vfmadd231pd 696(%%rsi)%{1to8%}, %%zmm2, %%zmm28\r\n" // C[0:8,2] += A[0:8,2]*B[10,2][2,2]
"vfmadd231pd 704(%%rsi)%{1to8%}, %%zmm2, %%zmm30\r\n" // C[0:8,4] += A[0:8,2]*B[10,2][2,4]
"vfmadd231pd 680(%%rsi)%{1to8%}, %%zmm3, %%zmm26\r\n" // C[0:8,0] += A[0:8,3]*B[10,2][3,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=11)
"vmovapd 50688(%%rdi), %%zmm0\r\n" // A [0,11] [0,0]
"vmovapd 52224(%%rdi), %%zmm2\r\n" // A [0,11] [0,2]
"vfmadd231pd 728(%%rsi)%{1to8%}, %%zmm0, %%zmm30\r\n" // C[0:8,4] += A[0:8,0]*B[11,2][0,4]
"vfmadd231pd 720(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[11,2][2,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=12)
"vmovapd 56064(%%rdi), %%zmm1\r\n" // A [0,12] [0,1]
"vmovapd 57600(%%rdi), %%zmm3\r\n" // A [0,12] [0,3]
"vmovapd 59136(%%rdi), %%zmm5\r\n" // A [0,12] [0,5]
"vfmadd231pd 736(%%rsi)%{1to8%}, %%zmm1, %%zmm26\r\n" // C[0:8,0] += A[0:8,1]*B[12,2][1,0]
"vfmadd231pd 744(%%rsi)%{1to8%}, %%zmm3, %%zmm26\r\n" // C[0:8,0] += A[0:8,3]*B[12,2][3,0]
"vfmadd231pd 752(%%rsi)%{1to8%}, %%zmm3, %%zmm27\r\n" // C[0:8,1] += A[0:8,3]*B[12,2][3,1]
"vfmadd231pd 760(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[12,2][3,5]
"vfmadd231pd 768(%%rsi)%{1to8%}, %%zmm5, %%zmm31\r\n" // C[0:8,5] += A[0:8,5]*B[12,2][5,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=13)
"vmovapd 60672(%%rdi), %%zmm1\r\n" // A [0,13] [0,1]
"vfmadd231pd 776(%%rsi)%{1to8%}, %%zmm1, %%zmm31\r\n" // C[0:8,5] += A[0:8,1]*B[13,2][1,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=14)
"vmovapd 65280(%%rdi), %%zmm1\r\n" // A [0,14] [0,1]
"vmovapd 66816(%%rdi), %%zmm3\r\n" // A [0,14] [0,3]
"vfmadd231pd 784(%%rsi)%{1to8%}, %%zmm1, %%zmm27\r\n" // C[0:8,1] += A[0:8,1]*B[14,2][1,1]
"vfmadd231pd 792(%%rsi)%{1to8%}, %%zmm3, %%zmm29\r\n" // C[0:8,3] += A[0:8,3]*B[14,2][3,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=15)
"vmovapd 69120(%%rdi), %%zmm0\r\n" // A [0,15] [0,0]
"vmovapd 72192(%%rdi), %%zmm4\r\n" // A [0,15] [0,4]
"vfmadd231pd 800(%%rsi)%{1to8%}, %%zmm0, %%zmm28\r\n" // C[0:8,2] += A[0:8,0]*B[15,2][0,2]
"vfmadd231pd 816(%%rsi)%{1to8%}, %%zmm0, %%zmm30\r\n" // C[0:8,4] += A[0:8,0]*B[15,2][0,4]
"vfmadd231pd 808(%%rsi)%{1to8%}, %%zmm4, %%zmm28\r\n" // C[0:8,2] += A[0:8,4]*B[15,2][4,2]
// Store C register block @ (d=0,r=0)
"vmovapd %%zmm26, 0(%%rdx)\r\n" // C [0,0] [0,0]
"vmovapd %%zmm27, 768(%%rdx)\r\n" // C [0,0] [0,1]
"vmovapd %%zmm28, 1536(%%rdx)\r\n" // C [0,0] [0,2]
"vmovapd %%zmm29, 2304(%%rdx)\r\n" // C [0,0] [0,3]
"vmovapd %%zmm30, 3072(%%rdx)\r\n" // C [0,0] [0,4]
"vmovapd %%zmm31, 3840(%%rdx)\r\n" // C [0,0] [0,5]
"addq $4608, %%rdx\r\n" // Move C to (d=0,r=1)
// Load C register block @ (d=0,r=0)
"vmovapd 0(%%rdx), %%zmm26\r\n" // C [0,0] [0,0]
"vmovapd 768(%%rdx), %%zmm27\r\n" // C [0,0] [0,1]
"vmovapd 1536(%%rdx), %%zmm28\r\n" // C [0,0] [0,2]
"vmovapd 2304(%%rdx), %%zmm29\r\n" // C [0,0] [0,3]
"vmovapd 3072(%%rdx), %%zmm30\r\n" // C [0,0] [0,4]
"vmovapd 3840(%%rdx), %%zmm31\r\n" // C [0,0] [0,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=0)
"vmovapd 0(%%rdi), %%zmm0\r\n" // A [0,0] [0,0]
"vmovapd 2304(%%rdi), %%zmm3\r\n" // A [0,0] [0,3]
"vmovapd 3072(%%rdi), %%zmm4\r\n" // A [0,0] [0,4]
"vfmadd231pd 840(%%rsi)%{1to8%}, %%zmm0, %%zmm31\r\n" // C[0:8,5] += A[0:8,0]*B[0,3][0,5]
"vfmadd231pd 832(%%rsi)%{1to8%}, %%zmm3, %%zmm30\r\n" // C[0:8,4] += A[0:8,3]*B[0,3][3,4]
"vfmadd231pd 824(%%rsi)%{1to8%}, %%zmm4, %%zmm28\r\n" // C[0:8,2] += A[0:8,4]*B[0,3][4,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=1)
"vmovapd 4608(%%rdi), %%zmm0\r\n" // A [0,1] [0,0]
"vmovapd 5376(%%rdi), %%zmm1\r\n" // A [0,1] [0,1]
"vfmadd231pd 848(%%rsi)%{1to8%}, %%zmm0, %%zmm31\r\n" // C[0:8,5] += A[0:8,0]*B[1,3][0,5]
"vfmadd231pd 856(%%rsi)%{1to8%}, %%zmm1, %%zmm31\r\n" // C[0:8,5] += A[0:8,1]*B[1,3][1,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=2)
"vmovapd 9216(%%rdi), %%zmm0\r\n" // A [0,2] [0,0]
"vmovapd 10752(%%rdi), %%zmm2\r\n" // A [0,2] [0,2]
"vmovapd 11520(%%rdi), %%zmm3\r\n" // A [0,2] [0,3]
"vfmadd231pd 872(%%rsi)%{1to8%}, %%zmm0, %%zmm27\r\n" // C[0:8,1] += A[0:8,0]*B[2,3][0,1]
"vfmadd231pd 880(%%rsi)%{1to8%}, %%zmm2, %%zmm30\r\n" // C[0:8,4] += A[0:8,2]*B[2,3][2,4]
"vfmadd231pd 864(%%rsi)%{1to8%}, %%zmm3, %%zmm26\r\n" // C[0:8,0] += A[0:8,3]*B[2,3][3,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=4)
"vmovapd 19968(%%rdi), %%zmm2\r\n" // A [0,4] [0,2]
"vmovapd 21504(%%rdi), %%zmm4\r\n" // A [0,4] [0,4]
"vmovapd 22272(%%rdi), %%zmm5\r\n" // A [0,4] [0,5]
"vfmadd231pd 888(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[4,3][2,1]
"vfmadd231pd 896(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[4,3][2,3]
"vfmadd231pd 912(%%rsi)%{1to8%}, %%zmm4, %%zmm31\r\n" // C[0:8,5] += A[0:8,4]*B[4,3][4,5]
"vfmadd231pd 904(%%rsi)%{1to8%}, %%zmm5, %%zmm29\r\n" // C[0:8,3] += A[0:8,5]*B[4,3][5,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=5)
"vmovapd 23040(%%rdi), %%zmm0\r\n" // A [0,5] [0,0]
"vfmadd231pd 920(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[5,3][0,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=6)
"vmovapd 29952(%%rdi), %%zmm3\r\n" // A [0,6] [0,3]
"vfmadd231pd 928(%%rsi)%{1to8%}, %%zmm3, %%zmm28\r\n" // C[0:8,2] += A[0:8,3]*B[6,3][3,2]
"vfmadd231pd 936(%%rsi)%{1to8%}, %%zmm3, %%zmm29\r\n" // C[0:8,3] += A[0:8,3]*B[6,3][3,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=8)
"vmovapd 36864(%%rdi), %%zmm0\r\n" // A [0,8] [0,0]
"vmovapd 37632(%%rdi), %%zmm1\r\n" // A [0,8] [0,1]
"vmovapd 38400(%%rdi), %%zmm2\r\n" // A [0,8] [0,2]
"vmovapd 39168(%%rdi), %%zmm3\r\n" // A [0,8] [0,3]
"vmovapd 40704(%%rdi), %%zmm5\r\n" // A [0,8] [0,5]
"vfmadd231pd 984(%%rsi)%{1to8%}, %%zmm0, %%zmm30\r\n" // C[0:8,4] += A[0:8,0]*B[8,3][0,4]
"vfmadd231pd 944(%%rsi)%{1to8%}, %%zmm1, %%zmm27\r\n" // C[0:8,1] += A[0:8,1]*B[8,3][1,1]
"vfmadd231pd 992(%%rsi)%{1to8%}, %%zmm1, %%zmm30\r\n" // C[0:8,4] += A[0:8,1]*B[8,3][1,4]
"vfmadd231pd 952(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[8,3][2,1]
"vfmadd231pd 960(%%rsi)%{1to8%}, %%zmm3, %%zmm28\r\n" // C[0:8,2] += A[0:8,3]*B[8,3][3,2]
"vfmadd231pd 976(%%rsi)%{1to8%}, %%zmm3, %%zmm29\r\n" // C[0:8,3] += A[0:8,3]*B[8,3][3,3]
"vfmadd231pd 968(%%rsi)%{1to8%}, %%zmm5, %%zmm28\r\n" // C[0:8,2] += A[0:8,5]*B[8,3][5,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=9)
"vmovapd 43776(%%rdi), %%zmm3\r\n" // A [0,9] [0,3]
"vfmadd231pd 1000(%%rsi)%{1to8%}, %%zmm3, %%zmm28\r\n" // C[0:8,2] += A[0:8,3]*B[9,3][3,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=11)
"vmovapd 52224(%%rdi), %%zmm2\r\n" // A [0,11] [0,2]
"vmovapd 54528(%%rdi), %%zmm5\r\n" // A [0,11] [0,5]
"vfmadd231pd 1008(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[11,3][2,1]
"vfmadd231pd 1032(%%rsi)%{1to8%}, %%zmm2, %%zmm31\r\n" // C[0:8,5] += A[0:8,2]*B[11,3][2,5]
"vfmadd231pd 1016(%%rsi)%{1to8%}, %%zmm5, %%zmm29\r\n" // C[0:8,3] += A[0:8,5]*B[11,3][5,3]
"vfmadd231pd 1024(%%rsi)%{1to8%}, %%zmm5, %%zmm30\r\n" // C[0:8,4] += A[0:8,5]*B[11,3][5,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=12)
"vmovapd 56064(%%rdi), %%zmm1\r\n" // A [0,12] [0,1]
"vmovapd 56832(%%rdi), %%zmm2\r\n" // A [0,12] [0,2]
"vmovapd 59136(%%rdi), %%zmm5\r\n" // A [0,12] [0,5]
"vfmadd231pd 1048(%%rsi)%{1to8%}, %%zmm1, %%zmm29\r\n" // C[0:8,3] += A[0:8,1]*B[12,3][1,3]
"vfmadd231pd 1040(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[12,3][2,1]
"vfmadd231pd 1056(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[12,3][2,3]
"vfmadd231pd 1064(%%rsi)%{1to8%}, %%zmm5, %%zmm30\r\n" // C[0:8,4] += A[0:8,5]*B[12,3][5,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=13)
"vmovapd 59904(%%rdi), %%zmm0\r\n" // A [0,13] [0,0]
"vmovapd 61440(%%rdi), %%zmm2\r\n" // A [0,13] [0,2]
"vfmadd231pd 1072(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[13,3][0,0]
"vfmadd231pd 1080(%%rsi)%{1to8%}, %%zmm2, %%zmm26\r\n" // C[0:8,0] += A[0:8,2]*B[13,3][2,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=14)
"vmovapd 65280(%%rdi), %%zmm1\r\n" // A [0,14] [0,1]
"vmovapd 66816(%%rdi), %%zmm3\r\n" // A [0,14] [0,3]
"vmovapd 67584(%%rdi), %%zmm4\r\n" // A [0,14] [0,4]
"vfmadd231pd 1104(%%rsi)%{1to8%}, %%zmm1, %%zmm31\r\n" // C[0:8,5] += A[0:8,1]*B[14,3][1,5]
"vfmadd231pd 1088(%%rsi)%{1to8%}, %%zmm3, %%zmm28\r\n" // C[0:8,2] += A[0:8,3]*B[14,3][3,2]
"vfmadd231pd 1096(%%rsi)%{1to8%}, %%zmm4, %%zmm30\r\n" // C[0:8,4] += A[0:8,4]*B[14,3][4,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=15)
"vmovapd 70656(%%rdi), %%zmm2\r\n" // A [0,15] [0,2]
"vmovapd 72192(%%rdi), %%zmm4\r\n" // A [0,15] [0,4]
"vmovapd 72960(%%rdi), %%zmm5\r\n" // A [0,15] [0,5]
"vfmadd231pd 1120(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[15,3][2,1]
"vfmadd231pd 1128(%%rsi)%{1to8%}, %%zmm4, %%zmm27\r\n" // C[0:8,1] += A[0:8,4]*B[15,3][4,1]
"vfmadd231pd 1112(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[15,3][5,0]
// Store C register block @ (d=0,r=0)
"vmovapd %%zmm26, 0(%%rdx)\r\n" // C [0,0] [0,0]
"vmovapd %%zmm27, 768(%%rdx)\r\n" // C [0,0] [0,1]
"vmovapd %%zmm28, 1536(%%rdx)\r\n" // C [0,0] [0,2]
"vmovapd %%zmm29, 2304(%%rdx)\r\n" // C [0,0] [0,3]
"vmovapd %%zmm30, 3072(%%rdx)\r\n" // C [0,0] [0,4]
"vmovapd %%zmm31, 3840(%%rdx)\r\n" // C [0,0] [0,5]
"addq $4608, %%rdx\r\n" // Move C to (d=0,r=1)
// Load C register block @ (d=0,r=0)
"vmovapd 0(%%rdx), %%zmm26\r\n" // C [0,0] [0,0]
"vmovapd 768(%%rdx), %%zmm27\r\n" // C [0,0] [0,1]
"vmovapd 1536(%%rdx), %%zmm28\r\n" // C [0,0] [0,2]
"vmovapd 2304(%%rdx), %%zmm29\r\n" // C [0,0] [0,3]
"vmovapd 3072(%%rdx), %%zmm30\r\n" // C [0,0] [0,4]
"vmovapd 3840(%%rdx), %%zmm31\r\n" // C [0,0] [0,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=0)
"vmovapd 1536(%%rdi), %%zmm2\r\n" // A [0,0] [0,2]
"vmovapd 3072(%%rdi), %%zmm4\r\n" // A [0,0] [0,4]
"vfmadd231pd 1136(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[0,4][2,1]
"vfmadd231pd 1152(%%rsi)%{1to8%}, %%zmm2, %%zmm31\r\n" // C[0:8,5] += A[0:8,2]*B[0,4][2,5]
"vfmadd231pd 1144(%%rsi)%{1to8%}, %%zmm4, %%zmm27\r\n" // C[0:8,1] += A[0:8,4]*B[0,4][4,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=2)
"vmovapd 9216(%%rdi), %%zmm0\r\n" // A [0,2] [0,0]
"vmovapd 10752(%%rdi), %%zmm2\r\n" // A [0,2] [0,2]
"vfmadd231pd 1160(%%rsi)%{1to8%}, %%zmm0, %%zmm31\r\n" // C[0:8,5] += A[0:8,0]*B[2,4][0,5]
"vfmadd231pd 1168(%%rsi)%{1to8%}, %%zmm2, %%zmm31\r\n" // C[0:8,5] += A[0:8,2]*B[2,4][2,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=3)
"vmovapd 16128(%%rdi), %%zmm3\r\n" // A [0,3] [0,3]
"vmovapd 17664(%%rdi), %%zmm5\r\n" // A [0,3] [0,5]
"vfmadd231pd 1184(%%rsi)%{1to8%}, %%zmm3, %%zmm29\r\n" // C[0:8,3] += A[0:8,3]*B[3,4][3,3]
"vfmadd231pd 1176(%%rsi)%{1to8%}, %%zmm5, %%zmm28\r\n" // C[0:8,2] += A[0:8,5]*B[3,4][5,2]
"vfmadd231pd 1192(%%rsi)%{1to8%}, %%zmm5, %%zmm30\r\n" // C[0:8,4] += A[0:8,5]*B[3,4][5,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=4)
"vmovapd 18432(%%rdi), %%zmm0\r\n" // A [0,4] [0,0]
"vmovapd 20736(%%rdi), %%zmm3\r\n" // A [0,4] [0,3]
"vmovapd 22272(%%rdi), %%zmm5\r\n" // A [0,4] [0,5]
"vfmadd231pd 1200(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[4,4][0,0]
"vfmadd231pd 1208(%%rsi)%{1to8%}, %%zmm3, %%zmm28\r\n" // C[0:8,2] += A[0:8,3]*B[4,4][3,2]
"vfmadd231pd 1224(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[4,4][3,5]
"vfmadd231pd 1216(%%rsi)%{1to8%}, %%zmm5, %%zmm29\r\n" // C[0:8,3] += A[0:8,5]*B[4,4][5,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=5)
"vmovapd 25344(%%rdi), %%zmm3\r\n" // A [0,5] [0,3]
"vfmadd231pd 1232(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[5,4][3,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=8)
"vmovapd 36864(%%rdi), %%zmm0\r\n" // A [0,8] [0,0]
"vfmadd231pd 1240(%%rsi)%{1to8%}, %%zmm0, %%zmm30\r\n" // C[0:8,4] += A[0:8,0]*B[8,4][0,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=9)
"vmovapd 42240(%%rdi), %%zmm1\r\n" // A [0,9] [0,1]
"vmovapd 43776(%%rdi), %%zmm3\r\n" // A [0,9] [0,3]
"vmovapd 45312(%%rdi), %%zmm5\r\n" // A [0,9] [0,5]
"vfmadd231pd 1248(%%rsi)%{1to8%}, %%zmm1, %%zmm26\r\n" // C[0:8,0] += A[0:8,1]*B[9,4][1,0]
"vfmadd231pd 1256(%%rsi)%{1to8%}, %%zmm3, %%zmm27\r\n" // C[0:8,1] += A[0:8,3]*B[9,4][3,1]
"vfmadd231pd 1264(%%rsi)%{1to8%}, %%zmm5, %%zmm27\r\n" // C[0:8,1] += A[0:8,5]*B[9,4][5,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=10)
"vmovapd 48384(%%rdi), %%zmm3\r\n" // A [0,10] [0,3]
"vmovapd 49152(%%rdi), %%zmm4\r\n" // A [0,10] [0,4]
"vfmadd231pd 1272(%%rsi)%{1to8%}, %%zmm3, %%zmm27\r\n" // C[0:8,1] += A[0:8,3]*B[10,4][3,1]
"vfmadd231pd 1288(%%rsi)%{1to8%}, %%zmm3, %%zmm30\r\n" // C[0:8,4] += A[0:8,3]*B[10,4][3,4]
"vfmadd231pd 1280(%%rsi)%{1to8%}, %%zmm4, %%zmm28\r\n" // C[0:8,2] += A[0:8,4]*B[10,4][4,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=11)
"vmovapd 50688(%%rdi), %%zmm0\r\n" // A [0,11] [0,0]
"vfmadd231pd 1296(%%rsi)%{1to8%}, %%zmm0, %%zmm28\r\n" // C[0:8,2] += A[0:8,0]*B[11,4][0,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=12)
"vmovapd 56064(%%rdi), %%zmm1\r\n" // A [0,12] [0,1]
"vmovapd 58368(%%rdi), %%zmm4\r\n" // A [0,12] [0,4]
"vmovapd 59136(%%rdi), %%zmm5\r\n" // A [0,12] [0,5]
"vfmadd231pd 1312(%%rsi)%{1to8%}, %%zmm1, %%zmm30\r\n" // C[0:8,4] += A[0:8,1]*B[12,4][1,4]
"vfmadd231pd 1320(%%rsi)%{1to8%}, %%zmm4, %%zmm30\r\n" // C[0:8,4] += A[0:8,4]*B[12,4][4,4]
"vfmadd231pd 1304(%%rsi)%{1to8%}, %%zmm5, %%zmm27\r\n" // C[0:8,1] += A[0:8,5]*B[12,4][5,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=13)
"vmovapd 59904(%%rdi), %%zmm0\r\n" // A [0,13] [0,0]
"vmovapd 60672(%%rdi), %%zmm1\r\n" // A [0,13] [0,1]
"vmovapd 62208(%%rdi), %%zmm3\r\n" // A [0,13] [0,3]
"vfmadd231pd 1336(%%rsi)%{1to8%}, %%zmm0, %%zmm29\r\n" // C[0:8,3] += A[0:8,0]*B[13,4][0,3]
"vfmadd231pd 1328(%%rsi)%{1to8%}, %%zmm1, %%zmm28\r\n" // C[0:8,2] += A[0:8,1]*B[13,4][1,2]
"vfmadd231pd 1344(%%rsi)%{1to8%}, %%zmm3, %%zmm30\r\n" // C[0:8,4] += A[0:8,3]*B[13,4][3,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=14)
"vmovapd 65280(%%rdi), %%zmm1\r\n" // A [0,14] [0,1]
"vmovapd 66816(%%rdi), %%zmm3\r\n" // A [0,14] [0,3]
"vfmadd231pd 1352(%%rsi)%{1to8%}, %%zmm1, %%zmm26\r\n" // C[0:8,0] += A[0:8,1]*B[14,4][1,0]
"vfmadd231pd 1360(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[14,4][3,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=15)
"vmovapd 70656(%%rdi), %%zmm2\r\n" // A [0,15] [0,2]
"vfmadd231pd 1368(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[15,4][2,1]
// Store C register block @ (d=0,r=0)
"vmovapd %%zmm26, 0(%%rdx)\r\n" // C [0,0] [0,0]
"vmovapd %%zmm27, 768(%%rdx)\r\n" // C [0,0] [0,1]
"vmovapd %%zmm28, 1536(%%rdx)\r\n" // C [0,0] [0,2]
"vmovapd %%zmm29, 2304(%%rdx)\r\n" // C [0,0] [0,3]
"vmovapd %%zmm30, 3072(%%rdx)\r\n" // C [0,0] [0,4]
"vmovapd %%zmm31, 3840(%%rdx)\r\n" // C [0,0] [0,5]
"addq $4608, %%rdx\r\n" // Move C to (d=0,r=1)
// Load C register block @ (d=0,r=0)
"vmovapd 0(%%rdx), %%zmm26\r\n" // C [0,0] [0,0]
"vmovapd 768(%%rdx), %%zmm27\r\n" // C [0,0] [0,1]
"vmovapd 1536(%%rdx), %%zmm28\r\n" // C [0,0] [0,2]
"vmovapd 2304(%%rdx), %%zmm29\r\n" // C [0,0] [0,3]
"vmovapd 3072(%%rdx), %%zmm30\r\n" // C [0,0] [0,4]
"vmovapd 3840(%%rdx), %%zmm31\r\n" // C [0,0] [0,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=0)
"vmovapd 3072(%%rdi), %%zmm4\r\n" // A [0,0] [0,4]
"vmovapd 3840(%%rdi), %%zmm5\r\n" // A [0,0] [0,5]
"vfmadd231pd 1384(%%rsi)%{1to8%}, %%zmm4, %%zmm28\r\n" // C[0:8,2] += A[0:8,4]*B[0,5][4,2]
"vfmadd231pd 1376(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[0,5][5,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=2)
"vmovapd 9984(%%rdi), %%zmm1\r\n" // A [0,2] [0,1]
"vmovapd 13056(%%rdi), %%zmm5\r\n" // A [0,2] [0,5]
"vfmadd231pd 1400(%%rsi)%{1to8%}, %%zmm1, %%zmm28\r\n" // C[0:8,2] += A[0:8,1]*B[2,5][1,2]
"vfmadd231pd 1392(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[2,5][5,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=3)
"vmovapd 14592(%%rdi), %%zmm1\r\n" // A [0,3] [0,1]
"vmovapd 16896(%%rdi), %%zmm4\r\n" // A [0,3] [0,4]
"vmovapd 17664(%%rdi), %%zmm5\r\n" // A [0,3] [0,5]
"vfmadd231pd 1416(%%rsi)%{1to8%}, %%zmm1, %%zmm28\r\n" // C[0:8,2] += A[0:8,1]*B[3,5][1,2]
"vfmadd231pd 1424(%%rsi)%{1to8%}, %%zmm4, %%zmm29\r\n" // C[0:8,3] += A[0:8,4]*B[3,5][4,3]
"vfmadd231pd 1408(%%rsi)%{1to8%}, %%zmm5, %%zmm27\r\n" // C[0:8,1] += A[0:8,5]*B[3,5][5,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=4)
"vmovapd 20736(%%rdi), %%zmm3\r\n" // A [0,4] [0,3]
"vfmadd231pd 1432(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[4,5][3,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=5)
"vmovapd 26112(%%rdi), %%zmm4\r\n" // A [0,5] [0,4]
"vfmadd231pd 1440(%%rsi)%{1to8%}, %%zmm4, %%zmm27\r\n" // C[0:8,1] += A[0:8,4]*B[5,5][4,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=6)
"vmovapd 29184(%%rdi), %%zmm2\r\n" // A [0,6] [0,2]
"vmovapd 29952(%%rdi), %%zmm3\r\n" // A [0,6] [0,3]
"vfmadd231pd 1448(%%rsi)%{1to8%}, %%zmm2, %%zmm31\r\n" // C[0:8,5] += A[0:8,2]*B[6,5][2,5]
"vfmadd231pd 1456(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[6,5][3,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=7)
"vmovapd 33024(%%rdi), %%zmm1\r\n" // A [0,7] [0,1]
"vmovapd 34560(%%rdi), %%zmm3\r\n" // A [0,7] [0,3]
"vfmadd231pd 1464(%%rsi)%{1to8%}, %%zmm1, %%zmm30\r\n" // C[0:8,4] += A[0:8,1]*B[7,5][1,4]
"vfmadd231pd 1472(%%rsi)%{1to8%}, %%zmm3, %%zmm30\r\n" // C[0:8,4] += A[0:8,3]*B[7,5][3,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=8)
"vmovapd 37632(%%rdi), %%zmm1\r\n" // A [0,8] [0,1]
"vmovapd 39168(%%rdi), %%zmm3\r\n" // A [0,8] [0,3]
"vfmadd231pd 1480(%%rsi)%{1to8%}, %%zmm1, %%zmm27\r\n" // C[0:8,1] += A[0:8,1]*B[8,5][1,1]
"vfmadd231pd 1488(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[8,5][3,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=9)
"vmovapd 43008(%%rdi), %%zmm2\r\n" // A [0,9] [0,2]
"vmovapd 45312(%%rdi), %%zmm5\r\n" // A [0,9] [0,5]
"vfmadd231pd 1504(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[9,5][2,3]
"vfmadd231pd 1496(%%rsi)%{1to8%}, %%zmm5, %%zmm28\r\n" // C[0:8,2] += A[0:8,5]*B[9,5][5,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=10)
"vmovapd 46080(%%rdi), %%zmm0\r\n" // A [0,10] [0,0]
"vfmadd231pd 1512(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[10,5][0,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=11)
"vmovapd 52992(%%rdi), %%zmm3\r\n" // A [0,11] [0,3]
"vfmadd231pd 1520(%%rsi)%{1to8%}, %%zmm3, %%zmm26\r\n" // C[0:8,0] += A[0:8,3]*B[11,5][3,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=12)
"vmovapd 55296(%%rdi), %%zmm0\r\n" // A [0,12] [0,0]
"vfmadd231pd 1528(%%rsi)%{1to8%}, %%zmm0, %%zmm30\r\n" // C[0:8,4] += A[0:8,0]*B[12,5][0,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=13)
"vmovapd 59904(%%rdi), %%zmm0\r\n" // A [0,13] [0,0]
"vmovapd 60672(%%rdi), %%zmm1\r\n" // A [0,13] [0,1]
"vfmadd231pd 1536(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[13,5][0,0]
"vfmadd231pd 1544(%%rsi)%{1to8%}, %%zmm1, %%zmm27\r\n" // C[0:8,1] += A[0:8,1]*B[13,5][1,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=14)
"vmovapd 67584(%%rdi), %%zmm4\r\n" // A [0,14] [0,4]
"vmovapd 68352(%%rdi), %%zmm5\r\n" // A [0,14] [0,5]
"vfmadd231pd 1568(%%rsi)%{1to8%}, %%zmm4, %%zmm29\r\n" // C[0:8,3] += A[0:8,4]*B[14,5][4,3]
"vfmadd231pd 1552(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[14,5][5,0]
"vfmadd231pd 1560(%%rsi)%{1to8%}, %%zmm5, %%zmm27\r\n" // C[0:8,1] += A[0:8,5]*B[14,5][5,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=15)
"vmovapd 72960(%%rdi), %%zmm5\r\n" // A [0,15] [0,5]
"vfmadd231pd 1576(%%rsi)%{1to8%}, %%zmm5, %%zmm28\r\n" // C[0:8,2] += A[0:8,5]*B[15,5][5,2]
// Store C register block @ (d=0,r=0)
"vmovapd %%zmm26, 0(%%rdx)\r\n" // C [0,0] [0,0]
"vmovapd %%zmm27, 768(%%rdx)\r\n" // C [0,0] [0,1]
"vmovapd %%zmm28, 1536(%%rdx)\r\n" // C [0,0] [0,2]
"vmovapd %%zmm29, 2304(%%rdx)\r\n" // C [0,0] [0,3]
"vmovapd %%zmm30, 3072(%%rdx)\r\n" // C [0,0] [0,4]
"vmovapd %%zmm31, 3840(%%rdx)\r\n" // C [0,0] [0,5]
"addq $4608, %%rdx\r\n" // Move C to (d=0,r=1)
// Load C register block @ (d=0,r=0)
"vmovapd 0(%%rdx), %%zmm26\r\n" // C [0,0] [0,0]
"vmovapd 768(%%rdx), %%zmm27\r\n" // C [0,0] [0,1]
"vmovapd 1536(%%rdx), %%zmm28\r\n" // C [0,0] [0,2]
"vmovapd 2304(%%rdx), %%zmm29\r\n" // C [0,0] [0,3]
"vmovapd 3072(%%rdx), %%zmm30\r\n" // C [0,0] [0,4]
"vmovapd 3840(%%rdx), %%zmm31\r\n" // C [0,0] [0,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=0)
"vmovapd 2304(%%rdi), %%zmm3\r\n" // A [0,0] [0,3]
"vfmadd231pd 1584(%%rsi)%{1to8%}, %%zmm3, %%zmm29\r\n" // C[0:8,3] += A[0:8,3]*B[0,6][3,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=1)
"vmovapd 4608(%%rdi), %%zmm0\r\n" // A [0,1] [0,0]
"vmovapd 5376(%%rdi), %%zmm1\r\n" // A [0,1] [0,1]
"vmovapd 6144(%%rdi), %%zmm2\r\n" // A [0,1] [0,2]
"vfmadd231pd 1592(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[1,6][0,0]
"vfmadd231pd 1600(%%rsi)%{1to8%}, %%zmm1, %%zmm29\r\n" // C[0:8,3] += A[0:8,1]*B[1,6][1,3]
"vfmadd231pd 1608(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[1,6][2,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=2)
"vmovapd 12288(%%rdi), %%zmm4\r\n" // A [0,2] [0,4]
"vmovapd 13056(%%rdi), %%zmm5\r\n" // A [0,2] [0,5]
"vfmadd231pd 1624(%%rsi)%{1to8%}, %%zmm4, %%zmm30\r\n" // C[0:8,4] += A[0:8,4]*B[2,6][4,4]
"vfmadd231pd 1616(%%rsi)%{1to8%}, %%zmm5, %%zmm29\r\n" // C[0:8,3] += A[0:8,5]*B[2,6][5,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=3)
"vmovapd 16128(%%rdi), %%zmm3\r\n" // A [0,3] [0,3]
"vmovapd 16896(%%rdi), %%zmm4\r\n" // A [0,3] [0,4]
"vfmadd231pd 1632(%%rsi)%{1to8%}, %%zmm3, %%zmm29\r\n" // C[0:8,3] += A[0:8,3]*B[3,6][3,3]
"vfmadd231pd 1640(%%rsi)%{1to8%}, %%zmm4, %%zmm31\r\n" // C[0:8,5] += A[0:8,4]*B[3,6][4,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=4)
"vmovapd 19200(%%rdi), %%zmm1\r\n" // A [0,4] [0,1]
"vmovapd 19968(%%rdi), %%zmm2\r\n" // A [0,4] [0,2]
"vfmadd231pd 1648(%%rsi)%{1to8%}, %%zmm1, %%zmm27\r\n" // C[0:8,1] += A[0:8,1]*B[4,6][1,1]
"vfmadd231pd 1656(%%rsi)%{1to8%}, %%zmm1, %%zmm29\r\n" // C[0:8,3] += A[0:8,1]*B[4,6][1,3]
"vfmadd231pd 1664(%%rsi)%{1to8%}, %%zmm2, %%zmm30\r\n" // C[0:8,4] += A[0:8,2]*B[4,6][2,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=5)
"vmovapd 23040(%%rdi), %%zmm0\r\n" // A [0,5] [0,0]
"vmovapd 23808(%%rdi), %%zmm1\r\n" // A [0,5] [0,1]
"vmovapd 25344(%%rdi), %%zmm3\r\n" // A [0,5] [0,3]
"vfmadd231pd 1688(%%rsi)%{1to8%}, %%zmm0, %%zmm30\r\n" // C[0:8,4] += A[0:8,0]*B[5,6][0,4]
"vfmadd231pd 1672(%%rsi)%{1to8%}, %%zmm1, %%zmm29\r\n" // C[0:8,3] += A[0:8,1]*B[5,6][1,3]
"vfmadd231pd 1680(%%rsi)%{1to8%}, %%zmm3, %%zmm29\r\n" // C[0:8,3] += A[0:8,3]*B[5,6][3,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=7)
"vmovapd 33792(%%rdi), %%zmm2\r\n" // A [0,7] [0,2]
"vmovapd 35328(%%rdi), %%zmm4\r\n" // A [0,7] [0,4]
"vfmadd231pd 1696(%%rsi)%{1to8%}, %%zmm2, %%zmm28\r\n" // C[0:8,2] += A[0:8,2]*B[7,6][2,2]
"vfmadd231pd 1704(%%rsi)%{1to8%}, %%zmm4, %%zmm31\r\n" // C[0:8,5] += A[0:8,4]*B[7,6][4,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=8)
"vmovapd 36864(%%rdi), %%zmm0\r\n" // A [0,8] [0,0]
"vmovapd 38400(%%rdi), %%zmm2\r\n" // A [0,8] [0,2]
"vmovapd 39168(%%rdi), %%zmm3\r\n" // A [0,8] [0,3]
"vfmadd231pd 1712(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[8,6][0,0]
"vfmadd231pd 1720(%%rsi)%{1to8%}, %%zmm2, %%zmm26\r\n" // C[0:8,0] += A[0:8,2]*B[8,6][2,0]
"vfmadd231pd 1728(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[8,6][3,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=11)
"vmovapd 54528(%%rdi), %%zmm5\r\n" // A [0,11] [0,5]
"vfmadd231pd 1736(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[11,6][5,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=12)
"vmovapd 57600(%%rdi), %%zmm3\r\n" // A [0,12] [0,3]
"vmovapd 58368(%%rdi), %%zmm4\r\n" // A [0,12] [0,4]
"vmovapd 59136(%%rdi), %%zmm5\r\n" // A [0,12] [0,5]
"vfmadd231pd 1760(%%rsi)%{1to8%}, %%zmm3, %%zmm30\r\n" // C[0:8,4] += A[0:8,3]*B[12,6][3,4]
"vfmadd231pd 1752(%%rsi)%{1to8%}, %%zmm4, %%zmm29\r\n" // C[0:8,3] += A[0:8,4]*B[12,6][4,3]
"vfmadd231pd 1744(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[12,6][5,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=13)
"vmovapd 59904(%%rdi), %%zmm0\r\n" // A [0,13] [0,0]
"vmovapd 62208(%%rdi), %%zmm3\r\n" // A [0,13] [0,3]
"vmovapd 63744(%%rdi), %%zmm5\r\n" // A [0,13] [0,5]
"vfmadd231pd 1784(%%rsi)%{1to8%}, %%zmm0, %%zmm28\r\n" // C[0:8,2] += A[0:8,0]*B[13,6][0,2]
"vfmadd231pd 1792(%%rsi)%{1to8%}, %%zmm0, %%zmm29\r\n" // C[0:8,3] += A[0:8,0]*B[13,6][0,3]
"vfmadd231pd 1768(%%rsi)%{1to8%}, %%zmm3, %%zmm26\r\n" // C[0:8,0] += A[0:8,3]*B[13,6][3,0]
"vfmadd231pd 1776(%%rsi)%{1to8%}, %%zmm5, %%zmm27\r\n" // C[0:8,1] += A[0:8,5]*B[13,6][5,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=14)
"vmovapd 66048(%%rdi), %%zmm2\r\n" // A [0,14] [0,2]
"vmovapd 68352(%%rdi), %%zmm5\r\n" // A [0,14] [0,5]
"vfmadd231pd 1808(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[14,6][2,3]
"vfmadd231pd 1800(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[14,6][5,0]
// Store C register block @ (d=0,r=0)
"vmovapd %%zmm26, 0(%%rdx)\r\n" // C [0,0] [0,0]
"vmovapd %%zmm27, 768(%%rdx)\r\n" // C [0,0] [0,1]
"vmovapd %%zmm28, 1536(%%rdx)\r\n" // C [0,0] [0,2]
"vmovapd %%zmm29, 2304(%%rdx)\r\n" // C [0,0] [0,3]
"vmovapd %%zmm30, 3072(%%rdx)\r\n" // C [0,0] [0,4]
"vmovapd %%zmm31, 3840(%%rdx)\r\n" // C [0,0] [0,5]
"addq $4608, %%rdx\r\n" // Move C to (d=0,r=1)
// Load C register block @ (d=0,r=0)
"vmovapd 0(%%rdx), %%zmm26\r\n" // C [0,0] [0,0]
"vmovapd 768(%%rdx), %%zmm27\r\n" // C [0,0] [0,1]
"vmovapd 1536(%%rdx), %%zmm28\r\n" // C [0,0] [0,2]
"vmovapd 2304(%%rdx), %%zmm29\r\n" // C [0,0] [0,3]
"vmovapd 3072(%%rdx), %%zmm30\r\n" // C [0,0] [0,4]
"vmovapd 3840(%%rdx), %%zmm31\r\n" // C [0,0] [0,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=1)
"vmovapd 7680(%%rdi), %%zmm4\r\n" // A [0,1] [0,4]
"vmovapd 8448(%%rdi), %%zmm5\r\n" // A [0,1] [0,5]
"vfmadd231pd 1824(%%rsi)%{1to8%}, %%zmm4, %%zmm28\r\n" // C[0:8,2] += A[0:8,4]*B[1,7][4,2]
"vfmadd231pd 1816(%%rsi)%{1to8%}, %%zmm5, %%zmm27\r\n" // C[0:8,1] += A[0:8,5]*B[1,7][5,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=2)
"vmovapd 10752(%%rdi), %%zmm2\r\n" // A [0,2] [0,2]
"vmovapd 13056(%%rdi), %%zmm5\r\n" // A [0,2] [0,5]
"vfmadd231pd 1840(%%rsi)%{1to8%}, %%zmm2, %%zmm30\r\n" // C[0:8,4] += A[0:8,2]*B[2,7][2,4]
"vfmadd231pd 1832(%%rsi)%{1to8%}, %%zmm5, %%zmm28\r\n" // C[0:8,2] += A[0:8,5]*B[2,7][5,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=3)
"vmovapd 14592(%%rdi), %%zmm1\r\n" // A [0,3] [0,1]
"vmovapd 15360(%%rdi), %%zmm2\r\n" // A [0,3] [0,2]
"vfmadd231pd 1864(%%rsi)%{1to8%}, %%zmm1, %%zmm31\r\n" // C[0:8,5] += A[0:8,1]*B[3,7][1,5]
"vfmadd231pd 1848(%%rsi)%{1to8%}, %%zmm2, %%zmm28\r\n" // C[0:8,2] += A[0:8,2]*B[3,7][2,2]
"vfmadd231pd 1856(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[3,7][2,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=4)
"vmovapd 18432(%%rdi), %%zmm0\r\n" // A [0,4] [0,0]
"vmovapd 19200(%%rdi), %%zmm1\r\n" // A [0,4] [0,1]
"vfmadd231pd 1872(%%rsi)%{1to8%}, %%zmm0, %%zmm28\r\n" // C[0:8,2] += A[0:8,0]*B[4,7][0,2]
"vfmadd231pd 1880(%%rsi)%{1to8%}, %%zmm1, %%zmm28\r\n" // C[0:8,2] += A[0:8,1]*B[4,7][1,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=5)
"vmovapd 23808(%%rdi), %%zmm1\r\n" // A [0,5] [0,1]
"vfmadd231pd 1888(%%rsi)%{1to8%}, %%zmm1, %%zmm31\r\n" // C[0:8,5] += A[0:8,1]*B[5,7][1,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=6)
"vmovapd 28416(%%rdi), %%zmm1\r\n" // A [0,6] [0,1]
"vmovapd 30720(%%rdi), %%zmm4\r\n" // A [0,6] [0,4]
"vfmadd231pd 1912(%%rsi)%{1to8%}, %%zmm1, %%zmm31\r\n" // C[0:8,5] += A[0:8,1]*B[6,7][1,5]
"vfmadd231pd 1896(%%rsi)%{1to8%}, %%zmm4, %%zmm27\r\n" // C[0:8,1] += A[0:8,4]*B[6,7][4,1]
"vfmadd231pd 1904(%%rsi)%{1to8%}, %%zmm4, %%zmm30\r\n" // C[0:8,4] += A[0:8,4]*B[6,7][4,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=8)
"vmovapd 37632(%%rdi), %%zmm1\r\n" // A [0,8] [0,1]
"vmovapd 38400(%%rdi), %%zmm2\r\n" // A [0,8] [0,2]
"vfmadd231pd 1928(%%rsi)%{1to8%}, %%zmm1, %%zmm30\r\n" // C[0:8,4] += A[0:8,1]*B[8,7][1,4]
"vfmadd231pd 1920(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[8,7][2,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=9)
"vmovapd 42240(%%rdi), %%zmm1\r\n" // A [0,9] [0,1]
"vfmadd231pd 1936(%%rsi)%{1to8%}, %%zmm1, %%zmm29\r\n" // C[0:8,3] += A[0:8,1]*B[9,7][1,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=10)
"vmovapd 46848(%%rdi), %%zmm1\r\n" // A [0,10] [0,1]
"vfmadd231pd 1944(%%rsi)%{1to8%}, %%zmm1, %%zmm28\r\n" // C[0:8,2] += A[0:8,1]*B[10,7][1,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=11)
"vmovapd 51456(%%rdi), %%zmm1\r\n" // A [0,11] [0,1]
"vfmadd231pd 1952(%%rsi)%{1to8%}, %%zmm1, %%zmm28\r\n" // C[0:8,2] += A[0:8,1]*B[11,7][1,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=12)
"vmovapd 55296(%%rdi), %%zmm0\r\n" // A [0,12] [0,0]
"vmovapd 58368(%%rdi), %%zmm4\r\n" // A [0,12] [0,4]
"vfmadd231pd 1960(%%rsi)%{1to8%}, %%zmm0, %%zmm28\r\n" // C[0:8,2] += A[0:8,0]*B[12,7][0,2]
"vfmadd231pd 1968(%%rsi)%{1to8%}, %%zmm4, %%zmm28\r\n" // C[0:8,2] += A[0:8,4]*B[12,7][4,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=13)
"vmovapd 61440(%%rdi), %%zmm2\r\n" // A [0,13] [0,2]
"vmovapd 62208(%%rdi), %%zmm3\r\n" // A [0,13] [0,3]
"vmovapd 63744(%%rdi), %%zmm5\r\n" // A [0,13] [0,5]
"vfmadd231pd 1976(%%rsi)%{1to8%}, %%zmm2, %%zmm26\r\n" // C[0:8,0] += A[0:8,2]*B[13,7][2,0]
"vfmadd231pd 1984(%%rsi)%{1to8%}, %%zmm3, %%zmm30\r\n" // C[0:8,4] += A[0:8,3]*B[13,7][3,4]
"vfmadd231pd 1992(%%rsi)%{1to8%}, %%zmm5, %%zmm30\r\n" // C[0:8,4] += A[0:8,5]*B[13,7][5,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=14)
"vmovapd 64512(%%rdi), %%zmm0\r\n" // A [0,14] [0,0]
"vfmadd231pd 2000(%%rsi)%{1to8%}, %%zmm0, %%zmm29\r\n" // C[0:8,3] += A[0:8,0]*B[14,7][0,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=15)
"vmovapd 71424(%%rdi), %%zmm3\r\n" // A [0,15] [0,3]
"vfmadd231pd 2008(%%rsi)%{1to8%}, %%zmm3, %%zmm29\r\n" // C[0:8,3] += A[0:8,3]*B[15,7][3,3]
// Store C register block @ (d=0,r=0)
"vmovapd %%zmm26, 0(%%rdx)\r\n" // C [0,0] [0,0]
"vmovapd %%zmm27, 768(%%rdx)\r\n" // C [0,0] [0,1]
"vmovapd %%zmm28, 1536(%%rdx)\r\n" // C [0,0] [0,2]
"vmovapd %%zmm29, 2304(%%rdx)\r\n" // C [0,0] [0,3]
"vmovapd %%zmm30, 3072(%%rdx)\r\n" // C [0,0] [0,4]
"vmovapd %%zmm31, 3840(%%rdx)\r\n" // C [0,0] [0,5]
"addq $4608, %%rdx\r\n" // Move C to (d=0,r=1)
// Load C register block @ (d=0,r=0)
"vmovapd 0(%%rdx), %%zmm26\r\n" // C [0,0] [0,0]
"vmovapd 768(%%rdx), %%zmm27\r\n" // C [0,0] [0,1]
"vmovapd 1536(%%rdx), %%zmm28\r\n" // C [0,0] [0,2]
"vmovapd 2304(%%rdx), %%zmm29\r\n" // C [0,0] [0,3]
"vmovapd 3072(%%rdx), %%zmm30\r\n" // C [0,0] [0,4]
"vmovapd 3840(%%rdx), %%zmm31\r\n" // C [0,0] [0,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=0)
"vmovapd 768(%%rdi), %%zmm1\r\n" // A [0,0] [0,1]
"vmovapd 1536(%%rdi), %%zmm2\r\n" // A [0,0] [0,2]
"vmovapd 2304(%%rdi), %%zmm3\r\n" // A [0,0] [0,3]
"vmovapd 3072(%%rdi), %%zmm4\r\n" // A [0,0] [0,4]
"vmovapd 3840(%%rdi), %%zmm5\r\n" // A [0,0] [0,5]
"vfmadd231pd 2040(%%rsi)%{1to8%}, %%zmm1, %%zmm30\r\n" // C[0:8,4] += A[0:8,1]*B[0,8][1,4]
"vfmadd231pd 2016(%%rsi)%{1to8%}, %%zmm2, %%zmm26\r\n" // C[0:8,0] += A[0:8,2]*B[0,8][2,0]
"vfmadd231pd 2032(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[0,8][2,3]
"vfmadd231pd 2024(%%rsi)%{1to8%}, %%zmm3, %%zmm27\r\n" // C[0:8,1] += A[0:8,3]*B[0,8][3,1]
"vfmadd231pd 2048(%%rsi)%{1to8%}, %%zmm4, %%zmm31\r\n" // C[0:8,5] += A[0:8,4]*B[0,8][4,5]
"vfmadd231pd 2056(%%rsi)%{1to8%}, %%zmm5, %%zmm31\r\n" // C[0:8,5] += A[0:8,5]*B[0,8][5,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=1)
"vmovapd 5376(%%rdi), %%zmm1\r\n" // A [0,1] [0,1]
"vmovapd 6912(%%rdi), %%zmm3\r\n" // A [0,1] [0,3]
"vfmadd231pd 2072(%%rsi)%{1to8%}, %%zmm1, %%zmm28\r\n" // C[0:8,2] += A[0:8,1]*B[1,8][1,2]
"vfmadd231pd 2064(%%rsi)%{1to8%}, %%zmm3, %%zmm27\r\n" // C[0:8,1] += A[0:8,3]*B[1,8][3,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=2)
"vmovapd 9216(%%rdi), %%zmm0\r\n" // A [0,2] [0,0]
"vmovapd 11520(%%rdi), %%zmm3\r\n" // A [0,2] [0,3]
"vfmadd231pd 2080(%%rsi)%{1to8%}, %%zmm0, %%zmm30\r\n" // C[0:8,4] += A[0:8,0]*B[2,8][0,4]
"vfmadd231pd 2088(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[2,8][3,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=3)
"vmovapd 13824(%%rdi), %%zmm0\r\n" // A [0,3] [0,0]
"vfmadd231pd 2096(%%rsi)%{1to8%}, %%zmm0, %%zmm30\r\n" // C[0:8,4] += A[0:8,0]*B[3,8][0,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=4)
"vmovapd 19968(%%rdi), %%zmm2\r\n" // A [0,4] [0,2]
"vfmadd231pd 2104(%%rsi)%{1to8%}, %%zmm2, %%zmm26\r\n" // C[0:8,0] += A[0:8,2]*B[4,8][2,0]
"vfmadd231pd 2112(%%rsi)%{1to8%}, %%zmm2, %%zmm28\r\n" // C[0:8,2] += A[0:8,2]*B[4,8][2,2]
"vfmadd231pd 2120(%%rsi)%{1to8%}, %%zmm2, %%zmm30\r\n" // C[0:8,4] += A[0:8,2]*B[4,8][2,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=5)
"vmovapd 23040(%%rdi), %%zmm0\r\n" // A [0,5] [0,0]
"vmovapd 23808(%%rdi), %%zmm1\r\n" // A [0,5] [0,1]
"vfmadd231pd 2136(%%rsi)%{1to8%}, %%zmm0, %%zmm31\r\n" // C[0:8,5] += A[0:8,0]*B[5,8][0,5]
"vfmadd231pd 2128(%%rsi)%{1to8%}, %%zmm1, %%zmm28\r\n" // C[0:8,2] += A[0:8,1]*B[5,8][1,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=6)
"vmovapd 30720(%%rdi), %%zmm4\r\n" // A [0,6] [0,4]
"vmovapd 31488(%%rdi), %%zmm5\r\n" // A [0,6] [0,5]
"vfmadd231pd 2152(%%rsi)%{1to8%}, %%zmm4, %%zmm28\r\n" // C[0:8,2] += A[0:8,4]*B[6,8][4,2]
"vfmadd231pd 2144(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[6,8][5,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=7)
"vmovapd 33024(%%rdi), %%zmm1\r\n" // A [0,7] [0,1]
"vmovapd 35328(%%rdi), %%zmm4\r\n" // A [0,7] [0,4]
"vmovapd 36096(%%rdi), %%zmm5\r\n" // A [0,7] [0,5]
"vfmadd231pd 2176(%%rsi)%{1to8%}, %%zmm1, %%zmm30\r\n" // C[0:8,4] += A[0:8,1]*B[7,8][1,4]
"vfmadd231pd 2168(%%rsi)%{1to8%}, %%zmm4, %%zmm28\r\n" // C[0:8,2] += A[0:8,4]*B[7,8][4,2]
"vfmadd231pd 2160(%%rsi)%{1to8%}, %%zmm5, %%zmm27\r\n" // C[0:8,1] += A[0:8,5]*B[7,8][5,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=8)
"vmovapd 37632(%%rdi), %%zmm1\r\n" // A [0,8] [0,1]
"vmovapd 39168(%%rdi), %%zmm3\r\n" // A [0,8] [0,3]
"vfmadd231pd 2192(%%rsi)%{1to8%}, %%zmm1, %%zmm29\r\n" // C[0:8,3] += A[0:8,1]*B[8,8][1,3]
"vfmadd231pd 2184(%%rsi)%{1to8%}, %%zmm3, %%zmm27\r\n" // C[0:8,1] += A[0:8,3]*B[8,8][3,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=9)
"vmovapd 42240(%%rdi), %%zmm1\r\n" // A [0,9] [0,1]
"vmovapd 43008(%%rdi), %%zmm2\r\n" // A [0,9] [0,2]
"vfmadd231pd 2200(%%rsi)%{1to8%}, %%zmm1, %%zmm28\r\n" // C[0:8,2] += A[0:8,1]*B[9,8][1,2]
"vfmadd231pd 2208(%%rsi)%{1to8%}, %%zmm1, %%zmm30\r\n" // C[0:8,4] += A[0:8,1]*B[9,8][1,4]
"vfmadd231pd 2224(%%rsi)%{1to8%}, %%zmm1, %%zmm31\r\n" // C[0:8,5] += A[0:8,1]*B[9,8][1,5]
"vfmadd231pd 2216(%%rsi)%{1to8%}, %%zmm2, %%zmm30\r\n" // C[0:8,4] += A[0:8,2]*B[9,8][2,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=10)
"vmovapd 47616(%%rdi), %%zmm2\r\n" // A [0,10] [0,2]
"vmovapd 49920(%%rdi), %%zmm5\r\n" // A [0,10] [0,5]
"vfmadd231pd 2240(%%rsi)%{1to8%}, %%zmm2, %%zmm30\r\n" // C[0:8,4] += A[0:8,2]*B[10,8][2,4]
"vfmadd231pd 2232(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[10,8][5,0]
"vfmadd231pd 2248(%%rsi)%{1to8%}, %%zmm5, %%zmm31\r\n" // C[0:8,5] += A[0:8,5]*B[10,8][5,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=11)
"vmovapd 52224(%%rdi), %%zmm2\r\n" // A [0,11] [0,2]
"vfmadd231pd 2256(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[11,8][2,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=12)
"vmovapd 58368(%%rdi), %%zmm4\r\n" // A [0,12] [0,4]
"vfmadd231pd 2264(%%rsi)%{1to8%}, %%zmm4, %%zmm28\r\n" // C[0:8,2] += A[0:8,4]*B[12,8][4,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=13)
"vmovapd 62976(%%rdi), %%zmm4\r\n" // A [0,13] [0,4]
"vfmadd231pd 2272(%%rsi)%{1to8%}, %%zmm4, %%zmm29\r\n" // C[0:8,3] += A[0:8,4]*B[13,8][4,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=14)
"vmovapd 64512(%%rdi), %%zmm0\r\n" // A [0,14] [0,0]
"vmovapd 66816(%%rdi), %%zmm3\r\n" // A [0,14] [0,3]
"vmovapd 67584(%%rdi), %%zmm4\r\n" // A [0,14] [0,4]
"vmovapd 68352(%%rdi), %%zmm5\r\n" // A [0,14] [0,5]
"vfmadd231pd 2280(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[14,8][0,0]
"vfmadd231pd 2288(%%rsi)%{1to8%}, %%zmm3, %%zmm29\r\n" // C[0:8,3] += A[0:8,3]*B[14,8][3,3]
"vfmadd231pd 2304(%%rsi)%{1to8%}, %%zmm4, %%zmm31\r\n" // C[0:8,5] += A[0:8,4]*B[14,8][4,5]
"vfmadd231pd 2296(%%rsi)%{1to8%}, %%zmm5, %%zmm30\r\n" // C[0:8,4] += A[0:8,5]*B[14,8][5,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=15)
"vmovapd 69888(%%rdi), %%zmm1\r\n" // A [0,15] [0,1]
"vmovapd 72960(%%rdi), %%zmm5\r\n" // A [0,15] [0,5]
"vfmadd231pd 2312(%%rsi)%{1to8%}, %%zmm1, %%zmm26\r\n" // C[0:8,0] += A[0:8,1]*B[15,8][1,0]
"vfmadd231pd 2320(%%rsi)%{1to8%}, %%zmm5, %%zmm28\r\n" // C[0:8,2] += A[0:8,5]*B[15,8][5,2]
// Store C register block @ (d=0,r=0)
"vmovapd %%zmm26, 0(%%rdx)\r\n" // C [0,0] [0,0]
"vmovapd %%zmm27, 768(%%rdx)\r\n" // C [0,0] [0,1]
"vmovapd %%zmm28, 1536(%%rdx)\r\n" // C [0,0] [0,2]
"vmovapd %%zmm29, 2304(%%rdx)\r\n" // C [0,0] [0,3]
"vmovapd %%zmm30, 3072(%%rdx)\r\n" // C [0,0] [0,4]
"vmovapd %%zmm31, 3840(%%rdx)\r\n" // C [0,0] [0,5]
"addq $4608, %%rdx\r\n" // Move C to (d=0,r=1)
// Load C register block @ (d=0,r=0)
"vmovapd 0(%%rdx), %%zmm26\r\n" // C [0,0] [0,0]
"vmovapd 768(%%rdx), %%zmm27\r\n" // C [0,0] [0,1]
"vmovapd 1536(%%rdx), %%zmm28\r\n" // C [0,0] [0,2]
"vmovapd 2304(%%rdx), %%zmm29\r\n" // C [0,0] [0,3]
"vmovapd 3072(%%rdx), %%zmm30\r\n" // C [0,0] [0,4]
"vmovapd 3840(%%rdx), %%zmm31\r\n" // C [0,0] [0,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=0)
"vmovapd 0(%%rdi), %%zmm0\r\n" // A [0,0] [0,0]
"vmovapd 1536(%%rdi), %%zmm2\r\n" // A [0,0] [0,2]
"vmovapd 3840(%%rdi), %%zmm5\r\n" // A [0,0] [0,5]
"vfmadd231pd 2328(%%rsi)%{1to8%}, %%zmm0, %%zmm27\r\n" // C[0:8,1] += A[0:8,0]*B[0,9][0,1]
"vfmadd231pd 2344(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[0,9][2,3]
"vfmadd231pd 2336(%%rsi)%{1to8%}, %%zmm5, %%zmm28\r\n" // C[0:8,2] += A[0:8,5]*B[0,9][5,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=1)
"vmovapd 4608(%%rdi), %%zmm0\r\n" // A [0,1] [0,0]
"vmovapd 6144(%%rdi), %%zmm2\r\n" // A [0,1] [0,2]
"vfmadd231pd 2360(%%rsi)%{1to8%}, %%zmm0, %%zmm30\r\n" // C[0:8,4] += A[0:8,0]*B[1,9][0,4]
"vfmadd231pd 2352(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[1,9][2,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=2)
"vmovapd 9984(%%rdi), %%zmm1\r\n" // A [0,2] [0,1]
"vmovapd 11520(%%rdi), %%zmm3\r\n" // A [0,2] [0,3]
"vmovapd 13056(%%rdi), %%zmm5\r\n" // A [0,2] [0,5]
"vfmadd231pd 2392(%%rsi)%{1to8%}, %%zmm1, %%zmm29\r\n" // C[0:8,3] += A[0:8,1]*B[2,9][1,3]
"vfmadd231pd 2400(%%rsi)%{1to8%}, %%zmm1, %%zmm31\r\n" // C[0:8,5] += A[0:8,1]*B[2,9][1,5]
"vfmadd231pd 2368(%%rsi)%{1to8%}, %%zmm3, %%zmm26\r\n" // C[0:8,0] += A[0:8,3]*B[2,9][3,0]
"vfmadd231pd 2376(%%rsi)%{1to8%}, %%zmm5, %%zmm27\r\n" // C[0:8,1] += A[0:8,5]*B[2,9][5,1]
"vfmadd231pd 2384(%%rsi)%{1to8%}, %%zmm5, %%zmm28\r\n" // C[0:8,2] += A[0:8,5]*B[2,9][5,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=3)
"vmovapd 13824(%%rdi), %%zmm0\r\n" // A [0,3] [0,0]
"vmovapd 16896(%%rdi), %%zmm4\r\n" // A [0,3] [0,4]
"vfmadd231pd 2416(%%rsi)%{1to8%}, %%zmm0, %%zmm30\r\n" // C[0:8,4] += A[0:8,0]*B[3,9][0,4]
"vfmadd231pd 2408(%%rsi)%{1to8%}, %%zmm4, %%zmm26\r\n" // C[0:8,0] += A[0:8,4]*B[3,9][4,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=4)
"vmovapd 18432(%%rdi), %%zmm0\r\n" // A [0,4] [0,0]
"vfmadd231pd 2424(%%rsi)%{1to8%}, %%zmm0, %%zmm30\r\n" // C[0:8,4] += A[0:8,0]*B[4,9][0,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=5)
"vmovapd 23040(%%rdi), %%zmm0\r\n" // A [0,5] [0,0]
"vmovapd 26880(%%rdi), %%zmm5\r\n" // A [0,5] [0,5]
"vfmadd231pd 2432(%%rsi)%{1to8%}, %%zmm0, %%zmm28\r\n" // C[0:8,2] += A[0:8,0]*B[5,9][0,2]
"vfmadd231pd 2440(%%rsi)%{1to8%}, %%zmm5, %%zmm28\r\n" // C[0:8,2] += A[0:8,5]*B[5,9][5,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=6)
"vmovapd 27648(%%rdi), %%zmm0\r\n" // A [0,6] [0,0]
"vmovapd 28416(%%rdi), %%zmm1\r\n" // A [0,6] [0,1]
"vfmadd231pd 2448(%%rsi)%{1to8%}, %%zmm0, %%zmm28\r\n" // C[0:8,2] += A[0:8,0]*B[6,9][0,2]
"vfmadd231pd 2456(%%rsi)%{1to8%}, %%zmm1, %%zmm28\r\n" // C[0:8,2] += A[0:8,1]*B[6,9][1,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=7)
"vmovapd 33024(%%rdi), %%zmm1\r\n" // A [0,7] [0,1]
"vmovapd 33792(%%rdi), %%zmm2\r\n" // A [0,7] [0,2]
"vmovapd 34560(%%rdi), %%zmm3\r\n" // A [0,7] [0,3]
"vfmadd231pd 2464(%%rsi)%{1to8%}, %%zmm1, %%zmm27\r\n" // C[0:8,1] += A[0:8,1]*B[7,9][1,1]
"vfmadd231pd 2472(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[7,9][2,1]
"vfmadd231pd 2480(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[7,9][2,3]
"vfmadd231pd 2488(%%rsi)%{1to8%}, %%zmm3, %%zmm30\r\n" // C[0:8,4] += A[0:8,3]*B[7,9][3,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=8)
"vmovapd 37632(%%rdi), %%zmm1\r\n" // A [0,8] [0,1]
"vfmadd231pd 2496(%%rsi)%{1to8%}, %%zmm1, %%zmm28\r\n" // C[0:8,2] += A[0:8,1]*B[8,9][1,2]
"vfmadd231pd 2504(%%rsi)%{1to8%}, %%zmm1, %%zmm31\r\n" // C[0:8,5] += A[0:8,1]*B[8,9][1,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=9)
"vmovapd 43776(%%rdi), %%zmm3\r\n" // A [0,9] [0,3]
"vmovapd 45312(%%rdi), %%zmm5\r\n" // A [0,9] [0,5]
"vfmadd231pd 2520(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[9,9][3,5]
"vfmadd231pd 2512(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[9,9][5,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=10)
"vmovapd 46080(%%rdi), %%zmm0\r\n" // A [0,10] [0,0]
"vmovapd 47616(%%rdi), %%zmm2\r\n" // A [0,10] [0,2]
"vfmadd231pd 2528(%%rsi)%{1to8%}, %%zmm0, %%zmm27\r\n" // C[0:8,1] += A[0:8,0]*B[10,9][0,1]
"vfmadd231pd 2536(%%rsi)%{1to8%}, %%zmm2, %%zmm28\r\n" // C[0:8,2] += A[0:8,2]*B[10,9][2,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=11)
"vmovapd 54528(%%rdi), %%zmm5\r\n" // A [0,11] [0,5]
"vfmadd231pd 2544(%%rsi)%{1to8%}, %%zmm5, %%zmm27\r\n" // C[0:8,1] += A[0:8,5]*B[11,9][5,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=12)
"vmovapd 56832(%%rdi), %%zmm2\r\n" // A [0,12] [0,2]
"vfmadd231pd 2552(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[12,9][2,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=13)
"vmovapd 61440(%%rdi), %%zmm2\r\n" // A [0,13] [0,2]
"vmovapd 62976(%%rdi), %%zmm4\r\n" // A [0,13] [0,4]
"vfmadd231pd 2568(%%rsi)%{1to8%}, %%zmm2, %%zmm28\r\n" // C[0:8,2] += A[0:8,2]*B[13,9][2,2]
"vfmadd231pd 2560(%%rsi)%{1to8%}, %%zmm4, %%zmm27\r\n" // C[0:8,1] += A[0:8,4]*B[13,9][4,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=14)
"vmovapd 64512(%%rdi), %%zmm0\r\n" // A [0,14] [0,0]
"vmovapd 65280(%%rdi), %%zmm1\r\n" // A [0,14] [0,1]
"vmovapd 66048(%%rdi), %%zmm2\r\n" // A [0,14] [0,2]
"vmovapd 68352(%%rdi), %%zmm5\r\n" // A [0,14] [0,5]
"vfmadd231pd 2600(%%rsi)%{1to8%}, %%zmm0, %%zmm29\r\n" // C[0:8,3] += A[0:8,0]*B[14,9][0,3]
"vfmadd231pd 2584(%%rsi)%{1to8%}, %%zmm1, %%zmm27\r\n" // C[0:8,1] += A[0:8,1]*B[14,9][1,1]
"vfmadd231pd 2592(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[14,9][2,1]
"vfmadd231pd 2608(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[14,9][2,3]
"vfmadd231pd 2576(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[14,9][5,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=15)
"vmovapd 70656(%%rdi), %%zmm2\r\n" // A [0,15] [0,2]
"vfmadd231pd 2616(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[15,9][2,3]
// Store C register block @ (d=0,r=0)
"vmovapd %%zmm26, 0(%%rdx)\r\n" // C [0,0] [0,0]
"vmovapd %%zmm27, 768(%%rdx)\r\n" // C [0,0] [0,1]
"vmovapd %%zmm28, 1536(%%rdx)\r\n" // C [0,0] [0,2]
"vmovapd %%zmm29, 2304(%%rdx)\r\n" // C [0,0] [0,3]
"vmovapd %%zmm30, 3072(%%rdx)\r\n" // C [0,0] [0,4]
"vmovapd %%zmm31, 3840(%%rdx)\r\n" // C [0,0] [0,5]
"addq $4608, %%rdx\r\n" // Move C to (d=0,r=1)
// Load C register block @ (d=0,r=0)
"vmovapd 0(%%rdx), %%zmm26\r\n" // C [0,0] [0,0]
"vmovapd 768(%%rdx), %%zmm27\r\n" // C [0,0] [0,1]
"vmovapd 1536(%%rdx), %%zmm28\r\n" // C [0,0] [0,2]
"vmovapd 2304(%%rdx), %%zmm29\r\n" // C [0,0] [0,3]
"vmovapd 3072(%%rdx), %%zmm30\r\n" // C [0,0] [0,4]
"vmovapd 3840(%%rdx), %%zmm31\r\n" // C [0,0] [0,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=0)
"vmovapd 768(%%rdi), %%zmm1\r\n" // A [0,0] [0,1]
"vmovapd 1536(%%rdi), %%zmm2\r\n" // A [0,0] [0,2]
"vmovapd 2304(%%rdi), %%zmm3\r\n" // A [0,0] [0,3]
"vfmadd231pd 2640(%%rsi)%{1to8%}, %%zmm1, %%zmm31\r\n" // C[0:8,5] += A[0:8,1]*B[0,10][1,5]
"vfmadd231pd 2632(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[0,10][2,3]
"vfmadd231pd 2624(%%rsi)%{1to8%}, %%zmm3, %%zmm26\r\n" // C[0:8,0] += A[0:8,3]*B[0,10][3,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=1)
"vmovapd 6912(%%rdi), %%zmm3\r\n" // A [0,1] [0,3]
"vmovapd 8448(%%rdi), %%zmm5\r\n" // A [0,1] [0,5]
"vfmadd231pd 2656(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[1,10][3,5]
"vfmadd231pd 2648(%%rsi)%{1to8%}, %%zmm5, %%zmm28\r\n" // C[0:8,2] += A[0:8,5]*B[1,10][5,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=2)
"vmovapd 12288(%%rdi), %%zmm4\r\n" // A [0,2] [0,4]
"vfmadd231pd 2664(%%rsi)%{1to8%}, %%zmm4, %%zmm28\r\n" // C[0:8,2] += A[0:8,4]*B[2,10][4,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=4)
"vmovapd 19200(%%rdi), %%zmm1\r\n" // A [0,4] [0,1]
"vmovapd 19968(%%rdi), %%zmm2\r\n" // A [0,4] [0,2]
"vfmadd231pd 2680(%%rsi)%{1to8%}, %%zmm1, %%zmm31\r\n" // C[0:8,5] += A[0:8,1]*B[4,10][1,5]
"vfmadd231pd 2672(%%rsi)%{1to8%}, %%zmm2, %%zmm26\r\n" // C[0:8,0] += A[0:8,2]*B[4,10][2,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=5)
"vmovapd 23040(%%rdi), %%zmm0\r\n" // A [0,5] [0,0]
"vmovapd 23808(%%rdi), %%zmm1\r\n" // A [0,5] [0,1]
"vfmadd231pd 2696(%%rsi)%{1to8%}, %%zmm0, %%zmm29\r\n" // C[0:8,3] += A[0:8,0]*B[5,10][0,3]
"vfmadd231pd 2688(%%rsi)%{1to8%}, %%zmm1, %%zmm28\r\n" // C[0:8,2] += A[0:8,1]*B[5,10][1,2]
"vfmadd231pd 2704(%%rsi)%{1to8%}, %%zmm1, %%zmm29\r\n" // C[0:8,3] += A[0:8,1]*B[5,10][1,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=6)
"vmovapd 28416(%%rdi), %%zmm1\r\n" // A [0,6] [0,1]
"vfmadd231pd 2712(%%rsi)%{1to8%}, %%zmm1, %%zmm27\r\n" // C[0:8,1] += A[0:8,1]*B[6,10][1,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=8)
"vmovapd 38400(%%rdi), %%zmm2\r\n" // A [0,8] [0,2]
"vfmadd231pd 2720(%%rsi)%{1to8%}, %%zmm2, %%zmm28\r\n" // C[0:8,2] += A[0:8,2]*B[8,10][2,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=9)
"vmovapd 43008(%%rdi), %%zmm2\r\n" // A [0,9] [0,2]
"vfmadd231pd 2728(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[9,10][2,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=10)
"vmovapd 46080(%%rdi), %%zmm0\r\n" // A [0,10] [0,0]
"vmovapd 49920(%%rdi), %%zmm5\r\n" // A [0,10] [0,5]
"vfmadd231pd 2744(%%rsi)%{1to8%}, %%zmm0, %%zmm30\r\n" // C[0:8,4] += A[0:8,0]*B[10,10][0,4]
"vfmadd231pd 2736(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[10,10][5,0]
"vfmadd231pd 2752(%%rsi)%{1to8%}, %%zmm5, %%zmm30\r\n" // C[0:8,4] += A[0:8,5]*B[10,10][5,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=12)
"vmovapd 58368(%%rdi), %%zmm4\r\n" // A [0,12] [0,4]
"vfmadd231pd 2760(%%rsi)%{1to8%}, %%zmm4, %%zmm26\r\n" // C[0:8,0] += A[0:8,4]*B[12,10][4,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=14)
"vmovapd 64512(%%rdi), %%zmm0\r\n" // A [0,14] [0,0]
"vmovapd 65280(%%rdi), %%zmm1\r\n" // A [0,14] [0,1]
"vmovapd 66816(%%rdi), %%zmm3\r\n" // A [0,14] [0,3]
"vfmadd231pd 2776(%%rsi)%{1to8%}, %%zmm0, %%zmm28\r\n" // C[0:8,2] += A[0:8,0]*B[14,10][0,2]
"vfmadd231pd 2768(%%rsi)%{1to8%}, %%zmm1, %%zmm26\r\n" // C[0:8,0] += A[0:8,1]*B[14,10][1,0]
"vfmadd231pd 2784(%%rsi)%{1to8%}, %%zmm3, %%zmm29\r\n" // C[0:8,3] += A[0:8,3]*B[14,10][3,3]
"vfmadd231pd 2792(%%rsi)%{1to8%}, %%zmm3, %%zmm30\r\n" // C[0:8,4] += A[0:8,3]*B[14,10][3,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=15)
"vmovapd 72192(%%rdi), %%zmm4\r\n" // A [0,15] [0,4]
"vfmadd231pd 2800(%%rsi)%{1to8%}, %%zmm4, %%zmm30\r\n" // C[0:8,4] += A[0:8,4]*B[15,10][4,4]
// Store C register block @ (d=0,r=0)
"vmovapd %%zmm26, 0(%%rdx)\r\n" // C [0,0] [0,0]
"vmovapd %%zmm27, 768(%%rdx)\r\n" // C [0,0] [0,1]
"vmovapd %%zmm28, 1536(%%rdx)\r\n" // C [0,0] [0,2]
"vmovapd %%zmm29, 2304(%%rdx)\r\n" // C [0,0] [0,3]
"vmovapd %%zmm30, 3072(%%rdx)\r\n" // C [0,0] [0,4]
"vmovapd %%zmm31, 3840(%%rdx)\r\n" // C [0,0] [0,5]
"addq $4608, %%rdx\r\n" // Move C to (d=0,r=1)
// Load C register block @ (d=0,r=0)
"vmovapd 0(%%rdx), %%zmm26\r\n" // C [0,0] [0,0]
"vmovapd 768(%%rdx), %%zmm27\r\n" // C [0,0] [0,1]
"vmovapd 1536(%%rdx), %%zmm28\r\n" // C [0,0] [0,2]
"vmovapd 2304(%%rdx), %%zmm29\r\n" // C [0,0] [0,3]
"vmovapd 3072(%%rdx), %%zmm30\r\n" // C [0,0] [0,4]
"vmovapd 3840(%%rdx), %%zmm31\r\n" // C [0,0] [0,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=0)
"vmovapd 768(%%rdi), %%zmm1\r\n" // A [0,0] [0,1]
"vfmadd231pd 2808(%%rsi)%{1to8%}, %%zmm1, %%zmm30\r\n" // C[0:8,4] += A[0:8,1]*B[0,11][1,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=1)
"vmovapd 6144(%%rdi), %%zmm2\r\n" // A [0,1] [0,2]
"vfmadd231pd 2816(%%rsi)%{1to8%}, %%zmm2, %%zmm26\r\n" // C[0:8,0] += A[0:8,2]*B[1,11][2,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=2)
"vmovapd 9984(%%rdi), %%zmm1\r\n" // A [0,2] [0,1]
"vmovapd 11520(%%rdi), %%zmm3\r\n" // A [0,2] [0,3]
"vfmadd231pd 2824(%%rsi)%{1to8%}, %%zmm1, %%zmm26\r\n" // C[0:8,0] += A[0:8,1]*B[2,11][1,0]
"vfmadd231pd 2832(%%rsi)%{1to8%}, %%zmm3, %%zmm28\r\n" // C[0:8,2] += A[0:8,3]*B[2,11][3,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=3)
"vmovapd 13824(%%rdi), %%zmm0\r\n" // A [0,3] [0,0]
"vmovapd 14592(%%rdi), %%zmm1\r\n" // A [0,3] [0,1]
"vmovapd 16128(%%rdi), %%zmm3\r\n" // A [0,3] [0,3]
"vfmadd231pd 2840(%%rsi)%{1to8%}, %%zmm0, %%zmm27\r\n" // C[0:8,1] += A[0:8,0]*B[3,11][0,1]
"vfmadd231pd 2856(%%rsi)%{1to8%}, %%zmm1, %%zmm30\r\n" // C[0:8,4] += A[0:8,1]*B[3,11][1,4]
"vfmadd231pd 2848(%%rsi)%{1to8%}, %%zmm3, %%zmm27\r\n" // C[0:8,1] += A[0:8,3]*B[3,11][3,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=5)
"vmovapd 26112(%%rdi), %%zmm4\r\n" // A [0,5] [0,4]
"vfmadd231pd 2864(%%rsi)%{1to8%}, %%zmm4, %%zmm31\r\n" // C[0:8,5] += A[0:8,4]*B[5,11][4,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=6)
"vmovapd 29952(%%rdi), %%zmm3\r\n" // A [0,6] [0,3]
"vfmadd231pd 2872(%%rsi)%{1to8%}, %%zmm3, %%zmm30\r\n" // C[0:8,4] += A[0:8,3]*B[6,11][3,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=7)
"vmovapd 33792(%%rdi), %%zmm2\r\n" // A [0,7] [0,2]
"vfmadd231pd 2880(%%rsi)%{1to8%}, %%zmm2, %%zmm28\r\n" // C[0:8,2] += A[0:8,2]*B[7,11][2,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=9)
"vmovapd 41472(%%rdi), %%zmm0\r\n" // A [0,9] [0,0]
"vmovapd 43776(%%rdi), %%zmm3\r\n" // A [0,9] [0,3]
"vfmadd231pd 2888(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[9,11][0,0]
"vfmadd231pd 2896(%%rsi)%{1to8%}, %%zmm3, %%zmm26\r\n" // C[0:8,0] += A[0:8,3]*B[9,11][3,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=10)
"vmovapd 46080(%%rdi), %%zmm0\r\n" // A [0,10] [0,0]
"vmovapd 49920(%%rdi), %%zmm5\r\n" // A [0,10] [0,5]
"vfmadd231pd 2912(%%rsi)%{1to8%}, %%zmm0, %%zmm29\r\n" // C[0:8,3] += A[0:8,0]*B[10,11][0,3]
"vfmadd231pd 2904(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[10,11][5,0]
"vfmadd231pd 2920(%%rsi)%{1to8%}, %%zmm5, %%zmm30\r\n" // C[0:8,4] += A[0:8,5]*B[10,11][5,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=11)
"vmovapd 53760(%%rdi), %%zmm4\r\n" // A [0,11] [0,4]
"vfmadd231pd 2928(%%rsi)%{1to8%}, %%zmm4, %%zmm28\r\n" // C[0:8,2] += A[0:8,4]*B[11,11][4,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=12)
"vmovapd 55296(%%rdi), %%zmm0\r\n" // A [0,12] [0,0]
"vmovapd 56064(%%rdi), %%zmm1\r\n" // A [0,12] [0,1]
"vmovapd 57600(%%rdi), %%zmm3\r\n" // A [0,12] [0,3]
"vmovapd 59136(%%rdi), %%zmm5\r\n" // A [0,12] [0,5]
"vfmadd231pd 2936(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[12,11][0,0]
"vfmadd231pd 2952(%%rsi)%{1to8%}, %%zmm1, %%zmm31\r\n" // C[0:8,5] += A[0:8,1]*B[12,11][1,5]
"vfmadd231pd 2944(%%rsi)%{1to8%}, %%zmm3, %%zmm29\r\n" // C[0:8,3] += A[0:8,3]*B[12,11][3,3]
"vfmadd231pd 2960(%%rsi)%{1to8%}, %%zmm5, %%zmm31\r\n" // C[0:8,5] += A[0:8,5]*B[12,11][5,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=13)
"vmovapd 62208(%%rdi), %%zmm3\r\n" // A [0,13] [0,3]
"vfmadd231pd 2968(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[13,11][3,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=14)
"vmovapd 66048(%%rdi), %%zmm2\r\n" // A [0,14] [0,2]
"vmovapd 67584(%%rdi), %%zmm4\r\n" // A [0,14] [0,4]
"vfmadd231pd 2976(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[14,11][2,1]
"vfmadd231pd 2984(%%rsi)%{1to8%}, %%zmm4, %%zmm31\r\n" // C[0:8,5] += A[0:8,4]*B[14,11][4,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=15)
"vmovapd 70656(%%rdi), %%zmm2\r\n" // A [0,15] [0,2]
"vmovapd 72192(%%rdi), %%zmm4\r\n" // A [0,15] [0,4]
"vmovapd 72960(%%rdi), %%zmm5\r\n" // A [0,15] [0,5]
"vfmadd231pd 3000(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[15,11][2,1]
"vfmadd231pd 3008(%%rsi)%{1to8%}, %%zmm4, %%zmm31\r\n" // C[0:8,5] += A[0:8,4]*B[15,11][4,5]
"vfmadd231pd 2992(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[15,11][5,0]
// Store C register block @ (d=0,r=0)
"vmovapd %%zmm26, 0(%%rdx)\r\n" // C [0,0] [0,0]
"vmovapd %%zmm27, 768(%%rdx)\r\n" // C [0,0] [0,1]
"vmovapd %%zmm28, 1536(%%rdx)\r\n" // C [0,0] [0,2]
"vmovapd %%zmm29, 2304(%%rdx)\r\n" // C [0,0] [0,3]
"vmovapd %%zmm30, 3072(%%rdx)\r\n" // C [0,0] [0,4]
"vmovapd %%zmm31, 3840(%%rdx)\r\n" // C [0,0] [0,5]
"addq $4608, %%rdx\r\n" // Move C to (d=0,r=1)
// Load C register block @ (d=0,r=0)
"vmovapd 0(%%rdx), %%zmm26\r\n" // C [0,0] [0,0]
"vmovapd 768(%%rdx), %%zmm27\r\n" // C [0,0] [0,1]
"vmovapd 1536(%%rdx), %%zmm28\r\n" // C [0,0] [0,2]
"vmovapd 2304(%%rdx), %%zmm29\r\n" // C [0,0] [0,3]
"vmovapd 3072(%%rdx), %%zmm30\r\n" // C [0,0] [0,4]
"vmovapd 3840(%%rdx), %%zmm31\r\n" // C [0,0] [0,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=0)
"vmovapd 0(%%rdi), %%zmm0\r\n" // A [0,0] [0,0]
"vfmadd231pd 3016(%%rsi)%{1to8%}, %%zmm0, %%zmm27\r\n" // C[0:8,1] += A[0:8,0]*B[0,12][0,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=1)
"vmovapd 5376(%%rdi), %%zmm1\r\n" // A [0,1] [0,1]
"vmovapd 8448(%%rdi), %%zmm5\r\n" // A [0,1] [0,5]
"vfmadd231pd 3032(%%rsi)%{1to8%}, %%zmm1, %%zmm31\r\n" // C[0:8,5] += A[0:8,1]*B[1,12][1,5]
"vfmadd231pd 3024(%%rsi)%{1to8%}, %%zmm5, %%zmm30\r\n" // C[0:8,4] += A[0:8,5]*B[1,12][5,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=2)
"vmovapd 9216(%%rdi), %%zmm0\r\n" // A [0,2] [0,0]
"vmovapd 10752(%%rdi), %%zmm2\r\n" // A [0,2] [0,2]
"vmovapd 13056(%%rdi), %%zmm5\r\n" // A [0,2] [0,5]
"vfmadd231pd 3056(%%rsi)%{1to8%}, %%zmm0, %%zmm28\r\n" // C[0:8,2] += A[0:8,0]*B[2,12][0,2]
"vfmadd231pd 3040(%%rsi)%{1to8%}, %%zmm2, %%zmm26\r\n" // C[0:8,0] += A[0:8,2]*B[2,12][2,0]
"vfmadd231pd 3048(%%rsi)%{1to8%}, %%zmm5, %%zmm27\r\n" // C[0:8,1] += A[0:8,5]*B[2,12][5,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=4)
"vmovapd 18432(%%rdi), %%zmm0\r\n" // A [0,4] [0,0]
"vmovapd 21504(%%rdi), %%zmm4\r\n" // A [0,4] [0,4]
"vfmadd231pd 3064(%%rsi)%{1to8%}, %%zmm0, %%zmm27\r\n" // C[0:8,1] += A[0:8,0]*B[4,12][0,1]
"vfmadd231pd 3072(%%rsi)%{1to8%}, %%zmm4, %%zmm30\r\n" // C[0:8,4] += A[0:8,4]*B[4,12][4,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=5)
"vmovapd 23040(%%rdi), %%zmm0\r\n" // A [0,5] [0,0]
"vfmadd231pd 3080(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[5,12][0,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=6)
"vmovapd 29952(%%rdi), %%zmm3\r\n" // A [0,6] [0,3]
"vmovapd 31488(%%rdi), %%zmm5\r\n" // A [0,6] [0,5]
"vfmadd231pd 3088(%%rsi)%{1to8%}, %%zmm3, %%zmm28\r\n" // C[0:8,2] += A[0:8,3]*B[6,12][3,2]
"vfmadd231pd 3096(%%rsi)%{1to8%}, %%zmm5, %%zmm30\r\n" // C[0:8,4] += A[0:8,5]*B[6,12][5,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=7)
"vmovapd 33024(%%rdi), %%zmm1\r\n" // A [0,7] [0,1]
"vmovapd 33792(%%rdi), %%zmm2\r\n" // A [0,7] [0,2]
"vmovapd 36096(%%rdi), %%zmm5\r\n" // A [0,7] [0,5]
"vfmadd231pd 3104(%%rsi)%{1to8%}, %%zmm1, %%zmm26\r\n" // C[0:8,0] += A[0:8,1]*B[7,12][1,0]
"vfmadd231pd 3120(%%rsi)%{1to8%}, %%zmm2, %%zmm31\r\n" // C[0:8,5] += A[0:8,2]*B[7,12][2,5]
"vfmadd231pd 3112(%%rsi)%{1to8%}, %%zmm5, %%zmm30\r\n" // C[0:8,4] += A[0:8,5]*B[7,12][5,4]
"vfmadd231pd 3128(%%rsi)%{1to8%}, %%zmm5, %%zmm31\r\n" // C[0:8,5] += A[0:8,5]*B[7,12][5,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=9)
"vmovapd 42240(%%rdi), %%zmm1\r\n" // A [0,9] [0,1]
"vfmadd231pd 3136(%%rsi)%{1to8%}, %%zmm1, %%zmm28\r\n" // C[0:8,2] += A[0:8,1]*B[9,12][1,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=10)
"vmovapd 46080(%%rdi), %%zmm0\r\n" // A [0,10] [0,0]
"vmovapd 46848(%%rdi), %%zmm1\r\n" // A [0,10] [0,1]
"vfmadd231pd 3144(%%rsi)%{1to8%}, %%zmm0, %%zmm29\r\n" // C[0:8,3] += A[0:8,0]*B[10,12][0,3]
"vfmadd231pd 3152(%%rsi)%{1to8%}, %%zmm1, %%zmm31\r\n" // C[0:8,5] += A[0:8,1]*B[10,12][1,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=11)
"vmovapd 50688(%%rdi), %%zmm0\r\n" // A [0,11] [0,0]
"vmovapd 51456(%%rdi), %%zmm1\r\n" // A [0,11] [0,1]
"vmovapd 52992(%%rdi), %%zmm3\r\n" // A [0,11] [0,3]
"vmovapd 53760(%%rdi), %%zmm4\r\n" // A [0,11] [0,4]
"vfmadd231pd 3176(%%rsi)%{1to8%}, %%zmm0, %%zmm30\r\n" // C[0:8,4] += A[0:8,0]*B[11,12][0,4]
"vfmadd231pd 3184(%%rsi)%{1to8%}, %%zmm1, %%zmm30\r\n" // C[0:8,4] += A[0:8,1]*B[11,12][1,4]
"vfmadd231pd 3160(%%rsi)%{1to8%}, %%zmm3, %%zmm27\r\n" // C[0:8,1] += A[0:8,3]*B[11,12][3,1]
"vfmadd231pd 3192(%%rsi)%{1to8%}, %%zmm3, %%zmm30\r\n" // C[0:8,4] += A[0:8,3]*B[11,12][3,4]
"vfmadd231pd 3168(%%rsi)%{1to8%}, %%zmm4, %%zmm28\r\n" // C[0:8,2] += A[0:8,4]*B[11,12][4,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=12)
"vmovapd 56832(%%rdi), %%zmm2\r\n" // A [0,12] [0,2]
"vmovapd 57600(%%rdi), %%zmm3\r\n" // A [0,12] [0,3]
"vmovapd 58368(%%rdi), %%zmm4\r\n" // A [0,12] [0,4]
"vfmadd231pd 3216(%%rsi)%{1to8%}, %%zmm2, %%zmm30\r\n" // C[0:8,4] += A[0:8,2]*B[12,12][2,4]
"vfmadd231pd 3200(%%rsi)%{1to8%}, %%zmm3, %%zmm27\r\n" // C[0:8,1] += A[0:8,3]*B[12,12][3,1]
"vfmadd231pd 3208(%%rsi)%{1to8%}, %%zmm4, %%zmm29\r\n" // C[0:8,3] += A[0:8,4]*B[12,12][4,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=13)
"vmovapd 59904(%%rdi), %%zmm0\r\n" // A [0,13] [0,0]
"vmovapd 62208(%%rdi), %%zmm3\r\n" // A [0,13] [0,3]
"vmovapd 63744(%%rdi), %%zmm5\r\n" // A [0,13] [0,5]
"vfmadd231pd 3224(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[13,12][0,0]
"vfmadd231pd 3240(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[13,12][3,5]
"vfmadd231pd 3232(%%rsi)%{1to8%}, %%zmm5, %%zmm28\r\n" // C[0:8,2] += A[0:8,5]*B[13,12][5,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=15)
"vmovapd 69120(%%rdi), %%zmm0\r\n" // A [0,15] [0,0]
"vmovapd 69888(%%rdi), %%zmm1\r\n" // A [0,15] [0,1]
"vmovapd 70656(%%rdi), %%zmm2\r\n" // A [0,15] [0,2]
"vfmadd231pd 3248(%%rsi)%{1to8%}, %%zmm0, %%zmm27\r\n" // C[0:8,1] += A[0:8,0]*B[15,12][0,1]
"vfmadd231pd 3264(%%rsi)%{1to8%}, %%zmm1, %%zmm30\r\n" // C[0:8,4] += A[0:8,1]*B[15,12][1,4]
"vfmadd231pd 3256(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[15,12][2,3]
// Store C register block @ (d=0,r=0)
"vmovapd %%zmm26, 0(%%rdx)\r\n" // C [0,0] [0,0]
"vmovapd %%zmm27, 768(%%rdx)\r\n" // C [0,0] [0,1]
"vmovapd %%zmm28, 1536(%%rdx)\r\n" // C [0,0] [0,2]
"vmovapd %%zmm29, 2304(%%rdx)\r\n" // C [0,0] [0,3]
"vmovapd %%zmm30, 3072(%%rdx)\r\n" // C [0,0] [0,4]
"vmovapd %%zmm31, 3840(%%rdx)\r\n" // C [0,0] [0,5]
"addq $4608, %%rdx\r\n" // Move C to (d=0,r=1)
// Load C register block @ (d=0,r=0)
"vmovapd 0(%%rdx), %%zmm26\r\n" // C [0,0] [0,0]
"vmovapd 768(%%rdx), %%zmm27\r\n" // C [0,0] [0,1]
"vmovapd 1536(%%rdx), %%zmm28\r\n" // C [0,0] [0,2]
"vmovapd 2304(%%rdx), %%zmm29\r\n" // C [0,0] [0,3]
"vmovapd 3072(%%rdx), %%zmm30\r\n" // C [0,0] [0,4]
"vmovapd 3840(%%rdx), %%zmm31\r\n" // C [0,0] [0,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=0)
"vmovapd 2304(%%rdi), %%zmm3\r\n" // A [0,0] [0,3]
"vmovapd 3072(%%rdi), %%zmm4\r\n" // A [0,0] [0,4]
"vmovapd 3840(%%rdi), %%zmm5\r\n" // A [0,0] [0,5]
"vfmadd231pd 3272(%%rsi)%{1to8%}, %%zmm3, %%zmm26\r\n" // C[0:8,0] += A[0:8,3]*B[0,13][3,0]
"vfmadd231pd 3280(%%rsi)%{1to8%}, %%zmm4, %%zmm26\r\n" // C[0:8,0] += A[0:8,4]*B[0,13][4,0]
"vfmadd231pd 3288(%%rsi)%{1to8%}, %%zmm5, %%zmm29\r\n" // C[0:8,3] += A[0:8,5]*B[0,13][5,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=3)
"vmovapd 15360(%%rdi), %%zmm2\r\n" // A [0,3] [0,2]
"vmovapd 17664(%%rdi), %%zmm5\r\n" // A [0,3] [0,5]
"vfmadd231pd 3304(%%rsi)%{1to8%}, %%zmm2, %%zmm30\r\n" // C[0:8,4] += A[0:8,2]*B[3,13][2,4]
"vfmadd231pd 3296(%%rsi)%{1to8%}, %%zmm5, %%zmm27\r\n" // C[0:8,1] += A[0:8,5]*B[3,13][5,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=4)
"vmovapd 18432(%%rdi), %%zmm0\r\n" // A [0,4] [0,0]
"vmovapd 19968(%%rdi), %%zmm2\r\n" // A [0,4] [0,2]
"vmovapd 20736(%%rdi), %%zmm3\r\n" // A [0,4] [0,3]
"vfmadd231pd 3320(%%rsi)%{1to8%}, %%zmm0, %%zmm28\r\n" // C[0:8,2] += A[0:8,0]*B[4,13][0,2]
"vfmadd231pd 3312(%%rsi)%{1to8%}, %%zmm2, %%zmm26\r\n" // C[0:8,0] += A[0:8,2]*B[4,13][2,0]
"vfmadd231pd 3344(%%rsi)%{1to8%}, %%zmm2, %%zmm31\r\n" // C[0:8,5] += A[0:8,2]*B[4,13][2,5]
"vfmadd231pd 3328(%%rsi)%{1to8%}, %%zmm3, %%zmm28\r\n" // C[0:8,2] += A[0:8,3]*B[4,13][3,2]
"vfmadd231pd 3336(%%rsi)%{1to8%}, %%zmm3, %%zmm30\r\n" // C[0:8,4] += A[0:8,3]*B[4,13][3,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=5)
"vmovapd 23040(%%rdi), %%zmm0\r\n" // A [0,5] [0,0]
"vfmadd231pd 3352(%%rsi)%{1to8%}, %%zmm0, %%zmm28\r\n" // C[0:8,2] += A[0:8,0]*B[5,13][0,2]
// Block GEMM microkernel
// Load A register block @ (d=0,r=6)
"vmovapd 29952(%%rdi), %%zmm3\r\n" // A [0,6] [0,3]
"vmovapd 30720(%%rdi), %%zmm4\r\n" // A [0,6] [0,4]
"vmovapd 31488(%%rdi), %%zmm5\r\n" // A [0,6] [0,5]
"vfmadd231pd 3376(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[6,13][3,5]
"vfmadd231pd 3368(%%rsi)%{1to8%}, %%zmm4, %%zmm29\r\n" // C[0:8,3] += A[0:8,4]*B[6,13][4,3]
"vfmadd231pd 3384(%%rsi)%{1to8%}, %%zmm4, %%zmm31\r\n" // C[0:8,5] += A[0:8,4]*B[6,13][4,5]
"vfmadd231pd 3360(%%rsi)%{1to8%}, %%zmm5, %%zmm27\r\n" // C[0:8,1] += A[0:8,5]*B[6,13][5,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=7)
"vmovapd 36096(%%rdi), %%zmm5\r\n" // A [0,7] [0,5]
"vfmadd231pd 3392(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[7,13][5,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=8)
"vmovapd 36864(%%rdi), %%zmm0\r\n" // A [0,8] [0,0]
"vmovapd 38400(%%rdi), %%zmm2\r\n" // A [0,8] [0,2]
"vmovapd 39936(%%rdi), %%zmm4\r\n" // A [0,8] [0,4]
"vfmadd231pd 3400(%%rsi)%{1to8%}, %%zmm0, %%zmm27\r\n" // C[0:8,1] += A[0:8,0]*B[8,13][0,1]
"vfmadd231pd 3408(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[8,13][2,1]
"vfmadd231pd 3416(%%rsi)%{1to8%}, %%zmm4, %%zmm30\r\n" // C[0:8,4] += A[0:8,4]*B[8,13][4,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=9)
"vmovapd 41472(%%rdi), %%zmm0\r\n" // A [0,9] [0,0]
"vfmadd231pd 3424(%%rsi)%{1to8%}, %%zmm0, %%zmm27\r\n" // C[0:8,1] += A[0:8,0]*B[9,13][0,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=10)
"vmovapd 46848(%%rdi), %%zmm1\r\n" // A [0,10] [0,1]
"vmovapd 49920(%%rdi), %%zmm5\r\n" // A [0,10] [0,5]
"vfmadd231pd 3448(%%rsi)%{1to8%}, %%zmm1, %%zmm29\r\n" // C[0:8,3] += A[0:8,1]*B[10,13][1,3]
"vfmadd231pd 3432(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[10,13][5,0]
"vfmadd231pd 3440(%%rsi)%{1to8%}, %%zmm5, %%zmm27\r\n" // C[0:8,1] += A[0:8,5]*B[10,13][5,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=11)
"vmovapd 54528(%%rdi), %%zmm5\r\n" // A [0,11] [0,5]
"vfmadd231pd 3456(%%rsi)%{1to8%}, %%zmm5, %%zmm27\r\n" // C[0:8,1] += A[0:8,5]*B[11,13][5,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=12)
"vmovapd 55296(%%rdi), %%zmm0\r\n" // A [0,12] [0,0]
"vmovapd 56832(%%rdi), %%zmm2\r\n" // A [0,12] [0,2]
"vmovapd 57600(%%rdi), %%zmm3\r\n" // A [0,12] [0,3]
"vfmadd231pd 3480(%%rsi)%{1to8%}, %%zmm0, %%zmm30\r\n" // C[0:8,4] += A[0:8,0]*B[12,13][0,4]
"vfmadd231pd 3464(%%rsi)%{1to8%}, %%zmm2, %%zmm26\r\n" // C[0:8,0] += A[0:8,2]*B[12,13][2,0]
"vfmadd231pd 3472(%%rsi)%{1to8%}, %%zmm3, %%zmm29\r\n" // C[0:8,3] += A[0:8,3]*B[12,13][3,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=13)
"vmovapd 59904(%%rdi), %%zmm0\r\n" // A [0,13] [0,0]
"vmovapd 62976(%%rdi), %%zmm4\r\n" // A [0,13] [0,4]
"vfmadd231pd 3488(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[13,13][0,0]
"vfmadd231pd 3496(%%rsi)%{1to8%}, %%zmm4, %%zmm27\r\n" // C[0:8,1] += A[0:8,4]*B[13,13][4,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=14)
"vmovapd 67584(%%rdi), %%zmm4\r\n" // A [0,14] [0,4]
"vmovapd 68352(%%rdi), %%zmm5\r\n" // A [0,14] [0,5]
"vfmadd231pd 3504(%%rsi)%{1to8%}, %%zmm4, %%zmm29\r\n" // C[0:8,3] += A[0:8,4]*B[14,13][4,3]
"vfmadd231pd 3512(%%rsi)%{1to8%}, %%zmm5, %%zmm29\r\n" // C[0:8,3] += A[0:8,5]*B[14,13][5,3]
"vfmadd231pd 3520(%%rsi)%{1to8%}, %%zmm5, %%zmm31\r\n" // C[0:8,5] += A[0:8,5]*B[14,13][5,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=15)
"vmovapd 70656(%%rdi), %%zmm2\r\n" // A [0,15] [0,2]
"vmovapd 71424(%%rdi), %%zmm3\r\n" // A [0,15] [0,3]
"vmovapd 72192(%%rdi), %%zmm4\r\n" // A [0,15] [0,4]
"vfmadd231pd 3536(%%rsi)%{1to8%}, %%zmm2, %%zmm31\r\n" // C[0:8,5] += A[0:8,2]*B[15,13][2,5]
"vfmadd231pd 3528(%%rsi)%{1to8%}, %%zmm3, %%zmm29\r\n" // C[0:8,3] += A[0:8,3]*B[15,13][3,3]
"vfmadd231pd 3544(%%rsi)%{1to8%}, %%zmm4, %%zmm31\r\n" // C[0:8,5] += A[0:8,4]*B[15,13][4,5]
// Store C register block @ (d=0,r=0)
"vmovapd %%zmm26, 0(%%rdx)\r\n" // C [0,0] [0,0]
"vmovapd %%zmm27, 768(%%rdx)\r\n" // C [0,0] [0,1]
"vmovapd %%zmm28, 1536(%%rdx)\r\n" // C [0,0] [0,2]
"vmovapd %%zmm29, 2304(%%rdx)\r\n" // C [0,0] [0,3]
"vmovapd %%zmm30, 3072(%%rdx)\r\n" // C [0,0] [0,4]
"vmovapd %%zmm31, 3840(%%rdx)\r\n" // C [0,0] [0,5]
"addq $4608, %%rdx\r\n" // Move C to (d=0,r=1)
// Load C register block @ (d=0,r=0)
"vmovapd 0(%%rdx), %%zmm26\r\n" // C [0,0] [0,0]
"vmovapd 768(%%rdx), %%zmm27\r\n" // C [0,0] [0,1]
"vmovapd 1536(%%rdx), %%zmm28\r\n" // C [0,0] [0,2]
"vmovapd 2304(%%rdx), %%zmm29\r\n" // C [0,0] [0,3]
"vmovapd 3072(%%rdx), %%zmm30\r\n" // C [0,0] [0,4]
"vmovapd 3840(%%rdx), %%zmm31\r\n" // C [0,0] [0,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=0)
"vmovapd 768(%%rdi), %%zmm1\r\n" // A [0,0] [0,1]
"vmovapd 2304(%%rdi), %%zmm3\r\n" // A [0,0] [0,3]
"vfmadd231pd 3552(%%rsi)%{1to8%}, %%zmm1, %%zmm26\r\n" // C[0:8,0] += A[0:8,1]*B[0,14][1,0]
"vfmadd231pd 3560(%%rsi)%{1to8%}, %%zmm3, %%zmm26\r\n" // C[0:8,0] += A[0:8,3]*B[0,14][3,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=1)
"vmovapd 6912(%%rdi), %%zmm3\r\n" // A [0,1] [0,3]
"vmovapd 7680(%%rdi), %%zmm4\r\n" // A [0,1] [0,4]
"vfmadd231pd 3576(%%rsi)%{1to8%}, %%zmm3, %%zmm30\r\n" // C[0:8,4] += A[0:8,3]*B[1,14][3,4]
"vfmadd231pd 3568(%%rsi)%{1to8%}, %%zmm4, %%zmm29\r\n" // C[0:8,3] += A[0:8,4]*B[1,14][4,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=2)
"vmovapd 9216(%%rdi), %%zmm0\r\n" // A [0,2] [0,0]
"vmovapd 9984(%%rdi), %%zmm1\r\n" // A [0,2] [0,1]
"vmovapd 12288(%%rdi), %%zmm4\r\n" // A [0,2] [0,4]
"vfmadd231pd 3584(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[2,14][0,0]
"vfmadd231pd 3592(%%rsi)%{1to8%}, %%zmm1, %%zmm30\r\n" // C[0:8,4] += A[0:8,1]*B[2,14][1,4]
"vfmadd231pd 3600(%%rsi)%{1to8%}, %%zmm4, %%zmm30\r\n" // C[0:8,4] += A[0:8,4]*B[2,14][4,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=3)
"vmovapd 13824(%%rdi), %%zmm0\r\n" // A [0,3] [0,0]
"vfmadd231pd 3608(%%rsi)%{1to8%}, %%zmm0, %%zmm30\r\n" // C[0:8,4] += A[0:8,0]*B[3,14][0,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=4)
"vmovapd 21504(%%rdi), %%zmm4\r\n" // A [0,4] [0,4]
"vfmadd231pd 3616(%%rsi)%{1to8%}, %%zmm4, %%zmm26\r\n" // C[0:8,0] += A[0:8,4]*B[4,14][4,0]
"vfmadd231pd 3624(%%rsi)%{1to8%}, %%zmm4, %%zmm31\r\n" // C[0:8,5] += A[0:8,4]*B[4,14][4,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=5)
"vmovapd 24576(%%rdi), %%zmm2\r\n" // A [0,5] [0,2]
"vmovapd 25344(%%rdi), %%zmm3\r\n" // A [0,5] [0,3]
"vfmadd231pd 3632(%%rsi)%{1to8%}, %%zmm2, %%zmm30\r\n" // C[0:8,4] += A[0:8,2]*B[5,14][2,4]
"vfmadd231pd 3640(%%rsi)%{1to8%}, %%zmm3, %%zmm30\r\n" // C[0:8,4] += A[0:8,3]*B[5,14][3,4]
// Block GEMM microkernel
// Load A register block @ (d=0,r=6)
"vmovapd 28416(%%rdi), %%zmm1\r\n" // A [0,6] [0,1]
"vfmadd231pd 3648(%%rsi)%{1to8%}, %%zmm1, %%zmm29\r\n" // C[0:8,3] += A[0:8,1]*B[6,14][1,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=8)
"vmovapd 36864(%%rdi), %%zmm0\r\n" // A [0,8] [0,0]
"vmovapd 38400(%%rdi), %%zmm2\r\n" // A [0,8] [0,2]
"vmovapd 39168(%%rdi), %%zmm3\r\n" // A [0,8] [0,3]
"vmovapd 39936(%%rdi), %%zmm4\r\n" // A [0,8] [0,4]
"vfmadd231pd 3664(%%rsi)%{1to8%}, %%zmm0, %%zmm30\r\n" // C[0:8,4] += A[0:8,0]*B[8,14][0,4]
"vfmadd231pd 3656(%%rsi)%{1to8%}, %%zmm2, %%zmm28\r\n" // C[0:8,2] += A[0:8,2]*B[8,14][2,2]
"vfmadd231pd 3672(%%rsi)%{1to8%}, %%zmm3, %%zmm30\r\n" // C[0:8,4] += A[0:8,3]*B[8,14][3,4]
"vfmadd231pd 3680(%%rsi)%{1to8%}, %%zmm4, %%zmm31\r\n" // C[0:8,5] += A[0:8,4]*B[8,14][4,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=9)
"vmovapd 45312(%%rdi), %%zmm5\r\n" // A [0,9] [0,5]
"vfmadd231pd 3688(%%rsi)%{1to8%}, %%zmm5, %%zmm29\r\n" // C[0:8,3] += A[0:8,5]*B[9,14][5,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=11)
"vmovapd 52224(%%rdi), %%zmm2\r\n" // A [0,11] [0,2]
"vmovapd 52992(%%rdi), %%zmm3\r\n" // A [0,11] [0,3]
"vfmadd231pd 3696(%%rsi)%{1to8%}, %%zmm2, %%zmm26\r\n" // C[0:8,0] += A[0:8,2]*B[11,14][2,0]
"vfmadd231pd 3704(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[11,14][2,3]
"vfmadd231pd 3712(%%rsi)%{1to8%}, %%zmm3, %%zmm29\r\n" // C[0:8,3] += A[0:8,3]*B[11,14][3,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=12)
"vmovapd 56832(%%rdi), %%zmm2\r\n" // A [0,12] [0,2]
"vmovapd 59136(%%rdi), %%zmm5\r\n" // A [0,12] [0,5]
"vfmadd231pd 3720(%%rsi)%{1to8%}, %%zmm2, %%zmm26\r\n" // C[0:8,0] += A[0:8,2]*B[12,14][2,0]
"vfmadd231pd 3728(%%rsi)%{1to8%}, %%zmm2, %%zmm28\r\n" // C[0:8,2] += A[0:8,2]*B[12,14][2,2]
"vfmadd231pd 3736(%%rsi)%{1to8%}, %%zmm5, %%zmm31\r\n" // C[0:8,5] += A[0:8,5]*B[12,14][5,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=13)
"vmovapd 59904(%%rdi), %%zmm0\r\n" // A [0,13] [0,0]
"vmovapd 61440(%%rdi), %%zmm2\r\n" // A [0,13] [0,2]
"vmovapd 62976(%%rdi), %%zmm4\r\n" // A [0,13] [0,4]
"vfmadd231pd 3744(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[13,14][0,0]
"vfmadd231pd 3752(%%rsi)%{1to8%}, %%zmm2, %%zmm26\r\n" // C[0:8,0] += A[0:8,2]*B[13,14][2,0]
"vfmadd231pd 3768(%%rsi)%{1to8%}, %%zmm2, %%zmm27\r\n" // C[0:8,1] += A[0:8,2]*B[13,14][2,1]
"vfmadd231pd 3760(%%rsi)%{1to8%}, %%zmm4, %%zmm26\r\n" // C[0:8,0] += A[0:8,4]*B[13,14][4,0]
"vfmadd231pd 3776(%%rsi)%{1to8%}, %%zmm4, %%zmm27\r\n" // C[0:8,1] += A[0:8,4]*B[13,14][4,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=15)
"vmovapd 72960(%%rdi), %%zmm5\r\n" // A [0,15] [0,5]
"vfmadd231pd 3784(%%rsi)%{1to8%}, %%zmm5, %%zmm26\r\n" // C[0:8,0] += A[0:8,5]*B[15,14][5,0]
// Store C register block @ (d=0,r=0)
"vmovapd %%zmm26, 0(%%rdx)\r\n" // C [0,0] [0,0]
"vmovapd %%zmm27, 768(%%rdx)\r\n" // C [0,0] [0,1]
"vmovapd %%zmm28, 1536(%%rdx)\r\n" // C [0,0] [0,2]
"vmovapd %%zmm29, 2304(%%rdx)\r\n" // C [0,0] [0,3]
"vmovapd %%zmm30, 3072(%%rdx)\r\n" // C [0,0] [0,4]
"vmovapd %%zmm31, 3840(%%rdx)\r\n" // C [0,0] [0,5]
"addq $4608, %%rdx\r\n" // Move C to (d=0,r=1)
// Load C register block @ (d=0,r=0)
"vmovapd 0(%%rdx), %%zmm26\r\n" // C [0,0] [0,0]
"vmovapd 768(%%rdx), %%zmm27\r\n" // C [0,0] [0,1]
"vmovapd 1536(%%rdx), %%zmm28\r\n" // C [0,0] [0,2]
"vmovapd 2304(%%rdx), %%zmm29\r\n" // C [0,0] [0,3]
"vmovapd 3072(%%rdx), %%zmm30\r\n" // C [0,0] [0,4]
"vmovapd 3840(%%rdx), %%zmm31\r\n" // C [0,0] [0,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=1)
"vmovapd 6144(%%rdi), %%zmm2\r\n" // A [0,1] [0,2]
"vmovapd 6912(%%rdi), %%zmm3\r\n" // A [0,1] [0,3]
"vfmadd231pd 3800(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[1,15][2,3]
"vfmadd231pd 3792(%%rsi)%{1to8%}, %%zmm3, %%zmm27\r\n" // C[0:8,1] += A[0:8,3]*B[1,15][3,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=2)
"vmovapd 9216(%%rdi), %%zmm0\r\n" // A [0,2] [0,0]
"vfmadd231pd 3808(%%rsi)%{1to8%}, %%zmm0, %%zmm28\r\n" // C[0:8,2] += A[0:8,0]*B[2,15][0,2]
"vfmadd231pd 3816(%%rsi)%{1to8%}, %%zmm0, %%zmm29\r\n" // C[0:8,3] += A[0:8,0]*B[2,15][0,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=3)
"vmovapd 15360(%%rdi), %%zmm2\r\n" // A [0,3] [0,2]
"vmovapd 16128(%%rdi), %%zmm3\r\n" // A [0,3] [0,3]
"vfmadd231pd 3824(%%rsi)%{1to8%}, %%zmm2, %%zmm31\r\n" // C[0:8,5] += A[0:8,2]*B[3,15][2,5]
"vfmadd231pd 3832(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[3,15][3,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=4)
"vmovapd 18432(%%rdi), %%zmm0\r\n" // A [0,4] [0,0]
"vmovapd 19968(%%rdi), %%zmm2\r\n" // A [0,4] [0,2]
"vmovapd 20736(%%rdi), %%zmm3\r\n" // A [0,4] [0,3]
"vmovapd 21504(%%rdi), %%zmm4\r\n" // A [0,4] [0,4]
"vfmadd231pd 3840(%%rsi)%{1to8%}, %%zmm0, %%zmm26\r\n" // C[0:8,0] += A[0:8,0]*B[4,15][0,0]
"vfmadd231pd 3848(%%rsi)%{1to8%}, %%zmm2, %%zmm28\r\n" // C[0:8,2] += A[0:8,2]*B[4,15][2,2]
"vfmadd231pd 3864(%%rsi)%{1to8%}, %%zmm2, %%zmm30\r\n" // C[0:8,4] += A[0:8,2]*B[4,15][2,4]
"vfmadd231pd 3856(%%rsi)%{1to8%}, %%zmm3, %%zmm28\r\n" // C[0:8,2] += A[0:8,3]*B[4,15][3,2]
"vfmadd231pd 3872(%%rsi)%{1to8%}, %%zmm4, %%zmm31\r\n" // C[0:8,5] += A[0:8,4]*B[4,15][4,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=6)
"vmovapd 29184(%%rdi), %%zmm2\r\n" // A [0,6] [0,2]
"vmovapd 30720(%%rdi), %%zmm4\r\n" // A [0,6] [0,4]
"vfmadd231pd 3888(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[6,15][2,3]
"vfmadd231pd 3880(%%rsi)%{1to8%}, %%zmm4, %%zmm26\r\n" // C[0:8,0] += A[0:8,4]*B[6,15][4,0]
// Block GEMM microkernel
// Load A register block @ (d=0,r=7)
"vmovapd 33792(%%rdi), %%zmm2\r\n" // A [0,7] [0,2]
"vmovapd 34560(%%rdi), %%zmm3\r\n" // A [0,7] [0,3]
"vmovapd 35328(%%rdi), %%zmm4\r\n" // A [0,7] [0,4]
"vfmadd231pd 3896(%%rsi)%{1to8%}, %%zmm2, %%zmm29\r\n" // C[0:8,3] += A[0:8,2]*B[7,15][2,3]
"vfmadd231pd 3912(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[7,15][3,5]
"vfmadd231pd 3904(%%rsi)%{1to8%}, %%zmm4, %%zmm29\r\n" // C[0:8,3] += A[0:8,4]*B[7,15][4,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=8)
"vmovapd 36864(%%rdi), %%zmm0\r\n" // A [0,8] [0,0]
"vmovapd 39168(%%rdi), %%zmm3\r\n" // A [0,8] [0,3]
"vmovapd 40704(%%rdi), %%zmm5\r\n" // A [0,8] [0,5]
"vfmadd231pd 3920(%%rsi)%{1to8%}, %%zmm0, %%zmm29\r\n" // C[0:8,3] += A[0:8,0]*B[8,15][0,3]
"vfmadd231pd 3928(%%rsi)%{1to8%}, %%zmm3, %%zmm30\r\n" // C[0:8,4] += A[0:8,3]*B[8,15][3,4]
"vfmadd231pd 3936(%%rsi)%{1to8%}, %%zmm5, %%zmm31\r\n" // C[0:8,5] += A[0:8,5]*B[8,15][5,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=9)
"vmovapd 41472(%%rdi), %%zmm0\r\n" // A [0,9] [0,0]
"vfmadd231pd 3944(%%rsi)%{1to8%}, %%zmm0, %%zmm29\r\n" // C[0:8,3] += A[0:8,0]*B[9,15][0,3]
// Block GEMM microkernel
// Load A register block @ (d=0,r=13)
"vmovapd 62976(%%rdi), %%zmm4\r\n" // A [0,13] [0,4]
"vmovapd 63744(%%rdi), %%zmm5\r\n" // A [0,13] [0,5]
"vfmadd231pd 3960(%%rsi)%{1to8%}, %%zmm4, %%zmm30\r\n" // C[0:8,4] += A[0:8,4]*B[13,15][4,4]
"vfmadd231pd 3968(%%rsi)%{1to8%}, %%zmm4, %%zmm31\r\n" // C[0:8,5] += A[0:8,4]*B[13,15][4,5]
"vfmadd231pd 3952(%%rsi)%{1to8%}, %%zmm5, %%zmm27\r\n" // C[0:8,1] += A[0:8,5]*B[13,15][5,1]
// Block GEMM microkernel
// Load A register block @ (d=0,r=14)
"vmovapd 65280(%%rdi), %%zmm1\r\n" // A [0,14] [0,1]
"vmovapd 66816(%%rdi), %%zmm3\r\n" // A [0,14] [0,3]
"vfmadd231pd 3976(%%rsi)%{1to8%}, %%zmm1, %%zmm28\r\n" // C[0:8,2] += A[0:8,1]*B[14,15][1,2]
"vfmadd231pd 3984(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[14,15][3,5]
// Block GEMM microkernel
// Load A register block @ (d=0,r=15)
"vmovapd 71424(%%rdi), %%zmm3\r\n" // A [0,15] [0,3]
"vfmadd231pd 3992(%%rsi)%{1to8%}, %%zmm3, %%zmm31\r\n" // C[0:8,5] += A[0:8,3]*B[15,15][3,5]
// Store C register block @ (d=0,r=0)
"vmovapd %%zmm26, 0(%%rdx)\r\n" // C [0,0] [0,0]
"vmovapd %%zmm27, 768(%%rdx)\r\n" // C [0,0] [0,1]
"vmovapd %%zmm28, 1536(%%rdx)\r\n" // C [0,0] [0,2]
"vmovapd %%zmm29, 2304(%%rdx)\r\n" // C [0,0] [0,3]
"vmovapd %%zmm30, 3072(%%rdx)\r\n" // C [0,0] [0,4]
"vmovapd %%zmm31, 3840(%%rdx)\r\n" // C [0,0] [0,5]
"addq $64, %%rdi\r\n" // Move A to (d=1,r=0)
"addq $-69056, %%rdx\r\n" // Move C to (d=1,r=-15)
"addq $1, %%r12\r\n"
"cmp $12, %%r12\r\n"
"jl LOOP_TOP_40_%=\r\n"
: : "m"(A), "m"(B), "m"(C) : "r12","rdi","rdx","zmm0","zmm1","zmm2","zmm26","zmm27","zmm28","zmm29","zmm3","zmm30","zmm31","zmm4","zmm5");
};
|
71f05388d2bddceeac6c8f2938df738ca2453d41 | 1791461e6740f81c2dd6704ae6a899a6707ee6b1 | /BZOJ/BZOJ1176.cpp | 53c2f39c7e5448a7be07dd297ae0dd9534869928 | [
"MIT"
] | permissive | HeRaNO/OI-ICPC-Codes | b12569caa94828c4bedda99d88303eb6344f5d6e | 4f542bb921914abd4e2ee7e17d8d93c1c91495e4 | refs/heads/master | 2023-08-06T10:46:32.714133 | 2023-07-26T08:10:44 | 2023-07-26T08:10:44 | 163,658,110 | 22 | 6 | null | null | null | null | UTF-8 | C++ | false | false | 2,098 | cpp | BZOJ1176.cpp | #include <cstdio>
#include <algorithm>
#define MAXQ 200010
#define MAXW 2000010
using namespace std;
struct Mokia
{
int x, y, opt, delta, id, pos;
};
Mokia q[MAXQ], t[MAXQ];
int n, T, opt, x1, x2, y_1, y2, A;
int c[MAXW], ans[MAXQ];
bool cmp(Mokia a, Mokia b)
{
if (a.x == b.x && a.y == b.y) return a.opt < b.opt;
return a.x == b.x ? a.y < b.y : a.x < b.x;
}
inline int lowbit(int x)
{
return x & -x;
}
inline void modify(int x, int v)
{
for (; x <= n; x += lowbit(x)) c[x] += v;
return ;
}
inline int query(int x)
{
int res = 0;
for (; x; x -= lowbit(x)) res += c[x];
return res;
}
void CDQ(int l, int r)
{
if (l == r) return ;
int mid = l + r >> 1, ll = l, rl = mid + 1;
for (int i = l; i <= r; i++)
{
if (q[i].id <= mid && !q[i].opt) modify(q[i].y, q[i].delta);
else if (q[i].id > mid && q[i].opt) ans[q[i].pos] += q[i].delta * query(q[i].y);
}
for (int i = l; i <= r; i++)
if (q[i].id <= mid && !q[i].opt) modify(q[i].y, -q[i].delta);
for (int i = l; i <= r; i++)
if (q[i].id <= mid) t[ll++] = q[i];
else t[rl++] = q[i];
for (int i = l; i <= r; i++) q[i] = t[i];
CDQ(l, mid);
CDQ(mid + 1, r);
return ;
}
inline void read(int &x)
{
x = 0;
char ch = getchar();
while (ch < '0' || ch > '9') ch = getchar();
while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
return ;
}
int main()
{
while (true)
{
read(opt);
opt--;
if (!~opt) read(n);
else if (!opt)
{
read(x1);
read(y_1);
read(A);
q[++T] = (Mokia)
{
x1, y_1, opt, A, 0, 0
};
q[T].id = T;
}
else if (opt == 1)
{
read(x1);
read(y_1);
read(x2);
read(y2);
ans[0]++;
q[++T] = (Mokia)
{
x1 - 1, y_1 - 1, opt, 1, 0, ans[0]
};
q[T].id = T;
q[++T] = (Mokia)
{
x2, y_1 - 1, opt, -1, 0, ans[0]
};
q[T].id = T;
q[++T] = (Mokia)
{
x1 - 1, y2, opt, -1, 0, ans[0]
};
q[T].id = T;
q[++T] = (Mokia)
{
x2, y2, opt, 1, 0, ans[0]
};
q[T].id = T;
}
else break;
}
sort(q + 1, q + T + 1, cmp);
CDQ(1, T);
for (int i = 1; i <= ans[0]; i++) printf("%d\n", ans[i]);
return 0;
}
|
55ff03f0a77aa1599e4a46c2ab4597bd34540b37 | 4f7229d2c746d79b2ad33f03d916ade770ec489a | /OpenFrameworks/apps/structuredLight/decode/src/testApp.cpp | 54cd86b4ca774aba9b3673780d8db668477584a5 | [] | no_license | icelinker/structured-light | 81a0275b78d7148586b51f296c147668a3350b43 | f46b4a8e98340264584315ca19ac956498e9e9a4 | refs/heads/master | 2020-11-26T19:06:51.348937 | 2015-07-02T00:06:53 | 2015-07-02T00:06:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,784 | cpp | testApp.cpp | #include "testApp.h"
/*
then implement exporting of sequences ("record").
then allow skipping to different locations in the sequence.
*/
void testApp::setup() {
hidden = false;
sequenceFrame = 0;
threePhase = NULL;
// setup control panel
panel.setup("control", 0, 0, 300, 720);
panel.loadSettings("control.xml");
panel.addPanel("input", 1);
panel.addPanel("decode", 1);
panel.addPanel("export", 1);
panel.addPanel("misc", 1);
panel.setWhichPanel("input");
inputList.listDir("input");
panel.addFileLister("input", &inputList, 240, 440);
panel.addSlider("camera rate", "cameraRate", 1, 1, 6, true);
panel.addSlider("camera offset", "cameraOffset", 0, 0, 5, true);
panel.addSlider("play rate", "playRate", 1, 1, 60, true);
panel.setWhichPanel("decode");
panel.addToggle("stop motion", "stopMotion", false);
panel.addToggle("play sequence", "playSequence", false);
panel.addSlider("jump to", "jumpTo", 0, 0, 100, false);
panel.addToggle("phase persistence", "phasePersistence", false);
panel.addToggle("reset view ", "resetView", false);
styles.push_back("cloud");
styles.push_back("mesh");
styles.push_back("none");
panel.addMultiToggle("style", "style", 0, styles);
vector<string> orientation;
orientation.push_back("horizontal");
orientation.push_back("vertical");
panel.addMultiToggle("orientation", "orientation", 0, orientation);
panel.addSlider("range threshold", "rangeThreshold", 40, 0, 255, true);
panel.addSlider("depth scale", "depthScale", 130, -500, 500, false);
panel.addSlider("depth skew", "depthSkew", -28, -50, 50, false);
panel.addSlider("filter min", "filterMin", -1024, -1024, 1024, false);
panel.addSlider("filter max", "filterMax", 1024, -1024, 1024, false);
panel.setWhichPanel("export");
exportFormats.push_back(".obj");
exportFormats.push_back(".ply");
exportFormats.push_back(".png");
panel.addMultiToggle("export format", "exportFormat", 0, exportFormats);
panel.addToggle("export", "export", false);
panel.addToggle("record", "record", false);
panel.addToggle("render movie", "renderMovie", false);
panel.addSlider("movie framerate", "movieFramerate", 60, 5, 60, true);
panel.setWhichPanel("misc");
panel.addSlider("gamma", "gamma", 1, 0.0, 1.0, false);
panel.addToggle("hud", "hud", false);
panel.addSlider("hudWidth", "hudWidth", 300.0, 0.0, 2000.0, false);
panel.addSlider("hudHeightOffset", "hudHeightOffset", 0.0, 0.0, 1.0, false);
panel.addSlider("maxPhase", "maxPhase", 10.0, 0.0, 100.0, false);
panel.addSlider("maxDepth power", "maxDepth", 3.0, 0.0, 5.0, false);
}
void testApp::drawCloud() {
bool* mask = threePhase->getMask();
float* depth = threePhase->getDepth();
byte* color = threePhase->getColor();
int srcWidth = threePhase->getWidth();
int srcHeight = threePhase->getHeight();
glEnable(GL_POINT_SIZE);
glPointSize(3);
glBegin(GL_POINTS);
int i = 0;
for (int y = 0; y < srcHeight; y++) {
for (int x = 0; x < srcWidth; x++) {
if (!mask[i]) {
glColor3ubv(&color[i * 3]);
glVertex3f(x, y, depth[i]);
}
i++;
}
}
glEnd();
}
void testApp::drawMesh() {
bool* mask = threePhase->getMask();
float* depth = threePhase->getDepth();
byte* color = threePhase->getColor();
int srcWidth = threePhase->getWidth();
int srcHeight = threePhase->getHeight();
glBegin(GL_TRIANGLES);
for (int y = 0; y < srcHeight - 1; y++) {
for (int x = 0; x < srcWidth - 1; x++) {
int nw = y * srcWidth + x;
int ne = nw + 1;
int sw = nw + srcWidth;
int se = ne + srcWidth;
if (!mask[nw] && !mask[se]) {
if (!mask[ne]) { // nw, ne, se
glColor3ubv(&color[nw * 3]);
glVertex3f(x, y, depth[nw]);
glColor3ubv(&color[ne * 3]);
glVertex3f(x + 1, y, depth[ne]);
glColor3ubv(&color[se * 3]);
glVertex3f(x + 1, y + 1, depth[se]);
}
if (!mask[sw]) { // nw, se, sw
glColor3ubv(&color[nw * 3]);
glVertex3f(x, y, depth[nw]);
glColor3ubv(&color[se * 3]);
glVertex3f(x + 1, y + 1, depth[se]);
glColor3ubv(&color[sw * 3]);
glVertex3f(x, y + 1, depth[sw]);
}
} else if (!mask[ne] && !mask[sw]) {
if (!mask[nw]) { // nw, ne, sw
glColor3ubv(&color[nw * 3]);
glVertex3f(x, y, depth[nw]);
glColor3ubv(&color[ne * 3]);
glVertex3f(x + 1, y, depth[ne]);
glColor3ubv(&color[sw * 3]);
glVertex3f(x, y + 1, depth[sw]);
}
if (!mask[se]) { // ne, se, sw
glColor3ubv(&color[ne * 3]);
glVertex3f(x + 1, y, depth[ne]);
glColor3ubv(&color[se * 3]);
glVertex3f(x + 1, y + 1, depth[se]);
glColor3ubv(&color[sw * 3]);
glVertex3f(x, y + 1, depth[sw]);
}
}
}
}
glEnd();
}
testApp::~testApp() {
}
void testApp::nextFrame() {
int cameraRate = panel.getValueI("cameraRate");
int cameraOffset = panel.getValueI("cameraOffset");
unsigned totalFrames = (totalImages - cameraOffset) / cameraRate;
int cameraFrame = (sequenceFrame * cameraRate) + cameraOffset;
cameraFrame %= totalImages;
if (usingDirectory) {
ofImage phase;
if (!phase.loadImage(inputDir + imageList.getName(cameraFrame))) {
cout << "couldn't load file " << (inputDir + imageList.getName(cameraFrame)) << endl;
return;
}
threePhase->set(sequenceFrame % 3, phase.getPixels());
} else {
movieInput.setFrame(cameraFrame);
threePhase->set(sequenceFrame % 3, movieInput.getPixels()); // TBD can movies have different than 24 bpp?
}
sequenceFrame = (sequenceFrame + 1) % totalFrames;
if (sequenceFrame == 0)
cout << "Starting sequence over." << endl;
}
void testApp::jumpTo(unsigned frame) {
sequenceFrame = frame;
for (int i = 0; i < 3; i++)
nextFrame();
}
void testApp::setupInput() {
if (threePhase != NULL)
delete threePhase;
threePhase = new ThreePhaseDecoder();
string name = inputList.getSelectedName();
usingDirectory = name.find('.') == string::npos;
if (usingDirectory) {
inputDir = "input/" + name + "/";
totalImages = imageList.listDir(inputDir);
for(int i = 0; i < totalImages; i++) {
cout << i << ": " << imageList.getName(i) << endl;
}
ofImage phase;
// TBD
string imageName = imageList.getName(0);
if (!phase.loadImage(inputDir + imageName)) {
cout << "couldn't load file " << (inputDir + imageName) << endl;
delete threePhase;
return;
}
int w = (int) phase.getWidth();
int h = (int) phase.getHeight();
threePhase->setup(w, h);
phaseUnwrapped.clear();
phaseUnwrapped.allocate(w, h, OF_IMAGE_COLOR);
phaseWrapped.clear();
phaseWrapped.allocate(w, h, OF_IMAGE_GRAYSCALE);
rangeIm.clear();
rangeIm.allocate(w, h, OF_IMAGE_GRAYSCALE);
unwrapOrderIm.clear();
unwrapOrderIm.allocate(w, h, OF_IMAGE_COLOR);
depthIm.clear();
depthIm.allocate(w, h, OF_IMAGE_COLOR);
} else {
movieInput.loadMovie("input/" + name);
movieInput.setVolume(0);
totalImages = movieInput.getTotalNumFrames();
threePhase->setup((int) movieInput.getWidth(), (int) movieInput.getHeight());
}
jumpTo(0);
}
void testApp::update() {
float curDepthScale = panel.getValueF("depthScale");
float curDepthSkew = panel.getValueF("depthSkew");
int curRangeThreshold = panel.getValueI("rangeThreshold");
int curOrientation = panel.getValueI("orientation");
float curFilterMin = panel.getValueF("filterMin");
float curFilterMax = panel.getValueF("filterMax");
bool curPlaySequence = panel.getValueB("playSequence");
int curPlayRate = panel.getValueI("playRate");
float curJumpTo = panel.getValueF("jumpTo");
bool curPhasePersistence = panel.getValueB("phasePersistence");
int curCameraRate = panel.getValueI("cameraRate");
int curCameraOffset = panel.getValueI("cameraOffset");
bool curStopMotion = panel.getValueB("stopMotion");
float gamma = panel.getValueF("gamma");
bool curResetView = panel.getValueB("resetView");
if (curResetView) {
camera = ofxEasyCam();
panel.setValueB("resetView", false);
}
bool reload = inputList.selectedHasChanged();
if (reload) {
setupInput();
inputList.clearChangedFlag();
}
unsigned totalFrames = (totalImages - curCameraOffset) / curCameraRate;
if (threePhase != NULL) {
threePhase->setGamma(gamma);
threePhase->setDepthScale(curDepthScale);
threePhase->setDepthSkew(curDepthSkew);
threePhase->setRangeThreshold(curRangeThreshold);
threePhase->setOrientation(curOrientation == 0 ? PHASE_HORIZONTAL : PHASE_VERTICAL);
threePhase->setPhasePersistence(curPhasePersistence);
if (curPhasePersistence != lastPhasePersistence)
threePhase->clearLastPhase();
if (curJumpTo != lastJumpTo) {
// map slider to entire range of input images
unsigned targetFrame = (unsigned) ofMap(lastJumpTo, 0, 100, 0, totalFrames);
// clamp to amaxmimum of last image - 3, so you don't try reading in a loop
targetFrame = (unsigned) ofClamp(targetFrame, 0, totalFrames - 3);
// quantize location if stop motion is enabled
if (curStopMotion)
targetFrame = (targetFrame / 3) * 3;
// so long as we're not just jumping to the same place
if ((targetFrame + 3) % totalFrames != sequenceFrame) {
jumpTo(targetFrame);
reload = true;
}
} else if (ofGetFrameNum() % curPlayRate == 0 &&
(curPlaySequence || curCameraRate != lastCameraRate || curCameraOffset != lastCameraOffset)) {
if (curStopMotion) {
// make sure to quantize current frame, in case we're switching from non-stop-motion
sequenceFrame = (sequenceFrame / 3) * 3;
for (int i = 0; i < 3; i++)
nextFrame();
} else
nextFrame();
panel.setValueF("jumpTo", ofMap(sequenceFrame, 0, totalFrames, 0, 100));
curJumpTo = panel.getValueF("jumpTo");
reload = true;
}
if (reload ||
gamma != lastGamma ||
curRangeThreshold != lastRangeThreshold || curOrientation != lastOrientation ||
curFilterMin != lastFilterMin || curFilterMax != lastFilterMax ||
curDepthScale != lastDepthScale || curDepthSkew != lastDepthSkew) {
threePhase->decode();
if (curFilterMin != -1024 || curFilterMax != 1024)
threePhase->filterRange(curFilterMin, curFilterMax);
redraw = true;
}
// export handling
bool curExport = panel.getValueB("export");
bool curRecord = panel.getValueB("record");
if (curExport || curRecord) {
string curFormat = exportFormats[panel.getValueI("exportFormat")];
string name = inputList.getSelectedName();
if (curRecord)
name += "-" + ofToString(sequenceFrame);
if (curFormat == ".png") {
threePhase->exportDepth("output/" + name + "-depth.png", panel.getValueI("filterMin"), panel.getValueI("filterMax"));
threePhase->exportTexture("output/" + name + "-texture.png");
} else {
int curStyle = panel.getValueI("style");
string outputFile = "output/" + name + "-" + styles[curStyle] + curFormat;
if (curStyle == 0) {
threePhase->exportCloud(outputFile);
} else if (curStyle == 1) {
threePhase->exportMesh(outputFile);
}
}
panel.setValueB("export", false);
}
}
lastGamma = gamma;
lastDepthScale = curDepthScale;
lastDepthSkew = curDepthSkew;
lastRangeThreshold = curRangeThreshold;
lastOrientation = curOrientation;
lastFilterMin = curFilterMin;
lastFilterMax = curFilterMax;
lastJumpTo = curJumpTo;
lastCameraRate = curCameraRate;
lastCameraOffset = curCameraOffset;
lastPhasePersistence = curPhasePersistence;
}
void testApp::getBounds(ofxPoint3f& min, ofxPoint3f& max) {
bool* mask = threePhase->getMask();
float* depth = threePhase->getDepth();
int srcWidth = threePhase->getWidth();
int srcHeight = threePhase->getHeight();
min.set(srcWidth, srcHeight, panel.getValueF("filterMax"));
max.set(0, 0, panel.getValueF("filterMin"));
int i = 0;
for (int y = 0; y < srcHeight; y++) {
for (int x = 0; x < srcWidth; x++) {
if (!mask[i]) {
if (x < min.x)
min.x = x;
if (x > max.x)
max.x = x;
if (y < min.y)
min.y = y;
if (y > max.y)
max.y = y;
if (depth[i] < min.z)
min.z = depth[i];
if (depth[i] > max.z)
max.z = depth[i];
}
i++;
}
}
}
void testApp::boxOutline(ofxPoint3f min, ofxPoint3f max) {
ofPushMatrix();
ofTranslate(min.x, min.y, min.z);
ofScale(max.x - min.x, max.y - min.y, max.z - min.z);
glBegin(GL_LINES);
// back
glVertex3s(0, 0, 0);
glVertex3s(1, 0, 0);
glVertex3s(0, 0, 0);
glVertex3s(0, 1, 0);
glVertex3s(1, 1, 0);
glVertex3s(1, 0, 0);
glVertex3s(1, 1, 0);
glVertex3s(0, 1, 0);
// front
glVertex3s(0, 0, 1);
glVertex3s(1, 0, 1);
glVertex3s(0, 0, 1);
glVertex3s(0, 1, 1);
glVertex3s(1, 1, 1);
glVertex3s(1, 0, 1);
glVertex3s(1, 1, 1);
glVertex3s(0, 1, 1);
// extrusion
glVertex3s(0, 0, 0);
glVertex3s(0, 0, 1);
glVertex3s(0, 1, 0);
glVertex3s(0, 1, 1);
glVertex3s(1, 0, 0);
glVertex3s(1, 0, 1);
glVertex3s(1, 1, 0);
glVertex3s(1, 1, 1);
glEnd();
ofPopMatrix();
}
void testApp::drawAxes(float size) {
ofPushMatrix();
ofScale(size, size, size);
ofPushStyle();
ofSetLineWidth(2.0);
ofSetColor(255, 0, 0);
glBegin(GL_LINES);
glVertex3s(0, 0, 0);
glVertex3s(1, 0, 0);
glEnd();
ofSetColor(0, 255, 0);
glBegin(GL_LINES);
glVertex3s(0, 0, 0);
glVertex3s(0, 1, 0);
glEnd();
ofSetColor(0, 0, 255);
glBegin(GL_LINES);
glVertex3s(0, 0, 0);
glVertex3s(0, 0, 1);
glEnd();
ofPopStyle();
ofPopMatrix();
}
void testApp::draw() {
if (hidden)
ofBackground(0, 0, 0);
else
ofBackground(128, 128, 128);
glPushMatrix();
camera.place();
glEnable(GL_DEPTH_TEST);
ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2);
if (threePhase != NULL) {
if (!hidden)
drawAxes(256); // major axes
ofTranslate(-threePhase->getWidth() / 2, -threePhase->getHeight() / 2);
if (!hidden) {
ofxPoint3f min, max;
getBounds(min, max);
ofSetColor(255, 255, 255);
boxOutline(min, max);
min.z = panel.getValueF("filterMin");
max.z = panel.getValueF("filterMax");
min -= 4;
max += 4;
ofSetColor(0, 0, 255);
boxOutline(min, max);
}
ofSetColor(255, 255, 255);
int useCloud = panel.getValueI("style");
if (useCloud == 0) {
drawCloud();
} else if (useCloud == 1) {
drawMesh();
}
}
glDisable(GL_DEPTH_TEST);
camera.remove();
if (panel.getValueB("renderMovie") && hidden) {
screenCapture.grabScreen(0, 0, ofGetWidth(), ofGetHeight());
movieOutput.addFrame(screenCapture.getPixels(), 1. / panel.getValueI("movieFramerate"));
}
glPopMatrix();
if ((threePhase != NULL) && panel.getValueB("hud")) {
int srcWidth = threePhase->getWidth();
int srcHeight = threePhase->getHeight();
if (redraw) {
bool* mask = threePhase->getMask();
float* depth = threePhase->getDepth();
byte* color = threePhase->getColor();
float* phase = threePhase->getPhase();
float* wrappedPhase = threePhase->getWrappedPhase();
float* range = threePhase->getRange();
float* unwrapOrder = threePhase->unwrapOrder;
unsigned char* upix = phaseUnwrapped.getPixels();
unsigned char* ppix = phaseWrapped.getPixels();
unsigned char* rpix = rangeIm.getPixels();
unsigned char* opix = unwrapOrderIm.getPixels();
unsigned char* dpix = depthIm.getPixels();
///float minPhase = threePhase->minPhase;
///float maxPhase = threePhase->maxPhase;
float minPhase = -panel.getValueF("maxPhase");
float maxPhase = -minPhase;
// threePhase->minDepth,threePhase->maxDepth
float maxDepth = pow(10, panel.getValueF("maxDepth"));
float minDepth = -maxDepth;
int i = 0;
for (int y = 0; y < srcHeight; y++) {
for (int x = 0; x < srcWidth; x++) {
ppix[i] = (char) ofMap(wrappedPhase[i],
0, 1,
0, 255);
rpix[i] = (char) range[i];
float mag;
ofColor col;
if (!mask[i]) {
mag = ofMap(phase[i], minPhase, maxPhase, 0.0, 1.0);
} else {
mag = 0.5;
}
col = makeColor(mag);
upix[i*3] = (char)col.r;
upix[i*3+1] = (char)col.g;
upix[i*3+2] = (char)col.b;
mag = 1.0 - ofMap(depth[i], minDepth, maxDepth, 0.0, 1.0);
col = makeColor(mag);
dpix[i*3] = (short) col.r;
dpix[i*3+1] = (short) col.g;
dpix[i*3+2] = (short) col.b;
mag = unwrapOrder[i] / (float)(srcWidth * srcHeight);
col = makeColor(mag);
opix[i*3] = (short) col.r;
opix[i*3+1] = (short) col.g;
opix[i*3+2] = (short) col.b;
i++;
}
}
phaseUnwrapped.update();
phaseWrapped.update();
rangeIm.update();
unwrapOrderIm.update();
depthIm.update();
}
int w = (int)panel.getValueF("hudWidth");
float hOff = panel.getValueF("hudHeightOffset");
ofSetColor(255, 255, 255);
glColor3f(1, 1, 1);
float sc = (float)srcHeight / (float)srcWidth;
hOff *= -2 * w * sc;
phaseUnwrapped.getTextureReference().draw(ofGetWidth() - w, hOff + 0*w*sc, w, w*sc);
depthIm.getTextureReference().draw(ofGetWidth() - w, hOff + 1*w*sc, w, w*sc);
rangeIm.getTextureReference().draw(ofGetWidth() - w, hOff + 2*w*sc, w, w*sc);
unwrapOrderIm.getTextureReference().draw(ofGetWidth() - 2*w, hOff + 0*w*sc, w, w*sc);
phaseWrapped.getTextureReference().draw(ofGetWidth() - 2*w, hOff + 1*w*sc, w, w*sc);
}
}
void testApp::keyPressed(int key) {
if (key == 'f')
ofToggleFullscreen();
if (key == '\t') {
hidden = !hidden;
panel.hidden = hidden;
if (panel.getValueB("renderMovie")) {
if (hidden) {
screenCapture.allocate(ofGetWidth(), ofGetHeight(), OF_IMAGE_COLOR);
movieOutput.setup(ofGetWidth(), ofGetHeight(), "output/" + ofToString(ofGetFrameNum()) + ".mov");
} else {
movieOutput.finishMovie();
}
}
}
}
const unsigned char testApp::scol[8][3] = {{255, 255, 255},
{255, 0, 0}, /// red is the warmest
{255, 255, 0},
{0, 255, 0},
{0, 255, 255},
{0, 0, 255},/// blue is the coolest, but purple comes later
{255, 0, 255},
{0, 0, 0}
};
ofColor testApp::makeColor(float f) {
/// or wrap around?
if (f > 1.0) f = 1.0;
if (f < 0.0) f = 0.0;
int i1 = 0;
int i2 = 1;
f = f * (8 - 1);
while (f > 1.0) {
f -= 1.0;
i1++;
i2++;
}
int r = int((1.0 - f) * (float)scol[i1][0] + f * (float)scol[i2][0]);
int g = int((1.0 - f) * (float)scol[i1][1] + f * (float)scol[i2][1]);
int b = int((1.0 - f) * (float)scol[i1][2] + f * (float)scol[i2][2]);
ofColor rv;
rv.r = r;
rv.g = g;
rv.b = b;
return rv;
}
|
e26166a5e1645f5e2024b6a8fb7a0fd00e258b63 | 7ae77f663c1015cc476ceda3f2e8eca906de5f12 | /ExampleMod/Source/ModdingExample/MainWeapon.cpp | cf36fb34ecb2e6aaab31777be3656154504624b3 | [] | no_license | zbx911/Ue4-Modding-Example-project | aa9d3733fa4dc3682534a6cafe9648321253d8f7 | cb5fb9b3fc10f6731d61eea5c046e313db7639fd | refs/heads/master | 2022-12-23T22:25:59.238328 | 2020-10-06T03:25:48 | 2020-10-06T03:25:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 515 | cpp | MainWeapon.cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "MainWeapon.h"
// Sets default values
AMainWeapon::AMainWeapon()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void AMainWeapon::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AMainWeapon::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
|
bf9f4268ae4659f9315ddfea211fc11ea2f535e9 | 09866ba376f9aa53ab6d129e2ff4f89076664c6d | /Source/RTSProject/Plugins/DaedalicTestAutomationPlugin/Source/DaedalicTestAutomationPlugin/Public/DaeTestSuiteActor.h | cf52c2d5ff15adaaa7bd67d5b99ff3f66821ec9b | [
"MIT"
] | permissive | JaredP94/ue4-rts | c05dee7f6b94fbed6343b0b04df8d921421f9cee | 242aa314ea8a4ac4145af214399d2ecb6c25234c | refs/heads/develop | 2021-05-17T22:53:11.999359 | 2020-12-20T19:48:54 | 2020-12-20T19:48:54 | 250,988,884 | 1 | 1 | MIT | 2020-12-20T19:48:55 | 2020-03-29T08:45:49 | C++ | UTF-8 | C++ | false | false | 3,849 | h | DaeTestSuiteActor.h | #pragma once
#include "DaeTestSuiteResult.h"
#include <CoreMinimal.h>
#include <GameFramework/Actor.h>
#include "DaeTestSuiteActor.generated.h"
class ADaeTestActor;
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDaeTestSuiteActorTestSuiteSuccessfulSignature,
ADaeTestSuiteActor*, TestSuite);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDaeTestSuiteActorTestSuiteFailedSignature,
ADaeTestSuiteActor*, TestSuite);
/** Collection of automated tests. */
UCLASS()
class DAEDALICTESTAUTOMATIONPLUGIN_API ADaeTestSuiteActor : public AActor
{
GENERATED_BODY()
public:
ADaeTestSuiteActor(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
virtual void BeginPlay() override;
virtual void Tick(float DeltaSeconds) override;
/** Runs all tests of this suite, in order. */
void RunAllTests();
/** Whether this test suite is currently running. */
bool IsRunning() const;
/** Gets the test that is currently running. */
ADaeTestActor* GetCurrentTest() const;
/** Gets the parameter for the current test run. */
UObject* GetCurrentTestParameter() const;
/** Gets the name of the current test. */
FString GetCurrentTestName() const;
/** Results of the whole test suite. */
FDaeTestSuiteResult GetResult() const;
/** Event when this test suite should set up. */
virtual void NotifyOnBeforeAll();
/** Event when this test suite has finished all tests. */
virtual void NotifyOnAfterAll();
/** Event when this test suite should set up for the next test. */
virtual void NotifyOnBeforeEach();
/** Event when this test suite should has finished a test. */
virtual void NotifyOnAfterEach();
/** Event when this test suite should set up. This is NOT a latent event. */
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "BeforeAll"))
void ReceiveOnBeforeAll();
/** Event when this test suite has finished all tests. This is NOT a latent event. */
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "AfterAll"))
void ReceiveOnAfterAll();
/** Event when this test suite should set up for the next test. This is NOT a latent event. */
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "BeforeEach"))
void ReceiveOnBeforeEach();
/** Event when this test suite should has finished a test. This is NOT a latent event. */
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "AfterEach"))
void ReceiveOnAfterEach();
/** Event when this test suite has successfully finished all tests. */
FDaeTestSuiteActorTestSuiteSuccessfulSignature OnTestSuiteSuccessful;
/** Event when any tests of this test suite have failed. */
FDaeTestSuiteActorTestSuiteFailedSignature OnTestSuiteFailed;
private:
/** Tests to run in this level. */
UPROPERTY(EditInstanceOnly)
TArray<ADaeTestActor*> Tests;
/** Whether to automatically run this test suite on BeginPlay in Play In Editor. */
UPROPERTY(EditInstanceOnly)
bool bRunInPIE;
/** Index of the current test. */
int32 TestIndex;
/** Index of the current parameter the current test is run with. */
int32 TestParameterIndex;
/** Time the current test has been running, in seconds. */
float TestTimeSeconds;
/** Results of the whole test suite. */
FDaeTestSuiteResult Result;
/** Runs the next test in this test suite. */
void RunNextTest();
UFUNCTION()
void OnTestSuccessful(ADaeTestActor* Test, UObject* Parameter);
UFUNCTION()
void OnTestFailed(ADaeTestActor* Test, UObject* Parameter, const FString& FailureMessage);
UFUNCTION()
void OnTestSkipped(ADaeTestActor* Test, UObject* Parameter, const FString& SkipReason);
};
|
d84e01006fc1962f6c35d7f82e998122e5963b42 | bb5964b979ec9444086a74540aaab44cc64a090d | /work/okeyLib/Template/MathTemplate.h | 16492f2789c403b71a5ca23a94b5034ded62e88c | [] | no_license | okey19841106/okey | d5942c1c86245dc022d43c31b14e902bb84ecc41 | 6fefb1d32836ae637c9f92e963136d0bf17ceb19 | refs/heads/master | 2021-01-20T21:53:06.536700 | 2016-01-25T06:51:09 | 2016-01-25T06:51:09 | 17,868,610 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 3,317 | h | MathTemplate.h | /********************************************************************
created: 2012/12/12
created: 12-12-2012 23:37
author: okey
purpose: math template
*********************************************************************/
#include "Types.h"
namespace Template
{
template< uint32 N >
struct Fib
{
enum
{
Val = Fib< N - 1 >::Val + Fib< N - 2 >::Val
};
};
template<> struct Fib< 0 >{enum{Val = 0};};
template<> struct Fib< 1 >{enum{Val = 1};};
#define FibT(n) Fib< n >::Val //斐波纳契函数
template< uint32 N >
struct Fact
{
enum{ Val = N * Fact< N - 1>::Val};
};
template<> struct Fact< 1 > {enum{ Val = 1 }; };
#define FactT(n) Fact< n >::Val //阶乘
template< f64& r, int i, int max>
struct Series
{
enum
{
// Continue is true until we've evaluated M terms
Continue = i + 1 != max,
NxtI = ( i + 1 ) * Continue,
NxtMaxTerms = max * Continue
};
static inline double val()
{
return 1 - r * r / (2.0 * i + 2.0) /
(2.0 * i + 3.0) * Series< r * Continue, NxtI, NxtMaxTerms >::val();
}
};
template<f64& r>
struct Sine
{
enum{MaxTerms = 10;};
static inline f64 sin()
{
return r * Series< r, 0 , MaxTerms>::val();
}
};
template <> struct Series< 0.0, 0, 0 >
{
static inline double val() { return 1.0; }
};
#define SineT( r ) Sine< r >::sin() // 正弦函数。
template < double& R > struct NrSine
{
// All values known at compile time.
// A decent compiler should be able to reduce to a single constant.
static inline double sin()
{
double Rsqr = R * R;
return R * ( 1.0 - Rsqr / 2.0 / 3.0
* ( 1.0 - Rsqr / 4.0 / 5.0
* ( 1.0 - Rsqr / 6.0 / 7.0
* ( 1.0 - Rsqr / 8.0 / 9.0
* ( 1.0 - Rsqr / 10.0 / 11.0
* ( 1.0 - Rsqr / 12.0 / 13.0
* ( 1.0 - Rsqr / 14.0 / 15.0
* ( 1.0 - Rsqr / 16.0 / 17.0
* ( 1.0 - Rsqr / 18.0 / 19.0
* ( 1.0 - Rsqr / 20.0 / 21.0
) ) ) ) ) ) ) ) ) );
}
};
// Make the template appear like a function
#define SineN( r ) NrSine< r >::sin() //非递归正弦函数。
template < double& R > struct NrCos
{
// All values known at compile time.
// A decent compiler should be able to reduce to a single constant.
static inline double cos()
{
double Rsqr = R * R;
return ( 1.0 - Rsqr / 2.0
* ( 1.0 - Rsqr / 3.0 / 4.0
* ( 1.0 - Rsqr / 5.0 / 6.0
* ( 1.0 - Rsqr / 7.0 / 8.0
* ( 1.0 - Rsqr / 9.0 / 10.0
* ( 1.0 - Rsqr / 11.0 / 12.0
* ( 1.0 - Rsqr / 13.0 / 14.0
* ( 1.0 - Rsqr / 15.0 / 16.0
* ( 1.0 - Rsqr / 17.0 / 18.0
* ( 1.0 - Rsqr / 19.0 / 20.0
* ( 1.0 - Rsqr / 21.0 / 22.0
) ) ) ) ) ) ) ) ) ) );
}
};
// Make the template appear like a function
#define CosN( r ) NrCos< r >::cos() //非递归余弦函数
///////////////////////////////////////////////////////////////////////////////
//
// Nonrecursive Tangent
// Series expansion for tan( R ).
// For conforming compilers, change double R to double& R
template < double& R > struct NrTan
{
// All values known at compile time.
// A decent compiler should be able to reduce to a single constant.
static inline double tan()
{
return NrSine< R >::sin() / NrCos< R >::cos();
}
};
// Make the template appear like a function
#define TanN( r ) NrTan< r >::tan() //非递归正切函数
} |
53ab075461b027d0f8588cbad5348b9196decc20 | ac60f11a8feee9ee845a116cc2d0266582cb6736 | /CubeSlicing.cpp | aab186743c1b61df3fcf0d4778f72f5da5565326 | [] | no_license | kometes77/gom | 51dd54d3f66d33ced61fb7c12b1f1c7960fd987a | 2c87f34b905e17d76fa78edb1d5d0a669534eb7c | refs/heads/master | 2020-07-20T14:47:05.876130 | 2011-04-11T15:01:49 | 2011-04-11T15:01:49 | 1,591,245 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 995 | cpp | CubeSlicing.cpp | #include<stdio.h>
#include<cv.h>
#include<cxcore.h>
#include<highgui.h>
#include "roadviewSlice.h"
#include "CubeSlicing.h"
namespace roadview {
void CubeSlicing::generateTiles(string strFilename, SliceInfo& sliceInfo) {
IplImage *inputImage = 0;
inputImage = cvLoadImage(strFilename.c_str(),CV_LOAD_IMAGE_UNCHANGED);
IplImage *image1024 = cvCreateImage( cvSize(sliceInfo.faceSize,sliceInfo.faceSize), inputImage->depth, inputImage->nChannels );
cvResize( (void*)inputImage, (void*)image1024, CV_INTER_CUBIC );
char outputFilename[100];
int x,y;
for(y=0;y<4;++y) {
for(x=0;x<4;++x) {
cvSetImageROI( image1024,cvRect(x*CUBE_L1_TILE_SIZE,y*CUBE_L1_TILE_SIZE,CUBE_L1_TILE_SIZE,CUBE_L1_TILE_SIZE) );
sprintf(outputFilename,"%s_%d_%d.jpg",sliceInfo.prefix,y,x);
cvSaveImage(outputFilename, image1024 );
}
}
cvResetImageROI( image1024 );
cvReleaseImage( &inputImage );
cvReleaseImage( &image1024 );
}
}//namespace
|
afb979b8b427abc23d2d920b3bdab89dfe95d21c | 6ea9796da14f3ee7880d04a51c6bff25713b3206 | /hackerrank/contests/week14-challenge/subtrees-and-paths/main.cc | c3fac0239b23e3f9ab81845181c0cca6dd098755 | [] | no_license | vguerra/programming_contests | 79def4d0a864811a48038b270cebda3fbdc0f000 | 025b064ae0675f015e61cb3066d099b814cd3871 | refs/heads/master | 2021-01-22T11:36:30.364021 | 2015-03-30T19:28:25 | 2015-03-30T19:28:25 | 25,770,826 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,400 | cc | main.cc | // Victor Guerra <vguerra@gmail.com>
// 20150313
// https://www.hackerrank.com/contests/w14/challenges/subtrees-and-paths
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <string>
#include <queue>
#include <stack>
int main() {
uint32_t N, Q;
std::cin >> N;
std::vector<int64_t> values(N + 1, 0);
std::vector<std::vector<uint32_t>> adj_list(N + 1, std::vector<uint32_t>());
std::vector<std::vector<uint32_t>> tree_adj_list(N + 1, std::vector<uint32_t>());
std::vector<uint32_t> parents(N + 1, 0);
std::vector<bool> visited(N + 1, false);
while (N-- - 1) {
uint32_t l, r;
std::cin >> l >> r;
adj_list[l].push_back(r);
adj_list[r].push_back(l);
}
// get info about all possibe paths from root.
std::queue<uint32_t> q;
parents[1] = 0;
q.push(1);
visited[1] = true;
while (!q.empty()) {
uint32_t v = q.front();
q.pop();
for (auto const& w : adj_list[v]) {
if (!visited[w]) {
q.push(w);
visited[w] = true;
parents[w] = v;
tree_adj_list[v].push_back(w);
}
}
}
std::cin >> Q;
while (Q--) {
std::string action;
std::cin >> action;
int64_t l, r;
std::cin >> l >> r;
if (action == "add") {
std::queue<uint32_t> pq;
pq.push(l);
while (!pq.empty()) {
uint32_t n = pq.front();
pq.pop();
values[n] += r;
for (const auto& m : tree_adj_list[n]) {
pq.push(m);
}
}
} else {
std::stack<uint32_t> left_stack;
std::stack<uint32_t> right_stack;
while (l != 0) {
left_stack.push(l);
l = parents[l];
}
while (r != 0) {
right_stack.push(r);
r = parents[r];
}
uint32_t common_parent = 0;
while (!left_stack.empty() && !right_stack.empty() && left_stack.top() == right_stack.top()) {
common_parent = left_stack.top();
left_stack.pop();
right_stack.pop();
}
int64_t max_value = values[common_parent];
while (!left_stack.empty()) {
max_value = std::max(max_value, values[left_stack.top()]);
left_stack.pop();
}
while (!right_stack.empty()) {
max_value = std::max(max_value, values[right_stack.top()]);
right_stack.pop();
}
std::cout << max_value << "\n";
}
}
return EXIT_SUCCESS;
}
|
be72396e6cad4fc2869a7ebe59c19af211586c8a | 221e73c8ffe152d7117b2f9c7aaa0faaf7c533f8 | /code/20.cpp | 2b04e3283a0b2e72a453e1444e5c2785fa1a20c9 | [] | no_license | gd2dg/pat-basic | 8c673d2a151d3587e48f31d2fff63b8211b2da4f | df391e0b7c903a09813bcd0aef75315213528b01 | refs/heads/master | 2022-05-11T17:01:35.746650 | 2017-07-17T05:15:29 | 2017-07-17T05:15:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,013 | cpp | 20.cpp | //C/C++实现
#include <iostream>
#include <algorithm>
#include <iomanip>
bool compare(double* a,double* b)
{
return a[2]>b[2];
}
double getMaxEarnings(){
int n,need;
std::cin>>n>>need;
double **cargo=new double*[n];
for(int i=0;i<n;i++)
cargo[i]=new double[3];
for(int i=0;i<n;i++)
std::cin>>cargo[i][0];
for(int i=0;i<n;i++)
{
std::cin>>cargo[i][1];
cargo[i][2]=cargo[i][1]/cargo[i][0];
}
std::sort(cargo,cargo+n,compare);
// for(int i=0;i<n;i++)
// {
// for(int j=0;j<3;j++)
// {
// std::cout<<cargo[i][j]<<" ";
// }
// std::cout<<std::endl;
// }
double j=need;
double income=0;
for(int i=0;i<n;i++)
{
double r=cargo[i][0];
double unitprice=cargo[i][2];
if(r<=j)
{
income+=cargo[i][1];
j-=r;
if(j<=0)break;
}
else{
income+=unitprice*j;
break;
}
}
std::cout<< std::fixed << std::setprecision(2)<<income<<std::endl;
for(int i=0;i<n;i++)
delete cargo[i];
delete [] cargo;
return income;
}
// int main(){
// getMaxEarnings();
// } |
f35cc97d18f652fb2728ebae403952a5edd42c2d | faf6ee9a095b05a05472ea57f93d9c640fd58620 | /GameEngine/SpRendering/MeshBufferColor.cpp | 2b48df6a0ec0fd1047ac2bd4252bbc3812db206a | [] | no_license | qbzjs/MyToy | 5c2a72fd53f05f2e7ca6eb7906c7bb8b3e7d4306 | 3bd78c6700028e07348b29fc9538be1b606e7c62 | refs/heads/master | 2022-10-12T14:11:01.228946 | 2018-09-30T10:30:56 | 2018-09-30T10:30:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 709 | cpp | MeshBufferColor.cpp | #include "MeshBufferColor.h"
USING_NAMESPACE_ENGINE;
MeshBufferColor::MeshBufferColor() : MeshBuffer(), m_VboColorHandle(0)
{
}
MeshBufferColor::~MeshBufferColor()
{
DeleteBufer(&m_VboColorHandle);
}
MeshBufferColor::MeshBufferColor(MeshPtr mesh) : MeshBuffer(mesh), m_VboColorHandle(0)
{
MakeColorBuffer(mesh->m_Colors, mesh->m_VertexCount);
}
void MeshBufferColor::MakeColorBuffer(const Color* colors, int size)
{
BindBuffer();
MakeVertexBuffer(&m_VboColorHandle, sizeof(Color) * size, 4, colors, ATTR_POS_COLOR, EBufferUsage::StaticDraw);
UnbindBuffer();
}
void MeshBufferColor::MakeBuffer(MeshPtr mesh)
{
MeshBuffer::MakeBuffer(mesh);
MakeColorBuffer(mesh->m_Colors, mesh->m_VertexCount);
}
|
20bf3d08c8b71474854c6d7c40252735440773e3 | 1791461e6740f81c2dd6704ae6a899a6707ee6b1 | /HSAHRBNUOJ/P19xx/P1963.cpp | 2d9cf29c07029090a5190757a767c1e80d117502 | [
"MIT"
] | permissive | HeRaNO/OI-ICPC-Codes | b12569caa94828c4bedda99d88303eb6344f5d6e | 4f542bb921914abd4e2ee7e17d8d93c1c91495e4 | refs/heads/master | 2023-08-06T10:46:32.714133 | 2023-07-26T08:10:44 | 2023-07-26T08:10:44 | 163,658,110 | 22 | 6 | null | null | null | null | UTF-8 | C++ | false | false | 1,009 | cpp | P1963.cpp | #include <iostream>
#include <cmath>
using namespace std;
bool zhishu(int a)
{
long b, i;
double c;
c = sqrt(a);
b = floor(c);
for (i = 2; i <= b; i++)
if (a % i == 0)
return 0;
return 1;
}
int hwlen(int a)
{
int k = 1, i = 1;
while (1)
{
k *= 10;
if (a < k) break;
i++;
}
return i;
}
int huiwen(int k)
{
int a[10], i = 0, j;
while (k > 0)
{
a[i] = k % 10;
k /= 10;
i++;
}
for (j = 0; j < i; j++)
if (a[j] != a[i - j - 1])
return 0;
return 1;
}
int extend(int k)
{
int i, ans = 1;
for (i = 1; i <= k; i++) ans *= 10;
return ans;
}
int main()
{
long long a, b, i;
cin >> a >> b;
for (i = a; i <= b; i++)
{
if (i == 1) continue;
if (i == 10) continue;
if (hwlen(i) % 2 == 0 && i != 11)
{
i = extend(hwlen(i));
continue;
}
else if (i % 2 == 0 && i != 2) continue;
else if (i % 3 == 0 && i != 3) continue;
else
{
if (!huiwen(i)) continue;
else
{
if (!zhishu(i)) continue;
else cout << i << endl;
}
}
}
return 0;
}
|
26c544f78ca8e58d3d164a6759c6e7a60ad4d517 | 967482ce7998d8814a13d8509db947b0df31f8e0 | /src/lib/eng/shl/Superset.cpp | e0dbf715da7fa14812b80adb5fc283833db53f8a | [] | no_license | loongarch64/afnix | 38dc9c9808f18ff5517f7c43f641057a9583aeda | 88cc629cc09086cda707e5ad6d8a1bd412491bbe | refs/heads/main | 2023-05-31T17:16:56.743466 | 2021-06-22T05:18:32 | 2021-06-22T05:18:32 | 379,150,535 | 0 | 0 | null | 2021-06-25T03:05:27 | 2021-06-22T05:20:29 | C++ | UTF-8 | C++ | false | false | 3,388 | cpp | Superset.cpp | // ---------------------------------------------------------------------------
// - Superset.cpp -
// - afnix engine - superset class implementation -
// ---------------------------------------------------------------------------
// - This program is free software; you can redistribute it and/or modify -
// - it provided that this copyright notice is kept intact. -
// - -
// - 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. In no event shall -
// - the copyright holder be liable for any direct, indirect, incidental or -
// - special damages arising in any way out of the use of this software. -
// ---------------------------------------------------------------------------
// - copyright (c) 1999-2021 amaury darsch -
// ---------------------------------------------------------------------------
#include "Superset.hpp"
#include "Exception.hpp"
namespace afnix {
// -------------------------------------------------------------------------
// - class section -
// -------------------------------------------------------------------------
// create a default superset
Superset::Superset (void) {
d_glst.reset ();
}
// destroy this superset
Superset::~Superset (void) {
reset ();
}
// return the class name
String Superset::repr (void) const {
return "Superset";
}
// reset this super set
void Superset::reset (void) {
wrlock ();
try {
// reset all registered nameset
long size = length ();
for (long i = 0; i < size; i++) {
Nameset* nset = getset (i);
if (nset != nullptr) nset->reset ();
}
// reset the globalset
Globalset::reset ();
unlock ();
} catch (...) {
unlock ();
throw;
}
}
// return the size of the superset
long Superset::length (void) const {
rdlock ();
try {
long result = d_glst.length ();
unlock ();
return result;
} catch (...) {
unlock ();
throw;
}
}
// return a nameset by index
Nameset* Superset::getset (const long index) const {
rdlock ();
try {
// get the nameset
Object* obj = d_glst.get (index);
Nameset* nset = dynamic_cast <Nameset*> (obj);
if (nset == nullptr) {
throw Exception ("superset-error", "cannot find nameset by index");
}
unlock ();
return nset;
} catch (...) {
unlock ();
throw;
}
}
// create a nameset by quark and register it
Nameset* Superset::mknset (const long quark) {
wrlock ();
if (exists (quark) == true) {
Nameset* nset = getnset (quark);
unlock ();
return nset;
}
try {
Nameset* result = Nameset::mknset (quark);
d_glst.add (result);
unlock ();
return result;
} catch (...) {
unlock ();
throw;
}
}
// create a nameset by name and register it
Nameset* Superset::mknset (const String& name) {
return mknset (name.toquark ());
}
}
|
a42ff1fa4141ae2a42bcfa0537e1eb53983eb81e | 57fdbe8027cffd94cb932f22aa115ce863819de5 | /Arrays/Source.cpp | f97112a5e193b396e5b2135f6533e753f38fc4fa | [] | no_license | KateKrechet/FUNCTIONS | 8d2c2a4d33fd22b3537fdae4f1b941ced7c6c076 | dac8c17408c30f425ace6bccb18a1f2e28006fdb | refs/heads/master | 2023-07-06T02:05:27.234149 | 2021-08-03T17:34:49 | 2021-08-03T17:34:49 | 390,126,619 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,594 | cpp | Source.cpp | #include<iostream>
using namespace std;
#define line "------------------------------------------------------------------------------------------------";
const int ROWS = 3;
const int COLS = 8;
void FillRand(int arr[], const int n);
void FillRand(short arr[], const int n);
void FillRand(float arr[], const int n);
void FillRand(double arr[], const int n);
void FillRand(char arr[], const int n);
void FillRand(int arr[ROWS][COLS], const int ROWS, const int COLS);//прототип перегруженной функции
void PrintRand(int arr[], const int n);
void PrintRand(short arr[], const int n);
void PrintRand(float arr[], const int n);
void PrintRand(double arr[], const int n);
void PrintRand(char arr[], const int n);
void PrintRand(int arr[ROWS][COLS], const int ROWS, const int COLS);
void SortRand(int arr[], const int n);
void SortRand(short arr[], const int n);
void SortRand(float arr[], const int n);
void SortRand(double arr[], const int n);
int Sum(int arr[], const int n);
short Sum(short arr[], const int n);
float Sum(float arr[], const int n);
double Sum(double arr[], const int n);
double Avg(int arr[], const int n);
double Avg(short arr[], const int n);
float Avg(float arr[], const int n);
double Avg(double arr[], const int n);
int minValue(int arr[], const int n);
short minValue(short arr[], const int n);
float minValue(float arr[], const int n);
double minValue(double arr[], const int n);
int maxValue(int arr[], const int n);
short maxValue(short arr[], const int n);
float maxValue(float arr[], const int n);
double maxValue(double arr[], const int n);
void ShiftLeft(int arr[], const int n, int move);
void ShiftLeft(short arr[], const int n, int move);
void ShiftLeft(float arr[], const int n, int move);
void ShiftLeft(double arr[], const int n, int move);
void ShiftLeft(char arr[], const int n, int move);
void ShiftRight(int arr[], const int n, int move);
void ShiftRight(short arr[], const int n, int move);
void ShiftRight(float arr[], const int n, int move);
void ShiftRight(double arr[], const int n, int move);
void ShiftRight(char arr[], const int n, int move);
//#define HOME_WORK
void main()
{
setlocale(LC_ALL, "Russian");
#ifdef HOME_WORK
int move = 0;
cout << "Short" << endl << line;
cout << endl;
const int n_1 = 5;
short arr_1[n_1];
FillRand(arr_1, n_1);
PrintRand(arr_1, n_1);
PrintRand(arr_1, n_1);
cout << "Сумма элементов массива: " << Sum(arr_1, n_1) << endl;
cout << "Среднее арифметическое элементов массива: " << Avg(arr_1, n_1) << endl;
cout << "Минимальное значение элементов массива: " << minValue(arr_1, n_1) << endl;
cout << "Максимальное значение элементов массива: " << maxValue(arr_1, n_1) << endl;
cout << "Введите на сколько позиций необходимо осуществить сдвиг влево: "; cin >> move;
ShiftLeft(arr_1, n_1, move);
PrintRand(arr_1, n_1);
cout << "Введите на сколько позиций необходимо осуществить сдвиг вправо: "; cin >> move;
ShiftRight(arr_1, n_1, move);
PrintRand(arr_1, n_1);
cout << endl;
cout << "Integer" << endl << line;
cout << endl;
const int n = 5;
int arr[n];
FillRand(arr, n);
PrintRand(arr, n);
PrintRand(arr, n);
cout << "Сумма элементов массива: " << Sum(arr, n) << endl;
cout << "Среднее арифметическое элементов массива: " << Avg(arr, n) << endl;
cout << "Минимальное значение элементов массива: " << minValue(arr, n) << endl;
cout << "Максимальное значение элементов массива: " << maxValue(arr, n) << endl;
cout << "Введите на сколько позиций необходимо осуществить сдвиг влево: "; cin >> move;
ShiftLeft(arr, n, move);
PrintRand(arr, n);
cout << "Введите на сколько позиций необходимо осуществить сдвиг вправо: "; cin >> move;
ShiftRight(arr, n, move);
PrintRand(arr, n);
cout << endl;
cout << "Float" << endl << line;
cout << endl;
const int SIZE_1 = 5;
double crr[SIZE_1];
FillRand(crr, SIZE_1);
PrintRand(crr, SIZE_1);
SortRand(crr, SIZE_1);
PrintRand(crr, SIZE_1);
cout << "Сумма элементов массива: " << Sum(crr, SIZE_1) << endl;
cout << "Среднее арифметическое элементов массива: " << Avg(crr, SIZE_1) << endl;
cout << "Минимальное значение элементов массива: " << minValue(crr, SIZE_1) << endl;
cout << "Максимальное значение элементов массива: " << maxValue(crr, SIZE_1) << endl;
cout << "Введите на сколько позиций необходимо осуществить сдвиг влево: "; cin >> move;
ShiftLeft(crr, SIZE_1, move);
PrintRand(crr, SIZE_1);
cout << "Введите на сколько позиций необходимо осуществить сдвиг вправо: "; cin >> move;
ShiftRight(crr, SIZE_1, move);
PrintRand(crr, SIZE_1);
cout << endl;
cout << "Double" << endl << line;
cout << endl;
const int SIZE = 5;
double brr[SIZE];
FillRand(brr, SIZE);
PrintRand(brr, SIZE);
SortRand(brr, SIZE);
PrintRand(brr, SIZE);
cout << "Сумма элементов массива: " << Sum(brr, SIZE) << endl;
cout << "Среднее арифметическое элементов массива: " << Avg(brr, SIZE) << endl;
cout << "Минимальное значение элементов массива: " << minValue(brr, SIZE) << endl;
cout << "Максимальное значение элементов массива: " << maxValue(brr, SIZE) << endl;
cout << "Введите на сколько позиций необходимо осуществить сдвиг влево: "; cin >> move;
ShiftLeft(brr, SIZE, move);
PrintRand(brr, SIZE);
cout << "Введите на сколько позиций необходимо осуществить сдвиг вправо: "; cin >> move;
ShiftRight(brr, SIZE, move);
PrintRand(brr, SIZE);
cout << endl;
cout << "Char" << endl << line;
cout << endl;
const int m = 5;
char drr[m];
FillRand(drr, m);
PrintRand(drr, m);
cout << "Введите на сколько позиций необходимо осуществить сдвиг влево: "; cin >> move;
ShiftLeft(drr, m, move);
PrintRand(drr, m);
cout << "Введите на сколько позиций необходимо осуществить сдвиг вправо: "; cin >> move;
ShiftRight(drr, m, move);
PrintRand(drr, m);
cout << endl;
#endif // HOME_WORK
int i_arr_2[ROWS][COLS];
FillRand(i_arr_2, ROWS, COLS);
PrintRand(i_arr_2, ROWS, COLS);
}
void FillRand(short arr[], const int n)
{
//формирование массива
for (int i = 0; i < n; i++)
{
arr[i] = rand() % 100;
}
}
void FillRand(int arr[], const int n)
{
//формирование массива
for (int i = 0; i < n; i++)
{
arr[i] = rand() % 100;
}
}
void FillRand(float arr[], const int n)
{
//формирование массива
for (int i = 0; i < n; i++)
{
arr[i] = float(rand() % 100) / 10;
}
}
void FillRand(double arr[], const int n)
{
//формирование массива
for (int i = 0; i < n; i++)
{
arr[i] = double(rand() % 100) / 10;
}
}
void FillRand(char arr[], const int n)
{
//формирование массива
for (int i = 0; i < n; i++)
{
arr[i] = rand() % 255;
}
}
void FillRand(int arr[ROWS][COLS], const int ROWS, const int COLS)
{
//формирование массива
for (int i = 0; i < ROWS; i++)
{
for (int j = 0; j < COLS; j++)
{
arr[i][j] = rand() % 100;
}
}
}
void PrintRand(short arr[], const int n)
{
//вывод массива
for (int i = 0; i < n; i++)
{
cout << arr[i] << "\t";
}
cout << endl;
}
void PrintRand(int arr[], const int n)
{
//вывод массива
for (int i = 0; i < n; i++)
{
cout << arr[i] << "\t";
}
cout << endl;
}
void PrintRand(float arr[], const int n)
{
//вывод массива
for (int i = 0; i < n; i++)
{
cout << arr[i] << "\t";
}
cout << endl;
}
void PrintRand(double arr[], const int n)
{
//вывод массива
for (int i = 0; i < n; i++)
{
cout << arr[i] << "\t";
}
cout << endl;
}
void PrintRand(char arr[], const int n)
{
//вывод массива
for (int i = 0; i < n; i++)
{
cout << arr[i] << "\t";
}
cout << endl;
}
void PrintRand(int arr[ROWS][COLS], const int ROWS, const int COLS)
{
//вывод массива
for (int i = 0; i < ROWS; i++)
{
for (int j = 0; j < COLS; j++)
{
cout << arr[i][j] << "\t";
}
cout << endl;
}
cout << endl;
}
void SortRand(short arr[], const int n)
{
//сортировка массива
for (int i = 0; i < n; i++)
{
for (int j = i + 1; j < n; j++)
{
if (arr[j] < arr[i])
{
short buffer = arr[i];
arr[i] = arr[j];
arr[j] = buffer;
}
}
}
}
void SortRand(int arr[], const int n)
{
//сортировка массива
for (int i = 0; i < n; i++)
{
for (int j = i + 1; j < n; j++)
{
if (arr[j] < arr[i])
{
int buffer = arr[i];
arr[i] = arr[j];
arr[j] = buffer;
}
}
}
}
void SortRand(float arr[], const int n)
{
//сортировка массива
for (int i = 0; i < n; i++)
{
for (int j = i + 1; j < n; j++)
{
if (arr[j] < arr[i])
{
float buffer = arr[i];
arr[i] = arr[j];
arr[j] = buffer;
}
}
}
}
void SortRand(double arr[], const int n)
{
//сортировка массива
for (int i = 0; i < n; i++)
{
for (int j = i + 1; j < n; j++)
{
if (arr[j] < arr[i])
{
double buffer = arr[i];
arr[i] = arr[j];
arr[j] = buffer;
}
}
}
}
short Sum(short arr[], const int n)
{
short Sum = 0;
for (int i = 0; i < n; i++)
{
Sum = Sum + arr[i];
}
return Sum;
}
int Sum(int arr[], const int n)
{
int Sum = 0;
for (int i = 0; i < n; i++)
{
Sum = Sum + arr[i];
}
return Sum;
}
float Sum(float arr[], const int n)
{
float Sum = 0;
for (int i = 0; i < n; i++)
{
Sum = Sum + arr[i];
}
return Sum;
}
double Sum(double arr[], const int n)
{
double Sum = 0;
for (int i = 0; i < n; i++)
{
Sum = Sum + arr[i];
}
return Sum;
}
double Avg(short arr[], const int n)
{
return (double)Sum(arr, n) / n;
}
double Avg(int arr[], const int n)
{
return (double)Sum(arr, n) / n;
}
float Avg(float arr[], const int n)
{
return Sum(arr, n) / n;
}
double Avg(double arr[], const int n)
{
return Sum(arr, n) / n;
}
short minValue(short arr[], const int n)
{
short minValue = arr[0];
for (int i = 0; i < n; i++)
{
if (arr[i] < minValue) minValue = arr[i];
}
return minValue;
}
int minValue(int arr[], const int n)
{
int minValue = arr[0];
for (int i = 0; i < n; i++)
{
if (arr[i] < minValue) minValue = arr[i];
}
return minValue;
}
float minValue(float arr[], const int n)
{
float minValue = arr[0];
for (int i = 0; i < n; i++)
{
if (arr[i] < minValue) minValue = arr[i];
}
return minValue;
}
double minValue(double arr[], const int n)
{
double minValue = arr[0];
for (int i = 0; i < n; i++)
{
if (arr[i] < minValue) minValue = arr[i];
}
return minValue;
}
short maxValue(short arr[], const int n)
{
short maxValue = arr[0];
for (int i = 0; i < n; i++)
{
if (arr[i] > maxValue) maxValue = arr[i];
}
return maxValue;
}
int maxValue(int arr[], const int n)
{
int maxValue = arr[0];
for (int i = 0; i < n; i++)
{
if (arr[i] > maxValue) maxValue = arr[i];
}
return maxValue;
}
float maxValue(float arr[], const int n)
{
float maxValue = arr[0];
for (int i = 0; i < n; i++)
{
if (arr[i] > maxValue) maxValue = arr[i];
}
return maxValue;
}
double maxValue(double arr[], const int n)
{
double maxValue = arr[0];
for (int i = 0; i < n; i++)
{
if (arr[i] > maxValue) maxValue = arr[i];
}
return maxValue;
}
void ShiftLeft(short arr[], const int n, int move)
{
for (int j = 0; j < move; j++)
{
const short buffer = arr[0];
for (int i = 0; i < n; i++)
{
arr[i] = arr[i + 1];
}
arr[n - 1] = buffer;
}
}
void ShiftLeft(int arr[], const int n, int move)
{
for (int j = 0; j < move; j++)
{
const int buffer = arr[0];
for (int i = 0; i < n; i++)
{
arr[i] = arr[i + 1];
}
arr[n - 1] = buffer;
}
}
void ShiftLeft(float arr[], const int n, int move)
{
for (int j = 0; j < move; j++)
{
const float buffer = arr[0];
for (int i = 0; i < n; i++)
{
arr[i] = arr[i + 1];
}
arr[n - 1] = buffer;
}
}
void ShiftLeft(double arr[], const int n, int move)
{
for (int j = 0; j < move; j++)
{
const double buffer = arr[0];
for (int i = 0; i < n; i++)
{
arr[i] = arr[i + 1];
}
arr[n - 1] = buffer;
}
}
void ShiftLeft(char arr[], const int n, int move)
{
for (int j = 0; j < move; j++)
{
const char buffer = arr[0];
for (int i = 0; i < n; i++)
{
arr[i] = arr[i + 1];
}
arr[n - 1] = buffer;
}
}
void ShiftRight(short arr[], const int n, int move)
{
ShiftLeft(arr, n, n - move);
}
void ShiftRight(int arr[], const int n, int move)
{
ShiftLeft(arr, n, n - move);
}
void ShiftRight(float arr[], const int n, int move)
{
ShiftLeft(arr, n, n - move);
}
void ShiftRight(double arr[], const int n, int move)
{
ShiftLeft(arr, n, n - move);
}
void ShiftRight(char arr[], const int n, int move)
{
ShiftLeft(arr, n, n - move);
}
|
d86f7e03e8da9ed5253108d166fbf722e4e0b7de | 96d3def8e1c9772f04252820f5ffe4059c9f261a | /KinectOptionsDialog.cpp | 0d223dc622bfc3ce8d4924ae93bd6df977faa3ed | [] | no_license | freemancw/PoseDesigner | c4f42f459fe78845f8448d5e3d1c296a334f7989 | bb2a14bbde0c436944ebd4ede7e3c2d24636df1c | refs/heads/master | 2016-08-02T21:41:03.425934 | 2012-03-05T16:09:15 | 2012-03-05T16:09:15 | 2,507,177 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,100 | cpp | KinectOptionsDialog.cpp | /*!
* @file KinectOptionsDialog.cpp
* @author Clinton Freeman
* @date 5/15/2011
*
* This file is primarily updated by the GUI editor.
*/
// local
#include <KinectOptionsDialog.h>
#include <ui_kinectoptionsdialog.h>
#include <KinectInfo.h>
KinectOptionsDialog::KinectOptionsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::KinectOptionsDialog)
{
ui->setupUi(this);
ui->drawBackground->setChecked(kinectInfo.bDrawBackground);
ui->drawSkeleton->setChecked(kinectInfo.bDrawSkeleton);
ui->drawPixels->setChecked(kinectInfo.bDrawPixels);
}
KinectOptionsDialog::~KinectOptionsDialog()
{
delete ui;
}
void KinectOptionsDialog::on_drawBackground_toggled(bool checked)
{
kinectInfo.bDrawBackground = checked;
//kinectInfo->setDrawBackground(checked);
}
void KinectOptionsDialog::on_drawSkeleton_toggled(bool checked)
{
kinectInfo.bDrawSkeleton = checked;
//kinectInfo->setDrawSkeleton(checked);
}
void KinectOptionsDialog::on_drawPixels_toggled(bool checked)
{
kinectInfo.bDrawPixels = checked;
//kinectInfo->setDrawPixels(checked);
}
|
bfa846b5a46df65b6f45f4671141634330c18b68 | 4413914e3b80f3796fccd6d78b1e57203c27de63 | /src/MyGame.h | 4eb3462b89b6e40da10a415ccfc99e45c99a419a | [] | no_license | grynca/LD33 | 657cb0114215cb27f01a725ee464564add4d113f | 6fbe97452fac32e7f270ebba205a1064a8e97f7c | refs/heads/master | 2021-01-25T09:00:15.110788 | 2015-08-25T10:49:13 | 2015-08-25T10:49:13 | 41,273,404 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 622 | h | MyGame.h | #ifndef MYGAME_H
#define MYGAME_H
#include "geng.h"
using namespace grynca;
#include "Helicopters.h"
#include "Missiles.h"
// fw
class Monster;
class HUD;
class MyGame : public Game, public Singleton<MyGame> {
public:
MyGame();
Helicopters helicopters;
Missiles missiles;
Monster& getMonster();
HUD& getHUD();
bool game_won;
private:
VersionedIndex monster_id_;
VersionedIndex hud_id_;
virtual void init() override;
virtual void update() override;
virtual void tick() override;
void updateDesktopShortcuts_();
void updateCameraMotion_();
};
#endif //MYGAME_H
|
899d955645088d07a262ea6b925e19abf043add0 | 0a2e28a3124281f162f6b90a7c26136fb41d3e2c | /307-Range-Sum-Query-Mutable.cpp | d7d59aff9b77b8f251ce151c64c6ca28c72fee2a | [] | no_license | liuyaqiu/LeetCode-Solution | 668d2331cfd4c48a8678cb4e51fa01903f89bfb5 | ac226d86eeed4aaa3e35bf90d7daac2fa5674e10 | refs/heads/master | 2020-01-27T19:50:57.570262 | 2018-03-01T09:09:12 | 2018-03-01T09:09:12 | 72,990,154 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,391 | cpp | 307-Range-Sum-Query-Mutable.cpp | #include <iostream>
#include <vector>
using namespace std;
/*
* Range Sum Query - Mutable
*
* Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.
*
* The update(i, val) function modifies nums by updating the element at index i to val.
* Example:
* Given nums = [1, 3, 5]
*
* sumRange(0, 2) -> 9
* update(1, 2)
* sumRange(0, 2) -> 8
* Note:
* The array is only modifiable by the update function.
* You may assume the number of calls to update and sumRange function is distributed evenly.
*
*
*/
struct Node {
int val;
int start;
int end;
Node* left;
Node* right;
Node(int x, int s, int e): val(x), start(s), end(e), left(NULL), right(NULL) {}
};
class NumArray {
private:
Node* root;
Node* create(vector<int>& nums, int start, int end) {
if(nums.empty())
return NULL;
if(start == end)
return new Node(nums[start], start, end);
int mid = (start + end) / 2;
Node* left = create(nums, start, mid);
Node* right = create(nums, mid + 1, end);
Node* cur = new Node(left->val + right->val, start, end);
cur->left = left;
cur->right = right;
return cur;
}
void updateTree(Node* root, int i, int val, int old_val) {
if(root == NULL)
return;
root->val += val - old_val;
int mid = (root->start + root->end) / 2;
if(i <= mid)
updateTree(root->left, i, val, old_val);
else
updateTree(root->right, i, val, old_val);
}
int sum(int i, int j, Node* root) {
int start = root->start;
int end = root->end;
int mid = (start + end) / 2;
if(start == i && end == j)
return root->val;
if(mid >= i) {
if(mid >= j)
return sum(i, j, root->left);
else
return sum(i, mid, root->left) + sum(mid + 1, j, root->right);
}
else
return sum(i, j, root->right);
}
public:
NumArray(vector<int> nums) {
root = create(nums, 0, nums.size() - 1);
}
int sumRange(int i, int j) {
if(root == NULL)
return 0;
return sum(i, j, root);
}
void update(int i, int val) {
int old_val = sumRange(i, i);
updateTree(root, i, val, old_val);
}
};
|
0e64faac7f2b4ece61c9b38429e9f2312a16d990 | 9a69c1d7968c75fa171582cfaf776123683f7ce3 | /1006.cpp | b454d418919195ebc8b66fb4aa06b5ae078a955a | [] | no_license | myxxxsquared/bailian | b505d6403351b5d83fdbe486c9d0119bb2b45cf5 | 66298fa080af4e507722d03662188208c0fdd794 | refs/heads/master | 2020-08-04T05:47:47.014151 | 2019-10-17T01:32:48 | 2019-10-17T01:32:48 | 212,027,712 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 506 | cpp | 1006.cpp | #include <stdio.h>
int main()
{
int count = 0;
while (true)
{
count++;
int a, b, c, d;
scanf("%d %d %d %d", &a, &b, &c, &d);
if (a == -1)
break;
a = a % 23, b = b % 28, c = c % 33;
for (; (c - a) % 23 != 0 || (c - b) % 28 != 0; c += 33)
;
d = (c - d + 21252) % 21252;
if (d == 0)
d = 21252;
printf("Case %d: the next triple peak occurs in %d days.\n", count, d);
}
return 0;
} |
2fa298220afc23cee1d9acfd587205b19bb16d1e | c157dc447672f47f2e4aef2291c25beea6d71cf0 | /geGL/src/geGL/OpenGLObject.h | 7dc05f5273c2ce043b717c7d9b3fe8cff92c8017 | [] | no_license | Rendering-FIT/GPUEngine | a1b38299adb9ee972a3b0011ad3bfb31b9da9fab | a5f486d3dfdc7c4430d90cb6cf0ccdba6da37844 | refs/heads/master | 2022-04-29T17:50:56.736207 | 2022-04-29T09:59:10 | 2022-04-29T10:09:39 | 81,936,720 | 11 | 8 | null | 2019-10-16T07:15:04 | 2017-02-14T11:04:27 | C++ | UTF-8 | C++ | false | false | 388 | h | OpenGLObject.h | #pragma once
#include<geGL/OpenGLContext.h>
class GEGL_EXPORT ge::gl::OpenGLObject{
public:
OpenGLObject(GLuint id = 0u);
OpenGLObject(FunctionTablePointer const&table,GLuint id = 0u);
virtual ~OpenGLObject();
GLuint getId()const;
GLuint&getId();
Context const&getContext()const;
OpenGLObject(OpenGLObject const&) = delete;
private:
OpenGLObjectImpl*impl = nullptr;
};
|
d62c88a1cbdc180ada337206151c2fd34fe71127 | 7887a24a4c0eed525a044b785e950d9a71ea7558 | /EventFilter/HGCalRawToDigi/test/HGCalSoATester.cc | 235d22c05c40f8be20d7c19ef5d8317939b1c9f6 | [
"Apache-2.0"
] | permissive | CMS-HGCAL/cmssw | 1aba653346d5a6a69aa60629b7b0cf81880cef91 | 03230166537ea0ea9e0c975cf28964ee81d545ae | refs/heads/hgcal-condformat-HGCalNANO-13_2_0_pre2 | 2023-08-16T21:25:36.872190 | 2023-08-14T20:05:05 | 2023-08-15T23:28:48 | 62,036,013 | 2 | 2 | Apache-2.0 | 2023-09-12T13:02:50 | 2016-06-27T07:48:31 | C++ | UTF-8 | C++ | false | false | 2,578 | cc | HGCalSoATester.cc | #include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ESWatcher.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/HGCalDigi/interface/HGCalDigiCollections.h"
#include "DataFormats/HGCalDigi/interface/HGCalDigiHostCollection.h"
#include <iostream>
#include <algorithm>
class HGCalSoATester : public edm::one::EDAnalyzer<> {
public:
explicit HGCalSoATester(const edm::ParameterSet& iConfig)
: digisToken_(consumes<HGCalElecDigiCollection>(iConfig.getParameter<edm::InputTag>("Digis"))),
soaDigisToken_(consumes<hgcaldigi::HGCalDigiHostCollection>(iConfig.getParameter<edm::InputTag>("SoADigis")))
{}
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("Digis",edm::InputTag("hgcalDigis"));
desc.add<edm::InputTag>("SoADigis",edm::InputTag("hgcalDigis"));
descriptions.addWithDefaultLabel(desc);
}
private:
void analyze(const edm::Event&, const edm::EventSetup& iSetup) override;
//tokens to access collections in ROOT file
const edm::EDGetTokenT<HGCalElecDigiCollection> digisToken_;
const edm::EDGetTokenT<hgcaldigi::HGCalDigiHostCollection> soaDigisToken_;
};
//
void HGCalSoATester::analyze(const edm::Event &iEvent, const edm::EventSetup& iSetup) {
const auto& digis = iEvent.get(digisToken_);
const auto& soadigis = iEvent.get(soaDigisToken_);
auto const& soadigis_view = soadigis.const_view();
//assert collections have the same size
assert((int32_t)digis.size()==soadigis_view.metadata().size());
//loop over collection of SoA digis
for(int32_t i = 0; i < soadigis_view.metadata().size(); ++i) {
auto vi = soadigis_view[i];
//assert 1:1 correspondence to "classic" digi by electronics id
HGCalElectronicsId elecId(vi.electronicsId());
auto _elecIdMatch = [elecId](HGCROCChannelDataFrameElecSpec d){
return d.id()==elecId;
};
auto it = std::find_if(digis.begin(), digis.end(), _elecIdMatch);
assert(it!=digis.end());
//assert values match
assert(vi.tctp()==it->tctp());
assert(vi.adcm1()==it->adcm1());
assert(vi.adc()==it->adc());
assert(vi.tot()==it->tot());
assert(vi.toa()==it->toa());
}
}
DEFINE_FWK_MODULE(HGCalSoATester);
|
4bf3f0dc929a01aa6ee2b010b61b40cbc81882c5 | 7a9037b43ef0f36443228a2dbb712952466b3cf6 | /c++ algortihms/other/right left shift.cpp | 63c9a6c70d181c2488b15f7e4bd643c1da40cc31 | [] | no_license | Suhrid-Talukder333/Data-structures-and-Algorithms | 1af2e42423b14c283eb82676de6db85fdc8bb6ed | 6508748b186b7f0e7ad492fed5e19059a857fa53 | refs/heads/master | 2023-07-12T23:40:38.188305 | 2021-08-14T04:00:59 | 2021-08-14T04:00:59 | 294,078,821 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 842 | cpp | right left shift.cpp | #include<iostream>
using namespace std;
int Leftshift(int arr[],int length)
{
for(int i=0; i<length; i++ )
{
if(i==length-1)
{
arr[i]=0;
}
else
arr[i]=arr[i+1];
}
}
void Rightshift(int arr[],int length)
{
for(int i=length-1; i>=0; i-- )
{
if(i==0)
{
arr[i]=0;
}
else
arr[i]=arr[i-1];
}
}
void display(int arr[], int length)
{
for(int i=0; i<length; i++)
{
cout<<arr[i]<<" ";
}
}
int main()
{
int arr[5]={1,2,3,4,5};
int length=sizeof(arr)/sizeof(arr[1]);
display(arr,length);
cout<<endl;
//Leftshift(arr,length);
//display(arr,length);
//cout<<endl;
Rightshift(arr,length);
display(arr,length);
}
|
ad01fe850a1b092dd5e2b4fa845fa45992cac28d | 694df92026911544a83df9a1f3c2c6b321e86916 | /c++/Game/CreateTeamParam/CreateTeamParam.cpp | 97ec9931dc4d595b79ea6cec6d735bead395b9d0 | [
"MIT"
] | permissive | taku-xhift/labo | f485ae87f01c2f45e4ef1a2a919cda7e571e3f13 | 89dc28fdb602c7992c6f31920714225f83a11218 | refs/heads/main | 2021-12-10T21:19:29.152175 | 2021-08-14T21:08:51 | 2021-08-14T21:08:51 | 81,219,052 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,964 | cpp | CreateTeamParam.cpp |
#pragma warning(disable:4996)
#pragma warning(disable:4290)
#include <algorithm>
#include <limits>
#include <Personal/StreamObject.hpp>
#include "Define.hpp"
#include "Utility.hpp"
#include "DataType.hpp"
#include "Functor.hpp"
#include <stdlib.h>
#include <time.h>
int main() {
unsigned int count = 0;
unsigned int select = std::numeric_limits<unsigned int>::max();
so::out << "Select a League!!\n";
so::out << count << ": Liga Espanola\n";
so::out << ++count << ": Premier League\n";
so::out << ++count << ": Serie A\n";
so::out << ++count << ": League 1\n";
so::out << ++count << ": Eledivisie\n";
so::out << so::endl;
std::cin >> select;
switch (select) {
case 0: {
so::out << "Liga Espanola is selected!!\n";
fileName = LigaData;
break;
}
case 1: {
so::out << "Premier League is selected!!\n";
fileName = PremierData;
break;
}
case 2: {
so::out << "Serie A is selected!!\n";
fileName = SerieAData;
break;
}
case 3: {
so::out << "League 1 is selected!!\n";
fileName = League1Data;
break;
}
case 4: {
so::out << "Eledivisie is selected!!\n";
fileName = EledivisieData;
break;
}
default: {
so::out << "exit...\n";
return 0;
}
}
so::out << so::endl;
so::out.fileName(fileName + "_" + so::out.fileName());
srand((unsigned)time( NULL ));
int testTimes = 5;
std::vector<Team> teamList = readParamFile(fileName);
SeasonResult result(teamList, 2);
for (int i = 0; i < testTimes; ++i) {
while (!result.isAllScheduleFinished()) {
result.stepADay();
}
result.finishSeazon();
}
std::sort(teamList.begin(), teamList.end(), SortByAllSeasonPointsGreater());
std::for_each(teamList.begin(), teamList.end(), Print());
so::out << result << so::endl;
std::cerr << "\n\n" << std::endl;
std::cerr << "Reported to " << so::out.fileName() << " !!!\n\n" << std::endl;
}
|
01aca4a88bc472b3114611e5fb42fe9c769c819b | f0d22137ab4aba3a70c25b42b628e3f09743d936 | /modules/demux/mkv/mkv.hpp | 596e1269148be532860f6c3f23215506b6cd2ad3 | [] | no_license | duxq/vlc_2.1.0-vs_2010 | 6da94eac73bb70604162558e46a266f9acfc0e56 | 218172f619c9e248b709e479e5c10e197127a88e | refs/heads/master | 2021-06-18T12:02:28.079902 | 2017-06-28T02:33:56 | 2017-06-28T02:33:56 | 118,862,081 | 1 | 0 | null | 2018-01-25T04:27:09 | 2018-01-25T04:27:08 | null | UTF-8 | C++ | false | false | 6,722 | hpp | mkv.hpp | /*****************************************************************************
* mkv.hpp : matroska demuxer
*****************************************************************************
* Copyright (C) 2003-2005, 2008 VLC authors and VideoLAN
* $Id: efc88b3c2fef23ac529fc190ef26fc0b404441e2 $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Steve Lhomme <steve.lhomme@free.fr>
*
* This program 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.1 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef _MKV_H_
#define _MKV_H_
/*****************************************************************************
* Preamble
*****************************************************************************/
/* config.h may include inttypes.h, so make sure we define that option
* early enough. */
#define __STDC_FORMAT_MACROS 1
#define __STDC_CONSTANT_MACROS 1
#define __STDC_LIMIT_MACROS 1
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <inttypes.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#ifdef HAVE_TIME_H
# include <time.h> /* time() */
#endif
#include <vlc_meta.h>
#include <vlc_charset.h>
#include <vlc_input.h>
#include <vlc_demux.h>
#include <iostream>
#include <cassert>
#include <typeinfo>
#include <string>
#include <vector>
#include <algorithm>
/* libebml and matroska */
#include "ebml/EbmlHead.h"
#include "ebml/EbmlSubHead.h"
#include "ebml/EbmlStream.h"
#include "ebml/EbmlContexts.h"
#include "ebml/EbmlVoid.h"
#include "ebml/EbmlVersion.h"
#include "ebml/StdIOCallback.h"
#include "matroska/KaxAttachments.h"
#include "matroska/KaxAttached.h"
#include "matroska/KaxBlock.h"
#include "matroska/KaxBlockData.h"
#include "matroska/KaxChapters.h"
#include "matroska/KaxCluster.h"
#include "matroska/KaxClusterData.h"
#include "matroska/KaxContexts.h"
#include "matroska/KaxCues.h"
#include "matroska/KaxCuesData.h"
#include "matroska/KaxInfo.h"
#include "matroska/KaxInfoData.h"
#include "matroska/KaxSeekHead.h"
#include "matroska/KaxSegment.h"
#include "matroska/KaxTag.h"
#include "matroska/KaxTags.h"
//#include "matroska/KaxTagMulti.h"
#include "matroska/KaxTracks.h"
#include "matroska/KaxTrackAudio.h"
#include "matroska/KaxTrackVideo.h"
#include "matroska/KaxTrackEntryData.h"
#include "matroska/KaxContentEncoding.h"
#include "matroska/KaxVersion.h"
#include "ebml/StdIOCallback.h"
extern "C" {
#include "../mp4/libmp4.h"
}
#ifdef HAVE_ZLIB_H
# include <zlib.h>
#endif
#define MKV_DEBUG 0
#define MATROSKA_COMPRESSION_NONE -1
#define MATROSKA_COMPRESSION_ZLIB 0
#define MATROSKA_COMPRESSION_BLIB 1
#define MATROSKA_COMPRESSION_LZOX 2
#define MATROSKA_COMPRESSION_HEADER 3
enum
{
MATROSKA_ENCODING_SCOPE_ALL_FRAMES = 1,
MATROSKA_ENCODING_SCOPE_PRIVATE = 2,
MATROSKA_ENCODING_SCOPE_NEXT = 4 /* unsupported */
};
#define MKVD_TIMECODESCALE 1000000
#define MKV_IS_ID( el, C ) ( el != NULL && typeid( *el ) == typeid( C ) )
using namespace LIBMATROSKA_NAMESPACE;
using namespace std;
void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock,
mtime_t i_pts, mtime_t i_duration, bool f_mandatory );
class attachment_c
{
public:
attachment_c( const std::string& _psz_file_name, const std::string& _psz_mime_type, int _i_size )
:i_size(_i_size)
,psz_file_name( _psz_file_name)
,psz_mime_type( _psz_mime_type)
{
p_data = NULL;
}
~attachment_c() { free( p_data ); }
/* Allocs the data space. Returns true if allocation went ok */
bool init()
{
p_data = malloc( i_size );
return (p_data != NULL);
}
const char* fileName() const { return psz_file_name.c_str(); }
const char* mimeType() const { return psz_mime_type.c_str(); }
int size() const { return i_size; }
void *p_data;
private:
int i_size;
std::string psz_file_name;
std::string psz_mime_type;
};
class matroska_segment_c;
struct matroska_stream_c
{
matroska_stream_c() :p_io_callback(NULL) ,p_estream(NULL) {}
~matroska_stream_c()
{
delete p_io_callback;
delete p_estream;
}
IOCallback *p_io_callback;
EbmlStream *p_estream;
std::vector<matroska_segment_c*> segments;
};
/*****************************************************************************
* definitions of structures and functions used by this plugins
*****************************************************************************/
class PrivateTrackData
{
public:
virtual ~PrivateTrackData() {}
virtual int32_t Init() { return 0; }
};
struct mkv_track_t
{
// ~mkv_track_t();
bool b_default;
bool b_enabled;
bool b_forced;
unsigned int i_number;
unsigned int i_extra_data;
uint8_t *p_extra_data;
char *psz_codec;
bool b_dts_only;
bool b_pts_only;
uint64_t i_default_duration;
float f_timecodescale;
mtime_t i_last_dts;
/* video */
es_format_t fmt;
float f_fps;
es_out_id_t *p_es;
/* audio */
unsigned int i_original_rate;
/* Private track paramters */
PrivateTrackData *p_sys;
bool b_inited;
/* data to be send first */
int i_data_init;
uint8_t *p_data_init;
/* hack : it's for seek */
bool b_search_keyframe;
bool b_silent;
/* informative */
const char *psz_codec_name;
const char *psz_codec_settings;
const char *psz_codec_info_url;
const char *psz_codec_download_url;
/* encryption/compression */
int i_compression_type;
uint32_t i_encoding_scope;
KaxContentCompSettings *p_compression_data;
};
struct mkv_index_t
{
int i_track;
int i_block_number;
int64_t i_position;
int64_t i_time;
bool b_key;
};
#endif /* _MKV_HPP_ */
|
39831287b1fb95fc9da6c2773a6866b9262360d0 | 4b160069675176ef6e763f1e36b683b1b37b1bb3 | /src/maths/mat3.cpp | 52c79e92a70c6b4698c526733b1fe01b10c7f918 | [] | no_license | therealdarkknight/Rambug-Engine- | f6b818492b3f325c1bea3c9c28ba386f5513b6e7 | 60a50d1d0b06456c9771484aa70f075be5df3b3a | refs/heads/master | 2020-06-09T23:06:42.937292 | 2019-06-24T14:48:37 | 2019-06-24T14:48:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,117 | cpp | mat3.cpp | /*
DO NOT DELETE THIS COMMENT:
The ROM(Rambug Optical Mathematics) Library:
This software is written by Danyil Blyschak, 8/2015 (1st Build).
For any permissions, questions, or bug fixes, email the
support email that came with your distribution of this software.
*/
#include "mat3.h"
namespace Rambug
{
namespace Math
{
mat3::mat3()
{
for (int i = 0; i < 3 * 3; i++)
{
elements[i] = 0.0f;
}
}
mat3::mat3(float diagonal)
{
for (int i = 0; i < 3 * 3; i++)
{
elements[i] = 0.0f;
}
elements[0 + 0 * 3] = diagonal;
elements[1 + 1 * 3] = diagonal;
elements[2 + 2 * 3] = diagonal;
}
// Method to get a copy of the current matrix
mat3 mat3::getCopy()
{
// Returns a copy of the current matrix
mat3 copy;
for (int i = 0; i < 3 * 3; i++)
{
copy.elements[i] = elements[i];
}
return copy;
}
// Static version
mat3 mat3::Copy(mat3 matrix)
{
return matrix.getCopy();
}
// Methods to get matrices
mat3 mat3::Identity()
{
return mat3(1);
}
mat3 mat3::Sign()
{
// Return a 3 x 3 sign matrix
// + - +
// - + -
// + - +
mat3 signMatrix(1);
// Column one
signMatrix.elements[0 + 0 * 3] = 1;
signMatrix.elements[1 + 0 * 3] = -1;
signMatrix.elements[2 + 0 * 3] = 1;
// Column two
signMatrix.elements[0 + 1 * 3] = -1;
signMatrix.elements[1 + 1 * 3] = 1;
signMatrix.elements[2 + 1 * 3] = -1;
// Column three
signMatrix.elements[0 + 2 * 3] = 1;
signMatrix.elements[1 + 2 * 3] = -1;
signMatrix.elements[2 + 2 * 3] = 1;
return signMatrix;
}
// Useful methods to do miscellaneous operations with matrices (will change the current matrix)
float mat3::determinant()
{
mat3 signMatrix = Sign();
// Get the submatrices of the first row
mat2 a = subMatrix(0, 0);
mat2 b = subMatrix(0, 1);
mat2 c = subMatrix(0, 2);
// Get the determinants of the submatrices
float aDeterminant = a.determinant();
float bDeterminant = b.determinant();
float cDeterminant = c.determinant();
// Get the numbers that we are going to multiply the determinants by
float aTerm = elements[0 + 0 * 3] * signMatrix.elements[0 + 0 * 3];
float bTerm = elements[0 + 1 * 3] * signMatrix.elements[0 + 1 * 3];
float cTerm = elements[0 + 2 * 3] * signMatrix.elements[0 + 2 * 3];
float aResult = aDeterminant * aTerm;
float bResult = bDeterminant * bTerm;
float cResult = cDeterminant * cTerm;
float result = aResult + bResult + cResult;
return result;
}
mat3& mat3::transpose()
{
// Make the columns of the matrix to rows
mat3 copy = getCopy();
for (int y = 0; y < 3; y++)
{
for (int x = 0; x < 3; x++)
{
elements[y + x * 3] = copy.elements[x + y * 3];
elements[x + y * 3] = copy.elements[y + x * 3];
}
}
return *this;
}
mat2 mat3::subMatrix(const int& row, const int& column)
{
mat3 copy = getCopy();
mat2 result;
// Check if we are not going out of bounds
if (row > 2 || column > 2)
{
return mat2(ERROR_MATRIX_ELEMENT);
}
switch (row)
{
case 0:
// 1st row
switch (column)
{
case 0:
// 1st row, 1st column
result.elements[0] = copy.elements[1 + 1 * 3];
result.elements[1] = copy.elements[2 + 1 * 3];
result.elements[2] = copy.elements[1 + 2 * 3];
result.elements[3] = copy.elements[2 + 2 * 3];
break;
case 1:
// 1st row, 2nd column
result.elements[0] = copy.elements[1 + 0 * 3];
result.elements[1] = copy.elements[2 + 0 * 3];
result.elements[2] = copy.elements[1 + 2 * 3];
result.elements[3] = copy.elements[2 + 2 * 3];
break;
case 2:
// 1st row, 3rd column
result.elements[0] = copy.elements[1 + 0 * 3];
result.elements[1] = copy.elements[2 + 0 * 3];
result.elements[2] = copy.elements[1 + 1 * 3];
result.elements[3] = copy.elements[2 + 1 * 3];
break;
}
break;
case 1:
// 2nd row
switch (column)
{
case 0:
// 2nd row, 1st column
result.elements[0] = copy.elements[0 + 1 * 3];
result.elements[1] = copy.elements[2 + 1 * 3];
result.elements[2] = copy.elements[0 + 2 * 3];
result.elements[3] = copy.elements[2 + 2 * 3];
break;
case 1:
// 2nd row, 2nd column
result.elements[0] = copy.elements[0 + 0 * 3];
result.elements[1] = copy.elements[2 + 0 * 3];
result.elements[2] = copy.elements[0 + 2 * 3];
result.elements[3] = copy.elements[2 + 2 * 3];
break;
case 2:
// 2nd row, 3rd column
result.elements[0] = copy.elements[0 + 0 * 3];
result.elements[1] = copy.elements[2 + 0 * 3];
result.elements[2] = copy.elements[0 + 1 * 3];
result.elements[3] = copy.elements[2 + 1 * 3];
break;
}
break;
case 2:
// 3rd row
switch (column)
{
case 0:
// 3rd row, 1st column
result.elements[0] = copy.elements[0 + 1 * 3];
result.elements[1] = copy.elements[1 + 1 * 3];
result.elements[2] = copy.elements[0 + 2 * 3];
result.elements[3] = copy.elements[1 + 2 * 3];
break;
case 1:
// 3rd row, 2nd column
result.elements[0] = copy.elements[0 + 0 * 3];
result.elements[1] = copy.elements[1 + 0 * 3];
result.elements[2] = copy.elements[0 + 2 * 3];
result.elements[3] = copy.elements[1 + 2 * 3];
break;
case 2:
// 3rd row, 3rd column
result.elements[0] = copy.elements[0 + 0 * 3];
result.elements[1] = copy.elements[1 + 0 * 3];
result.elements[2] = copy.elements[0 + 1 * 3];
result.elements[3] = copy.elements[1 + 1 * 3];
break;
}
break;
}
return result;
}
float mat3::minor(const int& row, const int& column)
{
mat2 smallerMatrix = subMatrix(row, column);
float smallerMatrixDeterminant = smallerMatrix.determinant();
return smallerMatrixDeterminant;
}
float mat3::cofactor(const int& row, const int& column)
{
mat3 signMatrix = Sign();
float Minor = minor(row, column);
float cofactor = Minor * signMatrix.elements[row + column * 4];
return cofactor;
}
mat3& mat3::minorMatrix()
{
mat3 copy = getCopy();
for (int y = 0; y < 3; y++)
{
for (int x = 0; x < 3; x++)
{
elements[x + y * 3] = copy.getMinor(x, y);
}
}
return *this;
}
mat3& mat3::cofactorMatrix()
{
mat3 copy = getCopy();
for (int y = 0; y < 3; y++)
{
for (int x = 0; x < 3; x++)
{
elements[x + y * 3] = copy.getCofactor(x, y);
}
}
return *this;
}
mat3& mat3::adjugate()
{
cofactorMatrix();
transpose();
return *this;
}
mat3& mat3::inverse()
{
float Determinant = determinant();
try
{
if (Determinant == 0)
throw "Divide by zero error";
float oneOverDeterminant = 1 / Determinant;
adjugate();
multiplyScalar(oneOverDeterminant);
}
catch (const char* e)
{
#if PRINT_METHOD_C
printf("MATH EXCEPTION OCCURRED: %s \n", e);
#endif
#if PRINT_METHOD_CPP
std::cout << "MATH EXCEPTION OCCURRED: " << e << std::endl;
#endif
}
return *this;
}
// Static versions
float mat3::Determinant(mat3& matrix)
{
return matrix.determinant();
}
mat3& mat3::Transpose(mat3& matrix)
{
return matrix.transpose();
}
mat2 mat3::SubMatrix(mat3& matrix, const int& row, const int& column)
{
return matrix.subMatrix(row, column);
}
float mat3::Minor(mat3& matrix, const int& row, const int& column)
{
return matrix.minor(row, column);
}
float mat3::Cofactor(mat3& matrix, const int& row, const int& column)
{
return matrix.cofactor(row, column);
}
mat3& mat3::MinorMatrix(mat3& matrix)
{
return matrix.minorMatrix();
}
mat3& mat3::CofactorMatrix(mat3& matrix)
{
return matrix.cofactorMatrix();
}
mat3& mat3::Adjugate(mat3& matrix)
{
return matrix.adjugate();
}
mat3& mat3::Inverse(mat3& matrix)
{
return matrix.inverse();
}
// Same methods, but they will return a value rather than change a matrix
float mat3::getDeterminant()
{
mat3 copy = getCopy();
return copy.determinant();
}
mat3 mat3::getTranspose()
{
mat3 copy = getCopy();
copy.transpose();
return copy;
}
mat2 mat3::getSubMatrix(const int& row, const int& column)
{
mat3 copy = getCopy();
return copy.subMatrix(row, column);
}
float mat3::getMinor(const int& row, const int& column)
{
mat3 copy = getCopy();
return copy.minor(row, column);
}
float mat3::getCofactor(const int& row, const int& column)
{
mat3 copy = getCopy();
return copy.cofactor(row, column);
}
mat3 mat3::getMinorMatrix()
{
mat3 copy = getCopy();
return copy.minorMatrix();
}
mat3 mat3::getCofactorMatrix()
{
mat3 copy = getCopy();
copy.cofactorMatrix();
return copy;
}
mat3 mat3::getAdjugate()
{
mat3 copy = getCopy();
copy.adjugate();
return copy;
}
mat3 mat3::getInverse()
{
mat3 copy = getCopy();
copy.inverse();
return copy;
}
// Static versions
float mat3::GetDeterminant(mat3 matrix)
{
return matrix.getDeterminant();
}
mat3 mat3::GetTranspose(mat3 matrix)
{
return matrix.getTranspose();
}
mat2 mat3::GetSubMatrix(mat3 matrix, const int& row, const int& column)
{
return matrix.getSubMatrix(row, column);
}
float mat3::GetMinor(mat3 matrix, const int& row, const int& column)
{
return matrix.getMinor(row, column);
}
float mat3::GetCofactor(mat3 matrix, const int& row, const int& column)
{
return matrix.getCofactor(row, column);
}
mat3 mat3::GetMinorMatrix(mat3 matrix)
{
return matrix.getMinorMatrix();
}
mat3 mat3::GetCofactorMatrix(mat3 matrix)
{
return matrix.getCofactorMatrix();
}
mat3 mat3::GetAdjugate(mat3 matrix)
{
return matrix.getAdjugate();
}
mat3 mat3::GetInverse(mat3 matrix)
{
return matrix.getInverse();
}
/* OPERATION METHODS BELOW */
// Methods to do arithmetic operations with matrices
mat3& mat3::add(const mat3& other)
{
for (int i = 0; i < 3 * 3; i++)
{
elements[i] += other.elements[i];
}
return *this;
}
mat3& mat3::subtract(const mat3& other)
{
for (int i = 0; i < 3 * 3; i++)
{
elements[i] -= other.elements[i];
}
return *this;
}
mat3& mat3::multiply(const mat3& other)
{
mat3 copy = getCopy();
for (int y = 0; y < 3; y++)
{
for (int x = 0; x < 3; x++)
{
float sum = 0.0f;
for (int e = 0; e < 3; e++)
{
sum += copy.elements[x + e * 3] * other.elements[e + y * 3];
}
elements[x + y * 3] = sum;
}
}
return *this;
}
mat3& mat3::divide(const mat3& other)
{
return multiply(GetInverse(other));
}
// Static versions
mat3& mat3::Add(mat3& left, const mat3& right)
{
return left.add(right);
}
mat3& mat3::Subtract(mat3& left, const mat3& right)
{
return left.subtract(right);
}
mat3& mat3::Multiply(mat3& left, const mat3& right)
{
return left.multiply(right);
}
mat3& mat3::Divide(mat3& left, const mat3& right)
{
return left.divide(right);
}
// Same methods, but they will return a value rather than change a matrix
mat3 mat3::sum(const mat3& other)
{
mat3 copy = getCopy();
copy.add(other);
return copy;
}
mat3 mat3::difference(const mat3& other)
{
mat3 copy = getCopy();
copy.subtract(other);
return copy;
}
mat3 mat3::product(const mat3& other)
{
mat3 copy = getCopy();
copy.multiply(other);
return copy;
}
mat3 mat3::quotient(const mat3& other)
{
mat3 copy = getCopy();
copy.divide(other);
return copy;
}
// Static versions
mat3 mat3::Sum(mat3 left, const mat3& right)
{
return left.sum(right);
}
mat3 mat3::Difference(mat3 left, const mat3& right)
{
return left.difference(right);
}
mat3 mat3::Product(mat3 left, const mat3& right)
{
return left.product(right);
}
mat3 mat3::Quotient(mat3 left, const mat3& right)
{
return left.quotient(right);
}
// Methods to do arithmetic operations with scalars
mat3& mat3::addScalar(const float& scalar)
{
for (int i = 0; i < 3 * 3; i++)
{
elements[i] += scalar;
}
return *this;
}
mat3& mat3::subtractScalar(const float& scalar)
{
for (int i = 0; i < 3 * 3; i++)
{
elements[i] -= scalar;
}
return *this;
}
mat3& mat3::multiplyScalar(const float& scalar)
{
for (int i = 0; i < 3 * 3; i++)
{
elements[i] *= scalar;
}
return *this;
}
mat3& mat3::divideScalar(const float& scalar)
{
for (int i = 0; i < 3 * 3; i++)
{
try
{
if (scalar == 0)
throw "Divide by zero error";
elements[i] /= scalar;
}
catch (const char* e)
{
#if PRINT_METHOD_C
printf("MATH EXCEPTION OCCURRED: %s \n", e);
#endif
#if PRINT_METHOD_CPP
std::cout << "MATH EXCEPTION OCCURRED: " << e << std::endl;
#endif
}
}
return *this;
}
// Static versions
mat3& mat3::AddScalar(mat3& matrix, const float& scalar)
{
return matrix.addScalar(scalar);
}
mat3& mat3::SubtractScalar(mat3& matrix, const float& scalar)
{
return matrix.subtractScalar(scalar);
}
mat3& mat3::MultiplyScalar(mat3& matrix, const float& scalar)
{
return matrix.multiplyScalar(scalar);
}
mat3& mat3::DivideScalar(mat3& matrix, const float& scalar)
{
return matrix.divideScalar(scalar);
}
// Same methods, but they will return a value rather than change a matrix
mat3 mat3::scalarSum(const float& scalar)
{
mat3 copy = getCopy();
copy.addScalar(scalar);
return copy;
}
mat3 mat3::scalarDifference(const float& scalar)
{
mat3 copy = getCopy();
copy.subtractScalar(scalar);
return copy;
}
mat3 mat3::scalarProduct(const float& scalar)
{
mat3 copy = getCopy();
copy.multiplyScalar(scalar);
return copy;
}
mat3 mat3::scalarQuotient(const float& scalar)
{
mat3 copy = getCopy();
copy.divideScalar(scalar);
return copy;
}
// Static versions
mat3 mat3::ScalarSum(mat3 matrix, const float& scalar)
{
return matrix.scalarSum(scalar);
}
mat3 mat3::ScalarDifference(mat3 matrix, const float& scalar)
{
return matrix.scalarDifference(scalar);
}
mat3 mat3::ScalarProduct(mat3 matrix, const float& scalar)
{
return matrix.scalarProduct(scalar);
}
mat3 mat3::ScalarQuotient(mat3 matrix, const float& scalar)
{
return matrix.scalarQuotient(scalar);
}
// Methods to do relational and comparison operations with matrices
bool mat3::isEqualTo(const mat3& other)
{
for (int i = 0; i < 3 * 3; i++)
{
if (elements[i] == other.elements[i])
{
if (i == (3 * 3 - 1))
{
break;
return true;
}
else
{
continue;
}
}
else
{
break;
return false;
}
}
}
bool mat3::isNotEqualTo(const mat3& other)
{
return !isEqualTo(other);
}
// Static versions
bool mat3::IsEqualTo(mat3 left, const mat3& right)
{
return left.isEqualTo(right);
}
bool mat3::IsNotEqualTo(mat3 left, const mat3& right)
{
return left.isNotEqualTo(right);
}
// Methods to print the matrix to the screen
// Uses C or C++'s method of printing
void mat3::print()
{
#if PRINT_METHOD_C
printf("mat3: \n");
for (int y = 0; y < 3; y++)
{
printf("[");
for (int x = 0; x < 3; x++)
{
printf("%f%s", elements[y + x * 3],
((x != 2 ? ", " : "] \n")));
}
}
#endif
#if PRINT_METHOD_CPP
Print(std::cout, *this);
#endif
}
// Uses C or C++'s method of printing
void mat3::Print(mat3 matrix)
{
matrix.print();
}
// Uses C++'s way of printing
std::ostream& mat3::Print(std::ostream& stream, const mat3& matrix)
{
stream << "mat3: " << std::endl;
for (int y = 0; y < 3; y++)
{
stream << "[";
for (int x = 0; x < 3; x++)
{
stream << matrix.elements[y + x * 3] <<
((x != 2 ? ", " : "] \n"));
}
}
return stream;
}
/* OPERATOR OVERLOAD BELOW */
// Overflow arithmetic operators with matrices
mat3 operator+(mat3 left, const mat3& right)
{
return mat3::Sum(left, right);
}
mat3 operator-(mat3 left, const mat3& right)
{
return mat3::Difference(left, right);
}
mat3 operator*(mat3 left, const mat3& right)
{
return mat3::Product(left, right);
}
mat3 operator/(mat3 left, const mat3& right)
{
return mat3::Quotient(left, right);
}
// Overflow arithmetic operators with scalars
mat3 operator+(mat3 matrix, const float& scalar)
{
return mat3::ScalarSum(matrix, scalar);
}
mat3 operator-(mat3 matrix, const float& scalar)
{
return mat3::ScalarDifference(matrix, scalar);
}
mat3 operator*(mat3 matrix, const float& scalar)
{
return mat3::ScalarProduct(matrix, scalar);
}
mat3 operator/(mat3 matrix, const float& scalar)
{
return mat3::ScalarQuotient(matrix, scalar);
}
// Overflow the compound assignment operators with matrices
mat3& mat3::operator+=(const mat3& other)
{
return add(other);
}
mat3& mat3::operator-=(const mat3& other)
{
return subtract(other);
}
mat3& mat3::operator*=(const mat3& other)
{
return multiply(other);
}
mat3& mat3::operator/=(const mat3& other)
{
return divide(other);
}
// Overflow the compound assignment operators with scalars
mat3& mat3::operator+=(const float& scalar)
{
return addScalar(scalar);
}
mat3& mat3::operator-=(const float& scalar)
{
return subtractScalar(scalar);
}
mat3& mat3::operator*=(const float& scalar)
{
return multiplyScalar(scalar);
}
mat3& mat3::operator/=(const float& scalar)
{
return divideScalar(scalar);
}
// Overflow relational and comparison operators
bool operator==(mat3 left, const mat3& right)
{
return mat3::IsEqualTo(left, right);
}
bool operator!=(mat3 left, const mat3& right)
{
return mat3::IsNotEqualTo(left, right);
}
// Overflow the bitwise operator
std::ostream& operator<<(std::ostream& stream, mat3 matrix)
{
return mat3::Print(stream, matrix);
}
}
}
|
76e709b0f581103381e6923c6457e821e07f6535 | 6316f75281dcc4898667e4d1f80292a734079079 | /HW11/Classes/HelloWorldScene.cpp | e3527557c855e93409c69ed126ac9da9fb29d779 | [] | no_license | tanxiaosysu/WindowsAPPandCocos2d | d8ab44c7c0efbf05167ca4f8a77a679f088a589f | c84c73e1d12d0c1c0248044ee2b333ade782bbb7 | refs/heads/master | 2021-01-17T14:56:41.142279 | 2016-08-04T09:30:41 | 2016-08-04T09:30:41 | 52,730,916 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,310 | cpp | HelloWorldScene.cpp | #include "HelloWorldScene.h"
#include "Monster.h"
#include <sstream>
#pragma execution_character_set("utf-8")
USING_NS_CC;
#define MIN_FLOAT 0.00001f
#define MAX_MONSTER_COUNT 15
Scene* HelloWorld::createScene() {
// 'scene' is an autorelease object
auto scene = Scene::create();
// 'layer' is an autorelease object
auto layer = HelloWorld::create();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
// on "init" you need to initialize your instance
bool HelloWorld::init() {
//////////////////////////////
// 1. super init first
if (!Layer::init()) {
return false;
}
visibleSize = Director::getInstance()->getVisibleSize();
origin = Director::getInstance()->getVisibleOrigin();
/* 地图 */
TMXTiledMap * tmx = TMXTiledMap::create("map.tmx");
tmx->setPosition(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2);
tmx->setAnchorPoint(Vec2(0.5f, 0.5f));
tmx->setScale(Director::getInstance()->getContentScaleFactor());
this->addChild(tmx, 0);
//创建一张贴图
auto texture = Director::getInstance()->getTextureCache()->addImage("$lucia_2.png");
//从贴图中以像素单位切割,创建关键帧
auto frame0 = SpriteFrame::createWithTexture(texture, CC_RECT_PIXELS_TO_POINTS(Rect(0, 0, 113, 113)));
//使用第一帧创建精灵
player = Sprite::createWithSpriteFrame(frame0);
player->setPosition(Vec2(origin.x + visibleSize.width / 2,
origin.y + visibleSize.height / 2));
addChild(player, 3);
TTFConfig ttfConfig;
ttfConfig.fontFilePath = "fonts/arial.ttf";
ttfConfig.fontSize = 36;
//杀怪数
killCount = Label::createWithTTF(ttfConfig, "0");
killCount->setPosition(Vec2(origin.x + visibleSize.width / 2,
origin.y + visibleSize.height - killCount->getContentSize().height));
addChild(killCount);
//周期性更新怪物调度器
schedule(schedule_selector(HelloWorld::updateMonster), 3.0f, kRepeatForever, 0);
//hp条
Sprite* sp0 = Sprite::create("hp.png", CC_RECT_PIXELS_TO_POINTS(Rect(0, 320, 420, 47)));
Sprite* sp = Sprite::create("hp.png", CC_RECT_PIXELS_TO_POINTS(Rect(610, 362, 4, 16)));
//使用hp条设置progressBar
pT = ProgressTimer::create(sp);
pT->setScaleX(90);
pT->setAnchorPoint(Vec2(0, 0));
pT->setType(ProgressTimerType::BAR);
pT->setBarChangeRate(Point(1, 0));
pT->setMidpoint(Point(0, 1));
pT->setPercentage(100);
pT->setPosition(Vec2(origin.x + 14 * pT->getContentSize().width, origin.y + visibleSize.height - 2 * pT->getContentSize().height));
addChild(pT, 1);
sp0->setAnchorPoint(Vec2(0, 0));
sp0->setPosition(Vec2(origin.x + pT->getContentSize().width, origin.y + visibleSize.height - sp0->getContentSize().height));
addChild(sp0, 0);
//静态动画
idle.reserve(1);
idle.pushBack(frame0);
//攻击动画
attack.reserve(17);
for (int i = 0; i < 17; i++) {
auto frame = SpriteFrame::createWithTexture(texture, CC_RECT_PIXELS_TO_POINTS(Rect(113 * i, 0, 113, 113)));
attack.pushBack(frame);
}
//死亡动画
auto texture2 = Director::getInstance()->getTextureCache()->addImage("$lucia_dead.png");
dead.reserve(22);
for (int i = 0; i < 22; i++) {
auto frame = SpriteFrame::createWithTexture(texture2, CC_RECT_PIXELS_TO_POINTS(Rect(79 * i, 0, 79, 90)));
dead.pushBack(frame);
}
//运动动画
auto texture3 = Director::getInstance()->getTextureCache()->addImage("$lucia_forward.png");
for (int i = 0; i < 8; i++) {
auto frame = SpriteFrame::createWithTexture(texture3, CC_RECT_PIXELS_TO_POINTS(Rect(68 * i, 0, 68, 101)));
run.pushBack(frame);
}
//Label
auto menuLabel1 = Label::createWithTTF(ttfConfig, "W");
auto menuLabel2 = Label::createWithTTF(ttfConfig, "S");
auto menuLabel3 = Label::createWithTTF(ttfConfig, "A");
auto menuLabel4 = Label::createWithTTF(ttfConfig, "D");
auto menuLabel5 = Label::createWithTTF(ttfConfig, "X");
//menuItem
auto item1 = MenuItemLabel::create(menuLabel1, CC_CALLBACK_1(HelloWorld::moveEvent, this, 'W'));
auto item2 = MenuItemLabel::create(menuLabel2, CC_CALLBACK_1(HelloWorld::moveEvent, this, 'S'));
auto item3 = MenuItemLabel::create(menuLabel3, CC_CALLBACK_1(HelloWorld::moveEvent, this, 'A'));
auto item4 = MenuItemLabel::create(menuLabel4, CC_CALLBACK_1(HelloWorld::moveEvent, this, 'D'));
auto item5 = MenuItemLabel::create(menuLabel5, CC_CALLBACK_1(HelloWorld::actionEvent, this, 'X'));
item3->setPosition(Vec2(origin.x + item3->getContentSize().width, origin.y + item3->getContentSize().height));
item4->setPosition(Vec2(item3->getPosition().x + 3 * item4->getContentSize().width, item3->getPosition().y));
item2->setPosition(Vec2(item3->getPosition().x + 1.5*item2->getContentSize().width, item3->getPosition().y));
item1->setPosition(Vec2(item2->getPosition().x, item2->getPosition().y + item1->getContentSize().height));
item5->setPosition(Vec2(origin.x + visibleSize.width - item5->getContentSize().width, item1->getPosition().y));
menu = Menu::create(item1, item2, item3, item4, item5, NULL);
menu->setPosition(Vec2(0, 0));
addChild(menu, 1);
lastCid = 'n';
monsterCount = 0;
//杀怪数的数字
intKillCount = 0;
return true;
}
void HelloWorld::moveEvent(Ref*, char cid) {
/* 碰撞检测 */
scheduleOnce(schedule_selector(HelloWorld::hitByMonster), 0);
const float distance = 30; /* 移动距离 */
const Vec2 moveList[4] = { /* 移动向量, 顺序依次为WASD */
Vec2(0, distance), Vec2(-1 * distance, 0), Vec2(0, -1 * distance), Vec2(distance, 0)
};
/* 动作 */
auto animation = Animation::createWithSpriteFrames(run, 0.1f);
auto animate = Animate::create(animation);
auto playerPos = player->getPosition(); /* 角色坐标 */
switch (cid) {
case 'W':
/* 条件判断是否处于边界, 下同 */
if (visibleSize.height - playerPos.y - distance < MIN_FLOAT) {
/* 处于边界则只播放动画不移动, 下同 */
player->runAction(animate);
} else {
/* 不处于边界则按moveList的指定方位移动, 下同 */
player->runAction(Spawn::create(MoveBy::create(0.8f, moveList[0]), animate, NULL));
}
break;
case 'A':
if (lastCid != 'A') {
player->setFlipX(true);
}
if (playerPos.x - distance < MIN_FLOAT) {
player->runAction(animate);
} else {
player->runAction(Spawn::create(MoveBy::create(0.8f, moveList[1]), animate, NULL));
}
break;
case 'S':
if (playerPos.y - distance < MIN_FLOAT) {
player->runAction(animate);
} else {
player->runAction(Spawn::create(MoveBy::create(0.8f, moveList[2]), animate, NULL));
}
break;
case 'D':
if (lastCid != 'D') {
player->setFlipX(false);
}
if (visibleSize.width - playerPos.x - distance < MIN_FLOAT) {
player->runAction(animate);
} else {
player->runAction(Spawn::create(MoveBy::create(0.8f, moveList[3]), animate, NULL));
}
break;
default:
break;
}
lastCid = cid;
}
void HelloWorld::actionEvent(Ref*, char cid) {
const float health = 15.0f; /* 血量增减百分比 */
float percentage;
/* 动作 */
auto attackAnimation = Animation::createWithSpriteFrames(attack, 0.05f);
auto deadAnimation = Animation::createWithSpriteFrames(dead, 0.05f);
auto attackAnimate = Animate::create(attackAnimation);
auto deadAnimate = Animate::create(deadAnimation);
switch (cid) {
case 'X':
player->runAction(attackAnimate);
/* 打怪 */
if (hitMonster()) {
/* 控制血量不超过100% */
percentage = pT->getPercentage() + health;
/* 动画 */
pT->runAction(ProgressTo::create(0.2f, 100.0f - percentage < MIN_FLOAT ? 100.0f : percentage));
}
break;
case 'Y':
player->runAction(deadAnimate);
/* 控制血量不低于0% */
percentage = pT->getPercentage() - health;
/* 动画 */
pT->runAction(ProgressTo::create(0.2f, percentage < MIN_FLOAT ? 0 : percentage));
break;
default:
break;
}
}
/* 更新怪函数 */
void HelloWorld::updateMonster(float dt) {
auto fac = Factory::getInstance();
/* 怪物不超过15个, 否则不会产生新怪 */
if (monsterCount < MAX_MONSTER_COUNT) {
monsterCount++;
auto m = fac->createMonster();
float x = random(origin.x, visibleSize.width);
float y = random(origin.y, visibleSize.height);
m->setPosition(x, y);
addChild(m, 3);
}
/* 怪物移动 */
fac->moveMonster(player->getPosition(), 1.0f);
/* 碰撞检测 */
scheduleOnce(schedule_selector(HelloWorld::hitByMonster), 0);
}
/* 打怪函数, 打到则移除怪返回true, 打不到返回false */
bool HelloWorld::hitMonster() {
auto fac = Factory::getInstance();
Rect playerRect = player->getBoundingBox();
Rect attackRect = Rect(playerRect.getMinX() - 40,
playerRect.getMinY(),
playerRect.getMaxX() - playerRect.getMinX() + 80,
playerRect.getMaxY() - playerRect.getMinY());
Sprite* collision = fac->collider(attackRect);
if (collision != NULL) {
fac->removeMonster(collision);
/* 怪物数更新 */
monsterCount--;
/* 击杀数更新 */
updateKillCount();
return true;
}
return false;
}
/* 被怪打函数 */
void HelloWorld::hitByMonster(float dt) {
auto fac = Factory::getInstance();
Sprite* collision = fac->collider(player->getBoundingBox());
if (collision != NULL) { /* 被怪打了 */
fac->removeMonster(collision);
actionEvent(this, 'Y');
}
}
/* 杀怪数更新函数 */
void HelloWorld::updateKillCount() {
/* 杀怪数+1, Label更新内容 */
intKillCount++;
std::stringstream s;
s << intKillCount;
killCount->setString(s.str());
}
|
79cf7096589f8851e0886ae747638976429ee5cd | 8f786151b08d7bce800dd0df5418b330f234d0e3 | /main.cpp | 27590763cf2738db517dea5afc80f0382fd65dc1 | [] | no_license | mlvangorden/BU-CS350 | 70d378deb38c9edd6abce1d96c6b40ecb218ebdb | fd4a3a9ebb17983d71fd8084b2a3012be2542b15 | refs/heads/master | 2020-04-27T14:02:17.322026 | 2019-03-07T17:53:20 | 2019-03-07T17:53:20 | 174,394,006 | 0 | 0 | null | 2019-03-07T17:53:21 | 2019-03-07T17:53:21 | null | UTF-8 | C++ | false | false | 224 | cpp | main.cpp | #include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include "helper.h"
using namespace std;
int main() {
Helper h;
h.generate_no_locality();
cout << h;
}
|
7ea43ec04ea408a0086d823e529f9a96aa948cae | 4491a810f77d635620442c6ef5e70ade50eecbe8 | /exam/2017.10.13/crf3.cpp | 1727d5f24963a9e941f53a0fc9b360964699a4a5 | [] | no_license | cooook/OI_Code | 15473a3b7deafa365d20ae36820f3281884209bf | 45d46b69f2d02b31dcc42d1cd5a5593a343d89af | refs/heads/master | 2023-04-03T21:35:57.365441 | 2021-04-15T14:36:02 | 2021-04-15T14:36:02 | 358,290,530 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,324 | cpp | crf3.cpp | #include <stdio.h>
#include <iostream>
#include <cstring>
#define ls o << 1
#define rs o << 1 | 1
#define MAXN 100005
int n,Q,val[MAXN],sum[MAXN<<2][8],_sum[8],tag[MAXN<<2];
template <typename _t>
inline _t read() {
_t x = 0, f = 1;
char ch = getchar();
for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -f;
for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
return x * f;
}
inline void build(int o,int l,int r) {
if (l == r) return sum[o][val[l]] = 1,void();
register int mid = l + r >> 1;
build(ls,l,mid); build(rs,mid+1,r);
if (l == r) return;
sum[o][1] = sum[ls][1] + sum[rs][1];
sum[o][2] = sum[ls][2] + sum[rs][2];
sum[o][3] = sum[ls][3] + sum[rs][3];
sum[o][4] = sum[ls][4] + sum[rs][4];
sum[o][5] = sum[ls][5] + sum[rs][5];
sum[o][6] = sum[ls][6] + sum[rs][6];
sum[o][7] = sum[ls][7] + sum[rs][7];
}
inline void Push_down(int o,int l,int r) {
if (l == r) return tag[o] = 0,void();
if (tag[o]) {
register int mid = l + r >> 1;
memset(sum[ls],0,sizeof sum[ls]);
memset(sum[rs],0,sizeof sum[rs]);
sum[ls][tag[o]] = mid - l + 1;
sum[rs][tag[o]] = r - mid;
tag[ls] = tag[o];
tag[rs] = tag[o];
tag[o] = 0;
}
}
inline void Update(int o,int l,int r,int x,int y,int val) {
if (x > y) return;
if (x <= l && r <= y) {
memset(sum[o],0,sizeof sum[o]);
tag[o] = val;
sum[o][val] = r - l + 1;
return;
}
Push_down(o,l,r);
register int mid = l + r >> 1;
if (x <= mid) Update(ls,l,mid,x,y,val);
if (mid < y) Update(rs,mid+1,r,x,y,val);
if (l == r) return;
sum[o][1] = sum[ls][1] + sum[rs][1];
sum[o][2] = sum[ls][2] + sum[rs][2];
sum[o][3] = sum[ls][3] + sum[rs][3];
sum[o][4] = sum[ls][4] + sum[rs][4];
sum[o][5] = sum[ls][5] + sum[rs][5];
sum[o][6] = sum[ls][6] + sum[rs][6];
sum[o][7] = sum[ls][7] + sum[rs][7];
}
inline void Query(int o,int l,int r,int x,int y) {
if (x > y) return;
if (x <= l && r <= y) {
_sum[1] += sum[o][1];
_sum[2] += sum[o][2];
_sum[3] += sum[o][3];
_sum[4] += sum[o][4];
_sum[5] += sum[o][5];
_sum[6] += sum[o][6];
_sum[7] += sum[o][7];
return;
}
Push_down(o,l,r);
register int mid = l + r >> 1;
if (x <= mid) Query(ls,l,mid,x,y);
if (mid < y) Query(rs,mid+1,r,x,y);
}
inline void Mark_down(int o,int l,int r) {
if (l == r) for (int i = 1; i <= 7; i++) if (sum[o][i]) return printf("%d ",i),void();
register int mid = l + r >> 1;
Push_down(o,l,r);
Mark_down(ls,l,mid); Mark_down(rs,mid+1,r);
}
int main() {
n = read<int>(); Q = read<int>();
for (int i = 1 ; i <= n; i++) val[i] = read<int>();
build(1,1,n);
while (Q --) {
register int l = read<int>(),r = read<int>(),op = read<int>();
memset(_sum,0,sizeof _sum);
Query(1,1,n,l,r);
if (!op) {
int last = l;
for (int i = 1; i <= 7; i++) Update(1,1,n,last,last + _sum[i] - 1,i),last += _sum[i];
}
else {
int last = r;
for (int i = 1; i <= 7; i++) Update(1,1,n,last-_sum[i]+1,last,i),last -= _sum[i];
}
}
Mark_down(1,1,n);
// while (true);
return 0;
} |
e953bad3042ea2108c2ae5d0e6e8e876d3da3c4a | 0c38f883b52501f2c39c29a1300aa5c1e043c2cc | /Assignment1/Assignment1/utils.cpp | 6c5e5368042825964b5ea90c457e2c555f17a11b | [] | no_license | wilcroft/CAD-Assignments | dd28fe5891586717095693c923ea659bf052477b | 642b03fe497aabb71b567043b3ed346b5c954201 | refs/heads/master | 2021-01-09T21:58:38.375999 | 2016-09-16T14:53:47 | 2016-09-16T14:53:47 | 43,307,300 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,350 | cpp | utils.cpp | #include "utils.h"
namespace utilvars{
int graphn, graphw;
// t_bound_box initial_coords;
Channel * routing;
std::map<pin, enum color_types> colormap;
}
void popToFront(std::list<struct connections_t>* lst, std::list<struct connections_t>::iterator it){
struct connections_t temp;
temp = *(it);
lst->erase(it);
lst->push_front(temp);
}
void popToFront(std::list<Connection>* lst, std::list<Connection>::iterator it){
Connection temp;
temp = *(it);
lst->erase(it);
lst->push_front(temp);
}
void printPin(pin p){
cout << std::get<0>(p) << ", " << std::get<1>(p) << ", " << std::get<2>(p) << endl;
}
int parseInputFile(char * fname, int * n, int * w, std::list<Connection> * connlist){
std::ifstream fs(fname);
string temp;
int item [6];
size_t idx = 0;
if (fs.fail()) {
cerr << "Error: Couldn't open file \"" << fname << "\"" << endl;
return -1;
}
//get the value for n
std::getline(fs, temp);
if (fs.eof()) {
cerr << "Error: missing parameter 'n' in file \"" << fname << "\"" << endl;
return -1;
}
try{ *n = std::stoi(temp); } //ensure conversion from string to int
catch (const std::invalid_argument& ia) {
cerr << "Error: '" << temp << "' is not a valid decimal integer" << endl;
return -1;
}
//cout << "n=" << temp << endl;
utilvars::graphn = *n;
//get the value for w
std::getline(fs, temp);
if (fs.eof()) {
cerr << "Error: missing parameter 'w' in file \"" << fname << "\"" << endl;
return -1;
}
try{ *w = std::stoi(temp); }
catch (const std::invalid_argument& ia) {
cerr << "Error: '" << temp << "' is not a valid decimal integer" << endl;
return -1;
}
//cout << "w=" << temp << endl;
utilvars::graphw = *w;
std::getline(fs, temp);
while (!fs.eof()){
// cout << "'" << temp << "'" << endl;
for (int i = 0; i < 6; i++){
try{ item[i] = std::stoi(temp, &idx); }
catch (const std::invalid_argument& ia) {
cerr << "Error: not a valid decimal integer" << endl;
return -1;
}
temp.erase(0, idx);
}
Connection newconn(item);
if (newconn.isEOPL()) break;
connlist->push_back(newconn);
std::getline(fs, temp);
}
fs.close();
//connlist.unique(&Connection::operator==);
return 0;
}
void printConnList(std::list<Connection> connlist){
std::list<Connection>::iterator it = connlist.begin();
for (it; it != connlist.end(); it++){
it->print();
}
}
void drawscreen(){
//extern int chipn, chipw;
set_draw_mode(DRAW_NORMAL);
clearscreen();
setlinestyle(SOLID);
setlinewidth(1);
setcolor(LIGHTGREY);
int subsq = 2 * utilvars::graphw + 1;
for (int i = 0; i < utilvars::graphn; i++){
for (int j = 0; j < utilvars::graphn + 1; j++){
for (int k = 0; k < utilvars::graphw; k++){
//Draw the wires
setcolor(LIGHTGREY);
//drawline(subsq*j * 2 + 2 * k + 1, (i + 1) * 2 * subsq - 1, subsq*j * 2 + 2 * k + 1, (2 * i + 1)*subsq);
//drawline( (i + 1) * 2 * subsq - 1,subsq*j * 2 + 2 * k + 1, (2 * i + 1)*subsq, subsq*j * 2 + 2 * k + 1);
drawWireSegment(true, i, j, k, LIGHTGREY);
drawWireSegment(false, j, i, k, LIGHTGREY);
}
}
for (int j = 0; j < utilvars::graphn; j++){
//Draw the logic blocks
setcolor(DARKGREY);
fillrect((2 * i + 1)*subsq, (2 * j + 1)*subsq, 2 *(i+1)*subsq - 1, 2 *(j+1)*subsq - 1);
for (int k = 1; k < 5; k++){
pin p = std::make_tuple(i, j, k);
bool ok = p == std::make_tuple(0, 2, 4);
for (int w = 0; w < utilvars::graphw; w++){
if (utilvars::routing->segmentAt(p, w)->getSource() == p)
drawPinToWire(p, w);
if (utilvars::routing->segmentAt(p, w)->getDest() == p)
drawPinToWire(p, w, utilvars::colormap[utilvars::routing->segmentAt(p, w)->getSource()]);
}
}
}
}
}
void drawWireSegment(bool isHoriz, int x, int y, int w, enum color_types c){
int subsq = 2 * utilvars::graphw + 1;
setcolor(c);
if (utilvars::routing->segmentAt(isHoriz, x, y, w)->getState() == ROUTING) setcolor(YELLOW);
if (utilvars::routing->segmentAt(isHoriz, x, y, w)->getState() == TARGET) setcolor(ORANGE);
if (utilvars::routing->segmentAt(isHoriz, x, y, w)->getState() == USED) {
setcolor(utilvars::colormap[utilvars::routing->segmentAt(isHoriz, x, y, w)->getSource()]);
drawSwitchConnections(isHoriz, x, y, w);
}
if (isHoriz){
drawline((x + 1) * 2 * subsq - 1, subsq*y * 2 + 2 * w + 1, (2 * x + 1)*subsq, subsq*y * 2 + 2 * w + 1);
}
else{
drawline(subsq*x * 2 + 2 * w + 1, (y + 1) * 2 * subsq - 1, subsq*x * 2 + 2 * w + 1, (2 * y + 1)*subsq);
}
}
void drawSwitchConnections(bool isHoriz, int x, int y, int w){
Segment * seg = utilvars::routing->segmentAt(isHoriz, x, y, w);
if (!seg->isUsed()) return;
pin src = seg->getSource();
bool bp = (src == std::make_tuple(0, 2, 4));
int subsq = 2 * utilvars::graphw + 1;
setcolor(utilvars::colormap[src]);
if (MODE == BIDIR){
if (isHoriz){
//left side
if (x > 0 && utilvars::routing->segmentAt('h', x - 1, y, w)->getSource() == src && utilvars::routing->segmentAt('h', x - 1, y, w)->isUsed()){
drawline((2 * x + 1)*subsq, subsq*y * 2 + 2 * w + 1, (x) * 2 * subsq - 1, subsq*y * 2 + 2 * w + 1);
}
if (y > 0 && utilvars::routing->segmentAt('v', x, y - 1, w)->getSource() == src && utilvars::routing->segmentAt('v', x, y - 1, w)->isUsed()){
drawline((2 * x + 1)*subsq, subsq*y * 2 + 2 * w + 1, subsq*x * 2 + 2 * w + 1, (y) * 2 * subsq - 1);
}
if (y < utilvars::graphn && utilvars::routing->segmentAt('v', x, y, w)->getSource() == src && utilvars::routing->segmentAt('v', x, y, w)->isUsed()){
drawline((2 * x + 1)*subsq, subsq*y * 2 + 2 * w + 1, subsq*x * 2 + 2 * w + 1, (2 * y + 1)*subsq);
}
//right side
if (x < (utilvars::graphn - 1) && utilvars::routing->segmentAt('h', x + 1, y, w)->getSource() == src && utilvars::routing->segmentAt('h', x + 1, y, w)->isUsed()){
// drawline((x + 1) * 2 * subsq - 1, subsq*y * 2 + 2 * w + 1, (x - 1) * 2 * subsq - 1, subsq*y * 2 + 2 * w + 1);
}
if (y > 0 && utilvars::routing->segmentAt('v', x + 1, y - 1, w)->getSource() == src && utilvars::routing->segmentAt('v', x + 1, y - 1, w)->isUsed()){
drawline((x + 1) * 2 * subsq - 1, subsq*y * 2 + 2 * w + 1, subsq*(x+1) * 2 + 2 * w + 1, (y)* 2 * subsq - 1);
}
if (y < utilvars::graphn && utilvars::routing->segmentAt('v', x + 1, y, w)->getSource() == src && utilvars::routing->segmentAt('v', x + 1, y, w)->isUsed()){
drawline((x + 1) * 2 * subsq - 1, subsq*y * 2 + 2 * w + 1, subsq*(x+1) * 2 + 2 * w + 1, (2 * y + 1)*subsq);
}
}
else{
if (y > 0 && utilvars::routing->segmentAt('v', x, y - 1, w)->getSource() == src && utilvars::routing->segmentAt('v', x, y - 1, w)->isUsed())
drawline(subsq*x * 2 + 2 * w + 1, (2 * y + 1)*subsq, subsq*x * 2 + 2 * w + 1, (y)* 2 * subsq - 1);
}
}
else{
if (isHoriz){
if (w % 2 == 0){ // W->E --->
if (x < (utilvars::graphn - 1) && utilvars::routing->segmentAt('h', x + 1, y, w)->getSource() == src && utilvars::routing->segmentAt('h', x + 1, y, w)->isUsed()){
drawline((x + 1) * 2 * subsq - 1, subsq*y * 2 + 2 * w + 1, (2 * x + 3)*subsq, subsq*y * 2 + 2 * w + 1);
}
if (y > 0 && utilvars::routing->segmentAt('v', x + 1, y - 1, w)->getSource() == src && utilvars::routing->segmentAt('v', x + 1, y - 1, w)->isUsed()){
drawline((x + 1) * 2 * subsq - 1, subsq*y * 2 + 2 * w + 1, subsq*(x + 1) * 2 + 2 * w + 1, (y)* 2 * subsq - 1);
}
if (y < utilvars::graphn && utilvars::routing->segmentAt('v', x + 1, y, w + 1)->getSource() == src && utilvars::routing->segmentAt('v', x + 1, y, w + 1)->isUsed()){
drawline((x + 1) * 2 * subsq - 1, subsq*y * 2 + 2 * w + 1, subsq*(x + 1) * 2 + 2 * (w+1) + 1, (2 * y + 1)*subsq);
}
}
else{ // E->W <----
if (x > 0 && utilvars::routing->segmentAt('h', x - 1, y, w)->getSource() == src && utilvars::routing->segmentAt('h', x - 1, y, w)->isUsed()){
drawline((2 * x + 1)*subsq, subsq*y * 2 + 2 * w + 1, (x)* 2 * subsq - 1, subsq*y * 2 + 2 * w + 1);
}
if (y > 0 && utilvars::routing->segmentAt('v', x, y - 1, w - 1)->getSource() == src && utilvars::routing->segmentAt('v', x, y - 1, w - 1)->isUsed()){
drawline((2 * x + 1)*subsq, subsq*y * 2 + 2 * w + 1, subsq*x * 2 + 2 * (w-1) + 1, (y)* 2 * subsq - 1);
}
if (y < utilvars::graphn && utilvars::routing->segmentAt('v', x, y, w)->getSource() == src && utilvars::routing->segmentAt('v', x, y, w)->isUsed()){
drawline((2 * x + 1)*subsq, subsq*y * 2 + 2 * w + 1, subsq*x * 2 + 2 * w + 1, (2 * y + 1)*subsq);
}
}
}
else {
if (w % 2 == 0){ // N->S V
if (y > 0 && utilvars::routing->segmentAt('v', x, y - 1, w)->getSource() == src && utilvars::routing->segmentAt('v', x, y - 1, w)->isUsed()){
drawline(subsq*x * 2 + 2 * w + 1, (2 * y + 1)*subsq, subsq*x * 2 + 2 * w + 1, (y)* 2 * subsq - 1);
}
if (x > 0 && utilvars::routing->segmentAt('h', x - 1, y, w + 1)->getSource() == src && utilvars::routing->segmentAt('h', x - 1, y, w + 1)->isUsed()){
drawline(subsq*x * 2 + 2 * w + 1, (2 * y + 1)*subsq, (x) * 2 * subsq - 1, subsq*y * 2 + 2 * (w+1) + 1);
}
if (x<utilvars::graphn && utilvars::routing->segmentAt('h', x, y, w)->getSource() == src && utilvars::routing->segmentAt('h', x, y, w)->isUsed()){
drawline(subsq*x * 2 + 2 * w + 1, (2 * y + 1)*subsq, (2 * x + 1)*subsq, subsq*y * 2 + 2 * w + 1);
}
}
else{ // S->N ^
if (y < (utilvars::graphn - 1) && utilvars::routing->segmentAt('v', x, y + 1, w)->getSource() == src && utilvars::routing->segmentAt('v', x, y + 1, w)->isUsed()){
drawline(subsq*x * 2 + 2 * w + 1, (y + 1) * 2 * subsq - 1, subsq*x * 2 + 2 * w + 1, (2 * y + 3)*subsq);
}
if (x > 0 && utilvars::routing->segmentAt('h', x - 1, y + 1, w)->getSource() == src && utilvars::routing->segmentAt('h', x - 1, y + 1, w)->isUsed()){
drawline(subsq*x * 2 + 2 * w + 1, (y + 1) * 2 * subsq - 1, (x) * 2 * subsq - 1, subsq*(y+1)* 2 + 2 * w + 1);
}
if (x<utilvars::graphn && utilvars::routing->segmentAt('h', x, y + 1, w - 1)->getSource() == src && utilvars::routing->segmentAt('h', x, y + 1, w - 1)->isUsed()){
drawline(subsq*x * 2 + 2 * w + 1, (y + 1) * 2 * subsq - 1, (2 * x + 1)*subsq, subsq*(y+1)* 2 + 2 *(w-1) + 1);
}
}
}
}
}
void drawPinToWire(pin p, int w, enum color_types c){
if (c==NUM_COLOR) setcolor(utilvars::colormap[p]);
else setcolor(c);
int x = std::get<0>(p);
int y = std::get<1>(p);
int o = std::get<2>(p);
int subsq = 2 * utilvars::graphw + 1;
//fillrect((2 * i + 1)*subsq, (2 * j + 1)*subsq, 2 * (i + 1)*subsq - 1, 2 * (j + 1)*subsq - 1);
switch (o){
case 1:
drawline((2 * x + 1)*subsq + 1, (2 * y + 1)*subsq, (2 * x + 1)*subsq + 1, subsq*y * 2 + 2 * w + 1);
break;
case 2:
drawline(2 * (x + 1)*subsq - 1, 2 * (y + 1)*subsq - 2, subsq*(x+1) * 2 + 2 * w + 1, 2 * (y + 1)*subsq - 2);
break;
case 3:
drawline(2 * (x + 1)*subsq - 2, 2 * (y + 1)*subsq - 1, 2 * (x + 1)*subsq - 2, subsq*(y+1)* 2 + 2 * w + 1 );
break;
case 4:
drawline((2 * x + 1)*subsq, (2 * y + 1)*subsq + 1, subsq*x * 2 + 2 * w + 1, (2 * y + 1)*subsq + 1);
default:;
}
}
std::list<Segment *> randomizeList(std::list<Segment *> l){
std::list<Segment *> newl;
std::vector<Segment *> v;
for(std::list<Segment *>::iterator iter = l.begin(); iter!= l.end(); iter++){
v.push_back(*iter);
}
std::random_shuffle(v.begin(), v.end());
for (int i=0; i<v.size(); i++)
newl.push_back(v[i]);
return newl;
}
|
1267f8c0e87e013a39b3b60bd8f39c5258c01ffc | 7a013350d3e6b9da62cb33c0bb364af3533b2865 | /Tank.h | ebd5a915678bc3214896f9ac1f0019d71c508941 | [] | no_license | DimitarHKostov/GameProject_OOP | 945f3fe1d5567ae2254c99644f34f8c6e612596a | c0b730ee669655e119ec122906711108fd2b0b03 | refs/heads/master | 2022-11-14T20:05:48.176673 | 2020-06-27T06:06:10 | 2020-06-27T06:06:10 | 219,047,394 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 320 | h | Tank.h | class Tank: public Monster
{
private:
int bonusDefense;
public:
Tank();
Tank(int, int, int, const char*);
void hit(Monster&) override;
~Tank();
void specialAbility() override;
void specialAbilityEffect() const override;
void setBonusDefense(int);
const int getBonusDefense() const;
}; |
8c4e1d89504b937abbbb6c5085805e27663e9e7c | b300f0a5f0dc5d3d12a7bd0d2945010c36dd0672 | /SFML-game/DialogInterface.hpp | 7d4da93046f7280c5469c9d46b8c6dea414f3b5e | [] | no_license | Baardi/RPG-Game | 642a003438f209e918556f3a31a156ead6340645 | e87cc31d230da5865b2041dbddd36a2d8f28ee1c | refs/heads/master | 2023-03-18T02:01:14.377887 | 2023-03-10T21:15:10 | 2023-03-10T21:15:10 | 132,925,514 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 192 | hpp | DialogInterface.hpp | #pragma once
#include "PopupMenu.hpp"
namespace appstate {
class DialogInterface : public appstate::PopupMenu
{
public:
DialogInterface();
~DialogInterface();
void init() override;
};
}
|
aa53bc86657b499185c8dbe5caf672a40a64836f | 483ff22f4f72fbd95eadf601875745ef04a0dbd3 | /CampusLife/VOJ/POJ_3277.cpp | af44368e982c1281445a53082b86f45d0c7dfa40 | [] | no_license | Domacles/MyCXXode | a7c98f52824ee62d79e22e9e5f7487c81a2e6108 | f72fc8b230d3b4bff8972472a39a66c1103bc341 | refs/heads/master | 2021-08-24T02:19:54.177050 | 2017-12-07T16:30:41 | 2017-12-07T16:30:41 | 113,472,855 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,803 | cpp | POJ_3277.cpp | #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
#define L(rt) (rt<<1)
#define R(rt) (rt<<1|1)
const int N=40010;
struct node{
int l,r,h;
}tree[N<<3];
int seg[N<<1],hei[N],lp[N],rp[N];
void build(int l,int r,int rt){
tree[rt].l=l;
tree[rt].r=r;
tree[rt].h=0;
if(l+1==r)
return ;
int mid=(l+r)>>1;
build(l,mid,L(rt));
build(mid,r,R(rt));
}
void update(int id,int l,int r,int rt){
if(seg[tree[rt].l]==l && seg[tree[rt].r]==r){ //找到与原来长度相等的
if(tree[rt].h<hei[id]) //比已存在的高 就把它覆盖
tree[rt].h=hei[id];
return ;
}
int mid=seg[(tree[rt].l+tree[rt].r)>>1];
if(r<=mid)
update(id,l,r,L(rt));
else if(l>=mid)
update(id,l,r,R(rt));
else{
update(id,l,mid,L(rt));
update(id,mid,r,R(rt));
}
}
long long Solve(int h,int rt){ //算每个子结点的面积并
if(tree[rt].h<h) //延迟覆盖 父结比子结点高的话
tree[rt].h=h;
if(tree[rt].l+1==tree[rt].r)
return (long long)(seg[tree[rt].r]-seg[tree[rt].l])*tree[rt].h;
long long a=Solve(tree[rt].h,L(rt));
long long b=Solve(tree[rt].h,R(rt));
return a+b;
}
int main(){
//freopen("input.txt","r",stdin);
int n;
while(~scanf("%d",&n)){
int cnt=0;
for(int i=1;i<=n;i++){ //离散化操作
scanf("%d%d%d",&lp[i],&rp[i],&hei[i]);
seg[++cnt]=lp[i];
seg[++cnt]=rp[i];
}
sort(seg+1,seg+cnt+1);
int len=unique(seg+1,seg+cnt+1)-(seg+1);
build(1,len,1);
for(int i=1;i<=n;i++)
update(i,lp[i],rp[i],1);
long long ans=Solve(0,1);
printf("%I64d\n",ans);
}
return 0;
} |
64a18640a057c8ec123a581630e3b7fd73445a65 | 17b6dfbb1f02cca3c2abc59171bde09c91cd7a5c | /API_4weeks Fire Emblem Copy/UI_tileInfo.cpp | ef1211764af4571af325ff7c3f169eca0aad5436 | [] | no_license | gomdroi/MCH_API | 6a117bc975996f7c191b342b1e1a8bd23c122888 | 6bb67112683deb4ab19f656a9082b246079534d6 | refs/heads/master | 2021-05-21T14:22:37.903154 | 2020-04-23T03:05:19 | 2020-04-23T03:05:19 | 252,679,079 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 4,727 | cpp | UI_tileInfo.cpp | #include "stdafx.h"
#include "UI_tileInfo.h"
#include "unitSet.h"
#include "tile.h"
UI_tileInfo::UI_tileInfo()
{
}
UI_tileInfo::~UI_tileInfo()
{
}
HRESULT UI_tileInfo::init()
{
isCommand = false;
isTagUnit = false;
tileFront = IMAGEMANAGER->addImage("타일정보메인", "images/UI/tileinfo_front.bmp", 150, 165, true, RGB(255, 0, 255));
tileNameBack = IMAGEMANAGER->addImage("타일이름백", "images/UI/tileinfo_nameback.bmp", 108, 54, true, RGB(255, 0, 255));
unitFront = IMAGEMANAGER->addImage("유닛정보메인", "images/UI/playerinfo_firstback.bmp", 288, 144, true, RGB(255, 0, 255));
unitHp = IMAGEMANAGER->addImage("유닛정보체력문자", "images/UI/playerinfo_first_hp.bmp", 48, 24, true, RGB(255, 0, 255));
IMAGEMANAGER->addImage("체력바앞쪽", "images/UI/hpbar_front.bmp", 138, 15,true,RGB(255,0,255));
IMAGEMANAGER->addImage("체력바뒤쪽", "images/UI/hpbar_back.bmp", 138, 15, true, RGB(255, 0, 255));
hpBar = new progressBar;
hpBar->init("images/UI/hpbar_front.bmp", "images/UI/hpbar_back.bmp", 0, 0, 138, 15);
hpBar->setGauge(10, 10);
return S_OK;
}
void UI_tileInfo::update()
{
//타일 정보 부분
if (g_cursor.getPosition().x < 315)
{
rc_tileFront = RectMakeCenter((WINSIZEX - tileFront->getWidth() / 2) - 10, (WINSIZEY - tileFront->getHeight() / 2) - 10,150,165);
}
else if (g_cursor.getPosition().x > 315)
{
rc_tileFront = RectMakeCenter(10 + (tileFront->getWidth() / 2), (WINSIZEY - tileFront->getHeight() / 2) - 10, 150, 165);
}
rc_tileNameBack = RectMake(rc_tileFront.left + 22, rc_tileFront.top + 40, 108, 54);
rc_tileNameStr = RectMake(rc_tileNameBack.left + 7, rc_tileNameBack.top + 16, 96, 37);
rc_tileDefStr = RectMake(rc_tileFront.left + 85, rc_tileFront.top + 92, 36, 21);
rc_tileAvoStr = RectMake(rc_tileFront.left + 85, rc_tileFront.top + 116, 36, 21);
//온 타일 유닛 정보 부분
if (g_cursor.getCurTile()->getOnTileUnit() != nullptr)
{
isTagUnit = true;
hpBar->setGauge(g_cursor.getCurTile()->getOnTileUnit()->getCurHp(), g_cursor.getCurTile()->getOnTileUnit()->getMaxHp());
}
else if (g_cursor.getCurTile()->getOnTileUnit() == nullptr)
{
isTagUnit = false;
}
if (isTagUnit)
{
if (g_cursor.getPosition().y < 240 && g_cursor.getPosition().x < 315)
{
rc_unitFront = RectMakeCenter((unitFront->getWidth() / 2), WINSIZEY - (unitFront->getHeight() / 2), 288, 144);
}
else if (g_cursor.getPosition().x > 315 || g_cursor.getPosition().y > 240 && g_cursor.getPosition().x < 315)
{
rc_unitFront = RectMakeCenter((unitFront->getWidth() / 2), (unitFront->getHeight() / 2), 288, 144);
}
rc_unitHpStr = RectMake(rc_unitFront.left + 175, rc_unitFront.top + 73, 90, 24);
rc_unitNameStr = RectMake(rc_unitFront.left + 140, rc_unitFront.top + 37, 110, 33);
rc_unitSmallMugShot = RectMake(rc_unitFront.left + 25, rc_unitFront.top + 25, 96, 96);
//온 타일 유닛 hp
hpBar->setX(rc_unitFront.left + 124);
hpBar->setY(rc_unitFront.top + 103);
hpBar->update();
}
}
void UI_tileInfo::animation()
{
}
void UI_tileInfo::render()
{
if (isTurning) return;
if (isBattleStart) return;
if (isEnemyTurn) return;
HFONT myFont = CreateFont(26, 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, "둥근모꼴");
HFONT oldFont = (HFONT)SelectObject(getMemDC(), myFont);
SetBkMode(getMemDC(), TRANSPARENT);
if (!isCommandStart)
{
//타일 정보
tileFront->render(getMemDC(), rc_tileFront.left, rc_tileFront.top);
tileNameBack->alphaRender(getMemDC(), rc_tileNameBack.left, rc_tileNameBack.top, 122);
SetTextColor(getMemDC(), RGB(255, 255, 255));
DrawText(getMemDC(), g_cursor.getCurTile()->getTileNameStr(), -1, &rc_tileNameStr, DT_CENTER);
SetTextColor(getMemDC(), RGB(0, 0, 0));
DrawText(getMemDC(), g_cursor.getCurTile()->getTileDefStr(), -1, &rc_tileDefStr, DT_RIGHT);
DrawText(getMemDC(), g_cursor.getCurTile()->getTileAvoStr(), -1, &rc_tileAvoStr, DT_RIGHT);
//온 타일 유닛 정보
if (isTagUnit)
{
unitFront->alphaRender(getMemDC(), rc_unitFront.left, rc_unitFront.top, 180);
unitHp->render(getMemDC(), rc_unitFront.left + 121, rc_unitFront.top + 73);
g_cursor.getCurTile()->getOnTileUnit()->getSmallMugShot()->render(getMemDC(), rc_unitSmallMugShot.left, rc_unitSmallMugShot.top);
sprintf_s(unitHpStr, "%d/%d", g_cursor.getCurTile()->getOnTileUnit()->getCurHp(),
g_cursor.getCurTile()->getOnTileUnit()->getMaxHp());
DrawText(getMemDC(), unitHpStr, -1, &rc_unitHpStr, DT_CENTER);
DrawText(getMemDC(), g_cursor.getCurTile()->getOnTileUnit()->getUnitNameStr(), -1, &rc_unitNameStr, DT_CENTER);
hpBar->render();
}
}
SelectObject(getMemDC(), oldFont);
DeleteObject(myFont);
}
void UI_tileInfo::release()
{
SAFE_DELETE(hpBar);
}
|
a4afb00b83cd5bfcf68f8b6f10a32b6a07171886 | e0d8e2cb01bb9327076ed366c14166ec55814ba6 | /game/player/wheel.cpp | 3dd318553bb85e58465f6021d1bd209516809f90 | [] | no_license | brennand97/ASCII-Game-Engine_CS162-Final-Project | e771b213287d24b5da198445f66ba1f0430872b8 | d7af2a833958da3c38a0d4269935d13ba28422b9 | refs/heads/master | 2021-06-12T21:42:08.981292 | 2017-04-04T02:48:43 | 2017-04-04T02:48:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,706 | cpp | wheel.cpp | /**
* Author: Brennan Douglas
* Date: 03/12/2017
* Description: This is the source file for the Wheel class
*/
#include "wheel.hpp"
#include <cmath>
#include "../../space.hpp"
std::string Wheel::TYPE = "wheel";
std::string Wheel::WheelConstraint::TYPE = "wheel_constraint";
// Constructor for the Wheel.
// <pos> defines the center of the wheel
// <width> defines the axel width between the two wheels
// <height> defines the width of each of the wheels
// <angle> defines the starting angle of the wheels
// <drag_coefficient> defines the drag coefficient for any velocity orthogonal to the wheel
Wheel::Wheel(double *pos, double width, double height, double angle, double drag_coefficient) : ParticleContainer() {
addType(Wheel::TYPE);
this->wheel_width = height;
this->axel_width = width;
this->drag_coefficient = drag_coefficient;
this->angle = angle;
// Left most x
double l_x;
// Bottom most y
double b_y;
if(pos != nullptr) {
l_x = pos[0] - (width / 2.0);
b_y = pos[1] - (height / 2.0);
} else {
l_x = 0;
b_y = 0;
}
// Left wheel top
double * l_w_t_pos = new double[2];
l_w_t_pos[0] = l_x;
l_w_t_pos[1] = b_y + height;
// Left wheel bottom
double * l_w_b_pos = new double[2];
l_w_b_pos[0] = l_x;
l_w_b_pos[1] = b_y;
// Left wheel attachment
double * l_w_a_pos = new double[2];
l_w_a_pos[0] = l_x;
l_w_a_pos[1] = b_y + (height / 2);
// Right wheel top
double * r_w_t_pos = new double[2];
r_w_t_pos[0] = l_x + width;
r_w_t_pos[1] = b_y + height;
// Right wheel bottom
double * r_w_b_pos = new double[2];
r_w_b_pos[0] = l_x + width;
r_w_b_pos[1] = b_y;
// Right wheel attachment
double * r_w_a_pos = new double[2];
r_w_a_pos[0] = l_x + width;
r_w_a_pos[1] = b_y + (height / 2);
// Particles, same naming convention as above
Particle* l_w_t = new Particle(l_w_t_pos);
Particle* l_w_b = new Particle(l_w_b_pos);
Particle* l_w_a = new Particle(l_w_a_pos);
l_w_a->setMass(10);
Particle* r_w_t = new Particle(r_w_t_pos);
Particle* r_w_b = new Particle(r_w_b_pos);
Particle* r_w_a = new Particle(r_w_a_pos);
r_w_a->setMass(10);
// Add particles as children (left -> right, top -> bottom)
addChild(l_w_t);
addChild(l_w_a);
addChild(l_w_b);
addChild(r_w_t);
addChild(r_w_a);
addChild(r_w_b);
// Define the line constraint for each of the wheel widths
wheel_width_constraint = new LineConstraint(height, Constraint::EQUAL);
wheel_width_constraint->addParticle(l_w_t);
wheel_width_constraint->addParticle(l_w_b);
wheel_width_constraint->addParticle(r_w_t);
wheel_width_constraint->addParticle(r_w_b);
addSpecificConstraint(wheel_width_constraint);
// Define the axel width constraint between the top and bottom particles of each wheel
axel_width_constraint = new LineConstraint(width, Constraint::EQUAL);
axel_width_constraint->addParticle(l_w_t);
axel_width_constraint->addParticle(r_w_t);
axel_width_constraint->addParticle(l_w_b);
axel_width_constraint->addParticle(r_w_b);
addSpecificConstraint(axel_width_constraint);
// Create the attachment constraint for each of the center particles on each wheel
attachment_constraint = new LineConstraint(height / 2, Constraint::EQUAL);
attachment_constraint->addParticle(l_w_a);
attachment_constraint->addParticle(l_w_t);
attachment_constraint->addParticle(l_w_a);
attachment_constraint->addParticle(l_w_b);
attachment_constraint->addParticle(r_w_a);
attachment_constraint->addParticle(r_w_t);
attachment_constraint->addParticle(r_w_a);
attachment_constraint->addParticle(r_w_b);
addSpecificConstraint(attachment_constraint);
// Calculate the diagonal as a box (angle zero)
double diagonal = std::sqrt((width * width) + (height * height));
// Set both diagonal constraints to the same diagonal value, creates a box
positive_diagonal_constraint = new LineConstraint(diagonal, Constraint::EQUAL);
positive_diagonal_constraint->addParticle(l_w_b);
positive_diagonal_constraint->addParticle(r_w_t);
addSpecificConstraint(positive_diagonal_constraint);
negative_diagonal_constraint = new LineConstraint(diagonal, Constraint::EQUAL);
negative_diagonal_constraint->addParticle(l_w_t);
negative_diagonal_constraint->addParticle(r_w_b);
addSpecificConstraint(negative_diagonal_constraint);
// Add the wheel constraint to each of the wheel particle pairs
wheelConstraint = new WheelConstraint(this->drag_coefficient);
wheelConstraint->addParticle(l_w_t);
wheelConstraint->addParticle(l_w_b);
wheelConstraint->addParticle(r_w_t);
wheelConstraint->addParticle(r_w_b);
addSpecificConstraint(wheelConstraint);
// Update the wheel to the given starting angle
setAngle(angle);
// Allow the constraints to adjust the wheel back into position after the angle change
for(int i = 0; i < 5; i++) {
((PairConstraint*) wheel_width_constraint)->fix(i + 1);
((PairConstraint*) axel_width_constraint)->fix(i + 1);
((PairConstraint*) attachment_constraint)->fix(i + 1);
((PairConstraint*) positive_diagonal_constraint)->fix(i + 1);
((PairConstraint*) negative_diagonal_constraint)->fix(i + 1);
}
// Remove all the velocity from the angle change
for(GameObject* go: children) {
((Particle*) go)->setPPosition(((Particle*) go)->getPosition());
}
}
// Set the axel width
void Wheel::setAxelWidth(double w) {
axel_width = w;
axel_width_constraint->setLength(axel_width);
double diagonal = std::sqrt((axel_width * axel_width) + (wheel_width * wheel_width));
positive_diagonal_constraint->setLength(diagonal);
negative_diagonal_constraint->setLength(diagonal);
setAngle(angle);
}
// Set the wheel width
void Wheel::setWheelWidth(double h) {
wheel_width = h;
wheel_width_constraint->setLength(wheel_width);
double diagonal = std::sqrt((axel_width * axel_width) + (wheel_width * wheel_width));
attachment_constraint->setLength(wheel_width / 2);
positive_diagonal_constraint->setLength(diagonal);
negative_diagonal_constraint->setLength(diagonal);
setAngle(angle);
}
// Change the angle of the wheels, defined by the lengths of the two diagonals
void Wheel::setAngle(double angle) {
const double pi = 3.1415926535897;
double a_sign = (angle < 0 ? -1 : 1);
this->angle = angle;
double pid4 = pi / 4;
if (angle < -pid4 || angle > pid4) {
angle = pid4 * a_sign;
}
double displacement = std::sin(angle) * wheel_width;
double height = std::cos(angle) * wheel_width;
double p_diagonal, n_diagonal;
// Update constraints
double width = axel_width + ( 2.0 * displacement );
p_diagonal = std::sqrt((width * width) + (height * height));
width = axel_width - ( 2.0 * displacement );
n_diagonal = std::sqrt((width * width) + (height * height));
positive_diagonal_constraint->setLength(p_diagonal);
negative_diagonal_constraint->setLength(n_diagonal);
last_angle_change = std::chrono::high_resolution_clock::now();
}
// Update the angle with a change in value rather then an absolute value
void Wheel::changeAngle(double d_angle) {
angle += d_angle;
setAngle(angle);
}
// Return the current vector of one of the wheels, as they are always parallel they are the same.
double* Wheel::getWheelVector() {
return douglas::vector::subtract(((Particle*) children[0])->getPosition(),
((Particle*) children[1])->getPosition());
}
// Render the wheel, each of the wheels and then a line connecting their midpoints.
void Wheel::render(Screen * screen) {
if(changed) {
rendered_pixels.clear();
Space* world = (Space*) getWorld();
double * p0 = world->convertToPixels((Particle*) getChildren()[0], screen);
double * p1 = world->convertToPixels((Particle*) getChildren()[1], screen);
double * p2 = world->convertToPixels((Particle*) getChildren()[2], screen);
double * p3 = world->convertToPixels((Particle*) getChildren()[3], screen);
double * p4 = world->convertToPixels((Particle*) getChildren()[4], screen);
double * p5 = world->convertToPixels((Particle*) getChildren()[5], screen);
screen->line(p1, p4, draw_char, &rendered_pixels);
screen->line(p0, p2, draw_char, &rendered_pixels);
screen->line(p3, p5, draw_char, &rendered_pixels);
delete [] p0;
delete [] p1;
delete [] p2;
delete [] p3;
delete [] p4;
delete [] p5;
}
screen->addToFrame(rendered_pixels);
}
// Update the wheels attributes
void Wheel::step(double dt) {
ParticleContainer::step(dt);
// If the current angle has been help for a certain amount of time set it back to zero
if((std::chrono::high_resolution_clock::now() - last_angle_change).count() / 1000000.0 > hold_angle_milliseconds) {
setAngle(0);
}
}
// Default constructor for the WheelConstraint
Wheel::WheelConstraint::WheelConstraint(double drag_coefficient) : PairConstraint() {
addType(WheelConstraint::TYPE);
this->drag_coefficient = drag_coefficient;
}
// Method that applies the necessary changes to the two particles provided in accordance with the constraint
void Wheel::WheelConstraint::fix(int iter, Particle * p1, Particle * p2) {
// Only apply constraint on the first iteration
if ( iter < 2 ) {
// Calculate the two velocities
double *vel1 = douglas::vector::subtract(p1->getPosition(), p1->getPPosition());
double *vel2 = douglas::vector::subtract(p2->getPosition(), p2->getPPosition());
// Calculate the vector along the wheel
double *wheelVector = douglas::vector::subtract(p1->getPosition(), p2->getPosition());
// Calculate the vector orthogonal to the wheel
double *resistanceVector = douglas::vector::vector(-wheelVector[1], wheelVector[0]);
// Calculate the amount of velocity parallel to the resistance vector
double *res_vel1 = douglas::vector::project(vel1, resistanceVector);
double *res_vel2 = douglas::vector::project(vel2, resistanceVector);
if (douglas::vector::magnitude(res_vel1) != 0) {
// Tmp container for calculations
double * tmp = douglas::vector::copy(res_vel1);
// Square each of the components
tmp[0] *= std::abs(res_vel1[0]);
tmp[1] *= std::abs(res_vel1[1]);
// Get the previous delta time for the particle
double p_dt = p1->getPreviousStepTime();
// Scale the factor by the drag coefficient, time squared, and inverse mass to get displacement
douglas::vector::scale(tmp, (this->drag_coefficient * p_dt) / p1->getMass());
// Reverse vector to be opposite of velocity
douglas::vector::scale(tmp, -1.0);
// Calculate the new position
double *diff = douglas::vector::project(tmp, resistanceVector);
if(douglas::vector::magnitude(diff) > douglas::vector::magnitude(res_vel1)) {
douglas::vector::scale(res_vel1, -1.0);
double *n_pos = douglas::vector::add(p1->getPosition(), res_vel1);
// Set the new position
p1->setPosition(n_pos);
// Delete all the old variables
delete [] n_pos;
} else {
double *n_pos = douglas::vector::add(p1->getPosition(), diff);
// Set the new position
p1->setPosition(n_pos);
// Delete all the old variables
delete [] n_pos;
}
delete [] tmp;
delete [] diff;
}
if (douglas::vector::magnitude(res_vel2) != 0) {
// Tmp container for calculations
double * tmp = douglas::vector::copy(res_vel2);
// Square each of the components
tmp[0] *= std::abs(res_vel2[0]);
tmp[1] *= std::abs(res_vel2[1]);
// Get the previous delta time for the particle
double p_dt = p2->getPreviousStepTime();
// Scale the factor by the drag coefficient, time squared, and inverse mass to get displacement
douglas::vector::scale(tmp, (this->drag_coefficient * p_dt) / p2->getMass());
// Reverse vector to be opposite of velocity
douglas::vector::scale(tmp, -1.0);
// Calculate the new position
double *diff = douglas::vector::project(tmp, resistanceVector);
if(douglas::vector::magnitude(diff) > douglas::vector::magnitude(res_vel2)) {
douglas::vector::scale(res_vel2, -1.0);
double *n_pos = douglas::vector::add(p2->getPosition(), res_vel2);
// Set the new position
p2->setPosition(n_pos);
// Delete all the old variables
delete [] n_pos;
} else {
double *n_pos = douglas::vector::add(p2->getPosition(), diff);
// Set the new position
p2->setPosition(n_pos);
// Delete all the old variables
delete[] n_pos;
}
delete [] tmp;
delete [] diff;
}
// Delete all the vectors
delete [] vel1;
delete [] vel2;
delete [] wheelVector;
delete [] resistanceVector;
delete [] res_vel1;
delete [] res_vel2;
}
} |
4f6c66c59aace4613ae9a080d02c9657d6b16574 | b1442f84be649f260dd15f91ecdd01fbce80df99 | /OcsfmlWindow/ocsfml_window_stub/Context.hpp | fd991088f99fb668c86bafa9daff73fa8d1a05d8 | [
"Zlib"
] | permissive | JoeDralliam/Ocsfml | ee91296c2a15f95e2e686ba08d048bf5f9ae7a71 | e1bf50665aa34dea4e4d249bf73ab0036b3731fb | refs/heads/master | 2021-01-21T00:43:40.449096 | 2015-11-01T15:20:42 | 2015-11-01T15:20:42 | 2,289,026 | 9 | 3 | null | 2015-10-31T11:00:48 | 2011-08-29T14:42:27 | OCaml | UTF-8 | C++ | false | false | 233 | hpp | Context.hpp | #ifndef OCSFML_CONTEXT_HPP_INCLUDED
#define OCSFML_CONTEXT_HPP_INCLUDED
#include <camlpp/custom_class.hpp>
#include <SFML/Window/Context.hpp>
typedef sf::Context sf_Context;
camlpp__preregister_custom_class( sf_Context );
#endif
|
039ead15ac18abaaf5614ca35e107cd444ff2826 | 66431914fa368bc92d20e4cad64bbde8b3717d00 | /DirectXEngine-2014/Graphics.h | 51dc903f54fd5c4e569fccb6d25b7bf9d7e620b6 | [] | no_license | AmiraliMohayaee/dx11-engine | a855550ac22d0f510db1e18073668cc87edfc584 | 0761454e9f91210800df8ff9d2f3626e848832b6 | refs/heads/master | 2021-06-05T13:13:37.299992 | 2018-10-15T22:58:36 | 2018-10-15T22:58:36 | 33,119,785 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,383 | h | Graphics.h | #pragma once
#include <Windows.h>
#include "Singleton.h"
#include <string>
#include <d3d11.h>
#include <d3dx11.h>
#include <xnamath.h>
#include "RenderTargetView.h"
#define WIN32_LEAN_AND_MEAN
namespace DXEngine
{
class Graphics : public NonCopyable
{
public:
bool Initialize(unsigned int width, unsigned int height, bool fullscreen, const std::wstring &title);
ID3D11Device* GetDevice() { return m_device; }
ID3D11DeviceContext* GetContext() { return m_context; }
void SetClearColour(const Colour &colour) { m_colour = colour; }
void SetAsCurrentRenderTargetView(); // Setting backbuffer as current render target view
void ClearBackBuffer();
void FlipBuffer();
void Shutdown();
int GetScreenWidth();
int GetScreenHeight();
private:
bool InitializeDX();
bool InitializeWin();
private:
Graphics();
~Graphics();
friend class Singleton<Graphics>;
Colour m_colour;
unsigned int m_width;
unsigned int m_height;
bool m_fullscreen;
std::wstring m_title;
HWND m_handle;
HINSTANCE m_instance;
D3D_DRIVER_TYPE m_driverType;
D3D_FEATURE_LEVEL m_featureLevel;
ID3D11Device* m_device;
ID3D11DeviceContext* m_context;
IDXGISwapChain* m_swapChain;
RenderTargetView m_renderTargetView;
ID3D11Texture2D* m_depthStencil;
ID3D11DepthStencilView* m_depthStencilView;
};
typedef Singleton<Graphics> TheGraphics;
} |
4753e8bd9d0363797049f4cce4c0410d81c0fa7a | dee3b3f42235c68217b6d672c6da25c69077c742 | /_MODEL_FOLDERS_/floorStraps/floorStraps.cpp | a2eee4b6edeeeeae5e51e0d7936dd35dd34e7d2b | [] | no_license | marcclintdion/a7_RETINA_Default_FBO | fa61f69253a935df5caf37baad98d79eb94e6566 | 93f056a3749ab88b3bd545b9426cacf9497f6a32 | refs/heads/master | 2021-01-10T07:11:50.408267 | 2015-09-26T18:33:17 | 2015-09-26T18:33:17 | 43,217,724 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 106,879 | cpp | floorStraps.cpp | GLfloat floorStraps[] =
{
//number of vertices = 2286
-3.90796,-0.157551,0.70337,-0.993044,0,-0.117742,0.740066, 0.905001,
-3.93219,-0.157551,0.907722,-0.993044,0,-0.117742,0.759955, 0.88389,
-3.93219,0.040093,0.907722,-0.993044,0,-0.117742,0.77252, 0.902619,
-3.90796,0.040093,0.70337,-0.993044,0,-0.117742,0.760342, 0.924103,
-2.1369,0.046356,0.819904,0.999074,0,0.043028,0.905898, 0.924686,
-2.14571,0.046356,1.02435,0.999074,0,0.043028,0.897228, 0.905033,
-2.14571,-0.155617,1.02435,0.999074,0,0.043028,0.905398, 0.88389,
-2.1369,-0.155617,0.819904,0.999074,0,0.043028,0.928931, 0.904831,
-3.93219,-0.157551,0.907722,-0.065144,1e-006,0.997876,0.759955, 0.88389,
-2.14571,-0.155617,1.02435,-0.065144,1e-006,0.997876,0.905398, 0.88389,
-2.14571,0.046356,1.02435,-0.065144,1e-006,0.997876,0.897228, 0.905033,
-3.93219,0.040093,0.907722,-0.065144,1e-006,0.997876,0.77252, 0.902619,
-2.14571,0.046356,1.02435,-0.003502,0.999994,-0.000283,0.897228, 0.905033,
-2.1369,0.046356,0.819904,-0.003502,0.999994,-0.000283,0.905898, 0.924686,
-3.90796,0.040093,0.70337,-0.003502,0.999994,-0.000283,0.760342, 0.924103,
-3.93219,0.040093,0.907722,-0.003502,0.999994,-0.000283,0.77252, 0.902619,
-3.71785,0.040093,-1.08286,-0.993753,0,-0.111604,0.82786, 0.465598,
-3.69525,0.040093,-1.28417,-0.993753,0,-0.111604,0.815734, 0.486339,
-3.69525,-0.157551,-1.28417,-0.993753,0,-0.111604,0.796113, 0.467415,
-3.71785,-0.157551,-1.08286,-0.993753,0,-0.111604,0.81551, 0.447304,
-2.01866,0.040093,-1.16833,0.999118,0,0.041997,0.956782, 0.486847,
-2.02717,0.040093,-0.965816,0.999118,0,0.041997,0.948173, 0.467715,
-2.02717,-0.157551,-0.965816,0.999118,0,0.041997,0.956369, 0.447304,
-2.01866,-0.157551,-1.16833,0.999118,0,0.041997,0.979158, 0.4679,
-2.02717,0.040093,-0.965816,-0.069063,0,0.997612,0.948173, 0.467715,
-3.71785,0.040093,-1.08286,-0.069063,0,0.997612,0.82786, 0.465598,
-3.71785,-0.157551,-1.08286,-0.069063,0,0.997612,0.81551, 0.447304,
-2.02717,-0.157551,-0.965816,-0.069063,0,0.997612,0.956369, 0.447304,
-2.02717,0.040093,-0.965816,-0,1,0,0.948173, 0.467715,
-2.01866,0.040093,-1.16833,-0,1,0,0.956782, 0.486847,
-3.69525,0.040093,-1.28417,-0,1,0,0.815734, 0.486339,
-3.71785,0.040093,-1.08286,-0,1,0,0.82786, 0.465598,
-3.91468,0.040093,-1.30803,0.098538,0,-0.995133,0.253796, 0.211286,
-3.70453,0.040093,-1.28722,0.098538,0,-0.995133,0.232159, 0.206834,
-3.70453,-0.157551,-1.28722,0.098538,0,-0.995133,0.212737, 0.193277,
-3.91468,-0.157551,-1.30803,0.098538,0,-0.995133,0.276778, 0.186879,
-3.70453,0.040093,-1.28722,0.993681,0.00229,0.112222,0.232159, 0.206834,
-3.92757,0.040093,0.683675,0.993681,0.00229,0.112222,0.229606, 0.35534,
-3.93795,-0.157551,0.783692,0.993681,0.00229,0.112222,0.212737, 0.38029,
-3.70453,-0.157551,-1.28722,0.993681,0.00229,0.112222,0.212737, 0.193277,
-3.92757,0.040093,0.683675,-0.087825,0.45345,0.886944,0.229606, 0.35534,
-4.13772,0.040093,0.662866,-0.087825,0.45345,0.886944,0.251753, 0.358787,
-4.1481,-0.157551,0.762883,-0.087825,0.45345,0.886944,0.26624, 0.376105,
-3.93795,-0.157551,0.783692,-0.087825,0.45345,0.886944,0.212737, 0.38029,
-4.13772,0.040093,0.662866,-0.993681,-0.002291,-0.112222,0.251753, 0.358787,
-3.91468,0.040093,-1.30803,-0.993681,-0.002291,-0.112222,0.253796, 0.211286,
-3.91468,-0.157551,-1.30803,-0.993681,-0.002291,-0.112222,0.276778, 0.186879,
-4.1481,-0.157551,0.762883,-0.993681,-0.002291,-0.112222,0.26624, 0.376105,
-4.13772,0.040093,0.662866,-0,1,0,0.251753, 0.358787,
-3.92757,0.040093,0.683675,-0,1,0,0.229606, 0.35534,
-3.70453,0.040093,-1.28722,-0,1,0,0.232159, 0.206834,
-3.91468,0.040093,-1.30803,-0,1,0,0.253796, 0.211286,
-5.98438,0.042358,0.641381,-0.98723,0.004248,-0.159247,0.342106, 0.843186,
-5.95116,0.042364,0.435495,-0.98723,0.004248,-0.159247,0.329137, 0.859774,
-5.95199,-0.155278,0.435338,-0.98723,0.004248,-0.159247,0.313041, 0.843131,
-5.9852,-0.155284,0.641224,-0.98723,0.004248,-0.159247,0.330605, 0.826148,
-4.15887,0.036827,0.672485,0.995861,-0.003263,0.090835,0.474718, 0.873567,
-4.17737,0.03677,0.875216,0.995861,-0.003263,0.090835,0.468461, 0.84919,
-4.17801,-0.160873,0.875133,0.995861,-0.003263,0.090835,0.477048, 0.826148,
-4.15951,-0.160815,0.672401,0.995861,-0.003263,0.090835,0.502971, 0.851936,
-4.17737,0.03677,0.875216,-0.128348,-0.000128,0.991729,0.468461, 0.84919,
-5.98438,0.042358,0.641381,-0.128348,-0.000128,0.991729,0.342106, 0.843186,
-5.9852,-0.155284,0.641224,-0.128348,-0.000128,0.991729,0.330605, 0.826148,
-4.17801,-0.160873,0.875133,-0.128348,-0.000128,0.991729,0.477048, 0.826148,
-4.17737,0.03677,0.875216,0.00302,0.999995,0.000539,0.468461, 0.84919,
-4.15887,0.036827,0.672485,0.00302,0.999995,0.000539,0.474718, 0.873567,
-5.95116,0.042364,0.435495,0.00302,0.999995,0.000539,0.329137, 0.859774,
-5.98438,0.042358,0.641381,0.00302,0.999995,0.000539,0.342106, 0.843186,
-5.66428,0.042444,-1.34566,-0.987608,0.004247,-0.156883,0.81697, 0.633486,
-5.63274,0.042456,-1.54417,-0.987608,0.004247,-0.156883,0.804833, 0.654638,
-5.63357,-0.155187,-1.54433,-0.987608,0.004247,-0.156883,0.785006, 0.635263,
-5.6651,-0.155198,-1.34582,-0.987608,0.004247,-0.156883,0.804711, 0.615101,
-3.9268,0.037266,-1.30792,0.992314,-0.00326,0.1237,0.948656, 0.65465,
-3.95186,0.037209,-1.1069,0.992314,-0.00326,0.1237,0.93645, 0.635904,
-3.95249,-0.160434,-1.10704,0.992314,-0.00326,0.1237,0.94874, 0.615101,
-3.92743,-0.160376,-1.30805,0.992314,-0.00326,0.1237,0.968465, 0.635404,
-3.95186,0.037209,-1.1069,-0.138092,-0.000228,0.990419,0.93645, 0.635904,
-5.66428,0.042444,-1.34566,-0.138092,-0.000228,0.990419,0.81697, 0.633486,
-5.6651,-0.155198,-1.34582,-0.138092,-0.000228,0.990419,0.804711, 0.615101,
-3.95249,-0.160434,-1.10704,-0.138092,-0.000228,0.990419,0.94874, 0.615101,
-3.95186,0.037209,-1.1069,0.002967,0.999995,0.000594,0.93645, 0.635904,
-3.9268,0.037266,-1.30792,0.002967,0.999995,0.000594,0.948656, 0.65465,
-5.63274,0.042456,-1.54417,0.002967,0.999995,0.000594,0.804833, 0.654638,
-5.66428,0.042444,-1.34566,0.002967,0.999995,0.000594,0.81697, 0.633486,
-5.84055,0.043402,-1.58644,0.16486,9.9e-005,-0.986317,0.384585, 0.208572,
-5.64764,0.042515,-1.5542,0.16486,9.9e-005,-0.986317,0.363958, 0.205394,
-5.64847,-0.155128,-1.55436,0.16486,9.9e-005,-0.986317,0.344128, 0.193013,
-5.84137,-0.154241,-1.5866,0.16486,9.9e-005,-0.986317,0.40653, 0.182963,
-5.64764,0.042515,-1.5542,0.987116,0.000538,0.160007,0.363958, 0.205394,
-5.96769,0.042384,0.414322,0.987116,0.000538,0.160007,0.368967, 0.356309,
-5.98307,-0.155258,0.515819,0.987116,0.000538,0.160007,0.353874, 0.373521,
-5.64847,-0.155128,-1.55436,0.987116,0.000538,0.160007,0.344128, 0.193013,
-5.96769,0.042384,0.414322,-0.136474,0.460933,0.876878,0.368967, 0.356309,
-6.16486,0.043271,0.383169,-0.136474,0.460933,0.876878,0.390479, 0.353361,
-6.18024,-0.154371,0.484666,-0.136474,0.460933,0.876878,0.40653, 0.378098,
-5.98307,-0.155258,0.515819,-0.136474,0.460933,0.876878,0.353874, 0.373521,
-6.16486,0.043271,0.383169,-0.986798,-0.001052,-0.161952,0.390479, 0.353361,
-5.84055,0.043402,-1.58644,-0.986798,-0.001052,-0.161952,0.384585, 0.208572,
-5.84137,-0.154241,-1.5866,-0.986798,-0.001052,-0.161952,0.40653, 0.182963,
-6.18024,-0.154371,0.484666,-0.986798,-0.001052,-0.161952,0.40653, 0.378098,
-6.16486,0.043271,0.383169,0.004419,0.99999,0.000789,0.390479, 0.353361,
-5.96769,0.042384,0.414322,0.004419,0.99999,0.000789,0.368967, 0.356309,
-5.64764,0.042515,-1.5542,0.004419,0.99999,0.000789,0.363958, 0.205394,
-5.84055,0.043402,-1.58644,0.004419,0.99999,0.000789,0.384585, 0.208572,
-7.93618,0.040104,0.323196,-0.974772,0,-0.223203,0.057393, 0.930052,
-7.89025,0.040104,0.122605,-0.974772,0,-0.223203,0.04537, 0.951215,
-7.89025,-0.15754,0.122605,-0.974772,0,-0.223203,0.025328, 0.93251,
-7.93618,-0.15754,0.323196,-0.974772,0,-0.223203,0.044803, 0.911644,
-6.18862,0.046367,0.38973,0.988752,0,0.149562,0.189039, 0.951985,
-6.21922,0.046367,0.592062,0.988752,0,0.149562,0.180087, 0.932584,
-6.21922,-0.155606,0.592062,0.988752,0,0.149562,0.188325, 0.911644,
-6.18862,-0.155606,0.38973,0.988752,0,0.149562,0.211683, 0.932217,
-6.21922,0.046367,0.592062,-0.15471,1e-006,0.98796,0.180087, 0.932584,
-7.93618,0.040104,0.323196,-0.15471,1e-006,0.98796,0.057393, 0.930052,
-7.93618,-0.15754,0.323196,-0.15471,1e-006,0.98796,0.044803, 0.911644,
-6.21922,-0.155606,0.592062,-0.15471,1e-006,0.98796,0.188325, 0.911644,
-6.21922,0.046367,0.592062,-0.003558,0.999993,-0.000676,0.180087, 0.932584,
-6.18862,0.046367,0.38973,-0.003558,0.999993,-0.000676,0.189039, 0.951985,
-7.89025,0.040104,0.122605,-0.003558,0.999993,-0.000676,0.04537, 0.951215,
-7.93618,0.040104,0.323196,-0.003558,0.999993,-0.000676,0.057393, 0.930052,
-7.51257,0.040104,-1.65328,-0.976133,0,-0.217175,0.827564, 0.426254,
-7.46858,0.040104,-1.85102,-0.976133,0,-0.217175,0.815483, 0.446735,
-7.46858,-0.15754,-1.85102,-0.976133,0,-0.217175,0.796113, 0.42807,
-7.51257,-0.15754,-1.65328,-0.976133,0,-0.217175,0.815244, 0.408217,
-5.85855,0.040104,-1.57448,0.988906,0,0.148542,0.954749, 0.447304,
-5.88866,0.040104,-1.37403,0.988906,0,0.148542,0.946008, 0.428401,
-5.88866,-0.15754,-1.37403,0.988906,0,0.148542,0.954307, 0.408217,
-5.85855,-0.15754,-1.57448,0.988906,0,0.148542,0.976846, 0.428556,
-5.88866,0.040104,-1.37403,-0.169471,0,0.985535,0.946008, 0.428401,
-7.51257,0.040104,-1.65328,-0.169471,0,0.985535,0.827564, 0.426254,
-7.51257,-0.15754,-1.65328,-0.169471,0,0.985535,0.815244, 0.408217,
-5.88866,-0.15754,-1.37403,-0.169471,0,0.985535,0.954307, 0.408217,
-5.88866,0.040104,-1.37403,-0,1,0,0.946008, 0.428401,
-5.85855,0.040104,-1.57448,-0,1,0,0.954749, 0.447304,
-7.46858,0.040104,-1.85102,-0,1,0,0.815483, 0.446735,
-7.51257,0.040104,-1.65328,-0,1,0,0.827564, 0.426254,
-7.68421,0.040104,-1.89819,0.204334,0,-0.978901,0.179391, 0.205892,
-7.47748,0.040104,-1.85504,0.204334,0,-0.978901,0.157744, 0.201531,
-7.47748,-0.15754,-1.85504,0.204334,0,-0.978901,0.138315, 0.188,
-7.68421,-0.15754,-1.89819,0.204334,0,-0.978901,0.202275, 0.181404,
-7.47748,0.040104,-1.85504,0.976804,-0.011161,0.213845,0.157744, 0.201531,
-7.90502,0.040104,0.108175,0.976804,-0.011161,0.213845,0.155233, 0.351639,
-7.93381,-0.15754,0.219071,0.976804,-0.011161,0.213845,0.138315, 0.376903,
-7.47748,-0.15754,-1.85504,0.976804,-0.011161,0.213845,0.138315, 0.188,
-7.90502,0.040104,0.108175,-0.17683,0.501083,0.84714,0.155233, 0.351639,
-8.11174,0.040104,0.065024,-0.17683,0.501083,0.84714,0.177613, 0.355323,
-8.14053,-0.15754,0.17592,-0.17683,0.501083,0.84714,0.192201, 0.373377,
-7.93381,-0.15754,0.219071,-0.17683,0.501083,0.84714,0.138315, 0.376903,
-8.11174,0.040104,0.065024,-0.976804,0.011161,-0.213845,0.177613, 0.355323,
-7.68421,0.040104,-1.89819,-0.976804,0.011161,-0.213845,0.179391, 0.205892,
-7.68421,-0.15754,-1.89819,-0.976804,0.011161,-0.213845,0.202275, 0.181404,
-8.14053,-0.15754,0.17592,-0.976804,0.011161,-0.213845,0.192201, 0.373377,
-8.11174,0.040104,0.065024,-0,1,0,0.177613, 0.355323,
-7.90502,0.040104,0.108175,-0,1,0,0.155233, 0.351639,
-7.47748,0.040104,-1.85504,-0,1,0,0.157744, 0.201531,
-7.68421,0.040104,-1.89819,-0,1,0,0.179391, 0.205892,
-9.99734,0.042369,-0.189027,-0.964555,0.004247,-0.263849,0.339682, 0.795499,
-9.94232,0.042375,-0.390184,-0.964555,0.004247,-0.263849,0.326613, 0.812319,
-9.94312,-0.155267,-0.390429,-0.964555,0.004247,-0.263849,0.310345, 0.795375,
-9.99815,-0.155273,-0.189271,-0.964555,0.004247,-0.263849,0.328225, 0.778212,
-8.13642,0.036839,0.065078,0.980448,-0.003263,0.196751,0.474338, 0.826148,
-8.17647,0.036781,0.264672,0.980448,-0.003263,0.196751,0.468266, 0.801507,
-8.1771,-0.160862,0.26452,0.980448,-0.003263,0.196751,0.476805, 0.778212,
-8.13705,-0.160804,0.064927,0.980448,-0.003263,0.196751,0.502971, 0.804357,
-8.17647,0.036781,0.264672,-0.241786,-9.5e-005,0.97033,0.468266, 0.801507,
-9.99734,0.042369,-0.189027,-0.241786,-9.5e-005,0.97033,0.339682, 0.795499,
-9.99815,-0.155273,-0.189271,-0.241786,-9.5e-005,0.97033,0.328225, 0.778212,
-8.1771,-0.160862,0.26452,-0.241786,-9.5e-005,0.97033,0.476805, 0.778212,
-8.17647,0.036781,0.264672,0.002858,0.999996,0.000838,0.468266, 0.801507,
-8.13642,0.036839,0.065078,0.002858,0.999996,0.000838,0.474338, 0.826148,
-9.94232,0.042375,-0.390184,0.002858,0.999996,0.000838,0.326613, 0.812319,
-9.99734,0.042369,-0.189027,0.002858,0.999996,0.000838,0.339682, 0.795499,
-9.47082,0.042456,-2.1202,-0.965183,0.004247,-0.26154,0.772235, 0.943254,
-9.41825,0.042467,-2.3142,-0.965183,0.004247,-0.26154,0.760197, 0.964652,
-9.41905,-0.155176,-2.31444,-0.965183,0.004247,-0.26154,0.740066, 0.945157,
-9.47162,-0.155187,-2.12044,-0.965183,0.004247,-0.26154,0.759893, 0.924686,
-7.69627,0.037278,-1.89938,0.97341,-0.003261,0.229048,0.905956, 0.96476,
-7.74267,0.03722,-1.70219,0.97341,-0.003261,0.229048,0.893604, 0.945797,
-7.74328,-0.160423,-1.7024,0.97341,-0.003261,0.229048,0.905826, 0.924686,
-7.69688,-0.160365,-1.89958,0.97341,-0.003261,0.229048,0.925923, 0.945151,
-7.74267,0.03722,-1.70219,-0.235099,-0.000259,0.971971,0.893604, 0.945797,
-9.47082,0.042456,-2.1202,-0.235099,-0.000259,0.971971,0.772235, 0.943254,
-9.47162,-0.155187,-2.12044,-0.235099,-0.000259,0.971971,0.759893, 0.924686,
-7.74328,-0.160423,-1.7024,-0.235099,-0.000259,0.971971,0.905826, 0.924686,
-7.74267,0.03722,-1.70219,0.002807,0.999996,0.000887,0.893604, 0.945797,
-7.69627,0.037278,-1.89938,0.002807,0.999996,0.000887,0.905956, 0.96476,
-9.41825,0.042467,-2.3142,0.002807,0.999996,0.000887,0.760197, 0.964652,
-9.47082,0.042456,-2.1202,0.002807,0.999996,0.000887,0.772235, 0.943254,
-9.62034,0.043413,-2.37844,0.269333,9.9e-005,-0.963047,0.053389, 0.022541,
-9.43199,0.042526,-2.32576,0.269333,9.9e-005,-0.963047,0.032992, 0.019302,
-9.43279,-0.155117,-2.326,0.269333,9.9e-005,-0.963047,0.017114, 0.005318,
-9.62115,-0.15423,-2.37868,0.269333,9.9e-005,-0.963047,0.070896, 0,
-9.43199,0.042526,-2.32576,0.964979,-0.004244,0.262293,0.032992, 0.019302,
-10.0111,0.042395,-0.195045,0.964979,-0.004244,0.262293,0.022682, 0.171281,
-10.0119,-0.155247,-0.195325,0.964979,-0.004244,0.262293,0, 0.182802,
-9.43279,-0.155117,-2.326,0.964979,-0.004244,0.262293,0.017114, 0.005318,
-10.0111,0.042395,-0.195045,-0.260744,-0.000325,0.965408,0.022682, 0.171281,
-10.2039,0.043282,-0.247093,-0.260744,-0.000325,0.965408,0.045932, 0.168787,
-10.2046,-0.15436,-0.247374,-0.260744,-0.000325,0.965408,0.070896, 0.19589,
-10.0119,-0.155247,-0.195325,-0.260744,-0.000325,0.965408,0, 0.182802,
-10.2039,0.043282,-0.247093,-0.964498,0.004244,-0.264056,0.045932, 0.168787,
-9.62034,0.043413,-2.37844,-0.964498,0.004244,-0.264056,0.053389, 0.022541,
-9.62115,-0.15423,-2.37868,-0.964498,0.004244,-0.264056,0.070896, 0,
-10.2046,-0.15436,-0.247374,-0.964498,0.004244,-0.264056,0.070896, 0.19589,
-10.2039,0.043282,-0.247093,0.004315,0.99999,0.001238,0.045932, 0.168787,
-10.0111,0.042395,-0.195045,0.004315,0.99999,0.001238,0.022682, 0.171281,
-9.43199,0.042526,-2.32576,0.004315,0.99999,0.001238,0.032992, 0.019302,
-9.62034,0.043413,-2.37844,0.004315,0.99999,0.001238,0.053389, 0.022541,
-6.16674,0.043402,0.400078,0.144231,-0.461037,-0.875581,0.113315, 0.028732,
-5.97383,0.042515,0.432322,0.144231,-0.461037,-0.875581,0.093419, 0.02631,
-5.98922,-0.155128,0.533854,0.144231,-0.461037,-0.875581,0.070896, 0.016286,
-6.18213,-0.154241,0.501611,0.144231,-0.461037,-0.875581,0.138315, 0,
-8.11664,0.040104,0.078904,0.176831,-0.501083,-0.84714,0.048957, 0.2226,
-7.90991,0.040104,0.122055,0.176831,-0.501083,-0.84714,0.028938, 0.225089,
-7.93871,-0.15754,0.232951,0.176831,-0.501083,-0.84714,0.004614, 0.19589,
-8.14543,-0.15754,0.1898,0.176831,-0.501083,-0.84714,0.070896, 0.212649,
-7.90991,0.040104,0.122055,0.978518,-0.013566,0.205716,0.028938, 0.225089,
-8.31586,0.040104,2.03994,0.978518,-0.013566,0.205716,0.021424, 0.35804,
-8.31586,-0.15754,2.03994,0.978518,-0.013566,0.205716,0.004614, 0.380439,
-7.93871,-0.15754,0.232951,0.978518,-0.013566,0.205716,0.004614, 0.19589,
-8.31586,0.040104,2.03994,-0.204334,0,0.978901,0.021424, 0.35804,
-8.52258,0.040104,1.99679,-0.204334,0,0.978901,0.043153, 0.361449,
-8.52258,-0.15754,1.99679,-0.204334,0,0.978901,0.059395, 0.376045,
-8.31586,-0.15754,2.03994,-0.204334,0,0.978901,0.004614, 0.380439,
-8.52258,0.040104,1.99679,-0.978518,0.013566,-0.205716,0.043153, 0.361449,
-8.11664,0.040104,0.078904,-0.978518,0.013566,-0.205716,0.048957, 0.2226,
-8.14543,-0.15754,0.1898,-0.978518,0.013566,-0.205716,0.070896, 0.212649,
-8.52258,-0.15754,1.99679,-0.978518,0.013566,-0.205716,0.059395, 0.376045,
-8.52258,0.040104,1.99679,-0,1,0,0.043153, 0.361449,
-8.31586,0.040104,2.03994,-0,1,0,0.021424, 0.35804,
-7.90991,0.040104,0.122055,-0,1,0,0.028938, 0.225089,
-8.11664,0.040104,0.078904,-0,1,0,0.048957, 0.2226,
-5.97383,0.042515,0.432322,0.98783,-0.000638,0.155535,0.093419, 0.02631,
-6.29975,0.042384,2.50687,0.98783,-0.000638,0.155535,0.099881, 0.170745,
-6.30056,-0.155258,2.50667,0.98783,-0.000638,0.155535,0.083368, 0.185226,
-5.98922,-0.155128,0.533854,0.98783,-0.000638,0.155535,0.070896, 0.016286,
-6.29975,0.042384,2.50687,-0.156066,-0.000325,0.987746,0.099881, 0.170745,
-6.49692,0.043271,2.47571,-0.156066,-0.000325,0.987746,0.121001, 0.167272,
-6.49774,-0.154371,2.47552,-0.156066,-0.000325,0.987746,0.138315, 0.189505,
-6.30056,-0.155258,2.50667,-0.156066,-0.000325,0.987746,0.083368, 0.185226,
-6.49692,0.043271,2.47571,-0.987522,0.000123,-0.157482,0.121001, 0.167272,
-6.16674,0.043402,0.400078,-0.987522,0.000123,-0.157482,0.113315, 0.028732,
-6.18213,-0.154241,0.501611,-0.987522,0.000123,-0.157482,0.138315, 0,
-6.49774,-0.154371,2.47552,-0.987522,0.000123,-0.157482,0.138315, 0.189505,
-6.49692,0.043271,2.47571,0.004423,0.99999,0.000762,0.121001, 0.167272,
-6.29975,0.042384,2.50687,0.004423,0.99999,0.000762,0.099881, 0.170745,
-5.97383,0.042515,0.432322,0.004423,0.99999,0.000762,0.093419, 0.02631,
-6.16674,0.043402,0.400078,0.004423,0.99999,0.000762,0.113315, 0.028732,
-4.14089,0.040093,0.68368,0.087825,-0.453449,-0.886944,0.115678, 0.215814,
-3.93074,0.040093,0.704489,0.087825,-0.453449,-0.886944,0.09517, 0.218223,
-3.94112,-0.157551,0.804507,0.087825,-0.453449,-0.886944,0.070896, 0.189505,
-4.15127,-0.157551,0.783697,0.087825,-0.453449,-0.886944,0.137589, 0.205714,
-3.93074,0.040093,0.704489,0.995022,-0.000926,0.09965,0.09517, 0.218223,
-4.12674,0.040093,2.65974,0.995022,-0.000926,0.09965,0.087726, 0.351826,
-4.12674,-0.157551,2.65974,0.995022,-0.000926,0.09965,0.070896, 0.374216,
-3.94112,-0.157551,0.804507,0.995022,-0.000926,0.09965,0.070896, 0.189505,
-4.12674,0.040093,2.65974,-0.098536,0,0.995133,0.087726, 0.351826,
-4.33689,0.040093,2.63893,-0.098536,0,0.995133,0.109239, 0.355318,
-4.33689,-0.157551,2.63893,-0.098536,0,0.995133,0.125305, 0.369927,
-4.12674,-0.157551,2.65974,-0.098536,0,0.995133,0.070896, 0.374216,
-4.33689,0.040093,2.63893,-0.995022,0.000925,-0.09965,0.109239, 0.355318,
-4.14089,0.040093,0.68368,-0.995022,0.000925,-0.09965,0.115678, 0.215814,
-4.15127,-0.157551,0.783697,-0.995022,0.000925,-0.09965,0.137589, 0.205714,
-4.33689,-0.157551,2.63893,-0.995022,0.000925,-0.09965,0.125305, 0.369927,
-4.33689,0.040093,2.63893,-0,1,0,0.109239, 0.355318,
-4.12674,0.040093,2.65974,-0,1,0,0.087726, 0.351826,
-3.93074,0.040093,0.704489,-0,1,0,0.09517, 0.218223,
-4.14089,0.040093,0.68368,-0,1,0,0.115678, 0.215814,
-10.5259,0.042369,1.71485,-0.964555,0.004247,-0.263849,0.566406, 0.762501,
-10.4709,0.042375,1.51369,-0.964555,0.004247,-0.263849,0.553279, 0.779841,
-10.4717,-0.155267,1.51345,-0.964555,0.004247,-0.263849,0.53654, 0.762382,
-10.5267,-0.155273,1.7146,-0.964555,0.004247,-0.263849,0.554964, 0.744721,
-8.54936,0.036839,2.00227,0.980448,-0.003263,0.196751,0.705433, 0.793912,
-8.58941,0.036781,2.20186,0.980448,-0.003263,0.196751,0.6996, 0.768656,
-8.59004,-0.160862,2.20171,0.980448,-0.003263,0.196751,0.707972, 0.744721,
-8.54999,-0.160804,2.00212,0.980448,-0.003263,0.196751,0.734825, 0.771558,
-8.58941,0.036781,2.20186,-0.243912,-8.7e-005,0.969797,0.6996, 0.768656,
-10.5259,0.042369,1.71485,-0.243912,-8.7e-005,0.969797,0.566406, 0.762501,
-10.5267,-0.155273,1.7146,-0.243912,-8.7e-005,0.969797,0.554964, 0.744721,
-8.59004,-0.160862,2.20171,-0.243912,-8.7e-005,0.969797,0.707972, 0.744721,
-8.58941,0.036781,2.20186,0.002682,0.999996,0.000796,0.6996, 0.768656,
-8.54936,0.036839,2.00227,0.002682,0.999996,0.000796,0.705433, 0.793912,
-10.4709,0.042375,1.51369,0.002682,0.999996,0.000796,0.553279, 0.779841,
-10.5259,0.042369,1.71485,0.002682,0.999996,0.000796,0.566406, 0.762501,
-10.2075,0.043413,-0.223665,0.269333,9.9e-005,-0.963047,0.327654, 0.204851,
-10.0191,0.042526,-0.170988,0.269333,9.9e-005,-0.963047,0.308635, 0.200972,
-10.02,-0.155117,-0.171233,0.269333,9.9e-005,-0.963047,0.293728, 0.186471,
-10.2083,-0.15423,-0.22391,0.269333,9.9e-005,-0.963047,0.344128, 0.182963,
-10.0191,0.042526,-0.170988,0.963724,-0.004245,0.266867,0.308635, 0.200972,
-10.5397,0.042395,1.70883,0.963724,-0.004245,0.266867,0.298181, 0.342237,
-10.5405,-0.155247,1.70855,0.963724,-0.004245,0.266867,0.276778, 0.353173,
-10.02,-0.155117,-0.171233,0.963724,-0.004245,0.266867,0.293728, 0.186471,
-10.5397,0.042395,1.70883,-0.260744,-0.000325,0.965408,0.298181, 0.342237,
-10.7324,0.043282,1.65678,-0.260744,-0.000325,0.965408,0.320713, 0.340278,
-10.7332,-0.15436,1.6565,-0.260744,-0.000325,0.965408,0.344128, 0.367557,
-10.5405,-0.155247,1.70855,-0.260744,-0.000325,0.965408,0.276778, 0.353173,
-10.7324,0.043282,1.65678,-0.963171,0.004245,-0.268856,0.320713, 0.340278,
-10.2075,0.043413,-0.223665,-0.963171,0.004245,-0.268856,0.327654, 0.204851,
-10.2083,-0.15423,-0.22391,-0.963171,0.004245,-0.268856,0.344128, 0.182963,
-10.7332,-0.15436,1.6565,-0.963171,0.004245,-0.268856,0.344128, 0.367557,
-10.7324,0.043282,1.65678,0.004307,0.99999,0.001267,0.320713, 0.340278,
-10.5397,0.042395,1.70883,0.004307,0.99999,0.001267,0.298181, 0.342237,
-10.0191,0.042526,-0.170988,0.004307,0.99999,0.001267,0.308635, 0.200972,
-10.2075,0.043413,-0.223665,0.004307,0.99999,0.001267,0.327654, 0.204851,
-11.069,0.042369,3.66718,-0.964555,0.004247,-0.263849,0.566866, 0.712662,
-11.014,0.042375,3.46602,-0.964555,0.004247,-0.263849,0.553667, 0.730441,
-11.0148,-0.155267,3.46578,-0.964555,0.004247,-0.263849,0.53654, 0.712497,
-11.0699,-0.155273,3.66694,-0.964555,0.004247,-0.263849,0.555475, 0.694428,
-8.98609,0.036838,3.99267,0.972864,-0.003264,0.231356,0.710047, 0.744721,
-9.03319,0.036781,4.19072,0.972864,-0.003264,0.231356,0.704014, 0.718964,
-9.03381,-0.160862,4.19054,0.972864,-0.003264,0.231356,0.712105, 0.694428,
-8.98671,-0.160804,3.99249,0.972864,-0.003264,0.231356,0.739775, 0.721516,
-9.03319,0.036781,4.19072,-0.24906,-0.000125,0.968488,0.704014, 0.718964,
-11.069,0.042369,3.66718,-0.24906,-0.000125,0.968488,0.566866, 0.712662,
-11.0699,-0.155273,3.66694,-0.24906,-0.000125,0.968488,0.555475, 0.694428,
-9.03381,-0.160862,4.19054,-0.24906,-0.000125,0.968488,0.712105, 0.694428,
-9.03319,0.036781,4.19072,0.002529,0.999996,0.000807,0.704014, 0.718964,
-8.98609,0.036838,3.99267,0.002529,0.999996,0.000807,0.710047, 0.744721,
-11.014,0.042375,3.46602,0.002529,0.999996,0.000807,0.553667, 0.730441,
-11.069,0.042369,3.66718,0.002529,0.999996,0.000807,0.566866, 0.712662,
-10.7317,0.043413,1.68182,0.269333,9.9e-005,-0.963047,0.260084, 0.021916,
-10.5433,0.042526,1.7345,0.269333,9.9e-005,-0.963047,0.240877, 0.018009,
-10.5441,-0.155117,1.73425,0.269333,9.9e-005,-0.963047,0.225771, 0.00352,
-10.7325,-0.15423,1.68158,0.269333,9.9e-005,-0.963047,0.276778, 0,
-10.5433,0.042526,1.7345,0.962949,-0.004245,0.269651,0.240877, 0.018009,
-11.0828,0.042395,3.66116,0.962949,-0.004245,0.269651,0.230284, 0.161375,
-11.0836,-0.155247,3.66088,0.962949,-0.004245,0.269651,0.208678, 0.172304,
-10.5441,-0.155117,1.73425,0.962949,-0.004245,0.269651,0.225771, 0.00352,
-11.0828,0.042395,3.66116,-0.260744,-0.000325,0.965408,0.230284, 0.161375,
-11.2756,0.043282,3.60911,-0.260744,-0.000325,0.965408,0.253043, 0.159442,
-11.2764,-0.15436,3.60883,-0.260744,-0.000325,0.965408,0.276778, 0.186879,
-11.0836,-0.155247,3.66088,-0.260744,-0.000325,0.965408,0.208678, 0.172304,
-11.2756,0.043282,3.60911,-0.962405,0.004246,-0.271585,0.253043, 0.159442,
-10.7317,0.043413,1.68182,-0.962405,0.004246,-0.271585,0.260084, 0.021916,
-10.7325,-0.15423,1.68158,-0.962405,0.004246,-0.271585,0.276778, 0,
-11.2764,-0.15436,3.60883,-0.962405,0.004246,-0.271585,0.276778, 0.186879,
-11.2756,0.043282,3.60911,0.004304,0.99999,0.001278,0.253043, 0.159442,
-11.0828,0.042395,3.66116,0.004304,0.99999,0.001278,0.230284, 0.161375,
-10.5433,0.042526,1.7345,0.004304,0.99999,0.001278,0.240877, 0.018009,
-10.7317,0.043413,1.68182,0.004304,0.99999,0.001278,0.260084, 0.021916,
-5.5797,0.043402,-3.18519,0.16486,9.7e-005,-0.986317,0.390763, 0.570865,
-5.38679,0.042515,-3.15295,0.16486,9.7e-005,-0.986317,0.37321, 0.567012,
-5.38761,-0.155128,-3.1531,0.16486,9.7e-005,-0.986317,0.359829, 0.552395,
-5.58052,-0.154241,-3.18535,0.16486,9.7e-005,-0.986317,0.405673, 0.549112,
-5.38679,0.042515,-3.15295,0.987202,-0.004244,0.15942,0.37321, 0.567012,
-5.64114,0.042384,-1.57788,0.987202,-0.004244,0.15942,0.363652, 0.692548,
-5.64196,-0.155258,-1.57807,0.987202,-0.004244,0.15942,0.343918, 0.703596,
-5.38761,-0.155128,-3.1531,0.987202,-0.004244,0.15942,0.359829, 0.552395,
-5.64114,0.042384,-1.57788,-0.156065,-0.000324,0.987747,0.363652, 0.692548,
-5.83831,0.043271,-1.60903,-0.156065,-0.000324,0.987747,0.384532, 0.690466,
-5.83913,-0.154371,-1.60923,-0.156065,-0.000324,0.987747,0.405673, 0.716779,
-5.64196,-0.155258,-1.57807,-0.156065,-0.000324,0.987747,0.343918, 0.703596,
-5.83831,0.043271,-1.60903,-0.986796,0.004242,-0.161914,0.384532, 0.690466,
-5.5797,0.043402,-3.18519,-0.986796,0.004242,-0.161914,0.390763, 0.570865,
-5.58052,-0.154241,-3.18535,-0.986796,0.004242,-0.161914,0.405673, 0.549112,
-5.83913,-0.154371,-1.60923,-0.986796,0.004242,-0.161914,0.405673, 0.716779,
-5.83831,0.043271,-1.60903,0.004417,0.99999,0.000802,0.384532, 0.690466,
-5.64114,0.042384,-1.57788,0.004417,0.99999,0.000802,0.363652, 0.692548,
-5.38679,0.042515,-3.15295,0.004417,0.99999,0.000802,0.37321, 0.567012,
-5.5797,0.043402,-3.18519,0.004417,0.99999,0.000802,0.390763, 0.570865,
-7.27439,0.040104,-3.73181,0.204334,0,-0.978901,0.455615, 0.548202,
-7.06767,0.040104,-3.68866,0.204334,0,-0.978901,0.434474, 0.545054,
-7.06767,-0.15754,-3.68866,0.204334,0,-0.978901,0.415437, 0.531963,
-7.27439,-0.15754,-3.73181,0.204334,0,-0.978901,0.473314, 0.524126,
-7.06767,0.040104,-3.68866,0.976121,0,0.217227,0.434474, 0.545054,
-7.47053,0.040104,-1.87836,0.976121,0,0.217227,0.433128, 0.683443,
-7.47053,-0.15754,-1.87836,0.976121,0,0.217227,0.415437, 0.707525,
-7.06767,-0.15754,-3.68866,0.976121,0,0.217227,0.415437, 0.531963,
-7.47053,0.040104,-1.87836,-0.204334,0,0.978901,0.433128, 0.683443,
-7.67726,0.040104,-1.92151,-0.204334,0,0.978901,0.454261, 0.686588,
-7.67726,-0.15754,-1.92151,-0.204334,0,0.978901,0.473314, 0.699688,
-7.47053,-0.15754,-1.87836,-0.204334,0,0.978901,0.415437, 0.707525,
-7.67726,0.040104,-1.92151,-0.976121,0,-0.217227,0.454261, 0.686588,
-7.27439,0.040104,-3.73181,-0.976121,0,-0.217227,0.455615, 0.548202,
-7.27439,-0.15754,-3.73181,-0.976121,0,-0.217227,0.473314, 0.524126,
-7.67726,-0.15754,-1.92151,-0.976121,0,-0.217227,0.473314, 0.699688,
-7.67726,0.040104,-1.92151,-0,1,0,0.454261, 0.686588,
-7.47053,0.040104,-1.87836,-0,1,0,0.433128, 0.683443,
-7.06767,0.040104,-3.68866,-0,1,0,0.434474, 0.545054,
-7.27439,0.040104,-3.73181,-0,1,0,0.455615, 0.548202,
-9.12639,0.043413,-4.16849,0.269333,9.9e-005,-0.963047,0.260885, 0.402553,
-8.93804,0.042526,-4.11581,0.269333,9.9e-005,-0.963047,0.241973, 0.399314,
-8.93884,-0.155117,-4.11606,0.269333,9.9e-005,-0.963047,0.227563, 0.385131,
-9.1272,-0.15423,-4.16873,0.269333,9.9e-005,-0.963047,0.276778, 0.38029,
-8.93804,0.042526,-4.11581,0.966271,-0.004242,0.257493,0.241973, 0.399314,
-9.40977,0.042395,-2.34559,0.966271,-0.004242,0.257493,0.23248, 0.535674,
-9.41056,-0.155247,-2.34587,0.966271,-0.004242,0.257493,0.211491, 0.547189,
-8.93884,-0.155117,-4.11606,0.966271,-0.004242,0.257493,0.227563, 0.385131,
-9.40977,0.042395,-2.34559,-0.260744,-0.000325,0.965408,0.23248, 0.535674,
-9.60248,0.043282,-2.39764,-0.260744,-0.000325,0.965408,0.254129, 0.533144,
-9.60327,-0.15436,-2.39792,-0.260744,-0.000325,0.965408,0.276778, 0.559408,
-9.41056,-0.155247,-2.34587,-0.260744,-0.000325,0.965408,0.211491, 0.547189,
-9.60248,0.043282,-2.39764,-0.9657,0.004243,-0.259625,0.254129, 0.533144,
-9.12639,0.043413,-4.16849,-0.9657,0.004243,-0.259625,0.260885, 0.402553,
-9.1272,-0.15423,-4.16873,-0.9657,0.004243,-0.259625,0.276778, 0.38029,
-9.60327,-0.15436,-2.39792,-0.9657,0.004243,-0.259625,0.276778, 0.559408,
-9.60248,0.043282,-2.39764,0.004317,0.99999,0.001229,0.254129, 0.533144,
-9.40977,0.042395,-2.34559,0.004317,0.99999,0.001229,0.23248, 0.535674,
-8.93804,0.042526,-4.11581,0.004317,0.99999,0.001229,0.241973, 0.399314,
-9.12639,0.043413,-4.16849,0.004317,0.99999,0.001229,0.260885, 0.402553,
-7.09946,0.040104,-3.48868,-0.976133,0,-0.217175,0.835216, 0.073252,
-7.05547,0.040104,-3.68642,-0.976133,0,-0.217175,0.822995, 0.093153,
-7.05547,-0.15754,-3.68642,-0.976133,0,-0.217175,0.804333, 0.07487,
-7.09946,-0.15754,-3.48868,-0.976133,0,-0.217175,0.823072, 0.055741,
-5.57527,0.040104,-3.41578,0.988906,0,0.148542,0.956452, 0.093531,
-5.60538,0.040104,-3.21533,0.988906,0,0.148542,0.94774, 0.075254,
-5.60538,-0.15754,-3.21533,0.988906,0,0.148542,0.956391, 0.055741,
-5.57527,-0.15754,-3.41578,0.988906,0,0.148542,0.978013, 0.075608,
-5.60538,0.040104,-3.21533,-0.179964,0,0.983673,0.94774, 0.075254,
-7.09946,0.040104,-3.48868,-0.179964,0,0.983673,0.835216, 0.073252,
-7.09946,-0.15754,-3.48868,-0.179964,0,0.983673,0.823072, 0.055741,
-5.60538,-0.15754,-3.21533,-0.179964,0,0.983673,0.956391, 0.055741,
-5.60538,0.040104,-3.21533,-0,1,0,0.94774, 0.075254,
-5.57527,0.040104,-3.41578,-0,1,0,0.956452, 0.093531,
-7.05547,0.040104,-3.68642,-0,1,0,0.822995, 0.093153,
-7.09946,0.040104,-3.48868,-0,1,0,0.835216, 0.073252,
-8.97546,0.042456,-3.91488,-0.965184,0.004247,-0.261538,0.827755, 0.360048,
-8.92289,0.042467,-4.10888,-0.965184,0.004247,-0.261538,0.815777, 0.380927,
-8.92369,-0.155176,-4.10912,-0.965184,0.004247,-0.261538,0.796113, 0.361933,
-8.97626,-0.155187,-3.91512,-0.965184,0.004247,-0.261538,0.815431, 0.341937,
-7.28316,0.037278,-3.73478,0.97341,-0.003261,0.229048,0.958175, 0.381169,
-7.32956,0.03722,-3.53759,0.97341,-0.003261,0.229048,0.945783, 0.362612,
-7.33017,-0.160423,-3.5378,0.97341,-0.003261,0.229048,0.957965, 0.341937,
-7.28377,-0.160365,-3.73498,0.97341,-0.003261,0.229048,0.977682, 0.361931,
-7.32956,0.03722,-3.53759,-0.223432,-0.000307,0.974719,0.945783, 0.362612,
-8.97546,0.042456,-3.91488,-0.223432,-0.000307,0.974719,0.827755, 0.360048,
-8.97626,-0.155187,-3.91512,-0.223432,-0.000307,0.974719,0.815431, 0.341937,
-7.33017,-0.160423,-3.5378,-0.223432,-0.000307,0.974719,0.957965, 0.341937,
-7.32956,0.03722,-3.53759,0.002961,0.999995,0.000926,0.945783, 0.362612,
-7.28316,0.037278,-3.73478,0.002961,0.999995,0.000926,0.958175, 0.381169,
-8.92289,0.042467,-4.10888,0.002961,0.999995,0.000926,0.815777, 0.380927,
-8.97546,0.042456,-3.91488,0.002961,0.999995,0.000926,0.827755, 0.360048,
-1.91174,0.040822,-2.79448,0.057333,0.000116,-0.998355,0.760173, 0.35655,
-1.71648,0.039935,-2.78327,0.057333,0.000116,-0.998355,0.744675, 0.361256,
-1.71731,-0.129508,-2.78334,0.057333,0.000116,-0.998355,0.73065, 0.341937,
-1.91257,-0.128621,-2.79455,0.057333,0.000116,-0.998355,0.770693, 0.343013,
-1.71648,0.039935,-2.78327,0.998586,-0.00495,0.052939,0.744675, 0.361256,
-1.80224,0.039805,-1.16559,0.998586,-0.00495,0.052939,0.752725, 0.486451,
-1.80307,-0.129638,-1.1657,0.998586,-0.00495,0.052939,0.73065, 0.486847,
-1.71731,-0.129508,-2.78334,0.998586,-0.00495,0.052939,0.73065, 0.341937,
-1.99654,0.040692,-1.18895,-0.998596,0.00495,-0.052743,0.774377, 0.482994,
-1.91174,0.040822,-2.79448,-0.998596,0.00495,-0.052743,0.760173, 0.35655,
-1.91257,-0.128621,-2.79455,-0.998596,0.00495,-0.052743,0.770693, 0.343013,
-1.99737,-0.128751,-1.18905,-0.998596,0.00495,-0.052743,0.796113, 0.479301,
-1.99654,0.040692,-1.18895,0.004525,0.99999,0.00032,0.774377, 0.482994,
-1.80224,0.039805,-1.16559,0.004525,0.99999,0.00032,0.752725, 0.486451,
-1.71648,0.039935,-2.78327,0.004525,0.99999,0.00032,0.744675, 0.361256,
-1.91174,0.040822,-2.79448,0.004525,0.99999,0.00032,0.760173, 0.35655,
-3.74611,0.040093,-2.9485,0.098538,0,-0.995133,0.515021, 0.550223,
-3.53596,0.040093,-2.92769,0.098538,0,-0.995133,0.493405, 0.547721,
-3.53596,-0.157551,-2.92769,0.098538,0,-0.995133,0.473314, 0.536182,
-3.74611,-0.157551,-2.9485,0.098538,0,-0.995133,0.53654, 0.524052,
-3.53596,0.040093,-2.92769,0.994892,0.001823,0.100933,0.493405, 0.547721,
-3.70091,0.040093,-1.30531,0.994892,0.001823,0.100933,0.502398, 0.67546,
-3.70023,-0.157551,-1.30487,0.994892,0.001823,0.100933,0.488775, 0.689838,
-3.53596,-0.157551,-2.92769,0.994892,0.001823,0.100933,0.473314, 0.536182,
-3.70091,0.040093,-1.30531,-0.098537,0.001888,0.995132,0.502398, 0.67546,
-3.91106,0.040093,-1.32612,-0.098537,0.001888,0.995132,0.521468, 0.672086,
-3.91038,-0.157551,-1.32568,-0.098537,0.001888,0.995132,0.53654, 0.694428,
-3.70023,-0.157551,-1.30487,-0.098537,0.001888,0.995132,0.488775, 0.689838,
-3.91106,0.040093,-1.32612,-0.994892,-0.001824,-0.100932,0.521468, 0.672086,
-3.74611,0.040093,-2.9485,-0.994892,-0.001824,-0.100932,0.515021, 0.550223,
-3.74611,-0.157551,-2.9485,-0.994892,-0.001824,-0.100932,0.53654, 0.524052,
-3.91038,-0.157551,-1.32568,-0.994892,-0.001824,-0.100932,0.53654, 0.694428,
-3.91106,0.040093,-1.32612,-0,1,0,0.521468, 0.672086,
-3.70091,0.040093,-1.30531,-0,1,0,0.502398, 0.67546,
-3.53596,0.040093,-2.92769,-0,1,0,0.493405, 0.547721,
-3.74611,0.040093,-2.9485,-0,1,0,0.515021, 0.550223,
0.098953,0.035155,3.11736,-0.999955,0,-0.009541,0.78011, 0.240652,
0.100916,0.035155,2.91159,-0.999955,0,-0.009541,0.76807, 0.262865,
0.100916,-0.134289,2.91159,-0.999955,0,-0.009541,0.748886, 0.246257,
0.098953,-0.134289,3.11736,-0.999955,0,-0.009541,0.769055, 0.222959,
2.00752,0.035155,2.84044,0.998879,-0,-0.047339,0.915215, 0.263409,
2.01748,0.035155,3.05057,0.998879,-0,-0.047339,0.905837, 0.242696,
2.01748,-0.134289,3.05057,0.998879,-0,-0.047339,0.911855, 0.222958,
2.00752,-0.134289,2.84044,0.998879,-0,-0.047339,0.936556, 0.246178,
2.01748,0.035155,3.05057,0.03479,0,0.999395,0.905837, 0.242696,
0.098953,0.035155,3.11736,0.03479,0,0.999395,0.78011, 0.240652,
0.098953,-0.134289,3.11736,0.03479,0,0.999395,0.769055, 0.222959,
2.01748,-0.134289,3.05057,0.03479,0,0.999395,0.911855, 0.222958,
2.01748,0.035155,3.05057,-0,1,0,0.905837, 0.242696,
2.00752,0.035155,2.84044,-0,1,0,0.915215, 0.263409,
0.100916,0.035155,2.91159,-0,1,0,0.76807, 0.262865,
0.098953,0.035155,3.11736,-0,1,0,0.78011, 0.240652,
-2.03388,0.03565,3.0317,-0.997407,0.004951,-0.071796,0.036858, 0.837139,
-2.0183,0.035656,2.81519,-0.997407,0.004951,-0.071796,0.026199, 0.854865,
-2.0192,-0.147828,2.81512,-0.997407,0.004951,-0.071796,0.008157, 0.839111,
-2.03479,-0.147835,3.03171,-0.997407,0.004951,-0.071796,0.028722, 0.820509,
-0.126386,0.03189,2.91492,0.999086,-0.014854,-0.040086,0.172821, 0.86776,
-0.119871,0.031832,3.1244,0.999086,-0.014854,-0.040086,0.16591, 0.842097,
-0.120501,-0.137611,3.12439,0.999086,-0.014854,-0.040086,0.172776, 0.820509,
-0.130633,-0.137553,2.91893,0.999086,-0.014854,-0.040086,0.199025, 0.848645,
-0.119871,0.031832,3.1244,-0.048366,0.000174,0.99883,0.16591, 0.842097,
-2.03388,0.03565,3.0317,-0.048366,0.000174,0.99883,0.036858, 0.837139,
-2.03479,-0.147835,3.03171,-0.048366,0.000174,0.99883,0.028722, 0.820509,
-0.120501,-0.137611,3.12439,-0.048366,0.000174,0.99883,0.172776, 0.820509,
-0.119871,0.031832,3.1244,0.001983,0.999998,0.000194,0.16591, 0.842097,
-0.126386,0.03189,2.91492,0.001983,0.999998,0.000194,0.172821, 0.86776,
-2.0183,0.035656,2.81519,0.001983,0.999998,0.000194,0.026199, 0.854865,
-2.03388,0.03565,3.0317,0.001983,0.999998,0.000194,0.036858, 0.837139,
1.9205,0.037513,1.0627,-0.065045,0.000405,-0.997882,0.576896, 0.36404,
2.13012,0.037513,1.0491,-0.065045,0.000405,-0.997882,0.555683, 0.366781,
2.12801,-0.131931,1.0491,-0.065045,0.000405,-0.997882,0.540078, 0.346678,
1.9205,-0.131931,1.0627,-0.065045,0.000405,-0.997882,0.59112, 0.351813,
2.13012,0.037513,1.0491,0.998195,-0.006217,-0.059741,0.555683, 0.366781,
2.24805,0.037513,3.0373,0.998195,-0.006217,-0.059741,0.562266, 0.498582,
2.24805,-0.131931,3.0373,0.998195,-0.006217,-0.059741,0.540078, 0.522966,
2.12801,-0.131931,1.0491,0.998195,-0.006217,-0.059741,0.540078, 0.346678,
2.24805,0.037513,3.0373,0.05213,0,0.99864,0.562266, 0.498582,
2.03207,0.037513,3.04857,0.05213,0,0.99864,0.586331, 0.500418,
2.03207,-0.131931,3.04857,0.05213,0,0.99864,0.606304, 0.510458,
2.24805,-0.131931,3.0373,0.05213,0,0.99864,0.540078, 0.522966,
2.03207,0.037513,3.04857,-0.998426,0,0.056093,0.586331, 0.500418,
1.9205,0.037513,1.0627,-0.998426,0,0.056093,0.576896, 0.36404,
1.9205,-0.131931,1.0627,-0.998426,0,0.056093,0.59112, 0.351813,
2.03207,-0.131931,3.04857,-0.998426,0,0.056093,0.606304, 0.510458,
2.03207,0.037513,3.04857,-0,1,0,0.586331, 0.500418,
2.24805,0.037513,3.0373,-0,1,0,0.562266, 0.498582,
2.13012,0.037513,1.0491,-0,1,0,0.555683, 0.366781,
1.9205,0.037513,1.0627,-0,1,0,0.576896, 0.36404,
-0.10826,0.032606,1.13972,-0.009783,0,-0.999952,0.656242, 0.366461,
0.09801,0.032606,1.1377,-0.009783,0,-0.999952,0.635772, 0.362829,
0.09801,-0.136838,1.1377,-0.009783,0,-0.999952,0.622331, 0.350334,
-0.10826,-0.136838,1.13972,-0.009783,0,-0.999952,0.672569, 0.346678,
0.09801,0.032606,1.1377,0.999997,0,0.002587,0.635772, 0.362829,
0.092892,0.037513,3.11604,0.999997,0,0.002587,0.630101, 0.49599,
0.092892,-0.131931,3.11604,0.999997,0,0.002587,0.606304, 0.517652,
0.09801,-0.136838,1.1377,0.999997,0,0.002587,0.622331, 0.350334,
0.092892,0.037513,3.11604,0.009778,0,0.999952,0.630101, 0.49599,
-0.113472,0.037513,3.11806,0.009778,0,0.999952,0.653271, 0.500218,
-0.113472,-0.131931,3.11806,0.009778,0,0.999952,0.672569, 0.512246,
0.092892,-0.131931,3.11604,0.009778,0,0.999952,0.606304, 0.517652,
-0.113472,0.037513,3.11806,-0.999996,0,-0.002634,0.653271, 0.500218,
-0.10826,0.032606,1.13972,-0.999996,0,-0.002634,0.656242, 0.366461,
-0.10826,-0.136838,1.13972,-0.999996,0,-0.002634,0.672569, 0.346678,
-0.113472,-0.131931,3.11806,-0.999996,0,-0.002634,0.672569, 0.512246,
-0.113472,0.037513,3.11806,-2.4e-005,0.999997,-0.00248,0.653271, 0.500218,
0.092892,0.037513,3.11604,-2.4e-005,0.999997,-0.00248,0.630101, 0.49599,
0.09801,0.032606,1.1377,-2.4e-005,0.999997,-0.00248,0.635772, 0.362829,
-0.10826,0.032606,1.13972,-2.4e-005,0.999997,-0.00248,0.656242, 0.366461,
-2.13034,0.040822,1.05246,0.057332,0.000114,-0.998355,0.050772, 0.404414,
-1.93508,0.039935,1.06368,0.057332,0.000114,-0.998355,0.027653, 0.405821,
-1.93592,-0.129508,1.06361,0.057332,0.000114,-0.998355,0.005, 0.380439,
-2.13118,-0.128621,1.05239,0.057332,0.000114,-0.998355,0.070896, 0.394876,
-1.93508,0.039935,1.06368,0.998282,-0.004956,0.058382,0.027653, 0.405821,
-2.05008,0.038231,3.02983,0.998282,-0.004956,0.058382,0.020873, 0.537354,
-2.05099,-0.145253,3.02979,0.998282,-0.004956,0.058382,0.005, 0.557813,
-1.93592,-0.129508,1.06361,0.998282,-0.004956,0.058382,0.005, 0.380439,
-2.05008,0.038231,3.02983,-0.03913,-2.5e-005,0.999234,0.020873, 0.537354,
-2.26183,0.039192,3.02153,-0.03913,-2.5e-005,0.999234,0.040963, 0.541168,
-2.26274,-0.144293,3.0215,-0.03913,-2.5e-005,0.999234,0.055316, 0.554541,
-2.05099,-0.145253,3.02979,-0.03913,-2.5e-005,0.999234,0.005, 0.557813,
-2.26183,0.039192,3.02153,-0.997766,0.004956,-0.066623,0.040963, 0.541168,
-2.13034,0.040822,1.05246,-0.997766,0.004956,-0.066623,0.050772, 0.404414,
-2.13118,-0.128621,1.05239,-0.997766,0.004956,-0.066623,0.070896, 0.394876,
-2.26274,-0.144293,3.0215,-0.997766,0.004956,-0.066623,0.055316, 0.554541,
-2.26183,0.039192,3.02153,0.004485,0.999989,0.001128,0.040963, 0.541168,
-2.05008,0.038231,3.02983,0.004485,0.999989,0.001128,0.020873, 0.537354,
-1.93508,0.039935,1.06368,0.004485,0.999989,0.001128,0.027653, 0.405821,
-2.13034,0.040822,1.05246,0.004485,0.999989,0.001128,0.050772, 0.404414,
-4.11683,0.040093,2.88317,-0.993044,0,-0.117741,0.042447, 0.796317,
-4.0926,0.040093,2.67882,-0.993044,0,-0.117741,0.02851, 0.820509,
-4.0926,-0.157551,2.67882,-0.993044,0,-0.117741,0.00507, 0.796194,
-4.11683,-0.157551,2.88317,-0.993044,0,-0.117741,0.030385, 0.771789,
-2.27303,0.045325,2.80039,0.999074,0,0.043028,0.178055, 0.820509,
-2.28256,0.045325,3.02178,0.999074,0,0.043028,0.168731, 0.802128,
-2.28256,-0.173384,3.02178,0.999074,0,0.043028,0.180014, 0.785036,
-2.27303,-0.173384,2.80039,0.999074,0,0.043028,0.199025, 0.804126,
-2.28256,0.045325,3.02178,-0.075351,1e-006,0.997157,0.168731, 0.802128,
-4.11683,0.040093,2.88317,-0.075351,1e-006,0.997157,0.042447, 0.796317,
-4.11683,-0.157551,2.88317,-0.075351,1e-006,0.997157,0.030385, 0.771789,
-2.28256,-0.173384,3.02178,-0.075351,1e-006,0.997157,0.180014, 0.785036,
-2.28256,0.045325,3.02178,-0.002848,0.999996,-0.000226,0.168731, 0.802128,
-2.27303,0.045325,2.80039,-0.002848,0.999996,-0.000226,0.178055, 0.820509,
-4.0926,0.040093,2.67882,-0.002848,0.999996,-0.000226,0.02851, 0.820509,
-4.11683,0.040093,2.88317,-0.002848,0.999996,-0.000226,0.042447, 0.796317,
0.146496,0.030886,5.17492,-0.999954,0,-0.009541,0.04271, 0.886964,
0.148814,0.030886,4.93197,-0.999954,0,-0.009541,0.029135, 0.911207,
0.148814,-0.169166,4.93197,-0.999954,0,-0.009541,0.008157, 0.893237,
0.146496,-0.169166,5.17492,-0.999954,0,-0.009541,0.029981, 0.86776,
2.12301,0.035155,4.83973,0.997875,-0,-0.065163,0.189448, 0.911644,
2.13856,0.035155,5.0778,0.997875,-0,-0.065163,0.178152, 0.888345,
2.13856,-0.134289,5.0778,0.997875,-0,-0.065163,0.18438, 0.86776,
2.12301,-0.134289,4.83973,0.997875,-0,-0.065163,0.211683, 0.894911,
2.13856,0.035155,5.0778,0.048693,0,0.998814,0.178152, 0.888345,
0.146496,0.030886,5.17492,0.048693,0,0.998814,0.04271, 0.886964,
0.146496,-0.169166,5.17492,0.048693,0,0.998814,0.029981, 0.86776,
2.13856,-0.134289,5.0778,0.048693,0,0.998814,0.18438, 0.86776,
2.13856,0.035155,5.0778,-0.00215,0.999998,5.9e-005,0.178152, 0.888345,
2.12301,0.035155,4.83973,-0.00215,0.999998,5.9e-005,0.189448, 0.911644,
0.148814,0.030886,4.93197,-0.00215,0.999998,5.9e-005,0.029135, 0.911207,
0.146496,0.030886,5.17492,-0.00215,0.999998,5.9e-005,0.04271, 0.886964,
-2.15393,0.03565,5.06642,-0.997407,0.004951,-0.071796,0.041613, 0.683889,
-2.13835,0.035656,4.8499,-0.997407,0.004951,-0.071796,0.031493, 0.710214,
-2.13926,-0.147828,4.84983,-0.997407,0.004951,-0.071796,0.00507, 0.686459,
-2.15484,-0.147835,5.06642,-0.997407,0.004951,-0.071796,0.036397, 0.65973,
-0.133875,0.02703,4.9281,0.999628,-0.014854,0.022858,0.189843, 0.710214,
-0.141761,0.026962,5.17541,0.999628,-0.014854,0.022858,0.179228, 0.690055,
-0.142503,-0.173088,5.17535,0.999628,-0.014854,0.022858,0.189728, 0.673279,
-0.139178,-0.17302,4.93251,0.999628,-0.014854,0.022858,0.209888, 0.695055,
-0.141761,0.026962,5.17541,-0.054071,7.1e-005,0.998537,0.179228, 0.690055,
-2.15393,0.03565,5.06642,-0.054071,7.1e-005,0.998537,0.041613, 0.683889,
-2.15484,-0.147835,5.06642,-0.054071,7.1e-005,0.998537,0.036397, 0.65973,
-0.142503,-0.173088,5.17535,-0.054071,7.1e-005,0.998537,0.189728, 0.673279,
-0.141761,0.026962,5.17541,0.004293,0.999991,0.000379,0.179228, 0.690055,
-0.133875,0.02703,4.9281,0.004293,0.999991,0.000379,0.189843, 0.710214,
-2.13835,0.035656,4.8499,0.004293,0.999991,0.000379,0.031493, 0.710214,
-2.15393,0.03565,5.06642,0.004293,0.999991,0.000379,0.041613, 0.683889,
2.03599,0.037513,3.06957,-0.047692,0.000297,-0.998862,0.313474, 0.384729,
2.24374,0.037513,3.0597,-0.047692,0.000297,-0.998862,0.29246, 0.387655,
2.24163,-0.131931,3.0597,-0.047692,0.000297,-0.998862,0.276778, 0.367557,
2.03599,-0.131931,3.06957,-0.047692,0.000297,-0.998862,0.327661, 0.37246,
2.24374,0.037513,3.0597,0.997972,-0.006215,-0.063353,0.29246, 0.387655,
2.36913,0.037513,5.05149,0.997972,-0.006215,-0.063353,0.299194, 0.519574,
2.36913,-0.131931,5.05149,0.997972,-0.006215,-0.063353,0.276778, 0.543961,
2.24163,-0.131931,3.0597,0.997972,-0.006215,-0.063353,0.276778, 0.367557,
2.36913,0.037513,5.05149,0.111864,0,0.993723,0.299194, 0.519574,
2.15315,0.037513,5.0758,0.111864,0,0.993723,0.323286, 0.52178,
2.15315,-0.131931,5.0758,0.111864,0,0.993723,0.343375, 0.531914,
2.36913,-0.131931,5.05149,0.111864,0,0.993723,0.276778, 0.543961,
2.15315,0.037513,5.0758,-0.998299,0,0.058297,0.323286, 0.52178,
2.03599,0.037513,3.06957,-0.998299,0,0.058297,0.313474, 0.384729,
2.03599,-0.131931,3.06957,-0.998299,0,0.058297,0.327661, 0.37246,
2.15315,-0.131931,5.0758,-0.998299,0,0.058297,0.343375, 0.531914,
2.15315,0.037513,5.0758,-0,1,0,0.323286, 0.52178,
2.36913,0.037513,5.05149,-0,1,0,0.299194, 0.519574,
2.24374,0.037513,3.0597,-0,1,0,0.29246, 0.387655,
2.03599,0.037513,3.06957,-0,1,0,0.313474, 0.384729,
-0.104596,0.037513,3.14325,-0.009778,0,-0.999952,0.183412, 0.022744,
0.101769,0.037513,3.14123,-0.009778,0,-0.999952,0.158823, 0.018396,
0.101769,-0.131931,3.14123,-0.009778,0,-0.999952,0.138315, 0.005865,
-0.104596,-0.131931,3.14325,-0.009778,0,-0.999952,0.208678, 0,
0.101769,0.037513,3.14123,0.999934,0,-0.011508,0.158823, 0.018396,
0.125174,0.033669,5.17493,0.999934,0,-0.011508,0.155559, 0.159089,
0.125174,-0.166382,5.17493,0.999934,0,-0.011508,0.138315, 0.181404,
0.101769,-0.131931,3.14123,0.999934,0,-0.011508,0.138315, 0.005865,
0.125174,0.033669,5.17493,0.009777,0,0.999952,0.155559, 0.159089,
-0.118466,0.033669,5.17731,0.009777,0,0.999952,0.177368, 0.163223,
-0.118466,-0.166382,5.17731,0.009777,0,0.999952,0.191621, 0.177502,
0.125174,-0.166382,5.17493,0.009777,0,0.999952,0.138315, 0.181404,
-0.118466,0.033669,5.17731,-0.999977,0,-0.006819,0.177368, 0.163223,
-0.104596,0.037513,3.14325,-0.999977,0,-0.006819,0.183412, 0.022744,
-0.104596,-0.131931,3.14325,-0.999977,0,-0.006819,0.208678, 0,
-0.118466,-0.166382,5.17731,-0.999977,0,-0.006819,0.191621, 0.177502,
-0.118466,0.033669,5.17731,1.8e-005,0.999998,0.00189,0.177368, 0.163223,
0.125174,0.033669,5.17493,1.8e-005,0.999998,0.00189,0.155559, 0.159089,
0.101769,0.037513,3.14123,1.8e-005,0.999998,0.00189,0.158823, 0.018396,
-0.104596,0.037513,3.14325,1.8e-005,0.999998,0.00189,0.183412, 0.022744,
-2.25553,0.040822,3.041,0.057332,0.000114,-0.998355,0.465018, 0.02772,
-2.06026,0.039935,3.05221,0.057332,0.000114,-0.998355,0.441707, 0.029142,
-2.0611,-0.129508,3.05215,0.057332,0.000114,-0.998355,0.418775, 0.003648,
-2.25636,-0.128621,3.04093,0.057332,0.000114,-0.998355,0.485355, 0.018187,
-2.06026,0.039935,3.05221,0.998501,-0.004956,0.054509,0.441707, 0.029142,
-2.17013,0.038231,5.06454,0.998501,-0.004956,0.054509,0.434822, 0.162483,
-2.17104,-0.145253,5.0645,0.998501,-0.004956,0.054509,0.418775, 0.182963,
-2.0611,-0.129508,3.05215,0.998501,-0.004956,0.054509,0.418775, 0.003648,
-2.17013,0.038231,5.06454,-0.03913,-2.6e-005,0.999234,0.434822, 0.162483,
-2.38188,0.039192,5.05624,-0.03913,-2.6e-005,0.999234,0.455124, 0.166265,
-2.38279,-0.144293,5.0562,-0.03913,-2.6e-005,0.999234,0.469649, 0.17963,
-2.17104,-0.145253,5.0645,-0.03913,-2.6e-005,0.999234,0.418775, 0.182963,
-2.38188,0.039192,5.05624,-0.998028,0.004956,-0.062573,0.455124, 0.166265,
-2.25553,0.040822,3.041,-0.998028,0.004956,-0.062573,0.465018, 0.02772,
-2.25636,-0.128621,3.04093,-0.998028,0.004956,-0.062573,0.485355, 0.018187,
-2.38279,-0.144293,5.0562,-0.998028,0.004956,-0.062573,0.469649, 0.17963,
-2.38188,0.039192,5.05624,0.004486,0.999989,0.001091,0.455124, 0.166265,
-2.17013,0.038231,5.06454,0.004486,0.999989,0.001091,0.434822, 0.162483,
-2.06026,0.039935,3.05221,0.004486,0.999989,0.001091,0.441707, 0.029142,
-2.25553,0.040822,3.041,0.004486,0.999989,0.001091,0.465018, 0.02772,
-4.24201,0.040093,4.87171,-0.993044,0,-0.117741,0.570198, 0.90373,
-4.21778,0.040093,4.66735,-0.993044,0,-0.117741,0.557525, 0.923899,
-4.21778,-0.157551,4.66735,-0.993044,0,-0.117741,0.53654, 0.90386,
-4.24201,-0.157551,4.87171,-0.993044,0,-0.117741,0.557405, 0.882011,
-2.39308,0.045325,4.8351,0.999074,0,0.043028,0.70765, 0.924182,
-2.40261,0.045325,5.05649,0.999074,0,0.043028,0.699439, 0.901928,
-2.40261,-0.173384,5.05649,0.999074,0,0.043028,0.709215, 0.882011,
-2.39308,-0.173384,4.8351,0.999074,0,0.043028,0.732484, 0.903763,
-2.40261,0.045325,5.05649,-0.099955,1e-006,0.994992,0.699439, 0.901928,
-4.24201,0.040093,4.87171,-0.099955,1e-006,0.994992,0.570198, 0.90373,
-4.24201,-0.157551,4.87171,-0.099955,1e-006,0.994992,0.557405, 0.882011,
-2.40261,-0.173384,5.05649,-0.099955,1e-006,0.994992,0.709215, 0.882011,
-2.40261,0.045325,5.05649,-0.002834,0.999996,-0.000225,0.699439, 0.901928,
-2.39308,0.045325,4.8351,-0.002834,0.999996,-0.000225,0.70765, 0.924182,
-4.21778,0.040093,4.66735,-0.002834,0.999996,-0.000225,0.557525, 0.923899,
-4.24201,0.040093,4.87171,-0.002834,0.999996,-0.000225,0.570198, 0.90373,
-6.89242,0.040104,-5.42065,0.204334,0,-0.978901,0.767996, 0.541521,
-6.6857,0.040104,-5.37749,0.204334,0,-0.978901,0.747501, 0.538282,
-6.6857,-0.15754,-5.37749,0.204334,0,-0.978901,0.729084, 0.525129,
-6.89242,-0.15754,-5.42065,0.204334,0,-0.978901,0.785006, 0.517652,
-6.6857,0.040104,-5.37749,0.976045,0,0.217569,0.747501, 0.538282,
-7.05938,0.040104,-3.7011,0.976045,0,0.217569,0.746093, 0.670453,
-7.05938,-0.15754,-3.7011,0.976045,0,0.217569,0.729084, 0.694329,
-6.6857,-0.15754,-5.37749,0.976045,0,0.217569,0.729084, 0.525129,
-7.05938,0.040104,-3.7011,-0.204334,0,0.978901,0.746093, 0.670453,
-7.2661,0.040104,-3.74425,-0.204334,0,0.978901,0.766598, 0.673684,
-7.2661,-0.15754,-3.74425,-0.204334,0,0.978901,0.785006, 0.686852,
-7.05938,-0.15754,-3.7011,-0.204334,0,0.978901,0.729084, 0.694329,
-7.2661,0.040104,-3.74425,-0.976045,0,-0.217569,0.766598, 0.673684,
-6.89242,0.040104,-5.42065,-0.976045,0,-0.217569,0.767996, 0.541521,
-6.89242,-0.15754,-5.42065,-0.976045,0,-0.217569,0.785006, 0.517652,
-7.2661,-0.15754,-3.74425,-0.976045,0,-0.217569,0.785006, 0.686852,
-7.2661,0.040104,-3.74425,-0,1,0,0.766598, 0.673684,
-7.05938,0.040104,-3.7011,-0,1,0,0.746093, 0.670453,
-6.6857,0.040104,-5.37749,-0,1,0,0.747501, 0.538282,
-6.89242,0.040104,-5.42065,-0,1,0,0.767996, 0.541521,
-8.68262,0.043413,-5.78994,0.269333,9.9e-005,-0.963047,0.391382, 0.400228,
-8.49426,0.042526,-5.73726,0.269333,9.9e-005,-0.963047,0.373202, 0.396936,
-8.49507,-0.155117,-5.73751,0.269333,9.9e-005,-0.963047,0.359503, 0.382672,
-8.68342,-0.15423,-5.79018,0.269333,9.9e-005,-0.963047,0.40653, 0.378098,
-8.49426,0.042526,-5.73726,0.965474,-0.004243,0.260463,0.373202, 0.396936,
-8.92737,0.042395,-4.13185,0.965474,-0.004243,0.260463,0.364109, 0.52573,
-8.92816,-0.155247,-4.13213,0.965474,-0.004243,0.260463,0.343918, 0.537238,
-8.49507,-0.155117,-5.73751,0.965474,-0.004243,0.260463,0.359503, 0.382672,
-8.92737,0.042395,-4.13185,-0.260744,-0.000325,0.965408,0.364109, 0.52573,
-9.12008,0.043282,-4.1839,-0.260744,-0.000325,0.965408,0.384974, 0.5232,
-9.12087,-0.15436,-4.18418,-0.260744,-0.000325,0.965408,0.40653, 0.549112,
-8.92816,-0.155247,-4.13213,-0.260744,-0.000325,0.965408,0.343918, 0.537238,
-9.12008,0.043282,-4.1839,-0.964839,0.004244,-0.262807,0.384974, 0.5232,
-8.68262,0.043413,-5.78994,-0.964839,0.004244,-0.262807,0.391382, 0.400228,
-8.68342,-0.15423,-5.79018,-0.964839,0.004244,-0.262807,0.40653, 0.378098,
-9.12087,-0.15436,-4.18418,-0.964839,0.004244,-0.262807,0.40653, 0.549112,
-9.12008,0.043282,-4.1839,0.004311,0.99999,0.00125,0.384974, 0.5232,
-8.92737,0.042395,-4.13185,0.004311,0.99999,0.00125,0.364109, 0.52573,
-8.49426,0.042526,-5.73726,0.004311,0.99999,0.00125,0.373202, 0.396936,
-8.68262,0.043413,-5.78994,0.004311,0.99999,0.00125,0.391382, 0.400228,
-0.111807,0.037513,-2.82575,-0.008374,0,-0.999965,0.728701, 0.028318,
0.094558,0.037513,-2.82748,-0.008374,0,-0.999965,0.709999, 0.024844,
0.094558,-0.131931,-2.82748,-0.008374,0,-0.999965,0.695501, 0.013198,
-0.111807,-0.131931,-2.82575,-0.008374,0,-0.999965,0.746759, 0.007037,
0.094558,0.037513,-2.82748,0.99991,0,-0.013438,0.709999, 0.024844,
0.117963,0.033669,-1.08584,0.99991,0,-0.013438,0.702685, 0.163308,
0.117963,-0.166382,-1.08584,0.99991,0,-0.013438,0.6831, 0.162236,
0.094558,-0.131931,-2.82748,0.99991,0,-0.013438,0.695501, 0.013198,
-0.100015,0.033669,-1.0838,-0.999977,0,0.006769,0.726073, 0.164239,
-0.111807,0.037513,-2.82575,-0.999977,0,0.006769,0.728701, 0.028318,
-0.111807,-0.131931,-2.82575,-0.999977,0,0.006769,0.746759, 0.007037,
-0.100015,-0.166382,-1.0838,-0.999977,0,0.006769,0.746759, 0.164826,
-0.100015,0.033669,-1.0838,2e-005,0.999998,0.002207,0.726073, 0.164239,
0.117963,0.033669,-1.08584,2e-005,0.999998,0.002207,0.702685, 0.163308,
0.094558,0.037513,-2.82748,2e-005,0.999998,0.002207,0.709999, 0.024844,
-0.111807,0.037513,-2.82575,2e-005,0.999998,0.002207,0.728701, 0.028318,
0.090191,0.037513,-4.73758,0.999998,0,-0.002089,0.430955, 0.183162,
0.094146,0.033669,-2.84436,0.999998,0,-0.002089,0.422471, 0.32486,
0.094146,-0.166382,-2.84436,0.999998,0,-0.002089,0.40653, 0.346678,
0.090191,-0.131931,-4.73758,0.999998,0,-0.002089,0.40653, 0.182963,
0.094146,0.033669,-2.84436,0.02054,0,0.999789,0.422471, 0.32486,
-0.112776,0.033669,-2.84011,0.02054,0,0.999789,0.438955, 0.330073,
-0.112776,-0.166382,-2.84011,0.02054,0,0.999789,0.450955, 0.345534,
0.094146,-0.166382,-2.84436,0.02054,0,0.999789,0.40653, 0.346678,
-0.112776,0.033669,-2.84011,-0.999998,0,0.001792,0.438955, 0.330073,
-0.116173,0.037513,-4.73585,-0.999998,0,0.001792,0.455244, 0.185723,
-0.116173,-0.131931,-4.73585,-0.999998,0,0.001792,0.479708, 0.190065,
-0.112776,-0.166382,-2.84011,-0.999998,0,0.001792,0.450955, 0.345534,
-0.112776,0.033669,-2.84011,2.9e-005,0.999998,0.002029,0.438955, 0.330073,
0.094146,0.033669,-2.84436,2.9e-005,0.999998,0.002029,0.422471, 0.32486,
0.090191,0.037513,-4.73758,2.9e-005,0.999998,0.002029,0.430955, 0.183162,
-0.116173,0.037513,-4.73585,2.9e-005,0.999998,0.002029,0.455244, 0.185723,
-0.125881,0.037513,-2.94019,0.999961,0,-0.008841,0.481372, 0.756252,
-0.124056,0.037513,-2.73383,0.999961,0,-0.008841,0.485866, 0.734673,
-0.124056,-0.131931,-2.73383,0.999961,0,-0.008841,0.498075, 0.716779,
-0.125881,-0.131931,-2.94019,0.999961,0,-0.008841,0.502971, 0.778212,
-0.124056,0.037513,-2.73383,-0.043712,1e-006,0.999044,0.485866, 0.734673,
-1.69736,0.033669,-2.80267,-0.043712,1e-006,0.999044,0.365943, 0.73207,
-1.69736,-0.166382,-2.80267,-0.043712,1e-006,0.999044,0.343918, 0.716779,
-0.124056,-0.131931,-2.73383,-0.043712,1e-006,0.999044,0.498075, 0.716779,
-1.69736,0.033669,-2.80267,-0.997595,0,-0.069308,0.365943, 0.73207,
-1.68225,0.033669,-3.02013,-0.997595,0,-0.069308,0.36208, 0.750644,
-1.68225,-0.166382,-3.02013,-0.997595,0,-0.069308,0.347731, 0.763359,
-1.69736,-0.166382,-2.80267,-0.997595,0,-0.069308,0.343918, 0.716779,
-1.68225,0.033669,-3.02013,0.051295,0,-0.998684,0.36208, 0.750644,
-0.125881,0.037513,-2.94019,0.051295,0,-0.998684,0.481372, 0.756252,
-0.125881,-0.131931,-2.94019,0.051295,0,-0.998684,0.502971, 0.778212,
-1.68225,-0.166382,-3.02013,0.051295,0,-0.998684,0.347731, 0.763359,
-1.68225,0.033669,-3.02013,-0.002453,0.999997,-7.7e-005,0.36208, 0.750644,
-1.69736,0.033669,-2.80267,-0.002453,0.999997,-7.7e-005,0.365943, 0.73207,
-0.124056,0.037513,-2.73383,-0.002453,0.999997,-7.7e-005,0.485866, 0.734673,
-0.125881,0.037513,-2.94019,-0.002453,0.999997,-7.7e-005,0.481372, 0.756252,
1.68431,0.037513,-3.0046,0.998695,0,-0.051064,0.143734, 0.749643,
1.69485,0.037513,-2.79849,0.998695,0,-0.051064,0.147645, 0.72806,
1.69485,-0.131931,-2.79849,0.998695,0,-0.051064,0.159245, 0.710214,
1.68431,-0.131931,-3.0046,0.998695,0,-0.051064,0.166212, 0.771789,
1.69485,0.037513,-2.79849,0.041999,0,0.999118,0.147645, 0.72806,
0.113947,0.033669,-2.73204,0.041999,0,0.999118,0.027515, 0.725585,
0.113947,-0.166382,-2.73204,0.041999,0,0.999118,0.00507, 0.710214,
1.69485,-0.131931,-2.79849,0.041999,0,0.999118,0.159245, 0.710214,
0.113947,0.033669,-2.73204,-0.999952,0,0.009826,0.027515, 0.725585,
0.111805,0.033669,-2.95002,-0.999952,0,0.009826,0.02427, 0.744457,
0.111805,-0.166382,-2.95002,-0.999952,0,0.009826,0.010299, 0.757296,
0.113947,-0.166382,-2.73204,-0.999952,0,0.009826,0.00507, 0.710214,
0.111805,0.033669,-2.95002,-0.034688,0,-0.999398,0.02427, 0.744457,
1.68431,0.037513,-3.0046,-0.034688,0,-0.999398,0.143734, 0.749643,
1.68431,-0.131931,-3.0046,-0.034688,0,-0.999398,0.166212, 0.771789,
0.111805,-0.166382,-2.95002,-0.034688,0,-0.999398,0.010299, 0.757296,
0.111805,0.033669,-2.95002,-0.002435,0.999997,7.3e-005,0.02427, 0.744457,
0.113947,0.033669,-2.73204,-0.002435,0.999997,7.3e-005,0.027515, 0.725585,
1.69485,0.037513,-2.79849,-0.002435,0.999997,7.3e-005,0.147645, 0.72806,
1.68431,0.037513,-3.0046,-0.002435,0.999997,7.3e-005,0.143734, 0.749643,
1.83494,0.037513,-4.77197,0.999215,0,-0.039625,0.765938, 0.017307,
1.90381,0.033669,-3.03525,0.999215,0,-0.039625,0.765937, 0.163575,
1.90381,-0.166382,-3.03525,0.999215,0,-0.039625,0.746759, 0.164198,
1.83494,-0.131931,-4.77197,0.999215,0,-0.039625,0.74676, 0.017902,
1.69717,0.033669,-3.02364,-0.999228,0,0.039299,0.785145, 0.164135,
1.62877,0.037513,-4.7629,-0.999228,0,0.039299,0.785149, 0.017634,
1.62877,-0.131931,-4.7629,-0.999228,0,0.039299,0.804333, 0.018325,
1.69717,-0.166382,-3.02364,-0.999228,0,0.039299,0.804333, 0.164826,
1.69717,0.033669,-3.02364,0.000111,0.999998,0.002207,0.785145, 0.164135,
1.90381,0.033669,-3.03525,0.000111,0.999998,0.002207,0.765937, 0.163575,
1.83494,0.037513,-4.77197,0.000111,0.999998,0.002207,0.765938, 0.017307,
1.62877,0.037513,-4.7629,0.000111,0.999998,0.002207,0.785149, 0.017634,
2.14926,0.035155,1.03037,-0.998195,0,0.060056,0.762862, 0.76032,
2.13576,0.035155,0.80607,-0.998195,0,0.060056,0.749526, 0.777569,
2.13576,-0.134289,0.80607,-0.998195,0,0.060056,0.734825, 0.764215,
2.14926,-0.134289,1.03037,-0.998195,0,0.060056,0.752534, 0.744721,
3.92252,0.035155,0.652491,0.99226,-0,-0.124179,0.894393, 0.791216,
3.9493,0.035155,0.866503,0.99226,-0,-0.124179,0.88654, 0.765749,
3.9493,-0.134289,0.866503,0.99226,-0,-0.124179,0.893286, 0.744721,
3.92252,-0.134289,0.652492,0.99226,-0,-0.124179,0.919862, 0.772956,
3.9493,0.035155,0.866503,0.090659,0,0.995882,0.88654, 0.765749,
2.14926,0.035155,1.03037,0.090659,0,0.995882,0.762862, 0.76032,
2.14926,-0.134289,1.03037,0.090659,0,0.995882,0.752534, 0.744721,
3.9493,-0.134289,0.866503,0.090659,0,0.995882,0.893286, 0.744721,
3.9493,0.035155,0.866503,-0,1,0,0.88654, 0.765749,
3.92252,0.035155,0.652491,-0,1,0,0.894393, 0.791216,
2.13576,0.035155,0.80607,-0,1,0,0.749526, 0.777569,
2.14926,0.035155,1.03037,-0,1,0,0.762862, 0.76032,
3.74116,0.037513,-1.28737,-0.102048,0.000444,-0.994779,0.314189, 0.016139,
3.94349,0.037513,-1.30806,-0.102048,0.000444,-0.994779,0.293076, 0.019626,
3.94138,-0.131931,-1.30799,-0.102048,0.000444,-0.994779,0.276778, 0,
3.74116,-0.131931,-1.28737,-0.102048,0.000444,-0.994779,0.329044, 0.003514,
3.94349,0.037513,-1.30806,0.99424,-0.006211,-0.107,0.293076, 0.019626,
4.17386,0.037699,0.842277,0.99424,-0.006211,-0.107,0.300031, 0.157341,
4.17386,-0.131746,0.842277,0.99424,-0.006211,-0.107,0.276778, 0.182963,
3.94138,-0.131931,-1.30799,0.99424,-0.006211,-0.107,0.276778, 0,
4.17386,0.037699,0.842277,0.103133,0,0.994668,0.300031, 0.157341,
3.96382,0.037513,0.864055,0.103133,0,0.994668,0.324703, 0.15853,
3.96382,-0.131931,0.864055,0.103133,0,0.994668,0.345174, 0.167878,
4.17386,-0.131746,0.842277,0.103133,0,0.994668,0.276778, 0.182963,
3.96382,0.037513,0.864055,-0.994687,0,0.102945,0.324703, 0.15853,
3.74116,0.037513,-1.28737,-0.994687,0,0.102945,0.314189, 0.016139,
3.74116,-0.131931,-1.28737,-0.994687,0,0.102945,0.329044, 0.003514,
3.96382,-0.131931,0.864055,-0.994687,0,0.102945,0.345174, 0.167878,
3.96382,0.037513,0.864055,-0.000449,1,4e-006,0.324703, 0.15853,
4.17386,0.037699,0.842277,-0.000449,1,4e-006,0.300031, 0.157341,
3.94349,0.037513,-1.30806,-0.000449,1,4e-006,0.293076, 0.019626,
3.74116,0.037513,-1.28737,-0.000449,1,4e-006,0.314189, 0.016139,
2.26542,0.035155,3.03265,-0.99746,0,0.071232,0.567743, 0.941862,
2.25077,0.035155,2.82739,-0.99746,0,0.071232,0.555365, 0.963824,
2.25077,-0.134289,2.82739,-0.99746,0,0.071232,0.53654, 0.947045,
2.26542,-0.134289,3.03265,-0.99746,0,0.071232,0.556917, 0.924182,
4.14321,0.035155,2.68008,0.997347,-0,-0.072789,0.702088, 0.964241,
4.15826,0.035155,2.88627,0.997347,-0,-0.072789,0.692689, 0.943882,
4.15826,-0.134289,2.88627,0.997347,-0,-0.072789,0.698675, 0.924182,
4.14321,-0.134289,2.68008,0.997347,-0,-0.072789,0.723179, 0.946733,
4.15826,0.035155,2.88627,0.077108,0,0.997023,0.692689, 0.943882,
2.26542,0.035155,3.03265,0.077108,0,0.997023,0.567743, 0.941862,
2.26542,-0.134289,3.03265,0.077108,0,0.997023,0.556917, 0.924182,
4.15826,-0.134289,2.88627,0.077108,0,0.997023,0.698675, 0.924182,
4.15826,0.035155,2.88627,-0,1,0,0.692689, 0.943882,
4.14321,0.035155,2.68008,-0,1,0,0.702088, 0.964241,
2.25077,0.035155,2.82739,-0,1,0,0.555365, 0.963824,
2.26542,0.035155,3.03265,-0,1,0,0.567743, 0.941862,
3.96619,0.038227,0.890058,-0.095748,0.000404,-0.995406,0.316462, 0.563129,
4.17528,0.038227,0.870013,-0.095748,0.000404,-0.995406,0.293476, 0.565181,
4.17317,-0.131217,0.870079,-0.095748,0.000404,-0.995406,0.276778, 0.543961,
3.96619,-0.131217,0.890058,-0.095748,0.000404,-0.995406,0.334993, 0.551646,
4.17528,0.038227,0.870013,0.994398,-0.006212,-0.105514,0.293476, 0.565181,
4.38566,0.037513,2.86264,0.994398,-0.006212,-0.105514,0.297382, 0.698848,
4.38566,-0.131931,2.86264,0.994398,-0.006212,-0.105514,0.276778, 0.721444,
4.17317,-0.131217,0.870079,0.994398,-0.006212,-0.105514,0.276778, 0.543961,
4.38566,0.037513,2.86264,0.099009,0,0.995086,0.297382, 0.698848,
4.17278,0.037513,2.88382,0.099009,0,0.995086,0.319771, 0.701337,
4.17278,-0.131931,2.88382,0.099009,0,0.995086,0.335518, 0.712332,
4.38566,-0.131931,2.86264,0.099009,0,0.995086,0.276778, 0.721444,
4.17278,0.037513,2.88382,-0.994674,0,0.103068,0.319771, 0.701337,
3.96619,0.038227,0.890058,-0.994674,0,0.103068,0.316462, 0.563129,
3.96619,-0.131217,0.890058,-0.994674,0,0.103068,0.334993, 0.551646,
4.17278,-0.131931,2.88382,-0.994674,0,0.103068,0.335518, 0.712332,
4.17278,0.037513,2.88382,3.5e-005,1,0.000355,0.319771, 0.701337,
4.38566,0.037513,2.86264,3.5e-005,1,0.000355,0.297382, 0.698848,
4.17528,0.038227,0.870013,3.5e-005,1,0.000355,0.293476, 0.565181,
3.96619,0.038227,0.890058,3.5e-005,1,0.000355,0.316462, 0.563129,
2.38485,0.030886,5.05233,-0.999774,0,0.021262,0.571101, 0.857325,
2.37969,0.030886,4.80943,-0.999774,0,0.021262,0.557518, 0.881574,
2.37969,-0.169166,4.80943,-0.999774,0,0.021262,0.53654, 0.863604,
2.38485,-0.169166,5.05233,-0.999774,0,0.021262,0.558364, 0.838127,
4.35011,0.035155,4.65643,0.995394,-1e-006,-0.095865,0.717831, 0.882011,
4.37298,0.035155,4.89391,0.995394,-1e-006,-0.095865,0.706535, 0.858724,
4.37298,-0.134289,4.89391,0.995394,-1e-006,-0.095865,0.712763, 0.838127,
4.35011,-0.134289,4.65643,0.995394,-1e-006,-0.095865,0.740066, 0.865278,
4.37298,0.035155,4.89391,0.079432,0,0.99684,0.706535, 0.858724,
2.38485,0.030886,5.05233,0.079432,0,0.99684,0.571101, 0.857325,
2.38485,-0.169166,5.05233,0.079432,0,0.99684,0.558364, 0.838127,
4.37298,-0.134289,4.89391,0.079432,0,0.99684,0.712763, 0.838127,
4.37298,0.035155,4.89391,-0.002147,0.999998,0.000125,0.706535, 0.858724,
4.35011,0.035155,4.65643,-0.002147,0.999998,0.000125,0.717831, 0.882011,
2.37969,0.030886,4.80943,-0.002147,0.999998,0.000125,0.557518, 0.881574,
2.38485,0.030886,5.05233,-0.002147,0.999998,0.000125,0.571101, 0.857325,
4.18299,0.037513,2.90637,-0.095748,0.000404,-0.995405,0.175054, 0.394123,
4.39208,0.037513,2.88632,-0.095748,0.000404,-0.995405,0.153933, 0.397002,
4.38997,-0.131931,2.88639,-0.095748,0.000404,-0.995405,0.138315, 0.376903,
4.18299,-0.131931,2.90637,-0.095748,0.000404,-0.995405,0.189212, 0.381853,
4.39208,0.037513,2.88632,0.994285,-0.00621,-0.106574,0.153933, 0.397002,
4.60263,0.037513,4.86051,0.994285,-0.00621,-0.106574,0.160635, 0.528582,
4.60263,-0.131931,4.86051,0.994285,-0.00621,-0.106574,0.138315, 0.552966,
4.38997,-0.131931,2.88639,0.994285,-0.00621,-0.106574,0.138315, 0.376903,
4.60263,0.037513,4.86051,0.142417,0,0.989807,0.160635, 0.528582,
4.3875,0.037513,4.89146,0.142417,0,0.989807,0.184727, 0.530696,
4.3875,-0.131931,4.89146,0.142417,0,0.989807,0.204769, 0.540814,
4.60263,-0.131931,4.86051,0.142417,0,0.989807,0.138315, 0.552966,
4.3875,0.037513,4.89146,-0.994735,0,0.102482,0.184727, 0.530696,
4.18299,0.037513,2.90637,-0.994735,0,0.102482,0.175054, 0.394123,
4.18299,-0.131931,2.90637,-0.994735,0,0.102482,0.189212, 0.381853,
4.3875,-0.131931,4.89146,-0.994735,0,0.102482,0.204769, 0.540814,
4.3875,0.037513,4.89146,-0,1,0,0.184727, 0.530696,
4.60263,0.037513,4.86051,-0,1,0,0.160635, 0.528582,
4.39208,0.037513,2.88632,-0,1,0,0.153933, 0.397002,
4.18299,0.037513,2.90637,-0,1,0,0.175054, 0.394123,
4.18856,0.035155,0.834945,-0.995496,0,0.094801,0.768652, 0.80866,
4.16905,0.035155,0.630089,-0.995496,0,0.094801,0.756242, 0.825018,
4.16905,-0.134289,0.630089,-0.995496,0,0.094801,0.741531, 0.811049,
4.18856,-0.134289,0.834945,-0.995496,0,0.094801,0.758496, 0.793182,
5.92092,0.035155,0.406181,0.984119,0,-0.177508,0.895632, 0.838127,
5.95642,0.035155,0.602988,0.984119,0,-0.177508,0.889092, 0.814049,
5.95642,-0.134289,0.602988,0.984119,0,-0.177508,0.89595, 0.793182,
5.92092,-0.134289,0.406181,0.984119,0,-0.177508,0.921216, 0.819621,
5.95642,0.035155,0.602988,0.130092,0,0.991502,0.889092, 0.814049,
4.18856,0.035155,0.834945,0.130092,0,0.991502,0.768652, 0.80866,
4.18856,-0.134289,0.834945,0.130092,0,0.991502,0.758496, 0.793182,
5.95642,-0.134289,0.602988,0.130092,0,0.991502,0.89595, 0.793182,
5.95642,0.035155,0.602988,-0,1,0,0.889092, 0.814049,
5.92092,0.035155,0.406181,-0,1,0,0.895632, 0.838127,
4.16905,0.035155,0.630089,-0,1,0,0.756242, 0.825018,
4.18856,0.035155,0.834945,-0,1,0,0.768652, 0.80866,
5.65957,0.014469,-1.35149,-0.174473,0.000472,-0.984662,0.642954, 0.533677,
5.85965,0.014469,-1.38687,-0.174473,0.000472,-0.984662,0.621161, 0.53598,
5.85763,-0.131931,-1.38665,-0.174473,0.000472,-0.984662,0.606304, 0.517652,
5.65957,-0.131931,-1.35149,-0.174473,0.000472,-0.984662,0.656502, 0.522713,
5.85965,0.014469,-1.38687,0.986021,-0.006451,-0.166494,0.621161, 0.53598,
6.18797,0.037513,0.56316,0.986021,-0.006451,-0.166494,0.627923, 0.664313,
6.18797,-0.131931,0.56316,0.986021,-0.006451,-0.166494,0.606304, 0.688095,
5.85763,-0.131931,-1.38665,0.986021,-0.006451,-0.166494,0.606304, 0.517652,
6.18797,0.037513,0.56316,0.182504,0,0.983205,0.627923, 0.664313,
5.97427,0.037513,0.602827,0.182504,0,0.983205,0.651338, 0.666352,
5.97427,-0.131931,0.602827,0.182504,0,0.983205,0.670785, 0.676252,
6.18797,-0.131931,0.56316,0.182504,0,0.983205,0.606304, 0.688095,
5.97427,0.037513,0.602827,-0.987282,0,0.158978,0.651338, 0.666352,
5.65957,0.014469,-1.35149,-0.987282,0,0.158978,0.642954, 0.533677,
5.65957,-0.131931,-1.35149,-0.987282,0,0.158978,0.656502, 0.522713,
5.97427,-0.131931,0.602827,-0.987282,0,0.158978,0.670785, 0.676252,
5.97427,0.037513,0.602827,-0.002079,0.999932,-0.011461,0.651338, 0.666352,
6.18797,0.037513,0.56316,-0.002079,0.999932,-0.011461,0.627923, 0.664313,
5.85965,0.014469,-1.38687,-0.002079,0.999932,-0.011461,0.621161, 0.53598,
5.65957,0.014469,-1.35149,-0.002079,0.999932,-0.011461,0.642954, 0.533677,
4.41222,0.035155,2.8518,-0.995496,0,0.094801,0.344267, 0.937476,
4.39272,0.035155,2.64695,-0.995496,0,0.094801,0.332113, 0.959624,
4.39272,-0.134289,2.64695,-0.995496,0,0.094801,0.313041, 0.94298,
4.41222,-0.134289,2.8518,-0.995496,0,0.094801,0.333254, 0.919818,
6.24961,0.035155,2.39111,0.988301,-0,-0.152519,0.478672, 0.960056,
6.28245,0.035155,2.60391,0.988301,-0,-0.152519,0.469104, 0.93928,
6.28245,-0.134289,2.60391,0.988301,-0,-0.152519,0.475232, 0.919818,
6.24961,-0.134289,2.39111,0.988301,-0,-0.152519,0.499823, 0.943338,
6.28245,0.035155,2.60391,0.131398,0,0.99133,0.469104, 0.93928,
4.41222,0.035155,2.8518,0.131398,0,0.99133,0.344267, 0.937476,
4.41222,-0.134289,2.8518,0.131398,0,0.99133,0.333254, 0.919818,
6.28245,-0.134289,2.60391,0.131398,0,0.99133,0.475232, 0.919818,
6.28245,0.035155,2.60391,-0,1,0,0.469104, 0.93928,
6.24961,0.035155,2.39111,-0,1,0,0.478672, 0.960056,
4.39272,0.035155,2.64695,-0,1,0,0.332113, 0.959624,
4.41222,0.035155,2.8518,-0,1,0,0.344267, 0.937476,
5.98934,0.037513,0.632304,-0.168767,0.000405,-0.985656,0.107754, 0.391609,
6.1964,0.037513,0.596922,-0.168767,0.000405,-0.985656,0.086508, 0.39433,
6.1943,-0.131931,0.597142,-0.168767,0.000405,-0.985656,0.070896, 0.374216,
5.98934,-0.131931,0.632304,-0.168767,0.000405,-0.985656,0.121981, 0.379374,
6.1964,0.037513,0.596922,0.987198,-0.006218,-0.159377,0.086508, 0.39433,
6.51274,0.037513,2.56301,0.987198,-0.006218,-0.159377,0.093107, 0.526308,
6.51274,-0.131931,2.56301,0.987198,-0.006218,-0.159377,0.070896, 0.550693,
6.1943,-0.131931,0.597142,0.987198,-0.006218,-0.159377,0.070896, 0.374216,
6.51274,0.037513,2.56301,0.170585,0,0.985343,0.093107, 0.526308,
6.29675,0.037513,2.6004,0.170585,0,0.985343,0.117329, 0.52826,
6.29675,-0.131931,2.6004,0.170585,0,0.985343,0.137311, 0.538359,
6.51274,-0.131931,2.56301,0.170585,0,0.985343,0.070896, 0.550693,
6.29675,0.037513,2.6004,-0.98802,0,0.154323,0.117329, 0.52826,
5.98934,0.037513,0.632304,-0.98802,0,0.154323,0.107754, 0.391609,
5.98934,-0.131931,0.632304,-0.98802,0,0.154323,0.121981, 0.379374,
6.29675,-0.131931,2.6004,-0.98802,0,0.154323,0.137311, 0.538359,
6.29675,0.037513,2.6004,-0,1,0,0.117329, 0.52826,
6.51274,0.037513,2.56301,-0,1,0,0.093107, 0.526308,
6.1964,0.037513,0.596922,-0,1,0,0.086508, 0.39433,
5.98934,0.037513,0.632304,-0,1,0,0.107754, 0.391609,
4.62811,0.030886,4.84381,-0.995496,0,0.094801,0.037744, 0.626337,
4.60508,0.030886,4.60195,-0.995496,0,0.094801,0.023436, 0.644897,
4.60508,-0.169166,4.60195,-0.995496,0,0.094801,0.006636, 0.629119,
4.62811,-0.169166,4.84381,-0.995496,0,0.094801,0.025799, 0.608716,
6.57114,0.035155,4.3615,0.985637,-0,-0.168881,0.183096, 0.65973,
6.61143,0.035155,4.59665,0.985637,-0,-0.168881,0.173804, 0.631013,
6.61143,-0.134289,4.59665,0.985637,-0,-0.168881,0.180406, 0.608716,
6.57114,-0.134289,4.3615,0.985637,-0,-0.168881,0.209888, 0.641377,
6.61143,0.035155,4.59665,0.123663,0,0.992324,0.173804, 0.631013,
4.62811,0.030886,4.84381,0.123663,0,0.992324,0.037744, 0.626337,
4.62811,-0.169166,4.84381,0.123663,0,0.992324,0.025799, 0.608716,
6.61143,-0.134289,4.59665,0.123663,0,0.992324,0.180406, 0.608716,
6.61143,0.035155,4.59665,-0.002127,0.999998,0.000283,0.173804, 0.631013,
6.57114,0.035155,4.3615,-0.002127,0.999998,0.000283,0.183096, 0.65973,
4.60508,0.030886,4.60195,-0.002127,0.999998,0.000283,0.023436, 0.644897,
4.62811,0.030886,4.84381,-0.002127,0.999998,0.000283,0.037744, 0.626337,
6.30859,0.037513,2.62214,-0.168765,0.000404,-0.985656,0.522064, 0.024149,
6.51564,0.037513,2.58676,-0.168765,0.000404,-0.985656,0.500927, 0.026939,
6.51354,-0.131931,2.58698,-0.168765,0.000404,-0.985656,0.485355, 0.006818,
6.30859,-0.131931,2.62214,-0.168765,0.000404,-0.985656,0.536218, 0.011902,
6.51564,0.037513,2.58676,0.986634,-0.006216,-0.162836,0.500927, 0.026939,
6.838,0.037513,4.54643,0.986634,-0.006216,-0.162836,0.507712, 0.158579,
6.838,-0.131931,4.54643,0.986634,-0.006216,-0.162836,0.485355, 0.182963,
6.51354,-0.131931,2.58698,0.986634,-0.006216,-0.162836,0.485355, 0.006818,
6.838,0.037513,4.54643,0.214896,0,0.976637,0.507712, 0.158579,
6.62573,0.037513,4.59314,0.214896,0,0.976637,0.531741, 0.160838,
6.62573,-0.131931,4.59314,0.214896,0,0.976637,0.551802, 0.171005,
6.838,-0.131931,4.54643,0.214896,0,0.976637,0.485355, 0.182963,
6.62573,0.037513,4.59314,-0.987301,0,0.158862,0.531741, 0.160838,
6.30859,0.037513,2.62214,-0.987301,0,0.158862,0.522064, 0.024149,
6.30859,-0.131931,2.62214,-0.987301,0,0.158862,0.536218, 0.011902,
6.62573,-0.131931,4.59314,-0.987301,0,0.158862,0.551802, 0.171005,
6.62573,0.037513,4.59314,-0,1,0,0.531741, 0.160838,
6.838,0.037513,4.54643,-0,1,0,0.507712, 0.158579,
6.51564,0.037513,2.58676,-0,1,0,0.500927, 0.026939,
6.30859,0.037513,2.62214,-0,1,0,0.522064, 0.024149,
6.20121,0.035155,0.562179,-0.986977,0,0.160861,0.767365, 0.714624,
6.16811,0.035155,0.359076,-0.986977,0,0.160861,0.754814, 0.731332,
6.16811,-0.134289,0.359076,-0.986977,0,0.160861,0.739775, 0.717065,
6.20121,-0.134289,0.562179,-0.986977,0,0.160861,0.757102, 0.698801,
7.93813,0.035155,0.008439,0.973896,0,-0.226993,0.897849, 0.744721,
7.98709,0.035155,0.218491,0.973896,0,-0.226993,0.890191, 0.719597,
7.98709,-0.134289,0.218491,0.973896,0,-0.226993,0.896881, 0.698801,
7.93813,-0.134289,0.008439,0.973896,0,-0.226993,0.923119, 0.726782,
7.98709,0.035155,0.218491,0.18898,0,0.981981,0.890191, 0.719597,
6.20121,0.035155,0.562179,0.18898,0,0.981981,0.767365, 0.714624,
6.20121,-0.134289,0.562179,0.18898,0,0.981981,0.757102, 0.698801,
7.98709,-0.134289,0.218491,0.18898,0,0.981981,0.896881, 0.698801,
7.98709,0.035155,0.218491,-0,1,0,0.890191, 0.719597,
7.93813,0.035155,0.008439,-0,1,0,0.897849, 0.744721,
6.16811,0.035155,0.359076,-0,1,0,0.754814, 0.731332,
6.20121,0.035155,0.562179,-0,1,0,0.767365, 0.714624,
7.57715,0.021201,-1.72765,-0.199046,0.000448,-0.97999,0.654506, 0.022017,
7.78302,0.021201,-1.76939,-0.199046,0.000448,-0.97999,0.632945, 0.025298,
7.78093,-0.131931,-1.76911,-0.199046,0.000448,-0.97999,0.617846, 0.007037,
7.57715,-0.131931,-1.72765,-0.199046,0.000448,-0.97999,0.66828, 0.010205,
7.78302,0.021201,-1.76939,0.976673,-0.00652,-0.214631,0.632945, 0.025298,
8.21011,0.037822,0.17873,0.976673,-0.00652,-0.214631,0.639845, 0.154739,
8.21011,-0.131623,0.17873,0.976673,-0.00652,-0.214631,0.617846, 0.179642,
7.78093,-0.131931,-1.76911,0.976673,-0.00652,-0.214631,0.617846, 0.007037,
8.21011,0.037822,0.17873,0.20631,0,0.978487,0.639845, 0.154739,
8.00349,0.037636,0.222295,0.20631,0,0.978487,0.663516, 0.155932,
8.00349,-0.131809,0.222295,0.20631,0,0.978487,0.6831, 0.165215,
8.21011,-0.131623,0.17873,0.20631,0,0.978487,0.617846, 0.179642,
8.00349,0.037636,0.222295,-0.976922,0,0.213597,0.663516, 0.155932,
7.57715,0.021201,-1.72765,-0.976922,0,0.213597,0.654506, 0.022017,
7.57715,-0.131931,-1.72765,-0.976922,0,0.213597,0.66828, 0.010205,
8.00349,-0.131809,0.222295,-0.976922,0,0.213597,0.6831, 0.165215,
8.00349,0.037636,0.222295,-0.002108,0.999966,-0.008018,0.663516, 0.155932,
8.21011,0.037822,0.17873,-0.002108,0.999966,-0.008018,0.639845, 0.154739,
7.78302,0.021201,-1.76939,-0.002108,0.999966,-0.008018,0.632945, 0.025298,
7.57715,0.021201,-1.72765,-0.002108,0.999966,-0.008018,0.654506, 0.022017,
6.53098,0.035155,2.54297,-0.984592,0,0.174869,0.7801, 0.313456,
6.49499,0.035155,2.34036,-0.984592,0,0.174869,0.767835, 0.335485,
6.49499,-0.134289,2.34036,-0.984592,0,0.174869,0.748886, 0.318759,
6.53098,-0.134289,2.54297,-0.984592,0,0.174869,0.769199, 0.295746,
8.37724,0.035155,1.97006,0.984317,-0,-0.176407,0.915375, 0.33605,
8.41371,0.035155,2.17355,0.984317,-0,-0.176407,0.905805, 0.315602,
8.41371,-0.134289,2.17355,0.984317,-0,-0.176407,0.911704, 0.295746,
8.37724,-0.134289,1.97006,0.984317,-0,-0.176407,0.936476, 0.31829,
8.41371,0.035155,2.17355,0.192546,0,0.981288,0.905805, 0.315602,
6.53098,0.035155,2.54297,0.192546,0,0.981288,0.7801, 0.313456,
6.53098,-0.134289,2.54297,0.192546,0,0.981288,0.769199, 0.295746,
8.41371,-0.134289,2.17355,0.192546,0,0.981288,0.911704, 0.295746,
8.41371,0.035155,2.17355,-0,1,0,0.905805, 0.315602,
8.37724,0.035155,1.97006,-0,1,0,0.915375, 0.33605,
6.49499,0.035155,2.34036,-0,1,0,0.767835, 0.335485,
6.53098,0.035155,2.54297,-0,1,0,0.7801, 0.313456,
8.00856,0.03835,0.247909,-0.199041,0.000405,-0.979991,0.711847, 0.360969,
8.21442,0.03835,0.206166,-0.199041,0.000405,-0.979991,0.68909, 0.363083,
8.21233,-0.131094,0.206451,-0.199041,0.000405,-0.979991,0.672569, 0.341937,
8.00856,-0.131094,0.247909,-0.199041,0.000405,-0.979991,0.73021, 0.349469,
8.21442,0.03835,0.206166,0.976705,-0.006205,-0.214499,0.68909, 0.363083,
8.6349,0.037513,2.12569,0.976705,-0.006205,-0.214499,0.692969, 0.495154,
8.6349,-0.131931,2.12569,0.976705,-0.006205,-0.214499,0.672569, 0.517652,
8.21233,-0.131094,0.206451,0.976705,-0.006205,-0.214499,0.672569, 0.341937,
8.6349,0.037513,2.12569,0.207498,0,0.978235,0.692969, 0.495154,
8.42789,0.037513,2.1696,0.207498,0,0.978235,0.71503, 0.497652,
8.42789,-0.131931,2.1696,0.207498,0,0.978235,0.73065, 0.508643,
8.6349,-0.131931,2.12569,0.207498,0,0.978235,0.672569, 0.517652,
8.42789,0.037513,2.1696,-0.97701,0,0.213195,0.71503, 0.497652,
8.00856,0.03835,0.247909,-0.97701,0,0.213195,0.711847, 0.360969,
8.00856,-0.131094,0.247909,-0.97701,0,0.213195,0.73021, 0.349469,
8.42789,-0.131931,2.1696,-0.97701,0,0.213195,0.73065, 0.508643,
8.42789,0.037513,2.1696,8.6e-005,1,0.000417,0.71503, 0.497652,
8.6349,0.037513,2.12569,8.6e-005,1,0.000417,0.692969, 0.495154,
8.21442,0.03835,0.206166,8.6e-005,1,0.000417,0.68909, 0.363083,
8.00856,0.03835,0.247909,8.6e-005,1,0.000417,0.711847, 0.360969,
6.85373,0.030886,4.54563,-0.992104,0,0.12542,0.571182, 0.813207,
6.82326,0.030886,4.30459,-0.992104,0,0.12542,0.557685, 0.837596,
6.82326,-0.169166,4.30459,-0.992104,0,0.12542,0.53654, 0.819592,
6.85373,-0.169166,4.54563,-0.992104,0,0.12542,0.558405, 0.793912,
8.79466,0.035155,3.92892,0.979968,-3e-006,-0.199157,0.719205, 0.838127,
8.84217,0.035155,4.16272,0.979968,-3e-006,-0.199157,0.707793, 0.814672,
8.84217,-0.134289,4.16272,0.979968,-3e-006,-0.199157,0.713916, 0.793912,
8.79466,-0.134289,3.92892,0.979968,-3e-006,-0.199157,0.741531, 0.821157,
8.84217,0.035155,4.16272,0.189095,-1e-006,0.981959,0.707793, 0.814672,
6.85373,0.030886,4.54563,0.189095,-1e-006,0.981959,0.571182, 0.813207,
6.85373,-0.169166,4.54563,0.189095,-1e-006,0.981959,0.558405, 0.793912,
8.84217,-0.134289,4.16272,0.189095,-1e-006,0.981959,0.713916, 0.793912,
8.84217,0.035155,4.16272,-0.002091,0.999998,0.000344,0.707793, 0.814672,
8.79466,0.035155,3.92892,-0.002091,0.999998,0.000344,0.719205, 0.838127,
6.82326,0.030886,4.30459,-0.002091,0.999998,0.000344,0.557685, 0.837596,
6.85373,0.030886,4.54563,-0.002091,0.999998,0.000344,0.571182, 0.813207,
8.4404,0.037513,2.19096,-0.199045,0.000404,-0.97999,0.510025, 0.362731,
8.64626,0.037513,2.14922,-0.199045,0.000404,-0.97999,0.489067, 0.366289,
8.64417,-0.131931,2.1495,-0.199045,0.000404,-0.97999,0.473314, 0.346678,
8.4404,-0.131931,2.19096,-0.199045,0.000404,-0.97999,0.524346, 0.350044,
8.64626,0.037513,2.14922,0.977474,-0.006207,-0.210966,0.489067, 0.366289,
9.06945,0.037513,4.11497,0.977474,-0.006207,-0.210966,0.495704, 0.498652,
9.06945,-0.131931,4.11497,0.977474,-0.006207,-0.210966,0.473314, 0.524052,
8.64417,-0.131931,2.1495,0.977474,-0.006207,-0.210966,0.473314, 0.346678,
9.06945,0.037513,4.11497,0.201342,0,0.979521,0.495704, 0.498652,
8.85636,0.037513,4.15877,0.201342,0,0.979521,0.520218, 0.499799,
8.85636,-0.131931,4.15877,0.201342,0,0.979521,0.540078, 0.509201,
9.06945,-0.131931,4.11497,0.201342,0,0.979521,0.473314, 0.524052,
8.85636,0.037513,4.15877,-0.97838,0,0.206815,0.520218, 0.499799,
8.4404,0.037513,2.19096,-0.97838,0,0.206815,0.510025, 0.362731,
8.4404,-0.131931,2.19096,-0.97838,0,0.206815,0.524346, 0.350044,
8.85636,-0.131931,4.15877,-0.97838,0,0.206815,0.540078, 0.509201,
8.85636,0.037513,4.15877,-0,1,0,0.520218, 0.499799,
9.06945,0.037513,4.11497,-0,1,0,0.495704, 0.498652,
8.64626,0.037513,2.14922,-0,1,0,0.489067, 0.366289,
8.4404,0.037513,2.19096,-0,1,0,0.510025, 0.362731,
8.22218,0.035155,0.169082,-0.978552,0,0.205998,0.767703, 0.85397,
8.17979,0.035155,-0.032287,-0.978552,0,0.205998,0.755, 0.870628,
8.17979,-0.134289,-0.032287,-0.978552,0,0.205998,0.740066, 0.856265,
8.22218,-0.134289,0.169082,-0.978552,0,0.205998,0.75751, 0.838127,
9.93155,0.035155,-0.436684,0.962449,0,-0.271464,0.897906, 0.88389,
9.9901,0.035155,-0.229102,0.962449,0,-0.271464,0.890406, 0.858823,
9.9901,-0.134289,-0.229102,0.962449,0,-0.271464,0.897186, 0.838127,
9.93155,-0.134289,-0.436684,0.962449,0,-0.271464,0.923157, 0.866166,
9.9901,0.035155,-0.229102,0.219724,0,0.975562,0.890406, 0.858823,
8.22218,0.035155,0.169082,0.219724,0,0.975562,0.767703, 0.85397,
8.22218,-0.134289,0.169082,0.219724,0,0.975562,0.75751, 0.838127,
9.9901,-0.134289,-0.229102,0.219724,0,0.975562,0.897186, 0.838127,
9.9901,0.035155,-0.229102,-0,1,0,0.890406, 0.858823,
9.93155,0.035155,-0.436684,-0,1,0,0.897906, 0.88389,
8.17979,0.035155,-0.032287,-0,1,0,0.755, 0.870628,
8.22218,0.035155,0.169082,-0,1,0,0.767703, 0.85397,
9.45792,0.037513,-2.14095,-0.243824,0.000403,-0.969819,0.588128, 0.022907,
9.66165,0.037513,-2.1921,-0.243824,0.000403,-0.969819,0.567428, 0.02659,
9.65958,-0.131931,-2.19172,-0.243824,0.000403,-0.969819,0.551802, 0.007037,
9.45792,-0.131931,-2.14095,-0.243824,0.000403,-0.969819,0.602291, 0.010201,
9.66165,0.037513,-2.1921,0.961525,-0.006199,-0.274646,0.567428, 0.02659,
10.2056,0.037699,-0.283817,0.961525,-0.006199,-0.274646,0.574038, 0.157663,
10.2056,-0.131746,-0.283817,0.961525,-0.006199,-0.274646,0.551802, 0.182963,
9.65958,-0.131931,-2.19172,0.961525,-0.006199,-0.274646,0.551802, 0.007037,
10.2056,0.037699,-0.283817,0.251014,0,0.967984,0.574038, 0.157663,
10.0012,0.037513,-0.230812,0.251014,0,0.967984,0.598026, 0.158759,
10.0012,-0.131931,-0.230812,0.251014,0,0.967984,0.617846, 0.168128,
10.2056,-0.131746,-0.283817,0.251014,0,0.967984,0.551802, 0.182963,
10.0012,0.037513,-0.230812,-0.961848,0,0.273585,0.598026, 0.158759,
9.45792,0.037513,-2.14095,-0.961848,0,0.273585,0.588128, 0.022907,
9.45792,-0.131931,-2.14095,-0.961848,0,0.273585,0.602291, 0.010201,
10.0012,-0.131931,-0.230812,-0.961848,0,0.273585,0.617846, 0.168128,
10.0012,0.037513,-0.230812,-0.000435,1,7.5e-005,0.598026, 0.158759,
10.2056,0.037699,-0.283817,-0.000435,1,7.5e-005,0.574038, 0.157663,
9.66165,0.037513,-2.1921,-0.000435,1,7.5e-005,0.567428, 0.02659,
9.45792,0.037513,-2.14095,-0.000435,1,7.5e-005,0.588128, 0.022907,
8.65829,0.035155,2.12747,-0.975525,0,0.219888,0.341004, 0.889728,
8.61304,0.035155,1.92673,-0.975525,0,0.219888,0.328092, 0.906639,
8.61304,-0.134289,1.92673,-0.975525,0,0.219888,0.313041, 0.891846,
8.65829,-0.134289,2.12747,-0.975525,0,0.219888,0.331007, 0.873567,
10.466,0.035155,1.51426,0.975181,-0,-0.221407,0.473987, 0.919818,
10.5118,0.035155,1.71586,0.975181,-0,-0.221407,0.466561, 0.894901,
10.5118,-0.134289,1.71586,0.975181,-0,-0.221407,0.47302, 0.873567,
10.466,-0.134289,1.51426,0.975181,-0,-0.221407,0.499553, 0.900751,
10.5118,0.035155,1.71586,0.216794,0,0.976217,0.466561, 0.894901,
8.65829,0.035155,2.12747,0.216794,0,0.976217,0.341004, 0.889728,
8.65829,-0.134289,2.12747,0.216794,0,0.976217,0.331007, 0.873567,
10.5118,-0.134289,1.71586,0.216794,0,0.976217,0.47302, 0.873567,
10.5118,0.035155,1.71586,-0,1,0,0.466561, 0.894901,
10.466,0.035155,1.51426,-0,1,0,0.473987, 0.919818,
8.61304,0.035155,1.92673,-0,1,0,0.328092, 0.906639,
8.65829,0.035155,2.12747,-0,1,0,0.341004, 0.889728,
10.0075,0.038227,-0.205458,-0.243819,0.000405,-0.969821,0.710639, 0.538094,
10.2112,0.038227,-0.256607,-0.243819,0.000405,-0.969821,0.687482, 0.539635,
10.2091,-0.131217,-0.256227,-0.243819,0.000405,-0.969821,0.670785, 0.517652,
10.0075,-0.131217,-0.205458,-0.243819,0.000405,-0.969821,0.728978, 0.527154,
10.2112,0.038227,-0.256607,0.964211,-0.006202,-0.265065,0.687482, 0.539635,
10.7338,0.037513,1.64843,0.964211,-0.006202,-0.265065,0.691326, 0.672393,
10.7338,-0.131931,1.64843,0.964211,-0.006202,-0.265065,0.670785, 0.694294,
10.2091,-0.131217,-0.256227,0.964211,-0.006202,-0.265065,0.670785, 0.517652,
10.7338,0.037513,1.64843,0.289124,0,0.957292,0.691326, 0.672393,
10.5257,0.037513,1.71127,0.289124,0,0.957292,0.71338, 0.675846,
10.5257,-0.131931,1.71127,0.289124,0,0.957292,0.729084, 0.687394,
10.7338,-0.131931,1.64843,0.289124,0,0.957292,0.670785, 0.694294,
10.5257,0.037513,1.71127,-0.965333,0,0.261022,0.71338, 0.675846,
10.0075,0.038227,-0.205458,-0.965333,0,0.261022,0.710639, 0.538094,
10.0075,-0.131217,-0.205458,-0.965333,0,0.261022,0.728978, 0.527154,
10.5257,-0.131931,1.71127,-0.965333,0,0.261022,0.729084, 0.687394,
10.5257,0.037513,1.71127,9.6e-005,1,0.000348,0.71338, 0.675846,
10.7338,0.037513,1.64843,9.6e-005,1,0.000348,0.691326, 0.672393,
10.2112,0.038227,-0.256607,9.6e-005,1,0.000348,0.687482, 0.539635,
10.0075,0.038227,-0.205458,9.6e-005,1,0.000348,0.710639, 0.538094,
9.08941,0.030886,4.10921,-0.974734,0,0.223368,0.036462, 0.575693,
9.03514,0.030886,3.8724,-0.974734,0,0.223368,0.021622, 0.594276,
9.03514,-0.169166,3.8724,-0.974734,0,0.223368,0.005, 0.578,
9.08941,-0.169166,4.10921,-0.974734,0,0.223368,0.024767, 0.557813,
11.0044,0.035155,3.45709,0.969791,-3e-006,-0.243938,0.183263, 0.608716,
11.0626,0.035155,3.68847,0.969791,-3e-006,-0.243938,0.173776, 0.580096,
11.0626,-0.134289,3.68847,0.969791,-3e-006,-0.243938,0.18032, 0.557813,
11.0044,-0.134289,3.45709,0.969791,-3e-006,-0.243938,0.209888, 0.590247,
11.0626,0.035155,3.68847,0.208542,-1e-006,0.978013,0.173776, 0.580096,
9.08941,0.030886,4.10921,0.208542,-1e-006,0.978013,0.036462, 0.575693,
9.08941,-0.169166,4.10921,0.208542,-1e-006,0.978013,0.024767, 0.557813,
11.0626,-0.134289,3.68847,0.208542,-1e-006,0.978013,0.18032, 0.557813,
11.0626,0.035155,3.68847,-0.002061,0.999998,0.000495,0.173776, 0.580096,
11.0044,0.035155,3.45709,-0.002061,0.999998,0.000495,0.183263, 0.608716,
9.03514,0.030886,3.8724,-0.002061,0.999998,0.000495,0.021622, 0.594276,
9.08941,0.030886,4.10921,-0.002061,0.999998,0.000495,0.036462, 0.575693,
10.5392,0.037513,1.73203,-0.243825,0.000403,-0.969819,0.443399, 0.362668,
10.7429,0.037513,1.68088,-0.243825,0.000403,-0.969819,0.422374, 0.366309,
10.7409,-0.131931,1.68126,-0.243825,0.000403,-0.969819,0.40653, 0.346678,
10.5392,-0.131931,1.73203,-0.243825,0.000403,-0.969819,0.457793, 0.349964,
10.7429,0.037513,1.68088,0.963001,-0.006197,-0.269428,0.422374, 0.366309,
11.2847,0.037513,3.62103,0.963001,-0.006197,-0.269428,0.429032, 0.498769,
11.2847,-0.131931,3.62103,0.963001,-0.006197,-0.269428,0.40653, 0.524126,
10.7409,-0.131931,1.68126,0.963001,-0.006197,-0.269428,0.40653, 0.346678,
11.2847,0.037513,3.62103,0.289122,-1e-006,0.957292,0.429032, 0.498769,
11.0766,0.037513,3.68387,0.289122,-1e-006,0.957292,0.453464, 0.500146,
11.0766,-0.131931,3.68387,0.289122,-1e-006,0.957292,0.473314, 0.50961,
11.2847,-0.131931,3.62103,0.289122,-1e-006,0.957292,0.40653, 0.524126,
11.0766,0.037513,3.68387,-0.964126,0,0.265446,0.453464, 0.500146,
10.5392,0.037513,1.73203,-0.964126,0,0.265446,0.443399, 0.362668,
10.5392,-0.131931,1.73203,-0.964126,0,0.265446,0.457793, 0.349964,
11.0766,-0.131931,3.68387,-0.964126,0,0.265446,0.473314, 0.50961,
11.0766,0.037513,3.68387,-0,1,0,0.453464, 0.500146,
11.2847,0.037513,3.62103,-0,1,0,0.429032, 0.498769,
10.7429,0.037513,1.68088,-0,1,0,0.422374, 0.366309,
10.5392,0.037513,1.73203,-0,1,0,0.443399, 0.362668,
7.79612,0.018254,-1.77634,-0.978552,0,0.205998,0.192638, 0.742794,
7.75373,0.018254,-1.97771,-0.978552,0,0.205998,0.179902, 0.759138,
7.75373,-0.134289,-1.97771,-0.978552,0,0.205998,0.166212, 0.746568,
7.79612,-0.134289,-1.77634,-0.978552,0,0.205998,0.183168, 0.7281,
9.38573,0.035155,-2.33144,0.962448,0,-0.271464,0.316928, 0.771789,
9.44428,0.035155,-2.12386,0.962448,0,-0.271464,0.309393, 0.7478,
9.44428,-0.134289,-2.12386,0.962448,0,-0.271464,0.316291, 0.7281,
9.38573,-0.134289,-2.33144,0.962448,0,-0.271464,0.341092, 0.754884,
9.44428,0.035155,-2.12386,0.206315,0,0.978486,0.309393, 0.7478,
7.79612,0.018254,-1.77634,0.206315,0,0.978486,0.192638, 0.742794,
7.79612,-0.134289,-1.77634,0.206315,0,0.978486,0.183168, 0.7281,
9.44428,-0.134289,-2.12386,0.206315,0,0.978486,0.316291, 0.7281,
9.44428,0.035155,-2.12386,-0.009788,0.999949,0.002416,0.309393, 0.7478,
9.38573,0.035155,-2.33144,-0.009788,0.999949,0.002416,0.316928, 0.771789,
7.75373,0.018254,-1.97771,-0.009788,0.999949,0.002416,0.179902, 0.759138,
7.79612,0.018254,-1.77634,-0.009788,0.999949,0.002416,0.192638, 0.742794,
5.87521,0.01403,-1.39321,-0.978552,0,0.205998,0.585454, 0.980347,
5.83282,0.01403,-1.59458,-0.978552,0,0.205998,0.572497, 1,
5.83282,-0.109762,-1.59458,-0.978552,0,0.205998,0.557968, 0.988394,
5.87521,-0.109762,-1.39321,-0.978552,0,0.205998,0.577261, 0.964241,
7.51129,0.011045,-1.92482,0.973914,0,-0.226916,0.706967, 1,
7.56024,0.011045,-1.71476,0.973914,0,-0.226916,0.696989, 0.978064,
7.56024,-0.109762,-1.71476,0.973914,0,-0.226916,0.702064, 0.964349,
7.51129,-0.109762,-1.92482,0.973914,0,-0.226916,0.723179, 0.988774,
7.56024,0.011045,-1.71476,0.187445,0,0.982275,0.696989, 0.978064,
5.87521,0.01403,-1.39321,0.187445,0,0.982275,0.585454, 0.980347,
5.87521,-0.109762,-1.39321,0.187445,0,0.982275,0.577261, 0.964241,
7.56024,-0.109762,-1.71476,0.187445,0,0.982275,0.702064, 0.964349,
7.56024,0.011045,-1.71476,0.001702,0.999999,-0.000378,0.696989, 0.978064,
7.51129,0.011045,-1.92482,0.001702,0.999999,-0.000378,0.706967, 1,
5.83282,0.01403,-1.59458,0.001702,0.999999,-0.000378,0.572497, 1,
5.87521,0.01403,-1.39321,0.001702,0.999999,-0.000378,0.585454, 0.980347,
3.98325,0.029269,-1.11108,-0.99359,0,0.113041,0.34078, 0.976632,
3.95998,0.029269,-1.31554,-0.99359,0,0.113041,0.328729, 0.99573,
3.95998,-0.109762,-1.31554,-0.99359,0,0.113041,0.313041, 0.983275,
3.98325,-0.109762,-1.11108,-0.99359,0,0.113041,0.331476, 0.960056,
5.60224,0.009412,-1.56312,0.981982,0,-0.188973,0.461705, 0.995916,
5.64299,0.009412,-1.35132,0.981982,0,-0.188973,0.451579, 0.973716,
5.64299,-0.109762,-1.35132,0.981982,0,-0.188973,0.456746, 0.960056,
5.60224,-0.109762,-1.56312,0.981982,0,-0.188973,0.477924, 0.984809,
5.64299,0.009412,-1.35132,0.143255,0,0.989686,0.451579, 0.973716,
3.98325,0.029269,-1.11108,0.143255,0,0.989686,0.34078, 0.976632,
3.98325,-0.109762,-1.11108,0.143255,0,0.989686,0.331476, 0.960056,
5.64299,-0.109762,-1.35132,0.143255,0,0.989686,0.456746, 0.960056,
5.64299,0.009412,-1.35132,0.01176,0.999929,-0.001808,0.451579, 0.973716,
5.60224,0.009412,-1.56312,0.01176,0.999929,-0.001808,0.461705, 0.995916,
3.95998,0.029269,-1.31554,0.01176,0.999929,-0.001808,0.328729, 0.99573,
3.98325,0.029269,-1.11108,0.01176,0.999929,-0.001808,0.34078, 0.976632,
5.65416,0.013404,-1.36801,0.000205,0.999999,0.001149,0.721773, 0.321174,
5.85381,0.013404,-1.40554,0.000205,0.999999,0.001149,0.702222, 0.317683,
5.55873,0.015539,-3.20973,0.000205,0.999999,0.001149,0.704645, 0.194183,
5.36292,0.015539,-3.1766,0.000205,0.999999,0.001149,0.72716, 0.197975,
5.65416,0.013404,-1.36801,-0.987281,0,0.158987,0.721773, 0.321174,
5.36292,0.015539,-3.1766,-0.987281,0,0.158987,0.72716, 0.197975,
5.36292,-0.132266,-3.1766,-0.987281,0,0.158987,0.748886, 0.178367,
5.65416,-0.145054,-1.36801,-0.987281,0,0.158987,0.734165, 0.332829,
5.85381,0.013404,-1.40554,0.184737,0,0.982788,0.702222, 0.317683,
5.65416,0.013404,-1.36801,0.184737,0,0.982788,0.721773, 0.321174,
5.65416,-0.145054,-1.36801,0.184737,0,0.982788,0.734165, 0.332829,
5.85381,-0.145054,-1.40554,0.184737,0,0.982788,0.687133, 0.33605,
5.55873,0.015539,-3.20973,0.986889,0,-0.161403,0.704645, 0.194183,
5.85381,0.013404,-1.40554,0.986889,0,-0.161403,0.702222, 0.317683,
5.85381,-0.145054,-1.40554,0.986889,0,-0.161403,0.687133, 0.33605,
5.55873,-0.132266,-3.20973,0.986889,0,-0.161403,0.687133, 0.183387,
5.36292,0.015539,-3.1766,-0.166818,0,-0.985988,0.72716, 0.197975,
5.55873,0.015539,-3.20973,-0.166818,0,-0.985988,0.704645, 0.194183,
5.55873,-0.132266,-3.20973,-0.166818,0,-0.985988,0.687133, 0.183387,
5.36292,-0.132266,-3.1766,-0.166818,0,-0.985988,0.748886, 0.178367,
7.5788,0.021185,-1.73528,-0.000782,0.999992,-0.003953,0.248773, 0.704136,
7.77764,0.021185,-1.77685,-0.000782,0.999992,-0.003953,0.229319, 0.701326,
7.38346,0.013765,-3.57381,-0.000782,0.999992,-0.003953,0.231569, 0.576882,
7.18634,0.013765,-3.53699,-0.000782,0.999992,-0.003953,0.254547, 0.58005,
7.5788,0.021185,-1.73528,-0.977088,0,0.212836,0.248773, 0.704136,
7.18634,0.013765,-3.53699,-0.977088,0,0.212836,0.254547, 0.58005,
7.18634,-0.132266,-3.53699,-0.977088,0,0.212836,0.276778, 0.559408,
7.5788,-0.145054,-1.73528,-0.977088,0,0.212836,0.26135, 0.715798,
7.77764,0.021185,-1.77685,0.204631,0,0.978839,0.229319, 0.701326,
7.5788,0.021185,-1.73528,0.204631,0,0.978839,0.248773, 0.704136,
7.5788,-0.145054,-1.73528,0.204631,0,0.978839,0.26135, 0.715798,
7.77764,-0.145054,-1.77685,0.204631,0,0.978839,0.214038, 0.720737,
7.38346,0.013765,-3.57381,0.976776,0,-0.214265,0.231569, 0.576882,
7.77764,0.021185,-1.77685,0.976776,0,-0.214265,0.229319, 0.701326,
7.77764,-0.145054,-1.77685,0.976776,0,-0.214265,0.214038, 0.720737,
7.38346,-0.132266,-3.57381,0.976776,0,-0.214265,0.214038, 0.566719,
7.18634,0.013765,-3.53699,-0.183604,0,-0.983,0.254547, 0.58005,
7.38346,0.013765,-3.57381,-0.183604,0,-0.983,0.231569, 0.576882,
7.38346,-0.132266,-3.57381,-0.183604,0,-0.983,0.214038, 0.566719,
7.18634,-0.132266,-3.53699,-0.183604,0,-0.983,0.276778, 0.559408,
9.46199,0.044599,-2.15754,-0.000979,0.999992,-0.003927,0.574873, 0.674347,
9.65831,0.044599,-2.20972,-0.000979,0.999992,-0.003927,0.556058, 0.671117,
9.16842,0.037179,-3.97407,-0.000979,0.999992,-0.003927,0.559169, 0.541886,
8.985,0.037179,-3.93158,-0.000979,0.999992,-0.003927,0.580871, 0.545524,
9.46199,0.044599,-2.15754,-0.965702,0,0.259652,0.574873, 0.674347,
8.985,0.037179,-3.93158,-0.965702,0,0.259652,0.580871, 0.545524,
8.985,-0.132266,-3.93158,-0.965702,0,0.259652,0.604655, 0.522966,
9.46199,-0.145054,-2.15754,-0.965702,0,0.259652,0.588108, 0.687519,
9.65831,0.044599,-2.20972,0.256844,0,0.966453,0.556058, 0.671117,
9.46199,0.044599,-2.15754,0.256844,0,0.966453,0.574873, 0.674347,
9.46199,-0.145054,-2.15754,0.256844,0,0.966453,0.588108, 0.687519,
9.65831,-0.145054,-2.20972,0.256844,0,0.966453,0.540078, 0.692596,
9.16842,0.037179,-3.97407,0.963547,0,-0.26754,0.559169, 0.541886,
9.65831,0.044599,-2.20972,0.963547,0,-0.26754,0.556058, 0.671117,
9.65831,-0.145054,-2.20972,0.963547,0,-0.26754,0.540078, 0.692596,
9.16842,-0.132266,-3.97407,0.963547,0,-0.26754,0.540078, 0.530331,
8.985,0.037179,-3.93158,-0.225675,0,-0.974203,0.580871, 0.545524,
9.16842,0.037179,-3.97407,-0.225675,0,-0.974203,0.559169, 0.541886,
9.16842,-0.132266,-3.97407,-0.225675,0,-0.974203,0.540078, 0.530331,
8.985,-0.132266,-3.93158,-0.225675,0,-0.974203,0.604655, 0.522966,
7.39612,0.018254,-3.59934,-0.971232,0,0.238135,0.811165, 0.532081,
7.34712,0.018254,-3.79921,-0.971232,0,0.238135,0.798171, 0.547895,
7.34712,-0.134289,-3.79921,-0.971232,0,0.238135,0.785006, 0.535411,
7.39612,-0.134289,-3.59934,-0.971232,0,0.238135,0.801846, 0.517652,
8.90544,0.035155,-4.14136,0.957501,0,-0.288429,0.932024, 0.560652,
8.96764,0.035155,-3.93484,0.957501,0,-0.288429,0.924659, 0.537012,
8.96764,-0.134289,-3.93484,0.957501,0,-0.288429,0.931772, 0.517652,
8.90544,-0.134289,-4.14136,0.957501,0,-0.288429,0.955976, 0.54418,
8.96764,0.035155,-3.93484,0.208779,0,0.977963,0.924659, 0.537012,
7.39612,0.018254,-3.59934,0.208779,0,0.977963,0.811165, 0.532081,
7.39612,-0.134289,-3.59934,0.208779,0,0.977963,0.801846, 0.517652,
8.96764,-0.134289,-3.93484,0.208779,0,0.977963,0.931772, 0.517652,
8.96764,0.035155,-3.93484,-0.010196,0.999944,0.00279,0.924659, 0.537012,
8.90544,0.035155,-4.14136,-0.010196,0.999944,0.00279,0.932024, 0.560652,
7.34712,0.018254,-3.79921,-0.010196,0.999944,0.00279,0.798171, 0.547895,
7.39612,0.018254,-3.59934,-0.010196,0.999944,0.00279,0.811165, 0.532081,
5.57784,0.01403,-3.22772,-0.988083,0,0.15392,0.835916, 0.140074,
5.54276,0.01403,-3.45292,-0.988083,0,0.15392,0.819923, 0.164826,
5.54276,-0.109762,-3.45292,-0.988083,0,0.15392,0.804333, 0.151475,
5.57784,-0.109762,-3.22772,-0.988083,0,0.15392,0.828912, 0.122771,
7.11482,0.011045,-3.75185,0.973914,0,-0.226916,0.950737, 0.164826,
7.16376,0.011045,-3.5418,0.973914,0,-0.226916,0.94164, 0.146825,
7.16376,-0.109762,-3.5418,0.973914,0,-0.226916,0.948448, 0.135105,
7.11482,-0.109762,-3.75185,0.973914,0,-0.226916,0.9647, 0.15657,
7.16376,0.011045,-3.5418,0.194267,0,0.980949,0.94164, 0.146825,
5.57784,0.01403,-3.22772,0.194267,0,0.980949,0.835916, 0.140074,
5.57784,-0.109762,-3.22772,0.194267,0,0.980949,0.828912, 0.122771,
7.16376,-0.109762,-3.5418,0.194267,0,0.980949,0.948448, 0.135105,
7.16376,0.011045,-3.5418,0.001822,0.999998,-0.000352,0.94164, 0.146825,
7.11482,0.011045,-3.75185,0.001822,0.999998,-0.000352,0.950737, 0.164826,
5.54276,0.01403,-3.45292,0.001822,0.999998,-0.000352,0.819923, 0.164826,
5.57784,0.01403,-3.22772,0.001822,0.999998,-0.000352,0.835916, 0.140074,
3.768,0.027947,-2.96284,-0.99359,0,0.113041,0.056029, 0.969728,
3.74474,0.027947,-3.1673,-0.99359,0,0.113041,0.041997, 0.992141,
3.74474,-0.109762,-3.1673,-0.99359,0,0.113041,0.025328, 0.976894,
3.768,-0.109762,-2.96284,-0.99359,0,0.113041,0.048113, 0.951985,
5.30773,0.008089,-3.40219,0.987285,0,-0.158959,0.171398, 0.992141,
5.34202,0.008089,-3.18925,0.987285,0,-0.158959,0.161665, 0.974084,
5.34202,-0.109762,-3.18925,0.987285,0,-0.158959,0.168109, 0.962297,
5.30773,-0.109762,-3.40219,0.987285,0,-0.158959,0.185012, 0.983649,
5.34202,0.008089,-3.18925,0.142378,0,0.989812,0.161665, 0.974084,
3.768,0.027947,-2.96284,0.142378,0,0.989812,0.056029, 0.969728,
3.768,-0.109762,-2.96284,0.142378,0,0.989812,0.048113, 0.951985,
5.34202,-0.109762,-3.18925,0.142378,0,0.989812,0.168109, 0.962297,
5.34202,0.008089,-3.18925,0.012408,0.999922,-0.00171,0.161665, 0.974084,
5.30773,0.008089,-3.40219,0.012408,0.999922,-0.00171,0.171398, 0.992141,
3.74474,0.027947,-3.1673,0.012408,0.999922,-0.00171,0.041997, 0.992141,
3.768,0.027947,-2.96284,0.012408,0.999922,-0.00171,0.056029, 0.969728,
8.97815,0.035337,-3.94339,-0.001041,0.999992,-0.003885,0.649374, 0.319737,
9.15932,0.035337,-3.9838,-0.001041,0.999992,-0.003885,0.633657, 0.316159,
8.66254,0.027917,-5.7688,-0.001041,0.999992,-0.003885,0.642337, 0.182196,
8.50116,0.027917,-5.71742,-0.001041,0.999992,-0.003885,0.664877, 0.184931,
8.97815,0.035337,-3.94339,-0.965702,0,0.259652,0.649374, 0.319737,
8.50116,0.027917,-5.71742,-0.965702,0,0.259652,0.664877, 0.184931,
8.50116,-0.132266,-5.71742,-0.965702,0,0.259652,0.687133, 0.18875,
8.97815,-0.145054,-3.94339,-0.965702,0,0.259652,0.660776, 0.333213,
9.15932,0.035337,-3.9838,0.217714,0,0.976013,0.633657, 0.316159,
8.97815,0.035337,-3.94339,0.217714,0,0.976013,0.649374, 0.319737,
8.97815,-0.145054,-3.94339,0.217714,0,0.976013,0.660776, 0.333213,
9.15932,-0.145054,-3.9838,0.217714,0,0.976013,0.61898, 0.33605,
8.66254,0.027917,-5.7688,0.963387,0,-0.268116,0.642337, 0.182196,
9.15932,0.035337,-3.9838,0.963387,0,-0.268116,0.633657, 0.316159,
9.15932,-0.145054,-3.9838,0.963387,0,-0.268116,0.61898, 0.33605,
8.66254,-0.132266,-5.7688,0.963387,0,-0.268116,0.61898, 0.181874,
7.18077,0.013317,-3.5491,0.001693,0.999965,0.008231,0.521959, 0.320308,
7.37961,0.013317,-3.59067,0.001693,0.999965,0.008231,0.504146, 0.317868,
6.97549,0.029362,-5.45626,0.001693,0.999965,0.008231,0.503043, 0.182963,
6.79163,0.029362,-5.41913,0.001693,0.999965,0.008231,0.526319, 0.182963,
7.18077,0.013317,-3.5491,-0.979027,0,0.20373,0.521959, 0.320308,
6.79163,0.029362,-5.41913,-0.979027,0,0.20373,0.526319, 0.182963,
6.79163,-0.132266,-5.41913,-0.979027,0,0.20373,0.549414, 0.185453,
7.18077,-0.145054,-3.5491,-0.979027,0,0.20373,0.534194, 0.33169,
7.37961,0.013317,-3.59067,0.204631,0,0.978839,0.504146, 0.317868,
7.18077,0.013317,-3.5491,0.204631,0,0.978839,0.521959, 0.320308,
7.18077,-0.145054,-3.5491,0.204631,0,0.978839,0.534194, 0.33169,
7.37961,-0.145054,-3.59067,0.204631,0,0.978839,0.490856, 0.337582,
6.97549,0.029362,-5.45626,0.977333,0,-0.211709,0.503043, 0.182963,
7.37961,0.013317,-3.59067,0.977333,0,-0.211709,0.504146, 0.317868,
7.37961,-0.145054,-3.59067,0.977333,0,-0.211709,0.490856, 0.337582,
6.97549,-0.132266,-5.45626,0.977333,0,-0.211709,0.479708, 0.184669,
5.36053,0.01495,-3.19328,0.001127,0.999961,0.0087,0.581635, 0.32091,
5.56129,0.01495,-3.22427,0.001127,0.999961,0.0087,0.564097, 0.317226,
5.24848,0.031624,-5.09525,0.001127,0.999961,0.0087,0.572775, 0.182974,
5.06417,0.031624,-5.07637,0.001127,0.999961,0.0087,0.596024, 0.183608,
5.36053,0.01495,-3.19328,-0.987842,0,0.155462,0.581635, 0.32091,
5.06417,0.031624,-5.07637,-0.987842,0,0.155462,0.596024, 0.183608,
5.06417,-0.132266,-5.07637,-0.987842,0,0.155462,0.61898, 0.187787,
5.36053,-0.145054,-3.19328,-0.987842,0,0.155462,0.593005, 0.333272,
5.56129,0.01495,-3.22427,0.152555,0,0.988295,0.564097, 0.317226,
5.36053,0.01495,-3.19328,0.152555,0,0.988295,0.581635, 0.32091,
5.36053,-0.145054,-3.19328,0.152555,0,0.988295,0.593005, 0.333272,
5.56129,-0.145054,-3.22427,0.152555,0,0.988295,0.549414, 0.33605,
5.24848,0.031624,-5.09525,0.986311,0,-0.164898,0.572775, 0.182974,
5.56129,0.01495,-3.22427,0.986311,0,-0.164898,0.564097, 0.317226,
5.56129,-0.145054,-3.22427,0.986311,0,-0.164898,0.549414, 0.33605,
5.24848,-0.132266,-5.09525,0.986311,0,-0.164898,0.549414, 0.182963,
3.54959,0.044599,-2.94167,-0.000349,0.999993,-0.003703,0.378138, 0.165918,
3.75178,0.044599,-2.96132,-0.000349,0.999993,-0.003703,0.360988, 0.161849,
3.54293,0.037179,-4.94494,-0.000349,0.999993,-0.003703,0.369973, 0.018668,
3.35613,0.037179,-4.92796,-0.000349,0.999993,-0.003703,0.394511, 0.020432,
3.54959,0.044599,-2.94167,-0.99529,0,0.096941,0.378138, 0.165918,
3.35613,0.037179,-4.92796,-0.99529,0,0.096941,0.394511, 0.020432,
3.35613,-0.132266,-4.92796,-0.99529,0,0.096941,0.418775, 0.024631,
3.54959,-0.145054,-2.94167,-0.99529,0,0.096941,0.390356, 0.180157,
3.75178,0.044599,-2.96132,0.096722,0,0.995311,0.360988, 0.161849,
3.54959,0.044599,-2.94167,0.096722,0,0.995311,0.378138, 0.165918,
3.54959,-0.145054,-2.94167,0.096722,0,0.995311,0.390356, 0.180157,
3.75178,-0.145054,-2.96132,0.096722,0,0.995311,0.345174, 0.182963,
3.54293,0.037179,-4.94494,0.994503,0,-0.104707,0.369973, 0.018668,
3.75178,0.044599,-2.96132,0.994503,0,-0.104707,0.360988, 0.161849,
3.75178,-0.145054,-2.96132,0.994503,0,-0.104707,0.345174, 0.182963,
3.54293,-0.132266,-4.94494,0.994503,0,-0.104707,0.345174, 0.018373,
1.73289,0.131759,-4.90253,0.999998,0,-0.001999,0.948935, 0.694329,
1.7333,0.131759,-4.69643,0.999998,0,-0.001999,0.939344, 0.674226,
1.7333,-0.037685,-4.69643,0.999998,0,-0.001999,0.945847, 0.65465,
1.73289,-0.037685,-4.90253,0.999998,0,-0.001999,0.969986, 0.677122,
1.7333,0.131759,-4.69643,0.0079,0,0.999969,0.939344, 0.674226,
-0.008027,0.127915,-4.68267,0.0079,0,0.999969,0.817107, 0.672826,
-0.008027,-0.072136,-4.68267,0.0079,0,0.999969,0.804916, 0.65465,
1.7333,-0.037685,-4.69643,0.0079,0,0.999969,0.945847, 0.65465,
-0.008027,0.127915,-4.68267,-1,0,0.000317,0.817107, 0.672826,
-0.008096,0.127915,-4.90065,-1,0,0.000317,0.804355, 0.694005,
-0.008096,-0.072136,-4.90065,-1,0,0.000317,0.785006, 0.675733,
-0.008027,-0.072136,-4.68267,-1,0,0.000317,0.804916, 0.65465,
-0.008096,0.127915,-4.90065,-0.002208,0.999998,3e-006,0.804355, 0.694005,
-0.008027,0.127915,-4.68267,-0.002208,0.999998,3e-006,0.817107, 0.672826,
1.7333,0.131759,-4.69643,-0.002208,0.999998,3e-006,0.939344, 0.674226,
1.73289,0.131759,-4.90253,-0.002208,0.999998,3e-006,0.948935, 0.694329,
3.45579,0.13258,-5.0815,0.999974,0,-0.007192,0.948531, 0.600461,
3.45725,0.13258,-4.87747,0.999974,0,-0.007192,0.937829, 0.580568,
3.45725,-0.036865,-4.87747,0.999974,0,-0.007192,0.94399, 0.560652,
3.45579,-0.036865,-5.0815,0.999974,0,-0.007192,0.968922, 0.582118,
3.45725,0.13258,-4.87747,0.105318,0,0.994439,0.937829, 0.580568,
1.74185,0.128736,-4.6958,0.105318,0,0.994439,0.816308, 0.57828,
1.74185,-0.071315,-4.6958,0.105318,0,0.994439,0.803683, 0.560652,
3.45725,-0.036865,-4.87747,0.105318,0,0.994439,0.94399, 0.560652,
1.74185,0.128736,-4.6958,-0.999991,0,0.004293,0.816308, 0.57828,
1.74092,0.128736,-4.91248,-0.999991,0,0.004293,0.804537, 0.599049,
1.74092,-0.071315,-4.91248,-0.999991,0,0.004293,0.785006, 0.581806,
1.74185,-0.071315,-4.6958,-0.999991,0,0.004293,0.803683, 0.560652,
1.74092,0.128736,-4.91248,-0.00224,0.999997,1.3e-005,0.804537, 0.599049,
1.74185,0.128736,-4.6958,-0.00224,0.999997,1.3e-005,0.816308, 0.57828,
3.45725,0.13258,-4.87747,-0.00224,0.999997,1.3e-005,0.937829, 0.580568,
3.45579,0.13258,-5.0815,-0.00224,0.999997,1.3e-005,0.948531, 0.600461,
5.02177,0.13258,-5.25173,0.988674,0,-0.150081,0.959316, 0.055741,
5.05274,0.13258,-5.0477,0.988674,0,-0.150081,0.950494, 0.036324,
5.05274,-0.036865,-5.0477,0.988674,0,-0.150081,0.957626, 0.017754,
5.02177,-0.036865,-5.25173,0.988674,0,-0.150081,0.980125, 0.040172,
5.05274,0.13258,-5.0477,0.101831,0,0.994802,0.950494, 0.036324,
3.46717,0.128736,-4.8854,0.101831,0,0.994802,0.835711, 0.034825,
3.46717,-0.071315,-4.8854,0.101831,0,0.994802,0.823198, 0.017307,
5.05274,-0.036865,-5.0477,0.101831,0,0.994802,0.957626, 0.017754,
3.46717,0.128736,-4.8854,-0.999986,0,0.005203,0.835711, 0.034825,
3.46604,0.128736,-5.10208,-0.999986,0,0.005203,0.823736, 0.055741,
3.46604,-0.071315,-5.10208,-0.999986,0,0.005203,0.804333, 0.038325,
3.46717,-0.071315,-4.8854,-0.999986,0,0.005203,0.823198, 0.017307,
3.46604,0.128736,-5.10208,-0.002429,0.999997,0.000185,0.823736, 0.055741,
3.46717,0.128736,-4.8854,-0.002429,0.999997,0.000185,0.835711, 0.034825,
5.05274,0.13258,-5.0477,-0.002429,0.999997,0.000185,0.950494, 0.036324,
5.02177,0.13258,-5.25173,-0.002429,0.999997,0.000185,0.959316, 0.055741,
-0.01571,0.131759,-4.88543,0.999999,0,-0.001648,0.903603, 0.222958,
-0.01537,0.131759,-4.67933,0.999999,0,-0.001648,0.895659, 0.198962,
-0.01537,-0.037685,-4.67933,0.999999,0,-0.001648,0.902763, 0.178367,
-0.01571,-0.037685,-4.88543,0.999999,0,-0.001648,0.928289, 0.204572,
-0.01537,0.131759,-4.67933,-0.002046,0,0.999998,0.895659, 0.198962,
-1.6495,0.127915,-4.68267,-0.002046,0,0.999998,0.777371, 0.194586,
-1.6495,-0.072136,-4.68267,-0.002046,0,0.999998,0.765926, 0.178367,
-0.01537,-0.037685,-4.67933,-0.002046,0,0.999998,0.902763, 0.178367,
-1.6495,0.127915,-4.68267,-0.999952,0,0.009826,0.777371, 0.194586,
-1.65164,0.127915,-4.90065,-0.999952,0,0.009826,0.763932, 0.210401,
-1.65164,-0.072136,-4.90065,-0.999952,0,0.009826,0.748886, 0.194762,
-1.6495,-0.072136,-4.68267,-0.999952,0,0.009826,0.765926, 0.178367,
-1.65164,0.127915,-4.90065,-0.002351,0.999997,1.4e-005,0.763932, 0.210401,
-1.6495,0.127915,-4.68267,-0.002351,0.999997,1.4e-005,0.777371, 0.194586,
-0.01537,0.131759,-4.67933,-0.002351,0.999997,1.4e-005,0.895659, 0.198962,
-0.01571,0.131759,-4.88543,-0.002351,0.999997,1.4e-005,0.903603, 0.222958,
};
|
7b7abb7d7b8b33724e578b816e574f648d45f41a | ac357369f0af0a65bef865bde8ad9121ab9dcfed | /Server/RaftConsensus.cc | e2cd6cd4e00556911a0e305cd6bc52aa654f27f8 | [
"ISC"
] | permissive | jimpelton/mingle-logcabin | 9b695fcd228ae55ef984f8a35d3a77246bd64ec9 | 2e2b6f3aa3c270ba46b7731f9d6bf48dba75c916 | refs/heads/master | 2020-03-25T17:12:40.946335 | 2014-07-15T18:43:06 | 2014-07-15T18:43:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 45,156 | cc | RaftConsensus.cc | /* Copyright (c) 2012 Stanford University
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR(S) DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <algorithm>
#include <string.h>
#include <time.h>
#include "build/Protocol/Raft.pb.h"
#include "Core/Debug.h"
#include "Core/ProtoBuf.h"
#include "Core/Random.h"
#include "Core/StringUtil.h"
#include "Core/ThreadId.h"
#include "Core/Util.h"
#include "Protocol/Common.h"
#include "RPC/Buffer.h"
#include "RPC/ClientRPC.h"
#include "RPC/ClientSession.h"
#include "RPC/ProtoBuf.h"
#include "RPC/ServerRPC.h"
#include "Server/RaftConsensus.h"
#include "Server/Globals.h"
#include "Server/StateMachine.h"
namespace LogCabin {
namespace Server {
namespace RaftConsensusInternal {
bool startThreads = true;
////////// Server //////////
Server::Server(uint64_t serverId)
: serverId(serverId)
, address()
, gcFlag(false)
{
}
Server::~Server()
{
}
////////// LocalServer //////////
LocalServer::LocalServer(uint64_t serverId, RaftConsensus& consensus)
: Server(serverId)
, consensus(consensus)
{
}
LocalServer::~LocalServer()
{
}
void
LocalServer::abortRequestVote()
{
}
void
LocalServer::beginRequestVote()
{
}
void
LocalServer::exit()
{
}
uint64_t
LocalServer::getLastAckEpoch() const
{
return consensus.currentEpoch;
}
uint64_t
LocalServer::getLastAgreeId() const
{
return consensus.log->getLastLogId();
}
bool
LocalServer::haveVote() const
{
return (consensus.votedFor == serverId);
}
bool
LocalServer::isCaughtUp() const
{
return true;
}
////////// Peer //////////
Peer::Peer(uint64_t serverId, RaftConsensus& consensus)
: Server(serverId)
, consensus(consensus)
, eventLoop(consensus.globals.eventLoop)
, exiting(false)
, requestVoteDone(false)
, haveVote_(false)
, lastAgreeId(0)
, lastAckEpoch(0)
, nextHeartbeatTime(TimePoint::min())
, backoffUntil(TimePoint::min())
, lastCatchUpIterationMs(~0UL)
, thisCatchUpIterationStart(Clock::now())
, thisCatchUpIterationGoalId(~0UL)
, isCaughtUp_(false)
, session()
, thread()
{
}
Peer::~Peer()
{
}
void
Peer::abortRequestVote()
{
requestVoteDone = true;
haveVote_ = false;
lastAgreeId = 0;
}
void
Peer::beginRequestVote()
{
requestVoteDone = false;
haveVote_ = false;
lastAgreeId = 0;
}
void
Peer::exit()
{
exiting = true;
}
uint64_t
Peer::getLastAckEpoch() const
{
return lastAckEpoch;
}
uint64_t
Peer::getLastAgreeId() const
{
return lastAgreeId;
}
bool
Peer::haveVote() const
{
return haveVote_;
}
bool
Peer::isCaughtUp() const
{
return isCaughtUp_;
}
bool
Peer::callRPC(Protocol::Raft::OpCode opCode,
const google::protobuf::Message& request,
google::protobuf::Message& response)
{
typedef RPC::ClientRPC::Status RPCStatus;
RPC::ClientRPC rpc(getSession(),
Protocol::Common::ServiceId::RAFT_SERVICE,
/* serviceSpecificErrorVersion = */ 0,
opCode,
request);
switch (rpc.waitForReply(&response, NULL)) {
case RPCStatus::OK:
return true;
case RPCStatus::SERVICE_SPECIFIC_ERROR:
PANIC("unexpected service-specific error");
default:
WARNING("RPC to server failed: %s",
rpc.getErrorMessage().c_str());
return false;
}
}
void
Peer::startThread(std::shared_ptr<Peer> self)
{
thisCatchUpIterationStart = Clock::now();
thisCatchUpIterationGoalId = consensus.log->getLastLogId();
++consensus.numPeerThreads;
thread = std::thread(&RaftConsensus::followerThreadMain, &consensus, self);
thread.detach();
}
std::shared_ptr<RPC::ClientSession>
Peer::getSession()
{
if (!session || !session->getErrorMessage().empty()) {
session = RPC::ClientSession::makeSession(
eventLoop,
RPC::Address(address, Protocol::Common::DEFAULT_PORT),
Protocol::Common::MAX_MESSAGE_LENGTH);
}
return session;
}
////////// Configuration::SimpleConfiguration //////////
Configuration::SimpleConfiguration::SimpleConfiguration()
: servers()
{
}
Configuration::SimpleConfiguration::~SimpleConfiguration()
{
}
bool
Configuration::SimpleConfiguration::all(const Predicate& predicate) const
{
for (auto it = servers.begin(); it != servers.end(); ++it) {
if (!predicate(*it))
return false;
}
return true;
}
bool
Configuration::SimpleConfiguration::contains(std::shared_ptr<Server> server)
const
{
for (auto it = servers.begin(); it != servers.end(); ++it) {
if (*it == server)
return true;
}
return false;
}
void
Configuration::SimpleConfiguration::forEach(const SideEffect& sideEffect)
{
for (auto it = servers.begin(); it != servers.end(); ++it)
sideEffect(*it);
}
uint64_t
Configuration::SimpleConfiguration::min(const GetValue& getValue) const
{
if (servers.empty())
return 0;
uint64_t smallest = ~0UL;
for (auto it = servers.begin(); it != servers.end(); ++it)
smallest = std::min(smallest, getValue(*it));
return smallest;
}
bool
Configuration::SimpleConfiguration::quorumAll(const Predicate& predicate) const
{
if (servers.empty())
return true;
uint64_t count = 0;
for (auto it = servers.begin(); it != servers.end(); ++it)
if (predicate(*it))
++count;
return (count >= servers.size() / 2 + 1);
}
uint64_t
Configuration::SimpleConfiguration::quorumMin(const GetValue& getValue) const
{
if (servers.empty())
return 0;
std::vector<uint64_t> values;
for (auto it = servers.begin(); it != servers.end(); ++it)
values.push_back(getValue(*it));
std::sort(values.begin(), values.end());
return values.at((values.size() - 1)/ 2);
}
////////// Configuration //////////
Configuration::Configuration(uint64_t serverId, RaftConsensus& consensus)
: consensus(consensus)
, knownServers()
, localServer()
, state(State::BLANK)
, id(0)
, description()
, oldServers()
, newServers()
{
localServer.reset(new LocalServer(serverId, consensus));
knownServers[serverId] = localServer;
}
Configuration::~Configuration()
{
}
void
Configuration::forEach(const SideEffect& sideEffect)
{
for (auto it = knownServers.begin(); it != knownServers.end(); ++it)
sideEffect(it->second);
}
bool
Configuration::hasVote(std::shared_ptr<Server> server) const
{
if (state == State::TRANSITIONAL) {
return (oldServers.contains(server) ||
newServers.contains(server));
} else {
return oldServers.contains(server);
}
}
bool
Configuration::quorumAll(const Predicate& predicate) const
{
if (state == State::TRANSITIONAL) {
return (oldServers.quorumAll(predicate) &&
newServers.quorumAll(predicate));
} else {
return oldServers.quorumAll(predicate);
}
}
uint64_t
Configuration::quorumMin(const GetValue& getValue) const
{
if (state == State::TRANSITIONAL) {
return std::min(oldServers.quorumMin(getValue),
newServers.quorumMin(getValue));
} else {
return oldServers.quorumMin(getValue);
}
}
void
Configuration::resetStagingServers()
{
if (state == State::STAGING) {
// staging servers could have changed other servers' addresses, so roll
// back to old description with old addresses
setConfiguration(id, description);
}
}
namespace {
void setGCFlag(std::shared_ptr<Server> server)
{
server->gcFlag = true;
}
} // anonymous namespace
void
Configuration::setConfiguration(
uint64_t newId,
const Protocol::Raft::Configuration& newDescription)
{
NOTICE("Activating configuration %lu:\n%s", newId,
Core::ProtoBuf::dumpString(newDescription, false).c_str());
if (newDescription.next_configuration().servers().size() == 0)
state = State::STABLE;
else
state = State::TRANSITIONAL;
id = newId;
description = newDescription;
oldServers.servers.clear();
newServers.servers.clear();
// Build up the list of old servers
for (auto confIt = description.prev_configuration().servers().begin();
confIt != description.prev_configuration().servers().end();
++confIt) {
std::shared_ptr<Server> server = getServer(confIt->server_id());
server->address = confIt->address();
oldServers.servers.push_back(server);
}
// Build up the list of new servers
for (auto confIt = description.next_configuration().servers().begin();
confIt != description.next_configuration().servers().end();
++confIt) {
std::shared_ptr<Server> server = getServer(confIt->server_id());
server->address = confIt->address();
newServers.servers.push_back(server);
}
// Servers not in the current configuration need to be told to exit
setGCFlag(localServer);
oldServers.forEach(setGCFlag);
newServers.forEach(setGCFlag);
auto it = knownServers.begin();
while (it != knownServers.end()) {
std::shared_ptr<Server> server = it->second;
if (!server->gcFlag) {
server->exit();
it = knownServers.erase(it);
} else {
server->gcFlag = false; // clear flag for next time
++it;
}
}
}
void
Configuration::setStagingServers(
const Protocol::Raft::SimpleConfiguration& stagingServers)
{
assert(state == State::STABLE);
state = State::STAGING;
for (auto it = stagingServers.servers().begin();
it != stagingServers.servers().end();
++it) {
std::shared_ptr<Server> server = getServer(it->server_id());
server->address = it->address();
newServers.servers.push_back(server);
}
}
bool
Configuration::stagingAll(const Predicate& predicate) const
{
if (state == State::STAGING)
return newServers.all(predicate);
else
return true;
}
uint64_t
Configuration::stagingMin(const GetValue& getValue) const
{
if (state == State::STAGING)
return newServers.min(getValue);
else
return 0;
}
std::ostream&
operator<<(std::ostream& os, Configuration::State state)
{
typedef Configuration::State State;
switch (state) {
case State::BLANK:
os << "State::BLANK";
break;
case State::STABLE:
os << "State::STABLE";
break;
case State::STAGING:
os << "State::STAGING";
break;
case State::TRANSITIONAL:
os << "State::TRANSITIONAL";
break;
}
return os;
}
////////// Configuration private methods //////////
std::shared_ptr<Server>
Configuration::getServer(uint64_t newServerId)
{
auto it = knownServers.find(newServerId);
if (it != knownServers.end()) {
return it->second;
} else {
std::shared_ptr<Peer> peer(new Peer(newServerId, consensus));
if (startThreads)
peer->startThread(peer);
knownServers[newServerId] = peer;
return peer;
}
}
////////// RaftConsensus //////////
uint64_t RaftConsensus::FOLLOWER_TIMEOUT_MS = 150;
uint64_t RaftConsensus::CANDIDATE_TIMEOUT_MS = 150;
uint64_t RaftConsensus::HEARTBEAT_PERIOD_MS = FOLLOWER_TIMEOUT_MS / 2;
// this is just set high for now so log messages shut up
uint64_t RaftConsensus::RPC_FAILURE_BACKOFF_MS = 2000;
uint64_t RaftConsensus::SOFT_RPC_SIZE_LIMIT =
Protocol::Common::MAX_MESSAGE_LENGTH - 1024;
RaftConsensus::RaftConsensus(Globals& globals)
: globals(globals)
, mutex()
, stateChanged()
, exiting(false)
, numPeerThreads(0)
, log()
, configuration()
, currentTerm(0)
, state(State::FOLLOWER)
, electionAttempt(0)
, committedId(0)
, leaderId(0)
, votedFor(0)
, currentEpoch(0)
, startElectionAt(TimePoint::max())
, candidacyThread()
, stepDownThread()
, invariants(*this)
{
}
RaftConsensus::~RaftConsensus()
{
exit();
if (candidacyThread.joinable())
candidacyThread.join();
if (stepDownThread.joinable())
stepDownThread.join();
std::unique_lock<Mutex> lockGuard(mutex);
while (numPeerThreads > 0)
stateChanged.wait(lockGuard);
}
void
RaftConsensus::init()
{
std::unique_lock<Mutex> lockGuard(mutex);
mutex.callback = std::bind(&Invariants::checkAll, &invariants);
NOTICE("My server ID is %lu", serverId);
if (!log) { // some unit tests pre-set the log; don't overwrite it
// TODO(ongaro): use configuration option instead of hard-coded string
log.reset(new Log(Core::StringUtil::format("log/%lu", serverId)));
}
NOTICE("Last log ID: %lu", log->getLastLogId());
if (log->metadata.has_current_term())
currentTerm = log->metadata.current_term();
if (log->metadata.has_voted_for())
votedFor = log->metadata.voted_for();
updateLogMetadata();
configuration.reset(new Configuration(serverId, *this));
scanForConfiguration();
if (configuration->state == Configuration::State::BLANK)
NOTICE("No configuration, waiting to receive one");
stepDown(currentTerm);
if (startThreads) {
candidacyThread = std::thread(&RaftConsensus::candidacyThreadMain,
this);
stepDownThread = std::thread(&RaftConsensus::stepDownThreadMain,
this);
}
// log->path = ""; // hack to disable disk
stateChanged.notify_all();
}
void
RaftConsensus::exit()
{
std::unique_lock<Mutex> lockGuard(mutex);
exiting = true;
if (configuration)
configuration->forEach(&Server::exit);
interruptAll();
}
RaftConsensus::ClientResult
RaftConsensus::getConfiguration(
Protocol::Raft::SimpleConfiguration& currentConfiguration,
uint64_t& id) const
{
std::unique_lock<Mutex> lockGuard(mutex);
if (!upToDateLeader(lockGuard))
return ClientResult::NOT_LEADER;
if (configuration->state != Configuration::State::STABLE ||
committedId < configuration->id) {
return ClientResult::RETRY;
}
currentConfiguration = configuration->description.prev_configuration();
id = configuration->id;
return ClientResult::SUCCESS;
}
std::pair<RaftConsensus::ClientResult, uint64_t>
RaftConsensus::getLastCommittedId() const
{
std::unique_lock<Mutex> lockGuard(mutex);
if (!upToDateLeader(lockGuard))
return {ClientResult::NOT_LEADER, 0};
else
return {ClientResult::SUCCESS, committedId};
}
Consensus::Entry
RaftConsensus::getNextEntry(uint64_t lastEntryId) const
{
std::unique_lock<Mutex> lockGuard(mutex);
uint64_t nextEntryId = lastEntryId + 1;
while (true) {
if (exiting)
throw ThreadInterruptedException();
if (committedId >= nextEntryId) {
const Log::Entry& logEntry = log->getEntry(nextEntryId);
Consensus::Entry entry;
entry.entryId = logEntry.entryId;
if (logEntry.type == Protocol::Raft::EntryType::DATA) {
entry.hasData = true;
entry.data = logEntry.data;
}
return entry;
}
stateChanged.wait(lockGuard);
}
}
void
RaftConsensus::handleAppendEntry(
const Protocol::Raft::AppendEntry::Request& request,
Protocol::Raft::AppendEntry::Response& response)
{
std::unique_lock<Mutex> lockGuard(mutex);
assert(!exiting);
// If the caller's term is stale, just return our term to it.
if (request.term() < currentTerm) {
VERBOSE("Caller(%lu) is stale. Our term is %lu, theirs is %lu",
request.server_id(), currentTerm, request.term());
response.set_term(currentTerm);
return;
}
// A new leader should always calls requestVote on this server before
// calling appendEntry; thus, we should not see a new term here.
assert(request.term() == currentTerm);
// Record the leader ID as a hint for clients.
if (leaderId == 0) {
// Candidates must step down when they discover the current leader.
stepDown(currentTerm);
leaderId = request.server_id();
NOTICE("All hail leader %lu for term %lu", leaderId, currentTerm);
}
assert(leaderId == request.server_id());
assert(state == State::FOLLOWER);
// This request is a sign of life from the current leader. Reset our timer
// so that we do not start a new election soon.
stepDown(currentTerm);
// For an entry to fit into our log, it must not leave a gap.
assert(request.prev_log_id() <= log->getLastLogId());
// It must also agree with the previous entry in the log (and, inductively
// all prior entries).
assert(log->getTerm(request.prev_log_id()) == request.prev_log_term());
// This needs to be able to handle duplicated RPC requests. We compare the
// entries' terms to know if we need to do the operation; otherwise,
// reapplying requests can result in data loss.
//
// The first problem this solves is that an old AppendEntry request may be
// duplicated and received after a newer request, which could cause
// undesirable data loss. For example, suppose the leader appends entry 4
// and then entry 5, but the follower receives 4, then 5, then 4 again.
// Without this extra guard, the follower would truncate 5 out of its
// log.
//
// The second problem is more subtle: if the same request is duplicated but
// the leader processes an earlier response, it will assume the
// acknowledged data is safe. However, there is a window of vulnerability
// on the follower's disk between the truncate and append operations (which
// are not done atomically) when the follower processes the later request.
uint64_t entryId = request.prev_log_id();
for (auto it = request.entries().begin();
it != request.entries().end();
++it) {
++entryId;
if (log->getTerm(entryId) == it->term())
continue;
if (log->getLastLogId() >= entryId) {
assert(committedId < entryId);
// TODO(ongaro): assertion: what I'm truncating better belong to
// only 1 term
NOTICE("Truncating %lu entries",
log->getLastLogId() - entryId + 1);
log->truncate(entryId - 1);
if (configuration->id >= entryId) {
// truncate can affect current configuration
scanForConfiguration();
}
}
Log::Entry entry;
entry.term = it->term();
entry.type = it->type();
switch (entry.type) {
case Protocol::Raft::EntryType::CONFIGURATION:
entry.configuration = it->configuration();
break;
case Protocol::Raft::EntryType::DATA:
entry.data = it->data();
break;
default:
PANIC("bad entry type");
}
uint64_t e = append(entry);
assert(e == entryId);
}
// The request's committed ID may be lower than ours: the protocol
// guarantees that a server with all committed entries becomes the new
// leader, but it does not guarantee that the new leader has the largest
// committed ID. We want our committed ID to monotonically increase over
// time, so we only update it if the request's is larger.
if (committedId < request.committed_id()) {
committedId = request.committed_id();
assert(committedId <= log->getLastLogId());
stateChanged.notify_all();
VERBOSE("New committedId: %lu", committedId);
}
response.set_term(currentTerm);
}
void
RaftConsensus::handleRequestVote(
const Protocol::Raft::RequestVote::Request& request,
Protocol::Raft::RequestVote::Response& response)
{
std::unique_lock<Mutex> lockGuard(mutex);
if (request.term() > currentTerm) {
VERBOSE("Caller(%lu) has newer term, updating. "
"Ours was %lu, theirs is %lu",
request.server_id(), currentTerm, request.term());
if (state == State::CANDIDATE) {
abortElection(request.term());
} else {
stepDown(request.term());
}
}
// At this point, if leaderId != 0, we could tell the caller to step down.
// However, this is just an optimization that does not affect correctness
// or really even efficiency, so it's not worth the trouble.
// If the caller has a less complete log, we can't give it our vote.
uint64_t lastLogId = log->getLastLogId();
uint64_t lastLogTerm = log->getTerm(lastLogId);
bool logIsOk = (request.last_log_term() > lastLogTerm ||
(request.last_log_term() == lastLogTerm &&
request.last_log_id() >= lastLogId));
if (request.term() == currentTerm && logIsOk && votedFor == 0) {
// Give caller our vote
VERBOSE("Voting for %lu in term %lu",
request.server_id(), currentTerm);
stepDown(currentTerm);
votedFor = request.server_id();
updateLogMetadata();
}
// Fill in response.
response.set_term(currentTerm);
// don't strictly need the first condition
response.set_granted(request.term() == currentTerm &&
votedFor == request.server_id());
response.set_last_log_term(lastLogTerm);
response.set_last_log_id(lastLogId);
response.set_begin_last_term_id(log->getBeginLastTermId());
}
std::pair<RaftConsensus::ClientResult, uint64_t>
RaftConsensus::replicate(const std::string& operation)
{
std::unique_lock<Mutex> lockGuard(mutex);
VERBOSE("replicate(%s)", operation.c_str());
Log::Entry entry;
entry.type = Protocol::Raft::EntryType::DATA;
entry.data = operation;
return replicateEntry(entry, lockGuard);
}
RaftConsensus::ClientResult
RaftConsensus::setConfiguration(
uint64_t oldId,
const Protocol::Raft::SimpleConfiguration& nextConfiguration)
{
std::unique_lock<Mutex> lockGuard(mutex);
if (state != State::LEADER)
return ClientResult::NOT_LEADER;
if (configuration->id != oldId ||
configuration->state != Configuration::State::STABLE) {
// configurations has changed in the meantime
return ClientResult::FAIL;
}
uint64_t term = currentTerm;
configuration->setStagingServers(nextConfiguration);
stateChanged.notify_all();
// Wait for new servers to be caught up. This will abort if not every
// server makes progress in a FOLLOWER_TIMEOUT_MS period.
++currentEpoch;
uint64_t epoch = currentEpoch;
TimePoint checkProgressAt =
Clock::now() + std::chrono::milliseconds(FOLLOWER_TIMEOUT_MS);
while (true) {
if (exiting || term != currentTerm)
return ClientResult::NOT_LEADER;
if (configuration->stagingAll(&Server::isCaughtUp))
break;
if (Clock::now() >= checkProgressAt) {
if (configuration->stagingMin(&Server::getLastAckEpoch) < epoch) {
configuration->resetStagingServers();
stateChanged.notify_all();
// TODO(ongaro): probably need to return a different type of
// message: confuses oldId mismatch from new server down
return ClientResult::FAIL;
} else {
++currentEpoch;
epoch = currentEpoch;
checkProgressAt =
(Clock::now() +
std::chrono::milliseconds(FOLLOWER_TIMEOUT_MS));
}
}
stateChanged.wait_until(lockGuard, checkProgressAt);
}
// Write and commit transitional configuration
Protocol::Raft::Configuration newConfiguration;
*newConfiguration.mutable_prev_configuration() =
configuration->description.prev_configuration();
*newConfiguration.mutable_next_configuration() = nextConfiguration;
Log::Entry entry;
entry.type = Protocol::Raft::EntryType::CONFIGURATION;
entry.configuration = newConfiguration;
std::pair<ClientResult, uint64_t> result =
replicateEntry(entry, lockGuard);
if (result.first != ClientResult::SUCCESS)
return result.first;
uint64_t transitionalId = result.second;
// Wait until the configuration that removes the old servers has been
// committed. This is the first configuration with ID greater than
// transitionalId.
while (true) {
// Check this first: if the new configuration excludes us so we've
// stepped down upon committing it, we still want to return success.
if (configuration->id > transitionalId &&
committedId >= configuration->id) {
return ClientResult::SUCCESS;
}
if (exiting || term != currentTerm)
return ClientResult::NOT_LEADER;
stateChanged.wait(lockGuard);
}
}
std::ostream&
operator<<(std::ostream& os, const RaftConsensus& raft)
{
std::unique_lock<Mutex> lockGuard(raft.mutex);
typedef RaftConsensus::State State;
os << "server id: " << raft.serverId << std::endl;
os << "term: " << raft.currentTerm << std::endl;
os << "state: " << raft.state << std::endl;
os << "leader: " << raft.leaderId << std::endl;
switch (raft.state) {
case State::FOLLOWER:
os << "vote: ";
if (raft.votedFor == 0)
os << "available";
else
os << "given to " << raft.votedFor;
os << std::endl;
break;
case State::CANDIDATE:
break;
case State::LEADER: {
break;
}
}
return os;
}
//// RaftConsensus private methods that MUST acquire the lock
void
RaftConsensus::candidacyThreadMain()
{
std::unique_lock<Mutex> lockGuard(mutex);
Core::ThreadId::setName("startNewElection");
while (!exiting) {
if (Clock::now() >= startElectionAt)
startNewElection();
stateChanged.wait_until(lockGuard, startElectionAt);
}
}
void
RaftConsensus::followerThreadMain(std::shared_ptr<Peer> peer)
{
std::unique_lock<Mutex> lockGuard(mutex);
Core::ThreadId::setName(
Core::StringUtil::format("Peer(%lu)", peer->serverId));
// Each iteration of this loop issues a new RPC or sleeps on the condition
// variable.
while (!peer->exiting) {
TimePoint now = Clock::now();
TimePoint waitUntil = TimePoint::min();
if (peer->backoffUntil > now) {
waitUntil = peer->backoffUntil;
} else {
switch (state) {
// Followers don't issue RPCs.
case State::FOLLOWER:
waitUntil = TimePoint::max();
break;
// Candidates request votes.
case State::CANDIDATE:
if (!peer->requestVoteDone)
requestVote(lockGuard, *peer);
else
waitUntil = TimePoint::max();
break;
// Leaders use requestVote to get the follower's log info,
// then replicate data and periodically send heartbeats.
case State::LEADER:
if (!peer->requestVoteDone) {
requestVote(lockGuard, *peer);
} else {
if (peer->lastAgreeId == log->getLastLogId() &&
now < peer->nextHeartbeatTime) {
waitUntil = peer->nextHeartbeatTime;
} else {
appendEntry(lockGuard, *peer);
}
}
break;
}
}
stateChanged.wait_until(lockGuard, waitUntil);
}
// must return immediately after this
--numPeerThreads;
stateChanged.notify_all();
}
void
RaftConsensus::stepDownThreadMain()
{
std::unique_lock<Mutex> lockGuard(mutex);
Core::ThreadId::setName("stepDown");
while (true) {
// Wait until this server is the leader and is not the only server in
// the cluster.
while (true) {
if (exiting)
return;
if (state == State::LEADER) {
// If this local server forms a quorum (it is the only server
// in the configuration), we need to sleep. Without this guard,
// this method would not relinquish the CPU.
++currentEpoch;
if (configuration->quorumMin(&Server::getLastAckEpoch) <
currentEpoch) {
break;
}
}
stateChanged.wait(lockGuard);
}
// Now, if a FOLLOWER_TIMEOUT goes by without confirming leadership,
// step down. FOLLOWER_TIMEOUT is a reasonable amount of time, since
// it's about when other servers will start elections and bump the
// term.
TimePoint stepDownAt =
Clock::now() + std::chrono::milliseconds(FOLLOWER_TIMEOUT_MS);
uint64_t term = currentTerm;
uint64_t epoch = currentEpoch; // currentEpoch was incremented above
while (true) {
if (exiting)
return;
if (currentTerm > term)
break;
if (configuration->quorumMin(&Server::getLastAckEpoch) >= epoch)
break;
if (Clock::now() >= stepDownAt) {
NOTICE("No broadcast for a timeout, stepping down");
stepDown(currentTerm + 1);
break;
}
stateChanged.wait_until(lockGuard, stepDownAt);
}
}
}
//// RaftConsensus private methods that MUST NOT acquire the lock
void
RaftConsensus::abortElection(uint64_t newTerm)
{
assert(state == State::CANDIDATE);
assert(currentTerm < newTerm);
currentTerm = newTerm;
leaderId = 0;
votedFor = 0;
configuration->forEach(&Server::abortRequestVote);
updateLogMetadata();
interruptAll();
}
void
RaftConsensus::advanceCommittedId()
{
if (state != State::LEADER) {
// getLastAgreeId is undefined unless we're leader
WARNING("advanceCommittedId called as %s",
Core::StringUtil::toString(state).c_str());
return;
}
// calculate the largest entry ID stored on a quorum of servers
uint64_t newCommittedId =
configuration->quorumMin(&Server::getLastAgreeId);
if (committedId >= newCommittedId)
return;
committedId = newCommittedId;
VERBOSE("New committedId: %lu", committedId);
assert(committedId <= log->getLastLogId());
stateChanged.notify_all();
if (state == State::LEADER && committedId >= configuration->id) {
// Upon committing a configuration that excludes itself, the leader
// steps down.
if (!configuration->hasVote(configuration->localServer)) {
stepDown(currentTerm + 1);
return;
}
// Upon committing a reconfiguration (Cold,new) entry, the leader
// creates the next configuration (Cnew) entry.
if (configuration->state == Configuration::State::TRANSITIONAL &&
isLeaderReady()) {
Log::Entry entry;
entry.term = currentTerm;
entry.type = Protocol::Raft::EntryType::CONFIGURATION;
*entry.configuration.mutable_prev_configuration() =
configuration->description.next_configuration();
append(entry);
advanceCommittedId();
return;
}
}
}
uint64_t
RaftConsensus::append(const Log::Entry& entry)
{
assert(entry.term != 0);
uint64_t entryId = log->append(entry);
if (entry.type == Protocol::Raft::EntryType::CONFIGURATION)
configuration->setConfiguration(entryId, entry.configuration);
stateChanged.notify_all();
return entryId;
}
void
RaftConsensus::appendEntry(std::unique_lock<Mutex>& lockGuard,
Peer& peer)
{
// Build up request
Protocol::Raft::AppendEntry::Request request;
request.set_server_id(serverId);
request.set_term(currentTerm);
uint64_t lastLogId = log->getLastLogId();
uint64_t prevLogId = peer.lastAgreeId;
request.set_prev_log_term(log->getTerm(prevLogId));
request.set_prev_log_id(prevLogId);
// Add entries
uint64_t numEntries = 0;
for (uint64_t entryId = prevLogId + 1; entryId <= lastLogId; ++entryId) {
const Log::Entry& entry = log->getEntry(entryId);
Protocol::Raft::Entry* e = request.add_entries();
e->set_term(entry.term);
e->set_type(entry.type);
switch (entry.type) {
case Protocol::Raft::EntryType::CONFIGURATION:
*e->mutable_configuration() = entry.configuration;
break;
case Protocol::Raft::EntryType::DATA:
e->set_data(entry.data);
break;
default:
PANIC("bad entry type");
}
uint64_t requestSize =
Core::Util::downCast<uint64_t>(request.ByteSize());
if (requestSize < SOFT_RPC_SIZE_LIMIT || numEntries == 0) {
// this entry fits, send it
VERBOSE("sending entry <id=%lu,term=%lu>", entryId, entry.term);
++numEntries;
} else {
// this entry doesn't fit, discard it
request.mutable_entries()->RemoveLast();
}
}
request.set_committed_id(std::min(committedId, prevLogId + numEntries));
// Execute RPC
Protocol::Raft::AppendEntry::Response response;
TimePoint start = Clock::now();
uint64_t epoch = currentEpoch;
lockGuard.unlock();
bool ok = peer.callRPC(Protocol::Raft::OpCode::APPEND_ENTRY,
request, response);
lockGuard.lock();
if (!ok) {
peer.backoffUntil = start +
std::chrono::milliseconds(RPC_FAILURE_BACKOFF_MS);
return;
}
// Process response
if (currentTerm != request.term() || peer.exiting) {
// we don't care about result of RPC
return;
}
// Since we were leader in this term before, we must still be leader in
// this term.
assert(state == State::LEADER);
if (response.term() > currentTerm) {
stepDown(response.term());
} else {
assert(response.term() == currentTerm);
peer.lastAckEpoch = epoch;
stateChanged.notify_all();
peer.nextHeartbeatTime = start +
std::chrono::milliseconds(HEARTBEAT_PERIOD_MS);
peer.lastAgreeId += numEntries;
advanceCommittedId();
if (!peer.isCaughtUp_ &&
peer.thisCatchUpIterationGoalId <= peer.lastAgreeId) {
Clock::duration duration =
Clock::now() - peer.thisCatchUpIterationStart;
uint64_t thisCatchUpIterationMs =
std::chrono::duration_cast<std::chrono::milliseconds>(
duration).count();
if (uint64_t(labs(peer.lastCatchUpIterationMs -
thisCatchUpIterationMs)) < FOLLOWER_TIMEOUT_MS) {
peer.isCaughtUp_ = true;
stateChanged.notify_all();
} else {
peer.lastCatchUpIterationMs = thisCatchUpIterationMs;
peer.thisCatchUpIterationStart = Clock::now();
peer.thisCatchUpIterationGoalId = log->getLastLogId();
}
}
}
}
void
RaftConsensus::becomeLeader()
{
assert(state == State::CANDIDATE);
NOTICE("Now leader for term %lu", currentTerm);
state = State::LEADER;
leaderId = serverId;
startElectionAt = TimePoint::max();
advanceCommittedId();
stateChanged.notify_all();
}
void
RaftConsensus::interruptAll()
{
stateChanged.notify_all();
// TODO(ongaro): ideally, this would go abort any current RPC, but RPC
// objects aren't presently thread-safe
}
bool
RaftConsensus::isLeaderReady() const
{
assert(state == State::LEADER);
uint64_t firstUncommittedTerm = log->getTerm(committedId + 1);
return (firstUncommittedTerm == 0 || firstUncommittedTerm == currentTerm);
}
std::pair<RaftConsensus::ClientResult, uint64_t>
RaftConsensus::replicateEntry(Log::Entry& entry,
std::unique_lock<Mutex>& lockGuard)
{
if (state == State::LEADER) {
if (!isLeaderReady())
return {ClientResult::RETRY, 0};
entry.term = currentTerm;
uint64_t entryId = append(entry);
advanceCommittedId();
while (!exiting && currentTerm == entry.term) {
if (committedId >= entryId) {
VERBOSE("replicate succeeded");
return {ClientResult::SUCCESS, entryId};
}
stateChanged.wait(lockGuard);
}
}
return {ClientResult::NOT_LEADER, 0};
}
void
RaftConsensus::requestVote(std::unique_lock<Mutex>& lockGuard, Peer& peer)
{
Protocol::Raft::RequestVote::Request request;
request.set_server_id(serverId);
request.set_term(currentTerm);
request.set_last_log_term(log->getTerm(log->getLastLogId()));
request.set_last_log_id(log->getLastLogId());
Protocol::Raft::RequestVote::Response response;
lockGuard.unlock();
VERBOSE("requestVote start");
TimePoint start = Clock::now();
uint64_t epoch = currentEpoch;
bool ok = peer.callRPC(Protocol::Raft::OpCode::REQUEST_VOTE,
request, response);
VERBOSE("requestVote done");
lockGuard.lock();
if (!ok) {
peer.backoffUntil = start +
std::chrono::milliseconds(RPC_FAILURE_BACKOFF_MS);
return;
}
if (currentTerm != request.term() || state == State::FOLLOWER ||
peer.exiting) {
VERBOSE("ignore RPC result");
// we don't care about result of RPC
return;
}
if (response.term() > currentTerm) {
if (state == State::LEADER) {
stepDown(response.term());
} else {
assert(state == State::CANDIDATE);
abortElection(response.term());
}
} else {
peer.requestVoteDone = true;
peer.lastAckEpoch = epoch;
stateChanged.notify_all();
// The peer's response.begin_last_term_id() - 1 is committed, since
// only entries in the peer's last term might be uncommitted. If we
// successfully become leader, we also have it. If not, lastAgreeId is
// undefined anyway.
peer.lastAgreeId = response.begin_last_term_id() - 1;
// Beyond that, we agree with the peer on any entries that match terms
// with ours.
for (uint64_t entryId = response.begin_last_term_id();
entryId <= response.last_log_id();
++entryId) {
if (log->getTerm(entryId) != response.last_log_term())
break;
peer.lastAgreeId = entryId;
}
if (state == State::LEADER) {
advanceCommittedId();
} else {
assert(state == State::CANDIDATE);
if (response.granted()) {
peer.haveVote_ = true;
VERBOSE("Got vote for term %lu", currentTerm);
if (configuration->quorumAll(&Server::haveVote))
becomeLeader();
} else {
VERBOSE("vote not granted");
}
}
}
}
void
RaftConsensus::scanForConfiguration()
{
for (uint64_t entryId = log->getLastLogId(); entryId > 0; --entryId) {
const Log::Entry& entry = log->getEntry(entryId);
if (entry.type == Protocol::Raft::EntryType::CONFIGURATION) {
configuration->setConfiguration(entryId, entry.configuration);
return;
}
}
// the configuration is never cleared out
assert(configuration->state == Configuration::State::BLANK);
}
void
RaftConsensus::setFollowerTimer()
{
uint64_t ms = Core::Random::randomRange(
FOLLOWER_TIMEOUT_MS,
uint64_t(double(FOLLOWER_TIMEOUT_MS) * 1.25));
VERBOSE("Will become candidate in %lu ms", ms);
startElectionAt = Clock::now() + std::chrono::milliseconds(ms);
stateChanged.notify_all();
}
void
RaftConsensus::setCandidateTimer(uint64_t attempt)
{
// truncated random exponential backoff
// The timer is set for a random value between
// 0 and CANDIDATE_TIMEOUT_MS * 2**(attempt - 1)
// from now. If this value exceeds FOLLOWER_TIMEOUT_MS, FOLLOWER_TIMEOUT_MS
// is used instead.
// TODO(ongaro): john suggests multiplying by N-ish, and using the
// broadcast time instead of 0.
assert(attempt > 0);
uint64_t scale;
if (attempt == 1)
scale = 1;
else if (attempt > 20)
scale = (2 << 18);
else
scale = (2 << (attempt - 2));
// scale is now 2**(attempt-1)
uint64_t minMs = 0;
uint64_t maxMs = std::min(CANDIDATE_TIMEOUT_MS * scale,
FOLLOWER_TIMEOUT_MS);
uint64_t ms = Core::Random::randomRange(minMs, maxMs);
startElectionAt = Clock::now() + std::chrono::milliseconds(ms);
stateChanged.notify_all();
}
void
RaftConsensus::startNewElection()
{
if (!configuration->hasVote(configuration->localServer)) {
// Don't have a configuration or not part of the current configuration:
// go back to sleep.
return;
}
if (electionAttempt == 0) {
// too verbose otherwise when server is partitioned
NOTICE("Running for election in term %lu", currentTerm + 1);
}
++currentTerm;
state = State::CANDIDATE;
leaderId = 0;
votedFor = serverId;
++electionAttempt;
setCandidateTimer(electionAttempt);
configuration->forEach(&Server::beginRequestVote);
updateLogMetadata();
interruptAll();
// if we're the only server, this election is already done
if (configuration->quorumAll(&Server::haveVote))
becomeLeader();
}
void
RaftConsensus::stepDown(uint64_t newTerm)
{
assert(currentTerm <= newTerm);
if (currentTerm < newTerm) {
VERBOSE("stepDown(%lu)", newTerm);
currentTerm = newTerm;
leaderId = 0;
votedFor = 0;
updateLogMetadata();
configuration->resetStagingServers();
}
state = State::FOLLOWER;
electionAttempt = 0;
setFollowerTimer();
interruptAll();
}
void
RaftConsensus::updateLogMetadata()
{
log->metadata.set_current_term(currentTerm);
log->metadata.set_voted_for(votedFor);
VERBOSE("updateMetadata start");
log->updateMetadata();
VERBOSE("updateMetadata end");
}
bool
RaftConsensus::upToDateLeader(std::unique_lock<Mutex>& lockGuard) const
{
++currentEpoch;
uint64_t epoch = currentEpoch;
while (true) {
if (exiting || state != State::LEADER)
return false;
if (configuration->quorumMin(&Server::getLastAckEpoch) >=
epoch) {
return true;
}
stateChanged.wait(lockGuard);
}
}
std::ostream&
operator<<(std::ostream& os, RaftConsensus::ClientResult clientResult)
{
typedef RaftConsensus::ClientResult ClientResult;
switch (clientResult) {
case ClientResult::SUCCESS:
os << "ClientResult::SUCCESS";
break;
case ClientResult::FAIL:
os << "ClientResult::FAIL";
break;
case ClientResult::RETRY:
os << "ClientResult::RETRY";
break;
case ClientResult::NOT_LEADER:
os << "ClientResult::NOT_LEADER";
break;
}
return os;
}
std::ostream&
operator<<(std::ostream& os, RaftConsensus::State state)
{
typedef RaftConsensus::State State;
switch (state) {
case State::FOLLOWER:
os << "State::FOLLOWER";
break;
case State::CANDIDATE:
os << "State::CANDIDATE";
break;
case State::LEADER:
os << "State::LEADER";
break;
}
return os;
}
} // namespace RaftConsensusInternal
} // namespace LogCabin::Server
} // namespace LogCabin
|
928a7c857168f9d74b4da75618f135f981b9dc95 | 491f11457d9b28ce6d86ca3760b87c871c99b94e | /Random/cybernautes.cpp | 55f9e2a0d51b52ccacd69187ddee16b0d53d2c10 | [] | no_license | jongli747/Contest-Code | 3d5d400bd61114a085f914163433be3b406523ee | 57d7f4fe830edb3b00ec284e0b1d7a14df7fe128 | refs/heads/master | 2021-01-10T23:17:13.181515 | 2018-11-10T19:42:08 | 2018-11-10T19:42:08 | 70,623,962 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 519 | cpp | cybernautes.cpp | #include<bits/stdc++.h>
using namespace std;
int n, sum, summ;
char str[100];
int main()
{
cin >> n >> str;
for(int i=0; i<=n-1; i++)
{
if(str[i] != '4' && str[i] != '7'){
cout << "No" << endl;
return 0;
}
}
for(int i=0; i<=(n/2)-1; i++)
{
sum = sum + str[i];
}
for(int j = n/2; j <= n-1; j++)
{
summ = summ + str[j];
}
if(sum != summ)
cout << "No" << endl;
else
cout << "Yes" << endl;
return 0;
}
|
0c21de145527f61c671445e64a74f4f71d66ed5d | 714bbe88a945f0dca7c96b65e68c703fd7a6e522 | /Matchstick/src/core/core.impl/MGDFDebugImpl.hpp | c1f8f898942bc8453bc0833572f9da4d8524bb80 | [
"MIT"
] | permissive | mrsharpoblunto/MGDF | bd925ba7360d07d76ec7996451b87fe84a0b86c0 | 579309170ba84ca9e69d3c99d0804af644dacc16 | refs/heads/master | 2023-06-02T18:46:09.523284 | 2023-05-13T19:40:50 | 2023-05-13T19:40:50 | 1,732,528 | 4 | 1 | null | 2022-12-07T19:15:27 | 2011-05-11T09:59:48 | C++ | UTF-8 | C++ | false | false | 821 | hpp | MGDFDebugImpl.hpp | #pragma once
#include <MGDF/ComObject.hpp>
#include <MGDF/MGDF.h>
#include <atomic>
#include <map>
#include <sstream>
#include <string>
#include "MGDFHostStats.hpp"
#include "MGDFTextStream.hpp"
#include "MGDFTimer.hpp"
namespace MGDF {
namespace core {
class Debug : public ComBase<IMGDFDebug> {
public:
virtual ~Debug(){};
Debug(Timer *timer);
void __stdcall Set(const char *section, const char *key, const char *value) final;
void __stdcall Clear(const char *section, const char *key) final;
BOOL __stdcall IsShown() final;
void __stdcall ToggleShown() final;
void DumpInfo(const HostStats &stats, TextStream &ss) const;
private:
std::map<std::string, std::map<std::string, std::string>> _data;
mutable std::atomic<bool> _shown;
Timer *_timer;
};
} // namespace core
} // namespace MGDF
|
8de1361d3eccb6ba9c9b2cfa2d1d129d80e5380f | 93343c49771b6e6f2952d03df7e62e6a4ea063bb | /HDOJ/2581_autoAC.cpp | fecaaaefbcc4978d13bba27abd4d9e3deb7897a4 | [] | no_license | Kiritow/OJ-Problems-Source | 5aab2c57ab5df01a520073462f5de48ad7cb5b22 | 1be36799dda7d0e60bd00448f3906b69e7c79b26 | refs/heads/master | 2022-10-21T08:55:45.581935 | 2022-09-24T06:13:47 | 2022-09-24T06:13:47 | 55,874,477 | 36 | 9 | null | 2018-07-07T00:03:15 | 2016-04-10T01:06:42 | C++ | UTF-8 | C++ | false | false | 3,830 | cpp | 2581_autoAC.cpp | #include<iostream>
#include<math.h>
using namespace std;
int t, w, l, b;
struct POINT
{
double x, y, r;
} node[12];
int parent[12];
int bomb[12][12];
int visit[12];
int isbomb[2][12];
double dist(POINT a, POINT b)
{
return sqrt(1.0 * ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)));
}
void UFset()
{
int i;
for(i = 0; i < b; i++)
parent[i] = -1;
}
int Find(int x)
{
int s;
for(s = x; parent[s] >= 0; s = parent[s]);
while(s != x)
{
int tmp = parent[x];
parent[x] = s;
x = tmp;
}
return s;
}
void Union(int r1, int r2)
{
if(parent[r1] > parent[r2])
{
parent[r2] += parent[r1];
parent[r1] = r2;
}
else
{
parent[r1] += parent[r2];
parent[r2] = r1;
}
}
void kruskal()
{
int i, j, k;
double s;
UFset();
for(i = 0; i < b; i++)
{
for(j = 0; j < b; j++)
{
if(i != j)
{
s = dist(node[i], node[j]) - node[i].r - node[j].r;
if(s <= 0 && Find(i) != Find(j))
Union(Find(i), Find(j));
}
}
}
}
int main()
{
int i, j, k, r, wa, wb;
double ab;
scanf("%d", &t);
while(t--)
{
scanf("%d%d%d", &w, &l, &b);
for(i = 0; i < b; i++)
scanf("%lf%lf%lf", &node[i].x, &node[i].y, &node[i].r);
kruskal();
r = k = 0;
memset(bomb, -1, 12 * 12 * sizeof(int));
memset(isbomb, -1, 2 * 12 * sizeof(int));
memset(visit, 0, sizeof(visit));
for(i = 0; i < b; i++)
{
if(visit[i]) continue;
visit[i] = 1;
bomb[k][r++] = i;
for(j = 0; j < b; j++)
{
if(i == j) continue;
if(Find(i) == Find(j))
{
bomb[k][r++] = j;
visit[j] = 1;
}
}
k++;
r = 0;
}
wa = wb = 0;
for(i = 0; i < k; i++)
{
r = 0;
for(j = 0; bomb[i][j] >= 0; j++)
{
if(node[bomb[i][j]].r - node[bomb[i][j]].x >= 0)
{
r = 1;
break;
}
}
if(r == 1)
{
for(j = 0; bomb[i][j] >= 0; wa++, j++)
isbomb[0][wa] = bomb[i][j];
}
r = 0;
for(j = 0; bomb[i][j] >= 0; j++)
{
if(w - node[bomb[i][j]].r - node[bomb[i][j]].x <= 0)
{
r = 1;
break;
}
}
if(r == 1)
{
for(j = 0; bomb[i][j] >= 0; wb++, j++)
isbomb[1][wb] = bomb[i][j];
}
}
ab = w;
for(i = 0; isbomb[0][i] >= 0; i++)
{
if(w - node[isbomb[0][i]].r - node[isbomb[0][i]].x < ab)
ab = w - node[isbomb[0][i]].r - node[isbomb[0][i]].x;
for(j = 0; isbomb[1][j] >= 0; j++)
{
double s = dist(node[isbomb[0][i]], node[isbomb[1][j]]) - node[isbomb[0][i]].r
- node[isbomb[1][j]].r;
if(s < ab)
ab = s;
}
}
for(i = 0; isbomb[1][i] >= 0; i++)
{
if(node[isbomb[1][i]].x - node[isbomb[1][i]].r < ab)
ab = node[isbomb[1][i]].x - node[isbomb[1][i]].r;
}
ab = 0.5 * ab;
if(ab < 0) ab = 0;
r = ceil(ab);
printf("%d\n", r);
}
return 0;
}
|
3fd4618d137185ae2db9e7ff390c74d31e756c6f | 841776845974ba2645eff58ff8fabedd873093f0 | /LeetCode/1827最小操作使数组递增.cpp | b68ab084c1512da5f71ecf05d713d7336e72b660 | [] | no_license | hello-sources/Coding-Training | f2652c9b8e58d244a172922e56897fa2a3ad52fb | d885ca23676cb712243640169cf2e5bef2d8c70e | refs/heads/master | 2023-01-19T11:17:36.097846 | 2023-01-01T00:49:09 | 2023-01-01T00:49:09 | 246,630,755 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 309 | cpp | 1827最小操作使数组递增.cpp | int minOperations(int* nums, int numsSize){
int ans = 0;
for (int i = 1; i < numsSize; i++) {
if (nums[i] > nums[i - 1]) continue;
else {
int left = nums[i - 1] - nums[i];
ans += left + 1;
nums[i] = nums[i - 1] + 1;
}
}
return ans;
} |
bbeef2363b8ac79ea125b57f7e4def78bfc853a7 | 39719ced2451b97c266568e2d9364bfe90ab3498 | /Source/PluginPhysics_Ode/Wrapper/Stepper.h | ed37ccccfc0dae75cd3b6240e3b7ecf3fa7ede07 | [
"MIT"
] | permissive | shanefarris/CoreGameEngine | 74ae026cdc443242fa80fe9802f5739c1064fb66 | 5bef275d1cd4e84aa059f2f4f9e97bfa2414d000 | refs/heads/master | 2020-05-07T12:19:23.055995 | 2019-04-11T14:10:16 | 2019-04-11T14:10:16 | 180,496,793 | 3 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 5,203 | h | Stepper.h | #ifndef _OGREODESTEPPER_H_
#define _OGREODESTEPPER_H_
#include "PreReqs.h"
#include "OgreFrameListener.h"
namespace Ode
{
//------------------------------------------------------------------------------------------------
class StepMode
{
public:
StepMode(World *world) : _world(world) { }
virtual ~StepMode() { }
virtual void step(const f32& time) = 0;
protected:
World* _world;
};
//------------------------------------------------------------------------------------------------
class BasicStepMode : public StepMode
{
public:
BasicStepMode(World *world) : StepMode(world) { }
virtual ~BasicStepMode() { }
inline void step(const f32& time) { dWorldStep(_world->getWorldID(), (dReal)time); }
};
//------------------------------------------------------------------------------------------------
class QuickStepMode : public StepMode
{
public:
QuickStepMode(World *world) : StepMode(world) { }
virtual ~QuickStepMode() { }
inline void step(const f32& time) { dWorldQuickStep(_world->getWorldID(), (dReal)time); }
};
//------------------------------------------------------------------------------------------------
class StepListener
{
public:
StepListener() { }
virtual ~StepListener() { }
virtual bool preStep(const f32& time) { return true; }
virtual bool postStep(const f32& time) { return true; }
virtual bool middleStep(const f32& time) { return true; }
};
//------------------------------------------------------------------------------------------------
class StepHandler : public Ogre::FrameListener
{
public:
enum AutoMode
{
AutoMode_NotAutomatic,
AutoMode_PreFrame,
AutoMode_PostFrame
};
enum StepModeType
{
BasicStep = 0,
QuickStep,
FastStep,
StepModeTypeCount
};
public:
StepHandler(World *world, StepModeType stepModeType = QuickStep,
const f32& step_size = 0.01f,
const f32& max_interval = 1.0f / 4.0f,
const f32& time_scale = 1.0f);
virtual ~StepHandler();
virtual bool step(const f32& time);
f32 getStepSize() const { return _step_size; }
void setStepSize (const f32& step_size){ _step_size = step_size; }
void pause(bool pause);
bool isPaused();
void setStepListener(StepListener* listener);
void setAutomatic(StepHandler::AutoMode mode, EngineDevice* root = 0);
bool frameStarted(const FrameEvent& evt);
bool frameEnded(const FrameEvent& evt);
protected:
bool prepareSteppingTime(const f32& time);
bool basicStep(const f32& time);
protected:
World* _world;
bool _paused;
bool _auto_pre;
bool _auto_post;
f32 _step_size;
f32 _total_time;
f32 _max_interval;
f32 _time_scale;
EngineDevice* _root;
StepListener* _listener;
StepMode* _current_stepper;
};
//------------------------------------------------------------------------------------------------
class ForwardFixedStepHandler:public StepHandler
{
public:
ForwardFixedStepHandler(World *world, StepModeType stepModeType = QuickStep,
const f32& step_size = 0.01f,
const f32& max_interval = 1.0f / 4.0f,
const f32& time_scale = 1.0f);
virtual ~ForwardFixedStepHandler();
virtual bool step(const f32& time);
};
//------------------------------------------------------------------------------------------------
class ExactVariableStepHandler:public StepHandler
{
public:
ExactVariableStepHandler(World *world ,
StepModeType stepModeType = QuickStep,
const f32& step_size = 0.01f,
const f32& max_interval = 1.0f / 4.0f,
const f32& time_scale = 1.0f);
virtual ~ExactVariableStepHandler();
virtual bool step(const f32& time);
};
//------------------------------------------------------------------------------------------------
// Fix your timestep Gaffer implementation.
// http://www.gaffer.org/articles/Timestep.html
// Gaffer :"If you implement this interpolation technique you ensure that there will
// not be any visual stuttering when your display and physics framerates
// are out of sync. It will also perfectly handle the undersampling case so
// your objects will move smoothly when you view your simulation in slow
// motion or ten years from now on that Sexium."
class ForwardFixedInterpolatedStepHandler : public StepHandler
{
public:
ForwardFixedInterpolatedStepHandler(World *world,
StepModeType stepModeType = QuickStep,
const f32& step_size = 0.01f,
const f32& frame_rate = 1.0f / 60.0f,
const f32& max_interval = 1.0f / 4.0f,
const f32& time_scale = 1.0f);
virtual ~ForwardFixedInterpolatedStepHandler();
virtual bool step(const f32& time);
private :
f32 _dbl_step_size;
f32 _inv_step_size;
f32 _next_total_time;
u32 _next_frame_step_count;
f32 _inv_next_total_time;
bool _fixed_frame_rate;
f32 _frame_rate;
};
}
#endif
|
3128d84035ac966d70b6f2fc31e25485fd6e8e1e | f6f3e43f395cdcd86de55ceba136f87059f4d16b | /CS260/BinarySearchTreeProject/BinarySearchTree/main.cpp | 1a417b4d53c58d5265988627303682b8fb14f10a | [] | no_license | ashrestha18/wou-cs | 97a765359ce2ea8d3de13431f3a7b1581c8836de | a6d197fa8d65ffb36e4dab2780b3482e48da0309 | refs/heads/master | 2022-11-09T15:27:13.373828 | 2020-06-22T07:35:14 | 2020-06-22T07:35:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 624 | cpp | main.cpp | #include "BSTree.h"
using namespace std;
int main()
{
BSTree<int> myTree;
myTree.clear();
myTree.insert(10);
myTree.insert(20);
myTree.insert(30);
myTree.insert(40);
myTree.insert(50);
myTree.insert(60);
myTree.insert(50);
myTree.insert(70);
myTree.insert(80);
myTree.insert(90);
myTree.inOrderPrint();
vector<TreeNode<int>*>* myVec = myTree.BSTtoVector();
vector<TreeNode<int>*>::iterator myIt = myVec->begin();
for(; myIt < myVec->end(); myIt++)
{
cout << static_cast<TreeNode<int>*>(*myIt)->height
<< " ";
}
return 0;
}
|
4db79271c12203893eb1b3aba4a3b16e96bf266b | 0531cb5cc3ca167fe63176cff1369715761eb08c | /libHSAIL/libHSAIL/hsail_c.cpp | 4f8382fafdf4585de5f6e11926ec5201d8acc49d | [] | no_license | syifan/HSAIL-Tools | 425898d26ce673b20af5abe482848510af90bdff | 708845fe55b2146d8fc2c46bdb91b74e3526ffb1 | refs/heads/master | 2021-05-28T20:10:36.966629 | 2014-12-11T20:28:54 | 2014-12-11T20:28:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,306 | cpp | hsail_c.cpp | #include "hsail_c.h"
#include <fstream>
#include <sstream>
#include "HSAILBrigContainer.h"
#include "HSAILBrigObjectFile.h"
#include "HSAILParser.h"
#include "HSAILDisassembler.h"
#include "HSAILValidator.h"
using namespace HSAIL_ASM;
namespace {
struct Api {
BrigContainer container;
std::string errorText;
Api()
: container()
, errorText()
{
}
Api(const void *data_bytes,
const void *code_bytes,
const void *operand_bytes,
const void * debug_bytes)
: container(
data_bytes,
code_bytes,
operand_bytes,
debug_bytes)
, errorText()
{
}
};
static int assemble(brig_container_t handle, std::istream& is)
{
try {
Scanner s(is, true);
Parser p(s, ((Api*)handle)->container);
p.parseSource();
}
catch(const SyntaxError& e) {
std::stringstream ss;
e.print(ss, is);
((Api*)handle)->errorText = ss.str();
return 1;
}
Validator v(((Api*)handle)->container);
if (!v.validate(true)) {
std::stringstream ss;
ss << v.getErrorMsg(&is) << "\n";
int rc = v.getErrorCode();
((Api*)handle)->errorText = ss.str();
return rc;
}
return 0;
}
}
extern "C" {
HSAIL_C_API brig_container_t brig_container_create_empty()
{
return (brig_container_t)new Api();
}
HSAIL_C_API brig_container_t brig_container_create_view(
const void *data_bytes,
const void *code_bytes,
const void *operand_bytes,
const void* debug_bytes)
{
return (brig_container_t)new Api(
data_bytes,
code_bytes,
operand_bytes,
debug_bytes);
}
HSAIL_C_API brig_container_t brig_container_create_copy(
const char *data_bytes,
const char *code_bytes,
const char *operand_bytes,
const char* debug_bytes)
{
Api *api = new Api;
api->container.strings().setData(data_bytes);
api->container.code().setData(code_bytes);
api->container.operands().setData(operand_bytes);
if (debug_bytes) { api->container.debugInfo().setData(debug_bytes); }
return (brig_container_t)api;
}
HSAIL_C_API void* brig_container_get_brig_module(brig_container_t handle)
{
return (void*)(((Api*)handle)->container.getBrigModule());
}
HSAIL_C_API unsigned brig_container_get_section_count(brig_container_t handle)
{
return (unsigned)(((Api*)handle)->container.getNumSections());
}
HSAIL_C_API const char* brig_container_get_section_bytes(brig_container_t handle, int section_id)
{
return ((Api*)handle)->container.sectionById(section_id).data().begin;
}
HSAIL_C_API size_t brig_container_get_section_size(brig_container_t handle, int section_id)
{
return ((Api*)handle)->container.sectionById(section_id).size();
}
HSAIL_C_API int brig_container_assemble_from_memory(brig_container_t handle, const char* text, size_t text_length)
{
std::string s((char*)text, text_length);
std::istringstream is(s);
return assemble(handle, is);
}
HSAIL_C_API int brig_container_assemble_from_file(brig_container_t handle, const char* filename)
{
std::ifstream ifs(filename, std::ifstream::in | std::ifstream::binary);
std::stringstream ss;
if ((!ifs.is_open()) || ifs.bad()) {
ss << "Could not open "<< filename;
((Api*)handle)->errorText = ss.str();
return 1;
}
return assemble(handle, ifs);
}
HSAIL_C_API int brig_container_disassemble_to_file(brig_container_t handle, const char* filename)
{
Disassembler d(((Api*)handle)->container);
d.setOutputOptions(0);
std::stringstream ss;
d.log(ss);
int rc = d.run(filename);
((Api*)handle)->errorText = ss.str();
return rc;
}
HSAIL_C_API int brig_container_load_from_mem(brig_container_t handle, const char* buf, size_t buf_length)
{
std::stringstream ss;
int rc = BrigIO::load(((Api*)handle)->container, FILE_FORMAT_AUTO, BrigIO::memoryReadingAdapter(buf, buf_length, ss));
((Api*)handle)->errorText = ss.str();
return rc;
}
HSAIL_C_API int brig_container_load_from_file(brig_container_t handle, const char* filename)
{
std::stringstream ss;
int rc = BrigIO::load(((Api*)handle)->container, FILE_FORMAT_AUTO, BrigIO::fileReadingAdapter(filename, ss));
((Api*)handle)->errorText = ss.str();
return rc;
}
HSAIL_C_API int brig_container_save_to_file(brig_container_t handle, const char* filename)
{
std::stringstream ss;
int rc = BrigIO::save(((Api*)handle)->container, FILE_FORMAT_BRIG | FILE_FORMAT_ELF32, BrigIO::fileWritingAdapter(filename, ss));
((Api*)handle)->errorText = ss.str();
return rc;
}
HSAIL_C_API int brig_container_validate(brig_container_t handle)
{
std::stringstream ss;
Validator v(((Api*)handle)->container);
if (!v.validate(true)) {
ss << v.getErrorMsg(0) << "\n";
int rc = v.getErrorCode();
((Api*)handle)->errorText = ss.str();
return rc;
}
return 0;
}
HSAIL_C_API const char* brig_container_get_error_text(brig_container_t handle) {
return ((Api*)handle)->errorText.c_str();
}
HSAIL_C_API void brig_container_destroy(brig_container_t handle)
{
delete (Api*)handle;
}
}
|
1c60cc7c5057b3ca4e787d07243d82e4be2a128f | 8dcac58a9a94bb288cb963155bd2ba46b7dda91a | /src/extract/bomb_directory.cpp | 66a0134b8a7f516d2cb6d1310300e13c70ecb414 | [] | no_license | pmiddend/extract | cf02f89740f85ec756b0015a5714307cbff65689 | b5d08a030227ba324050518b6e67476c8e922f65 | refs/heads/master | 2016-09-06T09:07:21.432784 | 2012-04-21T21:05:32 | 2012-04-21T21:05:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 425 | cpp | bomb_directory.cpp | #include <extract/bomb_directory.hpp>
#include <fcppt/text.hpp>
fcppt::string const
extract::bomb_directory(
boost::filesystem::path const &_p)
{
/*
fcppt::string::size_type const p =
_p.filename().find(
FCPPT_TEXT('.'));
if (p == fcppt::string::npos)
return
_p.filename()+FCPPT_TEXT(".dir");
*/
/*
return
_p.filename().substr(
0,
);
*/
return
_p.filename().string()+FCPPT_TEXT(".dir");
}
|
9434bb7c75f64c061f39657cadf6a050573bd65f | f0b7bcc41298354b471a72a7eeafe349aa8655bf | /codebase/apps/ingest/src/SerialIngest/Tty.hh | 7180f6d21ba11230286f23cf7b67874facbe31e7 | [
"BSD-3-Clause"
] | permissive | NCAR/lrose-core | 23abeb4e4f1b287725dc659fb566a293aba70069 | be0d059240ca442883ae2993b6aa112011755688 | refs/heads/master | 2023-09-01T04:01:36.030960 | 2023-08-25T00:41:16 | 2023-08-25T00:41:16 | 51,408,988 | 90 | 53 | NOASSERTION | 2023-08-18T21:59:40 | 2016-02-09T23:36:25 | C++ | UTF-8 | C++ | false | false | 3,003 | hh | Tty.hh | // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
// ** Copyright UCAR (c) 1990 - 2016
// ** University Corporation for Atmospheric Research (UCAR)
// ** National Center for Atmospheric Research (NCAR)
// ** Boulder, Colorado, USA
// ** BSD licence applies - redistribution and use in source and binary
// ** forms, with or without modification, are permitted provided that
// ** the following conditions are met:
// ** 1) If the software is modified to produce derivative works,
// ** such modified software should be clearly marked, so as not
// ** to confuse it with the version available from UCAR.
// ** 2) Redistributions of source code must retain the above copyright
// ** notice, this list of conditions and the following disclaimer.
// ** 3) 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.
// ** 4) Neither the name of UCAR nor the names of its contributors,
// ** if any, may be used to endorse or promote products derived from
// ** this software without specific prior written permission.
// ** DISCLAIMER: THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS
// ** OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
// ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
/////////////////////////////////////////////////////////////
// Tty.hh
//
// Tty class - reading serial ports
//
// Mike Dixon, RAP, NCAR, P.O.Box 3000, Boulder, CO, 80307-3000, USA
//
// June 1999
//
///////////////////////////////////////////////////////////////
#ifndef Tty_HH
#define Tty_HH
#include <termios.h>
#include <string>
#include "Params.hh"
using namespace std;
class Tty {
public:
// constructor
Tty(const string &prog_name, const Params ¶ms);
// destructor
virtual ~Tty();
// check for valid object
bool isOK() { return (_isOK); }
// open serial port
// returns 0 on success, -1 on failure
int openPort();
// close serial port
void closePort();
// reads a character
// returns 0 on success, -1 on failure
int readChar(char &cc);
// readSelect - waits for read access on fd
// Blocks if wait_msecs == -1
// Returns 0 on success, -1 on failure.
// Sets timedOut to true if timed out.
int readSelect(long wait_msecs, bool &timedOut);
protected:
private:
bool _isOK;
const string &_progName;
const Params &_params;
int _fd;
struct termios _termOld;
struct termios _termNew;
char *_speedStr(speed_t speed);
};
#endif
|
1067df895182daa8cbfe6e37237d15ad484f19b0 | 9cffd8d8ce7e179bc9037766aa868f07a974e86c | /MovementSkill/Engine.cpp | d98f5f867873f3b09ccab17a1938767a2db55258 | [] | no_license | KolCrooks/OpenGLEngine | 88efba1d7caf780ae9e8aca28ca7cb346872cdfd | 1ed4e5e6dac787c1d2f4bdb14ae0ca2455191119 | refs/heads/master | 2021-09-03T04:48:14.834754 | 2018-01-05T17:57:11 | 2018-01-05T17:57:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 664 | cpp | Engine.cpp | // MovementSkill.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "Settings.h"
#include "Logic.h"
using namespace sf;
settingsFile GameSettings;
Window* GameWindow;
bool USE_FILE_GEN_SETTINGS = false;
int main()
{
//Setup Settings
settings *Settings = new settings();
if (!USE_FILE_GEN_SETTINGS)
GameSettings = Settings->generateSettings();
else
GameSettings = Settings->getSettingsFromFile();
//Setup Window
Window GameWindow(sf::VideoMode(GameSettings.Window_W, GameSettings.Window_H), "GameDev");
//Setup Game Logic
logic *GameLogic = new logic();
GameLogic->Main(&GameWindow);
return 0;
}
|
8aadb150e8e5f0c7ed52a0bcc5e5d8aabfcf820a | bc3c03ae7a16786f6c99fb93622cd4eecda83c64 | /SheepHerdChallenge/Source/SheepHerdChallenge/DogPawn.h | 3c89db6964aa8c98fb5ee7f134a5fe6d58577617 | [] | no_license | lizzye414/SheepHerdingChallenge | b7a47159d69c8321ba9d7bbea0e911f5705262a6 | 0f1bbbe9dc04483a3e646fd3d9ec94afc8221de2 | refs/heads/master | 2022-12-17T14:36:25.556803 | 2020-09-15T15:28:22 | 2020-09-15T15:28:22 | 295,770,877 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 708 | h | DogPawn.h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/DefaultPawn.h"
#include "Components/InputComponent.h"
#include "DogPawn.generated.h"
/**
*
*/
UCLASS()
class SHEEPHERDCHALLENGE_API ADogPawn : public ADefaultPawn
{
GENERATED_BODY()
public:
void BeginPlay() override;
// The base speed of the dog
UPROPERTY(EditAnywhere, Category = "Settings")
float DogSpeed = 1.0f;
private:
void MoveUp(float Value);
void MoveRight(float Value);
// End the level and show current score
void EndLevel();
protected:
virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override;
};
|
5b3264b6df07959a1b13c7f09bf3dce5a0ed3b27 | d4d5b04211769a1378013e56cecca1e82387d167 | /pthread/Box.h | 8fd548eb6bf99d0336c3f259a7440a4050537491 | [] | no_license | aaaaxiaofei/parallel | fa818cafa61176fdb5f4f76f69f4200c1ffd99b2 | ce25f5217ce926a890bd814ae97b023c2876ebc2 | refs/heads/master | 2021-01-11T18:46:13.929874 | 2017-01-23T05:21:34 | 2017-01-23T05:21:34 | 79,620,949 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 345 | h | Box.h | #pragma once
#include <vector>
#include <string>
#include <fstream>
using namespace std;
class CBox
{
public:
int boxID;
double left_x, right_x, upper_y, lower_y, width, height, T, T_temp;
vector<int> left_id, right_id, top_id, bottom_id;
CBox(void);
~CBox(void);
void input(istream&);
void print();
double computeT(CBox box[]);
};
|
b1d53fdb82b8bbd034abefd657147ef2d2115101 | f40711962898b810cf3964e153d11ab5f8a96c6a | /src/surfer/common.h | 0864bc57638c3c73ca755bf9c12a57e475193992 | [] | no_license | leonardopsantos/mestrado-surfer | d8b400280b7fce81072eefe6dd54558ea50c7895 | d2baf7b18d48f89f5cb3bdc454a315020b302acc | refs/heads/master | 2021-01-18T17:11:49.067548 | 2016-08-23T21:25:16 | 2016-08-23T21:25:16 | 34,485,646 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 841 | h | common.h |
#ifndef _INCLUDED_COMMON_H_
#define _INCLUDED_COMMON_H_
#include <boost/foreach.hpp>
using namespace boost;
#define foreach BOOST_FOREACH
#define MAX(a, b) ((a > b) ? a : b)
#define dbprint(a) cout << #a << " = " << a << endl
#define BUFSIZE 512
enum lineOpts {OPT_USE_7, OPT_D_ADDERS, OPT_AGGRESSIVE, OPT_E_AGGREG, OPT_DWCF, OPT_CMUX, OPT_RSPLIT, OPT_MERGE_IO,
OPT_NOVEC, OPT_DWCC, OPT_USE4ADJ, OPT_MMATCH, OPT_2RAIL, OPT_SPLIT_CHECK, OPT_STACK_CHECK, OPT_FF_INPUT_CMP,
OPT_DUPLICATE_MUXES, OPT_NOCHECK, OPT_NODUPLNET, OPT_DUPLICATE_PI, OPT_NO_CMP_MODULE, OPT_ERROR_PO_SAMEW,
OPT_DWSF, OPT_CCHAIN, OPT_LOC};
#define OPT_CNT (((int) OPT_CCHAIN) + 1)
#define DEFAULT_MAXCHECK_CC 4 //Default value for maximum checker size
#define DEFAULT_MAXGROUP_CC 5 //Default value for maximum group size
extern bool options[OPT_CNT];
#endif
|
664489bf04e033dcc41b514dab04dc10df485600 | 6248b0c47e1073014ce784bccaa108674cd43108 | /Distributed Systems/Asteroids/Asteroid.cpp | 8d56d1f6da43e741969fcaa5972c617eff23b436 | [] | no_license | JorgeReus/ESCOM | 482608d537dc1aa9243a30885b1ab3ea9ff9ddf4 | c53398914b99b06658342d5fb8d71dd7e72d32a9 | refs/heads/master | 2021-09-24T16:21:37.756780 | 2018-10-11T18:14:40 | 2018-10-11T18:14:40 | 112,122,857 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,303 | cpp | Asteroid.cpp | #include "Asteroid.h"
#include "gfx.h"
#include <iostream>
#include <cstdlib>
#include <cmath>
#include "Coordinate.h"
using namespace std;
const int MAX_X = 1300;
const int MAX_Y = 740;
const int MIN_X = 0;
const int MIN_Y = 0;
Asteroid::Asteroid()
{
int cuadrant = 1 + rand() % 4;
if(cuadrant == 1) // Upper Cuadrant
{
posX = rand() % (MAX_X - MIN_X + 1) + MIN_X;
posY = rand() % (1 - MAX_Y) - MAX_Y;
}
else if(cuadrant == 2) // Lower Cuadrant
{
posX = rand() % (MAX_X - MIN_X + 1) + MIN_X;
posY = rand() % (MAX_Y + 1) + MAX_Y;
}
else if(cuadrant == 3) // Left Cuadrant
{
posX = rand() % (1 - MAX_X) - MAX_X;
posY = rand() % (MAX_Y - MIN_Y + 1) + MIN_Y;
}
else if(cuadrant == 4) // Right Cuadrant
{
posX = rand() % (MAX_X + 1) + MAX_X;
posY = rand() % (MAX_Y - MIN_Y + 1) + MIN_Y;
}
// radius multiplier of the asteoroid
radio = 1 + rand()%2;
// Set the directional velocity
vx = (rand()%(40) - 20)/radio;
vy = (rand()%(40) - 20)/radio;
vw = rand()%(21) -10;
// Create cirlce around the main circle
int minRadius = 30;
int maxRadius = 50;
int granularity = 15;
int minVary = 25;
int maxVary = 75;
for (double theta=0; theta<=2*M_PI; theta+=2*M_PI/granularity)
{
//Create the asteroid
int randVal = rand()%(maxVary - minVary + 1) + minVary;
double points = (2 * M_PI / granularity) * randVal / 100.0;
double angle = theta + points - (M_PI / granularity);
int radius = rand()%(maxRadius - minRadius + 1) + minRadius;
double x = static_cast<double>(sin(angle) * radius);
double y = static_cast<double>(-cos(angle) * radius);
// Store in vector
v.push_back(Coordinate(posX + radio * x, posY + radio * y));
}
}
Asteroid::~Asteroid()
{
}
void Asteroid::rotate(double angle)
{
double theta=M_PI*(angle + vw)/180.0; // Radians
for(int i=0; i < v.size(); i++){
double x1 = cos(theta)*(v[i].getX() - posX);
double x2 = sin(theta)*(v[i].getY() - posY);
double y1 = sin(theta)*(static_cast<double>(v[i].getX()) - posX);
double y2 = cos(theta)*(static_cast<double>(v[i].getY()) - posY);
v[i].setX(x1 - x2 + posX);
v[i].setY(y1 + y2 + posY);
}
return;
}
void Asteroid::draw()
{
for(int i=1; i<v.size(); i++){
gfx_line(v[i-1].getX(), v[i-1].getY(), v[i].getX(), v[i].getY());
}
gfx_line(v[v.size()-1].getX(), v[v.size()-1].getY(), v[0].getX(), v[0].getY());
return;
}
void Asteroid::showVertex(){
for(int i=0; i < v.size(); i++)
cout << "X:" << v[i].getX() << " Y:" << v[i].getY() << endl;
return;
}
void Asteroid::showCenter(){
cout << posX << "," << posY << endl;
return;
}
void Asteroid::move()
{
posX+=vx;
posY+=vy;
for(int i=0; i<v.size(); i++)
{
v[i].setX(v[i].getX() + vx);
v[i].setY(v[i].getY() + vy);
}
}
bool Asteroid::outOfLimits()
{
double aux = radio * 100;
bool isOut = false;
if(posX > MAX_X + aux)
isOut = true;
if(posX < MIN_X - aux)
isOut = true;
if(posY > MAX_Y + aux)
isOut = true;
if(posY < MIN_Y - aux)
isOut = true;
return isOut;
} |
9c71f9a7d5c082757022063acec94f036bf8a2fb | dec4ef167e1ce49062645cbf036be324ea677b5e | /SDK/PUBG_P_MotoDrive_Rock_Front_BP_functions.cpp | a28f2f622c356342952a95e15943a16560965f1b | [] | no_license | qrluc/pubg-sdk-3.7.19.5 | 519746887fa2204f27f5c16354049a8527367bfb | 583559ee1fb428e8ba76398486c281099e92e011 | refs/heads/master | 2021-04-15T06:40:38.144620 | 2018-03-26T00:55:36 | 2018-03-26T00:55:36 | 126,754,368 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,970 | cpp | PUBG_P_MotoDrive_Rock_Front_BP_functions.cpp | // PlayerUnknown's Battlegrounds (3.5.7.7) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "PUBG_P_MotoDrive_Rock_Front_BP_parameters.hpp"
namespace PUBG
{
//---------------------------------------------------------------------------
//Functions
//---------------------------------------------------------------------------
// Function P_MotoDrive_Rock_Front_BP.P_MotoDrive_Rock_Front_BP_C.UserConstructionScript
// (Event, Public, BlueprintCallable, BlueprintEvent)
void AP_MotoDrive_Rock_Front_BP_C::UserConstructionScript()
{
static UFunction* fn = nullptr;
if (!fn) fn = UObject::GetObjectCasted<UFunction>(116066);
AP_MotoDrive_Rock_Front_BP_C_UserConstructionScript_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function P_MotoDrive_Rock_Front_BP.P_MotoDrive_Rock_Front_BP_C.OnParameterUpdated
// (Event, Protected, BlueprintEvent)
void AP_MotoDrive_Rock_Front_BP_C::OnParameterUpdated()
{
static UFunction* fn = nullptr;
if (!fn) fn = UObject::GetObjectCasted<UFunction>(116065);
AP_MotoDrive_Rock_Front_BP_C_OnParameterUpdated_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function P_MotoDrive_Rock_Front_BP.P_MotoDrive_Rock_Front_BP_C.ExecuteUbergraph_P_MotoDrive_Rock_Front_BP
// (HasDefaults)
// Parameters:
// int EntryPoint (Parm, ZeroConstructor, IsPlainOldData)
void AP_MotoDrive_Rock_Front_BP_C::ExecuteUbergraph_P_MotoDrive_Rock_Front_BP(int EntryPoint)
{
static UFunction* fn = nullptr;
if (!fn) fn = UObject::GetObjectCasted<UFunction>(116052);
AP_MotoDrive_Rock_Front_BP_C_ExecuteUbergraph_P_MotoDrive_Rock_Front_BP_Params params;
params.EntryPoint = EntryPoint;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
|
8aa1cfc97788038bb48982a6d36aa3a76a2c8275 | 24004e1c3b8005af26d5890091d3c207427a799e | /Win32/NXOPEN/NXOpen/FollowFilletRule.hxx | c6aa359d1161a8aa343dc8ce3d7cc484d71452db | [] | no_license | 15831944/PHStart | 068ca6f86b736a9cc857d7db391b2f20d2f52ba9 | f79280bca2ec7e5f344067ead05f98b7d592ae39 | refs/heads/master | 2022-02-20T04:07:46.994182 | 2019-09-29T06:15:37 | 2019-09-29T06:15:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,070 | hxx | FollowFilletRule.hxx | #ifndef NXOpen_FOLLOWFILLETRULE_HXX_INCLUDED
#define NXOpen_FOLLOWFILLETRULE_HXX_INCLUDED
//--------------------------------------------------------------------------
// Header for C++ interface to JA API
//--------------------------------------------------------------------------
//
// Source File:
// FollowFilletRule.ja
//
// Generated by:
// apiwrap
//
// WARNING:
// This file is automatically generated - do not edit by hand
//
#ifdef _MSC_VER
#pragma once
#endif
#include <NXOpen/NXDeprecation.hxx>
#include <vector>
#include <NXOpen/NXString.hxx>
#include <NXOpen/Callback.hxx>
#include <NXOpen/SelectionIntentRule.hxx>
#include <NXOpen/libnxopencpp_exports.hxx>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4996)
#endif
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
namespace NXOpen
{
class FollowFilletRule;
class Body;
namespace Features
{
class Feature;
}
class ICurve;
class SelectionIntentRule;
class FollowFilletRuleImpl;
/** Represents a @link SelectionIntentRule SelectionIntentRule @endlink that collects curves/edges which are connected or tangent connected and follow onto and off an untrimmed fillet.
<br> Created in NX4.0.0. <br>
*/
class NXOPENCPPEXPORT FollowFilletRule : public SelectionIntentRule
{
private: FollowFilletRuleImpl * m_followfilletrule_impl;
/// \cond NX_NO_DOC
public: explicit FollowFilletRule(void *ptr);
/// \endcond
/** Frees the object from memory.
<br> Created in NX4.0.0. <br>
<br> License requirements : None */
public: virtual ~FollowFilletRule();
/** Gets the data for the follow fillet rule: @link FollowFilletRule FollowFilletRule @endlink
<br> Created in NX4.0.0. <br>
<br> License requirements : solid_modeling ("SOLIDS MODELING") */
public: void GetData
(
std::vector<NXOpen::Features::Feature *> & features /** Features whose curves are used to create this rule */,
std::vector<NXOpen::Body *> & bodies /** Bodies whose edges are used to create this rule */,
std::vector<NXOpen::ICurve *> & basicCurves /** Non-associative basic curves that are used to create this rule */,
NXOpen::ICurve ** seedWireframe /** Seed wireframe */,
NXOpen::ICurve ** endWireframe /** End wireframe. It can be null (Nothing) */,
bool* fromSeedStart /** True: the chain starts from the start point of the seed wireframe */,
double* gapTolerance /** Gap tolerance*/,
double* angleTolerance /** Angle tolerance*/,
NXOpen::FollowFilletRuleType* method /** Selection Intent method */
);
}; //lint !e1712 default constructor not defined for class
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#ifdef __GNUC__
#ifndef NX_NO_GCC_DEPRECATION_WARNINGS
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
#endif
#endif
#undef EXPORTLIBRARY
#endif
|
33ffc7f016bd73f36bca6e361d2aadcc217b6bbb | b203adce945facba4210e53b7ca42b8079fc7e93 | /lab6/aghMatrix.cpp | 8c11b185061a8297e7b0674f30e1c9b908ed64d1 | [] | no_license | macko99/mownit | f45b6346c018629a7f47ce01c6a79b64c04012f7 | 6b05d8a8e59afc2fa2c6fecee5a461669d441b2b | refs/heads/master | 2021-04-11T14:37:58.096920 | 2020-06-01T20:44:41 | 2020-06-01T20:44:41 | 249,028,894 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,576 | cpp | aghMatrix.cpp | #include <vector>
#include <iostream>
template <typename T> class AGHMatrix
{
private:
std::vector<std::vector<T>> matrix;
unsigned rows;
unsigned cols;
public:
explicit AGHMatrix(const std::vector<std::vector<T>>& matrix);
AGHMatrix(const AGHMatrix<T>& rhs);
virtual ~AGHMatrix() = default;
// Operator overloading, for "standard" mathematical matrix operations
AGHMatrix<T>& operator=(const AGHMatrix<T>& rhs);
// Matrix mathematical operations
AGHMatrix<T> operator+(const AGHMatrix<T>& rhs);
AGHMatrix<T> operator*(const AGHMatrix<T>& rhs);
// Access the individual elements
T& operator()(const unsigned& row, const unsigned& col);
const T& operator()(const unsigned& row, const unsigned& col) const;
// Printing matrix
std::ostream& operator<<(const AGHMatrix<T>& matrix);
// Access the row and column sizes
unsigned get_rows() const;
unsigned get_cols() const;
AGHMatrix<T> Jacoby(const AGHMatrix<T>& inputMatrix, unsigned iterations) const;
AGHMatrix<T> GaussSiedel(const AGHMatrix<T>& inputMatrix, unsigned iterations) const;
AGHMatrix<T> SOR(const AGHMatrix<T>& inputMatrix, unsigned iterations) const;
};
// Parameter Constructor
template<typename T>
AGHMatrix<T>::AGHMatrix(const std::vector<std::vector<T>>& mat)
{
matrix.resize(mat.size());
for (unsigned i = 0; i < mat.size(); i++)
{
matrix[i].resize(mat[i].size());
for(unsigned j = 0; j < mat[i].size(); j++)
{
matrix[i][j] = mat[i][j];
}
}
rows = matrix.size();
cols = matrix[1].size();
}
// Copy Constructor
template<typename T>
AGHMatrix<T>::AGHMatrix(const AGHMatrix<T>& rhs)
{
matrix = rhs.matrix;
rows = rhs.get_rows();
cols = rhs.get_cols();
}
// Get the number of rows of the matrix
template<typename T>
unsigned AGHMatrix<T>::get_rows() const
{
return this->rows;
}
// Get the number of columns of the matrix
template<typename T>
unsigned AGHMatrix<T>::get_cols() const
{
return this->cols;
}
// Assignment Operator
template<typename T>
AGHMatrix<T>& AGHMatrix<T>::operator=(const AGHMatrix<T>& rhs)
{
if (&rhs == this)
return *this;
unsigned new_rows = rhs.get_rows();
unsigned new_cols = rhs.get_cols();
matrix.resize(new_rows);
for (unsigned i=0; i<matrix.size(); i++)
{
matrix[i].resize(new_cols);
}
for (unsigned i=0; i<new_rows; i++)
{
for (unsigned j=0; j<new_cols; j++)
{
matrix[i][j] = rhs(i, j);
}
}
rows = new_rows;
cols = new_cols;
return *this;
}
// Access the individual elements
template<typename T>
T& AGHMatrix<T>::operator()(const unsigned& row, const unsigned& col)
{
return this->matrix[row][col];
}
// Access the individual elements (const)
template<typename T>
const T& AGHMatrix<T>::operator()(const unsigned& row, const unsigned& col) const
{
return this->matrix[row][col];
}
// Addition of two matrices
template<typename T>
AGHMatrix<T> AGHMatrix<T>::operator+(const AGHMatrix<T>& rhs)
{
if(this->get_cols() != rhs.get_cols() || this->get_rows() != rhs.get_rows()){
std::cout<<"error adding";
exit(-1);
}
else{
AGHMatrix<typeof(this->matrix[0][0])> mat3 (this->get_rows(), this->get_cols(), 0);
for (int i = 0; i < this->get_rows(); i++) {
for (int j = 0; j < this->get_cols(); j++) {
mat3.matrix[i][j] = this->matrix[i][j]+rhs.matrix[i][j];
}
}
return mat3;
}
}
// Left multiplication of this matrix and another
template<typename T>
AGHMatrix<T> AGHMatrix<T>::operator*(const AGHMatrix<T>& rhs)
{
if(this->get_cols() != rhs.get_rows()){
std::cout<<"error multiplying";
exit(-1);
}
else{
AGHMatrix<typeof(this->matrix[0][0])> mat3 (this->get_rows(), rhs.get_cols(), 0);
for (int i = 0; i < this->get_rows(); i++) {
for (int j = 0; j < rhs.get_cols(); j++) {
for(int k = 0 ; k < this->get_cols(); k++){
mat3.matrix[i][j] += this->matrix[i][k]*rhs.matrix[k][j];
}
}
}
return mat3;
}
}
// Printing matrix
template<typename T>
std::ostream& operator<<(std::ostream& stream, const AGHMatrix<T>& matrix)
{
for (int i=0; i<matrix.get_rows(); i++)
{
for (int j=0; j<matrix.get_cols(); j++)
{
stream << matrix(i,j) << ", ";
}
stream << std::endl;
}
stream << std::endl;
} |
14e65ec3541640a44dab900cfd17fae3bf11c2ee | 9650045c04c6c04d0f183d585ef8f3ce108ceb29 | /q5/main.cpp | a51fdafb8a7822aa587c87843c3309e90f5f00dd | [
"MIT"
] | permissive | mike10004/cs-bridge-2020-hw8 | 6d79a12a4b8433704b22853b101db93618fe1b55 | c2f196274aac3aa0447538b51a6e0cafab3dbd78 | refs/heads/master | 2021-02-06T05:32:45.349125 | 2020-03-03T23:19:54 | 2020-03-03T23:19:54 | 243,881,834 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 775 | cpp | main.cpp | // mac937@nyu.edu
// hw8 question 5
#include <iostream>
#include <string>
using namespace std;
// "Initialifies" a name by truncating it to its first letter and
// adding a period.
void initialify(string& name) {
char initial[] = "_";
if (!name.empty()) {
initial[0] = name[0];
name.assign(initial);
}
if (name[name.length() - 1] != '.') {
name.append(".");
}
}
// Ask for a name, e.g. "Mary Average User", and prints it in the
// form "User, Mary A."
int main() {
string firstName, middleName, lastName;
cout << "Enter full name: ";
cin >> firstName >> middleName >> lastName;
initialify(middleName);
cout << lastName << ", "
<< firstName << ' '
<< middleName << endl;
return 0;
}
|
770a6499afa872003220961b0dc60263d49f98a7 | a53d95351173949c6d742de3a640ae9b23152496 | /Source files/FiguresVariant.cpp | 2cd5baf575d0274ffe6f666c2904d5ad2038c3bb | [] | no_license | BMSTU732/Polymino | 6bda43f8b728948308e501ce7ee66c607cce014e | 2b61fc9e0e0a71d50bb7554a9976fb357e7cf724 | refs/heads/master | 2021-08-28T16:20:10.644488 | 2017-12-12T18:16:45 | 2017-12-12T18:16:45 | 112,956,863 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,613 | cpp | FiguresVariant.cpp | #include "FiguresVariant.hpp"
FiguresVariant::~FiguresVariant()
{}
FiguresVariant::FiguresVariant(string base, Figures figure) :
data_group_performance{ base },
figures{ figure },
end{ false }
{
vector<string> group_performances = figures.getGroupPerformances();
for (int i = 0; i < group_performances.size(); i++)
{
string buffer = base;
for (int j = 0; j < buffer.size(); j++)
{
if (buffer == group_performances[i])
{
end = true;
Substring common(data_group_performance,
i,
0,
0);
new_data_group_performances.push_back("");
common_substrings.push_back(common);
return;
}
buffer = getTurnedString(buffer);
}
}
getFiguresLargestCommonSubstring();
}
void FiguresVariant::getFiguresLargestCommonSubstring()
{
vector<string> group_performances = figures.getGroupPerformances();
for (int i = 0; i < group_performances.size(); i++)
{
getLargestCommonSubstrings(group_performances[i], i);
}
}
void FiguresVariant::getLargestCommonSubstrings(string figures_group_performance, int rotation)
{
string data_string = data_group_performance + data_group_performance;
string figures_string = figures_group_performance + figures_group_performance;
const int a_size = (int)data_string.size();
const int b_size = (int)figures_string.size();
typedef vector<int> solution;
const int solution_size = b_size + 1;
solution x(solution_size, 0), y(solution_size);
solution* previous = &x;
solution* current = &y;
size_t max_length = 0;
size_t substring_begining_index_data = 0;
size_t substring_begining_index_figures = 0;
for (int i = a_size - 1; i >= 0; i--)
{
for (int j = b_size - 1; j >= 0; j--)
{
int & current_match = (*current)[j];
if (data_string[i] != figures_string[j])
{
current_match = 0;
}
else
{
const int length = 1 + (*previous)[j + 1];
if (length > max_length)
{
max_length = length;
substring_begining_index_data = i % (a_size / 2);
substring_begining_index_figures = j % (b_size / 2);
}
current_match = length;
}
}
swap(previous, current);
}
size_t substrings_length = 0;
if (common_substrings.size() > 0)
{
substrings_length = common_substrings[0].size;
}
if (max_length > substrings_length)
{
common_substrings.clear();
Substring substring(data_string.substr(substring_begining_index_data, max_length),
rotation,
substring_begining_index_figures,
substring_begining_index_data);
common_substrings.push_back(substring);
}
else if (max_length == substrings_length)
{
Substring substring(data_string.substr(substring_begining_index_data, max_length),
rotation,
substring_begining_index_figures,
substring_begining_index_data);
common_substrings.push_back(substring);
}
}
bool FiguresVariant::checkData(string input)
{
vector<Coordinates> buffer;
Coordinates coord(0, 0);
buffer.push_back(coord);
for (int i = 0; i < input.size(); i++)
{
switch (input[i])
{
case 'R':
coord.j++;
break;
case 'D':
coord.i++;
break;
case 'L':
coord.j--;
break;
case 'U':
coord.i--;
break;
default:
break;
}
if (i != input.size() - 1)
{
if (find(buffer.begin(),
buffer.end(),
coord)
== buffer.end())
{
buffer.push_back(coord);
}
else
{
return false;
}
}
else
{
if (coord != Coordinates(0, 0))
{
return false;
}
}
}
return true;
}
bool FiguresVariant::countNewDataBase()
{
for (int i = 0; i < common_substrings.size(); i++)
{
if (data_group_performance.size() == 0)
{
return false;
}
else
{
string answer = "";
string part_first = getInvertedPart(i);
string data = data_group_performance;
size_t begin = common_substrings[i].index_in_data;
size_t end = (begin + common_substrings[i].substring.size()) % data.size();
if (begin < end)
{
answer = data.substr(0, begin);
answer += part_first;
answer += data.substr(end, data.size() - end);
}
else
{
answer = data.substr(end, begin - end);
answer += part_first;
}
new_data_group_performances.push_back(answer);
}
}
return true;
}
string FiguresVariant::getInvertedPart(int iterator)
{
string answer = "";
string inverted = "";
string figures_str = figures.getGroupPerformanceByIndex(common_substrings[iterator].rotation);
size_t begin = (common_substrings[iterator].index_in_figures +
common_substrings[iterator].size)
% figures_str.size();
size_t size = figures_str.size() - common_substrings[iterator].size;
if (begin + size <= figures_str.size())
{
inverted = figures_str.substr(begin, size);
}
else
{
inverted = figures_str.substr(begin, size);
}
for (int i = (int)inverted.size(); i >= 0; i--)
{
switch (inverted[i])
{
case 'R':
answer.push_back('L');
break;
case 'D':
answer.push_back('U');
break;
case 'L':
answer.push_back('R');
break;
case 'U':
answer.push_back('D');
break;
default:
break;
}
}
return answer;
}
size_t FiguresVariant::getSubstringLength()
{
if (common_substrings.size() > 0)
{
return common_substrings[0].size;
}
else return 0;
}
void FiguresVariant::printVariantInfo()
{
cout << endl
<< "Base group performance: "
<< data_group_performance << endl
<< "Common substrings: ";
for (int i = 0; i < common_substrings.size(); i++)
{
cout << common_substrings[i].substring
<< " " << common_substrings[i].index_in_figures
<< " " << common_substrings[i].index_in_data
<< endl;
}
cout
<< "New field base string: ";
for (int i = 0; i < new_data_group_performances.size(); i++)
{
cout << " " << new_data_group_performances[i] << endl;
}
}
FiguresVariant& FiguresVariant::operator = (const FiguresVariant& right)
{
data_group_performance = right.data_group_performance;
end = right.end;
new_data_group_performances = right.new_data_group_performances;
figures = right.figures;
common_substrings = right.common_substrings;
return *this;
}
string FiguresVariant::getTurnedString(string input)
{
size_t size = input.size();
char tmp = input[size - 1];
for (size_t i = size - 1; i > 0; i--)
{
input[i] = input[i - 1];
}
input[0] = tmp;
return input;
}
|
476495bbeb99061c3a1445b0e1ca49b3fdc04b06 | 9728b8a0731fb0efad974d1ad7a39a3dcdad689f | /elite-modern-implementation/vector.cpp | 0bc38bd11ea861d1eb501bd05c0859a834e0e6af | [] | no_license | kangere/Spring-18-OOP | 1e7e4cb0714d1cb874c578fe362e96a871050f6b | bf9bfe5eb078070b2518009f66ac860b7d8cde05 | refs/heads/master | 2021-05-11T06:38:02.956707 | 2018-05-04T21:14:30 | 2018-05-04T21:14:30 | 117,993,841 | 0 | 0 | null | 2018-04-01T05:02:42 | 2018-01-18T14:32:00 | C | UTF-8 | C++ | false | false | 3,077 | cpp | vector.cpp | #include "vector.hpp"
#include <math.h>
static const Matrix start_matrix =
{
{1.0,0.0,0.0},
{0.0,1.0,0.0},
{0.0,0.0,-1.0}
};
/*
*funciton multiplies this vector with a second matrix
*and updates fields of current vector (this vector)
*/
void vector::mult_vector(vector *matrix)
{
double t_x, t_y, t_z;
t_x = (x * matrix[0].x) + (y * matrix[0].y) + (z * matrix[0].z);
t_y = (x * matrix[1].x) + (y * matrix[1].y) + (z * matrix[1].z);
t_z = (x * matrix[2].x) + (y * matrix[2].y) + (z * matrix[2].z);
x = t_x;
y = t_y;
z = t_z;
}
/*
* Calculate the dot product of two vectors sharing a common point.
* Returns the cosine of the angle between the two vectors.
*/
double vector::vector_dot_product(vector &vec)
{
return (x * vec.x) + (y * vec.y) + (z * vec.z);
}
/*
* Convert a vector into a vector of unit (1) length.
*/
vector vector::unit_vector()
{
double uni;
uni = sqrt (x * x + y * y + z * z);
return vector((x / uni),(y / uni),(z / uni));
}
/*
* rotates vector
* replaces rotate_vec function in space.c
* consolidate vector functions to vector class
*/
void vector::rotate_vec(double alpha, double beta)
{
double t_x, t_y, t_z;
t_y = y - alpha * x;
t_x = x + alpha * t_y;
t_y = t_y - beta * z;
t_z = z + beta * t_y;
x = t_x;
y = t_y;
z = t_z;
}
void vector::rotate_var(int first, int second, int direction)
{
double fx,ux;
fx = first;
ux = second;
if (direction < 0)
{
first = fx - (fx / 512) + (ux / 19);
second = ux - (ux / 512) - (fx / 19);
}
else
{
first = fx - (fx / 512) - (ux / 19);
second = ux - (ux / 512) + (fx / 19);
}
}
/*
* Functions rotates the x,y or z values with another vector's
* x,y, or z value - (not too sure)
*
*/
void vector::rotate_x(int t_x,int direction)
{
rotate_var(x,t_x,direction);
}
void vector::rotate_y(int t_y,int direction)
{
rotate_var(y,t_y,direction);
}
void vector::rotate_z(int t_z,int direction)
{
rotate_var(z,t_z,direction);
}
/*
* overload assignment operator
*/
void vector::operator=(const vector &second)
{
if(this != &second)
{
x = second.x;
y = second.y;
z = second.z;
}
}
/*
* Resets matrix
*
*
*/
void set_init_matrix (vector *mat)
{
int i;
for (i = 0; i < 3; i++)
mat[i] = start_matrix[i];
}
void tidy_matrix (vector *mat)
{
mat[2] = mat[2].unit_vector();
if ((mat[2].get_x() > -1) && (mat[2].get_x() < 1))
{
if ((mat[2].get_y() > -1) && (mat[2].get_y() < 1))
{
mat[1].set_z(-(mat[2].get_x() * mat[1].get_x() + mat[2].get_y() * mat[1].get_y()) / mat[2].get_z());
}
else
{
mat[1].set_y(-(mat[2].get_x() * mat[1].get_x() + mat[2].get_z() * mat[1].get_z()) / mat[2].get_y());
}
}
else
{
mat[1].set_x(-(mat[2].get_y() * mat[1].get_y() + mat[2].get_z() * mat[1].get_z()) / mat[2].get_x());
}
mat[1] = mat[1].unit_vector();
/* xyzzy... nothing happens. :-)*/
mat[0].set_x(mat[1].get_y() * mat[2].get_z() - mat[1].get_z() * mat[2].get_y());
mat[0].set_y(mat[1].get_z() * mat[2].get_x() - mat[1].get_x() * mat[2].get_z());
mat[0].set_z(mat[1].get_x() * mat[2].get_y() - mat[1].get_y() * mat[2].get_x());
} |
24ef9db0c88caccf8c4a2119ccb93e00a4901063 | 9e34e84c20760a9a37512c675074974ac7e56275 | /more-source/2010-2011/kbtu_lksh/day9/cubes.cpp | 3ded0b1eacc9f61b48364ff22bd9225fcce693b4 | [] | no_license | Slava/competitiveProgramming | 2b7f26bf24143b459c6e2625ef1ea343a926bb76 | b68391720b9f9efc4162a66ca07d9448cffc1453 | refs/heads/master | 2021-01-21T12:40:40.053352 | 2020-01-06T19:21:45 | 2020-01-06T19:21:45 | 9,552,080 | 8 | 6 | null | null | null | null | UTF-8 | C++ | false | false | 2,775 | cpp | cubes.cpp | #include <cstdio>
#include <cstring>
#define min(a,b) (a<b?a:b)
int n, m, k, mm, ans, S, T;
int d[2100], from[2100];
struct edge {
int x, y, c, f, cost;
edge() {f = 0;}
}a[400000];
bool fordbellman() {
memset(from, ~0, sizeof from);
for (int i = 0; i < n; i++)
d[i] = (1 << 30);
d[S] = 0; from[S] = -2;
bool found = 1;
for (;found;) {
found = 0;
for (int i = 0; i < mm; i++) {
if (a[i].c - a[i].f <= 0)continue;
int x = a[i].x,
y = a[i].y,
c = a[i].cost;
if (from[x] == -1)continue;
if (d[y] > d[x] + c) {
d[y] = d[x] + c;
from[y] = i;
found = 1;
}
}
}
return from[T] != -1;
}
int g[2100][2100];
main() {
freopen("cubes.in", "r", stdin);
freopen("cubes.out", "w", stdout);
scanf("%d", &n);
int sum = 0;
S = n + n; T = S + 1;
for (int i = 0; i < n; i++) {
int x; scanf("%d", &x); sum += x;
a[mm].x = S; a[mm].y = i; a[mm].cost = 0; a[mm].c = x; mm++;
a[mm].x = i; a[mm].y = S; a[mm].cost = 0; a[mm].c = 0; mm++;
a[mm].x = i; a[mm].y = i + n; a[mm].cost = 0; a[mm].c = x; mm++;
a[mm].x = i + n; a[mm].y = i; a[mm].cost = 0; a[mm].c = 0; mm++;
}
for (int i = 0; i < n; i++) {
int x = sum / n;
a[mm].x = i + n; a[mm].y = T; a[mm].cost = 0; a[mm].c = x; mm++;
a[mm].x = T; a[mm].y = i + n; a[mm].cost = 0; a[mm].c = 0; mm++;
}
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
scanf("%d", &g[i][j]);
for (int k = 0; k < n; k++)
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (g[i][j] > g[i][k] + g[k][j])
g[i][j] = g[i][k] + g[k][j];
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++) {
int x;
x = g[i][j];
a[mm].x = i; a[mm].y = j + n; a[mm].cost = x; a[mm].c = (1 << 30); mm++;
a[mm].y = i; a[mm].x = j + n; a[mm].cost = -x; a[mm].c = 0; mm++;
}
n = T + 1;
for (;fordbellman();) {
int v = T, e = from[v], cost = 0, M = (1 << 30);
while (e != -2) {
M = min(M, a[e].c - a[e].f);
v = a[e].x;
e = from[v];
}
v = T; e = from[v];
while (e != -2) {
a[e].f += M;
a[e^1].f -= M;
cost += a[e].cost * M;
v = a[e].x;
e = from[v];
}
ans += cost;
// printf("%d\n", cost);
}
// puts("flow found");
printf("%d\n", ans);
return 0;
}
|
fbc46159ef99981264a8860c2771cb7fea786ce0 | a6da5d2b60ad4545b0263997bf2a6e839821cd9f | /Source/NoName/Components/Movement/NLCharacterMovementComponent.h | 97cd25bbfde1497f0fd93151201d38ebd75d8d10 | [] | no_license | Nomu-s-Lair/NoName | 5ab11a6a0f78cd392bf3fafe31be5378d1a87241 | 0a3d40c4affc2296b959cdb33007dd463710037d | refs/heads/main | 2023-08-02T21:19:30.531301 | 2021-10-09T19:54:33 | 2021-10-09T19:54:33 | 409,980,327 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 770 | h | NLCharacterMovementComponent.h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "NLCharacterMovementComponent.generated.h"
/**
*
*/
UCLASS()
class NONAME_API UNLCharacterMovementComponent : public UCharacterMovementComponent
{
GENERATED_BODY()
public:
virtual float GetMaxSpeed() const override;
float GetVelocity() { return Velocity.Size(); };
/** Sprint **/
bool bIsSprinting = false;
FORCEINLINE bool IsSprinting() { return bIsSprinting; }
void StartSprint();
void StopSprint();
protected:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character movement | Speed", meta = (ClampMin = 0.0f, UIMin = 0.0f))
float SprintSpeed = 1200.0f;
};
|
4262d507787b78cff3978975fb89d1bf39f8baf0 | f14db7a1da4a6112874e8b03c0e730cee93ba1ab | /shader.cpp | 65f517a1a709eacda974397b0c6a1ede385ad142 | [] | no_license | Pusiu/QtGame | abe8b5261ab0bac3061b74dff4823eca7415a9ea | ca413b4686fda6467101b3de9bee6afc1e5f52b5 | refs/heads/master | 2022-09-21T02:51:30.757944 | 2020-06-05T00:35:49 | 2020-06-05T00:35:49 | 179,370,468 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 670 | cpp | shader.cpp | #include "shader.h"
Shader::Shader(QString name, QString vertexPath, QString fragmentPath)
{
this->name=name;
this->vertexPath=vertexPath;
this->fragmentPath=fragmentPath;
program = new QOpenGLShaderProgram();
Reload();
}
void Shader::Reload()
{
program->bind();
program->removeAllShaders();
program->addShaderFromSourceFile(QOpenGLShader::Vertex, vertexPath);
program->addShaderFromSourceFile(QOpenGLShader::Fragment, fragmentPath);
program->bindAttributeLocation("vertex", 0);
program->bindAttributeLocation("normal", 1);
program->bindAttributeLocation("uvCoord", 2);
program->link();
program->release();
}
|
b9f4d2b1b55a1986b0ace498427d109b49a50f44 | 194e04c9df93a0cc5d3d76289fc41973c4700c93 | /Capture/Packet.cpp | 5e74ba87765284c4c2e36aa13c0bfef225bd8ecc | [] | no_license | StarRate1214/master | 30845be1440c8703c3e6043be852da0abbf03508 | 522a5975bb1c76752210ee4754992c86bab98a68 | refs/heads/master | 2022-03-08T10:34:29.511288 | 2019-11-03T04:36:54 | 2019-11-03T04:36:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,217 | cpp | Packet.cpp | #include "Packet.h"
/*
CEthernet::CEthernet() {}
CEthernet::~CEthernet() {}
CEthernet::CEthernet(u_int8_t src_mac[], u_int8_t dst_mac[], u_int16_t ether_type)
{
for (int i = 0; i < 6; i++)
{
this->src_mac[i] = src_mac[i];
this->dst_mac[i] = dst_mac[i];
}
this->ether_type = ether_type;
}
CEthernet::CEthernet(const CEthernet &ref)
: ether_type(ref.ether_type)
{
for (int i = 0; i < 6; i++)
{
src_mac[i] = ref.src_mac[i];
dst_mac[i] = ref.dst_mac[i];
}
}
CEthernet &CEthernet::operator=(const CEthernet &ref)
{
for (int i = 0; i < 6; i++)
{
src_mac[i] = ref.src_mac[i];
dst_mac[i] = ref.dst_mac[i];
}
ether_type = ref.ether_type;
return *this;
}
void CEthernet::setSrcMac(u_int8_t src_mac[])
{
for (int i = 0; i < 6; i++)
this->src_mac[i] = src_mac[i];
}
void CEthernet::setDstMac(u_int8_t dst_mac[6])
{
for (int i = 0; i < 6; i++)
this->dst_mac[i] = dst_mac[i];
}
void CEthernet::setEtherType(u_int16_t ether_type)
{
this->ether_type = ether_type;
}
*/
CIPv4::CIPv4()
: src_ip(0), dst_ip(0), tos(0), more_frag(false), dont_frag(true), ttl(0)
{
}
CIPv4::~CIPv4() {}
CIPv4::CIPv4(
u_int32_t src_ip,
u_int32_t dst_ip,
u_int8_t tos,
bool more_frag,
bool dont_frag,
u_int8_t ttl)
{
this->src_ip = src_ip;
this->dst_ip = dst_ip;
this->tos = tos;
this->more_frag = more_frag;
this->dont_frag = dont_frag;
this->ttl = ttl;
}
CIPv4::CIPv4(const CIPv4 &ref)
: src_ip(ref.src_ip), dst_ip(ref.dst_ip), tos(ref.tos), more_frag(ref.more_frag), dont_frag(ref.dont_frag), ttl(ref.ttl)
{
}
CIPv4 &CIPv4::operator=(const CIPv4 &ref)
{
src_ip = ref.src_ip;
dst_ip = ref.dst_ip;
tos = ref.tos;
more_frag = ref.more_frag;
dont_frag = ref.dont_frag;
ttl = ref.ttl;
return *this;
}
void CIPv4::setSrcIP(u_int32_t src_ip)
{
this->src_ip = src_ip;
}
void CIPv4::setDstIP(u_int32_t dst_ip)
{
this->dst_ip = dst_ip;
}
void CIPv4::setTos(u_int8_t tos)
{
this->tos = tos;
}
void CIPv4::setMoreFrag(bool more_frag)
{
this->more_frag = more_frag;
}
void CIPv4::setDontFrag(bool dont_frag)
{
this->dont_frag = dont_frag;
}
void CIPv4::setTTL(u_int8_t ttl)
{
this->ttl = ttl;
}
CICMP::CICMP()
: icmp_type(0), icmp_code(0)
{
}
CICMP::~CICMP() {}
CICMP::CICMP(u_int8_t icmp_type, u_int8_t icmp_code)
{
this->icmp_type = icmp_type;
this->icmp_code = icmp_code;
}
CICMP::CICMP(const CICMP &ref)
: icmp_type(ref.icmp_type), icmp_code(ref.icmp_code)
{
}
CICMP &CICMP::operator=(const CICMP &ref)
{
icmp_type = ref.icmp_type;
icmp_code = ref.icmp_code;
return *this;
}
void CICMP::setICMPtype(u_int8_t icmp_type)
{
this->icmp_type = icmp_type;
}
void CICMP::setICMPcode(u_int8_t icmp_code)
{
this->icmp_code = icmp_code;
}
CTCP ::CTCP()
{
}
CTCP ::~CTCP()
{
}
CTCP ::CTCP(u_int16_t src_port,
u_int16_t dst_port,
u_int32_t seq_num,
u_int32_t ack_num,
bool urg,
bool ack,
bool psh,
bool rst,
bool syn,
bool fin,
u_int16_t win_size)
{
this->src_port = src_port;
this->dst_port = dst_port;
this->seq_num = seq_num;
this->ack_num = ack_num;
this->urg = urg;
this->ack = ack;
this->psh = psh;
this->rst = rst;
this->syn = syn;
this->fin = fin;
this->win_size = win_size;
}
CTCP ::CTCP(const CTCP &ref)
{
src_port = ref.src_port;
dst_port = ref.dst_port;
seq_num = ref.seq_num;
ack_num = ref.ack_num;
urg = ref.urg;
ack = ref.ack;
psh = ref.psh;
rst = ref.rst;
syn = ref.syn;
fin = ref.fin;
win_size = ref.win_size;
}
CTCP &CTCP ::operator=(const CTCP &ref)
{
src_port = ref.src_port;
dst_port = ref.dst_port;
seq_num = ref.seq_num;
ack_num = ref.ack_num;
urg = ref.urg;
ack = ref.ack;
psh = ref.psh;
rst = ref.rst;
syn = ref.syn;
fin = ref.fin;
win_size = ref.win_size;
return *this;
}
void CTCP ::setSrcPort(u_int16_t src_port) { this->src_port = src_port; }
void CTCP ::setDstPort(u_int16_t dst_port) { this->dst_port = dst_port; }
void CTCP ::setSeqNum(u_int32_t seq_num) { this->seq_num = seq_num; }
void CTCP ::setAckNum(u_int32_t ack_num) { this->ack_num = ack_num; }
void CTCP ::setUrg(bool urg) { this->urg = urg; }
void CTCP ::setAck(bool ack) { this->ack = ack; }
void CTCP ::setPsh(bool psh) { this->psh = psh; }
void CTCP ::setRst(bool rst) { this->rst = rst; }
void CTCP ::setSyn(bool syn) { this->syn = syn; }
void CTCP ::setFin(bool fin) { this->fin = fin; }
void CTCP ::setWinSize(u_int16_t win_size) { this->win_size = win_size; }
CUDP ::CUDP()
{
}
CUDP ::~CUDP()
{
}
CUDP ::CUDP(u_int16_t src_port, u_int16_t dst_port)
{
this->src_port = src_port;
this->dst_port = dst_port;
}
CUDP ::CUDP(const CUDP &ref)
{
src_port = ref.src_port;
dst_port = ref.dst_port;
}
CUDP &CUDP ::operator=(const CUDP &ref)
{
src_port = ref.src_port;
dst_port = ref.dst_port;
return *this;
}
void CUDP ::setSrcPort(u_int16_t src_port) { this->src_port = src_port; }
void CUDP ::setDstPort(u_int16_t dst_port) { this->dst_port = dst_port; }
CPacket ::CPacket()
: protocol_type(-1), time(0), data_payload_size(0)
{
data_payload = new u_int8_t[1];
}
CPacket ::~CPacket()
{
delete[] data_payload;
}
CPacket ::CPacket(const CPacket &ref)
{
protocol_type = ref.protocol_type;
time = ref.time;
tcp = ref.tcp;
udp = ref.udp;
icmp = ref.icmp;
ip = ref.ip;
data_payload_size = ref.data_payload_size;
data_payload = new u_int8_t[data_payload_size];
for (int i = 0; i < data_payload_size; i++)
data_payload[i] = ref.data_payload[i];
}
CPacket &CPacket ::operator=(const CPacket &ref)
{
protocol_type = ref.protocol_type;
time = ref.time;
tcp = ref.tcp;
udp = ref.udp;
icmp = ref.icmp;
ip = ref.ip;
data_payload_size = ref.data_payload_size;
delete[] data_payload;
data_payload = new u_int8_t[data_payload_size];
for (int i = 0; i < data_payload_size; i++)
data_payload[i] = ref.data_payload[i];
return *this;
} |
5873c150b1a6c27f6590b21c4128eb7fc5f19c04 | 33be137cc86b78bce45820fc81383b0784b69c36 | /sources/arquade/game/m_insane.cpp | 59907e47225723e0a2aabbab0ccb54c4ebd56cdb | [] | no_license | Paril/quake2-source-archive | 010d9758448ae61442d7d12a7198d4c4874665d4 | 6eb7a72cd2187dc0caef151f9af5e6f4b090dd8a | refs/heads/main | 2023-07-12T16:50:16.098868 | 2021-08-22T12:30:00 | 2021-08-22T12:30:00 | 341,576,903 | 10 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 17,324 | cpp | m_insane.cpp | /*
Copyright (C) 1997-2001 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
==============================================================================
insane
==============================================================================
*/
#include "g_local.h"
#include "m_insane.h"
static int sound_fist;
static int sound_shake;
static int sound_moan;
static int sound_scream[8];
void insane_fist (edict_t *self)
{
gi.sound (self, CHAN_VOICE, sound_fist, 1, ATTN_IDLE, 0);
}
void insane_shake (edict_t *self)
{
gi.sound (self, CHAN_VOICE, sound_shake, 1, ATTN_IDLE, 0);
}
void insane_moan (edict_t *self)
{
gi.sound (self, CHAN_VOICE, sound_moan, 1, ATTN_IDLE, 0);
}
void insane_scream (edict_t *self)
{
gi.sound (self, CHAN_VOICE, sound_scream[rand()%8], 1, ATTN_IDLE, 0);
}
void insane_stand (edict_t *self);
void insane_dead (edict_t *self);
void insane_cross (edict_t *self);
void insane_walk (edict_t *self);
void insane_run (edict_t *self);
void insane_checkdown (edict_t *self);
void insane_checkup (edict_t *self);
void insane_onground (edict_t *self);
mframe_t insane_frames_stand_normal [] =
{
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, insane_checkdown
};
mmove_t insane_move_stand_normal = {FRAME_stand60, FRAME_stand65, insane_frames_stand_normal, insane_stand};
mframe_t insane_frames_stand_insane [] =
{
ai_stand, 0, insane_shake,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, NULL,
ai_stand, 0, insane_checkdown
};
mmove_t insane_move_stand_insane = {FRAME_stand65, FRAME_stand94, insane_frames_stand_insane, insane_stand};
mframe_t insane_frames_uptodown [] =
{
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, insane_moan,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 2.7f, NULL,
ai_move, 4.1f, NULL,
ai_move, 6, NULL,
ai_move, 7.6f, NULL,
ai_move, 3.6f, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, insane_fist,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, insane_fist,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL
};
mmove_t insane_move_uptodown = {FRAME_stand1, FRAME_stand40, insane_frames_uptodown, insane_onground};
mframe_t insane_frames_downtoup [] =
{
ai_move, -0.7f, NULL, // 41
ai_move, -1.2f, NULL, // 42
ai_move, -1.5f, NULL, // 43
ai_move, -4.5f, NULL, // 44
ai_move, -3.5f, NULL, // 45
ai_move, -0.2f, NULL, // 46
ai_move, 0, NULL, // 47
ai_move, -1.3f, NULL, // 48
ai_move, -3, NULL, // 49
ai_move, -2, NULL, // 50
ai_move, 0, NULL, // 51
ai_move, 0, NULL, // 52
ai_move, 0, NULL, // 53
ai_move, -3.3f, NULL, // 54
ai_move, -1.6f, NULL, // 55
ai_move, -0.3f, NULL, // 56
ai_move, 0, NULL, // 57
ai_move, 0, NULL, // 58
ai_move, 0, NULL // 59
};
mmove_t insane_move_downtoup = {FRAME_stand41, FRAME_stand59, insane_frames_downtoup, insane_stand};
mframe_t insane_frames_jumpdown [] =
{
ai_move, 0.2f, NULL,
ai_move, 11.5f, NULL,
ai_move, 5.1f, NULL,
ai_move, 7.1f, NULL,
ai_move, 0, NULL
};
mmove_t insane_move_jumpdown = {FRAME_stand96, FRAME_stand100, insane_frames_jumpdown, insane_onground};
mframe_t insane_frames_down [] =
{
ai_move, 0, NULL, // 100
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL, // 110
ai_move, -1.7f, NULL,
ai_move, -1.6f, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, insane_fist,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL, // 120
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL, // 130
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, insane_moan,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL, // 140
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL, // 150
ai_move, 0.5f, NULL,
ai_move, 0, NULL,
ai_move, -0.2f, insane_scream,
ai_move, 0, NULL,
ai_move, 0.2f, NULL,
ai_move, 0.4f, NULL,
ai_move, 0.6f, NULL,
ai_move, 0.8f, NULL,
ai_move, 0.7f, NULL,
ai_move, 0, insane_checkup // 160
};
mmove_t insane_move_down = {FRAME_stand100, FRAME_stand160, insane_frames_down, insane_onground};
mframe_t insane_frames_walk_normal [] =
{
ai_walk, 0, insane_scream,
ai_walk, 2.5f, NULL,
ai_walk, 3.5f, NULL,
ai_walk, 1.7f, NULL,
ai_walk, 2.3f, NULL,
ai_walk, 2.4f, NULL,
ai_walk, 2.2f, NULL,
ai_walk, 4.2f, NULL,
ai_walk, 5.6f, NULL,
ai_walk, 3.3f, NULL,
ai_walk, 2.4f, NULL,
ai_walk, 0.9f, NULL,
ai_walk, 0, NULL
};
mmove_t insane_move_walk_normal = {FRAME_walk27, FRAME_walk39, insane_frames_walk_normal, insane_walk};
mmove_t insane_move_run_normal = {FRAME_walk27, FRAME_walk39, insane_frames_walk_normal, insane_run};
mframe_t insane_frames_walk_insane [] =
{
ai_walk, 0, insane_scream, // walk 1
ai_walk, 3.4f, NULL, // walk 2
ai_walk, 3.6f, NULL, // 3
ai_walk, 2.9f, NULL, // 4
ai_walk, 2.2f, NULL, // 5
ai_walk, 2.6f, NULL, // 6
ai_walk, 0, NULL, // 7
ai_walk, 0.7f, NULL, // 8
ai_walk, 4.8f, NULL, // 9
ai_walk, 5.3f, NULL, // 10
ai_walk, 1.1f, NULL, // 11
ai_walk, 2, NULL, // 12
ai_walk, 0.5f, NULL, // 13
ai_walk, 0, NULL, // 14
ai_walk, 0, NULL, // 15
ai_walk, 4.9f, NULL, // 16
ai_walk, 6.7f, NULL, // 17
ai_walk, 3.8f, NULL, // 18
ai_walk, 2, NULL, // 19
ai_walk, 0.2f, NULL, // 20
ai_walk, 0, NULL, // 21
ai_walk, 3.4f, NULL, // 22
ai_walk, 6.4f, NULL, // 23
ai_walk, 5, NULL, // 24
ai_walk, 1.8f, NULL, // 25
ai_walk, 0, NULL // 26
};
mmove_t insane_move_walk_insane = {FRAME_walk1, FRAME_walk26, insane_frames_walk_insane, insane_walk};
mmove_t insane_move_run_insane = {FRAME_walk1, FRAME_walk26, insane_frames_walk_insane, insane_run};
mframe_t insane_frames_stand_pain [] =
{
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL
};
mmove_t insane_move_stand_pain = {FRAME_st_pain2, FRAME_st_pain12, insane_frames_stand_pain, insane_run};
mframe_t insane_frames_stand_death [] =
{
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL
};
mmove_t insane_move_stand_death = {FRAME_st_death2, FRAME_st_death18, insane_frames_stand_death, insane_dead};
mframe_t insane_frames_crawl [] =
{
ai_walk, 0, insane_scream,
ai_walk, 1.5f, NULL,
ai_walk, 2.1f, NULL,
ai_walk, 3.6f, NULL,
ai_walk, 2, NULL,
ai_walk, 0.9f, NULL,
ai_walk, 3, NULL,
ai_walk, 3.4f, NULL,
ai_walk, 2.4f, NULL
};
mmove_t insane_move_crawl = {FRAME_crawl1, FRAME_crawl9, insane_frames_crawl, NULL};
mmove_t insane_move_runcrawl = {FRAME_crawl1, FRAME_crawl9, insane_frames_crawl, NULL};
mframe_t insane_frames_crawl_pain [] =
{
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL
};
mmove_t insane_move_crawl_pain = {FRAME_cr_pain2, FRAME_cr_pain10, insane_frames_crawl_pain, insane_run};
mframe_t insane_frames_crawl_death [] =
{
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL
};
mmove_t insane_move_crawl_death = {FRAME_cr_death10, FRAME_cr_death16, insane_frames_crawl_death, insane_dead};
mframe_t insane_frames_cross [] =
{
ai_move, 0, insane_moan,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL
};
mmove_t insane_move_cross = {FRAME_cross1, FRAME_cross15, insane_frames_cross, insane_cross};
mframe_t insane_frames_struggle_cross [] =
{
ai_move, 0, insane_scream,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL,
ai_move, 0, NULL
};
mmove_t insane_move_struggle_cross = {FRAME_cross16, FRAME_cross30, insane_frames_struggle_cross, insane_cross};
void insane_cross (edict_t *self)
{
if (random() < 0.8)
self->monsterinfo.currentmove = &insane_move_cross;
else
self->monsterinfo.currentmove = &insane_move_struggle_cross;
}
void insane_walk (edict_t *self)
{
if ( self->spawnflags & 16 ) // Hold Ground?
if (self->s.frame == FRAME_cr_pain10)
{
self->monsterinfo.currentmove = &insane_move_down;
return;
}
if (self->spawnflags & 4)
self->monsterinfo.currentmove = &insane_move_crawl;
else
if (random() <= 0.5)
self->monsterinfo.currentmove = &insane_move_walk_normal;
else
self->monsterinfo.currentmove = &insane_move_walk_insane;
}
void insane_run (edict_t *self)
{
if ( self->spawnflags & 16 ) // Hold Ground?
if (self->s.frame == FRAME_cr_pain10)
{
self->monsterinfo.currentmove = &insane_move_down;
return;
}
if (self->spawnflags & 4) // Crawling?
self->monsterinfo.currentmove = &insane_move_runcrawl;
else
if (random() <= 0.5) // Else, mix it up
self->monsterinfo.currentmove = &insane_move_run_normal;
else
self->monsterinfo.currentmove = &insane_move_run_insane;
}
void insane_pain (edict_t *self, edict_t *other, float kick, int damage)
{
int l,r;
// if (self->health < (self->max_health / 2))
// self->s.skinnum = 1;
if (level.time < self->pain_debounce_time)
return;
self->pain_debounce_time = level.time + 3;
r = 1 + (rand()&1);
if (self->health < 25)
l = 25;
else if (self->health < 50)
l = 50;
else if (self->health < 75)
l = 75;
else
l = 100;
gi.sound (self, CHAN_VOICE, gi.soundindex (Q_VarArgs ("player/male/pain%i_%i.wav", l, r)), 1, ATTN_IDLE, 0);
if (skill->floatVal == 3)
return; // no pain anims in nightmare
// Don't go into pain frames if crucified.
if (self->spawnflags & 8)
{
self->monsterinfo.currentmove = &insane_move_struggle_cross;
return;
}
if ( ((self->s.frame >= FRAME_crawl1) && (self->s.frame <= FRAME_crawl9)) || ((self->s.frame >= FRAME_stand99) && (self->s.frame <= FRAME_stand160)) )
{
self->monsterinfo.currentmove = &insane_move_crawl_pain;
}
else
self->monsterinfo.currentmove = &insane_move_stand_pain;
}
void insane_onground (edict_t *self)
{
self->monsterinfo.currentmove = &insane_move_down;
}
void insane_checkdown (edict_t *self)
{
// if ( (self->s.frame == FRAME_stand94) || (self->s.frame == FRAME_stand65) )
if (self->spawnflags & 32) // Always stand
return;
if (random() < 0.3)
if (random() < 0.5)
self->monsterinfo.currentmove = &insane_move_uptodown;
else
self->monsterinfo.currentmove = &insane_move_jumpdown;
}
void insane_checkup (edict_t *self)
{
// If Hold_Ground and Crawl are set
if ( (self->spawnflags & 4) && (self->spawnflags & 16) )
return;
if (random() < 0.5)
self->monsterinfo.currentmove = &insane_move_downtoup;
}
void insane_stand (edict_t *self)
{
if (self->spawnflags & 8) // If crucified
{
self->monsterinfo.currentmove = &insane_move_cross;
self->monsterinfo.aiflags |= AI_STAND_GROUND;
}
// If Hold_Ground and Crawl are set
else if ( (self->spawnflags & 4) && (self->spawnflags & 16) )
self->monsterinfo.currentmove = &insane_move_down;
else
if (random() < 0.5)
self->monsterinfo.currentmove = &insane_move_stand_normal;
else
self->monsterinfo.currentmove = &insane_move_stand_insane;
}
void insane_dead (edict_t *self)
{
if (self->spawnflags & 8)
{
self->flags |= FL_FLY;
}
else
{
Vec3Set (self->mins, -16, -16, -24);
Vec3Set (self->maxs, 16, 16, -8);
self->movetype = MOVETYPE_TOSS;
}
self->svFlags |= SVF_DEADMONSTER;
self->nextthink = 0;
gi.linkentity (self);
}
void insane_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
{
int n;
if (self->health <= self->gib_health)
{
gi.sound (self, CHAN_VOICE, gi.soundindex ("misc/udeath.wav"), 1, ATTN_IDLE, 0);
for (n= 0; n < 2; n++)
ThrowGib (self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC);
for (n= 0; n < 4; n++)
ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
ThrowHead (self, "models/objects/gibs/head2/tris.md2", damage, GIB_ORGANIC);
self->deadflag = DEAD_DEAD;
return;
}
if (self->deadflag == DEAD_DEAD)
return;
gi.sound (self, CHAN_VOICE, gi.soundindex(Q_VarArgs ("player/male/death%i.wav", (rand()%4)+1)), 1, ATTN_IDLE, 0);
self->deadflag = DEAD_DEAD;
self->takedamage = DAMAGE_YES;
if (self->spawnflags & 8)
{
insane_dead (self);
}
else
{
if ( ((self->s.frame >= FRAME_crawl1) && (self->s.frame <= FRAME_crawl9)) || ((self->s.frame >= FRAME_stand99) && (self->s.frame <= FRAME_stand160)) )
self->monsterinfo.currentmove = &insane_move_crawl_death;
else
self->monsterinfo.currentmove = &insane_move_stand_death;
}
}
/*QUAKED misc_insane (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn CRAWL CRUCIFIED STAND_GROUND ALWAYS_STAND
*/
void SP_misc_insane (edict_t *self)
{
// static int skin = 0; //@@
if (deathmatch->floatVal)
{
G_FreeEdict (self);
return;
}
sound_fist = gi.soundindex ("insane/insane11.wav");
sound_shake = gi.soundindex ("insane/insane5.wav");
sound_moan = gi.soundindex ("insane/insane7.wav");
sound_scream[0] = gi.soundindex ("insane/insane1.wav");
sound_scream[1] = gi.soundindex ("insane/insane2.wav");
sound_scream[2] = gi.soundindex ("insane/insane3.wav");
sound_scream[3] = gi.soundindex ("insane/insane4.wav");
sound_scream[4] = gi.soundindex ("insane/insane6.wav");
sound_scream[5] = gi.soundindex ("insane/insane8.wav");
sound_scream[6] = gi.soundindex ("insane/insane9.wav");
sound_scream[7] = gi.soundindex ("insane/insane10.wav");
self->movetype = MOVETYPE_STEP;
self->solid = SOLID_BBOX;
self->s.modelIndex = gi.modelIndex("models/monsters/insane/tris.md2");
Vec3Set (self->mins, -16, -16, -24);
Vec3Set (self->maxs, 16, 16, 32);
self->health = 100;
self->gib_health = -50;
self->mass = 300;
self->pain = insane_pain;
self->die = insane_die;
self->monsterinfo.stand = insane_stand;
self->monsterinfo.walk = insane_walk;
self->monsterinfo.run = insane_run;
self->monsterinfo.dodge = NULL;
self->monsterinfo.attack = NULL;
self->monsterinfo.melee = NULL;
self->monsterinfo.sight = NULL;
self->monsterinfo.aiflags |= AI_GOOD_GUY;
//@@
// self->s.skinnum = skin;
// skin++;
// if (skin > 12)
// skin = 0;
gi.linkentity (self);
if (self->spawnflags & 16) // Stand Ground
self->monsterinfo.aiflags |= AI_STAND_GROUND;
self->monsterinfo.currentmove = &insane_move_stand_normal;
self->monsterinfo.scale = MODEL_SCALE;
if (self->spawnflags & 8) // Crucified ?
{
Vec3Set (self->mins, -16, 0, 0);
Vec3Set (self->maxs, 16, 8, 32);
self->flags |= FL_NO_KNOCKBACK;
flymonster_start (self);
}
else
{
walkmonster_start (self);
self->s.skinNum = rand()%3;
}
}
|
bada14b5facffc857b394012d2a34c139e35b2dc | 9de0cec678bc4a3bec2b4adabef9f39ff5b4afac | /PWG/FLOW/Tasks/AliAnalysisTaskPhiFlow.cxx | b622df02de015f4df46684311c8107c4fdd1b5e6 | [] | permissive | alisw/AliPhysics | 91bf1bd01ab2af656a25ff10b25e618a63667d3e | 5df28b2b415e78e81273b0d9bf5c1b99feda3348 | refs/heads/master | 2023-08-31T20:41:44.927176 | 2023-08-31T14:51:12 | 2023-08-31T14:51:12 | 61,661,378 | 129 | 1,150 | BSD-3-Clause | 2023-09-14T18:48:45 | 2016-06-21T19:31:29 | C++ | UTF-8 | C++ | false | false | 64,894 | cxx | AliAnalysisTaskPhiFlow.cxx | /**************************************************************************
* Copyright(c) 1998-1999, 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. *
**************************************************************************/
// AliAnalysisTaskPhiFlow:
// author: Redmer Alexander Bertens (rbertens@cern.ch)
// analyis task for phi-meson reconstruction and determination of v_n
// AliPhiMesonHelperTrack provides a lightweight helper track for reconstruction
// new in this version (use with caution): vzero event plane, event mixing
#include "TChain.h"
#include "TH1.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TMath.h"
#include "TObjArray.h"
#include "AliAnalysisTaskSE.h"
#include "AliAnalysisManager.h"
#include "AliAODEvent.h"
#include "AliAODInputHandler.h"
#include "AliCentrality.h"
#include "AliAnalysisTaskPhiFlow.h"
#include "AliFlowBayesianPID.h"
#include "AliPIDCombined.h"
#include "AliMCEvent.h"
#include "TProfile.h"
#include "AliFlowCandidateTrack.h"
#include "AliFlowTrackCuts.h"
#include "AliFlowEventSimple.h"
#include "AliFlowTrackSimple.h"
#include "AliFlowCommonConstants.h"
#include "AliFlowEvent.h"
#include "TVector3.h"
#include "AliAODVZERO.h"
#include "AliPIDResponse.h"
#include "AliTPCPIDResponse.h"
#include "AliAODMCParticle.h"
#include "AliAnalysisTaskVnV0.h"
#include "AliEventPoolManager.h"
#include "AliMultSelection.h"
#include "TMatrixDSym.h"
#include "AliVVertex.h"
#include "AliAODVertex.h"
class AliFlowTrackCuts;
using std::cout;
using std::endl;
ClassImp(AliAnalysisTaskPhiFlow)
ClassImp(AliPhiMesonHelperTrack)
AliAnalysisTaskPhiFlow::AliAnalysisTaskPhiFlow() : AliAnalysisTaskSE(),
fDebug(0), fIsMC(0), fEventMixing(0), fTypeMixing(0), fQA(0), fV0(0), fMassBins(1), fMinMass(-1.), fMaxMass(0.), fCutsRP(NULL), fNullCuts(0), fPIDResponse(0), fFlowEvent(0), fBayesianResponse(0), fCandidates(0), fCandidateEtaPtCut(0), fCandidateMinEta(0), fCandidateMaxEta(0), fCandidateMinPt(0), fCandidateMaxPt(0), fCandidateYCut(kFALSE), fCandidateMinY(-.5), fCandidateMaxY(.5), fNPtBins(18), fCentrality(999), fVertex(999), fAOD(0), fPoolManager(0), fOutputList(0), fEventStats(0), fCentralityPass(0), fCentralityNoPass(0), fNOPID(0), fPIDk(0),fNOPIDTOF(0), fPIDTOF(0), fPtP(0), fPtN(0), fPtKP(0), fPtKN(0), fMultCorAfterCuts(0), fMultvsCentr(0), fCentralityMin(0), fCentralityMax(100), fkCentralityMethodA(0), fkCentralityMethodB(0), fCentralityCut2010(0), fCentralityCut2011(0), fCentralityEstimator("V0M"), fPOICuts(0), fVertexRange(10.), fPhi(0), fPt(0), fEta(0), fVZEROA(0), fVZEROC(0), fTPCM(0)/*, fDeltaDipAngle(0), fDeltaDipPt(0), fApplyDeltaDipCut(0)*/, fDCAAll(0), fDCAXYQA(0), fDCAZQA(0), fDCAPrim(0), fDCASecondaryWeak(0), fDCAMaterial(0), fSubEventDPhiv2(0), fSkipEventSelection(0), fUsePidResponse(0), fPIDCombined(0), fPileUp(kTRUE), fMultESDTPCdif(15000), fLowCut(0), fHighCut(0), fMultTOFLowCut(0), fMultTOFHighCut(0), fHistCentralityWeights(0x0), fCentralityWeight(1.), fVertexZ(0), fHarmonic(2)
{
// Default constructor
for(Int_t i(0); i < 7; i++) fPIDConfig[i] = 1000.;
for(Int_t i(0); i < 5; i++) fDCAConfig[i] = 0.;
for(Int_t i(0); i < 20; i++) {
fVertexMixingBins[i] = 0;
fCentralityMixingBins[i] = 0;
}
fMixingParameters[0] = 1000; fMixingParameters[1] = 50000; fMixingParameters[2] = 5;
for(Int_t i(0); i < 18; i++) {
for(Int_t j(0); j < 2; j++) fV0Data[i][j] = 0;
fInvMNP[i] = 0; fInvMNN[i] = 0; fInvMPP[i] = 0; fPtSpectra[i] = 0; fPtBins[i] = 0.;
}
}
//_____________________________________________________________________________
AliAnalysisTaskPhiFlow::AliAnalysisTaskPhiFlow(const char *name) : AliAnalysisTaskSE(name),
fDebug(0), fIsMC(0), fEventMixing(0), fTypeMixing(0), fQA(0), fV0(0), fMassBins(1), fMinMass(-1.), fMaxMass(0.), fCutsRP(NULL), fNullCuts(0), fPIDResponse(0), fFlowEvent(0), fBayesianResponse(0), fCandidates(0), fCandidateEtaPtCut(0), fCandidateMinEta(0), fCandidateMaxEta(0), fCandidateMinPt(0), fCandidateMaxPt(0), fCandidateYCut(kFALSE), fCandidateMinY(-.5), fCandidateMaxY(.5), fNPtBins(18), fCentrality(999), fVertex(999), fAOD(0), fPoolManager(0), fOutputList(0), fEventStats(0), fCentralityPass(0), fCentralityNoPass(0), fNOPID(0), fPIDk(0), fNOPIDTOF(0), fPIDTOF(0), fPtP(0), fPtN(0), fPtKP(0), fPtKN(0), fMultCorAfterCuts(0), fMultvsCentr(0), fCentralityMin(0), fCentralityMax(100), fkCentralityMethodA(0), fkCentralityMethodB(0), fCentralityCut2010(0), fCentralityCut2011(0), fCentralityEstimator("V0M"), fPOICuts(0), fVertexRange(10.), fPhi(0), fPt(0), fEta(0), fVZEROA(0), fVZEROC(0), fTPCM(0)/*, fDeltaDipAngle(0), fDeltaDipPt(0), fApplyDeltaDipCut(0)*/, fDCAAll(0), fDCAXYQA(0), fDCAZQA(0), fDCAPrim(0), fDCASecondaryWeak(0), fDCAMaterial(0), fSubEventDPhiv2(0), fSkipEventSelection(0), fUsePidResponse(0), fPIDCombined(0), fPileUp(kTRUE), fMultESDTPCdif(15000), fLowCut(0), fHighCut(0), fMultTOFLowCut(0), fMultTOFHighCut(0), fHistCentralityWeights(0x0), fCentralityWeight(1.), fVertexZ(0), fHarmonic(2)
{
// Constructor
for(Int_t i(0); i < 7; i++) fPIDConfig[i] = 1000.;
for(Int_t i(0); i < 5; i++) fDCAConfig[i] = 0.;
for(Int_t i(0); i < 20; i++) {
fVertexMixingBins[i] = 0;
fCentralityMixingBins[i] = 0;
}
fMixingParameters[0] = 1000; fMixingParameters[1] = 50000; fMixingParameters[2] = 5;
for(Int_t i(0); i < 18; i++) {
for(Int_t j(0); j < 2; j++) fV0Data[i][j] = 0;
fInvMNP[i] = 0; fInvMNN[i] = 0; fInvMPP[i] = 0; fPtSpectra[i] = 0; fPtBins[i] = 0.;
}
DefineInput(0, TChain::Class());
DefineOutput(1, TList::Class());
DefineOutput(2, AliFlowEventSimple::Class());
if(fDebug > 0) cout << " === Created instance of AliAnaysisTaskPhiFlow === " << endl;
}
//_____________________________________________________________________________
AliAnalysisTaskPhiFlow::~AliAnalysisTaskPhiFlow()
{
// Destructor
if (fNullCuts) delete fNullCuts;
if (fOutputList) delete fOutputList;
if (fCandidates) delete fCandidates;
if (fFlowEvent) delete fFlowEvent;
if (fBayesianResponse) delete fBayesianResponse;
if (fEventMixing) delete fPoolManager;
if (fPIDCombined) delete fPIDCombined;
if (fDebug > 0) cout << " === Deleted instance of AliAnalysisTaskPhiFlow === " << endl;
}
//_____________________________________________________________________________
TH1F* AliAnalysisTaskPhiFlow::BookHistogram(const char* name)
{
// Return a pointer to a TH1 with predefined binning
if(fDebug > 0) cout << " *** BookHistogram() *** " << name << endl;
TH1F *hist = new TH1F(name, Form("M_{INV} (%s)", name), 60, .99, 1.092);
hist->GetXaxis()->SetTitle("M_{INV} (GeV / c^{2})");
hist->GetYaxis()->SetTitle("No. of pairs");
hist->SetMarkerStyle(kFullCircle);
hist->Sumw2();
fOutputList->Add(hist);
return hist;
}
//_____________________________________________________________________________
TH2F* AliAnalysisTaskPhiFlow::BookPIDHistogram(const char* name, Bool_t TPC)
{
// Return a pointer to a TH2 with predefined binning
if(fDebug > 0) cout << " *** BookPIDHisotgram() *** " << endl;
TH2F *hist = 0x0;
if(TPC) {
hist = new TH2F(name, Form("PID (%s)", name), 100, 0, 5, 100, 0, 1000);
hist->GetYaxis()->SetTitle("dE/dx (a.u.)");
}
if(!TPC) {
hist = new TH2F(name, Form("PID (%s)", name), 100, 0, 5, 100, 0, 1.5);
hist->GetYaxis()->SetTitle("#beta");
}
hist->GetXaxis()->SetTitle("P (GeV / c)");
fOutputList->Add(hist);
return hist;
}
//_____________________________________________________________________________
TH1F* AliAnalysisTaskPhiFlow::InitPtSpectraHistograms(Float_t nmin, Float_t nmax)
{
// intialize p_t histograms for each p_t bin
if(fDebug > 0) cout << " *** InitPtSpectraHistograms() *** " << endl;
TH1F* hist = new TH1F(Form("%4.2f p_{t} %4.2f", nmin, nmax), Form("%f p_{t} %f", nmin, nmax), 60, nmin, nmax);
hist->GetXaxis()->SetTitle("p_{T} GeV / c");
fOutputList->Add(hist);
return hist;
}
//_____________________________________________________________________________
TH1F* AliAnalysisTaskPhiFlow::BookPtHistogram(const char* name)
{
// Return a pointer to a p_T spectrum histogram
if(fDebug > 0) cout << " *** BookPtHistogram() *** " << endl;
TH1F* ratio = new TH1F(name, name, 100, 0, 7);
ratio->GetXaxis()->SetTitle("p_{T} ( GeV / c^{2} )");
ratio->GetYaxis()->SetTitle("No. of events");
ratio->Sumw2();
fOutputList->Add(ratio);
return ratio;
}
//_____________________________________________________________________________
void AliAnalysisTaskPhiFlow::AddPhiIdentificationOutputObjects()
{
// Add Phi Identification Output Objects
if(fDebug > 0) cout << " ** AddPhiIdentificationOutputObjects() *** " << endl;
if(fQA) {
fEventStats = new TH1F("fHistStats", "Event Statistics", 18, -.25, 4.25);
fEventStats->GetXaxis()->SetTitle("No. of events");
fEventStats->GetYaxis()->SetTitle("Statistics");
fOutputList->Add(fEventStats);
}
fCentralityPass = new TH1F("fCentralityPass", "Centrality Pass", 101, -1, 100);
fOutputList->Add(fCentralityPass);
if(fQA) {
fCentralityNoPass = new TH1F("fCentralityNoPass", "Centrality No Pass", 101, -1, 100);
fOutputList->Add(fCentralityNoPass);
fNOPID = BookPIDHistogram("TPC signal, all particles", kTRUE);
fPIDk = BookPIDHistogram("TPC signal, kaons", kTRUE);
fNOPIDTOF = BookPIDHistogram("TOF signal, all particles", kFALSE);
fPIDTOF = BookPIDHistogram("TOF signal, kaons", kFALSE);
}
for(Int_t ptbin(0); ptbin < fNPtBins; ptbin++) {
fInvMNP[ptbin] = BookHistogram(Form("NP, %4.2f < p_{T} < %4.2f GeV", fPtBins[ptbin], fPtBins[ptbin+1]));
fInvMNN[ptbin] = BookHistogram(Form("NN, %4.2f < p_{T} < %4.2f GeV", fPtBins[ptbin], fPtBins[ptbin+1]));
fInvMPP[ptbin] = BookHistogram(Form("PP, %4.2f < p_{T} < %4.2f GeV", fPtBins[ptbin], fPtBins[ptbin+1]));
}
if(fQA) {
for(Int_t ptbin(0); ptbin < fNPtBins; ptbin++) fPtSpectra[ptbin] = InitPtSpectraHistograms(fPtBins[ptbin], fPtBins[ptbin+1]);
fPtP = BookPtHistogram("i^{+}");
fPtN = BookPtHistogram("i^{-}");
fPtKP = BookPtHistogram("K^{+}");
fPtKN = BookPtHistogram("K^{-}");
fPhi = new TH1F("fPhi", "#phi distribution", 100, -.5, 7);
fOutputList->Add(fPhi);
fPt = new TH1F("fPt", "p_{T}", 100, 0, 5.5);
fOutputList->Add(fPt);
fEta = new TH1F("fEta", "#eta distribution", 100, -1.1, 1.1);
fOutputList->Add(fEta);
fVZEROA = new TH1F("fVZEROA", "VZERO A Multiplicity", 1000, 0, 10000);
fOutputList->Add(fVZEROA);
fVZEROC = new TH1F("fVZEROC", "VZERO C Multiplicity", 1000, 0, 10000);
fOutputList->Add(fVZEROC);
fTPCM = new TH1F("fTPCM", "TPC multiplicity", 1000, 0, 10000);
fOutputList->Add(fTPCM);
fDCAXYQA = new TH1F("fDCAXYQA", "fDCAXYQA", 1000, -5, 5);
fOutputList->Add(fDCAXYQA);
fDCAZQA = new TH1F("fDCAZQA", "fDCAZQA", 1000, -5, 5);
fOutputList->Add(fDCAZQA);
fMultCorAfterCuts = new TH2F("fMultCorAfterCuts", "centrality correlations;V0 centrality;CL0 centrality", 100, 0, 100, 100, 0, 100);
fOutputList->Add(fMultCorAfterCuts);
fMultvsCentr = new TH2F("fMultvsCentr", "multiplicty centrality;TPC multiplicity;V0 centrality", 250, 0, 5000, 100, 0, 100);
fOutputList->Add(fMultvsCentr);
}
if(fIsMC || fQA) {
fDCAAll = new TH2F("fDCAAll", "fDCAAll", 1000, 0, 10, 1000, -5, 5);
fOutputList->Add(fDCAAll);
fDCAPrim = new TH2F("fDCAprim","fDCAprim", 1000, 0, 10, 1000, -5, 5);
fOutputList->Add(fDCAPrim);
fDCASecondaryWeak = new TH2F("fDCASecondaryWeak","fDCASecondaryWeak", 1000, 0, 10, 1000, -5, 5);
fOutputList->Add(fDCASecondaryWeak);
fDCAMaterial = new TH2F("fDCAMaterial","fDCAMaterial", 1000, 0, 10, 1000, -5, 5);
fOutputList->Add(fDCAMaterial);
}
if(fV0) {
fSubEventDPhiv2 = new TProfile("fSubEventDPhiv2", "fSubEventDPhiv2", 5, 0, 5);
fSubEventDPhiv2->GetXaxis()->SetBinLabel(1, "<#Psi_{a} - #Psi_{b}>");
fSubEventDPhiv2->GetXaxis()->SetBinLabel(2, "<#Psi_{a} - #Psi_{c}>");
fSubEventDPhiv2->GetXaxis()->SetBinLabel(3, "<#Psi_{b} - #Psi_{c}>");
fSubEventDPhiv2->GetXaxis()->SetBinLabel(4, "#sqrt{#frac{<#Psi_{a} - #Psi_{b}><#Psi_{a} - #Psi_{c}>}{<#Psi_{b} - #Psi_{c}>}}");
fSubEventDPhiv2->GetXaxis()->SetBinLabel(5, "#sqrt{#frac{<#Psi_{a} - #Psi_{c}><#Psi_{b} - #Psi_{c}>}{<#Psi_{a} - #Psi_{b}>}}");
fOutputList->Add(fSubEventDPhiv2);
const char* V0[] = {"V0A", "V0C"};
for(Int_t ptbin(0); ptbin < fNPtBins; ptbin++)
for(Int_t iV0(0); iV0 < 2; iV0++) {
fV0Data[ptbin][iV0] = new TProfile(Form("%s v2 %4.2f < p_{T} < %4.2f GeV", V0[iV0], fPtBins[ptbin], fPtBins[ptbin+1]), Form("%s v2 %4.2f < p_{T} < %4.2f GeV", V0[iV0], fPtBins[ptbin], fPtBins[ptbin+1]), fMassBins, fMinMass, fMaxMass);
fOutputList->Add(fV0Data[ptbin][iV0]);
}
}
}
//_____________________________________________________________________________
void AliAnalysisTaskPhiFlow::UserCreateOutputObjects()
{
// Create user defined output objects
if(fDebug > 0) cout << " *** UserCreateOutputObjects() *** " << endl;
fNullCuts = new AliFlowTrackCuts("null_cuts");
fBayesianResponse = new AliFlowBayesianPID();
// combined pid
fPIDCombined = new AliPIDCombined;
fPIDCombined->SetDefaultTPCPriors();
fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF);
// flag to mc
if(fSkipEventSelection || fIsMC) fBayesianResponse->SetMC(kTRUE);
Double_t t(0);
for(Int_t i = 0; i < 7; i++) t+=TMath::Abs(fPIDConfig[i]);
if(t < 0.1) AliFatal("No valid PID procedure recognized -- terminating analysis !!!");
if(fNPtBins > 18) AliFatal("Invalid number of pt bins initialied ( > 18 ) -- terminating analysis !!!");
AliFlowCommonConstants* cc = AliFlowCommonConstants::GetMaster();
cc->SetNbinsQ(500); cc->SetNbinsPhi(180); cc->SetNbinsMult(10000);
cc->SetQMin(0.0); cc->SetPhiMin(0.0); cc->SetMultMin(0);
cc->SetQMax(3.0); cc->SetPhiMax(TMath::TwoPi()); cc->SetMultMax(10000);
cc->SetNbinsMass(fMassBins); cc->SetNbinsEta(200); (fMassBins == 1) ? cc->SetNbinsPt(15) : cc->SetNbinsPt(100); // high pt
cc->SetMassMin(fMinMass); cc->SetEtaMin(-5.0); cc->SetPtMin(0);
cc->SetMassMax(fMaxMass); cc->SetEtaMax(+5.0); (fMassBins == 1) ? cc->SetPtMax(15) : cc->SetPtMax(10); // high pt
fBayesianResponse->SetNewTrackParam();
AliAnalysisManager *man = AliAnalysisManager::GetAnalysisManager();
if (man) {
AliInputEventHandler* inputHandler = (AliInputEventHandler*)(man->GetInputEventHandler());
if (inputHandler) fPIDResponse = inputHandler->GetPIDResponse();
}
// Create all output objects and store them to a list
fOutputList = new TList();
fOutputList->SetOwner(kTRUE);
// Create and post the Phi identification output objects
AddPhiIdentificationOutputObjects();
PostData(1, fOutputList);
// create candidate array
fCandidates = new TObjArray(1000);
fCandidates->SetOwner(kTRUE);
// create and post flowevent
fFlowEvent = new AliFlowEvent(10000);
PostData(2, fFlowEvent);
if(fEventMixing) fPoolManager = InitializeEventMixing();
fLowCut = new TF1("fLowCut", "[0]+[1]*x - 5.*([2]+[3]*x+[4]*x*x+[5]*x*x*x)", 0, 100);
fHighCut = new TF1("fHighCut", "[0]+[1]*x + 5.5*([2]+[3]*x+[4]*x*x+[5]*x*x*x)", 0, 100);
fMultTOFLowCut = new TF1("fMultTOFLowCut", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 4.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x+[9]*x*x*x*x*x)", 0, 10000);
fMultTOFHighCut = new TF1("fMultTOFHighCut", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 4.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x+[9]*x*x*x*x*x)", 0, 10000);
fLowCut->SetParameters(0.0157497, 0.973488, 0.673612, 0.0290718, -0.000546728, 5.82749e-06);
fHighCut->SetParameters(0.0157497, 0.973488, 0.673612, 0.0290718, -0.000546728, 5.82749e-06);
fMultTOFLowCut->SetParameters(-1.0178, 0.333132, 9.10282e-05, -1.61861e-08, 1.47848, 0.0385923, -5.06153e-05, 4.37641e-08, -1.69082e-11, 2.35085e-15);
fMultTOFHighCut->SetParameters(-1.0178, 0.333132, 9.10282e-05, -1.61861e-08, 1.47848, 0.0385923, -5.06153e-05, 4.37641e-08, -1.69082e-11, 2.35085e-15);
if(fHistCentralityWeights) {
Double_t integral(fHistCentralityWeights->Integral()/fHistCentralityWeights->GetNbinsX());
TH1* temp((TH1*)fHistCentralityWeights->Clone("EP_weights_cen"));
for(Int_t i(0); i < temp->GetNbinsX(); i++) {
temp->SetBinError(1+i, 0.);// unertainty is irrelevant
temp->SetBinContent(1+i, integral/fHistCentralityWeights->GetBinContent(1+i));
}
delete fHistCentralityWeights;
fHistCentralityWeights = temp;
fOutputList->Add(temp);
}
fVertexZ = new TH1F("fVertexZ", "vertex Z position:vertex Z position", 60, -15., 15.);
fOutputList->Add(fVertexZ);
}
//_____________________________________________________________________________
AliEventPoolManager* AliAnalysisTaskPhiFlow::InitializeEventMixing()
{
// initialize event mixing
if(fDebug > 0) cout << " *** InitializeEventMixing() *** " << endl;
Int_t _c(0), _v(0);
for(Int_t i(0); i < 19; i++) {
if (fCentralityMixingBins[i+1] < fCentralityMixingBins[i]) { _c = i; break; }
else _c = 19;
}
for(Int_t i(0); i < 19; i++) {
if (fVertexMixingBins[i+1] < fVertexMixingBins[i]) { _v = i; break; }
else _v = 19;
}
if(fDebug > 0 ) cout << Form(" --> found %d centrality bins for mixing, %d vertex bins for mixing", _c, _v) << endl;
Double_t centralityBins[_c];
Double_t vertexBins[_v];
for(Int_t i(0); i < _c + 1; i++) centralityBins[i] = fCentralityMixingBins[i];
for(Int_t i(0); i < _v + 1; i++) vertexBins[i] = fVertexMixingBins[i];
return new AliEventPoolManager(fMixingParameters[0], fMixingParameters[1], _c, (Double_t*)centralityBins, _v, (Double_t*)vertexBins);
}
//_____________________________________________________________________________
template <typename T> Double_t AliAnalysisTaskPhiFlow::InvariantMass(const T* track1, const T* track2) const
{
// Return the invariant mass of two tracks, assuming both tracks are kaons
// if(fDebug > 1) cout << " *** InvariantMass() *** " << endl;
if ((!track2) || (!track1)) return 0.;
Double_t masss = TMath::Power(4.93676999999999977e-01, 2);
Double_t pxs = TMath::Power((track1->Px() + track2->Px()), 2);
Double_t pys = TMath::Power((track1->Py() + track2->Py()), 2);
Double_t pzs = TMath::Power((track1->Pz() + track2->Pz()), 2);
Double_t e1 = TMath::Sqrt(track1->P() * track1->P() + masss);
Double_t e2 = TMath::Sqrt(track2->P() * track2->P() + masss);
Double_t es = TMath::Power((e1 + e2), 2);
if ((es - (pxs + pys + pzs)) < 0) return 0.;
return TMath::Sqrt((es - (pxs + pys + pzs)));
}
//_____________________________________________________________________________
/*
template <typename T> Double_t AliAnalysisTaskPhiFlow::DeltaDipAngle(const T* track1, const T* track2) const
{
// Calculate the delta dip angle between two particles
if(fDebug > 1) cout << " *** DeltaDipAngle() *** " << endl;
if (track1->P()*track2->P() == 0) return 999;
return TMath::ACos(((track1->Pt() * track2->Pt()) + (track1->Pz() * track2->Pz())) / (track1->P() * track2->P()));
}
//_____________________________________________________________________________
template <typename T> Bool_t AliAnalysisTaskPhiFlow::CheckDeltaDipAngle(const T* track1, const T* track2) const
{
// Check if pair passes delta dip angle cut within 0 < p_t < fDeltaDipPt
if(fDebug > 1) cout << " *** CheckDeltaDipAngle() *** " << endl;
if ((TMath::Abs(DeltaDipAngle(track1, track2)) < fDeltaDipAngle) && (PhiPt(track1, track2) < fDeltaDipPt)) return kFALSE;
return kTRUE;
}
*/
//_____________________________________________________________________________
template <typename T> Bool_t AliAnalysisTaskPhiFlow::CheckCandidateEtaPtCut(const T* track1, const T* track2) const
{
// Check if pair passes eta and pt cut
// if(fDebug > 1) cout << " *** CheckCandidateEtaPtCut() *** " << endl;
if (fCandidateMinPt > PhiPt(track1, track2) || fCandidateMaxPt < PhiPt(track1, track2)) return kFALSE;
TVector3 a(track1->Px(), track1->Py(), track1->Pz());
TVector3 b(track2->Px(), track2->Py(), track2->Pz());
TVector3 c = a + b;
if (fCandidateMinEta > c.Eta() || fCandidateMaxEta < c.Eta()) return kFALSE;
return kTRUE;
}
//_____________________________________________________________________________
template <typename T> Bool_t AliAnalysisTaskPhiFlow::EventCut(T* event)
{
// Impose event cuts
// if(fDebug > 0) cout << " *** EventCut() *** " << endl;
if (!event) return kFALSE;
// if (fSkipEventSelection) return kTRUE;
if (!CheckCentrality(event)) return kFALSE;
if(fQA) PlotMultiplcities(event);
return kTRUE;
}
//_____________________________________________________________________________
template <typename T> void AliAnalysisTaskPhiFlow::PlotMultiplcities(const T* event) const
{
// QA multiplicity plots
if(fDebug > 1) cout << " *** PlotMultiplcities() *** " << endl;
fVZEROA->Fill(event->GetVZEROData()->GetMTotV0A(), fCentralityWeight);
fVZEROC->Fill(event->GetVZEROData()->GetMTotV0C(), fCentralityWeight);
fTPCM->Fill(event->GetNumberOfTracks(), fCentralityWeight);
}
//_____________________________________________________________________________
template <typename T> Bool_t AliAnalysisTaskPhiFlow::CheckVertex(const T* event)
{
// Check if event vertex is within given range
// if(fDebug > 0) cout << " *** CheckVertex() *** " << endl;
if (!event->GetPrimaryVertex()) return 0x0;
fVertex = event->GetPrimaryVertex()->GetZ();
if (TMath::Abs(fVertex) > fVertexRange) return 0x0;
return kTRUE;
}
//_____________________________________________________________________________
template <typename T> Bool_t AliAnalysisTaskPhiFlow::CheckCentrality(T* event)
{
// Check if event is within the set centrality range. Falls back to V0 centrality determination if no method is set
// if(fDebug > 0) cout << " *** CheckCentrality() *** " << endl;
if (!fkCentralityMethodA) AliFatal("No centrality method set! FATAL ERROR!");
// check if the AliMultSelection object is present. If so, we should invoke the
// new centrality framework
if(fPileUp) {
AliMultSelection *multSelection = 0x0;
multSelection = static_cast<AliMultSelection*>(event->FindListObject("MultSelection"));
if(multSelection) {
fCentrality = multSelection->GetMultiplicityPercentile(fCentralityEstimator.Data());
if(fCentrality > fCentralityMin && fCentrality < fCentralityMax && multSelection->GetMultiplicityPercentile("CL1") < 90) {
if(fHistCentralityWeights) {
fCentralityWeight = fHistCentralityWeights->GetBinContent(fHistCentralityWeights->FindBin(fCentrality));
}
fCentralityPass->Fill(fCentrality, fCentralityWeight);
return kTRUE;
} else {
fCentralityNoPass->Fill(fCentrality, fCentralityWeight);
return kFALSE;
}
}
}
else fCentrality = event->GetCentrality()->GetCentralityPercentile(fkCentralityMethodA);
Double_t cenB(-999);
// if a second centrality estimator is requited, set it
(fkCentralityMethodB) ? cenB = event->GetCentrality()->GetCentralityPercentile(fkCentralityMethodB) : cenB = fCentrality;
if (TMath::Abs(fCentrality-cenB) > 5 || cenB >= 80 || cenB < 0 || fCentrality <= fCentralityMin || fCentrality > fCentralityMax) {
if(fQA) fCentralityNoPass->Fill(fCentrality) ;
return kFALSE;
}
const Int_t nGoodTracks = event->GetNumberOfTracks();
if(fCentralityCut2010) { // cut on outliers
Float_t multTPC(0.); // tpc mult estimate
Float_t multGlob(0.); // global multiplicity
for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) { // fill tpc mult
AliAODTrack* trackAOD = dynamic_cast<AliAODTrack*>(event->GetTrack(iTracks));
if(!trackAOD) AliFatal("Not a standard AOD");
if (!trackAOD) continue;
if (!(trackAOD->TestFilterBit(1))) continue;
if ((trackAOD->Pt() < .2) || (trackAOD->Pt() > 5.0) || (TMath::Abs(trackAOD->Eta()) > .8) || (trackAOD->GetTPCNcls() < 70) || (trackAOD->GetDetPid()->GetTPCsignal() < 10.0) || (trackAOD->Chi2perNDF() < 0.2)) continue;
multTPC++;
}
for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) { // fill global mult
AliAODTrack* trackAOD = dynamic_cast<AliAODTrack*>(event->GetTrack(iTracks));
if(!trackAOD) AliFatal("Not a standard AOD");
if (!trackAOD) continue;
if (!(trackAOD->TestFilterBit(16))) continue;
if ((trackAOD->Pt() < .2) || (trackAOD->Pt() > 5.0) || (TMath::Abs(trackAOD->Eta()) > .8) || (trackAOD->GetTPCNcls() < 70) || (trackAOD->GetDetPid()->GetTPCsignal() < 10.0) || (trackAOD->Chi2perNDF() < 0.1)) continue;
Double_t b[2] = {-99., -99.};
Double_t bCov[3] = {-99., -99., -99.};
AliAODTrack copy(*trackAOD);
if (!(copy.PropagateToDCA(event->GetPrimaryVertex(), event->GetMagneticField(), 100., b, bCov))) continue;
if ((TMath::Abs(b[0]) > 0.3) || (TMath::Abs(b[1]) > 0.3)) continue;
multGlob++;
} //track loop
// printf(" mult TPC %.2f, mult Glob %.2f \n", multTPC, multGlob);
if(! (multTPC > (-40.3+1.22*multGlob) && multTPC < (32.1+1.59*multGlob))) return kFALSE;
if(fQA) {
fMultCorAfterCuts->Fill(multGlob, multTPC);
fMultvsCentr->Fill(fCentrality, multTPC);
}
}
if(fCentralityCut2011) { // cut on outliers
Float_t multTPC(0.); // tpc mult estimate
Float_t multGlob(0.); // global multiplicity
for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) { // fill tpc mult
AliAODTrack* trackAOD = dynamic_cast<AliAODTrack*>(event->GetTrack(iTracks));
if(!trackAOD) AliFatal("Not a standard AOD");
if (!trackAOD) continue;
if (!(trackAOD->TestFilterBit(1))) continue;
if ((trackAOD->Pt() < .2) || (trackAOD->Pt() > 5.0) || (TMath::Abs(trackAOD->Eta()) > .8) || (trackAOD->GetTPCNcls() < 70) || (trackAOD->GetDetPid()->GetTPCsignal() < 10.0) || (trackAOD->Chi2perNDF() < 0.2)) continue;
multTPC++;
}
for(Int_t iTracks = 0; iTracks < nGoodTracks; iTracks++) { // fill global mult
AliAODTrack* trackAOD = dynamic_cast<AliAODTrack*>(event->GetTrack(iTracks));
if(!trackAOD) AliFatal("Not a standard AOD");
if (!trackAOD) continue;
if (!(trackAOD->TestFilterBit(16))) continue;
if ((trackAOD->Pt() < .2) || (trackAOD->Pt() > 5.0) || (TMath::Abs(trackAOD->Eta()) > .8) || (trackAOD->GetTPCNcls() < 70) || (trackAOD->GetDetPid()->GetTPCsignal() < 10.0) || (trackAOD->Chi2perNDF() < 0.1)) continue;
Double_t b[2] = {-99., -99.};
Double_t bCov[3] = {-99., -99., -99.};
AliAODTrack copy(*trackAOD);
if (!(copy.PropagateToDCA(event->GetPrimaryVertex(), event->GetMagneticField(), 100., b, bCov))) continue;
if ((TMath::Abs(b[0]) > 0.3) || (TMath::Abs(b[1]) > 0.3)) continue;
multGlob++;
} //track loop
//printf(" mult TPC %.2f, mult Glob %.2f \n", multTPC, multGlob);
if(! (multTPC > (-36.73 + 1.48*multGlob) && multTPC < (62.87 + 1.78*multGlob))) return kFALSE;
if(fQA) {
fMultCorAfterCuts->Fill(multGlob, multTPC);
fMultvsCentr->Fill(fCentrality, multTPC);
}
}
fCentralityPass->Fill(fCentrality);
return kTRUE;
}
//_____________________________________________________________________________
void AliAnalysisTaskPhiFlow::InitializeBayesianPID(AliAODEvent* event)
{
// Initialize the Bayesian PID object for AOD
if(fDebug > 0) cout << " *** InitializeBayesianPID() *** " << endl;
fBayesianResponse->SetDetResponse(event, fCentrality);
}
//_____________________________________________________________________________
template <typename T> Bool_t AliAnalysisTaskPhiFlow::PassesTPCbayesianCut(T* track) const
{
// Check if the particle passes the TPC TOF bayesian cut.
if(fDebug > 1) cout << " *** PassesTPCbayesianCut() *** " << endl;
fBayesianResponse->ComputeProb(track);
if (!fBayesianResponse->GetCurrentMask(0)) return kFALSE; // return false if TPC has no response
Float_t *probabilities = fBayesianResponse->GetProb();
if (probabilities[3] > fPIDConfig[6]) {
if(fQA) {fPhi->Fill(track->Phi()); fPt->Fill(track->Pt()); fEta->Fill(track->Eta());}
return kTRUE;
}
return kFALSE;
}
//_____________________________________________________________________________
Bool_t AliAnalysisTaskPhiFlow::PassesDCACut(AliAODTrack* track) const
{
// check if track passes dca cut according to dca routine
// setup the routine as follows:
// fDCAConfig[0] < -1 no pt dependence
// fDCAConfig[0] = 0 do nothing
// fDCAConfig[0] > 1 pt dependent dca cut
// if(fDebug > 1) cout << " *** PassesDCACut() *** " << endl;
AliAODTrack copy(*track);
if( (fDCAConfig[0] < 0.1) && (fDCAConfig[0] > -0.1) ) {
if(fQA) {
Double_t b[2] = { -99., -99.};
Double_t bCov[3] = { -99., -99., -99.};
if(copy.PropagateToDCA(fAOD->GetPrimaryVertex(), fAOD->GetMagneticField(), 100., b, bCov)) {
fDCAXYQA->Fill(b[0]);
fDCAZQA->Fill(b[1]);
fDCAPrim->Fill(track->Pt(), b[0]);
}
}
return kTRUE;
}
Double_t b[2] = { -99., -99.};
Double_t bCov[3] = { -99., -99., -99.};
if(!copy.PropagateToDCA(fAOD->GetPrimaryVertex(), fAOD->GetMagneticField(), 100., b, bCov)) return kFALSE;
if((!fIsMC)&&fQA) fDCAMaterial->Fill(track->Pt(), b[0]);
if( (fDCAConfig[0] < -.9) && ( (TMath::Abs(b[0]) > fDCAConfig[1]) || (TMath::Abs(b[1]) > fDCAConfig[2])) ) return kFALSE;
if(fDCAConfig[0] > .9) {
if(fDCAConfig[4] < TMath::Abs(b[1])) return kFALSE;
Double_t denom = TMath::Power(track->Pt(), fDCAConfig[3]);
if( denom < 0.0000001 ) return kFALSE; // avoid division by zero
if( (fDCAConfig[1] + fDCAConfig[2] / denom) < TMath::Abs(b[0]) ) return kFALSE;
}
if(fQA) {
fDCAXYQA->Fill(b[0]);
fDCAZQA->Fill(b[1]);
fDCAPrim->Fill(track->Pt(), b[0]);
}
return kTRUE;
}
//_____________________________________________________________________________
Bool_t AliAnalysisTaskPhiFlow::IsKaon(AliAODTrack* track) const
{
// Kaon identification routine, based on multiple detectors and approaches
// if(fDebug > 1) cout << " *** IsKaon() *** " << endl;
/* if(fUsePidResponse) {
Double_t prob[10] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
fPIDCombined->ComputeProbabilities(track, fPIDResponse, prob);
if(prob[3] > fPIDConfig[6]) return kTRUE;
}
if(!PassesDCACut(track)) return kFALSE;
if(fQA) {fNOPID->Fill(track->P(), track->GetTPCsignal());fNOPIDTOF->Fill(track->P(), track->GetTOFsignal());}
if(track->Pt() < fPIDConfig[1]) {
if(fDebug>1) cout << " ITS received track with p_t " << track->Pt() << endl;
// if tpc control is disabled, pure its pid
if(fPIDConfig[2] < 0.) {
if (TMath::Abs(fPIDResponse->NumberOfSigmasITS(track, AliPID::kKaon)) < fPIDConfig[0]) return kTRUE;
return kFALSE;
}
// else, switch to ITS pid with TPC rejection of protons and pions
if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC(track, AliPID::kProton)) < fPIDConfig[3]) return kFALSE;
else if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC(track, AliPID::kPion)) < fPIDConfig[3]) return kFALSE;
else if (TMath::Abs(fPIDResponse->NumberOfSigmasITS(track, AliPID::kKaon)) < fPIDConfig[0]) {
if(fQA) {fPIDk->Fill(track->P(), track->GetTPCsignal()); fPIDTOF->Fill(track->P(), track->GetTOFsignal());}
return kTRUE;
}
return kFALSE;
}
if((track->Pt() > fPIDConfig[1]) && (track->Pt() < fPIDConfig[4])) {
if(fDebug>1) cout << " TPC received track with p_t " << track->Pt() << endl;
// if its control is disabled, pure tpc pid
if(fPIDConfig[5] < 0.) {
if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC(track, AliPID::kKaon)) < fPIDConfig[3]) return kTRUE;
return kFALSE;
}
// else, switch to TPC pid with ITS rejection of protons and pions
if (TMath::Abs(fPIDResponse->NumberOfSigmasITS(track, AliPID::kProton)) < fPIDConfig[0]) return kFALSE;
else if (TMath::Abs(fPIDResponse->NumberOfSigmasITS(track, AliPID::kPion)) < fPIDConfig[0]) return kFALSE;
else if (TMath::Abs(fPIDResponse->NumberOfSigmasTPC(track, AliPID::kKaon)) < fPIDConfig[3]) {
if(fQA) {fPIDk->Fill(track->P(), track->GetTPCsignal()); fPIDTOF->Fill(track->P(), track->GetTOFsignal());}
return kTRUE;
}
return kFALSE;
}
if(fDebug>1) cout << " Bayesian method received track with p_t " << track->Pt() << endl;
// switch to bayesian PID
if (PassesTPCbayesianCut(track)) {
if(fQA) {fPIDk->Fill(track->P(), track->GetTPCsignal());fPIDTOF->Fill(track->P(), track->GetTOFsignal());}
return kTRUE;
}*/
if(fQA) {
Float_t length = track->GetIntegratedLength();
Float_t time = track->GetTOFsignal();
Double_t beta = -.05;
if((length > 0) && (time > 0)) beta = length / 2.99792458e-2 / time;
fNOPID->Fill(track->P(), track->GetTPCsignal(), fCentralityWeight);
fNOPIDTOF->Fill(track->P(), beta, fCentralityWeight);
}
//kaon stuff
Double_t nSigKTPC = fPIDResponse->NumberOfSigmasTPC(track, AliPID::kKaon);
Double_t nSigKTOF = fPIDResponse->NumberOfSigmasTOF(track, AliPID::kKaon);
Double_t nSigmaK = 999;
if(track->Pt() > .4) {
nSigmaK = TMath::Sqrt(nSigKTPC*nSigKTPC+nSigKTOF*nSigKTOF);
} else {
if(track->GetTPCsignal() > 110) nSigmaK = TMath::Abs(nSigKTPC);
}
// pion
Double_t nSigPiTPC = fPIDResponse->NumberOfSigmasTPC(track, AliPID::kPion);
Double_t nSigPiTOF = fPIDResponse->NumberOfSigmasTOF(track, AliPID::kPion);
Double_t nSigmaPi = 999;
if(track->Pt() > .4) {
nSigmaPi = TMath::Sqrt(nSigPiTPC*nSigPiTPC+nSigPiTOF*nSigPiTOF);
} else {
if(track->GetTPCsignal() < 60) nSigmaPi = TMath::Abs(nSigPiTPC);
}
//proton
Double_t nSigPTPC = fPIDResponse->NumberOfSigmasTPC(track, AliPID::kProton);
Double_t nSigPTOF = fPIDResponse->NumberOfSigmasTOF(track, AliPID::kProton);
Double_t nSigmaP = 999;
if(track->Pt() > .4) {
nSigmaP = TMath::Sqrt(nSigPTPC*nSigPTPC+nSigPTOF*nSigPTOF);
} else {
if(track->GetTPCsignal() > 110) nSigmaP = TMath::Abs(nSigPTPC);
}
Short_t minSigma = FindMinNSigma(nSigmaPi, nSigmaK, nSigmaP);
if(minSigma == 0) return kFALSE;
if((nSigmaK == nSigmaPi) && ( nSigmaK == nSigmaP)) return kFALSE;
if(minSigma == 2 &&!GetDoubleCountingK(nSigmaK, minSigma)) {
if(fQA) {
Float_t length = track->GetIntegratedLength();
Float_t time = track->GetTOFsignal();
Double_t beta = -.05;
if((length > 0) && (time > 0)) beta = length / 2.99792458e-2 / time;
// additional selection to bruteforce throw away bad betas
if(beta < 0.4) return kFALSE;
fPIDk->Fill(track->P(), track->GetTPCsignal(), fCentralityWeight);
if(track->Pt() > .4) fPIDTOF->Fill(track->P(), beta, fCentralityWeight);
}
return kTRUE;
}
return kFALSE;
}
//_____________________________________________________________________________
template <typename T> Double_t AliAnalysisTaskPhiFlow::PhiPt(const T* track1, const T* track2) const
{
// return p_t of track pair
TVector3 a(track1->Px(), track1->Py(), track1->Pz());
TVector3 b(track2->Px(), track2->Py(), track2->Pz());
TVector3 c = a + b;
return c.Pt();
}
//_____________________________________________________________________________
template <typename T> void AliAnalysisTaskPhiFlow::PtSelector(Int_t tracktype, const T* track1, const T* track2) const
{
// plot m_inv spectra of like- and unlike-sign kaon pairs for each pt bin
Double_t pt = PhiPt(track1, track2);
if (tracktype == 0) {
for(Int_t ptbin(0); ptbin < fNPtBins; ptbin++) {
if ((fPtBins[ptbin] <= pt) && (fPtBins[ptbin+1] > pt )) {
fInvMNP[ptbin]->Fill(InvariantMass(track1, track2), fCentralityWeight);
if(fQA) fPtSpectra[ptbin]->Fill(pt, fCentralityWeight);
}
}
}
if (tracktype == 1) {
for(Int_t ptbin(0); ptbin < fNPtBins; ptbin++) {
if ((fPtBins[ptbin] <= pt) && (fPtBins[ptbin+1] > pt )) {
fInvMPP[ptbin]->Fill(InvariantMass(track1, track2), fCentralityWeight);
}
}
}
if (tracktype == 2) {
for(Int_t ptbin(0); ptbin < fNPtBins; ptbin++) {
if ((fPtBins[ptbin] <= pt) && (fPtBins[ptbin+1] > pt )) {
fInvMNN[ptbin]->Fill(InvariantMass(track1, track2), fCentralityWeight);
}
}
}
}
//_____________________________________________________________________________
template <typename T> Bool_t AliAnalysisTaskPhiFlow::PhiTrack(T* track) const
{
// check if track meets quality cuts
if(!track) return kFALSE;
return fPOICuts->IsSelected(track);
}
//_____________________________________________________________________________
template <typename T> void AliAnalysisTaskPhiFlow::SetNullCuts(T* event)
{
// Set null cuts
// if (fDebug > 0) cout << " *** SetNullCuts() *** " << fCutsRP << endl;
fCutsRP->SetEvent(event, MCEvent());
fNullCuts->SetParamType(AliFlowTrackCuts::kGlobal);
fNullCuts->SetPtRange(+1, -1); // select nothing QUICK
fNullCuts->SetEtaRange(+1, -1); // select nothing VZERO
fNullCuts->SetEvent(event, MCEvent());
}
//_____________________________________________________________________________
void AliAnalysisTaskPhiFlow::PrepareFlowEvent(Int_t iMulti)
{
// Prepare flow events
// if (fDebug > 0 ) cout << " *** PrepareFlowEvent() *** " << endl;
fFlowEvent->ClearFast();
fFlowEvent->Fill(fCutsRP, fNullCuts);
fFlowEvent->SetReferenceMultiplicity(iMulti);
fFlowEvent->DefineDeadZone(0, 0, 0, 0);
}
//_____________________________________________________________________________
void AliAnalysisTaskPhiFlow::UserExec(Option_t *)
{
// UserExec: called for each event. Commented where necessary
// if(fDebug > 0 ) cout << " *** UserExec() *** " << endl;
TObjArray* MixingCandidates = 0x0; // init null pointer for event mixing
if(fEventMixing) {
MixingCandidates = new TObjArray();
MixingCandidates->SetOwner(kTRUE); // mixing candidates has ownership of objects in array
}
if (!fPIDResponse) {
if(fDebug > 0 ) cout << " Could not get PID response " << endl;
return;
}
fAOD = dynamic_cast<AliAODEvent*>(InputEvent()); // check for aod data type
if (fAOD) {
if (!EventCut(fAOD)) return; // check for event cuts
// add extra pileup cuts for high intensity runs
// courtesy of alex dobrin
if (fPileUp){
// 12 11 centrality cut for pileup
//
//Centrality
Float_t v0Centr = -100.;
Float_t cl0Centr = -100.;
AliMultSelection* MultSelection = 0x0;
MultSelection = (AliMultSelection*) fAOD->FindListObject("MultSelection");
if( !MultSelection) {
AliWarning("AliMultSelection object not found!");
return;
} else {
v0Centr = MultSelection->GetMultiplicityPercentile("V0M");
cl0Centr = MultSelection->GetMultiplicityPercentile("CL0");
}
if (v0Centr >= 90. || v0Centr < 0)
return;
const Int_t nTracks = fAOD->GetNumberOfTracks();
Int_t multEsd = ((AliAODHeader*)fAOD->GetHeader())->GetNumberOfESDTracks();
Int_t multTrk = 0;
Int_t multTrkBefC = 0;
Int_t multTrkTOFBefC = 0;
Int_t multTPC = 0;
for (Int_t it = 0; it < nTracks; it++) {
AliAODTrack* aodTrk = (AliAODTrack*)fAOD->GetTrack(it);
if (!aodTrk){
delete aodTrk;
continue;
}
if (aodTrk->TestFilterBit(32)){
multTrkBefC++;
if ( TMath::Abs(aodTrk->GetTOFsignalDz()) <= 10 && aodTrk->GetTOFsignal() >= 12000 && aodTrk->GetTOFsignal() <= 25000)
multTrkTOFBefC++;
if ((TMath::Abs(aodTrk->Eta()) < TMath::Abs(fCandidateMinEta)) && (aodTrk->GetTPCNcls() >= 70) && (aodTrk->Pt() >= .2) && (aodTrk->Pt() < 20))
multTrk++;
}
if (aodTrk->TestFilterBit(32))
multTPC++;
}
Float_t multTPCn = multTPC;
Float_t multEsdn = multEsd;
Float_t multESDTPCDif = multEsdn - multTPCn*3.38;
if (cl0Centr < fLowCut->Eval(v0Centr))
return;
if (cl0Centr > fHighCut->Eval(v0Centr))
return;
if (multESDTPCDif > fMultESDTPCdif)
return;
if (multTrkTOFBefC < fMultTOFLowCut->Eval(Float_t(multTrkBefC)))
return;
if (multTrkTOFBefC > fMultTOFHighCut->Eval(Float_t(multTrkBefC)))
return;
if (plpMV(fAOD))
return;
Short_t isPileup = fAOD->IsPileupFromSPD(3);
if (isPileup != 0)
return;
if (((AliAODHeader*)fAOD->GetHeader())->GetRefMultiplicityComb08() < 0)
return;
/*
Int_t bc2 = ((AliAODHeader*)fAOD->GetHeader())->GetIRInt2ClosestInteractionMap();
if (bc2 != 0)
return;
Int_t bc1 = ((AliAODHeader*)fAOD->GetHeader())->GetIRInt1ClosestInteractionMap();
if (bc1 != 0)
return;
*/
// add vertexer selection
AliAODVertex* vtTrc = fAOD->GetPrimaryVertex();
AliAODVertex* vtSPD = fAOD->GetPrimaryVertexSPD();
if (vtTrc->GetNContributors()<2 || vtSPD->GetNContributors()<1) return; // one of vertices is missing
double covTrc[6],covSPD[6];
vtTrc->GetCovarianceMatrix(covTrc);
vtSPD->GetCovarianceMatrix(covSPD);
double dz = vtTrc->GetZ()-vtSPD->GetZ();
double errTot = TMath::Sqrt(covTrc[5]+covSPD[5]);
double errTrc = TMath::Sqrt(covTrc[5]);
double nsigTot = TMath::Abs(dz)/errTot, nsigTrc = TMath::Abs(dz)/errTrc;
if (TMath::Abs(dz)>0.2 || TMath::Abs(nsigTot)>10 || TMath::Abs(nsigTrc)>20) return; // bad vertexing
if(TMath::Abs(fAOD->GetPrimaryVertex()->GetZ()) > fVertexRange) return;
fVertex = fAOD->GetPrimaryVertex()->GetZ();
fVertexZ->Fill(fVertex);
fMultvsCentr->Fill(multTPCn, v0Centr);
fMultCorAfterCuts->Fill(v0Centr,cl0Centr);
//new function for 2015 to remove incomplete events
if (fAOD->IsIncompleteDAQ()) return;
} else {
if(TMath::Abs(fAOD->GetPrimaryVertex()->GetZ()) > fVertexRange) return;
fVertex = fAOD->GetPrimaryVertex()->GetZ();
fVertexZ->Fill(fVertex);
}
// InitializeBayesianPID(fAOD); // init event objects
double qx(0); // for tpc ep
double qy(0);
SetNullCuts(fAOD);
PrepareFlowEvent(fAOD->GetNumberOfTracks());
fCandidates->SetLast(-1);
if(fIsMC) IsMC(); // launch mc stuff
if(fQA) fEventStats->Fill(0);
Int_t unTracks = fAOD->GetNumberOfTracks();
AliAODTrack* un[unTracks];
AliAODTrack* up[unTracks];
Int_t unp(0);
Int_t unn(0);
// if(fDebug > 1) cout << " started with " << unTracks << " of tracks "<< endl;
for (Int_t iTracks = 0; iTracks < unTracks; iTracks++) { // select analysis candidates
AliAODTrack* track = dynamic_cast<AliAODTrack*>(fAOD->GetTrack(iTracks));
if(!track) AliFatal("Not a standard AOD");
if (!PhiTrack(track)) continue;
qx+=TMath::Cos(fHarmonic*track->Phi());
qy+=TMath::Sin(fHarmonic*track->Phi());
if (fQA) {
if(track->Charge() > 0) {fEventStats->Fill(1, fCentralityWeight); fPtP->Fill(track->Pt(), fCentralityWeight);}
if(track->Charge() < 0) {fEventStats->Fill(2, fCentralityWeight); fPtN->Fill(track->Pt(), fCentralityWeight);}
}
if (IsKaon(track)) {
if(fEventMixing) MixingCandidates->Add(new AliPhiMesonHelperTrack(track->Eta(), track->Phi(), track->P(),
track->Px(), track->Py(), track->Pz(),
track->Pt(), track->Charge()));
if (track->Charge() > 0) {
up[unp] = track;
unp++;
if(fQA) {fEventStats->Fill(3, fCentralityWeight);fPtKP->Fill(track->Pt(), fCentralityWeight);}
}
else if (track->Charge() < 0) {
un[unn] = track;
unn++;
if(fQA) {fEventStats->Fill(4, fCentralityWeight); fPtKN->Fill(track->Pt(), fCentralityWeight);}
}
}
}
for (Int_t pTracks = 0; pTracks < unp ; pTracks++) { // perform analysis
for (Int_t nTracks = 0; nTracks < unn ; nTracks++) {
// if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(up[pTracks], un[nTracks]))) continue;
if (fCandidateEtaPtCut && (!CheckCandidateEtaPtCut(up[pTracks], un[nTracks]))) continue;
PtSelector(0, up[pTracks], un[nTracks]);
Double_t pt = PhiPt(up[pTracks], un[nTracks]);
Double_t mass = InvariantMass(up[pTracks], un[nTracks]);
TVector3 a(up[pTracks]->Px(), up[pTracks]->Py(), up[pTracks]->Pz());
TVector3 b(un[nTracks]->Px(), un[nTracks]->Py(), up[pTracks]->Pz());
TVector3 c = a + b;
Double_t phi = c.Phi();
Double_t eta = c.Eta();
Double_t p = TMath::Sqrt(c.Px()*c.Px()+c.Py()*c.Py()+c.Pz()*c.Pz());
Int_t nIDs[2];
nIDs[0] = up[pTracks]->GetID();
nIDs[1] = un[nTracks]->GetID();
MakeTrack(mass, pt, phi, eta, 2, nIDs, p, c.Pz());
}
}
// if (fDebug > 0) printf("I received %d candidates\n", fCandidates->GetEntriesFast()); // insert candidates into flow events
for (int iCand = 0; iCand != fCandidates->GetEntriesFast(); ++iCand) {
AliFlowCandidateTrack *cand = dynamic_cast<AliFlowCandidateTrack*>(fCandidates->At(iCand));
if (!cand) continue;
// if (fDebug > 1) printf(" --> Checking at candidate %d with %d daughters: mass %f\n", iCand, cand->GetNDaughters(), cand->Mass());
for (int iDau = 0; iDau != cand->GetNDaughters(); ++iDau) {
if (fDebug>1) printf(" *** Daughter %d with fID %d ***", iDau, cand->GetIDDaughter(iDau));
for (int iRPs = 0; iRPs != fFlowEvent->NumberOfTracks(); ++iRPs) {
AliFlowTrack *iRP = dynamic_cast<AliFlowTrack*>(fFlowEvent->GetTrack(iRPs));
if (!iRP) continue;
if (!iRP->InRPSelection()) continue;
if (cand->GetIDDaughter(iDau) == iRP->GetID()) {
// if (fDebug > 1) printf(" was in RP set");
iRP->SetForRPSelection(kFALSE);
fFlowEvent->SetNumberOfRPs(fFlowEvent->GetNumberOfRPs() - 1);
}
}
// if (fDebug > 1) printf("\n");
}
cand->SetForPOISelection(kTRUE);
fFlowEvent->InsertTrack(((AliFlowTrack*) cand));
}
// if (fDebug > 0) printf("TPCevent %d\n", fFlowEvent->NumberOfTracks());
if(!fEventMixing) { // combinatorial background
for (Int_t pTracks = 0; pTracks < unp ; pTracks++) {
for (Int_t nTracks = pTracks + 1; nTracks < unp ; nTracks++) {
// if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(up[pTracks], up[nTracks]))) continue;
if (fCandidateEtaPtCut && (!CheckCandidateEtaPtCut(up[pTracks], up[nTracks]))) continue;
PtSelector(1, up[pTracks], up[nTracks]);
}
}
for (Int_t nTracks = 0; nTracks < unn ; nTracks++) {
for (Int_t pTracks = nTracks + 1; pTracks < unn ; pTracks++) {
// if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(un[nTracks], un[pTracks]))) continue;
if (fCandidateEtaPtCut && (!CheckCandidateEtaPtCut(un[nTracks], un[pTracks]))) continue;
PtSelector(2, un[nTracks], un[pTracks]);
}
}
}
if(fEventMixing) ReconstructionWithEventMixing(MixingCandidates);
// ugly, ugly hack but i want to pass the centrality weight to the sp task
fFlowEvent->SetPsi5(fCentralityWeight);
// and second guly hack, save the tpc ep
fFlowEvent->SetPsi2(qx);
fFlowEvent->SetPsi3(qy);
PostData(1, fOutputList);
PostData(2, fFlowEvent);
}
}
//_____________________________________________________________________________
void AliAnalysisTaskPhiFlow::Exec(Option_t* c)
{
// skip the event selection for SE task (e.g. for MC productions)
if(fSkipEventSelection) AliAnalysisTaskPhiFlow::UserExec(c);
// exec of task se will do event selection and call UserExec
else AliAnalysisTaskSE::Exec(c);
}
//_____________________________________________________________________________
void AliAnalysisTaskPhiFlow::ReconstructionWithEventMixing(TObjArray* MixingCandidates) const
{
// perform phi reconstruction with event mixing
// if(fDebug > 0) cout << " *** ReconstructionWithEventMixing() *** " << endl;
AliEventPool* pool = fPoolManager->GetEventPool(fCentrality, fVertex);
if(!pool) AliFatal(Form("No pool found for centrality = %f, zVtx = %f", fCentrality, fVertex));
if(pool->IsReady() || pool->NTracksInPool() > fMixingParameters[1] / 10 || pool->GetCurrentNEvents() >= fMixingParameters[2]) {
Int_t nEvents = pool->GetCurrentNEvents();
// if(fDebug > 0) cout << " --> " << nEvents << " events in mixing buffer ... " << endl;
for (Int_t iEvent(0); iEvent < nEvents; iEvent++) {
TObjArray* mixed_candidates = pool->GetEvent(iEvent);
if(!mixed_candidates) continue; // this should NEVER happen
Int_t bufferTracks = mixed_candidates->GetEntriesFast(); // buffered candidates
Int_t candidates = MixingCandidates->GetEntriesFast(); // mixing candidates
// if(fDebug > 0) cout << Form(" - mixing %d tracks with %d buffered tracks from event %d ... ", candidates, bufferTracks, iEvent) << endl;
AliPhiMesonHelperTrack* buffer_un[bufferTracks]; // set values for buffered candidates
AliPhiMesonHelperTrack* buffer_up[bufferTracks];
Int_t buffer_unp(0);
Int_t buffer_unn(0);
AliPhiMesonHelperTrack* mix_un[candidates];// set values for mixing candidates
AliPhiMesonHelperTrack* mix_up[candidates];
Int_t mix_unp(0);
Int_t mix_unn(0);
for (Int_t iTracks = 0; iTracks < candidates; iTracks++) { // distinguish between k+ and k- for mixing candidates
AliPhiMesonHelperTrack* track = (AliPhiMesonHelperTrack*)MixingCandidates->At(iTracks);
if(!track) continue;
if (track->Charge() > 0) {
mix_up[mix_unp] = track;
mix_unp++;
}
else if (track->Charge() < 0 ) {
mix_un[mix_unn] = track;
mix_unn++;
}
}
for (Int_t iTracks = 0; iTracks < bufferTracks; iTracks++) { // distinguish between k+ and k- for buffered candidates
AliPhiMesonHelperTrack* track = (AliPhiMesonHelperTrack*)mixed_candidates->At(iTracks);
if(!track) continue;
if (track->Charge() > 0) {
buffer_up[buffer_unp] = track;
buffer_unp++;
}
else if (track->Charge() < 0 ) {
buffer_un[buffer_unn] = track;
buffer_unn++;
}
}
for (Int_t pMix = 0; pMix < mix_unp; pMix++) { // mix k+ (current event) k+ (buffer)
// if(fDebug > 1 ) cout << Form("mixing current k+ track %d with", pMix);
if(!fTypeMixing) { // mix with like-sign kaons
for(Int_t pBuf = 0; pBuf < buffer_unp; pBuf++) {
// if(fDebug > 1 ) cout << Form(" buffered k+ track %d", pBuf) << endl;
// if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(mix_up[pMix], buffer_up[pBuf]))) continue;
if (fCandidateMinEta && (!CheckCandidateEtaPtCut(mix_up[pMix], buffer_up[pBuf]))) continue;
PtSelector(1, mix_up[pMix], buffer_up[pBuf]);
}
}
else if(fTypeMixing) { // mix with unlike-sign kaons
for(Int_t nBuf = 0; nBuf < buffer_unn; nBuf++) {
// if(fDebug > 1 ) cout << Form(" buffered k- track %d", nBuf) << endl;
// if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(mix_up[pMix], buffer_un[nBuf]))) continue;
if (fCandidateMinEta && (!CheckCandidateEtaPtCut(mix_up[pMix], buffer_un[nBuf]))) continue;
PtSelector(2, mix_up[pMix], buffer_un[nBuf]);
}
}
}
for (Int_t nMix = 0; nMix < mix_unn; nMix++) { // mix k- (current event) k- (buffer)
// if(fDebug > 1 ) cout << Form("mixing current k- track %d with", nMix);
if(!fTypeMixing) { // mix with like-sign kaons
for(Int_t nBuf = 0; nBuf < buffer_unn; nBuf++) {
// if(fDebug > 1 ) cout << Form(" buffered k- track %d", nBuf) << endl;
// if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(mix_un[nMix], buffer_un[nBuf]))) continue;
if (fCandidateMinEta && (!CheckCandidateEtaPtCut(mix_un[nMix], buffer_un[nBuf]))) continue;
PtSelector(2, mix_un[nMix], buffer_un[nBuf]);
}
}
else if(fTypeMixing) { // mix with unlike-sign kaons
for(Int_t pBuf = 0; pBuf < buffer_unp; pBuf++) {
// if(fDebug > 1 ) cout << Form(" buffered k+ track %d", pBuf) << endl;
// if (fApplyDeltaDipCut && (!CheckDeltaDipAngle(mix_un[nMix], buffer_up[pBuf]))) continue;
if (fCandidateMinEta && (!CheckCandidateEtaPtCut(mix_un[nMix], buffer_up[pBuf]))) continue;
PtSelector(1, mix_un[nMix], buffer_up[pBuf]);
}
}
}
} // end of mixed events loop
} // end of checking to see whether pool is filled correctly
pool->UpdatePool(MixingCandidates); // update pool with current mixing candidates (for next event)
// if(fDebug > 0 ) pool->PrintInfo();
}
//_____________________________________________________________________________
void AliAnalysisTaskPhiFlow::Terminate(Option_t *)
{
// terminate
if(fDebug > 0) cout << " *** Terminate() *** " << endl;
}
//______________________________________________________________________________
void AliAnalysisTaskPhiFlow::MakeTrack(Double_t mass, Double_t pt, Double_t phi, Double_t eta, Int_t nDau, Int_t iID[], Double_t p, Double_t pz) const
{
// Construct Flow Candidate Track from two selected candidates
// if(fDebug > 1 ) cout << " *** MakeTrack() *** " << endl;
// if requested, check rapidity at this point
if(fCandidateYCut) {
Double_t y = 0.5*TMath::Log((TMath::Sqrt(mass*mass+p*p)+pz)/(TMath::Sqrt(mass*mass+p*p)-pz));
if (y > fCandidateMaxY || y < fCandidateMinY) return;
}
Bool_t overwrite = kTRUE;
AliFlowCandidateTrack *sTrack = static_cast<AliFlowCandidateTrack*>(fCandidates->At(fCandidates->GetLast() + 1));
if (!sTrack) {
sTrack = new AliFlowCandidateTrack(); //deleted by fCandidates
overwrite = kFALSE;
}
else sTrack->ClearMe();
sTrack->SetMass(mass);
sTrack->SetPt(pt);
sTrack->SetPhi(phi);
sTrack->SetEta(eta);
for (Int_t iDau = 0; iDau != nDau; ++iDau) sTrack->AddDaughter(iID[iDau]);
sTrack->SetForPOISelection(kTRUE);
sTrack->SetForRPSelection(kFALSE);
if (overwrite) fCandidates->SetLast(fCandidates->GetLast() + 1);
else fCandidates->AddLast(sTrack);
return;
}
//_____________________________________________________________________________
void AliAnalysisTaskPhiFlow::IsMC()
{
// Fill QA histos for MC analysis
TClonesArray *arrayMC = 0;
if(fDebug > 0) cout << " -> Switching to MC mode <- " << endl;
// fill array with mc tracks
arrayMC = (TClonesArray*) fAOD->GetList()->FindObject(AliAODMCParticle::StdBranchName());
if (!arrayMC) AliFatal("Error: MC particles branch not found!\n");
for (Int_t iTracks = 0; iTracks < fAOD->GetNumberOfTracks(); iTracks++) {
AliAODTrack* track = dynamic_cast<AliAODTrack*>(fAOD->GetTrack(iTracks));
if(!track) AliFatal("Not a standard AOD");
if(!PhiTrack(track) || !IsKaon(track)) { // check for kaons
if(fDebug>1) cout << " Rejected track" << endl;
continue;
}
if (fDebug>1) cout << " Received MC kaon " << endl;
Double_t b[2] = { -99., -99.};
Double_t bCov[3] = { -99., -99., -99.};
AliAODTrack copy(*track);
if(!copy.PropagateToDCA(fAOD->GetPrimaryVertex(), fAOD->GetMagneticField(), 100., b, bCov)) return;
// find corresponding mc particle
AliAODMCParticle *partMC = (AliAODMCParticle*) arrayMC->At(TMath::Abs(track->GetLabel()));
if (!partMC) {
if(fDebug > 1) cout << "Cannot get MC particle" << endl;
continue;
}
// Check if it is primary, secondary from material or secondary from weak decay
Bool_t isPrimary = partMC->IsPhysicalPrimary();
Bool_t isSecondaryMaterial = kFALSE;
Bool_t isSecondaryWeak = kFALSE;
if (!isPrimary) {
Int_t mfl = -999, codemoth = -999;
Int_t indexMoth = partMC->GetMother();
if (indexMoth >= 0) { // is not fake
AliAODMCParticle* moth = (AliAODMCParticle*) arrayMC->At(indexMoth);
codemoth = TMath::Abs(moth->GetPdgCode());
mfl = Int_t(codemoth / TMath::Power(10, Int_t(TMath::Log10(codemoth))));
}
if (mfl == 3) isSecondaryWeak = kTRUE;
else isSecondaryMaterial = kTRUE;
}
if (isPrimary) {
fDCAPrim->Fill(track->Pt(), b[0]);
fDCAXYQA->Fill(b[0]);
fDCAZQA->Fill(b[1]);
}
if (isSecondaryWeak) fDCASecondaryWeak->Fill(track->Pt(), b[0]);
if (isSecondaryMaterial) fDCAMaterial->Fill(track->Pt(), b[0]);
}
}
//_____________________________________________________________________________
Double_t AliAnalysisTaskPhiFlow::GetWDist(const AliVVertex* v0, const AliVVertex* v1)
{
// calculate sqrt of weighted distance to other vertex
if (!v0 || !v1) {
printf("One of vertices is not valid\n");
return 0;
}
static TMatrixDSym vVb(3);
double dist = -1;
double dx = v0->GetX()-v1->GetX();
double dy = v0->GetY()-v1->GetY();
double dz = v0->GetZ()-v1->GetZ();
double cov0[6],cov1[6];
v0->GetCovarianceMatrix(cov0);
v1->GetCovarianceMatrix(cov1);
//
// fQxavsV0[0] fQxnmV0A
// fQyavsV0[0] fQynmV0A
// fQxavsV0[1] fQxnsV0A
// fQyavsV0[1] fQynsV0A
// fQxcvsV0[0] fQxnmV0C
// fQycvsV0[0] fQynmV0C
// fQxcvsV0[1] fQxnsV0C
// fQycvsV0[1] fQynsV0C vVb(0,0) = cov0[0]+cov1[0];
vVb(1,1) = cov0[2]+cov1[2];
vVb(2,2) = cov0[5]+cov1[5];
vVb(1,0) = vVb(0,1) = cov0[1]+cov1[1];
vVb(0,2) = vVb(1,2) = vVb(2,0) = vVb(2,1) = 0.;
vVb.InvertFast();
if (!vVb.IsValid()) {printf("Singular Matrix\n"); return dist;}
dist = vVb(0,0)*dx*dx + vVb(1,1)*dy*dy + vVb(2,2)*dz*dz
+ 2*vVb(0,1)*dx*dy + 2*vVb(0,2)*dx*dz + 2*vVb(1,2)*dy*dz;
return dist>0 ? TMath::Sqrt(dist) : -1;
}
//_____________________________________________________________________________
Bool_t AliAnalysisTaskPhiFlow::plpMV(const AliAODEvent* aod)
{
// check for multi-vertexer pile-up
//
const int kMinPlpContrib = 5;
const double kMaxPlpChi2 = 5.0;
const double kMinWDist = 15;
//
const AliVVertex* vtPrm = 0;
const AliVVertex* vtPlp = 0;
int nPlp = 0;
//
if ( !(nPlp=aod->GetNumberOfPileupVerticesTracks()) ) return kFALSE;
vtPrm = aod->GetPrimaryVertex();
if (vtPrm == aod->GetPrimaryVertexSPD()) return kTRUE; // there are pile-up vertices but no primary
//int bcPrim = vtPrm->GetBC();
//
for (int ipl=0;ipl<nPlp;ipl++) {
vtPlp = (const AliVVertex*)aod->GetPileupVertexTracks(ipl);
//
if (vtPlp->GetNContributors() < kMinPlpContrib) continue;
if (vtPlp->GetChi2perNDF() > kMaxPlpChi2) continue;
// int bcPlp = vtPlp->GetBC();
// if (bcPlp!=AliVTrack::kTOFBCNA && TMath::Abs(bcPlp-bcPrim)>2) return kTRUE; // pile-up from other BC
//
double wDst = GetWDist(vtPrm,vtPlp);
if (wDst<kMinWDist) continue;
//
return kTRUE; // pile-up: well separated vertices
}
//
return kFALSE;
//
}
//_____________________________________________________________________________
//---------------------------------------------------
Short_t AliAnalysisTaskPhiFlow::FindMinNSigma(Double_t nSpi, Double_t nSk, Double_t nSp) const
{
Short_t kPID = 0;
if((nSk == nSpi) && (nSk == nSp))
return kPID;
if((nSk < nSpi) && (nSk < nSp) && (nSk < fPIDConfig[0]))
kPID = 2;
if((nSpi < nSk) && (nSpi < nSp) && (nSpi < fPIDConfig[0]))
kPID = 1;
if((nSp < nSk) && (nSp < nSpi) && (nSp < fPIDConfig[0]))
kPID = 3;
return kPID;
}
//_____________________________________________________________________________
Bool_t AliAnalysisTaskPhiFlow::GetDoubleCountingK(Double_t nSk, Short_t minNSigma) const
{
Bool_t kDC = kFALSE;
if (nSk < fPIDConfig[0] && minNSigma != 2)
kDC = kTRUE;
return kDC;
}
|
01e7ba5cc61590ed8f319033decce12972807392 | 6c6bb201c0dce86a053dfb9f4e8b2f26d0892fca | /downloaddialog.cpp | 736101edfff862d97cad2304de77b382605112d7 | [] | no_license | End1-1/FlashCards | 076481f5bb263e42beba879be4612c7c279de2be | e8609f440894dd4eab389397c0db91af0abfc896 | refs/heads/master | 2022-11-07T18:39:02.336469 | 2022-10-17T21:22:47 | 2022-10-17T21:22:47 | 251,817,501 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 971 | cpp | downloaddialog.cpp | #include "downloaddialog.h"
#include "ui_downloaddialog.h"
#include "download.h"
#include <QThread>
DownloadDialog *DownloadDialog::fInstance = nullptr;
DownloadDialog::DownloadDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::DownloadDialog)
{
ui->setupUi(this);
ui->tbl->setColumnWidths(ui->tbl->columnCount(), 50, 200);
}
DownloadDialog::~DownloadDialog()
{
delete ui;
}
void DownloadDialog::startDownload()
{
Download *d = new Download();
connect(d, &Download::newServer, this, &DownloadDialog::newServerName);
QThread *t = new QThread();
connect(t, &QThread::started, d, &Download::downloadData);
d->moveToThread(t);
t->start();
}
DownloadDialog *DownloadDialog::instance()
{
if (fInstance == nullptr) {
fInstance = new DownloadDialog();
}
return fInstance;
}
void DownloadDialog::newServerName(const QString &name)
{
int r = ui->tbl->addEmptyRow();
ui->tbl->setString(r, 1, name);
}
|
a752f13a07c26fd4fb3a111bcdf85fa2d14a9d3a | e413e4020617f2645f7f3ed89ec698183c17e919 | /Haralick/Haralick.h | d3a1b2f2f7a4555c5ed1a35a4af284a9e631c87e | [] | no_license | YanXuHappygela/Farsight-latest | 5c349421b75262f89352cc05093c04d3d6dfb9b0 | 021b1766dc69138dcd64a5f834fdb558bc558a27 | refs/heads/master | 2020-04-24T13:28:25.601628 | 2014-09-30T18:51:29 | 2014-09-30T18:51:29 | 24,650,739 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,123 | h | Haralick.h | #include "itkImageRegionIteratorWithIndex.h"
#include "itkImageRegionConstIterator.h"
#include "itkImageRegionIterator.h"
#include "itkImage.h"
#include <itkIndex.h>
#include "itkImageFileReader.h"
//class Haralick returns the Haralick texture feature vector
class Haralick
{
public:
#define Dimension 2
#define VIndexDimension 2
typedef unsigned char PixelType;
typedef itk::Image<PixelType , Dimension > ImageType;
typedef itk::ImageRegionIteratorWithIndex< ImageType > IteratorType;
typedef itk::Index< VIndexDimension > IndexType;
typedef ImageType::SizeType InputSizeType;
std::string imageFileName;
ImageType::Pointer inputImage;
Haralick(std::string imageFileName);
Haralick(ImageType::Pointer inputImage);
Haralick();
~Haralick();
double * GetHaralik();
private:
unsigned char ** f;
int M , N ,Ng;
int ReadInputImage(std::string imageFileName);
void SetInputImage();
// this function calculates the maximum intensity value of image
int max_value();
// this method calculates minimum value of inensity value in image
int min_value();
// the method sets the size of the cooccurence matrix
void set_Ng();
double f1_ASM,f2_Contrast,f3_Correlation,f4_Variance,f5_IDM,f6_Sum_Avg,f7_Sum_Var,f8_Sum_Entropy,f9_Entropy,f10_diff_var,f11_difference_entropy,f12,f13;
double f14_maxcorr (int** P,int N);
double *pgm_vector (int nl, int nh);
double **pgm_matrix (int nrl,int nrh, int ncl, int nch);
void results (double *Tp,char *c, double *a);
void simplesrt ( int n, double arr[]);
void mkbalanced ( double **a, int n);
void reduction ( double **a, int n);
int hessenberg ( double **a,double wr[],double wi[], int n);
void SWAP(double a,double b);
int ** calculateco_occurrence( int dir[]);
//this method calculates the cooccurance matrix for a given angle .As the cooccurrence matrix is symmetric
//(used by haralick feature calculation) so the matrices coorsponding to angles theta and theta+180 are combined
void calculatecooccurrence( int** P ,int angle);
void calculatefeatures(int** P );
}; |
0f115f87eb0cd7186176b5e74c4e1c8a8cf01f3f | 4c55fdb3b0d661cba6ab88447777d6bed8785485 | /X/Src/TextureManager.cpp | c14ac3c63a0d094fd867ba76c25792e9eb9f2824 | [] | no_license | arorabharat144/TheAdventuresOfEnchantedSkeleton | b6d42eb53241549ef849e36e8cc20968f2cb64cd | e330606a44cb501c9cb6db24be75eff92639acdb | refs/heads/master | 2020-05-22T00:22:26.947161 | 2019-05-11T18:49:59 | 2019-05-11T18:49:59 | 186,170,679 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,341 | cpp | TextureManager.cpp | //====================================================================================================
// Filename: TextureManager.cpp
// Created by: Peter Chan
//====================================================================================================
#include "Precompiled.h"
#include "TextureManager.h"
#include "Texture.h"
using namespace X;
namespace
{
TextureManager* sTextureManager = nullptr;
}
void TextureManager::StaticInitialize(const char* root)
{
XASSERT(sTextureManager == nullptr, "[TextureManager] Manager already initialized!");
sTextureManager = new TextureManager();
sTextureManager->SetRootPath(root);
}
//----------------------------------------------------------------------------------------------------
void TextureManager::StaticTerminate()
{
if (sTextureManager != nullptr)
{
sTextureManager->Clear();
SafeDelete(sTextureManager);
}
}
//----------------------------------------------------------------------------------------------------
TextureManager* TextureManager::Get()
{
XASSERT(sTextureManager != nullptr, "[TextureManager] No instance registered.");
return sTextureManager;
}
//----------------------------------------------------------------------------------------------------
TextureManager::TextureManager()
{
}
//----------------------------------------------------------------------------------------------------
TextureManager::~TextureManager()
{
XASSERT(mInventory.empty(), "[TextureManager] Clear() must be called to clean up.");
}
//----------------------------------------------------------------------------------------------------
void TextureManager::SetRootPath(const char* path)
{
mRoot = path;
}
//----------------------------------------------------------------------------------------------------
TextureId TextureManager::Load(const char* fileName)
{
std::string fullName = mRoot + "/" + fileName;
std::hash<std::string> hasher;
TextureId hash = hasher(fullName);
auto result = mInventory.insert({ hash, nullptr });
if (result.second)
{
Texture* texture = new Texture();
if (texture->Initialize(fullName.c_str()))
{
result.first->second = texture;
}
else
{
SafeDelete(texture);
mInventory.erase(result.first);
hash = 0;
}
}
return hash;
}
//----------------------------------------------------------------------------------------------------
void TextureManager::Clear()
{
for (auto& item : mInventory)
{
if (item.second)
{
item.second->Terminate();
SafeDelete(item.second);
}
}
mInventory.clear();
}
//----------------------------------------------------------------------------------------------------
void TextureManager::BindVS(TextureId id, uint32_t slot)
{
auto iter = mInventory.find(id);
if (iter != mInventory.end())
{
iter->second->BindVS(slot);
}
}
//----------------------------------------------------------------------------------------------------
void TextureManager::BindPS(TextureId id, uint32_t slot)
{
auto iter = mInventory.find(id);
if (iter != mInventory.end())
{
iter->second->BindPS(slot);
}
}
//----------------------------------------------------------------------------------------------------
Texture* TextureManager::GetTexture(TextureId id)
{
auto iter = mInventory.find(id);
return iter != mInventory.end() ? iter->second : nullptr;
} |
9d9c860256f7a83aaeea977b87ca3ff4ed5758a2 | c95937d631510bf5a18ad1c88ac59f2b68767e02 | /src/graph/backend/graph_compiler/core/src/compiler/ir/graph/mixed_partition.cpp | 7a5c2fe1b80ef9a2298ef9b08e0036d03baeccc8 | [
"BSD-3-Clause",
"MIT",
"Intel",
"BSL-1.0",
"Apache-2.0",
"BSD-2-Clause"
] | permissive | oneapi-src/oneDNN | 5cdaa8d5b82fc23058ffbf650eb2f050b16a9d08 | aef984b66360661b3116d9d1c1c9ca0cad66bf7f | refs/heads/master | 2023-09-05T22:08:47.214983 | 2023-08-09T07:55:23 | 2023-09-05T13:13:34 | 58,414,589 | 1,544 | 480 | Apache-2.0 | 2023-09-14T07:09:12 | 2016-05-09T23:26:42 | C++ | UTF-8 | C++ | false | false | 170,016 | cpp | mixed_partition.cpp | /*******************************************************************************
* Copyright 2022-2023 Intel Corporation
*
* 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 "mixed_partition.hpp"
#include <algorithm>
#include <string>
#include "pass/pass.hpp"
#include "transform/transform.hpp"
#include "tunable_op.hpp"
#include "utils.hpp"
#include <compiler/ir/builder.hpp>
#include <compiler/ir/easy_build.hpp>
#include <compiler/ir/graph/fusible_op_utils.hpp>
#include <compiler/ir/graph/lowering.hpp>
#include <compiler/ir/transform/auto_cast.hpp>
#include <compiler/ir/transform/buffer_schedule.hpp>
#include <compiler/ir/transform/concat_memory_planning.hpp>
#include <compiler/ir/transform/constant_fold.hpp>
#include <compiler/ir/transform/dyn_tsr_transform.hpp>
#include <compiler/ir/transform/index_flatten.hpp>
#include <compiler/ir/transform/loop_transform.hpp>
#include <compiler/ir/transform/pointer_alias_info.hpp>
#include <compiler/ir/transform/scope_flatten.hpp>
#include <compiler/ir/transform/tensor2var.hpp>
#include <compiler/ir/transform/tensor_inplace_info.hpp>
#include <compiler/ir/visitor.hpp>
#include <ops/convolution.hpp>
#include <ops/fusible/memory_movement.hpp>
#include <ops/fusible/padding.hpp>
#include <ops/fusible/pooling.hpp>
#include <ops/fusible/reduce.hpp>
#include <ops/managed_matmul_core.hpp>
#include <runtime/config.hpp>
namespace dnnl {
namespace impl {
namespace graph {
namespace gc {
SC_MODULE(graph.mixed_partition);
void mxp_replacer_t::replace_anchor(
const std::vector<fuse_anchor_map_ptr> &fanchors) {
auto replace_fsmap = [&](const fuse_anchor_map_ptr &cur) {
for (auto &fs_pair : cur->fsmap_.datamap_) {
for (auto &slice : fs_pair.second) {
for (auto &range : slice) {
range.first = dispatch_impl(range.first);
range.second = dispatch_impl(range.second);
}
}
}
};
for (auto &anmap : fanchors) {
replace_fsmap(anmap);
}
}
namespace graph {
void tensor_detail_to_ir_tensor(sc_graph_t &graph, const std::string &name,
const graph_tensor_ptr >, mxp_buffer_allocator *buf_alloc) {
COMPILE_ASSERT(buf_alloc, "No buffer allocator found")
bool is_cost_model_enabled
= buf_alloc->get_binded_mxp()->cost_->is_enabled();
if (!buf_alloc->g2b_map_.haskey(gt)) {
auto tsr = graph::tensor_detail_to_ir_tensor(graph, name, gt->details_);
buf_alloc->g2b_map_.get(gt) = tsr;
if (!graph.is_dynamic() && is_cost_model_enabled) {
auto dim_prod = get_dims_product(
get_expr_to_dims(tsr.checked_as<tensor>()->dims_));
auto dtype_size = utils::get_sizeof_etype(
tsr.checked_as<tensor>()->elem_dtype_.type_code_);
// first touch
buf_alloc->mem_trace_.emplace_back(
memory_optim::memory_alloc_trace_t {(uintptr_t)tsr.get(),
(size_t)dim_prod * dtype_size});
// last use
buf_alloc->mem_trace_.emplace_back(
memory_optim::memory_alloc_trace_t {
(uintptr_t)tsr.get(), (size_t)0});
}
} else if (!graph.is_dynamic() && is_cost_model_enabled) {
auto tsr = get_real_tensor(buf_alloc->g2b_map_.get(gt));
// update last use trace
auto last_trace = std::remove_if(buf_alloc->mem_trace_.begin(),
buf_alloc->mem_trace_.end(),
[&tsr](const memory_optim::memory_alloc_trace_t &trace) {
return ((uintptr_t)tsr.get() == trace.buffer_id_)
&& (trace.size_ == 0);
});
COMPILE_ASSERT((last_trace + 1) == buf_alloc->mem_trace_.end(),
"Not found last use trace for: " << tsr);
(*last_trace) = memory_optim::memory_alloc_trace_t {
(uintptr_t)tsr.get(), (size_t)0};
}
}
void tensor_detail_to_ir_tensor(sc_graph_t &graph,
const std::string &name_prefix,
const std::vector<graph_tensor_ptr> &tsrs,
mxp_buffer_allocator *buf_alloc) {
COMPILE_ASSERT(buf_alloc, "No buffer allocator found")
for (size_t i = 0; i < tsrs.size(); i++) {
tensor_detail_to_ir_tensor(
graph, name_prefix + std::to_string(i), tsrs[i], buf_alloc);
}
}
} // namespace graph
mixed_fuse_op_t *get_mixed_op_from_graph(sc_graph_t &graph) {
mixed_fuse_op_t *mixed_op = nullptr;
for (auto &op : graph.ops_) {
if (auto mx_op = op->dyn_cast<mixed_fuse_op_t>()) {
COMPILE_ASSERT(!mixed_op, "Only one fused op is expected")
mixed_op = mx_op;
}
}
return mixed_op;
}
void mxp_buffer_allocator::set_buffer_inplace_hint(
const expr &target_buf, const expr &inplace_buf) {
// skip dynamic cases
// Buffer inplace currently does not support dynamic buffers
if (binded_mxp_->get_host_graph().is_dynamic()) { return; }
COMPILE_ASSERT(target_buf.defined() && inplace_buf.defined(),
"Both buffer should be defined")
// skip same buffer
if (inplace_buf.ptr_same(target_buf)) return;
auto target_id = alias_info::get_or_create_alias_info(*target_buf.get());
SC_MODULE_INFO << "Mark inplace hint for buffer: " << inplace_buf << " ==> "
<< target_buf;
inplace_buf->attr()[attr_keys::tensor_inplace_hint]
= std::vector<temp_tensor_inplace_info_t> {
{target_id, inplace_kind::ZERO_OFFSET}};
// update inner inaplce map
inplace_map_[(uintptr_t)inplace_buf.get()]
= std::vector<std::pair<uintptr_t, inplace_kind>> {
{(uintptr_t)target_buf.get(), inplace_kind::ZERO_OFFSET}};
}
void mxp_buffer_allocator::allocate_buffer(sc_op *op) {
auto &graph = op->get_owner_graph();
// allocate input buffer
graph::tensor_detail_to_ir_tensor(graph,
op->op_name_ + "_" + std::to_string(op->logical_op_id_) + "_ins_",
op->get_inputs(), this);
/* deal with special ops: explict inplace input */
// tensorview op
if (auto tv_op = op->dyn_cast<tensor_view_op_t>()) {
auto inp = tv_op->get_inputs()[0];
if ((inp->uses_.size() == 1)
&& (inp->details_.get_blocking_dims()
== tv_op->get_outputs()[0]
->details_.get_blocking_dims())
&& (binded_mxp_->contains(inp->producer_owner_))
&& (!(g2b_map_.get(inp).isa<tensor>()
&& g2b_map_.get(inp)
.static_as<tensor>()
->init_value_))) {
if (graph.is_dynamic()) {
// reset plain dims hint as do inplacement here.
auto &tsr = g2b_map_.get(inp);
tsr->attr().set(attr_keys::plain_dims,
graph.dims_to_expr(
op->get_outputs()[0]
->details_.get_plain_dims()));
}
g2b_map_.get(op->get_outputs()[0]) = g2b_map_.get(inp);
} else {
auto base_tsr = get_real_tensor(g2b_map_.get(inp));
g2b_map_.get(op->get_outputs()[0]) = builder::tensor_ptr(base_tsr,
std::vector<expr>(base_tsr->dims_.size(), 0),
tv_op->get_shapes_expr());
}
}
// reduce collect op
if (auto collc_op = op->dyn_cast<reduce_collect_op_t>()) {
if (collc_op->is_place_holder_op()) {
// inplace reduce_compute_op output
COMPILE_ASSERT(
op->get_inputs()[0]
->producer_owner_->isa<reduce_compute_op_t>(),
"reduce collect op is expected to follow reduce compute "
"op, but got "
<< op->get_inputs()[0]->producer_owner_->op_name_)
// no code generated
g2b_map_.get(op->get_outputs()[0])
= g2b_map_.get(op->get_inputs()[0]);
}
}
// allocate output buffer
graph::tensor_detail_to_ir_tensor(graph,
op->op_name_ + "_" + std::to_string(op->logical_op_id_) + "_outs_",
op->get_outputs(), this);
// reorder op
if (auto reo_op = op->dyn_cast<reorder_op_t>()) {
if (reo_op->check_padding()) {
op->get_outputs()[0]->attrs_.set(
mixed_partition_hint::no_inplace, true);
}
}
/* infer post-op inplace */
auto query_inplace = [&](const graph_tensor_ptr &out,
const graph_tensor_ptr &in) -> bool {
return (!op->isa<tunable_op_t>()) && (in->uses_.size() == 1)
&& (out != in)
&& (out->details_.get_blocking_dims()
== in->details_.get_blocking_dims())
&& (out->details_.dtype_ == in->details_.dtype_)
&& (out->details_.get_format() == in->details_.get_format())
&& (binded_mxp_->contains(
in->producer_owner_)) // inputs of partition should not
// be inplaced
&& (!in->producer_owner_->isa<tunable_op_t>())
&& (!(g2b_map_.get(in).isa<tensor>()
&& g2b_map_.get(in)
.static_as<tensor>()
->init_value_)); // TODO(XXX): inplace inited
// tensor
};
for (auto &out : op->get_outputs()) {
if (out->attrs_.get_or_else(mixed_partition_hint::no_inplace, false)) {
continue;
}
// query input
for (auto &inp : op->get_inputs()) {
if (inp->attrs_.get_or_else(
mixed_partition_hint::no_inplace, false)) {
continue;
}
if (query_inplace(out, inp)) {
// set buffer inplace hint for output buffer
set_buffer_inplace_hint(g2b_map_.get(inp), g2b_map_.get(out));
break;
}
}
}
/* deal with special ops: set tensor initial value */
// reduce collect and compute op
if (auto rd_impl_op = op->dyn_cast<reduce_impl_op_t>()) {
auto buf = g2b_map_.get(op->get_outputs()[0]);
COMPILE_ASSERT(buf.isa<tensor>(),
"output of reduce_impl op should be tensor type")
rd_impl_op->set_reduce_buffer(buf.checked_as<tensor>());
}
/* infer pre-op inplace */
if (op->isa<padding_op_t>() && op->get_inputs()[0]->uses_.size() == 1
&& !binded_mxp_->empty()) {
auto out = op->get_outputs()[0];
auto ins = op->get_inputs()[0];
auto old_input = g2b_map_.get(ins);
if (old_input.isa<tensor>()
|| (old_input.isa<tensorptr>() && ins->uses_.size() == 1
&& utils::is_one_of(
old_input.static_as<tensorptr>()->base_->dtype_,
sc_data_type_t::u8(), sc_data_type_t::s8()))) {
if (old_input.isa<tensorptr>()) {
auto &producer = ins->producer_owner_;
if (!producer->isa<tensor_view_op_t>()) return;
auto &tv_inp = producer->get_inputs()[0];
if (tv_inp->attrs_.get_or_else(
mixed_partition_hint::no_inplace, false))
return;
if (producer->share_gt_with_op<tensor_view_op_t>(tv_inp)
|| producer->share_gt_with_op<tunable_op_t>(tv_inp))
return;
}
op->attrs_.set<bool>(
mixed_partition_hint::inplace_optimized_op, true);
auto pad_op = op->dyn_cast<padding_op_t>();
auto new_input = builder::tensor_ptr(g2b_map_.get(out),
pad_op->get_padding_offsets_exprs(),
pad_op->get_inputs()[0]->details_.get_blocking_dims_expr(
graph),
true);
if (old_input.isa<tensorptr>()) {
auto parent_tsr = get_real_tensor(old_input);
auto shape = parent_tsr->dims_;
new_input = builder::tensor_ptr(new_input,
std::vector<expr>(
new_input.static_as<tensorptr>()->shape_.size(),
0),
shape, false);
old_input = parent_tsr;
}
// Buffer replace
replace_buffer(old_input, new_input);
}
}
}
std::vector<memory_optim::memory_alloc_trace_t>
mxp_buffer_allocator::get_real_mem_trace(
const std::unordered_set<graph_tensor *> &keep_cut_set) const {
std::vector<memory_optim::memory_alloc_trace_t> shrink_trace = mem_trace_;
std::unordered_set<expr> ignore_buf_set;
for (auto &g2b : g2b_map_.datamap_) {
if (binded_mxp_->is_parti_cut(g2b.first)
&& keep_cut_set.find(g2b.first) == keep_cut_set.end()) {
ignore_buf_set.insert(get_real_tensor(g2b.second));
}
}
for (auto iter = shrink_trace.begin(); iter != shrink_trace.end();) {
auto tsr = ((expr_base *)iter->buffer_id_)->node_ptr_from_this();
if (ignore_buf_set.find(tsr) != ignore_buf_set.end()) {
iter = shrink_trace.erase(iter);
} else {
iter++;
}
}
std::transform(shrink_trace.begin(), shrink_trace.end(),
shrink_trace.begin(),
[&](const memory_optim::memory_alloc_trace_t &t) {
if (t.size_ == 0) return t;
auto tsr = ((expr_base *)t.buffer_id_)->node_ptr_from_this();
auto shrink_info = get_shrinked_info(tsr);
auto shape = get_dims_product(get_expr_to_dims(
shrink_info.empty() ? tsr.checked_as<tensor>()->dims_
: get_slice_shape(shrink_info)));
auto dtype_size = utils::get_sizeof_etype(
tsr.checked_as<tensor>()->elem_dtype_.type_code_);
return memory_optim::memory_alloc_trace_t {
t.buffer_id_, shape * dtype_size};
});
return shrink_trace;
}
size_t get_buffer_usage(const context_ptr &ctx,
const std::vector<memory_optim::memory_alloc_trace_t> &mem_trace,
const memory_optim::inplace_info_map &inplace_map) {
std::unordered_map<uintptr_t, std::size_t> out_schedule;
std::unordered_map<uintptr_t, std::vector<uintptr_t>> out_inplace_selection;
return schedule_memory_allocations(mem_trace, /*alignment*/ 64,
ctx->flags_.buffer_schedule_ == attr_keys::BUF_SCHED_HOT,
inplace_map, out_schedule, out_inplace_selection);
}
size_t mxp_buffer_allocator::get_real_buffer_usage() const {
return get_buffer_usage(
binded_mxp_->ctx_, get_real_mem_trace(), inplace_map_);
}
void mxp_buffer_allocator::replace_buffer(
const expr &old_buffer, const expr &new_buffer) {
// assert new buffer
COMPILE_ASSERT(b2g_map_.find(new_buffer) == b2g_map_.end(),
"Currently, it is only expected to replace with new buffer which "
"never appear in mixed IR, but got "
<< new_buffer)
// get old buffer
COMPILE_ASSERT(old_buffer.isa<tensor>(),
"Replace target is expected to be Tensor node")
if (tsr2anch_map_.find(old_buffer) != tsr2anch_map_.end()) {
tsr2anch_map_.erase(old_buffer);
}
if (b2g_map_.find(old_buffer) != b2g_map_.end()) {
auto old_gt = b2g_map_[old_buffer];
b2g_map_.erase(old_buffer);
b2g_map_[new_buffer] = old_gt;
}
// get real tsr
auto old_tsr = get_real_tensor(old_buffer),
new_tsr = get_real_tensor(new_buffer);
// update trace
bool new_tsr_already_in_trace = false;
std::for_each(mem_trace_.begin(), mem_trace_.end(),
[&old_tsr, &new_tsr, &new_tsr_already_in_trace](
memory_optim::memory_alloc_trace_t &t) {
if (t.buffer_id_ == (uintptr_t)old_tsr.get()) {
t.buffer_id_ = (uintptr_t)new_tsr.get();
} else if (t.buffer_id_ == (uintptr_t)new_tsr.get()) {
new_tsr_already_in_trace = true;
}
});
if (new_tsr_already_in_trace) {
int cnt = 0;
// erase middle two times
for (auto iter = mem_trace_.begin(); iter != mem_trace_.end();) {
if (iter->buffer_id_ == (uintptr_t)new_tsr.get()) {
cnt++;
if (cnt == 2 || cnt == 3) {
iter = mem_trace_.erase(iter);
continue;
}
}
iter++;
}
COMPILE_ASSERT(
cnt == 4, "Unexpected buffer occurs time in trace: " << cnt)
}
// update inplace map if necessary
for (auto iter = inplace_map_.begin(); iter != inplace_map_.end();) {
auto buf1 = ((expr_base *)iter->first)->node_ptr_from_this();
auto buf2 = get_inplaced_buffer(buf1);
if (buf1.ptr_same(old_buffer) || buf2.ptr_same(old_buffer)) {
iter = inplace_map_.erase(iter);
} else {
iter++;
}
}
// replace g2b map
for (auto &g2b : g2b_map_.datamap_) {
auto &buf = g2b.second;
auto tsr = get_real_tensor(buf);
if (tsr.ptr_same(old_tsr.static_as<tensor>())) {
set_base_tensor(buf, new_buffer);
}
}
// TIR replace
node_ptr_map buffer_map = {{old_buffer.impl, new_buffer.impl}};
mxp_replacer_t(buffer_map).replace_func(binded_mxp_->func_);
}
std::tuple<std::vector<expr>, std::vector<expr>>
mxp_buffer_allocator::get_buffer(sc_op *op) const {
std::vector<expr> inputs(op->get_inputs().size()),
outputs(op->get_outputs().size());
std::transform(op->get_inputs().begin(), op->get_inputs().end(),
inputs.begin(), [&](const graph_tensor_ptr >) {
COMPILE_ASSERT(
g2b_map_.haskey(gt), "please allocate buffer first")
return g2b_map_.datamap_.find(gt.get())->second;
});
std::transform(op->get_outputs().begin(), op->get_outputs().end(),
outputs.begin(), [&](const graph_tensor_ptr >) {
COMPILE_ASSERT(
g2b_map_.haskey(gt), "please allocate buffer first")
return g2b_map_.datamap_.find(gt.get())->second;
});
return std::make_tuple(inputs, outputs);
}
static cmp_res cmp_op_anchor(sc_op *op, fuse_anchor_map_ptr cur_anchor,
fuse_anchor_map_ptr new_anchor) {
cmp_res res = cmp_res::unknown;
auto cmper = [&](const std::vector<graph_tensor_ptr> >_vec) {
std::for_each(
gt_vec.begin(), gt_vec.end(), [&](const graph_tensor_ptr >) {
if (utils::is_one_of(res, cmp_res::unknown, cmp_res::equal)
&& cur_anchor->fsmap_.hasvalue(gt)
&& new_anchor->fsmap_.hasvalue(gt)) {
res = cmp_slice_range(cur_anchor->fsmap_.get(gt),
new_anchor->fsmap_.get(gt));
}
});
};
// compare input
cmper(op->get_inputs());
// if result is unknown, continue compare output
if (res == cmp_res::unknown) { cmper(op->get_outputs()); }
COMPILE_ASSERT(res != cmp_res::unknown, "Unknown comparision result")
return res;
}
void mxp_buffer_allocator::update_input_buffer_info(sc_op *op) {
auto commited_anchor_map = binded_mxp_->lookup_anchor_map(op);
auto update_inp_tensor_info = [&](const graph_tensor_ptr &inp) {
auto buf = g2b_map_.get(inp);
if (b2g_map_.find(buf) == b2g_map_.end()) b2g_map_[buf] = inp;
auto tsr = get_real_tensor(buf);
bool is_borrowed = (commited_anchor_map->borrowed_fanchor_map_.find(inp)
!= commited_anchor_map->borrowed_fanchor_map_.end());
// update b2g map if necessary
if (is_borrowed) b2g_map_[buf] = inp;
auto real_anchor_map = is_borrowed
? commited_anchor_map->borrowed_fanchor_map_[inp]
: commited_anchor_map;
if (tsr2anch_map_.find(tsr) != tsr2anch_map_.end()) {
COMPILE_ASSERT(b2g_map_.find(buf) != b2g_map_.end(),
"base tensor should be visited")
// current anchor map
auto cur_anchor_map = tsr2anch_map_[tsr];
// auto skip
if (cur_anchor_map == real_anchor_map) return;
// redirect to common parent anchor if new anchor is cousin
// relationship of current anchor in avoid of use before define
if (cur_anchor_map->is_cousin_for(real_anchor_map)) {
// set common parent anchor no matter which anchor is larger
tsr2anch_map_[tsr]
= real_anchor_map->get_root()->shared_from_this();
} else {
auto cur_slice = cur_anchor_map->fsmap_.get(b2g_map_[buf]);
auto new_slice = real_anchor_map->fsmap_.get(inp);
auto res = cmp_slice_range(cur_slice, new_slice);
bool need_overwrite = false;
if (res == cmp_res::l_less_r) {
need_overwrite = true;
} else if (res == cmp_res::equal) {
// usually occurs in op is reduce or reduce collect op
need_overwrite
= real_anchor_map->is_parent_for(cur_anchor_map)
|| real_anchor_map->is_sibling_for(cur_anchor_map);
}
// update latest anchor map
if (need_overwrite) { tsr2anch_map_[tsr] = real_anchor_map; }
}
} else {
tsr2anch_map_[tsr] = real_anchor_map;
}
};
for (auto &inp : op->get_inputs()) {
update_inp_tensor_info(inp);
}
}
void mxp_buffer_allocator::update_output_buffer_info(sc_op *op) {
auto commited_anchor_map = binded_mxp_->lookup_anchor_map(op);
auto sub_of_commited_anchor_map
= binded_mxp_->lookup_sub_anchor_map(commited_anchor_map);
auto update_out_tensor_info = [&](const graph_tensor_ptr &out) {
auto buf = g2b_map_.get(out);
if (b2g_map_.find(buf) == b2g_map_.end()) b2g_map_[buf] = out;
auto tsr = get_real_tensor(buf);
if (tsr2anch_map_.find(tsr) != tsr2anch_map_.end()) {
// only input anchor is expected for below logic
if (!commited_anchor_map->is_input_anchor()) return;
COMPILE_ASSERT(b2g_map_.find(buf) != b2g_map_.end(),
"base tensor should be visited")
// auto skip
if (tsr2anch_map_[tsr] == commited_anchor_map) return;
auto cur_slice = tsr2anch_map_[tsr]->fsmap_.get(b2g_map_[buf]);
auto new_slice = commited_anchor_map->fsmap_.get(out);
auto res = cmp_slice_range(cur_slice, new_slice);
if (res == cmp_res::l_less_r) {
tsr2anch_map_[tsr] = commited_anchor_map;
}
} else {
fuse_anchor_map_ptr min_anchor_map = nullptr;
for (auto &sub_anchor : sub_of_commited_anchor_map) {
if (!sub_anchor->fsmap_.hasvalue(out)) continue;
if (!min_anchor_map)
min_anchor_map = sub_anchor;
else {
auto min_slice = min_anchor_map->fsmap_.get(out);
auto cur_slice = sub_anchor->fsmap_.get(out);
if (cmp_slice_range(min_slice, cur_slice)
== cmp_res::l_larger_r) {
min_anchor_map = sub_anchor;
}
}
}
tsr2anch_map_[tsr]
= min_anchor_map ? min_anchor_map : commited_anchor_map;
}
};
for (auto &out : op->get_outputs()) {
update_out_tensor_info(out);
}
}
void mxp_buffer_allocator::tensor_initialize() {
for (auto &pair : g2b_map_.datamap_) {
auto op = pair.first->producer_owner_;
// zero out padding area
if (auto padding = op->dyn_cast<padding_op_t>()) {
if (b2g_map_.find(pair.second) == b2g_map_.end()) continue;
stmts decl_body;
auto pad_tsr = get_real_tensor(pair.second);
slice_range_list range_list = {};
if (pair.second->attr().has_key(mixed_partition_hint::cut_buffer)) {
decl_body = binded_mxp_->func_->body_.checked_as<stmts>();
} else {
COMPILE_ASSERT(
tsr2anch_map_.find(pad_tsr) != tsr2anch_map_.end(),
"Could not find padding tensor: "
<< pad_tsr << " in tsr2anchor map")
auto anchor = tsr2anch_map_[pad_tsr];
range_list = anchor->fsmap_.get(b2g_map_[pair.second]);
decl_body = anchor->get_parent_scope();
}
auto ret = padding->get_zero_out_stmt(pad_tsr, range_list);
decl_body->seq_.insert(decl_body->seq_.begin(), ret);
}
}
}
void mxp_buffer_allocator::copy_concat_memory_attrs_tsr2buf() {
for (auto &op : binded_mxp_->committed_ops_) {
if (!op->isa<concat_op_t>()) { continue; }
auto concat = op->stc_cast<concat_op_t>();
for (auto &input_tsr : concat->get_inputs()) {
if (input_tsr->attrs_.has_key(
concat_optim_attr_keys::graph_memory_offset)) {
auto &offset = input_tsr->attrs_.get<std::vector<expr>>(
concat_optim_attr_keys::graph_memory_offset);
auto &buf = binded_mxp_->buf_alloc_.g2b_map_.get(input_tsr);
COMPILE_ASSERT(buf.isa<tensor>(),
"Buffer with memory_offset should be a tensor")
buf->attr()[concat_optim_attr_keys::pass_memory_offset]
= offset;
auto &final_tsr = input_tsr->attrs_.get<graph_tensor_ptr>(
concat_optim_attr_keys::graph_memory_offset_to);
COMPILE_ASSERT(
binded_mxp_->buf_alloc_.g2b_map_.haskey(final_tsr),
"No buffer allocated for concat outputs")
auto &out_buffer
= binded_mxp_->buf_alloc_.g2b_map_.get(final_tsr);
buf->attr()[concat_optim_attr_keys::pass_memory_offset_to]
= out_buffer;
SC_MODULE_INFO
<< "Buffer: " << buf
<< " has memory offset to buffer: " << out_buffer;
}
}
}
}
inline bool is_elementwise_op(const sc_op *op) {
return op->isa<unary_elementwise_op_t>()
|| op->isa<binary_elementwise_op_t>();
}
inline bool is_elementwise_producer(const graph_tensor *gt) {
return is_elementwise_op(gt->producer_owner_);
}
// If last gt depends on all users of cur gt, return true
inline bool check_last_use_for_gt(const graph_tensor *cur_gt,
const graph_tensor *last_gt, const mxp_buffer_allocator *alloc) {
return std::all_of(cur_gt->uses_.begin(), cur_gt->uses_.end(),
[&alloc, &last_gt](const std::pair<int, sc_op_weak_ptr_t> &user) {
return alloc->get_binded_mxp()->dep_m_->lookup(
user.second.get(), last_gt->producer_owner_)
== 1;
});
}
// max step to explore preview ops
static constexpr int EXPLORE_INPLACE_MAX_STEP = 8;
static void collect_inplace_info(graph_tensor *cur_gt, graph_tensor *ref_gt,
std::unordered_set<graph_tensor *> &inplace_set,
std::unordered_set<expr> &visited_set,
const std::unordered_set<graph_tensor *> &valid_set,
mxp_buffer_allocator *alloc, int step) {
// increment by 1 recursive depth and auto skip
if (EXPLORE_INPLACE_MAX_STEP == (step++)) return;
// skip repeated
if (inplace_set.find(cur_gt) != inplace_set.end()) return;
// return when producer is not elementwise op
if (!is_elementwise_producer(cur_gt)) { return; }
// use buffer as key for map
auto cur_buf = alloc->g2b_map_.get(cur_gt);
// check inplace condition
if ((visited_set.find(cur_buf) == visited_set.end())
&& (valid_set.find(cur_gt) != valid_set.end()) && (cur_gt != ref_gt)
&& (cur_gt->details_.get_blocking_dims()
== ref_gt->details_.get_blocking_dims())
&& (cur_gt->details_.dtype_ == ref_gt->details_.dtype_)
&& (cur_gt->details_.get_format() == ref_gt->details_.get_format())
&& check_last_use_for_gt(cur_gt, ref_gt, alloc)) {
inplace_set.insert(cur_gt);
// reset step
step = 0;
// reset ref_gt
ref_gt = cur_gt;
}
// if not mark visited
if (visited_set.find(cur_buf) == visited_set.end()) {
// recursively mark visited
while (cur_buf.defined()) {
visited_set.insert(cur_buf);
cur_buf = alloc->get_inplaced_buffer(cur_buf);
}
}
// get cur op
auto elem_op = cur_gt->producer_owner_;
// recursively collect inplace information
for (auto &inp : elem_op->get_inputs()) {
collect_inplace_info(inp.get(), ref_gt, inplace_set, visited_set,
valid_set, alloc, step);
}
}
expr mxp_buffer_allocator::get_inplaced_buffer(const expr &buf) const {
auto iter = inplace_map_.find((uintptr_t)buf.get());
if (iter != inplace_map_.end()) {
COMPILE_ASSERT(iter->second.size() == 1,
"Unexpected inplace info size during partition")
return ((expr_base *)iter->second[0].first)->node_ptr_from_this();
}
return expr();
}
void mxp_buffer_allocator::query_inplace() {
SC_MODULE_INFO << "Query buffer inplace hint...";
// step 0: get outer loop
auto outer_loops = binded_mxp_->get_outer_loops();
if (outer_loops.empty()) return;
auto batch_anchor = binded_mxp_->get_anchor_inside_loop(outer_loops.back());
if (!batch_anchor) return;
// step 1: search gt which defined inside outer loop
std::vector<graph_tensor *> ref_gt_list;
std::unordered_set<graph_tensor *> valid_set;
for (auto &tsr2anch : tsr2anch_map_) {
auto anchor = tsr2anch.second;
auto tsr = tsr2anch.first;
if (tsr->attr().has_key(mixed_partition_hint::cut_buffer)) continue;
if (b2g_map_.find(tsr) == b2g_map_.end()) continue;
auto shrink_gt = b2g_map_[tsr];
auto slice_on_batch_anchor = batch_anchor->fsmap_.get(shrink_gt);
auto slice_on_cur_anchor = slice_range_list {get_shrinked_info(tsr)};
if (slice_on_cur_anchor.empty() || slice_on_batch_anchor.empty())
continue;
if (cmp_slice_range(slice_on_batch_anchor, slice_on_cur_anchor)
== cmp_res::equal) {
ref_gt_list.emplace_back(b2g_map_[tsr].get());
valid_set.insert(b2g_map_[tsr].get());
}
}
// skip
if (ref_gt_list.empty()) return;
// sort by op id
std::sort(ref_gt_list.begin(), ref_gt_list.end(),
[](const graph_tensor *gt1, const graph_tensor *gt2) {
return gt1->producer_owner_->logical_op_id_
> gt2->producer_owner_->logical_op_id_;
});
std::unordered_set<expr> replaced_buffer, visited_buffer;
for (auto &ref_gt : ref_gt_list) {
// auto skip
if (replaced_buffer.find(g2b_map_.get(ref_gt)) != replaced_buffer.end())
continue;
// step 2: collect inplace mapping for each gt
std::unordered_set<graph_tensor *> inplace_gt_set;
collect_inplace_info(ref_gt, ref_gt, inplace_gt_set, visited_buffer,
valid_set, this, /*init_step*/ 0);
if (inplace_gt_set.empty()) continue;
// step 3: transform map to vector sorted by op committing order
std::vector<graph_tensor *> inplace_gt_list;
for (auto &commit_op : binded_mxp_->committed_ops_) {
if (commit_op.get() == ref_gt->producer_owner_) {
inplace_gt_list.emplace_back(ref_gt);
} else {
for (auto &out : commit_op->get_outputs()) {
if (inplace_gt_set.find(out.get())
!= inplace_gt_set.end()) {
inplace_gt_list.emplace_back(out.get());
}
}
}
}
// step 4: validate inplace chain to ensure all of gt satisfy last use
graph_tensor *next_gt = nullptr;
for (auto iter = inplace_gt_list.rbegin();
iter != inplace_gt_list.rend();) {
if (!next_gt)
next_gt = (*iter);
else {
if (check_last_use_for_gt(*iter, next_gt, this)) {
next_gt = (*iter);
} else {
iter = std::vector<graph_tensor *>::reverse_iterator(
inplace_gt_list.erase((++iter).base()));
continue;
}
}
++iter;
}
// step 5: mark inplace attr for each buffer in list with the previous
// one
for (size_t i = 1; i < inplace_gt_list.size(); i++) {
// get target gt
auto target_gt = inplace_gt_list[i - 1];
auto target_buf = g2b_map_.get(target_gt);
// get inplace gt
auto inplace_gt = inplace_gt_list[i];
auto inplace_buf = g2b_map_.get(inplace_gt);
// skip repeated replaced
if (replaced_buffer.find(inplace_buf) != replaced_buffer.end())
continue;
// set inplace hint
set_buffer_inplace_hint(target_buf, inplace_buf);
// in avoid of repeat try
replaced_buffer.insert(inplace_buf);
}
}
}
void mxp_buffer_allocator::calibrate_info() {
// collect cut buffer
std::unordered_set<expr> cut_buffer_set;
for (auto iter = inplace_map_.begin(); iter != inplace_map_.end();) {
auto out_buf = ((expr_base *)iter->first)->node_ptr_from_this();
if (!out_buf->attr().has_key(mixed_partition_hint::cut_buffer)) {
++iter;
continue;
}
// temp buffer set
std::unordered_set<expr> temp_set;
// record whether tensorptr would be inplaced by cut buffer
bool inplace_tptr = false;
auto buf = out_buf;
while (buf.defined()) {
// if tensorptr found
if (buf.isa<tensorptr>()) {
inplace_tptr = true;
break;
}
temp_set.insert(buf);
buf = get_inplaced_buffer(buf);
}
if (!inplace_tptr) {
// remove tensor shrink attr for those shared with cut buffer
for (auto &tb : temp_set) {
tb->attr().remove(tensor_shrinker_attrs::should_shrink);
}
cut_buffer_set.insert(temp_set.begin(), temp_set.end());
++iter;
} else {
// cut off inplace hint for the output buffer
out_buf->attr().remove(attr_keys::tensor_inplace_hint);
// remove inplace map
iter = inplace_map_.erase(iter);
}
}
// validate inplace hint for shrink info
for (auto iter = inplace_map_.begin(); iter != inplace_map_.end();) {
auto buf1 = ((expr_base *)iter->first)->node_ptr_from_this();
auto buf2 = get_inplaced_buffer(buf1);
// auto skip cut buffer
if (cut_buffer_set.find(buf1) != cut_buffer_set.end()) {
COMPILE_ASSERT(cut_buffer_set.find(buf2) != cut_buffer_set.end(),
"inplaced buffer should also be set cut buffer")
++iter;
} else {
auto shrink_info1 = get_shrinked_info(buf1);
auto shrink_info2 = get_shrinked_info(buf2);
// if shrink info is not equal, remove inplace hint
if ((shrink_info1.empty() ^ shrink_info2.empty())
|| (!shrink_info1.empty() && !shrink_info2.empty()
&& cmp_slice_range({shrink_info1}, {shrink_info2})
!= cmp_res::equal)) {
SC_MODULE_INFO << "removing tensor inplace hint: " << buf1
<< " ==> " << buf2 << " for safety";
// remove inplace hint to ensure correctness
buf1->attr().remove(attr_keys::tensor_inplace_hint);
// remove inplace map
iter = inplace_map_.erase(iter);
} else {
++iter;
}
}
}
}
inline bool check_tsr_len_under_resigter_size(
size_t tsr_len, uint16_t simd_len, uint16_t max_register_tol = 16) {
return (tsr_len % simd_len == 0 && (tsr_len / simd_len) < max_register_tol);
}
bool mxp_buffer_allocator::validate_tsr2var() const {
for (auto &tsr2def : tsr2anch_map_) {
auto tsr = tsr2def.first;
if (!tsr->attr().has_key(attr_keys::must_tensor2var)) continue;
auto shrinked_info = get_shrinked_info(tsr);
if (shrinked_info.empty()) continue;
auto shape = get_slice_shape(shrinked_info);
auto prod = get_dims_product(get_expr_to_dims(shape));
auto tsr_simd_len = vectorize_step(binded_mxp_->ctx_,
tsr.checked_as<tensor>()->elem_dtype_.type_code_);
if (!check_tsr_len_under_resigter_size(prod, tsr_simd_len))
return false;
}
return true;
}
int mxp_buffer_allocator::use_count(const expr &buffer) const {
int cnt = 0;
for (auto &g2b : g2b_map_.datamap_) {
if (g2b.second.ptr_same(buffer)) cnt++;
}
return cnt;
}
fuse_anchor_map_ptr mxp_buffer_allocator::get_real_anchor_for_buffer(
const expr &buffer) const {
auto tsr = get_real_tensor(buffer);
if (tsr2anch_map_.find(tsr) == tsr2anch_map_.end()) return nullptr;
auto anch = tsr2anch_map_.find(tsr)->second;
auto parent_loop = anch->get_parent_loop();
// use outer anchor for cases that calculation is partially done. (e.g.
// calculating part of K for matmul)
if ((b2g_map_.find(tsr) == b2g_map_.end()
|| b2g_map_.find(tsr)
->second->producer_owner_->isa<tunable_op_t>())
&& parent_loop.isa<for_loop>()
&& parent_loop->attr().has_key(stmt_attr_key::reduce_root_loop)) {
auto raw = parent_loop->attr()
.get<std::weak_ptr<stmt_base_t>>(
stmt_attr_key::reduce_root_loop)
.lock();
COMPILE_ASSERT(raw, "reduce_root_loop weak ptr invalidated");
anch = binded_mxp_->get_anchor_inside_loop(
stmt(raw).checked_as<for_loop>());
COMPILE_ASSERT(anch,
"No anchor found under reduce root loop, please create it "
"otherwise, it may cause correctness issue")
}
return anch;
}
slice_range mxp_buffer_allocator::get_shrinked_info(const expr &buffer) const {
auto anchor = get_real_anchor_for_buffer(buffer);
if (!anchor) return {};
COMPILE_ASSERT(b2g_map_.find(buffer) != b2g_map_.end(),
"Could not find " << buffer << " in b2g map");
slice_range ret;
auto range_list = anchor->fsmap_.get(b2g_map_.find(buffer)->second);
if (range_list.size() != 1) {
if (range_list.empty()
|| !(anchor->isa<fuse_iter_anchor_map_t>()
|| anchor->isa<fuse_grouped_anchor_map_t>()))
return {};
else
ret = *std::max_element(range_list.begin(), range_list.end(),
[&](const slice_range &A, const slice_range &B) {
return cmp_slice_range({A}, {B}) == cmp_res::l_less_r;
});
} else {
ret = range_list[0];
}
return ret;
}
void mxp_buffer_allocator::declare_tensor() const {
// define real tensor, and put it at the `def_pos` of ss
auto declare_tensor_ = [&](const expr &tsr) {
auto fanchor = get_real_anchor_for_buffer(tsr);
if (!fanchor) return;
// search insert position in scope of fusion anchor
auto &ss = fanchor->get_parent_scope()->seq_;
size_t def_pos = 0;
for (; def_pos < ss.size(); def_pos++) {
// skip var def node
if (!ss[def_pos].cast<define>()
.filter([](const define &d) {
return d->var_.isa<var>();
})
.has_value())
break;
}
ss.emplace(ss.begin() + def_pos,
builder::make_var_tensor_def_unattached(tsr));
};
for (auto &tsr2def : tsr2anch_map_) {
if (tsr2def.first->attr().has_key(mixed_partition_hint::cut_buffer))
continue;
declare_tensor_(tsr2def.first);
}
}
void mxp_buffer_allocator::set_shrink_info() const {
// set shrink info
auto set_shrink_info_ = [&](const expr &buffer) {
auto shrink_range = get_shrinked_info(buffer);
if (shrink_range.empty()) return;
buffer->attr()[tensor_shrinker_attrs::should_shrink]
= tensor_shrinker_t::shrink_info_t {
/*base*/ get_slice_idx(shrink_range),
/*shape*/ get_slice_shape(shrink_range), stmts()};
};
for (auto &buf2shr : b2g_map_) {
if (buf2shr.first->attr().has_key(mixed_partition_hint::cut_buffer))
continue;
set_shrink_info_(buf2shr.first);
}
}
std::vector<memory_optim::memory_alloc_trace_t> merge_mem_trace(
const std::vector<memory_optim::memory_alloc_trace_t> &mem_trace1,
const std::vector<memory_optim::memory_alloc_trace_t> &mem_trace2,
const std::unordered_map<expr, expr> &buffer_map) {
auto ret = mem_trace1;
for (auto &trace : mem_trace2) {
auto tsr = ((expr_base *)trace.buffer_id_)->node_ptr_from_this();
auto trace_itr = buffer_map.find(tsr);
bool is_replaced = trace_itr != buffer_map.end();
auto buf_id = is_replaced ? (uintptr_t)(trace_itr->second.get())
: trace.buffer_id_;
if (trace.size_ > 0) {
auto last_use = std::find_if(ret.begin(), ret.end(),
[&buf_id](const memory_optim::memory_alloc_trace_t &tr) {
return (tr.buffer_id_ == buf_id) && (tr.size_ == 0);
});
if (last_use != ret.end()) {
ret.erase(last_use);
continue;
}
}
if (is_replaced) {
ret.emplace_back(
memory_optim::memory_alloc_trace_t {buf_id, trace.size_});
} else {
ret.emplace_back(trace);
}
}
return ret;
}
memory_optim::inplace_info_map merge_inplace_map(
const memory_optim::inplace_info_map &inplace_map1,
const memory_optim::inplace_info_map &inplace_map2,
const std::unordered_map<expr, expr> &buffer_map) {
auto ret = inplace_map1;
for (auto &inplace_pair : inplace_map2) {
COMPILE_ASSERT(inplace_pair.second.size() == 1,
"Unexpected inplace info size during partition")
memory_optim::inplace_info info = inplace_pair.second[0];
auto tsr = ((expr_base *)info.first)->node_ptr_from_this();
auto iter = buffer_map.find(tsr);
ret[inplace_pair.first]
= std::vector<std::pair<uintptr_t, inplace_kind>> {
{iter != buffer_map.end()
? (uintptr_t)iter->second.get()
: info.first,
info.second}};
}
return ret;
}
mxp_mem_info merge_real_mem_info(const mxp_buffer_allocator &alloc1,
const mxp_buffer_allocator &alloc2) {
// get buffer replace map
std::unordered_map<expr, expr> buffer_map;
std::unordered_set<graph_tensor *> keep_cut_set;
for (auto &g2b : alloc2.g2b_map_.datamap_) {
auto gt = g2b.first;
if (alloc1.g2b_map_.haskey(gt)) {
buffer_map[g2b.second] = alloc1.g2b_map_.datamap_.find(gt)->second;
if (alloc1.get_binded_mxp()->is_parti_out(gt)
&& alloc2.get_binded_mxp()->is_parti_inp(gt)) {
keep_cut_set.insert(gt);
}
}
}
return std::make_pair(
merge_mem_trace(alloc1.get_real_mem_trace(keep_cut_set),
alloc2.get_real_mem_trace(keep_cut_set), buffer_map),
merge_inplace_map(
alloc1.inplace_map_, alloc2.inplace_map_, buffer_map));
}
void mxp_buffer_allocator::merge(mxp_buffer_allocator &other,
std::unordered_map<expr, expr> &buffer_map,
const std::pair<fuse_anchor_map_ptr, fuse_anchor_map_ptr>
&common_buffer_anchor_pair) {
buffer_map.clear();
auto common_buffer_anchor = common_buffer_anchor_pair.first,
common_other_buffer_anchor = common_buffer_anchor_pair.second;
for (auto &other_g2b : other.g2b_map_.datamap_) {
auto other_gt = other_g2b.first;
// if other tensor has conflict in current tensor, redirect it to common
// buffer anchor
if (g2b_map_.haskey(other_gt)) {
auto existed_buf = g2b_map_.get(other_gt);
buffer_map[other_g2b.second] = existed_buf;
if ((binded_mxp_->is_parti_inp(other_gt)
&& other.binded_mxp_->is_parti_inp(other_gt))
|| (binded_mxp_->is_parti_out(other_gt)
&& other.binded_mxp_->is_parti_out(other_gt)))
continue;
COMPILE_ASSERT(common_buffer_anchor,
"Conflict buffer: "
<< existed_buf
<< " is detected but no common buffer anchor "
"is found for redirection")
tsr2anch_map_[get_real_tensor(existed_buf)] = common_buffer_anchor;
// the existed buffer will become intermediate buffer, which may be
// shrinked
if (b2g_map_.find(existed_buf) == b2g_map_.end()) {
b2g_map_[existed_buf] = other_gt->shared_from_this();
}
} else {
auto buffer = other.g2b_map_.get(other_gt);
g2b_map_.get(other_gt) = buffer;
if (other.b2g_map_.find(buffer) != other.b2g_map_.end()) {
b2g_map_[buffer] = other.b2g_map_[buffer];
}
if (other.tsr2anch_map_.find(get_real_tensor(buffer))
!= other.tsr2anch_map_.end()) {
auto other_anchor
= other.tsr2anch_map_[get_real_tensor(buffer)];
tsr2anch_map_[get_real_tensor(buffer)]
= (other_anchor == common_other_buffer_anchor)
? common_buffer_anchor
: other_anchor;
}
}
}
// merge mem trace
mem_trace_ = merge_mem_trace(mem_trace_, other.mem_trace_, buffer_map);
// merge inplace map
inplace_map_
= merge_inplace_map(inplace_map_, other.inplace_map_, buffer_map);
}
void mxp_buffer_allocator::clear() {
binded_mxp_ = nullptr;
g2b_map_.clear();
tsr2anch_map_.clear();
b2g_map_.clear();
mem_trace_.clear();
}
void outerloop_axis_binder::run(int real_axis_size) {
// reset
reset();
if (!base_gt_ || init_axis_.empty()) return;
// set start node
bd_ax_map_.get(base_gt_) = bound_axis {init_axis_.begin(),
init_axis_.begin()
+ std::min(static_cast<int64_t>(real_axis_size),
static_cast<int64_t>(init_axis_.size()))};
// call start node user recursively infer binding axis
COMPILE_ASSERT(
!base_gt_->uses_.empty(), "no user found for base graph tensor")
for (auto &user : base_gt_->uses_) {
auto user_op = user.second;
if (!user_op->isa<output_op>()) {
COMPILE_ASSERT(
user_op->isa<op_traits::mixed_partition_acceptable>(),
user_op->op_name_
<< " is not mixed partition acceptable op")
user_op->dyn_cast<op_traits::mixed_partition_acceptable>()
->infer_binding_axis(bd_ax_map_);
break;
}
}
}
int outerloop_axis_binder::align_with(
outerloop_axis_binder &other, int check_axis_size) {
// start running auto-infer binding axis
run(check_axis_size);
other.run(check_axis_size);
bound_axis cur_axis, other_axis;
if (bd_ax_map_.haskey(base_gt_) && other.bd_ax_map_.haskey(base_gt_)) {
cur_axis = bd_ax_map_.get(base_gt_);
other_axis = other.bd_ax_map_.get(base_gt_);
} else if (bd_ax_map_.haskey(other.base_gt_)
&& other.bd_ax_map_.haskey(other.base_gt_)) {
cur_axis = bd_ax_map_.get(other.base_gt_);
other_axis = other.bd_ax_map_.get(other.base_gt_);
} else {
SC_MODULE_INFO
<< "Could not validate axis due to no binding hint found";
return 0;
}
COMPILE_ASSERT(!cur_axis.empty() && !other_axis.empty(),
"binding axis could not be empty, but got "
<< utils::print_nested_vector(cur_axis) << " and "
<< utils::print_nested_vector(other_axis))
COMPILE_ASSERT(check_axis_size <= static_cast<int64_t>(cur_axis.size())
&& check_axis_size
<= static_cast<int64_t>(other_axis.size()),
"check axis size should not be larger than binding axis size, but "
"got " << check_axis_size
<< " for " << utils::print_nested_vector(cur_axis) << " and "
<< utils::print_nested_vector(other_axis))
int aligned_num = 0;
for (int i = 0; i < check_axis_size; i++) {
if (cur_axis[i] == other_axis[i])
aligned_num++;
else
break;
}
return aligned_num;
}
void extract_anchor_from_fmgr_to_parti(fusion_manager *fmgr,
mixed_parti_t *parti, std::vector<expr> ir_tsrs,
std::vector<graph_tensor_ptr> gtsrs,
const fuse_anchor_map_ptr &parent_fanchor) {
COMPILE_ASSERT(ir_tsrs.size() == gtsrs.size(),
"IR tensor-to-graph tensor mapping is not expected")
// extract input anchor
for (auto &anchor_map : fmgr->unpack_dst_anchor()) {
fslice_map fsmap;
for (size_t i = 0; i < ir_tsrs.size(); i++) {
if (anchor_map.second.find(ir_tsrs[i]) != anchor_map.second.end()) {
fsmap.get(gtsrs[i])
= anchor_map.second.find(ir_tsrs[i])->second;
}
}
if (!fsmap.empty()) {
parti->append_fusion_anchor(std::make_shared<fuse_anchor_map_t>(
anchor_map.first, fsmap, parent_fanchor, true));
}
}
// extract output anchor
for (auto &anchor_map : fmgr->unpack_src_anchor()) {
fslice_map fsmap;
for (size_t i = 0; i < ir_tsrs.size(); i++) {
if (anchor_map.second.find(ir_tsrs[i]) != anchor_map.second.end()) {
fsmap.get(gtsrs[i])
= anchor_map.second.find(ir_tsrs[i])->second;
// usually used for extract tunable op inner anchor, due to
// current template style, it need to handle fsmap base offset
if (parent_fanchor) {
COMPILE_ASSERT(parent_fanchor->fsmap_.haskey(gtsrs[i])
&& parent_fanchor->fsmap_.get(gtsrs[i])
.size()
== 1,
"inherited fsmap should have recorded current gt "
"single "
"slice range")
auto inherited_slice_range
= parent_fanchor->fsmap_.get(gtsrs[i])[0];
auto inherited_offset
= get_slice_idx(inherited_slice_range);
size_t outer_anchor_loop_size = 0;
for (auto &off : inherited_offset) {
if (!off.isa<constant_c>()
|| get_expr_as_int(off) != 0) {
outer_anchor_loop_size++;
} else {
break;
}
}
auto &cur_slice_range_list = fsmap.get(gtsrs[i]);
for (auto &cur_slice_range : cur_slice_range_list) {
COMPILE_ASSERT(cur_slice_range.size()
>= outer_anchor_loop_size,
"inner anchor range should be larger than "
"outer anchor loop size")
for (size_t i = 0; i < outer_anchor_loop_size; i++) {
cur_slice_range[i].first = cur_slice_range[i].first
+ inherited_slice_range[i].first;
}
}
}
}
}
if (!fsmap.empty()) {
parti->append_fusion_anchor(std::make_shared<fuse_anchor_map_t>(
anchor_map.first, fsmap, parent_fanchor));
}
}
// extract output iterated anchor
if (!fmgr->iter_anchor_list_.empty()) {
for (auto &iter_anchor : fmgr->iter_anchor_list_) {
fslice_map fsmap;
for (size_t i = 0; i < ir_tsrs.size(); i++) {
if (iter_anchor.tsr_.ptr_same(ir_tsrs[i])) {
fsmap.get(gtsrs[i]) = iter_anchor.slice_list_;
}
}
if (!fsmap.empty()) {
parti->append_fusion_anchor(
std::make_shared<fuse_iter_anchor_map_t>(
iter_anchor.iter_, iter_anchor.anchor_position_,
fsmap, iter_anchor.dispatch_helper_));
}
}
}
// extract output grouped anchor
if (!fmgr->grouped_anchor_map_.empty()) {
for (auto &grouped_anchor_map_ : fmgr->grouped_anchor_map_) {
auto grouped_anchor = grouped_anchor_map_.second;
// extract anchor position
auto anchor_ss = std::move(grouped_anchor.anchor_position_);
// extract anchor fsmap
auto anchor_es_map = grouped_anchor.expr_slice_map_;
fslice_map fsmap;
for (size_t i = 0; i < ir_tsrs.size(); i++) {
auto iter = anchor_es_map.find(ir_tsrs[i]);
if (iter != anchor_es_map.end()) {
fsmap.get(gtsrs[i]) = std::move(iter->second);
}
}
if (!fsmap.empty()) {
parti->append_fusion_anchor(
std::make_shared<fuse_grouped_anchor_map_t>(
anchor_ss, fsmap));
}
}
}
}
void search_op_anchor_in_parti(sc_op *op, mixed_parti_t *parti) {
if (parti->merged_to) {
search_op_anchor_in_parti(op, parti->get_root());
return;
}
for (auto &fanchor : parti->fanchors_) {
// if op is marked as break_pre_fuse, only pre-op fusion is accepted
if (!parti->empty()
&& op->attrs_.get_or_else(
mixed_partition_hint::pre_fuse_begin_op, false)) {
if (fanchor->fsmap_.hasvalue(op->get_outputs()[0])) {
parti->set_anchor_for_op(op, fanchor);
}
// in avoid of preop fusion select unexpected anchor
continue;
}
infer_status_map_t stat_map(parti->ctx_, false);
std::unordered_set<graph_tensor_ptr> known_gt;
// deal with fusible op which use output loop mode to create partition
if (parti->empty()
&& std::any_of(op->get_outputs().begin(),
op->get_outputs().end(),
[&fanchor](const graph_tensor_ptr >) {
return fanchor->fsmap_.haskey(gt);
})) {
COMPILE_ASSERT(op->isa<fusible_op_t>(),
"Only fusible op is expected, but got " << op->op_name_)
// use pre-infer slice range method
op->dyn_cast<fusible_op_t>()->pre_slice_ranges(
fanchor->fsmap_, stat_map);
} else { /* most common cases */
// check input slice firstly
if (!fanchor->check_input_for_op(op, known_gt)) continue;
// TODO(XXX): merge
if (auto fusible = op->dyn_cast<fusible_op_t>()) {
fusible->infer_slice_ranges(fanchor->fsmap_, stat_map);
} else if (auto tunable = op->dyn_cast<tunable_op_t>()) {
tunable->infer_slice_ranges(fanchor->fsmap_, stat_map);
} else {
COMPILE_ASSERT(0, "Unexpected op type found: " << op->op_name_)
}
}
bool success_flag = true;
// check status map
if (stat_map.is_ok()) {
/** doule check list
* 1. validate input slice
* 2. validate output slice
* 3. check cost model
* */
success_flag = fanchor->validate_input_for_op(op, known_gt)
&& fanchor->validate_output_for_op(op)
&& parti->cost_->make_decision_for_op(op, fanchor);
}
// TODO(yunfei): remove this check when old fmgr is totally deprecated
else if (stat_map.is_fail()) {
auto &fail_list
= stat_map.get_ops_by_status(infer_status_code::FAIL);
success_flag = (fail_list.find(op->shared_from_this())
== fail_list.end());
} else {
success_flag = false;
}
if (success_flag) {
// set op anchor, and auto select smallest one
parti->set_anchor_for_op(op, fanchor);
} else {
// forbid op in current anchor
fanchor->forbid_op(op, known_gt);
}
}
}
static std::string print_loops_range(const std::vector<for_loop> &loops) {
std::stringstream os;
int cnt = 0;
for (auto &l : loops) {
if (cnt != 0) { os << "X"; }
if (l->iter_begin_.isa<constant>() && l->iter_end_.isa<constant>()) {
os << (get_expr_as_int(l->iter_end_)
- get_expr_as_int(l->iter_begin_));
} else {
os << "var";
}
cnt++;
}
return os.str();
}
enum class parti_dep : int {
no_dep = 0,
l_dep_r = 1,
r_dep_l = 2,
inter_dep = 3,
};
/**
* Check two partition dependency
* */
static parti_dep check_parti_dep(mixed_parti_t *A, mixed_parti_t *B) {
A = A->get_root(), B = B->get_root();
auto dep_m = A->dep_m_;
auto A_ops = A->ops, B_ops = B->ops;
bool A_dep_B = false, B_dep_A = false;
for (auto &op_a : A_ops) {
for (auto &op_b : B_ops) {
auto dep_flag = dep_m->lookup(op_a, op_b);
if (dep_flag == 1)
B_dep_A = true;
else if (dep_flag == -1)
A_dep_B = true;
}
}
if (A_dep_B && !B_dep_A) {
return parti_dep::l_dep_r;
} else if (B_dep_A && !A_dep_B) {
return parti_dep::r_dep_l;
} else if (!A_dep_B && !B_dep_A) {
return parti_dep::no_dep;
} else {
return parti_dep::inter_dep;
}
}
/**
* Check two partition connectionship
* */
static bool check_parti_connectionship(mixed_parti_t *A, mixed_parti_t *B) {
A = A->get_root(), B = B->get_root();
auto A_ops = A->ops, B_ops = B->ops;
for (auto &op_a : A_ops) {
std::unordered_set<graph_tensor_ptr> gt_set;
std::for_each(op_a->get_inputs().begin(), op_a->get_inputs().end(),
[>_set](const graph_tensor_ptr >) { gt_set.insert(gt); });
std::for_each(op_a->get_outputs().begin(), op_a->get_outputs().end(),
[>_set](const graph_tensor_ptr >) { gt_set.insert(gt); });
for (auto &op_b : B_ops) {
for (auto &inp : op_b->get_inputs()) {
if (gt_set.find(inp) != gt_set.end()) return true;
}
for (auto &out : op_b->get_outputs()) {
if (gt_set.find(out) != gt_set.end()) return true;
}
}
}
return false;
}
/**
* Check two partition ring risk
* */
static bool check_parti_ring_risk(mixed_parti_t *A, mixed_parti_t *B) {
A = A->get_root(), B = B->get_root();
auto dep = check_parti_dep(A, B);
if (dep == parti_dep::inter_dep)
return true;
else if (dep == parti_dep::no_dep)
return false;
auto append_parti = (dep == parti_dep::l_dep_r) ? A : B,
target_parti = (dep == parti_dep::l_dep_r) ? B : A;
auto append_ops = append_parti->ops;
for (auto &op_a : append_ops) {
for (auto &inp : op_a->get_inputs()) {
if (append_parti->is_parti_inp(inp)
&& !target_parti->contains(inp->producer_owner_)) {
for (auto &op_in_set : target_parti->ops) {
auto result = target_parti->dep_m_->lookup(
op_in_set->logical_op_id_,
inp->producer_owner_->logical_op_id_);
if (result == 1) { return true; }
}
}
}
}
return false;
}
static stmts find_last_parallel_for(const stmts &scope, int64_t &out_index) {
auto &outer_body = scope.static_as<stmts>()->seq_;
int64_t prefetch_insertion_point = -1;
if (!outer_body.empty()) {
for (int64_t i = outer_body.size() - 1; i >= 0; i--) {
auto &s = outer_body[i];
if (s.isa<stmts>()) {
auto ret = find_last_parallel_for(
s.static_as<stmts>(), out_index);
if (ret.defined()) { return ret; }
}
if (s.cast<for_loop>()
.filter([](const for_loop &v) {
return v->kind_ == for_type::PARALLEL
&& (!v->attr_
|| !v->attr_->get_or_else(
"dont_prefetch",
false));
})
.has_value()) {
out_index = i;
return scope;
}
}
}
return stmts();
}
/**
* Check two partition is forked, like
* input
* / \
* parti A parti B
* | |
* output output
* Note that: this is different relationship from no dependency
* */
static bool check_parti_forked(mixed_parti_t *A, mixed_parti_t *B) {
A = A->get_root(), B = B->get_root();
auto dep_m = A->dep_m_;
// for all op depends on A, should not depends on B
for (auto &op_in_A : A->ops) {
auto A_id = op_in_A->logical_op_id_;
auto related_ids = dep_m->lookup_ops_depend_on(A_id);
for (auto &op_in_B : B->ops) {
auto B_id = op_in_B->logical_op_id_;
if (std::any_of(related_ids.begin(), related_ids.end(),
[&B_id, &dep_m](const int &rid) {
return dep_m->lookup(B_id, rid) == 1;
})) {
return false;
}
}
}
return true;
}
/**
* Check two partition axis binding
* */
static int check_parti_loop_axis_binding(
mixed_parti_t *A, mixed_parti_t *B, int check_loop_size) {
A = A->get_root();
B = B->get_root();
// skip conv workload until all conv ops implement axis binding infer
if (A->contain_convolution() || B->contain_convolution()) {
// limit to at most one outer loop (batch-dimension)
return std::min(1, check_loop_size);
}
// auto skip when A and B are forked
if (check_parti_forked(A, B)) return check_loop_size;
return A->ax_binder_.align_with(B->ax_binder_, check_loop_size);
}
static void merge_parti_impl(mixed_parti_t *pa_to_merge,
mixed_parti_t *parti_be_merged, size_t merged_loop_size,
const sc_op_ptr &joint_op = nullptr) {
pa_to_merge = pa_to_merge->get_root(),
parti_be_merged = parti_be_merged->get_root();
auto outer_loops_to_merge = pa_to_merge->get_outer_loops(),
outer_loops_be_merged = parti_be_merged->get_outer_loops();
auto outer_loops_merged_target = outer_loops_to_merge[merged_loop_size - 1];
auto outer_loops_merged_append
= outer_loops_be_merged[merged_loop_size - 1];
auto max_to_merge_anchor_map
= pa_to_merge->get_anchor_inside_loop(outer_loops_merged_target);
auto max_be_merged_anchor_map = parti_be_merged->get_anchor_inside_loop(
outer_loops_merged_append);
/* * * * * * * * * * * * * * * * *
* Step 1: Merge func_
* * * * * * * * * * * * * * * * */
COMPILE_ASSERT(
max_to_merge_anchor_map, "max-to-merge fusion anchor not found")
max_to_merge_anchor_map->fuse_anchor_map_t::commit_stmt(
outer_loops_merged_append->body_);
// var and tensor replace map
node_ptr_map node_remap;
std::unordered_map<expr, expr> buffer_map;
/* * * * * * * * * * * * * * * * *
* Step 2: Merge fanchor_
* * * * * * * * * * * * * * * * */
// erase inferred but not allocated gt
for (auto &to_merge_anchor_map : pa_to_merge->fanchors_) {
for (auto iter = to_merge_anchor_map->fsmap_.datamap_.begin();
iter != to_merge_anchor_map->fsmap_.datamap_.end();) {
if (!pa_to_merge->buf_alloc_.g2b_map_.haskey(iter->first)) {
iter = to_merge_anchor_map->fsmap_.datamap_.erase(iter);
} else {
iter++;
}
}
}
for (auto &be_merged_anchor_map : parti_be_merged->fanchors_) {
for (auto iter = be_merged_anchor_map->fsmap_.datamap_.begin();
iter != be_merged_anchor_map->fsmap_.datamap_.end();) {
if (!parti_be_merged->buf_alloc_.g2b_map_.haskey(iter->first)) {
iter = be_merged_anchor_map->fsmap_.datamap_.erase(iter);
} else {
iter++;
}
}
}
// append inner loop anchor
for (auto &be_merged_anchor_map : parti_be_merged->fanchors_) {
// skip outer anchor
if (std::any_of(outer_loops_be_merged.begin(),
outer_loops_be_merged.begin() + merged_loop_size,
[&be_merged_anchor_map, &parti_be_merged](
const for_loop &loop) {
return parti_be_merged->get_anchor_inside_loop(loop,
be_merged_anchor_map->is_input_anchor())
== be_merged_anchor_map;
})) {
continue;
}
be_merged_anchor_map->attach_parent_anchor(
max_to_merge_anchor_map, max_be_merged_anchor_map);
pa_to_merge->append_fusion_anchor(be_merged_anchor_map);
}
// merge outer loop anchor
for (size_t i = 0; i < merged_loop_size; i++) {
node_remap[outer_loops_be_merged[i]->var_.impl]
= outer_loops_to_merge[i]->var_.impl;
node_remap[outer_loops_be_merged[i].impl]
= outer_loops_to_merge[i].impl;
auto be_merged_anchor_map = parti_be_merged->get_anchor_inside_loop(
outer_loops_be_merged[i]),
to_merge_anchor_map
= pa_to_merge->get_anchor_inside_loop(outer_loops_to_merge[i]);
if (be_merged_anchor_map && to_merge_anchor_map) {
to_merge_anchor_map->merge(be_merged_anchor_map);
// reset op anchor map if neccesary
if (i == merged_loop_size - 1) {
for (auto &op_anchor_pair : parti_be_merged->op_anchor_map_) {
if (op_anchor_pair.second == be_merged_anchor_map) {
op_anchor_pair.second = to_merge_anchor_map;
}
}
}
}
}
/* * * * * * * * * * * * * * * * *
* Step 3: Merge buf_alloc_
* * * * * * * * * * * * * * * * */
pa_to_merge->buf_alloc_.merge(parti_be_merged->buf_alloc_, buffer_map,
std::make_pair(max_to_merge_anchor_map, max_be_merged_anchor_map));
/* * * * * * * * * * * * * * * * * *
* Step 4: Replace expr involving:
* 1. func->body
* 2. fanchor->fsmap->slice_range
* * * * * * * * * * * * * * * * * */
for (auto &buf_pair : buffer_map) {
node_remap.insert(
std::make_pair(buf_pair.first.impl, buf_pair.second.impl));
}
// create mxp inplace replacer
mxp_replacer_t mxp_reper(node_remap);
// 1. func->body
mxp_reper.replace_func(pa_to_merge->func_);
// 2. fanchor->fsmap->slice_range
mxp_reper.replace_anchor(pa_to_merge->fanchors_);
/* * * * * * * * * * * * * * * * *
* Step 5: Merge op_anchor_map_
* * * * * * * * * * * * * * * * */
for (auto &op_anchor_pair : parti_be_merged->op_anchor_map_) {
// override existed ones
pa_to_merge->op_anchor_map_[op_anchor_pair.first]
= op_anchor_pair.second;
}
// erase joint op in op_anchor_map
pa_to_merge->op_anchor_map_.erase(joint_op.get());
/* * * * * * * * * * * * * * * * *
* Step 6: Merge op_
* * * * * * * * * * * * * * * * */
// call base merge
// move 'ops' from src to target and set 'merged_to' of src to be target
pa_to_merge->fusion_partition_t::merge(
static_cast<fusion_partition_t *>(parti_be_merged)
->shared_from_this());
// Merge commited ops
pa_to_merge->committed_ops_.insert(pa_to_merge->committed_ops_.end(),
parti_be_merged->committed_ops_.begin(),
parti_be_merged->committed_ops_.end());
// clear merged parti
parti_be_merged->clear();
}
static size_t get_great_common_loop_size(const std::vector<for_loop> &loop_A,
const std::vector<for_loop> &loop_B) {
// great common size
auto gcs = std::min(loop_A.size(), loop_B.size());
size_t merged_loop_size = 0;
for (; merged_loop_size < gcs; merged_loop_size++) {
auto &to_merge = loop_A[merged_loop_size];
auto &be_merged = loop_B[merged_loop_size];
if (!(to_merge->iter_begin_.isa<constant_c>()
&& to_merge->step_.isa<constant_c>()
&& be_merged->iter_begin_.isa<constant_c>()
&& be_merged->step_.isa<constant_c>())) {
break;
}
if (!to_merge->iter_end_.isa<constant_c>()
&& slice_expr_equals(
to_merge->iter_end_, be_merged->iter_end_)) {
continue; // for dynamic
} else if (!(to_merge->iter_end_.isa<constant_c>()
&& be_merged->iter_end_.isa<constant_c>())) {
break;
}
auto A_begin = get_expr_as_int(to_merge->iter_begin_),
A_end = get_expr_as_int(to_merge->iter_end_),
A_step = get_expr_as_int(to_merge->step_),
B_begin = get_expr_as_int(be_merged->iter_begin_),
B_end = get_expr_as_int(be_merged->iter_end_),
B_step = get_expr_as_int(be_merged->step_);
auto A_num_threads = to_merge->num_threads_;
auto B_num_threads = be_merged->num_threads_;
if (A_begin != B_begin || A_end != B_end || A_step != B_step
|| A_num_threads != B_num_threads)
break;
}
return merged_loop_size;
}
static bool try_merge_mixed_parti_parallel_inners(
mixed_parti_t *pa_to_merge, mixed_parti_t *parti_be_merged) {
pa_to_merge = pa_to_merge->get_root(),
parti_be_merged = parti_be_merged->get_root();
auto outer_loops_to_merge = pa_to_merge->get_outer_loops(),
outer_loops_be_merged = parti_be_merged->get_outer_loops();
if (outer_loops_to_merge.empty() || outer_loops_be_merged.empty())
return false;
auto merged_loop_size = get_great_common_loop_size(
outer_loops_to_merge, outer_loops_be_merged);
if (!merged_loop_size) return false; // no outer loop can be merged
// validate axis binding
merged_loop_size = check_parti_loop_axis_binding(
parti_be_merged, pa_to_merge, merged_loop_size);
SC_MODULE_INFO << "After axis binding, num loops to merge: "
<< merged_loop_size;
if (!merged_loop_size) return false; // no outer loop can be merged
// change the loop var name of the first for.
// first for: for m_s, for n_s. second for: for m_s_o, m_s_i, n_s.
// merge directly: for m_s, for n_s, for n_s.
// add suffix and merge: for m_s_0, for n_s_0, for n_s.
for (size_t i = 0; i < merged_loop_size; ++i) {
std::string &varname
= outer_loops_to_merge[i]->var_.static_as<var>()->name_;
varname += "_0";
}
SC_MODULE_INFO << "parallel merging two partition:";
SC_MODULE_INFO << pa_to_merge->func_;
SC_MODULE_INFO << parti_be_merged->func_;
if (check_parti_dep(pa_to_merge, parti_be_merged) == parti_dep::no_dep) {
auto last_for = get_last_loop_in_body(
outer_loops_to_merge[merged_loop_size - 1]->body_);
if (last_for.defined()) {
last_for->attr()[stmt_attr_key::no_post_barrier] = true;
}
}
// try to add prefetch code
if (pa_to_merge->ctx_->flags_.prefetch_) {
auto op_first = pa_to_merge->committed_ops_[0];
auto op_second = parti_be_merged->committed_ops_[0];
if (auto second_prefetch
= op_second->dyn_cast<op_traits::may_prefetch_t>()) {
int64_t prefetch_insertion_point = -1;
auto last_for_parent = find_last_parallel_for(
outer_loops_to_merge[merged_loop_size - 1]
->body_.static_as<stmts>(),
prefetch_insertion_point);
std::vector<tensor_slice> in_slice;
in_slice.reserve(op_second->get_inputs().size());
for (auto &inp : op_second->get_inputs()) {
auto second_in = parti_be_merged->buf_alloc_.g2b_map_.get(inp);
in_slice.emplace_back(second_in);
}
auto prefetch_idx = second_prefetch->query_prefetch(
pa_to_merge->ctx_, false, in_slice);
for (auto itr = prefetch_idx.begin(); itr != prefetch_idx.end();) {
auto input = op_second->get_inputs()[*itr]->producer_owner_;
if (pa_to_merge->contains(input)) {
itr = prefetch_idx.erase(itr);
} else {
++itr;
}
}
if (prefetch_insertion_point != -1 && !prefetch_idx.empty()) {
std::vector<stmt> out_seq;
second_prefetch->generate_prefetcher_and_set_idle(
pa_to_merge->ctx_, false, in_slice, prefetch_idx,
out_seq);
auto &outer_body = last_for_parent->seq_;
outer_body.insert(outer_body.begin() + prefetch_insertion_point,
out_seq.begin(), out_seq.end());
}
}
}
auto outer_loops_merged_target = outer_loops_to_merge[merged_loop_size - 1];
auto max_to_merge_anchor_map
= pa_to_merge->get_anchor_inside_loop(outer_loops_merged_target);
if (!max_to_merge_anchor_map) {
auto s = builder::make_stmts_unattached({}).checked_as<stmts>();
add_parent_node(s, outer_loops_merged_target->body_);
outer_loops_merged_target->body_.checked_as<stmts>()->seq_.emplace_back(
s);
// dummy fsmap, the tensor belongs to this scope will not be shrinked
fslice_map fsmap;
max_to_merge_anchor_map = std::make_shared<fuse_anchor_map_t>(s, fsmap);
pa_to_merge->append_fusion_anchor(max_to_merge_anchor_map);
}
pa_to_merge->func_->name_
+= "_parallel_merge_" + parti_be_merged->func_->name_;
merge_parti_impl(pa_to_merge, parti_be_merged, merged_loop_size);
SC_MODULE_INFO << "parallel merging result:";
SC_MODULE_INFO << pa_to_merge->func_;
return true;
}
static bool try_merge_mixed_parti_parallel(mixed_parti_t *A, mixed_parti_t *B) {
A = A->get_root(), B = B->get_root();
if (A == B) return false;
if (!A->func_.get() || !B->func_.get()) return false;
if (!check_parti_connectionship(A, B)) return false;
if (check_parti_ring_risk(A, B)) return false;
auto dep = check_parti_dep(A, B);
COMPILE_ASSERT(
dep != parti_dep::inter_dep, "inter-dependency is not expected");
auto append_parti = (dep == parti_dep::l_dep_r) ? A : B,
target_parti = (dep == parti_dep::l_dep_r) ? B : A;
SC_MODULE_INFO << "Start try_merge_mixed_parti_parallel: "
<< "Target: " << target_parti->func_->name_
<< ", Append: " << append_parti->func_->name_;
auto outer_loops_target = target_parti->get_outer_loops(),
outer_loops_append = append_parti->get_outer_loops();
if (outer_loops_target.empty() || outer_loops_append.empty()) return false;
auto outermost_loop_target = outer_loops_target[0],
outermost_loop_append = outer_loops_append[0];
// check parallel loops attr.
if (!(outermost_loop_target->kind_ == for_type::PARALLEL
&& (outermost_loop_target->num_threads_ > 0))
|| !(outermost_loop_append->kind_ == for_type::PARALLEL
&& (outermost_loop_append->num_threads_ > 0))) {
return false;
}
// check axis binding on the outmost axis
if (!check_parti_loop_axis_binding(append_parti, target_parti, 1)) {
return false;
}
// cannot do parallel merge when loop split granularity are different
if (outermost_loop_target->attr().get_or_else(
stmt_attr_key::parallel_merge_loop_granularity, 1)
!= outermost_loop_append->attr().get_or_else(
stmt_attr_key::parallel_merge_loop_granularity, 1)) {
return false;
}
if (outermost_loop_target->iter_begin_.isa<constant_c>()
&& outermost_loop_target->iter_end_.isa<constant_c>()
&& outermost_loop_target->step_.isa<constant_c>()
&& outermost_loop_append->iter_begin_.isa<constant_c>()
&& outermost_loop_append->iter_end_.isa<constant_c>()
&& outermost_loop_append->step_.isa<constant_c>()) {
auto target_begin = get_expr_as_int(outermost_loop_target->iter_begin_),
target_end = get_expr_as_int(outermost_loop_target->iter_end_),
target_step = get_expr_as_int(outermost_loop_target->step_),
append_begin = get_expr_as_int(outermost_loop_append->iter_begin_),
append_end = get_expr_as_int(outermost_loop_append->iter_end_),
append_step = get_expr_as_int(outermost_loop_append->step_);
// start and step must be the same
if (!(target_begin == append_begin && target_step == append_step)) {
return false;
}
if (target_end
!= append_end) { // if the end is not same, then we try to split
// the first on num_threads_ to merge, but we
// require num_iters == num_threads
if (append_parti->contain_convolution()
|| target_parti->contain_convolution()) {
// currently do not support split num_threads_ on conv
return false;
}
if (target_begin != 0 || target_step != 1 || append_begin != 0
|| append_step != 1) {
// Only support begin is 0 and step is 1
return false;
}
if (target_end == outermost_loop_target->num_threads_
&& append_end == outermost_loop_append->num_threads_) {
// For the two fors, same start, same step, different end =>
// different num_iters.
// For each for, num_iters == num_threads. So We split the for
// on num_threads.
// can not split the outermost loop in imbalanced cases
if (!outermost_loop_target->attr().get_or_else(
stmt_attr_key::parallel_loop_balanced, true)
|| !outermost_loop_append->attr().get_or_else(
stmt_attr_key::parallel_loop_balanced, true)) {
SC_MODULE_INFO << "The outermost loop is imbalanced, can "
"not be split";
return false;
}
if (outermost_loop_target->num_threads_
> outermost_loop_append->num_threads_
&& outermost_loop_target->num_threads_
% outermost_loop_append->num_threads_
== 0) {
if (outermost_loop_append->num_threads_ == 1) {
// in this case, after split, outermost_loop_target
// num_threads will be 1
return false;
}
int64_t num_groups = outermost_loop_target->num_threads_
/ outermost_loop_append->num_threads_;
target_parti->try_split_outermost_loop_on_num_threads(
num_groups);
return try_merge_mixed_parti_parallel_inners(
target_parti, append_parti);
} else if (outermost_loop_append->num_threads_
> outermost_loop_target->num_threads_
&& outermost_loop_append->num_threads_
% outermost_loop_target->num_threads_
== 0) {
if (outermost_loop_target->num_threads_ == 1) {
// in this case, after split, outermost_loop_append
// num_threads will be 1
return false;
}
int64_t num_groups = outermost_loop_append->num_threads_
/ outermost_loop_target->num_threads_;
append_parti->try_split_outermost_loop_on_num_threads(
num_groups);
return try_merge_mixed_parti_parallel_inners(
target_parti, append_parti);
} else {
return false;
}
} else { // do not support num_iters != num_threads case for now
return false;
}
} else { // the two fors have same (start, end, step)
// if num_threads are the same, merge them directly
if (outermost_loop_target->num_threads_
== outermost_loop_append->num_threads_) {
return try_merge_mixed_parti_parallel_inners(
target_parti, append_parti);
} else {
return false;
}
}
} else { // if (start, end, step) is not constant
return false;
}
}
static bool try_merge_mixed_parti_horizontally(
mixed_parti_t *A, mixed_parti_t *B) {
A = A->get_root(), B = B->get_root();
if (A == B) return false;
if (!A->func_.get() || !B->func_.get()) return false;
if (!A->contain_tunable_op() || !B->contain_tunable_op()) return false;
if (!check_parti_connectionship(A, B)) return false;
if (check_parti_dep(A, B) != parti_dep::no_dep) return false;
auto outer_loops_A = A->get_outer_loops(),
outer_loops_B = B->get_outer_loops();
if (outer_loops_A.empty() || outer_loops_B.empty()) return false;
// skip parallel merge
if (outer_loops_A[0]->num_threads_ > 0
|| outer_loops_B[0]->num_threads_ > 0)
return false;
// check cost model
if (!A->cost_->make_decision_for_parti(
B, 1, parti_merge_kind::horizontal)) {
return false;
}
SC_MODULE_INFO << "horizontally merging two partition:";
SC_MODULE_INFO << A->func_;
SC_MODULE_INFO << B->func_;
/* * * * * * * * * * * * * * * * *
* Step 0: Fuse func_
* * * * * * * * * * * * * * * * */
node_ptr_map node_remap;
schedule_loop_body(A->func_->body_, &node_remap);
schedule_loop_body(B->func_->body_, &node_remap);
/* * * * * * * * * * * * * * * * *
* Step 1: Merge func_
* * * * * * * * * * * * * * * * */
auto new_body = make_stmt<stmts_node_t>(
std::vector<stmt> {A->func_->body_, B->func_->body_});
A->func_->body_ = std::move(new_body);
/* * * * * * * * * * * * * * * * *
* Step 2: Merge fanchor_
* * * * * * * * * * * * * * * * */
A->append_fusion_anchor(B->fanchors_);
/* * * * * * * * * * * * * * * * *
* Step 3: Merge buffer_
* * * * * * * * * * * * * * * * */
std::unordered_map<expr, expr> buffer_map;
A->buf_alloc_.merge(
B->buf_alloc_, buffer_map, std::make_pair(nullptr, nullptr));
/* * * * * * * * * * * * * * * * *
* Step 4: Replace expr
* * * * * * * * * * * * * * * * */
for (auto &buf_pair : buffer_map) {
node_remap.insert(
std::make_pair(buf_pair.first.impl, buf_pair.second.impl));
}
mxp_replacer_t expr_reper(node_remap);
// 1. func->body
expr_reper.replace_func(A->func_);
// 2. fanchor->fsmap->slice_range
expr_reper.replace_anchor(A->fanchors_);
/* * * * * * * * * * * * * * * * *
* Step 5: Merge op_anchor_map_
* * * * * * * * * * * * * * * * */
A->op_anchor_map_.insert(
B->op_anchor_map_.begin(), B->op_anchor_map_.end());
// call base merge
A->fusion_partition_t::merge(
static_cast<fusion_partition_t *>(B)->shared_from_this());
// Merge commited ops
A->committed_ops_.insert(A->committed_ops_.end(), B->committed_ops_.begin(),
B->committed_ops_.end());
auto &body = A->func_->body_;
/* * * * * * * * * * * * * * * * *
* Step 6: Same to Horizontal Merge
* * * * * * * * * * * * * * * * */
COMPILE_ASSERT(body.isa<stmts>(), "body has only one stmt.");
scope_flatten(body.checked_as<stmts>(), -1);
std::vector<stmt> &body_seq = body.checked_as<stmts>()->seq_;
std::vector<for_loop> loops;
std::vector<stmt> not_loops;
for (auto &st : body_seq) {
if (st.isa<for_loop>()) {
loops.push_back(st.checked_as<for_loop>());
} else if (!st.isa<returns>()) {
not_loops.push_back(st);
}
}
std::vector<stmt> new_seq(not_loops.begin(), not_loops.end());
new_seq.insert(new_seq.end(), loops.begin(), loops.end());
body_seq = std::move(new_seq);
COMPILE_ASSERT(loops.size() > 1,
"No need to horizontal fuse as parallel loop number is less "
"than "
"2.");
constant_folder_t cf;
auto_caster_t ac;
for (size_t i = 1; i < loops.size(); i++) {
loops[0]->parallel_merge(body, loops[i]);
loops[0]->iter_end_ = cf(ac(loops[0]->iter_end_)).remove_const();
}
add_parent_node(loops[0], stmt());
A->func_->name_ += "_horizontal_merge_" + B->func_->name_;
SC_MODULE_INFO << "horizontally merging result:";
SC_MODULE_INFO << A->func_;
// clear merged parti
B->clear();
return true;
}
static sc_dim get_loops_range(const for_loop &loop) {
if (!(loop->iter_begin_.isa<constant_c>()
&& loop->iter_end_.isa<constant_c>())) {
return (int64_t)0;
}
return get_expr_as_int(loop->iter_end_)
- get_expr_as_int(loop->iter_begin_);
}
static sc_dim get_loops_range_prod(const std::vector<for_loop> &loops) {
sc_dim prod_res = 1;
for (auto &l : loops) {
prod_res *= get_loops_range(l);
}
return prod_res;
}
static void try_align_parti_outer_loops(mixed_parti_t *A, mixed_parti_t *B) {
auto outer_loops_A = A->get_outer_loops(),
outer_loops_B = B->get_outer_loops();
if (outer_loops_A.empty() || outer_loops_B.empty()) return;
if (outer_loops_A.size() == outer_loops_B.size()) return;
auto outermost_loop_A_range = get_loops_range(outer_loops_A[0]),
outermost_loop_B_range = get_loops_range(outer_loops_B[0]);
if (outermost_loop_A_range == 0 || outermost_loop_B_range == 0
|| outermost_loop_A_range == outermost_loop_B_range) {
return;
} else if (outermost_loop_A_range <= outermost_loop_B_range) {
B->try_split_outermost_loop(outermost_loop_A_range);
} else {
A->try_split_outermost_loop(outermost_loop_B_range);
}
}
// check brgemm pre-op fusion
static bool try_merge_brgemm_and_preop_parti(mixed_parti_t *A, mixed_parti_t *B,
const sc_op_ptr &joint_op = nullptr) {
A = A->get_root(), B = B->get_root();
if (A == B) return false;
if (!A->func_.get() || !B->func_.get()) return false;
if (!joint_op && !check_parti_connectionship(A, B)) return false;
if (check_parti_ring_risk(A, B)) return false;
auto dep_flag = check_parti_dep(A, B);
if (dep_flag == parti_dep::inter_dep) return false;
mixed_parti_t *brgemm_parti, *preop_parti;
if (A->contain_tunable_op() && B->contain_elemwise_op_only()) {
brgemm_parti = A;
preop_parti = B;
} else if (B->contain_tunable_op() && A->contain_elemwise_op_only()) {
brgemm_parti = B;
preop_parti = A;
} else {
return false;
}
if (check_parti_dep(brgemm_parti, preop_parti) == parti_dep::l_dep_r)
return false;
SC_MODULE_INFO << "pre-op merging two partition:";
SC_MODULE_INFO << A->func_;
SC_MODULE_INFO << B->func_;
/* * * * * * * * * * * * * * * * *
* Step 1: pre infer elementwise op using brgemm parti fusion anchor
* * * * * * * * * * * * * * * * */
for (auto &brgemm_parti_anchor : brgemm_parti->fanchors_) {
fslice_map tmp_fsmap;
for (auto iter = brgemm_parti_anchor->fsmap_.datamap_.begin();
iter != brgemm_parti_anchor->fsmap_.datamap_.end();) {
if (!brgemm_parti->buf_alloc_.g2b_map_.haskey(iter->first)) {
auto brgemm_parti_cut_op = iter->first->producer_owner_;
if (preop_parti->contains(brgemm_parti_cut_op)) {
if (brgemm_parti_cut_op
!= preop_parti->committed_ops_.back().get()) {
SC_MODULE_INFO << "brgemm_parti_cut_op "
<< brgemm_parti_cut_op->op_name_
<< brgemm_parti_cut_op->logical_op_id_
<< " is not the end of preop_parti "
"commited_ops.";
}
bool hit_cut_op = false;
infer_status_map_t stat_map(brgemm_parti->ctx_, false);
// set known slice range and prepare for pre-infer slice
// range
tmp_fsmap.get(iter->first) = iter->second;
// only ops before cut_op_iter will be infered with
// pre_slice
for (auto op_iter = preop_parti->committed_ops_.rbegin();
op_iter != preop_parti->committed_ops_.rend();
op_iter++) {
COMPILE_ASSERT((*op_iter)->isa<fusible_op_t>(),
"Only fusible op is expected on pre-op "
"partiion. "
"but got "
<< (*op_iter)->op_name_);
if ((*op_iter).get() == brgemm_parti_cut_op) {
hit_cut_op = true;
}
if (!hit_cut_op) continue;
(*op_iter)->stc_cast<fusible_op_t>()->pre_slice_ranges(
tmp_fsmap, stat_map);
COMPILE_ASSERT(stat_map.is_ok(),
"Elementwise ops are expected to infer "
"successfully")
}
iter++;
} else {
iter = brgemm_parti_anchor->fsmap_.datamap_.erase(iter);
}
} else {
iter++;
}
}
// move fsmap
brgemm_parti_anchor->fsmap_.datamap_.insert(
tmp_fsmap.datamap_.begin(), tmp_fsmap.datamap_.end());
}
/* * * * * * * * * * * * * * * * *
* Step 2: Commit ops in pre-op parti into brgemm parti by original order
* * * * * * * * * * * * * * * * */
brgemm_parti->func_->name_ += "_preop_merge";
// set pre-op fusion attr
preop_parti->committed_ops_.front()->attrs_.set(
mixed_partition_hint::pre_fuse_begin_op, true);
for (auto &op_in_preop_parti : preop_parti->committed_ops_) {
brgemm_parti->add(op_in_preop_parti);
}
// remove pre-op fusion attr
preop_parti->committed_ops_.front()->attrs_.remove(
mixed_partition_hint::pre_fuse_begin_op);
// erase joint op in op_anchor_map
brgemm_parti->op_anchor_map_.erase(joint_op.get());
/* * * * * * * * * * * * * * * * *
* Step 3: Merge op_
* * * * * * * * * * * * * * * * */
// call base merge
brgemm_parti->fusion_partition_t::merge(
static_cast<fusion_partition_t *>(preop_parti)->shared_from_this());
SC_MODULE_INFO << "pre-op merging result:";
SC_MODULE_INFO << brgemm_parti->func_;
// clear merged parti
preop_parti->clear();
return true;
}
static bool try_merge_mixed_parti_vertically(mixed_parti_t *A, mixed_parti_t *B,
const sc_op_ptr &joint_op = nullptr, bool keep_outerloop_size = false) {
A = A->get_root(), B = B->get_root();
if (A == B) return false;
if (!A->func_.get() || !B->func_.get()) return false;
if (!joint_op && !check_parti_connectionship(A, B)) return false;
if (!joint_op && check_parti_ring_risk(A, B)) return false;
auto dep_flag = check_parti_dep(A, B);
// if two partition inter-depends each other, could not merge them
if (dep_flag == parti_dep::inter_dep) return false;
// if both two partitions have input anchor, could not merge them
if (A->contain_input_anchor() && B->contain_input_anchor()) return false;
mixed_parti_t *pa_to_merge = nullptr, *parti_be_merged = nullptr;
pa_to_merge = (dep_flag == parti_dep::l_dep_r) ? B : A;
parti_be_merged = (dep_flag == parti_dep::l_dep_r) ? A : B;
auto outer_loops_to_merge = pa_to_merge->get_outer_loops(),
outer_loops_be_merged = parti_be_merged->get_outer_loops();
auto merged_loop_size = get_great_common_loop_size(
outer_loops_to_merge, outer_loops_be_merged);
if (!merged_loop_size) return false;
// validate axis binding
merged_loop_size = check_parti_loop_axis_binding(
parti_be_merged, pa_to_merge, merged_loop_size);
if (!merged_loop_size
|| (keep_outerloop_size
&& (merged_loop_size != outer_loops_to_merge.size()
|| merged_loop_size
!= outer_loops_be_merged.size())))
return false;
// check cost model
if (!pa_to_merge->cost_->make_decision_for_parti(
parti_be_merged, merged_loop_size, parti_merge_kind::vertical))
return false;
if (auto max_to_merge_anchor_map = pa_to_merge->get_anchor_inside_loop(
outer_loops_to_merge[merged_loop_size - 1])) {
if (joint_op
&& std::any_of(joint_op->get_inputs().begin(),
joint_op->get_inputs().end(),
[&max_to_merge_anchor_map, &pa_to_merge](
const graph_tensor_ptr &inp) {
return pa_to_merge->contains(inp->producer_owner_)
&& max_to_merge_anchor_map->blocked_gt_set_
.find(inp)
!= max_to_merge_anchor_map->blocked_gt_set_
.end();
}))
return false;
} else {
return false;
}
SC_MODULE_INFO << "merging two partition:";
SC_MODULE_INFO << A->func_;
SC_MODULE_INFO << B->func_;
pa_to_merge->func_->name_ += "_merge_" + parti_be_merged->func_->name_;
merge_parti_impl(pa_to_merge, parti_be_merged, merged_loop_size, joint_op);
SC_MODULE_INFO << "Merging result:";
SC_MODULE_INFO << pa_to_merge->func_;
return true;
}
// usually used by crossover dispatcher
static bool try_merge_mixed_parti_vertically(
mixed_parti_t *A, mixed_parti_t *B) {
A = A->get_root(), B = B->get_root();
if (A == B) return false;
// if A and B are forked, do not merge them
if (check_parti_forked(A, B)) return false;
// in avoid conflict with parallel merge
if (A->contain_nested_parallel_for() || B->contain_nested_parallel_for())
return false;
// skip single op partition
if (A->is_single_op_parti() || B->is_single_op_parti()) return false;
bool image_affinity = A->contain_convolution() && B->contain_convolution();
return try_merge_mixed_parti_vertically(A, B, nullptr, !image_affinity);
}
static bool try_merge_mixed_parti_with_joint_op(const mixed_parti_t::ptr &A,
const mixed_parti_t::ptr &B, const sc_op_ptr &joint_op) {
mixed_parti_t *default_lhs, *default_rhs;
// If no dependence, first execute the partition with more tunable ops
if (joint_op->isa<tunable_op_t>()
|| (A->contain_tunable_op()
&& (!B->contain_tunable_op()
|| (B->count_op_with_type<tunable_op_t>()
> A->count_op_with_type<
tunable_op_t>())))) {
default_lhs = B.get();
default_rhs = A.get();
} else {
default_lhs = A.get();
default_rhs = B.get();
}
auto &ctx = A->ctx_;
if (ctx->flags_.opt_level_ == sc_opt_level::lv1) {
return try_merge_mixed_parti_vertically(
default_lhs, default_rhs, joint_op);
}
// if pre-op fusion succeed, skip vertical merge
return try_merge_brgemm_and_preop_parti(default_lhs, default_rhs, joint_op)
|| try_merge_mixed_parti_vertically(
default_lhs, default_rhs, joint_op);
}
mixed_parti_t::mixed_parti_t(
const context_ptr &ctx, const sc_op_ptr &op, const dep_mat_ptr &dep_m)
: dep_m_(dep_m), ctx_(ctx) {
auto &graph = op->get_owner_graph();
if (graph.is_dynamic()) {
cost_ = std::make_shared<dynamic_fusion_cost_model_t>(this,
graph.attrs_.get_or_else("temp.dynamic_fusion_policy",
dynamic_fusion_policy_t::max_fusion));
} else {
cost_ = std::make_shared<static_fusion_cost_model_t>(this);
}
if (!op->isa<constant_op_t>() && !op->isa<tensor_view_op_t>()) {
SC_MODULE_INFO << "================ create new partition: "
<< op->op_name_ << "_" << op->logical_op_id_
<< " ================";
auto mixed_op = op->dyn_cast<op_traits::mixed_partition_acceptable>();
mixed_op->create_mixed_partition(this);
func_->name_ = op->op_name_ + std::to_string(op->logical_op_id_);
SC_MODULE_INFO << func_;
}
ops.insert(op);
committed_ops_.emplace_back(op);
}
mixed_parti_t::mixed_parti_t(const context_ptr &ctx, const func_t &func,
const fusion_anchor_mgr_t &fmgr, const dep_mat_ptr &dep_m)
: dep_m_(dep_m), ctx_(ctx), func_(func) {
cost_ = std::make_shared<static_fusion_cost_model_t>(this);
append_fusion_anchor(fmgr.fanchor_list_);
}
bool mixed_parti_t::is_ok_to_add(sc_op *op) {
if (merged_to) { return get_root()->is_ok_to_add(op); }
if (empty()) { return false; }
if (!fusion_partition_t::is_ok_to_add(op, (*dep_m_))) {
SC_MODULE_INFO << op->op_name_ << "_" << op->logical_op_id_
<< " fail to add partition: " << func_->name_
<< ", due to potential graph "
"dependency ring risk";
return false;
}
// TODO(yunfei): when all tunable ops completely refactored to managed
// threads mode, remove this if.
if (op->isa<tunable_op_t>() && contain_nested_parallel_for()) {
return false;
}
// search suitable anchor for op
auto mixed_op = op->dyn_cast<op_traits::mixed_partition_acceptable>();
mixed_op->search_anchor(this);
if (!ready_for_op(op)) {
SC_MODULE_INFO << op->op_name_ << "_" << op->logical_op_id_
<< " fail to add partition: " << func_->name_
<< ", due to no suitable anchor found";
return false;
}
return true;
}
bool mixed_parti_t::ready_for_op(sc_op *op) const {
if (merged_to) { return get_root()->ready_for_op(op); }
return op_anchor_map_.find(op) != op_anchor_map_.end();
}
void mixed_parti_t::set_anchor_for_op(
sc_op *op, const fuse_anchor_map_ptr &fanchor_map) {
if (merged_to) {
get_root()->set_anchor_for_op(op, fanchor_map);
return;
}
auto iter = op_anchor_map_.find(op);
// update op_anchor_map_
if (iter != op_anchor_map_.end()) {
// auto skip
if (iter->second == fanchor_map) return;
auto res = cmp_op_anchor(op, iter->second, fanchor_map);
// if new anchor is more smaller than the current one
if (res == cmp_res::l_larger_r) {
// overwrite new anchor
op_anchor_map_[op] = fanchor_map;
} else if (res == cmp_res::equal) {
// Except for reduce_collect_op_t with COPY kind because this mode
// will elimiate first required axis
if (auto red_coll = op->dyn_cast<reduce_collect_op_t>()) {
if (red_coll->op_ == reduce_collect_op_t::kind::COPY) return;
}
// if sub anchor is equal to parent one, overwrite it
if (iter->second->is_parent_for(fanchor_map)) {
// overwrite inner anchor
op_anchor_map_[op] = fanchor_map;
}
}
} else {
op_anchor_map_[op] = fanchor_map;
}
}
bool mixed_parti_t::add(const sc_op_ptr &op) {
if (merged_to) { return get_root()->add(op); }
// pre-check anchor for op in avoid of throw assert during following
// appending stage
search_op_anchor_in_parti(op.get(), this);
// if no anchor is ready, return false
if (!ready_for_op(op.get())) return false;
/* adding op to partition */
SC_MODULE_INFO << "================ adding op: " << op->op_name_ << "_"
<< op->logical_op_id_ << " to partition: " << func_->name_
<< " ================";
if (op->need_dynamic_internal_query()) {
dyn_inter_ = std::make_shared<mixed_dyn_internal_info_t>(ctx_);
}
auto mixed_op = op->dyn_cast<op_traits::mixed_partition_acceptable>();
mixed_op->append_mixed_partition(this);
func_->name_ += "_" + op->op_name_ + std::to_string(op->logical_op_id_);
SC_MODULE_INFO << func_;
ops.insert(op);
committed_ops_.emplace_back(op);
return true;
}
void mixed_parti_t::append_fusion_anchor(const fuse_anchor_map_ptr &fanchor) {
auto cur = try_convert_anchor(ctx_, fanchor);
cur->binded_mxp_ = this;
fanchors_.emplace_back(cur);
}
fuse_anchor_map_ptr mixed_parti_t::lookup_anchor_map(
sc_op *op, bool throw_assert) const {
if (merged_to) { return get_root()->lookup_anchor_map(op); }
auto iter = op_anchor_map_.find(op);
auto ret = (iter != op_anchor_map_.end()) ? iter->second : nullptr;
if (throw_assert) {
COMPILE_ASSERT(ret,
"No dispatched fusion anchor map found for "
<< op->op_name_
<< " in this partition, please try to search it "
"firstly");
}
return ret;
}
fuse_anchor_map_ptr mixed_parti_t::lookup_anchor_map(const stmts &ss) const {
if (merged_to) { return get_root()->lookup_anchor_map(ss); }
auto iter = std::find_if(fanchors_.begin(), fanchors_.end(),
[&ss](const fuse_anchor_map_ptr &amap) {
return ss.ptr_same(amap->anchor_position_);
});
return (iter != fanchors_.end()) ? (*iter) : nullptr;
}
std::vector<fuse_anchor_map_ptr> mixed_parti_t::lookup_sub_anchor_map(
const fuse_anchor_map_ptr &parent_fanchor) const {
if (merged_to) { return get_root()->lookup_sub_anchor_map(parent_fanchor); }
std::vector<fuse_anchor_map_ptr> subs;
for (auto &fanc : fanchors_) {
if (fanc->parent_ == parent_fanchor) { subs.emplace_back(fanc); }
}
return subs;
}
void mixed_parti_t::clear_fanchor(fuse_anchor_map_ptr &fanchor) {
stmt anchor = fanchor->anchor_position_;
if (!fanchor->isa<fuse_grouped_anchor_map_t>()) {
COMPILE_ASSERT(anchor.checked_as<stmts>()->seq_.empty(),
"Could not remove this fanchor, because it is not empty");
} else {
for (auto &sub_group : anchor.checked_as<stmts>()->seq_) {
COMPILE_ASSERT(sub_group.checked_as<stmts>()->seq_.empty(),
"Could not remove this fanchor, because it is not empty");
}
}
stmt parent = get_parent_node(anchor);
auto ss_parent = parent.checked_as<stmts>();
// clear empty if_node outside iter anchor if necessary
if (fanchor->isa<fuse_iter_anchor_map_t>() && ss_parent->seq_.size() == 1
&& get_parent_node(parent).isa<if_else>()) {
auto if_node = get_parent_node(parent);
// redirect
parent = get_parent_node(if_node);
ss_parent = parent.checked_as<stmts>();
anchor = if_node;
}
// find anchor iter
std::vector<stmt>::iterator anchor_iter
= std::find_if(ss_parent->seq_.begin(), ss_parent->seq_.end(),
[anchor](stmt &s) { return s.ptr_same(anchor); });
COMPILE_ASSERT(anchor_iter != ss_parent->seq_.end(),
"Could not found anchor in current parent stmts");
// remove anchor
ss_parent->seq_.erase(anchor_iter);
// reset fanchor
fanchor->anchor_position_ = stmts();
fanchor->fsmap_.clear();
}
void mixed_parti_t::clear_fanchors() {
for (auto iter = fanchors_.begin(); iter != fanchors_.end();) {
auto fanchor = *iter;
if (!fanchor->anchor_position_->size()) {
clear_fanchor(fanchor);
iter = fanchors_.erase(iter);
} else {
iter++;
}
}
}
std::vector<for_loop> mixed_parti_t::get_outer_loops(
fuse_anchor_map_ptr fanchor) const {
if (merged_to) { return get_root()->get_outer_loops(fanchor); }
std::vector<for_loop> outer_loops;
if (!func_) return outer_loops;
auto body = func_->body_;
fuse_anchor_map_ptr target_fanchor = std::move(fanchor);
while (target_fanchor && target_fanchor->parent_) {
target_fanchor = target_fanchor->parent_;
}
if (body.isa<stmts>()
&& (body.checked_as<stmts>()->seq_.size() == 1
|| body.checked_as<stmts>()->seq_.size() == 2)) {
if (body.checked_as<stmts>()->seq_.size() == 2) {
if (!body.checked_as<stmts>()->seq_[1].isa<returns>())
return outer_loops;
}
auto st = body.checked_as<stmts>()->seq_[0];
if (st.isa<for_loop>()) {
auto loop = st.static_as<for_loop>();
while (loop.defined()) {
outer_loops.emplace_back(loop);
loop = get_next_inner_loop_with_anchor(loop, target_fanchor);
}
}
}
return outer_loops;
}
/**
* for_loop(){
* // input anchor
* {}
* // body
* ...
* // output anchor
* {}
* }
* */
fuse_anchor_map_ptr mixed_parti_t::get_anchor_inside_loop(
const for_loop &loop, bool input_anchor) const {
auto &body = loop->body_;
if (body.isa<stmts>()) {
auto ss = body.static_as<stmts>();
for (auto s : ss->seq_) {
// find anchor inside if-node
if (s.isa<if_else>()) {
auto if_node = s.static_as<if_else>();
if (!if_node->then_case_.defined()
|| if_node->else_case_.defined())
continue;
auto then_stmts = if_node->then_case_.static_as<stmts>();
if (then_stmts->seq_.size() == 1)
s = then_stmts->seq_[0];
else
continue;
}
if (!s.isa<stmts>()) continue;
auto inner_ss = s.static_as<stmts>();
auto anchor_map = lookup_anchor_map(inner_ss);
if (anchor_map) {
// check anchor type
if (input_anchor != anchor_map->is_input_anchor()) continue;
return anchor_map;
}
}
}
return nullptr;
}
for_loop mixed_parti_t::get_next_inner_loop_with_anchor(
const for_loop &cur_loop,
const fuse_anchor_map_ptr &target_fanchor) const {
if (cur_loop->body_.isa<for_loop>()) {
return cur_loop->body_.checked_as<for_loop>();
} else if (cur_loop->body_.isa<stmts>()) {
auto ss = cur_loop->body_.static_as<stmts>();
bool target_anchor_found = false;
for_loop next_loop = for_loop();
for (auto &s : ss->seq_) {
if (s.isa<stmts>()) {
auto inner_ss = s.static_as<stmts>();
if (inner_ss->seq_.empty()) {
auto anchor_map = lookup_anchor_map(inner_ss);
if (anchor_map) {
if (anchor_map == target_fanchor) {
target_anchor_found = true;
break;
}
continue;
} else {
next_loop = for_loop();
break;
}
} else {
next_loop = for_loop();
break;
}
} else if (s.isa<for_loop>() && !next_loop.defined()) {
next_loop = s.checked_as<for_loop>();
} else if (s.cast<evaluate>()
.map([](const evaluate &v) {
return v->value_.as<intrin_call>();
})
.filter([](const intrin_call &v) {
return v->type_
== intrin_type::set_thread_idle_func;
})
.has_value()) {
// When prefetch is enabled, a prefetcher function call
// `evaluate{set_thread_idle_func(...)}` would have been added
// to the loop. We should ignore it when finding next anchor.
continue;
} else {
next_loop = for_loop();
break;
}
}
return target_anchor_found ? for_loop() : next_loop;
}
return for_loop();
}
class var_replacer_t : public ir_visitor_t {
public:
var_replacer_t(const std::unordered_map<expr_c, expr_c> &remap)
: remap_(remap) {}
std::unordered_map<expr_c, expr_c> remap_;
using ir_visitor_t::dispatch;
using ir_visitor_t::visit;
expr_c visit(var_c v) override {
auto itr = remap_.find(v);
if (itr != remap_.end()) { return itr->second; }
return v;
}
};
void mixed_parti_t::try_split_outermost_loop_on_num_threads(
int64_t num_groups) {
auto outer_loops = get_outer_loops();
if (outer_loops.empty()) return;
auto outermost_loop = outer_loops[0];
// cache original largest anchor inside outermost loop
auto origin_large_anchor = get_anchor_inside_loop(outermost_loop);
// node ptr replace map
node_ptr_map remap;
// change IR and record replace map
auto split_inner_loop
= outermost_loop->split_on_num_threads(num_groups, &remap);
// split outer loop axis binder
ax_binder_.split_init_axis(0);
mxp_replacer_t(remap).replace_anchor(fanchors_);
// if original largest anchor not null, create new largest anchor under new
// outermost loop
if (origin_large_anchor) {
auto s = builder::make_stmts_unattached({}).checked_as<stmts>();
add_parent_node(s, outermost_loop->body_);
outermost_loop->body_.checked_as<stmts>()->seq_.emplace_back(s);
// dummy fsmap, the tensor belongs to this scope will not be shrinked
fslice_map new_fsmap;
// copy from original fsmap
new_fsmap.datamap_ = origin_large_anchor->fsmap_.datamap_;
// create var inplacer
std::unordered_map<expr_c, expr_c> vmap = {{split_inner_loop->var_,
make_expr<constant_node>(
UINT64_C(0), split_inner_loop->var_->dtype_)}};
var_replacer_t repl(vmap);
// modify slice range
for (auto &fspair : new_fsmap.datamap_) {
for (auto &srange : fspair.second) {
for (auto &r : srange) {
auto new_v = repl.dispatch(r.first);
// if necesary
if (!new_v.ptr_same(r.first)) {
// set new offset
r.first = new_v.remove_const();
// set new range
r.second = dim2unsigned(get_expr_as_int(r.second)
* (get_expr_as_int(split_inner_loop->iter_end_)
- get_expr_as_int(
split_inner_loop
->iter_begin_)));
}
}
}
}
// append new anchor into parti
append_fusion_anchor(std::make_shared<fuse_anchor_map_t>(s, new_fsmap));
}
}
void mixed_parti_t::try_split_outermost_loop(int64_t block) {
auto outer_loops = get_outer_loops();
if (outer_loops.empty()) return;
auto outermost_loop = outer_loops[0];
auto outermost_loop_range = get_expr_as_int(outermost_loop->iter_end_)
- get_expr_as_int(outermost_loop->iter_begin_);
if (outermost_loop_range % block != 0) return;
if (!outermost_loop->step_.isa<constant>()
|| get_expr_as_int(outermost_loop->step_) != 1)
return;
node_ptr_map remap;
// change IR and record replace map
outermost_loop->split(outermost_loop_range / block, &remap);
// split outer loop axis binder
ax_binder_.split_init_axis(0);
mxp_replacer_t(remap).replace_anchor(fanchors_);
}
void mixed_parti_t::buffer_schedule() {
if (merged_to) {
get_root()->buffer_schedule();
return;
}
if (ctx_->flags_.concat_optimization_) {
buf_alloc_.copy_concat_memory_attrs_tsr2buf();
}
buf_alloc_.tensor_initialize();
buf_alloc_.declare_tensor();
buf_alloc_.set_shrink_info();
buf_alloc_.query_inplace();
buf_alloc_.calibrate_info();
}
bool mixed_parti_t::is_parti_inp(const graph_tensor *gt) const {
if (merged_to) { return get_root()->is_parti_inp(gt); }
auto ths = this;
return std::any_of(gt->uses_.begin(), gt->uses_.end(),
[&ths](const std::pair<int, sc_op_weak_ptr_t> &user) {
return ths->contains(user.second.get());
})
&& !contains(gt->producer_owner_);
}
bool mixed_parti_t::is_parti_inp(const graph_tensor_ptr >) const {
return is_parti_inp(gt.get());
}
bool mixed_parti_t::is_parti_out(const graph_tensor *gt) const {
if (merged_to) { return get_root()->is_parti_out(gt); }
auto ths = this;
return contains(gt->producer_owner_)
&& std::any_of(gt->uses_.begin(), gt->uses_.end(),
[&ths](const std::pair<int, sc_op_weak_ptr_t> &user) {
return !ths->contains(user.second.get());
});
}
bool mixed_parti_t::is_parti_out(const graph_tensor_ptr >) const {
return is_parti_out(gt.get());
}
bool mixed_parti_t::is_const_parti() const {
return (get_ops_size() == 1
&& get_ith_op(0)->attrs_.get_or_else(
"constant", const_kind::not_const)
!= const_kind::not_const);
}
bool mixed_parti_t::contain_convolution() const {
return contain_op_with_type<ops::conv_fwd_core_op_t>()
|| contain_op_with_type<ops::conv_bwd_data_core_op_t>()
|| contain_op_with_type<ops::conv_bwd_weight_core_op_t>();
}
bool mixed_parti_t::contain_nested_parallel_for() const {
auto outer_loops = get_outer_loops();
if (outer_loops.empty()) return false;
if (outer_loops.size() == 1) {
if (outer_loops[0]->num_threads_ == 0) return false;
if (outer_loops[0]->body_.isa<stmts>()) {
auto &ss = outer_loops[0]->body_.static_as<stmts>()->seq_;
for (auto &s : ss) {
if (s.isa<for_loop>()) {
if (s.static_as<for_loop>()->num_threads_ > 0) return true;
}
}
}
return false;
}
return (outer_loops[0]->num_threads_ > 0)
&& (outer_loops[1]->num_threads_ > 0);
}
bool mixed_parti_t::contain_tunable_op() const {
return contain_op_with_type<tunable_op_t>();
}
bool mixed_parti_t::contain_elemwise_op_only() const {
if (merged_to) { return get_root()->contain_elemwise_op_only(); }
for (auto &op : ops) {
if (!is_elementwise_op(op.get())) return false;
}
return true;
}
bool mixed_parti_t::is_single_op_parti() const {
if (merged_to) { return get_root()->is_single_op_parti(); }
return ops.size() == 1;
}
bool mixed_parti_t::is_optimized() const {
if (merged_to) { return get_root()->is_optimized(); }
if (committed_ops_.empty()) return false;
return is_optimized_sub_graph(get_host_graph());
}
void mixed_parti_t::clear() {
// Graph-related
ops.clear();
committed_ops_.clear();
ax_binder_.clear();
// IR-related
func_ = func_t();
fanchors_.clear();
buf_alloc_.clear();
op_anchor_map_.clear();
// Cost Model
cost_ = nullptr;
}
float mixed_parti_t::evaluate_perf() {
if (merged_to) { return get_root()->evaluate_perf(); }
return cost_->evaluate();
}
bool mixed_parti_t::is_small_workload() const {
if (merged_to) { return get_root()->is_small_workload(); }
// skip partition owning more than one ops
if (committed_ops_.size() != 1) return false;
// get sinlge op
auto single_op = committed_ops_[0].get();
// skip tunable op
if (single_op->isa<tunable_op_t>()) return false;
// get committed anchor
auto committed_anchor = lookup_anchor_map(single_op);
COMPILE_ASSERT(committed_anchor, "No committed anchor found")
// query small op workload
return committed_anchor->is_small_op_workload(single_op);
}
std::vector<mixed_parti_t::ptr> collect_parti_set(
const std::vector<mixed_parti_t::ptr> &op_2_partition,
bool ignore_const) {
std::unordered_set<mixed_parti_t::ptr> parti_set;
std::vector<mixed_parti_t::ptr> parti_vec;
for (auto &parti : op_2_partition) {
if (parti_set.count(parti)) { continue; }
// auto skip nullptr or const parti
if (!parti || (ignore_const && parti->is_const_parti())) continue;
parti_set.insert(parti);
parti_vec.push_back(parti);
}
return parti_vec;
}
static bool check_repartition(const mixed_parti_t::ptr &parti) {
if (!parti || parti->get_ops_size() < 2) return false;
// check tensorview in edge of partition
bool repartition = false;
// check buffer is tensorptr
auto check_parti_out_tptr = [&repartition, &parti](
const graph_tensor_ptr &out) {
auto producer = out->producer_owner_;
COMPILE_ASSERT(parti->buf_alloc_.g2b_map_.haskey(out),
"No buffer allocated found for output "
"of " << producer->op_name_
<< producer->logical_op_id_)
if (parti->buf_alloc_.g2b_map_.get(out).isa<tensorptr>()) {
if (producer->isa<tensor_view_op_t>()) {
auto tv_op = producer;
graph_tensor *tv_inp;
while (tv_op->isa<tensor_view_op_t>()) {
tv_op->attrs_[op_attr_key::no_fuse] = true;
tv_inp = tv_op->get_inputs()[0].get();
tv_op = tv_inp->producer_owner_;
}
if (parti->buf_alloc_.g2b_map_.get(tv_inp).isa<tensorptr>()) {
tv_inp->attrs_[mixed_partition_hint::no_inplace] = true;
}
} else {
out->attrs_[mixed_partition_hint::no_inplace] = true;
}
repartition = true;
}
};
for (auto &op : parti->ops) {
// 1. check partition output buffer should not be tensoptr
for (auto &out : op->get_outputs()) {
if (parti->is_parti_out(out)) check_parti_out_tptr(out);
}
// 2. check reorder
if (auto reo = op->isa<reorder_op_t>()) {
if (!op->dyn_cast<reorder_op_t>()->support_output_loop()
|| op->get_inputs()[0]->uses_.size() == 1) {
continue;
}
auto tunable_users = search_tuneop_linearly(op);
// mark this kind of reorder to do pre-op fusion during
// repartition stage
if (tunable_users && !parti->contains(tunable_users.get())) {
op->attrs_[op_attr_key::break_pre_fuse] = true;
repartition = true;
// the input of this reorder will be the new output of
// partition, check tptr in advance to reduce repartition times
check_parti_out_tptr(op->get_inputs()[0]);
}
}
}
return repartition;
}
bool mixed_parti_t::contain_input_anchor() const {
if (merged_to) { return get_root()->contain_input_anchor(); }
return std::any_of(fanchors_.begin(), fanchors_.end(),
[](const fuse_anchor_map_ptr &anchor) {
return anchor->is_input_anchor();
});
}
static mixed_parti_t::ptr try_execute_pre_op_fusion(const context_ptr &ctx,
const sc_op_ptr &op,
std::vector<mixed_parti_t::ptr> &avaliable_input_parti) {
mixed_parti_t::ptr parent_partition = nullptr;
// only suitable for tunable op
if (!op->isa<tunable_op_t>()) return parent_partition;
if (ctx->flags_.opt_level_ == sc_opt_level::lv1) {
return parent_partition;
}
// collect reorder parti
std::vector<mixed_parti_t *> reo_parti;
for (auto &inp_parti : avaliable_input_parti) {
if (inp_parti->get_ops_size() == 1
&& inp_parti->contain_op_with_type<reorder_op_t>()) {
reo_parti.emplace_back(inp_parti->get_root());
}
}
if (reo_parti.empty()) return parent_partition;
// create tunable partition for possible input fusion anchor
parent_partition = std::make_shared<mixed_parti_t>(
reo_parti[0]->ctx_, op, reo_parti[0]->dep_m_);
if (!parent_partition->contain_input_anchor()) {
parent_partition->clear();
return nullptr;
}
// search input anchor for reorder op
for (auto &rparti : reo_parti) {
auto reo = rparti->committed_ops_[0];
bool input_anchor_found = false;
for (auto &fanchor : parent_partition->fanchors_) {
// only search input anchor
if (!fanchor->is_input_anchor()) continue;
// check output of reorder
auto reo_out = reo->get_outputs()[0], reo_in = reo->get_inputs()[0];
if (!fanchor->fsmap_.hasvalue(reo_out)) continue;
fslice_map tmp_fsmap;
// copy to tmp fsmap
tmp_fsmap.get(reo_out) = fanchor->fsmap_.get(reo_out);
infer_status_map_t stat_map(parent_partition->ctx_, false);
reo->stc_cast<fusible_op_t>()->pre_slice_ranges(
tmp_fsmap, stat_map);
if (stat_map.is_ok()) {
input_anchor_found = true;
fanchor->fsmap_.get(reo_in) = tmp_fsmap.get(reo_in);
}
}
if (input_anchor_found) {
// set pre-op fusion attr
reo->attrs_.set(mixed_partition_hint::pre_fuse_begin_op, true);
// pre fuse reorder
parent_partition->add(reo);
// remove pre-op fusion attr
reo->attrs_.remove(mixed_partition_hint::pre_fuse_begin_op);
// clear origin parti
rparti->clear();
// reset root pointer
rparti->merged_to = parent_partition;
}
}
if (parent_partition->get_ops_size() == 1) {
parent_partition->clear();
// reset
parent_partition = nullptr;
} else {
auto &ops = parent_partition->committed_ops_;
auto old_op = std::move(ops.front());
ops.erase(ops.begin());
ops.emplace_back(std::move(old_op));
}
return parent_partition;
}
static mixed_parti_t::ptr try_execute_post_op_fusion(const context_ptr &ctx,
const sc_op_ptr &op,
std::vector<mixed_parti_t::ptr> &avaliable_input_parti) {
mixed_parti_t::ptr parent_partition = nullptr;
// try to preop merge the partitons of all inputs in advance
for (auto &inp_parti : avaliable_input_parti) {
if (!parent_partition) {
parent_partition = inp_parti;
} else if (!parent_partition->empty() && !inp_parti->empty()) {
COMPILE_ASSERT(op->isa<op_traits::mixed_partition_acceptable>(),
"Unexpected op type find: " << op->op_name_)
op->dyn_cast<op_traits::mixed_partition_acceptable>()
->search_anchor(parent_partition.get());
op->dyn_cast<op_traits::mixed_partition_acceptable>()
->search_anchor(inp_parti.get());
if (ctx->flags_.opt_level_ == sc_opt_level::lv1) { continue; }
if (parent_partition->ready_for_op(op.get())
&& inp_parti->ready_for_op(op.get())) {
// the difference between later partition merge with
// joint op is that current merge need to check
// partition connection to ensure legality.
try_merge_brgemm_and_preop_parti(
parent_partition.get(), inp_parti.get(), nullptr);
}
}
}
// reset parent partition
parent_partition = nullptr;
// try to add op to input partition
for (auto &inp_parti : avaliable_input_parti) {
if (inp_parti->is_ok_to_add(op.get())) {
if (parent_partition) {
try_merge_mixed_parti_with_joint_op(
parent_partition, inp_parti, op);
parent_partition = std::static_pointer_cast<mixed_parti_t>(
parent_partition->get_root()->shared_from_this());
} else {
parent_partition = inp_parti;
// Do not merge input partition according hint
if (op->attrs_.get_or_else(
mixed_partition_hint::no_gather_op, false))
break;
}
}
}
if (parent_partition) {
if (!parent_partition->get_root()->add(op)) {
// set no gather input partition hint
op->attrs_.set(mixed_partition_hint::no_gather_op, true);
}
}
return parent_partition;
}
bool do_partition(const context_ptr &ctx, sc_graph_t &g,
std::vector<mixed_parti_t::ptr> &op_2_partition) {
// validate partition
bool repartition = false;
// a speculative DFS visitor
op_visitor_t visitor
= op_visitor_t::dfs_topology_speculative_sort(g.ops_.size());
visitor.visit_graph(g, [&](op_visitor_t *visitor, const sc_op_ptr &op) {
if (op->isa<input_op>() || op->isa<output_op>()) return;
mixed_parti_t::ptr parent_partition = nullptr;
if (op->attrs_.get_or_else(op_attr_key::no_fuse, false)) {
SC_MODULE_INFO << op->op_name_ << "_" << op->logical_op_id_
<< " is marked as no fuse";
} else {
if (!op->attrs_.get_or_else(op_attr_key::break_pre_fuse, false)) {
std::vector<mixed_parti_t::ptr> avaliable_input_parti;
// collect avaliable input partition
auto sorted_inputs = get_sorted_inputs_by_layout_input(op);
for (auto &in : sorted_inputs) {
// if an input is fusible and is not "break_post_fuse"
if (!in->producer_owner_->attrs_.get_or_else(
op_attr_key::break_post_fuse, false)
&& !in->producer_owner_->attrs_.get_or_else(
op_attr_key::no_fuse, false)
&& in->producer_owner_->attrs_.get_or_else(
"constant", const_kind::not_const)
== const_kind::not_const) {
auto &cur_in_partition
= op_2_partition[in->producer_owner_
->logical_op_id_];
if (cur_in_partition)
avaliable_input_parti.emplace_back(
cur_in_partition);
} else if (in->producer_owner_->attrs_.get_or_else(
op_attr_key::break_post_fuse, false)) {
SC_MODULE_INFO << op->op_name_ << "_"
<< op->logical_op_id_
<< " fail to add partition because it "
"is marked as break post fuse";
}
}
// try pre op fusion
parent_partition = try_execute_pre_op_fusion(
ctx, op, avaliable_input_parti);
if (!parent_partition) {
// try post op fusion
parent_partition = try_execute_post_op_fusion(
ctx, op, avaliable_input_parti);
}
} else {
SC_MODULE_INFO << op->op_name_ << "_" << op->logical_op_id_
<< " fail to add partition because it is marked "
"as break pre fuse";
}
}
if (!parent_partition || !parent_partition->contains(op.get())) {
// op was not added into parent partition, usually after unexpected
// input partition merge, as the result, set repatition flag to
// trigger next round of partition from the view of performance.
if (parent_partition && !parent_partition->contains(op.get())) {
repartition = true;
}
parent_partition = std::make_shared<mixed_parti_t>(
ctx, op, std::make_shared<op_dep_matrix_t>(g));
}
op_2_partition[op->logical_op_id_] = parent_partition;
});
for (auto &parti : op_2_partition) {
if (parti) {
parti = std::static_pointer_cast<mixed_parti_t>(
parti->get_root()->shared_from_this());
}
}
// collect parti set
auto parti_set = collect_parti_set(op_2_partition);
// assign checker
auto checker = &check_repartition;
std::for_each(parti_set.begin(), parti_set.end(),
[&checker, &repartition](const mixed_parti_t::ptr &parti) {
if ((*checker)(parti)) repartition = true;
});
if (repartition) {
SC_MODULE_INFO << "================ Repartition the whole graph "
"================";
}
return !repartition;
}
bool mixed_parti_t::validate_optimization() const {
return buf_alloc_.validate_tsr2var();
}
bool mixed_parti_t::can_optimize_outer_loop(bool allow_tensorview) const {
if (merged_to) {
return get_root()->can_optimize_outer_loop(allow_tensorview);
}
bool for_reduce = contain_op_with_type<op_traits::maybe_split_optimized_t>()
&& std::all_of(ops.begin(), ops.end(),
[&](const sc_op_ptr &op) {
if (op->isa<movement_op_t>()) {
if (op->isa<tensor_view_op_t>()
&& allow_tensorview) {
return is_parti_out(op->get_outputs()[0])
|| is_parti_inp(op->get_inputs()[0]);
} else if (op->isa<reorder_op_t>()) {
return op->attrs_.get_or_else(
op_attr_key::no_fuse, false);
} else {
return false;
}
} else {
return is_elementwise_op(op.get())
|| op->isa<reduce_op_t>()
|| op->isa<reduce_collect_op_t>()
|| (op->isa<reduce_compute_op_t>()
&& !op->stc_cast<
reduce_compute_op_t>()
->is_partial_reduce());
}
})
&& std::any_of(ops.begin(), ops.end(), [&](const sc_op_ptr &op) {
std::vector<int> rd_axis;
if (auto rd_op = op->dyn_cast<reduce_op_t>()) {
rd_axis = rd_op->get_rd_axis();
} else if (auto rd_op
= op->dyn_cast<reduce_compute_op_t>()) {
rd_axis = rd_op->get_rd_axis();
} else {
return false;
}
std::sort(rd_axis.begin(), rd_axis.end());
int cur = (op->get_inputs()[0]
->details_.get_blocking_dims()
.size()
- rd_axis.size());
/** E.g
* - reduce input dims: [32,64,16,16]
* - rd_axis: [2,3]
* It is unecessary to optimize outer loop for this kind
* of reduce op
* */
for (auto &ax : rd_axis) {
if (ax != cur) return true;
cur++;
}
return false;
});
bool for_pooling = contain_op_with_type<pooling_op_t>()
&& std::all_of(ops.begin(), ops.end(), [&](const sc_op_ptr &op) {
return (!op->isa<movement_op_t>() || op->isa<padding_op_t>())
&& !op->isa<tunable_op_t>();
});
return !is_optimized() && (for_reduce || for_pooling);
}
static bool try_optimize_reduce(mixed_parti_t *parti, sc_graph_t &sub_graph,
const std::unordered_map<sc_op_ptr, sc_op_ptr> &graph2orig_ops) {
// currently disable reduce optimization in dynamic
if (!parti->contain_op_with_type<op_traits::maybe_split_optimized_t>()
|| sub_graph.is_dynamic())
return false;
bool redo = false;
auto ctx = parti->ctx_;
auto outer_loops = parti->get_outer_loops();
// if parti contains nested parallel for, it could not be ensured that the
// inner loop is not parallel
bool nested_parallel_found = parti->contain_nested_parallel_for();
// calculate least loop size which satisfies parallelism
size_t parallel_least_size = 0;
if (!outer_loops.empty()) {
for (parallel_least_size = 1; parallel_least_size < outer_loops.size();
parallel_least_size++) {
if (evaluate_loop_parallel_balance({outer_loops.begin(),
outer_loops.begin() + parallel_least_size})
== 1.0f) {
break;
}
}
}
// If parallel loop can be ensured in advanced
if (parallel_least_size > 0) {
std::unordered_set<op_traits::maybe_split_optimized_t *>
splited_reduce_set;
parti->ax_binder_.run(parallel_least_size);
for (auto &op : sub_graph.ops_) {
if (auto red_op
= op->dyn_cast<op_traits::maybe_split_optimized_t>()) {
if (!red_op->can_split_op()) continue;
if (auto rd_op = op->dyn_cast<reduce_op_t>()) {
if (!nested_parallel_found)
splited_reduce_set.insert(red_op);
continue;
} else if (auto rd_op = op->dyn_cast<reduce_compute_op_t>()) {
COMPILE_ASSERT(rd_op->is_partial_reduce(),
"Only partial reduce is expected")
if (nested_parallel_found) {
splited_reduce_set.insert(red_op);
continue;
}
auto rd_axis = rd_op->get_rd_axis();
// transform to plain rd axis
rd_axis = transform_axis_blocking2plain(
op->get_inputs()[0]->details_, rd_axis);
rd_axis.erase(rd_axis.begin());
// find original reduce op in partition
auto orig_iter = graph2orig_ops.find(op);
if (orig_iter == graph2orig_ops.end()) continue;
auto &rd_binding_axis = parti->ax_binder_.bd_ax_map_.get(
orig_iter->second->get_inputs()[0]);
if (rd_binding_axis.empty()) continue;
// If all of `rd_axis` would not appear on parallel
// outer loops
if (std::all_of(rd_binding_axis.begin(),
rd_binding_axis.end(),
[&rd_axis](const std::vector<int> &bd_ax) {
return std::all_of(bd_ax.begin(),
bd_ax.end(),
[&rd_axis](const int &ax) {
return std::all_of(
rd_axis.begin(),
rd_axis.end(),
[&ax](const int &
rd_ax) {
return ax != rd_ax;
});
});
})) {
splited_reduce_set.insert(red_op);
}
} else {
COMPILE_ASSERT(
0, "Unexpected kind of op found: " << op->op_name_)
}
}
}
// If split reduce op exist
for (auto &red_op : splited_reduce_set) {
auto op = dynamic_cast<sc_op *>(red_op);
reduce_operator rd_type;
// check padding except for reduce add
if (auto rd_op = op->dyn_cast<reduce_op_t>()) {
rd_type = rd_op->get_rd_op();
} else if (auto rd_op = op->dyn_cast<reduce_compute_op_t>()) {
rd_type = rd_op->get_rd_op();
} else {
COMPILE_ASSERT(
0, "Unexpected kind of op found: " << op->op_name_)
}
if (rd_type != reduce_operator::add) {
auto &plain_dims
= op->get_inputs()[0]->details_.get_plain_dims();
auto &fmt = op->get_inputs()[0]->details_.get_format();
auto blocking_dims = sc_data_format_t::get_blocking_shapes(
plain_dims, fmt);
auto padded_dims = sc_data_format_t::get_padded_plain_shapes(
blocking_dims, fmt);
// currently, do not support split with padding
if (plain_dims != padded_dims) continue;
}
// pre-check
if (op->isa<reduce_compute_op_t>()) {
// find original op in partition
auto orig_iter = graph2orig_ops.find(op->shared_from_this());
if (orig_iter == graph2orig_ops.end()) continue;
// get shrink info
auto slice_info = parti->buf_alloc_.get_shrinked_info(
parti->buf_alloc_.g2b_map_.get(
orig_iter->second->get_outputs()[0]));
if (slice_info.empty()) continue;
sc_dim prod = get_dims_product(
get_expr_to_dims(get_slice_shape(slice_info)));
auto tsr_simd_len = vectorize_step(
ctx, op->get_inputs()[0]->details_.dtype_.type_code_);
if (!check_tsr_len_under_resigter_size(prod, tsr_simd_len))
continue;
}
// Do split
red_op->split_op(ctx, sub_graph, 1);
redo = true;
}
}
return redo;
}
static bool try_optimize_concat(mixed_parti_t *parti, sc_graph_t &sub_graph) {
return parti->ctx_->flags_.concat_optimization_
&& concat_memory_planning_on_graph(sub_graph);
}
static bool try_optimize_outer_loop(mixed_parti_t *parti, sc_graph_t &sub_graph,
const std::unordered_map<sc_op_ptr, sc_op_ptr> &graph2orig_ops) {
// prepare stage
auto &ops = sub_graph.ops_;
// check reorder in partition which includes reduce op but
// exclude tunable op
if (parti->contain_op_with_type<op_traits::maybe_split_optimized_t>()
&& !parti->contain_tunable_op()
&& parti->contain_op_with_type<reorder_op_t>()) {
bool forced_reorder_axis = false;
std::unordered_set<sc_op_ptr> reo_op_set;
auto run_threads = runtime_config_t::get().get_num_threads();
for (auto &op : ops) {
if (op->is_removed_) continue;
if (op->isa<op_traits::maybe_split_optimized_t>()) {
std::vector<int> rd_axis;
if (auto rd_op = op->dyn_cast<reduce_op_t>()) {
rd_axis = rd_op->get_rd_axis();
} else if (auto rd_op = op->dyn_cast<reduce_compute_op_t>()) {
if (rd_op->is_partial_reduce()) {
forced_reorder_axis = false;
break;
}
rd_axis = rd_op->get_rd_axis();
}
auto shape = op->get_inputs()[0]->details_.get_blocking_dims();
int outer_rd_axis_size = 1;
for (int i = 0; i < *rd_axis.begin(); i++) {
outer_rd_axis_size *= shape[i];
}
if (outer_rd_axis_size < run_threads)
forced_reorder_axis = true;
} else if (op->isa<reorder_op_t>()) {
reo_op_set.insert(op);
}
}
if (forced_reorder_axis) {
std::for_each(reo_op_set.begin(), reo_op_set.end(),
[&graph2orig_ops](const sc_op_ptr &op) {
op->attrs_[op_attr_key::no_fuse] = true;
// sync origin op in partition
auto orig_iter = graph2orig_ops.find(op);
COMPILE_ASSERT(orig_iter != graph2orig_ops.end(),
"Could not find original op in partition")
orig_iter->second->attrs_[op_attr_key::no_fuse] = true;
});
}
}
// optimize loop order
if (parti->can_optimize_outer_loop()) {
for (auto &op : ops) {
if (is_elementwise_op(op.get())
|| op->isa<op_traits::maybe_split_optimized_t>()
|| op->isa<pooling_op_t>()) {
// set optimized outer loop hint
op->attrs_.set(
mixed_partition_hint::optimized_outer_loop, true);
}
}
return true;
} else {
return false;
}
}
static bool try_optimize_fusion_anchor(mixed_parti_t *parti,
const std::unordered_map<sc_op_ptr, sc_op_ptr> &graph2orig_ops) {
// auto skip
if (parti->committed_ops_.size() < 2) return false;
auto &ctx = parti->ctx_;
auto &dep_m = parti->dep_m_;
// check the op whether is the elementwise op with last dim undividable
auto elem_op_with_last_dim_undividable
= [&ctx, &parti](const sc_op_ptr &op) -> bool {
if (!is_elementwise_op(op.get())) return false;
auto committed_anchor = parti->lookup_anchor_map(op.get(), false);
if (!committed_anchor) return false;
auto gt = op->get_outputs()[0];
COMPILE_ASSERT(committed_anchor->fsmap_.hasvalue(gt),
"Unexpected case for elementwise op: " << op->op_name_ << "_"
<< op->logical_op_id_)
auto &slice_info = committed_anchor->fsmap_.get(gt);
if (slice_info.size() != 1) return false;
auto compute_shape = get_slice_shape(slice_info[0]);
if (!compute_shape.back().isa<constant>()) return false;
auto last_dim = get_expr_as_int(compute_shape.back());
// get max lanes
auto dtype = gt->details_.dtype_;
auto lanes = vectorize_step(ctx, dtype.type_code_);
return ((last_dim > lanes) && (last_dim % lanes != 0));
};
// query partition op on graph
auto query_op_on_graph = [&graph2orig_ops](const sc_op_ptr &op) {
auto iter = std::find_if(graph2orig_ops.begin(), graph2orig_ops.end(),
[&op](const std::pair<sc_op_ptr, sc_op_ptr> &kv) {
return kv.second == op;
});
COMPILE_ASSERT(
iter != graph2orig_ops.end(), "Could not find mapping op")
return iter->first;
};
// set hint about fusion anchor
auto set_hint = [](std::vector<sc_op_ptr> &ops) -> bool {
if (ops.size() > 1) {
for (auto &op : ops) {
op->attrs_.set(mixed_partition_hint::split_anchor_op, true);
}
ops.clear();
return true;
}
return false;
};
bool redo = false;
std::vector<sc_op_ptr> target_ops;
// visit sorted commit ops
for (auto &op : parti->committed_ops_) {
if (target_ops.empty() && elem_op_with_last_dim_undividable(op)) {
// lookup commited anchor
auto &committed_anchor = *parti->lookup_anchor_map(op.get());
if (typeid(committed_anchor) == typeid(fuse_anchor_map_t)) {
target_ops.emplace_back(query_op_on_graph(op));
}
} else if (!target_ops.empty()) {
auto first_op
= graph2orig_ops.find(target_ops.front())->second.get();
// successive elementwise op and same anchor with first op and have
// dependency with last target op
if (elem_op_with_last_dim_undividable(op)
&& (parti->lookup_anchor_map(first_op)
== parti->lookup_anchor_map(op.get()))
&& dep_m->lookup(target_ops.back(), op) == 1) {
target_ops.emplace_back(query_op_on_graph(op));
continue;
} else if (parti->lookup_anchor_map(first_op)
== parti->lookup_anchor_map(op.get(), false)
&& !target_ops.empty()) {
target_ops.clear();
// replace first op
if (elem_op_with_last_dim_undividable(op)) {
target_ops.emplace_back(query_op_on_graph(op));
}
}
// double-check redo flag
redo |= set_hint(target_ops);
}
}
// if the first op still exists utils loop ends
redo |= set_hint(target_ops);
return redo;
}
bool try_optimize_parti(mixed_parti_t *parti, sc_graph_t &sub_graph,
const std::unordered_map<sc_op_ptr, sc_op_ptr> &graph2orig_ops) {
if (sub_graph.is_dynamic()) { return false; }
// skip already optimized parti
if (parti->is_optimized()) return false;
bool need_optimize = false;
// optimize reduce
need_optimize |= try_optimize_reduce(parti, sub_graph, graph2orig_ops);
// optimize concat
need_optimize |= try_optimize_concat(parti, sub_graph);
// optimize loop order
need_optimize |= try_optimize_outer_loop(parti, sub_graph, graph2orig_ops);
// optimize fusion anchor
need_optimize |= try_optimize_fusion_anchor(parti, graph2orig_ops);
if (need_optimize) {
sub_graph.attrs_.set(mixed_partition_hint::optimized_sub_graph, true);
}
return need_optimize;
}
static std::string get_graph_name(const sc_graph_t &graph) {
std::string ret;
for (auto &op : graph.ops_) {
if (op->isa<input_op>() || op->isa<output_op>()
|| op->isa<constant_op_t>())
continue;
if (!ret.empty()) ret += "_";
ret += op->op_name_;
}
return ret;
}
static std::string get_parti_prefix(const mixed_parti_t &parti) {
std::string prefix;
if (parti.ops.size() > 1) {
prefix = "partition_";
auto outer_loops = parti.get_outer_loops();
if (!outer_loops.empty()) {
prefix = "outerloop_" + print_loops_range(outer_loops) + "_"
+ prefix;
}
}
return prefix;
}
static void search_first_prefetch_op(mixed_parti_t &parti) {
for (const auto &op : parti.committed_ops_) {
if (op->isa<tunable_op_t>() && op->isa<op_traits::may_prefetch_t>()) {
op->attrs_[mixed_partition_hint::first_prefetch_op] = true;
break;
}
}
}
std::shared_ptr<mixed_fuse_op_t> mixed_parti_t::transform_to_mixed_op() {
COMPILE_ASSERT(!empty(), "Could not transform empty partition")
// Get original graph
auto &g = get_host_graph();
// Make sub graph
sc_graph_t sub_graph;
sub_graph.sync_dynamic_info_with_graph(g);
std::vector<graph_tensor_ptr> fused_op_in, fused_op_out;
std::vector<expr> arg_ins, arg_out;
std::string op_name;
// the mapping for original op to op in sub graph
std::unordered_map<sc_op_ptr, sc_op_ptr> graph2orig_ops;
// the mapping for original LT in original ops to fuse => the LT in the
// sub_graph.
std::unordered_map<graph_tensor_ptr, graph_tensor_ptr> orig_2_graph;
auto get_or_create_graph_tsr = [&](const graph_tensor_ptr &orig_lr) {
auto itr = orig_2_graph.find(orig_lr);
if (itr != orig_2_graph.end()) { return itr->second; }
auto ret = std::make_shared<graph_tensor>(nullptr, orig_lr->details_);
orig_2_graph.insert(std::make_pair(orig_lr, ret));
return ret;
};
auto visitor = op_visitor_t::dfs_topology_sort(g.ops_.size());
std::unordered_set<graph_tensor_ptr> input_tsr_set;
// search first prefetch op of original graph and set attr on it
search_first_prefetch_op(*this);
// visit original graph
visitor.visit_graph(g, [&](op_visitor_t *visitor, const sc_op_ptr &op) {
if (ops.find(op) == ops.end()) { return; }
std::vector<graph_tensor_ptr> new_graph_in, new_graph_ou;
for (auto &in : op->get_inputs()) {
new_graph_in.emplace_back(get_or_create_graph_tsr(in));
if (is_parti_inp(in)
&& input_tsr_set.find(in) == input_tsr_set.end()) {
// if the input is not included in the parti, make an input
// node
auto new_input_op = sub_graph.make_input({new_graph_in.back()});
// inherit constant attr for input if necessary
if (in->producer_owner_->attrs_.has_key("constant")) {
new_input_op->attrs_.set("constant",
in->producer_owner_->attrs_.get<int>("constant"));
}
// add the input in the args of the fused op in orig
// sub_graph
fused_op_in.emplace_back(in);
input_tsr_set.insert(in);
COMPILE_ASSERT(buf_alloc_.g2b_map_.haskey(in),
"No buffer allocated for " << op->op_name_ << "_"
<< op->logical_op_id_
<< " inputs")
arg_ins.emplace_back(buf_alloc_.g2b_map_.get(in));
}
}
for (auto &out : op->get_outputs()) {
new_graph_ou.emplace_back(get_or_create_graph_tsr(out));
// if the output is a "cut" - an edge across the parti and
// outside of the parti; or if concat optimization is enabled:
if (is_parti_out(out)
|| (ctx_->flags_.concat_optimization_
&& op->isa<concat_op_t>()
&& op->attrs_.get_or_else(
concat_optim_attr_keys::is_final_concat,
false))) {
// if there is a use outside of the parti, the tensor should
// be marked "output"
const auto &outtsr = new_graph_ou.back();
auto new_out_op = sub_graph.make_output({outtsr});
// make a new output tensor for the fused_op_t in the
// original sub_graph
fused_op_out.emplace_back(
std::make_shared<graph_tensor>(nullptr, out->details_));
// save the mapping of the tensor to be replaced => new
// tensor
output_replace_map[out] = fused_op_out.back();
COMPILE_ASSERT(buf_alloc_.g2b_map_.haskey(out),
"No buffer allocated for " << op->op_name_ << "_"
<< op->logical_op_id_
<< " outputs")
auto out_buffer = buf_alloc_.g2b_map_.get(out);
// if outbuffer is already reused, set attr on output op
if (out_buffer->attr().has_key(
attr_keys::tensor_inplace_hint)) {
new_out_op->attrs_.set("buffer_already_reused", true);
}
arg_out.emplace_back(out_buffer);
}
}
auto copyable = op->dyn_cast<op_traits::copyable_t>();
assert(copyable);
auto copied = copyable->copy(new_graph_in, new_graph_ou, sub_graph);
copied->copy_dispatch_key_set_from_op(op);
graph2orig_ops.insert(std::make_pair(copied, op));
// build the fused op name
if (!op_name.empty()) op_name += '_';
op_name += copied->op_name_;
});
// copy graph in avoid of redo fall-back case
auto copied_grpah = copy_graph(sub_graph);
if (try_optimize_parti(this, sub_graph, graph2orig_ops)) {
SC_MODULE_INFO << "Optimizing mixed partition for current pattern: "
<< func_->name_;
// copy optimized sub graph
auto copied_opt_grpah = copy_graph(sub_graph);
// redo mixed partition with setting hint
do_mixed_partition(ctx_, sub_graph);
bool fall_back = false;
std::vector<mixed_parti_t::ptr> parti_list;
std::string mx_op_name;
bool non_mixed_op_exist = false;
// redo validation stage
for (auto &op : sub_graph.ops_) {
if (op->isa<input_op>() || op->isa<output_op>()
|| op->isa<constant_op_t>())
continue;
if (!mx_op_name.empty()) mx_op_name += "_";
if (auto mx_op = op->dyn_cast<mixed_fuse_op_t>()) {
COMPILE_ASSERT(mx_op->parti_list_.size() == 1,
"Unexpected partition size found: "
<< mx_op->parti_list_.size())
if (!mx_op->parti_list_[0]->validate_optimization()) {
// reset
fall_back = true;
SC_MODULE_INFO << "invalid optimized reduce detected, "
"fall-back "
"to original pattern";
break;
}
parti_list.emplace_back(mx_op->parti_list_[0]);
mx_op_name += get_graph_name(mx_op->sub_graph_);
} else {
if (op->isa<reduce_collect_op_t>()) {
fall_back = true;
SC_MODULE_INFO << "reduce collect op must be fused with "
"reduce compute op, fall-back "
"to original pattern";
break;
}
if (!op->isa<tensor_view_op_t>()) non_mixed_op_exist = true;
mx_op_name += op->op_name_;
}
}
if (!fall_back) {
if (parti_list.size() == 1 && !non_mixed_op_exist) {
mx_op_name = get_parti_prefix(*parti_list[0]) + mx_op_name;
} else {
mx_op_name = "multi_partitions_" + mx_op_name;
}
std::vector<sc_op_ptr> lower_args(sub_graph.get_output_ops());
auto input_ops = sub_graph.get_input_ops();
lower_args.insert(
lower_args.end(), input_ops.begin(), input_ops.end());
auto modu = lower_graph(ctx_, sub_graph, lower_args, false);
auto main_func = modu->get_entry_func();
main_func->name_ = mx_op_name;
main_func->decl_->name_ = mx_op_name;
return std::make_shared<mixed_fuse_op_t>(mx_op_name, parti_list,
modu, copied_opt_grpah,
/*ins*/ fused_op_in,
/*outs*/
fused_op_out, any_map_t {});
} else {
// fall-back
parti_list.clear();
mx_op_name.clear();
}
}
// mark read/write buffer
graph::mark_read_or_write_buffers(arg_ins, true);
graph::mark_read_or_write_buffers(arg_out, false);
// build up final func name and param
std::vector<expr> args = arg_out, buffer_args;
args.insert(args.end(), arg_ins.begin(), arg_ins.end());
std::for_each(args.begin(), args.end(), [&g](const expr &arg) {
COMPILE_ASSERT(arg.isa<tensor>(),
"Only tensor node is expected for function argument, but "
"got " << arg)
arg->attr()[mixed_partition_hint::cut_buffer] = true;
if (g.is_dynamic()
|| g.attrs_.get_or_else("temp.parent_graph_dynamic", false)) {
arg->attr()[attr_keys::always_trans] = true;
}
});
if (dyn_inter_) {
buffer_args = args;
args.emplace_back(dyn_inter_->inter_funcs_param_);
}
func_->params_ = args;
func_->decl_->params_ = args;
if (dyn_inter_) {
assert(dyn_inter_->inter_call_.defined());
// replace output buffer of single core/internal func.
auto reset_args = [&buffer_args](std::vector<expr> &target_args,
const std::vector<expr> &extra_args) {
target_args = buffer_args;
target_args.insert(
target_args.end(), extra_args.begin(), extra_args.end());
};
reset_args(dyn_inter_->inter_call_->args_,
dyn_inter_->inter_call_extra_args_);
reset_args(dyn_inter_->inter_func_->params_,
dyn_inter_->inter_func_extra_args_);
dyn_inter_->inter_func_->decl_->params_
= dyn_inter_->inter_func_->params_;
reset_args(dyn_inter_->single_core_func_->params_,
dyn_inter_->single_core_func_extra_args_);
dyn_inter_->single_core_func_->decl_->params_
= dyn_inter_->single_core_func_->params_;
}
// buffer schedule: declare, set shrink info, tensor initilize and query
// inplace
buffer_schedule();
// clear unused fanchor, in avoid of loop fuse break
clear_fanchors();
// remove all parallel flag
remove_parallel(func_, true);
// set function name
func_->name_ = get_parti_prefix(*this) + op_name;
func_->decl_->name_ = func_->name_;
// link op name
op_name = func_->name_;
SC_MODULE_INFO << "mixed partition result:";
SC_MODULE_INFO << func_;
auto fused_op = std::make_shared<mixed_fuse_op_t>(op_name,
std::vector<mixed_parti_t::ptr> {
std::static_pointer_cast<mixed_parti_t>(
shared_from_this())},
nullptr, copied_grpah,
/*ins*/ fused_op_in,
/*outs*/
fused_op_out, any_map_t {});
return fused_op;
}
using crossover_alg
= std::function<void(const std::vector<mixed_parti_t::ptr> &parti_vec)>;
static void crossover_dispatcher(
const std::vector<mixed_parti_t::ptr> &parti_vec,
parti_merge_kind merge_kind) {
// select merger by merge kind
bool (*merger)(mixed_parti_t * A, mixed_parti_t * B);
switch (merge_kind) {
case parti_merge_kind::vertical: {
merger = try_merge_mixed_parti_vertically;
break;
}
case parti_merge_kind::horizontal: {
merger = try_merge_mixed_parti_horizontally;
break;
}
case parti_merge_kind::parallel: {
merger = try_merge_mixed_parti_parallel;
break;
}
default: COMPILE_ASSERT(0, "Unknown partition merge kind found")
}
auto op_size = parti_vec.size();
for (size_t i = 0; i < op_size; i++) {
auto parti_A = parti_vec[i];
if (!parti_A) continue;
for (size_t j = i; j < op_size; j++) {
auto parti_B = parti_vec[j];
if (!parti_B) continue;
merger(parti_A.get(), parti_B.get());
}
}
}
static void horizontal_crossover(
const std::vector<mixed_parti_t::ptr> &parti_vec) {
SC_MODULE_INFO << "Applying horizontal merge crossover algorithm...";
crossover_dispatcher(parti_vec, parti_merge_kind::horizontal);
}
static void parallel_crossover(
const std::vector<mixed_parti_t::ptr> &parti_vec) {
SC_MODULE_INFO << "Applying parallel merge crossover algorithm...";
crossover_dispatcher(parti_vec, parti_merge_kind::parallel);
}
static void vertical_crossover(
const std::vector<mixed_parti_t::ptr> &parti_vec) {
SC_MODULE_INFO << "Applying vertical merge crossover algorithm...";
crossover_dispatcher(parti_vec, parti_merge_kind::vertical);
}
static void crossover_partition(std::vector<mixed_parti_t::ptr> &op_2_partition,
const std::vector<crossover_alg> &algs) {
std::vector<mixed_parti_t::ptr> parti_vec
= collect_parti_set(op_2_partition);
for (auto &al : algs) {
al(parti_vec);
}
for (auto &parti : op_2_partition) {
if (parti) {
parti = std::static_pointer_cast<mixed_parti_t>(
parti->get_root()->shared_from_this());
}
}
}
static expr merge_fusion_condition_by_parti_list(
const std::vector<mixed_parti_t::ptr> &partis) {
auto parti_set = collect_parti_set(partis);
expr ret = false;
for (auto &parti : parti_set) {
if (parti) { ret = ret || parti->get_fusion_policy_condition(); }
}
return ret;
}
void do_mixed_partition(const context_ptr &ctx, sc_graph_t &graph) {
auto op_size = graph.ops_.size();
// mapping from op id => partition
std::vector<mixed_parti_t::ptr> op_2_partition;
// set max iter times
constexpr int maxiter = 3;
// dynamic policy condition
expr fusion_policy_condition = false;
for (int i = 0; i < maxiter; i++) {
op_2_partition.clear();
op_2_partition.resize(op_size);
bool ret = do_partition(ctx, graph, op_2_partition);
auto cur_cond = merge_fusion_condition_by_parti_list(op_2_partition);
fusion_policy_condition = fusion_policy_condition || cur_cond;
if (ret)
break;
else if (i == maxiter - 1) {
SC_MODULE_INFO << "mixed partition exceed max iteration times, "
"please enlarge limitation and try again";
return;
}
}
graph.attrs_.set("temp.fusion_policy_condition", fusion_policy_condition);
if (ctx->flags_.opt_level_ >= sc_opt_level::lv3) {
std::vector<crossover_alg> algs = {
horizontal_crossover, parallel_crossover, vertical_crossover};
crossover_partition(op_2_partition, algs);
}
std::vector<sc_op_ptr> fused_ops;
for (auto &parti : op_2_partition) {
if (!parti || !parti->output_replace_map.empty() || parti->empty()
|| parti->ops.size() == 1) {
// if a partition has been processed or it is empty or single op,
// skip it.
continue;
}
auto fused_op = parti->transform_to_mixed_op();
fused_op->attrs_[mixed_partition_hint::parti]
= std::weak_ptr<mixed_parti_t>(parti);
fused_ops.emplace_back(fused_op);
}
std::unordered_map<graph_tensor_ptr, graph_tensor_ptr> tsr_replace_map;
for (auto &fused_op : fused_ops) {
auto partition = fused_op->attrs_[mixed_partition_hint::parti]
.get<std::weak_ptr<mixed_parti_t>>()
.lock();
assert(partition);
fused_op->attrs_.remove(mixed_partition_hint::parti);
for (auto &old_new : partition->output_replace_map) {
auto &old = old_new.first;
auto &newv = old_new.second;
old->replace_with(newv);
assert(tsr_replace_map.find(old) == tsr_replace_map.end());
tsr_replace_map.insert(old_new);
}
for (auto &in : fused_op->info_.inputs_) {
// if an input is replaced by other fused_op node, update it
auto itr = tsr_replace_map.find(in);
if (itr != tsr_replace_map.end()) { in = itr->second; }
}
graph.add(fused_op);
for (auto &op : partition->ops) {
op->remove();
}
// no main op is expected
assert(!partition->main_tunable_op);
}
graph.reset_op_ids();
}
void mixed_partition(sc_graph_t &graph, const context_ptr &ctx) {
if (!graph.attrs_.get_or_else("temp.fuse", 1)) { return; }
SC_MODULE_INFO << "Starting Mixed Partition...";
do_mixed_partition(ctx, graph);
}
} // namespace gc
} // namespace graph
} // namespace impl
} // namespace dnnl
|
7c9e613254c5192b7e7fe89af10682c9dd0f62a4 | 49bae5d7b641d32dd09c207253b3269db8dcf2b3 | /libs/level5/tacticalmap/stitcher.cpp | 2fab0f9a8a1959a3b1c627eadf371493149b2876 | [] | no_license | DeanoC/old_wyrd | 744702f2157894dce4eca6dfdb1895bd3c7b1cb6 | 97cb85b5d756adbef4c899e72c4e121f049e6ec3 | refs/heads/master | 2020-07-26T20:12:26.167716 | 2019-01-08T13:44:00 | 2019-01-08T13:44:00 | 208,752,240 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,938 | cpp | stitcher.cpp | #include "stitcher.h"
#include <unordered_map>
#include <algorithm>
Math::vec3 TacticalMapStitcher::rotateVector(Math::vec3 const& v, int rotationInDegrees_)
{
if(rotationInDegrees_ < 0)
{
rotationInDegrees_ = 360 - ((-rotationInDegrees_) % 360);
}
switch(rotationInDegrees_ % 360)
{
case 0:
return v;
case 90:
return {v.z, v.y, -v.x};
case 180:
return -v;
case 270:
return {-v.z, v.y, v.x};
default:
assert(false);
return {0, 0, 0};
}
}
Geometry::AABB TacticalMapStitcher::rotateAABB(Geometry::AABB const& v, int rotationInDegrees_)
{
if(rotationInDegrees_ < 0)
{
rotationInDegrees_ = 360 - ((-rotationInDegrees_) % 360);
}
switch(rotationInDegrees_ % 360)
{
case 0:
return v;
case 90:
return v.transform(Math::rotate(Math::identity<Math::mat4x4>(), 90.0f, Math::vec3(0, 1, 0)));
case 180:
return v.transform(Math::rotate(Math::identity<Math::mat4x4>(), 180.0f, Math::vec3(0, 1, 0)));
case 270:
return v.transform(Math::rotate(Math::identity<Math::mat4x4>(), 270.0f, Math::vec3(0, 1, 0)));
default:
assert(false);
return v;
}
}
void TacticalMapStitcher::addTacticalMapInstance(std::shared_ptr<TacticalMap const> map_, Math::vec3 const position_,
int rotationInDegrees_, int mapParcelId_)
{
instances.emplace_back(map_, position_, rotationInDegrees_, mapParcelId_);
}
std::shared_ptr<TacticalMap> TacticalMapStitcher::build()
{
// determine size of the stitched together map
static const float fmininit = std::numeric_limits<float>::max();
static const float fmaxinit = -std::numeric_limits<float>::max();
Math::vec3 totalMinExtents{fmininit, fmininit, fmininit};
Math::vec3 totalMaxExtents{fmaxinit, fmaxinit, fmaxinit};
size_t levelCount = 0;
uint32_t tacticalLevelDataSize = 0;
for(auto[map, position, rotationInDegrees, _] : instances)
{
Geometry::AABB aabb = map->getAABB();
Math::vec3 minExtent = position + aabb.getMinExtent();
Math::vec3 maxExtent = position + aabb.getMaxExtent();
totalMinExtents = Math::min(totalMinExtents, minExtent);
totalMaxExtents = Math::max(totalMaxExtents, maxExtent);
levelCount += map->levelCount;
if(tacticalLevelDataSize != 0)
{
assert(map->sizeOfTacticalLevelData == tacticalLevelDataSize);
}
tacticalLevelDataSize = std::max(tacticalLevelDataSize, map->sizeOfTacticalLevelData);
}
int width = (int) floor(totalMaxExtents.x - totalMinExtents.x);
int height = (int) floor(totalMaxExtents.z - totalMinExtents.z);
size_t const levelMemorySize = sizeof(TacticalMapTileLevel) * levelCount;
size_t const levelDataMemorySize = tacticalLevelDataSize * levelCount;
size_t const mapMemorySize = sizeof(TacticalMapTile) * width * height;
size_t const memorySize = sizeof(TacticalMap) +
levelMemorySize +
levelDataMemorySize +
mapMemorySize;
auto const bigmemory = (uint8_t*) malloc(memorySize);
auto const biglevels = (TacticalMapTileLevel*) (bigmemory + sizeof(TacticalMap));
auto const biglevelDatasByte = ((uint8_t*) biglevels) + levelMemorySize;
auto const bigmap = (TacticalMapTile*) (biglevelDatasByte + levelDataMemorySize);
std::memset(biglevels, 0, levelMemorySize);
std::memset(biglevelDatasByte, 0, levelDataMemorySize);
std::memset(bigmap, 0, mapMemorySize);
TacticalMapTileLevel* curLevels = biglevels;
uint8_t* curLevelDatasBytes = biglevelDatasByte;
TacticalMapTile* curMap = bigmap;
for(auto[map, position, rotationInDegrees, mapParcelId] : instances)
{
Geometry::AABB aabb = map->getAABB();
Math::vec3 minExtent = position + aabb.getMinExtent();
Math::vec3 maxExtent = position + aabb.getMaxExtent();
// copy level and level data
std::memcpy(curLevels, map->levels, map->levelCount * sizeof(TacticalMapTileLevel));
std::memcpy(curLevelDatasBytes, map->levelDataHeap, map->levelCount * tacticalLevelDataSize);
// relocate tiles to the correct orientation and position on the big map
// also fixup pointers from the parcel map to the new big map
Math::vec3 const bigMapPos = (minExtent - totalMinExtents);
int dsy = (int) std::floor(bigMapPos.z);
assert(dsy < height);
for(auto y = 0u; y < map->height; ++y)
{
int dsx = (int) floor(bigMapPos.x);
assert(dsx < width);
for(auto x = 0u; x < map->width; ++x)
{
TacticalMap::TileCoord_t ssx = 0;
TacticalMap::TileCoord_t ssy = 0;
Math::vec3 v{(float) x + map->getBottomLeft().x, 0, (float) y + map->getBottomLeft().y};
Math::vec3 local = rotateVector(v, rotationInDegrees);
map->worldToLocal(local, ssx, ssy);
int const si = (int) ssy * (int) map->width + (int) ssx;
int const di = (int) dsy * (int) width + (int) dsx;
TacticalMapTile const* src = &map->map[si];
TacticalMapTile* dest = &bigmap[di];
// pre fixup source check
for(auto levelChk = 0u; levelChk < src->levelCount; levelChk++)
{
auto srcLevelData = map->getLevelData(*src, levelChk);
assert(srcLevelData->levelNum == levelChk);
}
// copy it from src to dest (another check for luck)
assert((uint8_t*) dest < bigmemory + memorySize);
std::memcpy(dest, src, sizeof(TacticalMapTile));
if(dest->levelCount != 0)
{
// pre fixup check that dest came over okay
auto curLevel = curLevels[dest->levelStartIndex];
auto curLevelData = (TacticalMapLevelDataHeader*) (curLevelDatasBytes +
(dest->levelStartIndex * tacticalLevelDataSize));
assert(curLevelData->levelNum == 0);
// do the fixup
dest->levelStartIndex = uint32_t(curLevels - biglevels) + dest->levelStartIndex;
for(auto levelChk = 0u; levelChk < dest->levelCount; levelChk++)
{
auto dstLevelDataBytes = biglevelDatasByte +
((dest->levelStartIndex + levelChk) * tacticalLevelDataSize);
auto dstLevelData = (TacticalMapLevelDataHeader*) dstLevelDataBytes;
dstLevelData->instance = mapParcelId;
// post fixup check
assert(dstLevelData->levelNum == levelChk);
}
}
dsx++;
}
dsy++;
}
curLevels += map->levelCount;
curLevelDatasBytes += map->levelCount * tacticalLevelDataSize;
}
TacticalMap* tmap = new(bigmemory) TacticalMap();
tmap->width = width;
tmap->height = height;
tmap->levelCount = (uint32_t) levelCount;
tmap->bottomLeft = {totalMinExtents.x, totalMinExtents.z};
tmap->minHeight = totalMinExtents.y;
tmap->maxHeight = totalMaxExtents.y;
tmap->sizeOfTacticalMapTile = sizeof(TacticalMapTile);
tmap->sizeOfTacticalMapTileLevel = sizeof(TacticalMapTileLevel);
tmap->sizeOfTacticalLevelData = tacticalLevelDataSize;
char* tname = (char*) malloc(name.size() + 1);
std::memcpy(tname, name.data(), name.size());
tname[name.size()] = '\0';
tmap->name = tname;
tmap->levels = biglevels;
tmap->map = bigmap;
tmap->levelDataHeap = biglevelDatasByte;
return std::shared_ptr<TacticalMap>(
tmap,
[](TacticalMap* ptr)
{
if(ptr) free((void*) ptr->name);
free(ptr);
});
} |
5e016e7e9cff00e5e65164e86c45f7ed8a21a662 | 89f65a23452b37d3673c45c143694c6015b3e35f | /DesktopIconAssistant/DesktopDlg.cpp | 309c239d5d013c1e1f4d402c2b645ca65e1608ce | [
"MIT"
] | permissive | yang123vc/DesktopIconAssistant | 2dd9c7bf6233a9e96598b8e144f089f3a54c7717 | eede495380194abf1fd8bf4ae14e8eddcf1ccd5b | refs/heads/master | 2020-12-11T01:40:00.824367 | 2012-10-22T15:41:01 | 2012-10-22T15:41:01 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 8,350 | cpp | DesktopDlg.cpp | // DesktopDlg.cpp : implementation file
//
#include "stdafx.h"
#include "global.h"
#include "DesktopIconAssistant.h"
#include "DesktopIconAssistantDlg.h"
#include "DesktopDlg.h"
// CDesktopDlg dialog
IMPLEMENT_DYNAMIC(CDesktopDlg, CDialog)
CDesktopDlg::CDesktopDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDesktopDlg::IDD, pParent)
, m_iToolType(NONE)
, m_bSelectArea(FALSE)
, m_iBezierPointNum(0)
{
memset(&m_ptBegin, 0 , sizeof(POINT));
memset(&m_ptEnd, 0 , sizeof(POINT));
m_bmpBg.LoadBitmap(IDB_DESKTOP_BG);
}
CDesktopDlg::~CDesktopDlg()
{
m_bmpBg.DeleteObject();
}
void CDesktopDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDOK, m_btnOK);
DDX_Control(pDX, IDCANCEL, m_btnCancel);
}
BEGIN_MESSAGE_MAP(CDesktopDlg, CDialog)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_PAINT()
ON_WM_MOUSEMOVE()
ON_WM_ERASEBKGND()
ON_BN_CLICKED(IDOK, &CDesktopDlg::OnBnClickedOk)
END_MESSAGE_MAP()
// CDesktopDlg message handlers
BOOL CDesktopDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
setFace();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDesktopDlg::setToolType(int type)
{
if (type > NONE && type <= BEZIER)
{
m_iToolType = type;
}
}
void CDesktopDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
if (!m_bSelectArea)
{
beginSelect(point);
}
else
{
endSelect(point);
}
CDialog::OnLButtonDown(nFlags, point);
}
void CDesktopDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
if (m_bSelectArea)
{
POINT pt;
pt = point;
if (MK_SHIFT & nFlags)
{
adjustPoint(&pt);
}
endSelect(pt);
}
CDialog::OnLButtonUp(nFlags, point);
}
void CDesktopDlg::drawOutline(CDC &dc)
{
// Set the pen color
CPen pen(PS_SOLID, 4, RGB(255, 0, 0));
dc.SelectObject(&pen);
dc.SelectObject(GetStockObject(NULL_BRUSH));
switch (m_iToolType)
{
case LINE:
dc.MoveTo(m_ptBegin);
dc.LineTo(m_ptEnd);
break;
case HOLLOWRECT:
// jump to case FILLRECT
case FILLRECT:
dc.Rectangle(m_ptBegin.x, m_ptBegin.y, m_ptEnd.x, m_ptEnd.y);
break;
case OVAL:
dc.Ellipse(m_ptBegin.x, m_ptBegin.y, m_ptEnd.x, m_ptEnd.y);
break;
case HEART:
RECT rct;
rct.left = min(m_ptBegin.x, m_ptEnd.x);
rct.top = min(m_ptBegin.y, m_ptEnd.y);
rct.right = max(m_ptBegin.x, m_ptEnd.x);
rct.bottom = max(m_ptBegin.y, m_ptEnd.y);
m_heart.setRect(&rct);
m_heart.draw(dc);
break;
case BEZIER:
if (m_iBezierPointNum <= 2)
{
dc.MoveTo(m_aBezierPoints[0]);
dc.LineTo(m_aBezierPoints[3]);
}
else if (m_iBezierPointNum <= 3)
{
m_aBezierPoints[2] = m_aBezierPoints[1];
dc.PolyBezier(m_aBezierPoints, 4);
}
else
{
dc.PolyBezier(m_aBezierPoints, 4);
}
break;
default:
break;
}
}
void CDesktopDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
CDC bgDC;
CRect rect;
BITMAP bit;
GetClientRect(&rect);
// load the background bitmap
m_bmpBg.GetBitmap(&bit);
bgDC.CreateCompatibleDC(&dc);
bgDC.SelectObject(&m_bmpBg);
// copy the background bitmap to the buffer dc
dc.StretchBlt(0, 0, rect.right - rect.left, rect.bottom - rect.left, &bgDC, 0, 0, bit.bmWidth, bit.bmHeight, SRCCOPY);
CString msg;
CString sFormat;
CFont mFont;
mFont.CreateFont(30, 15, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("ËÎÌå"));
dc.SetBkMode(TRANSPARENT);
sFormat.LoadString(IDS_ICONS_SELECTED);
msg.Format(sFormat, ((CDesktopIconAssistantDlg *)AfxGetApp()->m_pMainWnd)->getSelectedIconCount());
dc.SetTextColor(RGB(255, 0, 0));
dc.SelectObject(&mFont);
dc.TextOut(rect.right / 2 - 120, rect.bottom / 2, msg, msg.GetLength());
drawOutline(dc);
}
void CDesktopDlg::OnMouseMove(UINT nFlags, CPoint point)
{
if (MK_LBUTTON & nFlags)
{
if (m_bSelectArea)
{
POINT pt;
pt = point;
if (MK_SHIFT & nFlags)
{
adjustPoint(&pt);
}
if (m_iToolType == BEZIER)
{
switch(m_iBezierPointNum)
{
case 1:
m_aBezierPoints[3] = pt;
break;
case 3:
m_aBezierPoints[1] = pt;
break;
case 4:
m_aBezierPoints[2] = pt;
break;
default:
break;
}
}
else
{
m_ptEnd = pt;
}
Invalidate();
}
}
else
{
if (m_bSelectArea)
{
endSelect(m_ptEnd);
}
}
CDialog::OnMouseMove(nFlags, point);
}
void CDesktopDlg::beginSelect(POINT pt)
{
m_bSelectArea = TRUE;
if (m_iToolType == BEZIER)
{
if (m_iBezierPointNum >= 4)
m_iBezierPointNum = 1;
else
m_iBezierPointNum++;
switch(m_iBezierPointNum)
{
case 1:
m_aBezierPoints[0] = pt;
break;
case 3:
m_aBezierPoints[1] = pt;
break;
case 4:
m_aBezierPoints[2] = pt;
break;
default:
break;
}
}
else
{
m_ptBegin = pt;
}
// hide all the buttons
m_btnOK.ShowWindow(SW_HIDE);
m_btnCancel.ShowWindow(SW_HIDE);
}
void CDesktopDlg::endSelect(POINT pt)
{
m_bSelectArea = FALSE;
if (m_iToolType == BEZIER)
{
switch(m_iBezierPointNum)
{
case 1:
m_iBezierPointNum++;
m_aBezierPoints[3] = pt;
break;
case 3:
m_aBezierPoints[1] = pt;
break;
case 4:
m_aBezierPoints[2] = pt;
break;
default:
break;
}
}
else
{
m_ptEnd = pt;
}
// Show all the buttons
m_btnOK.ShowWindow(SW_SHOWNORMAL);
m_btnCancel.ShowWindow(SW_SHOWNORMAL);
// Draw the outline
Invalidate();
if (m_iToolType == BEZIER && m_iBezierPointNum == 4)
((CDesktopIconAssistantDlg *)AfxGetApp()->m_pMainWnd)->bezierSort(m_aBezierPoints);
else
((CDesktopIconAssistantDlg *)AfxGetApp()->m_pMainWnd)->toolSort(m_ptBegin, m_ptEnd, m_iToolType);
}
void CDesktopDlg::adjustPoint(LPPOINT lpPoint)
{
double dx = fabs((double)m_ptBegin.x - lpPoint->x) + EPS;
double dy = fabs((double)m_ptBegin.y - lpPoint->y) + EPS;
switch (m_iToolType)
{
case LINE:
if (dx / dy > 2)
{
lpPoint->y = m_ptBegin.y;
}
else if (dy / dx > 2)
{
lpPoint->x = m_ptBegin.x;
}
else if (dx / dy >= 0.5
&& dx / dy <= 2)
{
if (dx < dy)
{
lpPoint->y = (long)(m_ptBegin.y + (lpPoint->y - m_ptBegin.y) * dx / dy);
}
else
{
lpPoint->x = (long)(m_ptBegin.x + (lpPoint->x - m_ptBegin.x) * dy / dx);;
}
}
break;
case HOLLOWRECT:
// jump to case OVAL
case FILLRECT:
// jump to case OVAL
case OVAL:
if (dx < dy)
{
lpPoint->y = (long)(m_ptBegin.y + (lpPoint->y - m_ptBegin.y) * dx / dy);
}
else
{
lpPoint->x = (long)(m_ptBegin.x + (lpPoint->x - m_ptBegin.x) * dy / dx);
}
break;
case HEART:
if (dx * 1.082 < dy)
{
lpPoint->y = (long)(m_ptBegin.y + (lpPoint->y - m_ptBegin.y) * dx * 1.082 / dy);
}
else
{
lpPoint->x = (long)(m_ptBegin.x + (lpPoint->x - m_ptBegin.x) * dy / 1.082 / dx);
}
default:
break;
}
}
void CDesktopDlg::setFace(void)
{
// Load the OK button
m_btnOK.SetBitmaps(IDB_OK_NORMAL, 0, IDB_OK_OVER, 0, RGB(0, 0, 255));
m_btnOK.SizeToContent();
// Load the OK button
m_btnCancel.SetBitmaps(IDB_CANCEL_NORMAL, 0, IDB_CANCEL_OVER, 0, RGB(0, 0, 255));
m_btnCancel.SizeToContent();
// Get the desktop area
RECT rctDesktop;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rctDesktop, 0);
// Change the dialog size to cover the whole desktop
MoveWindow(&rctDesktop);
RECT rctClient;
GetClientRect(&rctClient);
int x = rctClient.right / 2 - 100;
int y = rctClient.bottom / 2 - 100;
// Move the buttons to the center
m_btnOK.SetWindowPos(NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
m_btnCancel.SetWindowPos(NULL, x + 60 + 30, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
// Make the dialog transparent
SetLayeredWindowAttributes(0, 200, LWA_ALPHA);
}
BOOL CDesktopDlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
return TRUE;
//return CDialog::OnEraseBkgnd(pDC);
}
void CDesktopDlg::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
OnOK();
} |
4f3a49b799e00f2ce0696d9c6c98b45d9f247882 | 7898594272a0c006ae4a04f5fde02e71f0e53949 | /engine/main.cpp | 4e9c23638596b7f78f56926c41ea16ee7cede567 | [] | no_license | albertvaka/gaem2020_gmtk | f82a97099579e810eb8c1ee58e65ded5a6900b37 | 4b93d8c0801242b40089cd2d0b402dacd401aac8 | refs/heads/master | 2022-11-17T08:25:37.650058 | 2020-07-19T00:54:36 | 2020-07-19T00:54:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,377 | cpp | main.cpp | #include "scene_manager.h"
#include "input.h"
#include "mates.h"
#include "text.h"
#include "debug.h"
#include "window.h"
#include "camera.h"
#include "../src/assets.h"
#include "../src/scene_main.h"
#include "../src/scene_intro.h"
#ifdef _IMGUI
#include "imgui.h"
#include "imgui_impl_sdl.h"
#include "imgui_impl_opengl3.h"
#endif
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
#include <SDL_mixer.h>
Scene* SceneManager::currentScene = nullptr;
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
float mainClock;
#define _FPS_COUNTER
Scene* currentScene;
Text* txt_fps;
int fps_counter = 0;
float fpsClock = 0.f;
bool slowDown = false;
int last_ticks;
void init();
void main_loop();
int main(int argc, char* argv[])
{
init();
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(main_loop, 0, 1);
#else
while (true) {
main_loop();
}
#endif
}
#if __WIN32__
#pragma comment(lib, "Shcore.lib")
#include <ShellScalingApi.h>
#endif
void init() {
#if __WIN32__
SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
#endif
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER) != 0) {
Debug::out << SDL_GetError();
exit(1);
}
if (TTF_Init() != 0) {
Debug::out << TTF_GetError();
}
if (Mix_Init(MIX_INIT_OGG) == 0) {
Debug::out << Mix_GetError();
}
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) != 0) {
Debug::out << Mix_GetError();
}
if (Window::Init() != 0) {
exit(1);
}
Input::Init();
#ifdef _IMGUI
ImGui::CreateContext();
ImGui_ImplSDL2_InitForOpenGL(Window::window, nullptr);
ImGui_ImplOpenGL3_Init(nullptr);
#endif
Assets::LoadAll();
srand(time(NULL));
#ifdef _FPS_COUNTER
txt_fps= new Text(Assets::font_30);
txt_fps->setString("0");
#endif
last_ticks = SDL_GetTicks();
currentScene = new SceneIntro();
SceneManager::SetScene(currentScene);
currentScene->EnterScene();
}
void main_loop() {
if (SceneManager::CurrentScene() != currentScene) {
currentScene->ExitScene();
delete currentScene;
currentScene = SceneManager::CurrentScene();
currentScene->EnterScene();
}
#ifdef _IMGUI
//GPU_ActivateShaderProgram(0, NULL);
GPU_FlushBlitBuffer(); // IMPORTANT: run GPU_FlushBlitBuffer before ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplSDL2_NewFrame(Window::window);
ImGui::NewFrame();
#endif
int ticks = SDL_GetTicks();
float dt = (ticks - last_ticks) / 1000.f;
last_ticks = ticks;
//Input
Mouse::scrollWheel = 0.f;
Window::ProcessEvents();
#ifdef _IMGUI
ImGuiIO& io = ImGui::GetIO();
if (!io.WantCaptureKeyboard)
#endif
{
Keyboard::_UpdateInputState();
}
#ifdef _IMGUI
if (!io.WantCaptureMouse)
#endif
{
Mouse::_UpdateInputState();
}
GamePad::_UpdateInputState();
Input::Update(dt);
#ifdef _DEBUG
const SDL_Scancode DEBUG_FRAME_BY_FRAME = SDL_SCANCODE_F1;
const SDL_Scancode DEBUG_FRAME_BY_FRAME_NEXT = SDL_SCANCODE_E;
const SDL_Scancode DEBUG_MODE = SDL_SCANCODE_F2;
if (Keyboard::IsKeyJustPressed(DEBUG_MODE)) {
Debug::Draw = !Debug::Draw;
}
static bool frameByFrame = false;
if (Keyboard::IsKeyJustPressed(DEBUG_FRAME_BY_FRAME)) {
frameByFrame = !frameByFrame;
}
if (frameByFrame && Debug::Draw) {
Camera::MoveCameraWithArrows(50.f, dt);
Camera::ChangeZoomWithPlusAndMinus(1.f, dt);
}
if (!frameByFrame || Keyboard::IsKeyJustPressed(DEBUG_FRAME_BY_FRAME_NEXT))
#endif
{
#ifdef _DEBUG
ClearDebugVecs();
#endif
float limited_dt = dt;
if (limited_dt > 0.06f) // less than 17 FPS
{
limited_dt = 0.06f; //Slow game down instead of epic jumps
slowDown = true;
}
mainClock += limited_dt;
currentScene->Update(limited_dt);
}
currentScene->Draw();
//(Camera::GetBounds() * 0.99f).Draw();
#ifdef _DEBUG
if (Debug::Draw) {
DrawDebugVecs();
}
#endif
//Draw GUI
Camera::GUI::Begin();
#ifdef _FPS_COUNTER
fps_counter++;
fpsClock += dt;
if (fpsClock > 0.5f)
{
txt_fps->setString(std::to_string(int(fps_counter / fpsClock)) + (slowDown ? "!" : ""));
slowDown = false;
fps_counter = 0;
fpsClock = 0;
}
Window::Draw(*txt_fps, Camera::GUI::GetBounds().TopRight() + vec(-5, 5))
.withOrigin(txt_fps->getSize().x, 0)
.withScale(0.5f);
#endif
#ifdef _IMGUI
ImGui::Render();
SDL_GL_MakeCurrent(Window::window, Window::target->context->context);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
#endif
Camera::GUI::End();
GPU_Flip(Window::target);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.